You can authenticate user in your application using SIF (Service Integration Framework) Java API.
Following is the code you can use to authenticate the user:
Properties props = new Properties();
props.put("siperian-client.orsId", "MyORSId");
props.put("siperian-client.protocol", "http");
props.put("siperian-client.username", "MyUserName");
props.put("siperian-client.password", "MyPassword");
props.put("http.call.url", "http://MyApplicationName:MyAppPort/cmx/request");
try {
SiperianClient sipClient = SiperianClient.newSiperianClient(props);
AuthenticateRequest req = new AuthenticateRequest();
AuthenticateResponse resp = (AuthenticateResponse) sipClient.process(req);
System.out.println("User has role(s): ");
for (Object role : resp.getRoleNames())
System.out.printf("\t" + (String) role + "\n");
System.out.println("Admin? " + resp.isAdministrator());
System.out.println("External? " + resp.isExternalAuthentication());
System.out.println("Expires? " + resp.isPasswordExpires());
} catch (Exception e) {
// Login Failed
System.out.println("Login failed.");
}
Please note that you need to change following configuration in above code, you can also user properties from configuration file if available in your application:
MyORSId: ORS Id which application is using.
MyUserName Name of user which you want to authenticate, this user need to exists on MDM Hub
MyPassword Password of user matching in MDM Hub.
MyApplicationName Host on which MDM Hub is running.
MyAppPort Port on which MDM Hub is running.
0 Comment(s)