Search in sources :

Example 1 with SAML2IdPActions

use of org.apache.syncope.core.provisioning.api.SAML2IdPActions in project syncope by apache.

the class SAML2UserManager method getActions.

private List<SAML2IdPActions> getActions(final SAML2IdPEntity idp) {
    List<SAML2IdPActions> actions = new ArrayList<>();
    idp.getActionsClassNames().forEach(className -> {
        try {
            Class<?> actionsClass = Class.forName(className);
            SAML2IdPActions idpActions = (SAML2IdPActions) ApplicationContextProvider.getBeanFactory().createBean(actionsClass, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, true);
            actions.add(idpActions);
        } catch (Exception e) {
            LOG.warn("Class '{}' not found", className, e);
        }
    });
    return actions;
}
Also used : SAML2IdPActions(org.apache.syncope.core.provisioning.api.SAML2IdPActions) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) ParsingValidationException(org.apache.syncope.core.persistence.api.attrvalue.validation.ParsingValidationException)

Example 2 with SAML2IdPActions

use of org.apache.syncope.core.provisioning.api.SAML2IdPActions in project syncope by apache.

the class SAML2UserManager method update.

@Transactional(propagation = Propagation.REQUIRES_NEW)
public String update(final String username, final SAML2IdPEntity idp, final SAML2LoginResponseTO responseTO) {
    UserTO userTO = binder.getUserTO(userDAO.findKey(username));
    UserTO original = SerializationUtils.clone(userTO);
    fill(idp.getKey(), responseTO, userTO);
    UserPatch userPatch = AnyOperations.diff(userTO, original, true);
    List<SAML2IdPActions> actions = getActions(idp);
    for (SAML2IdPActions action : actions) {
        userPatch = action.beforeUpdate(userPatch, responseTO);
    }
    Pair<UserPatch, List<PropagationStatus>> updated = provisioningManager.update(userPatch, false);
    userTO = binder.getUserTO(updated.getLeft().getKey());
    for (SAML2IdPActions action : actions) {
        userTO = action.afterUpdate(userTO, responseTO);
    }
    return userTO.getUsername();
}
Also used : SAML2IdPActions(org.apache.syncope.core.provisioning.api.SAML2IdPActions) UserTO(org.apache.syncope.common.lib.to.UserTO) ArrayList(java.util.ArrayList) List(java.util.List) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with SAML2IdPActions

use of org.apache.syncope.core.provisioning.api.SAML2IdPActions in project syncope by apache.

the class SAML2UserManager method create.

@Transactional(propagation = Propagation.REQUIRES_NEW)
public String create(final SAML2IdPEntity idp, final SAML2LoginResponseTO responseTO, final String nameID) {
    UserTO userTO = new UserTO();
    if (idp.getUserTemplate() != null) {
        templateUtils.apply(userTO, idp.getUserTemplate());
    }
    List<SAML2IdPActions> actions = getActions(idp);
    for (SAML2IdPActions action : actions) {
        userTO = action.beforeCreate(userTO, responseTO);
    }
    fill(idp.getKey(), responseTO, userTO);
    if (userTO.getRealm() == null) {
        userTO.setRealm(SyncopeConstants.ROOT_REALM);
    }
    if (userTO.getUsername() == null) {
        userTO.setUsername(nameID);
    }
    Pair<String, List<PropagationStatus>> created = provisioningManager.create(userTO, false, false);
    userTO = binder.getUserTO(created.getKey());
    for (SAML2IdPActions action : actions) {
        userTO = action.afterCreate(userTO, responseTO);
    }
    return userTO.getUsername();
}
Also used : SAML2IdPActions(org.apache.syncope.core.provisioning.api.SAML2IdPActions) UserTO(org.apache.syncope.common.lib.to.UserTO) ArrayList(java.util.ArrayList) List(java.util.List) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ArrayList (java.util.ArrayList)3 SAML2IdPActions (org.apache.syncope.core.provisioning.api.SAML2IdPActions)3 List (java.util.List)2 UserTO (org.apache.syncope.common.lib.to.UserTO)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ParseException (java.text.ParseException)1 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)1 ParsingValidationException (org.apache.syncope.core.persistence.api.attrvalue.validation.ParsingValidationException)1