Hi Dhanushka,
Thanks for the code snippet.
Purpose is as follows.
When a username is given, want to check whether that user is in the admin
role.
The current implementation is as follows.
private static boolean isAdminUser(String username, UserRealm userRealm) {
try {
String[] userRoles =
userRealm.getUserStoreManager().getRoleListOfUser(username);
String adminRole =
userRealm.getRealmConfiguration().getAdminRoleName();
for (String userRole : userRoles) {
if (adminRole.equals(userRole)) {
return true;
}
}
} catch (UserStoreException e) {
log.error("Error while retrieving roles for user " + username,
e);
}
return false;
}
I was thinking whether there might an existing method that is already
written.
Thanks,
Hemika
Hemika Kodikara
Software Engineer
WSO2 Inc.
lean . enterprise . middleware
http://wso2.com
Mobile : +94777688882
On Mon, Jan 26, 2015 at 1:35 AM, Danushka Fernando <[email protected]>
wrote:
> Hi Hemika
> I guess there are several ways to achieve this. But better if you mention
> why and where you want this to do.
> As per Tharindu's way I guess you need a user store implementation which
> expose that outside since you need a relam config to that util. Can you
> explain why and where you need this?
> On Jan 25, 2015 9:32 AM, "Hemika Kodikara" <[email protected]> wrote:
>
>> Hi All,
>>
>> Is there an existing method in carbon to find whether a user is an admin
>> or not provided their username ?
>>
>> Regards,
>> Hemika
>>
>> Hemika Kodikara
>> Software Engineer
>> WSO2 Inc.
>> lean . enterprise . middleware
>> http://wso2.com
>>
>> Mobile : +94777688882
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev