Search in sources :

Example 1 with GluuUserRole

use of org.xdi.model.GluuUserRole in project oxTrust by GluuFederation.

the class SecurityService method isUseAdminUser.

public boolean isUseAdminUser(String userName) {
    try {
        User user = personService.getUserByUid(userName);
        GluuUserRole[] roles = getUserRoles(user);
        for (GluuUserRole role : roles) {
            if (GluuUserRole.MANAGER.equals(role)) {
                return true;
            }
        }
    } catch (Exception ex) {
        log.error("Failed to find user '{}' in ldap", userName, ex);
    }
    return false;
}
Also used : User(org.gluu.oxtrust.model.User) GluuUserRole(org.xdi.model.GluuUserRole)

Example 2 with GluuUserRole

use of org.xdi.model.GluuUserRole in project oxTrust by GluuFederation.

the class OxChooserWebService method postLogin.

public void postLogin(GluuCustomPerson person) throws Exception {
    log.debug("Configuring application after user '{}' login", person.getUid());
    identity.setUser(person);
    // Set user roles
    GluuUserRole[] userRoles = securityService.getUserRoles(person);
    for (GluuUserRole userRole : userRoles) {
        identity.addRole(userRole.getRoleName());
    }
}
Also used : GluuUserRole(org.xdi.model.GluuUserRole)

Example 3 with GluuUserRole

use of org.xdi.model.GluuUserRole 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 GluuUserRole[] getUserRoles(User user) {
    GluuOrganization organization = organizationService.getOrganization();
    // String ownerGroupDn = organization.getOwnerGroup();
    String managerGroupDn = organization.getManagerGroup();
    String personDN = user.getDn();
    Set<GluuUserRole> userRoles = new HashSet<GluuUserRole>();
    if (groupService.isMemberOrOwner(managerGroupDn, personDN)) {
        userRoles.add(GluuUserRole.MANAGER);
    }
    if ((userRoles.size() == 0)) /*
									 * &&
									 * (GluuStatus.ACTIVE.equals(person.getStatus
									 * ()))
									 */
    {
        userRoles.add(GluuUserRole.USER);
    }
    return userRoles.toArray(new GluuUserRole[userRoles.size()]);
}
Also used : GluuUserRole(org.xdi.model.GluuUserRole) GluuOrganization(org.gluu.oxtrust.model.GluuOrganization) HashSet(java.util.HashSet)

Aggregations

GluuUserRole (org.xdi.model.GluuUserRole)3 HashSet (java.util.HashSet)1 GluuOrganization (org.gluu.oxtrust.model.GluuOrganization)1 User (org.gluu.oxtrust.model.User)1