directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r406156 - in /directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw: ChangePasswordConfiguration.java protocol/ChangePasswordProtocolHandler.java service/CheckPasswordPolicy.java
Date Sat, 13 May 2006 22:16:12 GMT
Author: erodriguez
Date: Sat May 13 15:16:10 2006
New Revision: 406156

URL: http://svn.apache.org/viewcvs?rev=406156&view=rev
Log:
Improvements to robustness in the Change Password protocol-provider:
o  Corrected error introduced by refactoring to MINA IoHandlerChain.  Chain processing would
always return a password policy violation error message despite successfully updating the
password.
o  Set smarter default for base DN for searches to make out-of-the-box demos work easier.
o  Added better error message returned to clients when changepw service principal is not found.

Modified:
    directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java
    directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java
    directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/CheckPasswordPolicy.java

Modified: directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java?rev=406156&r1=406155&r2=406156&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java
(original)
+++ directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java
Sat May 13 15:16:10 2006
@@ -43,6 +43,9 @@
     /** the default change password principal */
     private static final String DEFAULT_PRINCIPAL = "kadmin/changepw@EXAMPLE.COM";
 
+    /** the default change password base DN */
+    public static final String CHANGEPW_ENTRY_BASEDN = "ou=users,dc=example,dc=com";
+
     /** the prop key const for primary.realm */
     private static final String REALM_KEY = "realm";
 
@@ -243,6 +246,19 @@
         }
 
         return new KerberosPrincipal( DEFAULT_PRINCIPAL );
+    }
+
+
+    public String getEntryBaseDn()
+    {
+        String key = ENTRY_BASEDN_KEY;
+
+        if ( configuration.containsKey( key ) )
+        {
+            return get( key );
+        }
+
+        return CHANGEPW_ENTRY_BASEDN;
     }
 
 

Modified: directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java?rev=406156&r1=406155&r2=406156&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java
(original)
+++ directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java
Sat May 13 15:16:10 2006
@@ -18,6 +18,7 @@
 package org.apache.directory.server.changepw.protocol;
 
 
+import java.io.UnsupportedEncodingException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
@@ -26,6 +27,7 @@
 
 import org.apache.directory.server.changepw.ChangePasswordConfiguration;
 import org.apache.directory.server.changepw.exceptions.ChangePasswordException;
+import org.apache.directory.server.changepw.exceptions.ErrorType;
 import org.apache.directory.server.changepw.messages.ChangePasswordErrorModifier;
 import org.apache.directory.server.changepw.messages.ChangePasswordRequest;
 import org.apache.directory.server.changepw.service.ChangePasswordChain;
@@ -121,9 +123,9 @@
         {
             log.error( e.getMessage() );
 
-            ChangePasswordException cpe = ( ChangePasswordException ) e;
+            KerberosException ke = ( KerberosException ) e;
 
-            ErrorMessage errorMessage = getErrorMessage( config.getChangepwPrincipal(), cpe
);
+            ErrorMessage errorMessage = getErrorMessage( config.getChangepwPrincipal(), ke
);
 
             ChangePasswordErrorModifier modifier = new ChangePasswordErrorModifier();
             modifier.setErrorMessage( errorMessage );
@@ -168,7 +170,24 @@
     private byte[] buildExplanatoryData( KerberosException exception )
     {
         short resultCode = ( short ) exception.getErrorCode();
-        byte[] resultString = exception.getExplanatoryData();
+
+        byte[] resultString = { (byte) 0x00 };
+
+        if ( exception.getExplanatoryData() == null || exception.getExplanatoryData().length
== 0 )
+        {
+            try
+            {
+                resultString = exception.getMessage().getBytes( "UTF-8" );
+            }
+            catch ( UnsupportedEncodingException uee )
+            {
+                log.error(  uee.getMessage() );
+            }
+        }
+        else
+        {
+            resultString = exception.getExplanatoryData();
+        }
 
         ByteBuffer byteBuffer = ByteBuffer.allocate( 256 );
         byteBuffer.putShort( resultCode );

Modified: directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/CheckPasswordPolicy.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/CheckPasswordPolicy.java?rev=406156&r1=406155&r2=406156&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/CheckPasswordPolicy.java
(original)
+++ directory/trunks/apacheds/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/CheckPasswordPolicy.java
Sat May 13 15:16:10 2006
@@ -61,17 +61,17 @@
         int categoryCount = config.getCategoryCountPolicy();
         int tokenSize = config.getTokenSizePolicy();
 
-        if ( isValid( username, password, passwordLength, categoryCount, tokenSize ) )
+        if ( !isValid( username, password, passwordLength, categoryCount, tokenSize ) )
         {
-            next.execute( session, message );
-        }
+            String explanation = buildErrorMessage( username, password, passwordLength, categoryCount,
tokenSize );
+            log.error( explanation );
 
-        String explanation = buildErrorMessage( username, password, passwordLength, categoryCount,
tokenSize );
-        log.error( explanation );
+            byte[] explanatoryData = explanation.getBytes( "UTF-8" );
 
-        byte[] explanatoryData = explanation.getBytes( "UTF-8" );
+            throw new ChangePasswordException( ErrorType.KRB5_KPASSWD_SOFTERROR, explanatoryData
);
+        }
 
-        throw new ChangePasswordException( ErrorType.KRB5_KPASSWD_SOFTERROR, explanatoryData
);
+        next.execute( session, message );
     }
 
 



Mime
View raw message