Search in sources :

Example 61 with GluuCustomPerson

use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.

the class ConfigureCacheRefreshAction method validateInterceptorScript.

public void validateInterceptorScript() {
    String result = update();
    if (!OxTrustConstants.RESULT_SUCCESS.equals(result)) {
        return;
    }
    // Reinit dialog
    init();
    this.showInterceptorValidationDialog = true;
    boolean loadedScripts = externalCacheRefreshService.getCustomScriptConfigurations().size() > 0;
    if (!loadedScripts) {
        String message = "Can't load Cache Refresh scripts. Using default script";
        log.error(message);
        this.interceptorValidationMessage = message;
        return;
    }
    // Prepare data for dummy entry
    String targetInum = inumService.generateInums(OxTrustConstants.INUM_TYPE_PEOPLE_SLUG, false);
    String targetPersonDn = personService.getDnForPerson(targetInum);
    String[] targetCustomObjectClasses = appConfiguration.getPersonObjectClassTypes();
    // Collect all attributes
    String[] keyAttributesWithoutValues = getCompoundKeyAttributesWithoutValues(cacheRefreshConfiguration);
    String[] sourceAttributes = getSourceAttributes(cacheRefreshConfiguration);
    // Merge all attributes into one set
    Set<String> allAttributes = new HashSet<String>();
    for (String attribute : keyAttributesWithoutValues) {
        allAttributes.add(attribute);
    }
    for (String attribute : sourceAttributes) {
        allAttributes.add(attribute);
    }
    // Prepare source person entry with default attributes values
    GluuSimplePerson sourcePerson = new GluuSimplePerson();
    List<GluuCustomAttribute> customAttributes = sourcePerson.getCustomAttributes();
    for (String attribute : allAttributes) {
        customAttributes.add(new GluuCustomAttribute(attribute, "Test value"));
    }
    // Prepare target person
    GluuCustomPerson targetPerson = new GluuCustomPerson();
    targetPerson.setDn(targetPersonDn);
    targetPerson.setInum(targetInum);
    targetPerson.setStatus(appConfiguration.getSupportedUserStatus().get(0));
    targetPerson.setCustomObjectClasses(targetCustomObjectClasses);
    // Execute mapping according to configuration
    Map<String, String> targetServerAttributesMapping = getTargetServerAttributesMapping(cacheRefreshConfiguration);
    cacheRefreshService.setTargetEntryAttributes(sourcePerson, targetServerAttributesMapping, targetPerson);
    // Execute interceptor script
    boolean executionResult = externalCacheRefreshService.executeExternalUpdateUserMethods(targetPerson);
    if (!executionResult) {
        String message = "Can't execute Cache Refresh scripts.";
        log.error(message);
        this.interceptorValidationMessage = message;
        return;
    }
    log.info("Script has been executed successfully.\n\nSample source entry is:\n'{}'.\n\nSample result entry is:\n'{}'", getGluuSimplePersonAttributesWithValues(sourcePerson), getGluuCustomPersonAttributesWithValues(targetPerson));
    this.interceptorValidationMessage = String.format("Script has been executed successfully.\n\nSample source entry is:\n%s.\n\nSample result entry is:\n%s", getGluuSimplePersonAttributesWithValues(sourcePerson), getGluuCustomPersonAttributesWithValues(targetPerson));
}
Also used : GluuSimplePerson(org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson) GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) HashSet(java.util.HashSet)

Example 62 with GluuCustomPerson

use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.

the class LanguageBean method getLocaleCode.

public String getLocaleCode() {
    GluuCustomPerson gluuCustomPerson = (GluuCustomPerson) identity.getUser();
    if (gluuCustomPerson == null) {
        return null;
    }
    GluuCustomAttribute locale = getLocaleOrNull(gluuCustomPerson);
    if (locale == null) {
        return null;
    } else {
        return locale.getValue();
    }
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson)

Example 63 with GluuCustomPerson

use of org.gluu.oxtrust.model.GluuCustomPerson 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());
    }
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) UserRole(org.gluu.model.user.UserRole)

Example 64 with GluuCustomPerson

use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.

the class UpdatePersonAction method add.

/**
 * Initializes attributes for adding new person
 *
 * @return String describing success of the operation
 * @throws Exception
 */
public String add() {
    if (!organizationService.isAllowPersonModification()) {
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new person");
        conversationService.endConversation();
        return OxTrustConstants.RESULT_FAILURE;
    }
    if (this.person != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    this.update = false;
    this.person = new GluuCustomPerson();
    initAttributes(true);
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson)

Example 65 with GluuCustomPerson

use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.

the class UpdatePersonAction method userEmailIsUniqAtCreationTime.

private boolean userEmailIsUniqAtCreationTime(String email) {
    if (email == null) {
        return true;
    }
    boolean emailIsUniq = true;
    List<GluuCustomPerson> gluuCustomPersons = personService.getPersonsByEmail(email);
    if (gluuCustomPersons != null && gluuCustomPersons.size() > 0) {
        for (GluuCustomPerson gluuCustomPerson : gluuCustomPersons) {
            if (gluuCustomPerson.getAttribute(MAIL).equalsIgnoreCase(email)) {
                emailIsUniq = false;
                break;
            }
        }
    }
    return emailIsUniq;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson)

Aggregations

GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)133 ArrayList (java.util.ArrayList)42 ScimPerson (org.gluu.oxtrust.model.scim.ScimPerson)27 Test (org.testng.annotations.Test)22 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)21 ConfigurableTest (org.gluu.oxtrust.action.test.ConfigurableTest)18 Produces (javax.ws.rs.Produces)17 Response (javax.ws.rs.core.Response)17 ScimPersonGroups (org.gluu.oxtrust.model.scim.ScimPersonGroups)14 ScimPersonIms (org.gluu.oxtrust.model.scim.ScimPersonIms)14 ScimPersonPhones (org.gluu.oxtrust.model.scim.ScimPersonPhones)14 ScimPersonPhotos (org.gluu.oxtrust.model.scim.ScimPersonPhotos)14 ScimRoles (org.gluu.oxtrust.model.scim.ScimRoles)14 PersonMeta (org.gluu.oxtrust.model.scim.PersonMeta)13 ScimEntitlements (org.gluu.oxtrust.model.scim.ScimEntitlements)13 ScimName (org.gluu.oxtrust.model.scim.ScimName)13 ScimPersonAddresses (org.gluu.oxtrust.model.scim.ScimPersonAddresses)13 ScimPersonEmails (org.gluu.oxtrust.model.scim.ScimPersonEmails)13 ScimCustomAttributes (org.gluu.oxtrust.model.scim.ScimCustomAttributes)12 Scimx509Certificates (org.gluu.oxtrust.model.scim.Scimx509Certificates)12