Hi,
I am implementing API export feature for APIM.
I want to check whether a logged in user has admin role, because we are
going to allow only admin users to export and import APIs.
Following is the source which I tried. But
userStoreManager.authenticate(username,
password) does not authenticate tenant admins.
I get the session cookie by login using super tenant credentials.
Any help is appreciated.
Thank you.
ServiceClient serviceClient;
Options option;
RemoteUserStoreManagerServiceStub userStoreManager =
new RemoteUserStoreManagerServiceStub(null, SERVICE_URL +
"RemoteUserStoreManagerService");
serviceClient = userStoreManager._getServiceClient();
option = serviceClient.getOptions();
option.setManageSession(true);
option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING,
sessionCookie);
//Checking whether current user is authenticated and he has admin role
if (userStoreManager.authenticate(username, password)) {
String adminRoleName =
CarbonContext.getCurrentContext().getUserRealm().getRealmConfiguration()
.getAdminRoleName();
if (userStoreManager.isExistingRole(adminRoleName)) {
userName = username;
LOG.info(username + " user authenticated successfully");
return true;
}
}
--
Best Regards,
*Thilini Cooray*
Software Engineer
Mobile : +94 (0) 774 570 112 <%2B94%20%280%29%20773%20451194>
E-mail : [email protected]
WSO2 Inc. www.wso2.com
lean.enterprise.middleware
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev