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;
}
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();
}
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();
}
Aggregations