Sharad Mishra has uploaded a new change for review. Change subject: core: WIP: Add suppoort for SSL in LDAP. ......................................................................
core: WIP: Add suppoort for SSL in LDAP. This patch adds support for Simple authentication over SSL in LDAP. Change-Id: I31acf3142ca8cffe8f9174545ee8421ec243644a Signed-off-by: Sharad Mishra <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/LDAPSecurityAuthentication.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/LDAPTemplateWrapperFactory.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/SslSimpleDirContextAuthenticationStrategy.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/SslSimpleLdapTemplateWrapper.java 4 files changed, 66 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/98/10898/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/LDAPSecurityAuthentication.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/LDAPSecurityAuthentication.java index 3b58067..5a75049 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/LDAPSecurityAuthentication.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/LDAPSecurityAuthentication.java @@ -1,5 +1,5 @@ package org.ovirt.engine.core.bll.adbroker; public enum LDAPSecurityAuthentication { - SIMPLE, GSSAPI; + SIMPLE, SIMPLE_SSL, GSSAPI; } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/LDAPTemplateWrapperFactory.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/LDAPTemplateWrapperFactory.java index 0412389..3c6d530 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/LDAPTemplateWrapperFactory.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/LDAPTemplateWrapperFactory.java @@ -21,6 +21,7 @@ static { registerClass(LDAPSecurityAuthentication.GSSAPI, GSSAPILdapTemplateWrapper.class); registerClass(LDAPSecurityAuthentication.SIMPLE, SimpleLdapTemplateWrapper.class); + registerClass(LDAPSecurityAuthentication.SIMPLE_SSL, SslSimpleLdapTemplateWrapper.class); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/SslSimpleDirContextAuthenticationStrategy.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/SslSimpleDirContextAuthenticationStrategy.java new file mode 100644 index 0000000..dd822d8 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/SslSimpleDirContextAuthenticationStrategy.java @@ -0,0 +1,21 @@ +package org.ovirt.engine.core.bll.adbroker; + +import java.util.Hashtable; + +import javax.naming.Context; + +import org.springframework.ldap.core.support.SimpleDirContextAuthenticationStrategy; + +public class SslSimpleDirContextAuthenticationStrategy extends SimpleDirContextAuthenticationStrategy { + + private static final String SSL_PROTOCOL = "ssl"; + + @Override + public void setupEnvironment(Hashtable env, String userDn, String password) { + super.setupEnvironment(env, userDn, password); + env.put(Context.SECURITY_PROTOCOL, SSL_PROTOCOL); + + } + + +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/SslSimpleLdapTemplateWrapper.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/SslSimpleLdapTemplateWrapper.java new file mode 100644 index 0000000..506ac83 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/SslSimpleLdapTemplateWrapper.java @@ -0,0 +1,43 @@ +package org.ovirt.engine.core.bll.adbroker; + +import javax.naming.directory.SearchControls; + +import org.ovirt.engine.core.ldap.LdapProviderType; +import org.springframework.ldap.core.NameClassPairCallbackHandler; +import org.springframework.ldap.core.support.DirContextAuthenticationStrategy; +import org.springframework.ldap.core.support.LdapContextSource; + + + +public class SslSimpleLdapTemplateWrapper extends LDAPTemplateWrapper { + + /** + * @param contextSource + */ + public SslSimpleLdapTemplateWrapper(LdapContextSource contextSource, String userName, String password, String path) { + super(contextSource, userName, password, path); + } + + @Override + public void search(String baseDN, String filter, String displayFilter, SearchControls searchControls, NameClassPairCallbackHandler handler) { + pagedSearch(baseDN,filter, displayFilter, searchControls, handler); + } + + @Override + protected DirContextAuthenticationStrategy buildContextAuthenticationStategy() { + return new SslSimpleDirContextAuthenticationStrategy(); + } + + @Override + protected void setCredentialsOnContext() { + contextSource.setUserDn(userName); + contextSource.setPassword(password); + + } + + @Override + public void adjustUserName(LdapProviderType ldapProviderType) { + // No manipulation on user name is required, + } + +} \ No newline at end of file -- To view, visit http://gerrit.ovirt.org/10898 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I31acf3142ca8cffe8f9174545ee8421ec243644a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Sharad Mishra <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
