You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/08/05 12:02:35 UTC
svn commit: r682659 - in
/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers:
./ bind/ bind/cramMD5/ bind/digestMD5/ bind/gssapi/ bind/ntlm/ bind/plain/
Author: elecharny
Date: Tue Aug 5 03:02:34 2008
New Revision: 682659
URL: http://svn.apache.org/viewvc?rev=682659&view=rev
Log:
o injext the ldapserver instance into the ldapSession instance, to have a direct access to the adminSession instance
o Remove the useless mutex, as the adminSession is available through the ldapServer instance
Modified:
directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/LdapRequestHandler.java
directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewBindHandler.java
directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/MechanismHandler.java
directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/SimpleMechanismHandler.java
directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/cramMD5/CramMd5MechanismHandler.java
directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/digestMD5/DigestMd5CallbackHandler.java
directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/digestMD5/DigestMd5MechanismHandler.java
directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/gssapi/GssapiMechanismHandler.java
directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/ntlm/NtlmMechanismHandler.java
directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/plain/PlainMechanismHandler.java
Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/LdapRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/LdapRequestHandler.java?rev=682659&r1=682658&r2=682659&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/LdapRequestHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/LdapRequestHandler.java Tue Aug 5 03:02:34 2008
@@ -73,6 +73,7 @@
public final void messageReceived( IoSession session, T message ) throws Exception
{
LdapSession ldapSession = ldapServer.getLdapSession( session );
+ ldapSession.setLdapServer( ldapServer );
// We should check that the server allows anonymous requests
// only if it's not a BindRequest
Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewBindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewBindHandler.java?rev=682659&r1=682658&r2=682659&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewBindHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewBindHandler.java Tue Aug 5 03:02:34 2008
@@ -77,14 +77,6 @@
/** A Hashed Adapter mapping SASL mechanisms to their handlers. */
private Map<String, MechanismHandler> handlers;
- /** A session created using the server Admin, to be able to get full access to the server */
- private CoreSession adminSession;
-
-
- /** A lock used to protect the creation of the inner AdminSession */
- private Object mutex = new Object();
-
-
/**
* Set the mechanisms handler map.
*
@@ -375,6 +367,8 @@
private void handleSaslAuthPending( LdapSession ldapSession, BindRequest bindRequest, DirectoryService ds ) throws Exception
{
+ CoreSession adminSession = ldapSession.getLdapServer().getDirectoryService().getAdminSession();
+
// First, check that we have the same mechanism
String saslMechanism = bindRequest.getSaslMechanism();
@@ -394,7 +388,7 @@
throw new IllegalArgumentException( message );
}
- SaslServer ss = mechanismHandler.handleMechanism( ldapSession, adminSession, bindRequest );
+ SaslServer ss = mechanismHandler.handleMechanism( ldapSession, bindRequest );
if ( !ss.isComplete() )
{
@@ -541,7 +535,7 @@
MechanismHandler mechanismHandler = handlers.get( saslMechanism );
// Get the SaslServer instance which manage the C/R exchange
- SaslServer ss = mechanismHandler.handleMechanism( ldapSession, adminSession, bindRequest );
+ SaslServer ss = mechanismHandler.handleMechanism( ldapSession, bindRequest );
// We have to generate a challenge
generateSaslChallenge( ldapSession, ss, bindRequest );
@@ -642,13 +636,7 @@
private PrincipalStoreEntry findPrincipal( LdapServer ldapServer, GetPrincipal getPrincipal ) throws Exception
{
- synchronized ( mutex )
- {
- if ( adminSession == null )
- {
- adminSession = getLdapServer().getDirectoryService().getAdminSession();
- }
- }
+ CoreSession adminSession = ldapServer.getDirectoryService().getAdminSession();
return ( PrincipalStoreEntry ) getPrincipal.execute( adminSession, null );
}
@@ -684,15 +672,6 @@
}
else
{
- synchronized ( mutex )
- {
- if ( adminSession == null )
- {
- adminSession = getLdapServer().getDirectoryService().getAdminSession();
- ldapSession.setLdapServer( getLdapServer() );
- }
- }
-
handleSaslAuth( ldapSession, bindRequest );
}
}
Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/MechanismHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/MechanismHandler.java?rev=682659&r1=682658&r2=682659&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/MechanismHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/MechanismHandler.java Tue Aug 5 03:02:34 2008
@@ -22,7 +22,6 @@
import javax.security.sasl.SaslServer;
-import org.apache.directory.server.core.CoreSession;
import org.apache.directory.server.newldap.LdapSession;
import org.apache.directory.shared.ldap.message.BindRequest;
@@ -45,5 +44,5 @@
* @return The {@link SaslServer} to use for the duration of the bound session.
* @throws Exception
*/
- public SaslServer handleMechanism( LdapSession session, CoreSession adminSession, BindRequest bindRequest ) throws Exception;
+ public SaslServer handleMechanism( LdapSession session, BindRequest bindRequest ) throws Exception;
}
Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/SimpleMechanismHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/SimpleMechanismHandler.java?rev=682659&r1=682658&r2=682659&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/SimpleMechanismHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/SimpleMechanismHandler.java Tue Aug 5 03:02:34 2008
@@ -53,7 +53,7 @@
private static final Logger LOG = LoggerFactory.getLogger( SimpleMechanismHandler.class );
- public SaslServer handleMechanism( LdapSession ldapSession, CoreSession adminSession, BindRequest bindRequest ) throws Exception
+ public SaslServer handleMechanism( LdapSession ldapSession, BindRequest bindRequest ) throws Exception
{
// create a new Bind context, with a null session, as we don't have
// any context yet.
@@ -68,6 +68,8 @@
try
{
+ CoreSession adminSession = ldapSession.getLdapServer().getDirectoryService().getAdminSession();
+
// And call the OperationManager bind operation.
adminSession.getDirectoryService().getOperationManager().bind( opContext );
Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/cramMD5/CramMd5MechanismHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/cramMD5/CramMd5MechanismHandler.java?rev=682659&r1=682658&r2=682659&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/cramMD5/CramMd5MechanismHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/cramMD5/CramMd5MechanismHandler.java Tue Aug 5 03:02:34 2008
@@ -21,7 +21,6 @@
import org.apache.directory.server.core.CoreSession;
-import org.apache.directory.server.newldap.LdapServer;
import org.apache.directory.server.newldap.LdapSession;
import org.apache.directory.server.newldap.handlers.bind.MechanismHandler;
import org.apache.directory.server.newldap.handlers.bind.SaslConstants;
@@ -44,7 +43,7 @@
*/
public class CramMd5MechanismHandler implements MechanismHandler
{
- public SaslServer handleMechanism( LdapSession ldapSession, CoreSession adminSession, BindRequest bindRequest ) throws Exception
+ public SaslServer handleMechanism( LdapSession ldapSession, BindRequest bindRequest ) throws Exception
{
SaslServer ss = (SaslServer)ldapSession.getSaslProperty( SaslConstants.SASL_SERVER );
@@ -57,6 +56,8 @@
ldapSession.putSaslProperty( SaslConstants.SASL_USER_BASE_DN, userBaseDn );
Map<String, String> saslProps = new HashMap<String, String>();
+ CoreSession adminSession = ldapSession.getLdapServer().getDirectoryService().getAdminSession();
+
CallbackHandler callbackHandler = new CramMd5CallbackHandler( ldapSession, adminSession, bindRequest );
ss = Sasl.createSaslServer( SupportedSaslMechanisms.CRAM_MD5, SaslConstants.LDAP_PROTOCOL, saslHost, saslProps, callbackHandler );
Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/digestMD5/DigestMd5CallbackHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/digestMD5/DigestMd5CallbackHandler.java?rev=682659&r1=682658&r2=682659&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/digestMD5/DigestMd5CallbackHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/digestMD5/DigestMd5CallbackHandler.java Tue Aug 5 03:02:34 2008
@@ -39,7 +39,6 @@
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.AttributeTypeOptions;
-import org.apache.mina.common.IoSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,8 +54,6 @@
{
private static final Logger LOG = LoggerFactory.getLogger( DigestMd5CallbackHandler.class );
- private IoSession session;
-
private String bindDn;
private String userPassword;
Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/digestMD5/DigestMd5MechanismHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/digestMD5/DigestMd5MechanismHandler.java?rev=682659&r1=682658&r2=682659&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/digestMD5/DigestMd5MechanismHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/digestMD5/DigestMd5MechanismHandler.java Tue Aug 5 03:02:34 2008
@@ -75,7 +75,7 @@
- public SaslServer handleMechanism( LdapSession ldapSession, CoreSession adminSession, BindRequest bindRequest ) throws Exception
+ public SaslServer handleMechanism( LdapSession ldapSession, BindRequest bindRequest ) throws Exception
{
SaslServer ss = (SaslServer)ldapSession.getSaslProperty( SaslConstants.SASL_SERVER );
@@ -90,6 +90,8 @@
saslProps.put( Sasl.QOP, ldapSession.getLdapServer().getSaslQopString() );
saslProps.put( "com.sun.security.sasl.digest.realm", getActiveRealms( ldapSession.getLdapServer() ) );
+ CoreSession adminSession = ldapSession.getLdapServer().getDirectoryService().getAdminSession();
+
CallbackHandler callbackHandler = new DigestMd5CallbackHandler( ldapSession, adminSession, bindRequest );
ss = Sasl.createSaslServer( SupportedSaslMechanisms.DIGEST_MD5, SaslConstants.LDAP_PROTOCOL, saslHost, saslProps, callbackHandler );
Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/gssapi/GssapiMechanismHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/gssapi/GssapiMechanismHandler.java?rev=682659&r1=682658&r2=682659&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/gssapi/GssapiMechanismHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/gssapi/GssapiMechanismHandler.java Tue Aug 5 03:02:34 2008
@@ -20,7 +20,6 @@
package org.apache.directory.server.newldap.handlers.bind.gssapi;
-import org.apache.directory.server.core.CoreSession;
import org.apache.directory.server.newldap.LdapSession;
import org.apache.directory.server.newldap.handlers.bind.MechanismHandler;
import org.apache.directory.server.newldap.handlers.bind.SaslConstants;
@@ -44,7 +43,7 @@
*/
public class GssapiMechanismHandler implements MechanismHandler
{
- public SaslServer handleMechanism( LdapSession ldapSession, CoreSession adminSession, BindRequest bindRequest ) throws Exception
+ public SaslServer handleMechanism( LdapSession ldapSession, BindRequest bindRequest ) throws Exception
{
SaslServer ss;
Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/ntlm/NtlmMechanismHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/ntlm/NtlmMechanismHandler.java?rev=682659&r1=682658&r2=682659&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/ntlm/NtlmMechanismHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/ntlm/NtlmMechanismHandler.java Tue Aug 5 03:02:34 2008
@@ -20,7 +20,6 @@
package org.apache.directory.server.newldap.handlers.bind.ntlm;
-import org.apache.directory.server.core.CoreSession;
import org.apache.directory.server.newldap.LdapSession;
import org.apache.directory.server.newldap.handlers.bind.MechanismHandler;
import org.apache.directory.server.newldap.handlers.bind.SaslConstants;
@@ -56,7 +55,7 @@
}
- public SaslServer handleMechanism( LdapSession ldapSession, CoreSession adminSession, BindRequest bindRequest ) throws Exception
+ public SaslServer handleMechanism( LdapSession ldapSession, BindRequest bindRequest ) throws Exception
{
SaslServer ss = ( SaslServer ) ldapSession.getSaslProperty( SaslConstants.SASL_SERVER );
Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/plain/PlainMechanismHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/plain/PlainMechanismHandler.java?rev=682659&r1=682658&r2=682659&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/plain/PlainMechanismHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/plain/PlainMechanismHandler.java Tue Aug 5 03:02:34 2008
@@ -42,13 +42,14 @@
/**
* {@inheritDoc}
*/
- public SaslServer handleMechanism( LdapSession ldapSession, CoreSession adminSession, BindRequest bindRequest ) throws Exception
+ public SaslServer handleMechanism( LdapSession ldapSession, BindRequest bindRequest ) throws Exception
{
SaslServer ss = ( SaslServer ) ldapSession.getSaslProperty( SaslConstants.SASL_SERVER );
if ( ss == null )
{
-
+ CoreSession adminSession = ldapSession.getLdapServer().getDirectoryService().getAdminSession();
+
ss = new PlainSaslServer( ldapSession, adminSession, bindRequest );
ldapSession.putSaslProperty( SaslConstants.SASL_SERVER, ss );
}