directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1043794 - in /directory/apacheds/trunk/protocol-changepw: ./ src/main/java/org/apache/directory/server/changepw/ src/main/java/org/apache/directory/server/changepw/exceptions/ src/main/java/org/apache/directory/server/changepw/io/ src/main...
Date Thu, 09 Dec 2010 00:14:14 GMT
Author: elecharny
Date: Thu Dec  9 00:14:14 2010
New Revision: 1043794

URL: http://svn.apache.org/viewvc?rev=1043794&view=rev
Log:
Merged the kerberos-codec branch, 2

Removed:
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordErrorModifier.java
Modified:
    directory/apacheds/trunk/protocol-changepw/   (props changed)
    directory/apacheds/trunk/protocol-changepw/pom.xml
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/exceptions/ChangePasswordException.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordDataEncoder.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorDecoder.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorEncoder.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordReplyDecoder.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordReplyEncoder.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestDecoder.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestEncoder.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordError.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequest.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequestModifier.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordContext.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordService.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/CheckPasswordPolicy.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/value/ChangePasswordData.java
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/value/ChangePasswordDataModifier.java
    directory/apacheds/trunk/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/ChangepwProtocolHandlerTest.java
    directory/apacheds/trunk/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/MapPrincipalStoreImpl.java

Propchange: directory/apacheds/trunk/protocol-changepw/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  9 00:14:14 2010
@@ -1,3 +1,4 @@
 /directory/apacheds/branches/apacheds-codec-merge/protocol-changepw:982369-987590
 /directory/apacheds/branches/apacheds-config/protocol-changepw:1023442-1029077
 /directory/apacheds/branches/apacheds-dnfactory-experiment/protocol-changepw:980138-980936
+/directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-changepw:1040956-1043765

Modified: directory/apacheds/trunk/protocol-changepw/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/pom.xml?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/pom.xml (original)
+++ directory/apacheds/trunk/protocol-changepw/pom.xml Thu Dec  9 00:14:14 2010
@@ -49,7 +49,7 @@
     
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>apacheds-kerberos-shared</artifactId>
+      <artifactId>apacheds-kerberos-codec</artifactId>
     </dependency>
     
     <dependency>

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java Thu Dec  9 00:14:14 2010
@@ -26,14 +26,18 @@ import java.util.List;
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
+import net.sf.ehcache.Cache;
+
 import org.apache.directory.server.changepw.protocol.ChangePasswordProtocolHandler;
 import org.apache.directory.server.constants.ServerDNConstants;
-import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
+import org.apache.directory.server.kerberos.shared.replay.ReplayCacheImpl;
+import org.apache.directory.server.kerberos.shared.replay.ReplayCache;
 import org.apache.directory.server.kerberos.shared.store.DirectoryPrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.protocol.shared.DirectoryBackedService;
 import org.apache.directory.server.protocol.shared.transport.Transport;
 import org.apache.directory.server.protocol.shared.transport.UdpTransport;
+import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.mina.core.service.IoAcceptor;
@@ -114,6 +118,8 @@ public class ChangePasswordServer extend
     /** The policy for token size. */
     private int policyTokenSize;
 
+    /** the cache used for storing change password requests */
+    private ReplayCache replayCache;
 
     /**
      * Creates a new instance of ChangePasswordConfiguration.
@@ -268,6 +274,11 @@ public class ChangePasswordServer extend
     {
         PrincipalStore store = new DirectoryPrincipalStore( getDirectoryService(), new DN(this.getSearchBaseDn())  );
         
+        LOG.debug( "initializing the changepassword replay cache" );
+
+        Cache cache = getDirectoryService().getCacheService().getCache( "changePwdReplayCache" );
+        replayCache = new ReplayCacheImpl( cache );
+
         if ( ( transports == null ) || ( transports.size() == 0 ) )
         {
             // Default to UDP with port 464
@@ -334,6 +345,8 @@ public class ChangePasswordServer extend
             }
         }
 
+        replayCache.clear();
+        
         LOG.info( "ChangePassword service stopped." );
         //System.out.println( "ChangePassword service stopped." );
     }
@@ -393,6 +406,15 @@ public class ChangePasswordServer extend
     
     
     /**
+     * @return the replayCache
+     */
+    public ReplayCache getReplayCache()
+    {
+        return replayCache;
+    }
+
+
+    /**
      * @see Object#toString()
      */
     public String toString()

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/exceptions/ChangePasswordException.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/exceptions/ChangePasswordException.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/exceptions/ChangePasswordException.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/exceptions/ChangePasswordException.java Thu Dec  9 00:14:14 2010
@@ -21,7 +21,7 @@
 package org.apache.directory.server.changepw.exceptions;
 
 
-import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
+import org.apache.directory.shared.kerberos.exceptions.KerberosException;
 
 
 /**

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordDataEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordDataEncoder.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordDataEncoder.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordDataEncoder.java Thu Dec  9 00:14:14 2010
@@ -25,7 +25,6 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 
 import org.apache.directory.server.changepw.value.ChangePasswordData;
-import org.apache.directory.server.kerberos.shared.io.encoder.PrincipalNameEncoder;
 import org.apache.directory.shared.asn1.der.ASN1OutputStream;
 import org.apache.directory.shared.asn1.der.DERGeneralString;
 import org.apache.directory.shared.asn1.der.DEROctetString;

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorDecoder.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorDecoder.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorDecoder.java Thu Dec  9 00:14:14 2010
@@ -24,9 +24,8 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 
 import org.apache.directory.server.changepw.messages.ChangePasswordError;
-import org.apache.directory.server.changepw.messages.ChangePasswordErrorModifier;
-import org.apache.directory.server.kerberos.shared.io.decoder.ErrorMessageDecoder;
-import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
+import org.apache.directory.server.kerberos.protocol.KerberosDecoder;
+import org.apache.directory.shared.kerberos.messages.KrbError;
 
 
 /**
@@ -62,8 +61,7 @@ public class ChangePasswordErrorDecoder
         buf.get( errorBytes );
         ByteBuffer errorBuffer = ByteBuffer.wrap( errorBytes );
 
-        ErrorMessageDecoder errorDecoder = new ErrorMessageDecoder();
-        ErrorMessage errorMessage = errorDecoder.decode( errorBuffer );
+        KrbError errorMessage = KerberosDecoder.decodeKrbError( errorBuffer );
 
         modifier.setErrorMessage( errorMessage );
 

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorEncoder.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorEncoder.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorEncoder.java Thu Dec  9 00:14:14 2010
@@ -25,8 +25,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 
 import org.apache.directory.server.changepw.messages.ChangePasswordError;
-import org.apache.directory.server.kerberos.shared.io.encoder.ErrorMessageEncoder;
-import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
+import org.apache.directory.shared.kerberos.messages.KrbError;
 
 
 /**
@@ -47,7 +46,7 @@ public class ChangePasswordErrorEncoder
     public void encode( ByteBuffer buf, ChangePasswordError message ) throws IOException
     {
         // Build error message bytes
-        ErrorMessage errorMessage = message.getErrorMessage();
+        KrbError errorMessage = message.getKrbError();
         ErrorMessageEncoder errorEncoder = new ErrorMessageEncoder();
         byte[] errorBytes = errorEncoder.encode( errorMessage );
 

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordReplyDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordReplyDecoder.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordReplyDecoder.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordReplyDecoder.java Thu Dec  9 00:14:14 2010
@@ -24,11 +24,9 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 
 import org.apache.directory.server.changepw.messages.ChangePasswordReply;
-import org.apache.directory.server.changepw.messages.ChangePasswordReplyModifier;
-import org.apache.directory.server.kerberos.shared.io.decoder.ApplicationReplyDecoder;
-import org.apache.directory.server.kerberos.shared.io.decoder.PrivateMessageDecoder;
-import org.apache.directory.server.kerberos.shared.messages.application.ApplicationReply;
+import org.apache.directory.server.kerberos.protocol.KerberosDecoder;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
+import org.apache.directory.shared.kerberos.messages.ApRep;
 
 
 /**
@@ -48,20 +46,14 @@ public class ChangePasswordReplyDecoder
      */
     public ChangePasswordReply decode( ByteBuffer buf ) throws IOException
     {
-        ChangePasswordReplyModifier modifier = new ChangePasswordReplyModifier();
-
         short messageLength = buf.getShort();
         short protocolVersion = buf.getShort();
         short encodedAppReplyLength = buf.getShort();
 
-        modifier.setProtocolVersionNumber( protocolVersion );
-
         byte[] encodedAppReply = new byte[encodedAppReplyLength];
         buf.get( encodedAppReply );
 
-        ApplicationReplyDecoder appDecoder = new ApplicationReplyDecoder();
-        ApplicationReply applicationReply = appDecoder.decode( encodedAppReply );
-        modifier.setApplicationReply( applicationReply );
+        ApRep applicationReply = KerberosDecoder.decodeApRep( encodedAppReply );
 
         int privateBytesLength = messageLength - HEADER_LENGTH - encodedAppReplyLength;
         byte[] encodedPrivateMessage = new byte[privateBytesLength];
@@ -69,8 +61,8 @@ public class ChangePasswordReplyDecoder
 
         PrivateMessageDecoder privateDecoder = new PrivateMessageDecoder();
         PrivateMessage privateMessage = privateDecoder.decode( encodedPrivateMessage );
-        modifier.setPrivateMessage( privateMessage );
+        applicationReply.setPrivateMessage( privateMessage );
 
-        return modifier.getChangePasswordReply();
+        return applicationReply.getChangePasswordReply();
     }
 }

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordReplyEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordReplyEncoder.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordReplyEncoder.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordReplyEncoder.java Thu Dec  9 00:14:14 2010
@@ -25,8 +25,6 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 
 import org.apache.directory.server.changepw.messages.ChangePasswordReply;
-import org.apache.directory.server.kerberos.shared.io.encoder.ApplicationReplyEncoder;
-import org.apache.directory.server.kerberos.shared.io.encoder.PrivateMessageEncoder;
 import org.apache.directory.server.kerberos.shared.messages.application.ApplicationReply;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
 

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestDecoder.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestDecoder.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestDecoder.java Thu Dec  9 00:14:14 2010
@@ -25,10 +25,9 @@ import java.nio.ByteBuffer;
 
 import org.apache.directory.server.changepw.messages.ChangePasswordRequest;
 import org.apache.directory.server.changepw.messages.ChangePasswordRequestModifier;
-import org.apache.directory.server.kerberos.shared.io.decoder.ApplicationRequestDecoder;
-import org.apache.directory.server.kerberos.shared.io.decoder.PrivateMessageDecoder;
-import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
-import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
+import org.apache.directory.server.kerberos.protocol.KerberosDecoder;
+import org.apache.directory.shared.kerberos.messages.ApReq;
+import org.apache.directory.shared.kerberos.messages.KrbPriv;
 
 
 /**
@@ -56,16 +55,14 @@ public class ChangePasswordRequestDecode
         byte[] undecodedAuthHeader = new byte[authHeaderLength];
         buf.get( undecodedAuthHeader, 0, authHeaderLength );
 
-        ApplicationRequestDecoder decoder = new ApplicationRequestDecoder();
-        ApplicationRequest authHeader = decoder.decode( undecodedAuthHeader );
+        ApReq authHeader = KerberosDecoder.decodeApReq( undecodedAuthHeader );
 
         modifier.setAuthHeader( authHeader );
 
         byte[] encodedPrivate = new byte[buf.remaining()];
         buf.get( encodedPrivate, 0, buf.remaining() );
 
-        PrivateMessageDecoder privateDecoder = new PrivateMessageDecoder();
-        PrivateMessage privMessage = privateDecoder.decode( encodedPrivate );
+        KrbPriv privMessage = KerberosDecoder.decodeKrbPriv( encodedPrivate );
 
         modifier.setPrivateMessage( privMessage );
 

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestEncoder.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestEncoder.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestEncoder.java Thu Dec  9 00:14:14 2010
@@ -24,10 +24,8 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 
 import org.apache.directory.server.changepw.messages.ChangePasswordRequest;
-import org.apache.directory.server.kerberos.shared.io.encoder.ApplicationRequestEncoder;
-import org.apache.directory.server.kerberos.shared.io.encoder.PrivateMessageEncoder;
-import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
+import org.apache.directory.shared.kerberos.messages.ApReq;
 
 
 /**
@@ -48,7 +46,7 @@ public class ChangePasswordRequestEncode
     public void encode( ByteBuffer buf, ChangePasswordRequest message ) throws IOException
     {
         // Build application request bytes
-        ApplicationRequest appRequest = message.getAuthHeader();
+        ApReq appRequest = message.getAuthHeader();
         ApplicationRequestEncoder appEncoder = new ApplicationRequestEncoder();
         byte[] encodedAppRequest = appEncoder.encode( appRequest );
 

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordError.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordError.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordError.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordError.java Thu Dec  9 00:14:14 2010
@@ -20,38 +20,39 @@
 package org.apache.directory.server.changepw.messages;
 
 
-import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
+import org.apache.directory.shared.kerberos.messages.KrbError;
 
 
 /**
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class ChangePasswordError extends AbstractPasswordMessage
 {
-    private ErrorMessage errorMessage;
+    private KrbError krbError;
 
 
     /**
      * Creates a new instance of ChangePasswordError.
      *
      * @param versionNumber
-     * @param errorMessage
+     * @param krbError The KRB-ERROR
      */
-    public ChangePasswordError( short versionNumber, ErrorMessage errorMessage )
+    public ChangePasswordError( short versionNumber, KrbError krbError )
     {
         super( versionNumber );
 
-        this.errorMessage = errorMessage;
+        this.krbError = krbError;
     }
 
 
     /**
-     * Returns the {@link ErrorMessage}.
+     * Returns the {@link KrbError}.
      *
-     * @return The {@link ErrorMessage}.
+     * @return The {@link KrbError}.
      */
-    public ErrorMessage getErrorMessage()
+    public KrbError getKrbError()
     {
-        return errorMessage;
+        return krbError;
     }
 }

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequest.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequest.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequest.java Thu Dec  9 00:14:14 2010
@@ -20,8 +20,8 @@
 package org.apache.directory.server.changepw.messages;
 
 
-import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
+import org.apache.directory.shared.kerberos.messages.ApReq;
 
 
 /**
@@ -29,7 +29,7 @@ import org.apache.directory.server.kerbe
  */
 public class ChangePasswordRequest extends AbstractPasswordMessage
 {
-    private ApplicationRequest authHeader;
+    private ApReq authHeader;
     private PrivateMessage privateMessage;
 
 
@@ -40,7 +40,7 @@ public class ChangePasswordRequest exten
      * @param authHeader
      * @param privateMessage
      */
-    public ChangePasswordRequest( short versionNumber, ApplicationRequest authHeader, PrivateMessage privateMessage )
+    public ChangePasswordRequest( short versionNumber, ApReq authHeader, PrivateMessage privateMessage )
     {
         super( versionNumber );
 
@@ -50,11 +50,11 @@ public class ChangePasswordRequest exten
 
 
     /**
-     * Returns the {@link ApplicationRequest}.
+     * Returns the {@link ApReq}.
      *
-     * @return The {@link ApplicationRequest}.
+     * @return The {@link ApReq}.
      */
-    public ApplicationRequest getAuthHeader()
+    public ApReq getAuthHeader()
     {
         return authHeader;
     }

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequestModifier.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequestModifier.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequestModifier.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequestModifier.java Thu Dec  9 00:14:14 2010
@@ -20,8 +20,8 @@
 package org.apache.directory.server.changepw.messages;
 
 
-import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
+import org.apache.directory.shared.kerberos.messages.ApReq;
 
 
 /**
@@ -29,7 +29,7 @@ import org.apache.directory.server.kerbe
  */
 public class ChangePasswordRequestModifier extends AbstractPasswordMessageModifier
 {
-    private ApplicationRequest authHeader;
+    private ApReq authHeader;
     private PrivateMessage privateMessage;
 
 
@@ -49,7 +49,7 @@ public class ChangePasswordRequestModifi
      *
      * @param authHeader
      */
-    public void setAuthHeader( ApplicationRequest authHeader )
+    public void setAuthHeader( ApReq authHeader )
     {
         this.authHeader = authHeader;
     }

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java Thu Dec  9 00:14:14 2010
@@ -31,16 +31,14 @@ import javax.security.auth.kerberos.Kerb
 import org.apache.directory.server.changepw.ChangePasswordServer;
 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.ChangePasswordContext;
 import org.apache.directory.server.changepw.service.ChangePasswordService;
 import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
-import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
-import org.apache.directory.server.kerberos.shared.messages.ErrorMessageModifier;
-import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
+import org.apache.directory.shared.kerberos.exceptions.KerberosException;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
+import org.apache.directory.shared.kerberos.KerberosTime;
+import org.apache.directory.shared.kerberos.messages.KrbError;
 import org.apache.mina.core.service.IoHandler;
 import org.apache.mina.core.session.IdleStatus;
 import org.apache.mina.core.session.IoSession;
@@ -150,7 +148,7 @@ public class ChangePasswordProtocolHandl
                 log.warn( ke.getLocalizedMessage() );
             }
 
-            ErrorMessage errorMessage = getErrorMessage( config.getServicePrincipal(), ke );
+            KrbError errorMessage = getErrorMessage( config.getServicePrincipal(), ke );
 
             ChangePasswordErrorModifier modifier = new ChangePasswordErrorModifier();
             modifier.setErrorMessage( errorMessage );
@@ -182,20 +180,20 @@ public class ChangePasswordProtocolHandl
     }
 
 
-    private ErrorMessage getErrorMessage( KerberosPrincipal principal, KerberosException exception )
+    private KrbError getErrorMessage( KerberosPrincipal principal, KerberosException exception )
     {
-        ErrorMessageModifier modifier = new ErrorMessageModifier();
+        KrbError krbError = new KrbError();
 
         KerberosTime now = new KerberosTime();
 
-        modifier.setErrorCode( exception.getErrorCode() );
-        modifier.setExplanatoryText( exception.getLocalizedMessage() );
-        modifier.setServerPrincipal( principal );
-        modifier.setServerTime( now );
-        modifier.setServerMicroSecond( 0 );
-        modifier.setExplanatoryData( buildExplanatoryData( exception ) );
+        krbError.setErrorCode( ErrorType.getTypeByOrdinal( exception.getErrorCode() ) );
+        krbError.setEText( exception.getLocalizedMessage() );
+        krbError.setSName( principal );
+        krbError.setSTime( now );
+        krbError.setSusec( 0 );
+        krbError.setEData( buildExplanatoryData( exception ) );
 
-        return modifier.getErrorMessage();
+        return krbError;
     }
 
 

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordContext.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordContext.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordContext.java Thu Dec  9 00:14:14 2010
@@ -25,12 +25,11 @@ import java.net.InetAddress;
 import org.apache.directory.server.changepw.ChangePasswordServer;
 import org.apache.directory.server.changepw.messages.AbstractPasswordMessage;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.CipherTextHandler;
-import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
-import org.apache.directory.server.kerberos.shared.messages.components.Authenticator;
-import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
-import org.apache.directory.server.kerberos.shared.replay.ReplayCache;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
+import org.apache.directory.shared.kerberos.messages.ApReq;
+import org.apache.directory.shared.kerberos.messages.Authenticator;
+import org.apache.directory.shared.kerberos.messages.Ticket;
 
 
 /**
@@ -46,34 +45,15 @@ public class ChangePasswordContext
     private AbstractPasswordMessage reply;
     private InetAddress clientAddress;
 
-    private ApplicationRequest authHeader;
+    private ApReq authHeader;
     private Ticket ticket;
     private Authenticator authenticator;
     private PrincipalStoreEntry serverEntry;
-    private ReplayCache replayCache;
     private CipherTextHandler cipherTextHandler;
     private String password;
 
 
     /**
-     * @return Returns the replayCache.
-     */
-    public ReplayCache getReplayCache()
-    {
-        return replayCache;
-    }
-
-
-    /**
-     * @param replayCache The replayCache to set.
-     */
-    public void setReplayCache( ReplayCache replayCache )
-    {
-        this.replayCache = replayCache;
-    }
-
-
-    /**
      * @return Returns the serverEntry.
      */
     public PrincipalStoreEntry getServerEntry()
@@ -202,7 +182,7 @@ public class ChangePasswordContext
     /**
      * @return Returns the authHeader.
      */
-    public ApplicationRequest getAuthHeader()
+    public ApReq getAuthHeader()
     {
         return authHeader;
     }
@@ -211,7 +191,7 @@ public class ChangePasswordContext
     /**
      * @param authHeader The authHeader to set.
      */
-    public void setAuthHeader( ApplicationRequest authHeader )
+    public void setAuthHeader( ApReq authHeader )
     {
         this.authHeader = authHeader;
     }

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordService.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordService.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordService.java Thu Dec  9 00:14:14 2010
@@ -37,28 +37,25 @@ import org.apache.directory.server.chang
 import org.apache.directory.server.changepw.value.ChangePasswordData;
 import org.apache.directory.server.changepw.value.ChangePasswordDataModifier;
 import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.server.kerberos.shared.KerberosUtils;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.CipherTextHandler;
-import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.KeyUsage;
-import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
-import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
+import org.apache.directory.shared.kerberos.exceptions.KerberosException;
 import org.apache.directory.server.kerberos.shared.messages.application.ApplicationReply;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
-import org.apache.directory.server.kerberos.shared.messages.components.Authenticator;
-import org.apache.directory.server.kerberos.shared.messages.components.EncApRepPart;
-import org.apache.directory.server.kerberos.shared.messages.components.EncApRepPartModifier;
-import org.apache.directory.server.kerberos.shared.messages.components.EncKrbPrivPart;
-import org.apache.directory.server.kerberos.shared.messages.components.EncKrbPrivPartModifier;
-import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
-import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData;
-import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
-import org.apache.directory.server.kerberos.shared.messages.value.HostAddress;
-import org.apache.directory.server.kerberos.shared.messages.value.HostAddresses;
-import org.apache.directory.server.kerberos.shared.replay.InMemoryReplayCache;
 import org.apache.directory.server.kerberos.shared.replay.ReplayCache;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
+import org.apache.directory.shared.kerberos.KerberosUtils;
+import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
+import org.apache.directory.shared.kerberos.components.EncKrbPrivPart;
+import org.apache.directory.shared.kerberos.components.EncryptedData;
+import org.apache.directory.shared.kerberos.components.EncryptionKey;
+import org.apache.directory.shared.kerberos.components.HostAddress;
+import org.apache.directory.shared.kerberos.components.HostAddresses;
+import org.apache.directory.shared.kerberos.messages.ApReq;
+import org.apache.directory.shared.kerberos.messages.Authenticator;
+import org.apache.directory.shared.kerberos.messages.EncApRepPart;
+import org.apache.directory.shared.kerberos.messages.Ticket;
 import org.apache.mina.core.session.IoSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -68,11 +65,8 @@ public class ChangePasswordService
     /** the logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( ChangePasswordService.class );
 
-    private static final ReplayCache replayCache = new InMemoryReplayCache();
-    
     private static final CipherTextHandler cipherTextHandler = new CipherTextHandler();
 
-    
     public static void execute( IoSession session, ChangePasswordContext changepwContext ) throws KerberosException, IOException
     {
         if ( LOG.isDebugEnabled() )
@@ -107,7 +101,9 @@ public class ChangePasswordService
         PrincipalStore store = changepwContext.getStore();
         Authenticator authenticator = changepwContext.getAuthenticator();
         String newPassword = changepwContext.getPassword();
-        KerberosPrincipal clientPrincipal = authenticator.getClientPrincipal();
+        KerberosPrincipal clientPrincipal = KerberosUtils.getKerberosPrincipal( 
+            authenticator.getCName(),
+            authenticator.getCRealm() );
 
         // usec and seq-number must be present per MS but aren't in legacy kpasswd
         // seq-number must have same value as authenticator
@@ -152,7 +148,6 @@ public class ChangePasswordService
     
     private static void configureChangePassword( ChangePasswordContext changepwContext )
     {
-        changepwContext.setReplayCache( replayCache );
         changepwContext.setCipherTextHandler( cipherTextHandler );
     }
     
@@ -171,7 +166,7 @@ public class ChangePasswordService
             throw new ChangePasswordException( ErrorType.KRB5_KPASSWD_AUTHERROR );
         }
 
-        ApplicationRequest authHeader = request.getAuthHeader();
+        ApReq authHeader = request.getAuthHeader();
         Ticket ticket = authHeader.getTicket();
 
         changepwContext.setAuthHeader( authHeader );
@@ -189,7 +184,7 @@ public class ChangePasswordService
 
         if ( !ticket.getRealm().equals( primaryRealm ) || !serverPrincipal.equals( changepwPrincipal ) )
         {
-            throw new KerberosException( org.apache.directory.server.kerberos.shared.exceptions.ErrorType.KRB_AP_ERR_NOT_US );
+            throw new KerberosException( org.apache.directory.shared.kerberos.exceptions.ErrorType.KRB_AP_ERR_NOT_US );
         }
     }
     
@@ -199,26 +194,26 @@ public class ChangePasswordService
         KerberosPrincipal principal =  changepwContext.getTicket().getServerPrincipal();
         PrincipalStore store = changepwContext.getStore();
 
-        changepwContext.setServerEntry( KerberosUtils.getEntry( principal, store, org.apache.directory.server.kerberos.shared.exceptions.ErrorType.KDC_ERR_S_PRINCIPAL_UNKNOWN ) );
+        changepwContext.setServerEntry( KerberosUtils.getEntry( principal, store, org.apache.directory.shared.kerberos.exceptions.ErrorType.KDC_ERR_S_PRINCIPAL_UNKNOWN ) );
     }
     
     
     private static void verifyServiceTicketAuthHeader( ChangePasswordContext changepwContext ) throws KerberosException
     {
-        ApplicationRequest authHeader = changepwContext.getAuthHeader();
+        ApReq authHeader = changepwContext.getAuthHeader();
         Ticket ticket = changepwContext.getTicket();
 
         EncryptionType encryptionType = ticket.getEncPart().getEType();
         EncryptionKey serverKey = changepwContext.getServerEntry().getKeyMap().get( encryptionType );
 
         long clockSkew = changepwContext.getConfig().getAllowableClockSkew();
-        ReplayCache replayCache = changepwContext.getReplayCache();
+        ReplayCache replayCache = changepwContext.getConfig().getReplayCache();
         boolean emptyAddressesAllowed = changepwContext.getConfig().isEmptyAddressesAllowed();
         InetAddress clientAddress = changepwContext.getClientAddress();
         CipherTextHandler cipherTextHandler = changepwContext.getCipherTextHandler();
 
         Authenticator authenticator = KerberosUtils.verifyAuthHeader( authHeader, ticket, serverKey, clockSkew, replayCache,
-            emptyAddressesAllowed, clientAddress, cipherTextHandler, KeyUsage.NUMBER11, false );
+            emptyAddressesAllowed, clientAddress, cipherTextHandler, KeyUsage.AP_REQ_AUTHNT_SESS_KEY, false );
 
         ChangePasswordRequest request = ( ChangePasswordRequest ) changepwContext.getRequest();
 
@@ -243,7 +238,7 @@ public class ChangePasswordService
         // TODO - check client principal in ticket is authorized to change password
 
         // get the subsession key from the Authenticator
-        EncryptionKey subSessionKey = authenticator.getSubSessionKey();
+        EncryptionKey subSessionKey = authenticator.getSubKey();
 
         // decrypt the request's private message with the subsession key
         EncryptedData encReqPrivPart = request.getPrivateMessage().getEncryptedPart();
@@ -253,7 +248,7 @@ public class ChangePasswordService
         try
         {
             privatePart = ( EncKrbPrivPart ) cipherTextHandler.unseal( EncKrbPrivPart.class, subSessionKey,
-                encReqPrivPart, KeyUsage.NUMBER13 );
+                encReqPrivPart, KeyUsage.KRB_PRIV_ENC_PART_CHOSEN_KEY );
         }
         catch ( KerberosException ke )
         {
@@ -292,13 +287,14 @@ public class ChangePasswordService
         try
         {
             PrincipalStore store = changepwContext.getStore();
-            ApplicationRequest authHeader = changepwContext.getAuthHeader();
+            ApReq authHeader = changepwContext.getAuthHeader();
             Ticket ticket = changepwContext.getTicket();
-            ReplayCache replayCache = changepwContext.getReplayCache();
+            ReplayCache replayCache = changepwContext.getConfig().getReplayCache();
             long clockSkew = changepwContext.getConfig().getAllowableClockSkew();
 
             Authenticator authenticator = changepwContext.getAuthenticator();
-            KerberosPrincipal clientPrincipal = authenticator.getClientPrincipal();
+            KerberosPrincipal clientPrincipal = KerberosUtils.getKerberosPrincipal( 
+                authenticator.getCName(), authenticator.getCRealm() );
             String desiredPassword = changepwContext.getPassword();
 
             InetAddress clientAddress = changepwContext.getClientAddress();
@@ -357,22 +353,21 @@ public class ChangePasswordService
 
         // create priv message
         // user-data component is short result code
-        EncKrbPrivPartModifier modifier = new EncKrbPrivPartModifier();
+        EncKrbPrivPart privPart = new EncKrbPrivPart();
         byte[] resultCode =
             { ( byte ) 0x00, ( byte ) 0x00 };
-        modifier.setUserData( resultCode );
+        privPart.setUserData( resultCode );
 
-        modifier.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
-        EncKrbPrivPart privPart = modifier.getEncKrbPrivPart();
+        privPart.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
 
         // get the subsession key from the Authenticator
-        EncryptionKey subSessionKey = authenticator.getSubSessionKey();
+        EncryptionKey subSessionKey = authenticator.getSubKey();
 
         EncryptedData encPrivPart;
 
         try
         {
-            encPrivPart = cipherTextHandler.seal( subSessionKey, privPart, KeyUsage.NUMBER13 );
+            encPrivPart = cipherTextHandler.seal( subSessionKey, privPart, KeyUsage.KRB_PRIV_ENC_PART_CHOSEN_KEY );
         }
         catch ( KerberosException ke )
         {
@@ -382,19 +377,17 @@ public class ChangePasswordService
         PrivateMessage privateMessage = new PrivateMessage( encPrivPart );
 
         // Begin AP_REP generation
-        EncApRepPartModifier encApModifier = new EncApRepPartModifier();
-        encApModifier.setClientTime( authenticator.getClientTime() );
-        encApModifier.setClientMicroSecond( authenticator.getClientMicroSecond() );
-        encApModifier.setSequenceNumber( Integer.valueOf( authenticator.getSequenceNumber() ) );
-        encApModifier.setSubSessionKey( authenticator.getSubSessionKey() );
-
-        EncApRepPart repPart = encApModifier.getEncApRepPart();
+        EncApRepPart repPart = new EncApRepPart();
+        repPart.setCTime( authenticator.getCtime() );
+        repPart.setCusec( authenticator.getCusec() );
+        repPart.setSeqNumber( Integer.valueOf( authenticator.getSeqNumber() ) );
+        repPart.setSubkey( authenticator.getSubKey() );
 
         EncryptedData encRepPart;
 
         try
         {
-            encRepPart = cipherTextHandler.seal( ticket.getEncTicketPart().getSessionKey(), repPart, KeyUsage.NUMBER12 );
+            encRepPart = cipherTextHandler.seal( ticket.getEncTicketPart().getSessionKey(), repPart, KeyUsage.AP_REP_ENC_PART_SESS_KEY );
         }
         catch ( KerberosException ke )
         {

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/CheckPasswordPolicy.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/CheckPasswordPolicy.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/CheckPasswordPolicy.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/CheckPasswordPolicy.java Thu Dec  9 00:14:14 2010
@@ -28,7 +28,8 @@ import javax.security.auth.kerberos.Kerb
 import org.apache.directory.server.changepw.ChangePasswordServer;
 import org.apache.directory.server.changepw.exceptions.ChangePasswordException;
 import org.apache.directory.server.changepw.exceptions.ErrorType;
-import org.apache.directory.server.kerberos.shared.messages.components.Authenticator;
+import org.apache.directory.shared.kerberos.KerberosUtils;
+import org.apache.directory.shared.kerberos.messages.Authenticator;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.handler.chain.IoHandlerCommand;
 import org.slf4j.Logger;
@@ -54,7 +55,8 @@ public class CheckPasswordPolicy impleme
 
         ChangePasswordServer config = changepwContext.getConfig();
         Authenticator authenticator = changepwContext.getAuthenticator();
-        KerberosPrincipal clientPrincipal = authenticator.getClientPrincipal();
+        KerberosPrincipal clientPrincipal = KerberosUtils.getKerberosPrincipal( 
+            authenticator.getCName(), authenticator.getCRealm() );
 
         String password = changepwContext.getPassword();
         String username = clientPrincipal.getName();

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/value/ChangePasswordData.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/value/ChangePasswordData.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/value/ChangePasswordData.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/value/ChangePasswordData.java Thu Dec  9 00:14:14 2010
@@ -20,7 +20,7 @@
 package org.apache.directory.server.changepw.value;
 
 
-import org.apache.directory.server.kerberos.shared.messages.value.PrincipalName;
+import org.apache.directory.shared.kerberos.components.PrincipalName;
 
 
 /**

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/value/ChangePasswordDataModifier.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/value/ChangePasswordDataModifier.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/value/ChangePasswordDataModifier.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/value/ChangePasswordDataModifier.java Thu Dec  9 00:14:14 2010
@@ -20,7 +20,7 @@
 package org.apache.directory.server.changepw.value;
 
 
-import org.apache.directory.server.kerberos.shared.messages.value.PrincipalName;
+import org.apache.directory.shared.kerberos.components.PrincipalName;
 
 
 /**

Modified: directory/apacheds/trunk/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/ChangepwProtocolHandlerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/ChangepwProtocolHandlerTest.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/ChangepwProtocolHandlerTest.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/ChangepwProtocolHandlerTest.java Thu Dec  9 00:14:14 2010
@@ -20,6 +20,8 @@
 package org.apache.directory.server.changepw.protocol;
 
 
+import static org.junit.Assert.assertEquals;
+
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.InetAddress;
@@ -37,28 +39,27 @@ import org.apache.directory.server.chang
 import org.apache.directory.server.changepw.messages.ChangePasswordRequest;
 import org.apache.directory.server.changepw.value.ChangePasswordData;
 import org.apache.directory.server.changepw.value.ChangePasswordDataModifier;
-import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.CipherTextHandler;
-import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.KeyUsage;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.RandomKeyFactory;
-import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
-import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
-import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
-import org.apache.directory.server.kerberos.shared.messages.components.AuthenticatorModifier;
-import org.apache.directory.server.kerberos.shared.messages.components.EncKrbPrivPart;
-import org.apache.directory.server.kerberos.shared.messages.components.EncKrbPrivPartModifier;
-import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
-import org.apache.directory.server.kerberos.shared.messages.value.ApOptions;
-import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData;
-import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
-import org.apache.directory.server.kerberos.shared.messages.value.HostAddress;
-import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
-import org.apache.directory.server.kerberos.shared.messages.value.PrincipalName;
-import org.apache.directory.server.kerberos.shared.messages.value.types.PrincipalNameType;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.TicketFactory;
+import org.apache.directory.shared.kerberos.KerberosMessageType;
+import org.apache.directory.shared.kerberos.KerberosTime;
+import org.apache.directory.shared.kerberos.codec.options.ApOptions;
+import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
+import org.apache.directory.shared.kerberos.codec.types.PrincipalNameType;
+import org.apache.directory.shared.kerberos.components.EncKrbPrivPart;
+import org.apache.directory.shared.kerberos.components.EncryptedData;
+import org.apache.directory.shared.kerberos.components.EncryptionKey;
+import org.apache.directory.shared.kerberos.components.HostAddress;
+import org.apache.directory.shared.kerberos.components.PrincipalName;
+import org.apache.directory.shared.kerberos.exceptions.KerberosException;
+import org.apache.directory.shared.kerberos.messages.ApReq;
+import org.apache.directory.shared.kerberos.messages.Authenticator;
+import org.apache.directory.shared.kerberos.messages.KrbError;
+import org.apache.directory.shared.kerberos.messages.Ticket;
 import org.apache.mina.core.future.WriteFuture;
 import org.apache.mina.core.session.DummySession;
 import org.junit.BeforeClass;
@@ -66,8 +67,6 @@ import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import static org.junit.Assert.assertEquals;
-
 /**
  * Tests the ChangePasswordProtocolHandler.
  *
@@ -115,7 +114,7 @@ public class ChangepwProtocolHandlerTest
         handler.messageReceived( session, message );
 
         ChangePasswordError reply = ( ChangePasswordError ) session.getMessage();
-        ErrorMessage error = reply.getErrorMessage();
+        KrbError error = reply.getKrbError();
         assertEquals( "Protocol version unsupported", 6, error.getErrorCode() );
     }
 
@@ -133,7 +132,7 @@ public class ChangepwProtocolHandlerTest
         handler.messageReceived( session, message );
 
         ChangePasswordError reply = ( ChangePasswordError ) session.getMessage();
-        ErrorMessage error = reply.getErrorMessage();
+        KrbError error = reply.getKrbError();
         assertEquals( "Request failed due to an error in authentication processing", 3, error.getErrorCode() );
     }
 
@@ -162,19 +161,22 @@ public class ChangepwProtocolHandlerTest
 
         ApOptions apOptions = new ApOptions();
 
-        AuthenticatorModifier modifier = new AuthenticatorModifier();
-        modifier.setVersionNumber( 5 );
-        modifier.setClientRealm( "EXAMPLE.COM" );
-        modifier.setClientName( getPrincipalName( "hnelson" ) );
-        modifier.setClientTime( new KerberosTime() );
-        modifier.setClientMicroSecond( 0 );
-
-        modifier.setSubSessionKey( subSessionKey );
-
-        EncryptedData encryptedAuthenticator = cipherTextHandler.seal( serviceTicket.getEncTicketPart().getSessionKey(), modifier
-                .getAuthenticator(), KeyUsage.NUMBER11 );
-
-        ApplicationRequest apReq = new ApplicationRequest( apOptions, serviceTicket, encryptedAuthenticator );
+        Authenticator authenticator = new Authenticator();
+        authenticator.setVersionNumber( 5 );
+        authenticator.setCRealm( "EXAMPLE.COM" );
+        authenticator.setCName( getPrincipalName( "hnelson" ) );
+        authenticator.setCTime( new KerberosTime() );
+        authenticator.setCusec( 0 );
+
+        authenticator.setSubKey( subSessionKey );
+
+        EncryptedData encryptedAuthenticator = cipherTextHandler.seal( serviceTicket.getEncTicketPart().getKey(), authenticator
+                , KeyUsage.AP_REQ_AUTHNT_SESS_KEY );
+
+        ApReq apReq = new ApReq();
+        apReq.setOption( apOptions );
+        apReq.setTicket( serviceTicket );
+        apReq.setAuthenticator( encryptedAuthenticator );
 
         String newPassword = "secretsecret";
 
@@ -185,7 +187,7 @@ public class ChangepwProtocolHandlerTest
         handler.messageReceived( session, message );
 
         ChangePasswordError reply = ( ChangePasswordError ) session.getMessage();
-        ErrorMessage error = reply.getErrorMessage();
+        KrbError error = reply.getKrbError();
         assertEquals( "Initial flag required", 7, error.getErrorCode() );
 
         //ChangePasswordReply reply = ( ChangePasswordReply ) session.getMessage();
@@ -240,17 +242,20 @@ public class ChangepwProtocolHandlerTest
 
         ApOptions apOptions = new ApOptions();
 
-        AuthenticatorModifier modifier = new AuthenticatorModifier();
-        modifier.setVersionNumber( 5 );
-        modifier.setClientRealm( "EXAMPLE.COM" );
-        modifier.setClientName( getPrincipalName( "hnelson" ) );
-        modifier.setClientTime( new KerberosTime() );
-        modifier.setClientMicroSecond( 0 );
-
-        EncryptedData encryptedAuthenticator = cipherTextHandler.seal( serverKey, modifier.getAuthenticator(),
-                KeyUsage.NUMBER11 );
-
-        ApplicationRequest apReq = new ApplicationRequest( apOptions, serviceTicket, encryptedAuthenticator );
+        Authenticator authenticator = new Authenticator();
+        authenticator.setVersionNumber( 5 );
+        authenticator.setCRealm( "EXAMPLE.COM" );
+        authenticator.setCName( getPrincipalName( "hnelson" ) );
+        authenticator.setCTime( new KerberosTime() );
+        authenticator.setCusec( 0 );
+
+        EncryptedData encryptedAuthenticator = cipherTextHandler.seal( serverKey, authenticator,
+                KeyUsage.AP_REQ_AUTHNT_SESS_KEY );
+
+        ApReq apReq = new ApReq();
+        apReq.setOption( apOptions );
+        apReq.setTicket( serviceTicket );
+        apReq.setAuthenticator( encryptedAuthenticator );
 
         String newPassword = "secretsecret";
 
@@ -261,7 +266,7 @@ public class ChangepwProtocolHandlerTest
         handler.messageReceived( session, message );
 
         ChangePasswordError reply = ( ChangePasswordError ) session.getMessage();
-        ErrorMessage error = reply.getErrorMessage();
+        KrbError error = reply.getKrbError();
         assertEquals( "Protocol version unsupported", 6, error.getErrorCode() );
     }
 
@@ -273,13 +278,12 @@ public class ChangepwProtocolHandlerTest
             throws UnsupportedEncodingException, KerberosException, UnknownHostException
     {
         // Make private message part.
-        EncKrbPrivPartModifier privPartModifier = new EncKrbPrivPartModifier();
-        privPartModifier.setUserData( newPassword.getBytes( "UTF-8" ) );
-        privPartModifier.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
-        EncKrbPrivPart encReqPrivPart = privPartModifier.getEncKrbPrivPart();
+        EncKrbPrivPart encReqPrivPart = new EncKrbPrivPart();
+        encReqPrivPart.setUserData( newPassword.getBytes( "UTF-8" ) );
+        encReqPrivPart.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
 
         // Seal private message part.
-        EncryptedData encryptedPrivPart = cipherTextHandler.seal( subSessionKey, encReqPrivPart, KeyUsage.NUMBER13 );
+        EncryptedData encryptedPrivPart = cipherTextHandler.seal( subSessionKey, encReqPrivPart, KeyUsage.KRB_PRIV_ENC_PART_CHOSEN_KEY );
 
         // Make private message with private message part.
         PrivateMessage privateMessage = new PrivateMessage();
@@ -299,7 +303,7 @@ public class ChangepwProtocolHandlerTest
             UnknownHostException, IOException
     {
         // Make private message part.
-        EncKrbPrivPartModifier privPartModifier = new EncKrbPrivPartModifier();
+        EncKrbPrivPart encReqPrivPart = new EncKrbPrivPart();
 
         ChangePasswordDataModifier dataModifier = new ChangePasswordDataModifier();
         dataModifier.setNewPassword( newPassword.getBytes() );
@@ -310,13 +314,12 @@ public class ChangepwProtocolHandlerTest
         ChangePasswordDataEncoder encoder = new ChangePasswordDataEncoder();
         byte[] dataBytes = encoder.encode( data );
 
-        privPartModifier.setUserData( dataBytes );
+        encReqPrivPart.setUserData( dataBytes );
 
-        privPartModifier.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
-        EncKrbPrivPart encReqPrivPart = privPartModifier.getEncKrbPrivPart();
+        encReqPrivPart.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
 
         // Seal private message part.
-        EncryptedData encryptedPrivPart = cipherTextHandler.seal( subSessionKey, encReqPrivPart, KeyUsage.NUMBER13 );
+        EncryptedData encryptedPrivPart = cipherTextHandler.seal( subSessionKey, encReqPrivPart, KeyUsage.KRB_PRIV_ENC_PART_CHOSEN_KEY );
 
         // Make private message with private message part.
         PrivateMessage privateMessage = new PrivateMessage();

Modified: directory/apacheds/trunk/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/MapPrincipalStoreImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/MapPrincipalStoreImpl.java?rev=1043794&r1=1043793&r2=1043794&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/MapPrincipalStoreImpl.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/MapPrincipalStoreImpl.java Thu Dec  9 00:14:14 2010
@@ -25,12 +25,12 @@ import java.util.Map;
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
-import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.KerberosKeyFactory;
-import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntryModifier;
+import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
+import org.apache.directory.shared.kerberos.components.EncryptionKey;
 
 
 /**



Mime
View raw message