use of org.gluu.model.user.UserRole in project oxTrust by GluuFederation.
the class Authenticator method postLogin.
/**
* Set session variables after user login
*
* @throws Exception
*/
private void postLogin(User user) {
identity.login();
log.debug("Configuring application after user '{}' login", user.getUid());
GluuCustomPerson person = findPersonByDn(user.getDn());
identity.setUser(person);
// Set user roles
UserRole[] userRoles = securityService.getUserRoles(user);
if (ArrayHelper.isNotEmpty(userRoles)) {
log.debug("Get '{}' user roles", Arrays.toString(userRoles));
} else {
log.debug("Get 0 user roles");
}
for (UserRole userRole : userRoles) {
identity.addRole(userRole.getRoleName());
}
}
use of org.gluu.model.user.UserRole in project oxTrust by GluuFederation.
the class SecurityService method getUserRoles.
/**
* Get person user roles
*
* @param user
* Person
* @return List of roles
* @throws Exception
* exception
*/
public UserRole[] getUserRoles(User user) {
GluuOrganization organization = organizationService.getOrganization();
// String ownerGroupDn = organization.getOwnerGroup();
String managerGroupDn = organization.getManagerGroup();
String personDN = user.getDn();
Set<UserRole> userRoles = new HashSet<UserRole>();
if (groupService.isMemberOrOwner(managerGroupDn, personDN)) {
userRoles.add(UserRole.MANAGER);
}
if ((userRoles.size() == 0)) /*
* &&
* (GluuStatus.ACTIVE.equals(person.getStatus
* ()))
*/
{
userRoles.add(UserRole.USER);
}
return userRoles.toArray(new UserRole[userRoles.size()]);
}
use of org.gluu.model.user.UserRole in project oxTrust by GluuFederation.
the class SecurityService method isUseAdminUser.
public boolean isUseAdminUser(String userName) {
try {
User user = personService.getUserByUid(userName);
UserRole[] roles = getUserRoles(user);
for (UserRole role : roles) {
if (UserRole.MANAGER.equals(role)) {
return true;
}
}
} catch (Exception ex) {
log.error("Failed to find user '{}' in ldap", userName, ex);
}
return false;
}
Aggregations