use of com.evolveum.midpoint.authentication.impl.ldap.LdapDirContextAdapter in project midpoint by Evolveum.
the class MidPointLdapAuthenticationProvider method doAuthentication.
protected DirContextOperations doAuthentication(DirContextOperations originalDirContextOperations) {
if (originalDirContextOperations instanceof DirContextAdapter) {
Authentication actualAuthentication = SecurityContextHolder.getContext().getAuthentication();
if (actualAuthentication instanceof MidpointAuthentication) {
MidpointAuthentication mpAuthentication = (MidpointAuthentication) actualAuthentication;
ModuleAuthenticationImpl moduleAuthentication = (ModuleAuthenticationImpl) getProcessingModule(mpAuthentication);
if (moduleAuthentication instanceof LdapModuleAuthentication) {
// HACK because of NP in DirContextAdapter(DirContextAdapter master)
if (!originalDirContextOperations.isUpdateMode()) {
((DirContextAdapter) originalDirContextOperations).setUpdateMode(true);
((DirContextAdapter) originalDirContextOperations).setUpdateMode(false);
}
LdapDirContextAdapter mpDirContextAdapter = new LdapDirContextAdapter((DirContextAdapter) originalDirContextOperations);
mpDirContextAdapter.setNamingAttr(((LdapModuleAuthentication) moduleAuthentication).getNamingAttribute());
if (moduleAuthentication.getFocusType() != null) {
Class<FocusType> focusType = PrismContext.get().getSchemaRegistry().determineCompileTimeClass(moduleAuthentication.getFocusType());
mpDirContextAdapter.setFocusType(focusType);
}
return mpDirContextAdapter;
}
}
}
return originalDirContextOperations;
}
Aggregations