use of com.evolveum.midpoint.authentication.impl.ldap.MidpointPrincipalContextMapper in project midpoint by Evolveum.
the class LdapModuleFactory method getProvider.
private AuthenticationProvider getProvider(LdapAuthenticationModuleType moduleType) {
DefaultSpringSecurityContextSource ctx = new DefaultSpringSecurityContextSource(moduleType.getHost());
ctx.setUserDn(moduleType.getUserDn());
try {
ctx.setPassword(protector.decryptString(moduleType.getUserPassword()));
} catch (EncryptionException e) {
LOGGER.error("Couldn't obtain clear string for configuration of LDAP user password from " + moduleType.getUserPassword());
}
getObjectObjectPostProcessor().postProcess(ctx);
BindAuthenticator auth = new BindAuthenticator(ctx);
if (StringUtils.isNotEmpty(moduleType.getDnPattern())) {
auth.setUserDnPatterns(new String[] { moduleType.getDnPattern() });
}
if (moduleType.getSearch() != null) {
FilterBasedLdapUserSearch search = new FilterBasedLdapUserSearch("", moduleType.getSearch().getPattern(), ctx);
if (moduleType.getSearch().isSubtree() != null) {
search.setSearchSubtree(moduleType.getSearch().isSubtree());
}
getObjectObjectPostProcessor().postProcess(search);
auth.setUserSearch(search);
}
getObjectObjectPostProcessor().postProcess(auth);
MidPointLdapAuthenticationProvider provider = new MidPointLdapAuthenticationProvider(auth);
provider.setUserDetailsContextMapper(new MidpointPrincipalContextMapper(principalManager));
getObjectObjectPostProcessor().postProcess(provider.getAuthenticatorProvider());
getObjectObjectPostProcessor().postProcess(provider);
return provider;
}
Aggregations