directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r578743 [10/12] - in /directory/apacheds/branches/apacheds-kerberos: kerberos-shared/ kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/ kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypt...
Date Mon, 24 Sep 2007 10:18:45 GMT
Added: directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/KerberosRequestBodyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/KerberosRequestBodyTest.java?rev=578743&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/KerberosRequestBodyTest.java (added)
+++ directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/KerberosRequestBodyTest.java Mon Sep 24 03:18:05 2007
@@ -0,0 +1,244 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.kerberos.shared.messages.value;
+
+
+import java.io.ByteArrayOutputStream;
+import java.nio.ByteBuffer;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+import javax.security.auth.kerberos.KerberosPrincipal;
+
+import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
+import org.apache.directory.server.kerberos.shared.io.encoder.KdcRequestEncoder;
+import org.apache.directory.server.kerberos.shared.messages.KdcRequest;
+import org.apache.directory.server.kerberos.shared.messages.MessageType;
+import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
+import org.apache.directory.server.kerberos.shared.messages.value.flags.KdcOption;
+import org.apache.directory.server.kerberos.shared.messages.value.flags.KdcOptions;
+import org.apache.directory.server.kerberos.shared.messages.value.types.HostAddressType;
+import org.apache.directory.server.kerberos.shared.messages.value.types.PrincipalNameType;
+import org.apache.directory.server.kerberos.shared.store.TicketFactory;
+import org.apache.directory.shared.asn1.der.ASN1OutputStream;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test the KerberosRequestBody encoding and decoding
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 542147 $, $Date: 2007-05-28 10:14:21 +0200 (Mon, 28 May 2007) $
+ */
+public class KerberosRequestBodyTest extends TestCase
+{
+    private static Date date = null;
+    
+    static
+    {
+        try
+        {
+            date = new SimpleDateFormat( "yyyyMMddHHmmss'Z'" ).parse( "20070717114503Z" );
+        }
+        catch ( ParseException pe )
+        {
+            // Do nothing
+        }
+    }
+
+    public void testEncodingKerberosRequestBody() throws Exception
+    {
+        KerberosRequestBody krb = new KerberosRequestBody();
+        
+        // KdcOptions
+        KdcOptions kdcOptions = new KdcOptions();
+        kdcOptions.setFlag( KdcOption.FORWARDABLE );
+        kdcOptions.setFlag( KdcOption.PROXIABLE );
+        kdcOptions.setFlag( KdcOption.POSTDATED );
+        kdcOptions.setFlag( KdcOption.VALIDATE );
+        
+        krb.setKdcOptions( kdcOptions );
+        
+        // Client principal
+        KerberosPrincipal ckp = new KerberosPrincipal( "test@APACHE.ORG" );
+
+        // cName
+        krb.setClientPrincipal( ckp );
+
+        // Realm
+        krb.setRealm( "APACHE.ORG" );
+        
+        // sName
+        KerberosPrincipal skp = new KerberosPrincipal( "server@APACHE.ORG" );
+        krb.setServerPrincipal( skp );
+        
+        // from, till and renew
+        KerberosTime kerberosTime = new KerberosTime( date );
+        krb.setFrom( kerberosTime );
+        krb.setTill( kerberosTime );
+        krb.setRenewtime( kerberosTime );
+        
+        // nonce
+        krb.setNonce( 1000 );
+        
+        // EncryptionTypes
+        krb.addEncryptionType( EncryptionType.AES128_CTS_HMAC_SHA1_96 );
+        krb.addEncryptionType( EncryptionType.DES3_CBC_MD5 );
+        
+        // addresses
+        HostAddress[] ha = new HostAddress[]
+            { 
+                new HostAddress( HostAddressType.ADDRTYPE_INET, new byte[] { 0x01, 0x02, 0x03, 0x04 } ) 
+            };
+
+        HostAddresses addresses = new HostAddresses( ha );
+        krb.setAddresses( addresses );
+        
+        // encAuthorizationData
+        EncryptedData ed = new EncryptedData( EncryptionType.AES128_CTS_HMAC_SHA1_96, 1, new byte[]
+            { 0x01, 0x02, 0x03, 0x04 } );
+        krb.setEncAuthorizationData( ed );
+        
+        // additionalTickets
+        TicketFactory ticketFactory = new TicketFactory();
+
+        KerberosPrincipal clientPrincipal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
+        KerberosPrincipal serverPrincipal = new KerberosPrincipal( "kadmin/changepw@EXAMPLE.COM" );
+        String serverPassword = "s3crEt";
+
+        EncryptionKey serverKey = ticketFactory.getServerKey( serverPrincipal, serverPassword );
+
+        Ticket serviceTicket = ticketFactory.getTicket( clientPrincipal, serverPrincipal, serverKey );
+        
+        krb.addAdditionalTicket( serviceTicket );
+
+        // Encode the body
+        ByteBuffer encoded = ByteBuffer.allocate( krb.computeLength() );
+        krb.encode( encoded );
+        
+        // Check with the old encoder
+        KdcRequestEncoder encoder = new KdcRequestEncoder();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ASN1OutputStream aos = new ASN1OutputStream( baos );
+        
+        KdcRequest request = new KdcRequest( MessageType.KRB_AS_REQ, (List<PreAuthenticationData>)null, krb );
+
+        aos.writeObject( encoder.encodeKdcRequestBody( request ) );
+        aos.close();
+        
+        byte[] result = baos.toByteArray();
+        
+        // The expected result
+        byte[] expectedResult = new byte[]
+            { 
+                0x30, (byte)0x82, 0x01, (byte)0xA9, 
+                  (byte)0xA0, 0x07, 
+                    0x03, 0x05, 
+                      0x00, 0x52, 0x00, 0x00, 0x01,
+                  (byte)0xA1, 0x11,
+                    0x30, 0x0F, 
+                      (byte) 0xA0, 0x03, 
+                        0x02, 0x01, 0x01, 
+                      (byte) 0xA1, 0x08, 
+                        0x30, 0x06, 
+                          0x1B, 0x04, 
+                            't', 'e', 's', 't',
+                  (byte)0xA2,0x0C,
+                    0x1B, 0x0A,
+                      'A', 'P', 'A', 'C', 'H', 'E', '.', 'O', 'R', 'G',
+                  (byte)0xA3, 0x13,
+                    0x30, 0x11, 
+                      (byte) 0xA0, 0x03, 
+                        0x02, 0x01, 0x01, 
+                      (byte) 0xA1, 0x0A, 
+                        0x30, 0x08, 
+                          0x1B, 0x06, 
+                            's', 'e', 'r', 'v', 'e', 'r',
+                  (byte)0xA4, 0x11,
+                    0x18, 0x0F,
+                      '2', '0', '0', '7', '0', '7', '1', '7', '0', '9', '4', '5', '0', '3', 'Z',
+                  (byte)0xA5, 0x11,
+                    0x18, 0x0F,
+                      '2', '0', '0', '7', '0', '7', '1', '7', '0', '9', '4', '5', '0', '3', 'Z',
+                  (byte)0xA6, 0x11,
+                    0x18, 0x0F,
+                      '2', '0', '0', '7', '0', '7', '1', '7', '0', '9', '4', '5', '0', '3', 'Z',
+                  (byte)0xA7, 0x04,
+                    0x02, (byte)0x02, 0x03, (byte)0xE8,
+                  (byte)0xA8, 0x08,
+                    0x30, 0x06,
+                      0x02, 0x01, 0x11,
+                      0x02, 0x01, 0x05,
+                  (byte)0xA9, 0x11,
+                    0x30, 0x0F, 
+                      0x30, 0x0d, 
+                        (byte)0xA0, 0x03, 
+                          0x02, 0x01, 0x02, 
+                        (byte)0xA1, 0x06, 
+                          0x04, 0x04, 
+                            0x01, 0x02, 0x03, 0x04,
+                  (byte)0xAA, 0x14,
+                    0x30, 0x12, 
+                      (byte)0xA0, 0x03, 
+                        0x02, 0x01, 0x11, 
+                      (byte)0xA1, 0x03, 
+                        0x02, 0x01, 0x01, 
+                      (byte)0xA2, 0x06, 
+                        0x04, 0x04, 0x01, 0x02, 0x03, 0x04,
+                  (byte)0xAB, (byte)0x81, (byte)0xF5,
+                    0x30, (byte)0x81, (byte)0xF2,
+                      0x61, (byte)0x81, (byte)0xEF,
+                        0x30,  (byte)0x81, (byte)0xEC, 
+                          (byte)0xA0, 0x03,
+                            0x02, 0x01, 0x05,
+                          (byte)0xA1, 0x0D,
+                            0x1B, 0x0B, 
+                              'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
+                          (byte)0xA2, 0x1D,
+                            0x30, 0x1B,
+                              (byte)0xA0, 0x03, 
+                                0x02, 0x01, 0x01, 
+                              (byte)0xA1, 0x14, 
+                                0x30, 0x12, 
+                                  0x1B, 0x06, 
+                                    'k', 'a', 'd', 'm', 'i', 'n',
+                                  0x1B, 0x08,
+                                    'c', 'h', 'a', 'n', 'g', 'e', 'p', 'w',
+                          (byte)0xA3, (byte)0x81, (byte)0xB6, 
+                            0x30, (byte)0x81, (byte)0xB3,
+                              (byte)0xA0, 0x03,
+                                0x02, 0x01, 0x03,
+                              (byte)0xA2, (byte)0x81, (byte)0xAB,
+                                0x04, (byte)0x81, (byte)0xA8
+            };
+
+        // We will just compared the first bytes (everyting before the encrypted data)
+        String expectedResultString = StringTools.dumpBytes( expectedResult );
+        String resultString = StringTools.dumpBytes( encoded.array() ).substring( 0,  expectedResultString.length() );
+        String encoderResultString = StringTools.dumpBytes( result ).substring( 0,  expectedResultString.length() );
+        
+        assertEquals( expectedResultString, resultString );
+        assertEquals( expectedResultString, encoderResultString );
+    }
+}

Added: directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/KerberosTimeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/KerberosTimeTest.java?rev=578743&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/KerberosTimeTest.java (added)
+++ directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/KerberosTimeTest.java Mon Sep 24 03:18:05 2007
@@ -0,0 +1,92 @@
+package org.apache.directory.server.kerberos.shared.messages.value;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import junit.framework.TestCase;
+
+public class KerberosTimeTest extends TestCase
+{
+
+    public void testKerberosTime()
+    {
+        fail( "Not yet implemented" );
+    }
+
+
+    public void testKerberosTimeLong()
+    {
+        fail( "Not yet implemented" );
+    }
+
+
+    public void testKerberosTimeDate()
+    {
+        fail( "Not yet implemented" );
+    }
+
+
+    public void testGetTimeString()
+    {
+        fail( "Not yet implemented" );
+    }
+
+
+    public void testGetTime() throws ParseException
+    {
+        String zuluTime = "20070708224829Z";
+        KerberosTime kt = KerberosTime.getTime( zuluTime );
+        
+        SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyyMMddHHmmss'Z'" );
+        TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
+        dateFormat.setTimeZone( UTC_TIME_ZONE );
+        Date date = dateFormat.parse( zuluTime );
+        
+        assertEquals( date, kt .toDate() );
+    }
+
+
+    public void testCompareTo()
+    {
+        fail( "Not yet implemented" );
+    }
+
+
+    public void testToDate()
+    {
+        fail( "Not yet implemented" );
+    }
+
+
+    public void testIsInClockSkew()
+    {
+        fail( "Not yet implemented" );
+    }
+
+
+    public void testGreaterThan()
+    {
+        fail( "Not yet implemented" );
+    }
+
+
+    public void testLessThan()
+    {
+        fail( "Not yet implemented" );
+    }
+
+
+    public void testEqualsKerberosTime()
+    {
+        fail( "Not yet implemented" );
+    }
+
+
+    public void testIsZero()
+    {
+        fail( "Not yet implemented" );
+    }
+
+}

Added: directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PreAuthEncryptedTimestampTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PreAuthEncryptedTimestampTest.java?rev=578743&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PreAuthEncryptedTimestampTest.java (added)
+++ directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PreAuthEncryptedTimestampTest.java Mon Sep 24 03:18:05 2007
@@ -0,0 +1,77 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.kerberos.shared.messages.value;
+
+
+import java.nio.ByteBuffer;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test the PA-ENC-TIMESTAMP encoding and decoding
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 542147 $, $Date: 2007-05-28 10:14:21 +0200 (Mon, 28 May 2007) $
+ */
+public class PreAuthEncryptedTimestampTest extends TestCase
+{
+    private static Date date = null;
+    
+    static
+    {
+        try
+        {
+            date = new SimpleDateFormat( "yyyyMMddHHmmss'Z'" ).parse( "20070717114503Z" );
+        }
+        catch ( ParseException pe )
+        {
+            // Do nothing
+        }
+    }
+
+    public void testEncodingPreAuthEncryptedTimestamp() throws Exception
+    {
+        KerberosTime paTimestamp = new KerberosTime( date );
+
+        PreAuthEncryptedTimestamp paet = new PreAuthEncryptedTimestamp( paTimestamp, 128 );
+        
+        ByteBuffer encoded = ByteBuffer.allocate( paet.computeLength() );
+
+        paet.encode( encoded );
+
+        byte[] expectedResult = new byte[]
+            { 
+            0x30, 0x19, 
+              (byte)0xA0, 0x11,
+                0x18, 0x0F,
+                  '2', '0', '0', '7', '0', '7', '1', '7', '0', '9', '4', '5', '0', '3', 'Z',
+              (byte)0xA1, 0x04, 
+                0x02, 0x02, 0x00, (byte)0x80 
+            };
+
+        assertEquals( StringTools.dumpBytes( expectedResult ), StringTools.dumpBytes( encoded.array() ) );
+    }
+}

Added: directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PreAuthenticationDataTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PreAuthenticationDataTest.java?rev=578743&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PreAuthenticationDataTest.java (added)
+++ directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PreAuthenticationDataTest.java Mon Sep 24 03:18:05 2007
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.kerberos.shared.messages.value;
+
+
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+
+import org.apache.directory.server.kerberos.shared.messages.value.types.PreAuthenticationDataType;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test the PreAuthenticationData encoding and decoding
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 542147 $, $Date: 2007-05-28 10:14:21 +0200 (Mon, 28 May 2007) $
+ */
+public class PreAuthenticationDataTest extends TestCase
+{
+    public void testEncodingPreAuthenticationData() throws Exception
+    {
+        PreAuthenticationData pad = new PreAuthenticationData( PreAuthenticationDataType.PA_ASF3_SALT, new byte[]
+            { 0x01, 0x02, 0x03 } );
+
+        ByteBuffer encoded = ByteBuffer.allocate( pad.computeLength() );
+
+        pad.encode( encoded );
+
+        byte[] expectedResult = new byte[]
+            { 
+            0x30, 0x0c, 
+              ( byte ) 0xA1, 0x03, 
+                0x02, 0x01, 0x0A, 
+              ( byte ) 0xA2, 0x05, 
+                0x04, 0x03, 
+                  0x01, 0x02, 0x03 
+            };
+
+        assertTrue( Arrays.equals( expectedResult, encoded.array() ) );
+    }
+
+
+    public void testEncodingNullPreAuthenticationData() throws Exception
+    {
+        PreAuthenticationData pad = new PreAuthenticationData( PreAuthenticationDataType.PA_ASF3_SALT, null );
+
+        ByteBuffer encoded = ByteBuffer.allocate( pad.computeLength() );
+
+        pad.encode( encoded );
+
+        byte[] expectedResult = new byte[]
+            { 
+                0x30, 0x09, 
+                  ( byte ) 0xA1, 0x03, 
+                    0x02, 0x01, 0x0A, 
+                  ( byte ) 0xA2, 0x02, 
+                    0x04, 0x00 
+            };
+
+        assertTrue( Arrays.equals( expectedResult, encoded.array() ) );
+    }
+}

Added: directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalNameTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalNameTest.java?rev=578743&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalNameTest.java (added)
+++ directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalNameTest.java Mon Sep 24 03:18:05 2007
@@ -0,0 +1,110 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.kerberos.shared.messages.value;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.server.kerberos.shared.messages.value.types.PrincipalNameType;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test the PrincipalName encoding and decoding
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 542147 $, $Date: 2007-05-28 10:14:21 +0200 (Mon, 28 May 2007) $
+ */
+public class PrincipalNameTest extends TestCase
+{
+    public void testEncodingPrincipalNameOneName() throws Exception
+    {
+        PrincipalName principal = new PrincipalName( "Test@APACHE", PrincipalNameType.KRB_NT_PRINCIPAL );
+
+        ByteBuffer encoded = ByteBuffer.allocate( principal.computeLength() );
+
+        principal.encode( encoded );
+
+        byte[] expectedResult = new byte[]
+            { 
+              0x30, 0x0F, 
+                (byte) 0xA0, 0x03, 
+                  0x02, 0x01, 0x01, 
+                (byte) 0xA1, 0x08, 
+                  0x30, 0x06, 
+                    0x1B, 0x04, 
+                      'T', 'e', 's', 't' 
+            };
+
+        assertEquals( StringTools.dumpBytes( expectedResult ), StringTools.dumpBytes( encoded.array() ) );
+    }
+
+
+    public void testEncodingPrincipalName3names() throws Exception
+    {
+        PrincipalName principal = new PrincipalName( "Test1@APACHE", PrincipalNameType.KRB_NT_PRINCIPAL );
+        principal.addNameString( "Test2" );
+        principal.addNameString( "Test3" );
+
+        ByteBuffer encoded = ByteBuffer.allocate( principal.computeLength() );
+
+        principal.encode( encoded );
+
+        byte[] expectedResult = new byte[]
+            { 
+              0x30, 0x1e, 
+                (byte) 0xA0, 0x03, 
+                  0x02, 0x01, 0x01, 
+                (byte) 0xA1, 0x17, 
+                  0x30, 0x15, 
+                    0x1B, 0x05, 
+                      'T', 'e', 's', 't', '1', 
+                    0x1B, 0x05, 
+                      'T', 'e', 's', 't', '2', 
+                    0x1B, 0x05, 
+                      'T', 'e', 's', 't', '3' 
+            };
+
+        assertEquals( StringTools.dumpBytes( expectedResult ), StringTools.dumpBytes( encoded.array() ) );
+    }
+
+
+    public void testEncodingPrincipalNameNullName() throws Exception
+    {
+        PrincipalName principal = new PrincipalName( null, PrincipalNameType.KRB_NT_PRINCIPAL );
+
+        ByteBuffer encoded = ByteBuffer.allocate( principal.computeLength() );
+
+        principal.encode( encoded );
+
+        byte[] expectedResult = new byte[]
+            { 
+              0x30, 0x09, 
+                ( byte ) 0xA0, 0x03, 
+                  0x02, 0x01, 0x01, 
+                ( byte ) 0xA1, 0x02, 
+                  0x30, 0x00 
+            };
+
+        assertEquals( StringTools.dumpBytes( expectedResult ), StringTools.dumpBytes( encoded.array() ) );
+    }
+}

Added: directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/TransitedEncodingTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/TransitedEncodingTest.java?rev=578743&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/TransitedEncodingTest.java (added)
+++ directory/apacheds/branches/apacheds-kerberos/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/TransitedEncodingTest.java Mon Sep 24 03:18:05 2007
@@ -0,0 +1,80 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.kerberos.shared.messages.value;
+
+
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+
+import org.apache.directory.server.kerberos.shared.messages.value.types.TransitedEncodingType;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test the TransitedEncoding encoding and decoding
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 542147 $, $Date: 2007-05-28 10:14:21 +0200 (Mon, 28 May 2007) $
+ */
+public class TransitedEncodingTest extends TestCase
+{
+    public void testEncodingFast() throws Exception
+    {
+        TransitedEncoding te = new TransitedEncoding( TransitedEncodingType.DOMAIN_X500_COMPRESS, new byte[]
+            { 0x01, 0x02, 0x03 } );
+
+        ByteBuffer encoded = ByteBuffer.allocate( te.computeLength() );
+
+        te.encode( encoded );
+
+        byte[] expectedResult = new byte[]
+            { 
+              0x30, 0x0c, 
+                ( byte ) 0xA0, 0x03, 
+                  0x02, 0x01, 0x01, 
+                ( byte ) 0xA1, 0x05, 
+                  0x04, 0x03, 0x01, 0x02, 0x03 
+            };
+
+        assertTrue( Arrays.equals( expectedResult, encoded.array() ) );
+    }
+
+
+    public void testEncodingNoStructureFast() throws Exception
+    {
+        TransitedEncoding te = new TransitedEncoding( TransitedEncodingType.DOMAIN_X500_COMPRESS, null );
+
+        ByteBuffer encoded = ByteBuffer.allocate( te.computeLength() );
+
+        te.encode( encoded );
+
+        byte[] expectedResult = new byte[]
+            { 
+              0x30, 0x09, 
+                ( byte ) 0xA0, 0x03, 
+                  0x02, 0x01, 0x01, 
+                ( byte ) 0xA1, 0x02, 
+                  0x04, 0x00 
+            };
+
+        assertTrue( Arrays.equals( expectedResult, encoded.array() ) );
+    }
+}

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java Mon Sep 24 03:18:05 2007
@@ -254,14 +254,13 @@
 
         List<EncryptionType> encTypes = new ArrayList<EncryptionType>();
 
-        for ( String enc : encryptionTypeStrings )
+        for ( String encryptionType : encryptionTypeStrings )
         {
-            for ( EncryptionType type : EncryptionType.VALUES )
+        	EncryptionType type = EncryptionType.getByName( encryptionType );
+        	
+        	if ( type != EncryptionType.UNKNOWN )
             {
-                if ( type.toString().equalsIgnoreCase( enc ) )
-                {
-                    encTypes.add( type );
-                }
+                encTypes.add( type );
             }
         }
 

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordDataEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordDataEncoder.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordDataEncoder.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordDataEncoder.java Mon Sep 24 03:18:05 2007
@@ -20,12 +20,12 @@
 package org.apache.directory.server.changepw.io;
 
 
-import java.io.ByteArrayOutputStream;
 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.server.kerberos.shared.messages.value.PrincipalName;
 import org.apache.directory.shared.asn1.der.ASN1OutputStream;
 import org.apache.directory.shared.asn1.der.DERGeneralString;
 import org.apache.directory.shared.asn1.der.DEROctetString;
@@ -40,27 +40,6 @@
 public class ChangePasswordDataEncoder
 {
     /**
-     * Encodes a {@link ChangePasswordData} into a byte array.
-     *
-     * @param data
-     * @return The byte array.
-     * @throws IOException
-     */
-    public byte[] encode( ChangePasswordData data ) throws IOException
-    {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        ASN1OutputStream aos = new ASN1OutputStream( baos );
-
-        DERSequence dataSequence = encodeDataSequence( data );
-        aos.writeObject( dataSequence );
-
-        aos.close();
-
-        return baos.toByteArray();
-    }
-
-
-    /**
      * Encodes a {@link ChangePasswordData} into a {@link ByteBuffer}.
      *
      * @param data
@@ -83,17 +62,10 @@
         DERSequence sequence = new DERSequence();
         sequence.add( new DERTaggedObject( 0, new DEROctetString( data.getPassword() ) ) );
 
-        // OPTIONAL
-        if ( data.getPrincipalName() != null )
-        {
-            sequence.add( new DERTaggedObject( 1, PrincipalNameEncoder.encode( data.getPrincipalName() ) ) );
-        }
-
-        // OPTIONAL
-        if ( data.getRealm() != null )
-        {
-            sequence.add( new DERTaggedObject( 2, DERGeneralString.valueOf( data.getRealm() ) ) );
-        }
+        PrincipalName name = data.getPrincipalName();
+        sequence.add( new DERTaggedObject( 1, PrincipalNameEncoder.encode( name ) ) );
+
+        sequence.add( new DERTaggedObject( 2, DERGeneralString.valueOf( data.getRealm() ) ) );
 
         return sequence;
     }

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorDecoder.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorDecoder.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorDecoder.java Mon Sep 24 03:18:05 2007
@@ -26,7 +26,7 @@
 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.shared.messages.KerberosError;
 
 
 /**
@@ -50,11 +50,12 @@
         ChangePasswordErrorModifier modifier = new ChangePasswordErrorModifier();
 
         short messageLength = buf.getShort();
+        modifier.setMessageLength( messageLength );
 
         modifier.setProtocolVersionNumber( buf.getShort() );
 
         // AP_REQ length will be 0 for error messages
-        buf.getShort(); // authHeader length
+        modifier.setAuthHeaderLength( buf.getShort() );
 
         int errorLength = messageLength - HEADER_LENGTH;
 
@@ -64,7 +65,7 @@
         ByteBuffer errorBuffer = ByteBuffer.wrap( errorBytes );
 
         ErrorMessageDecoder errorDecoder = new ErrorMessageDecoder();
-        ErrorMessage errorMessage = errorDecoder.decode( errorBuffer );
+        KerberosError errorMessage = errorDecoder.decode( errorBuffer );
 
         modifier.setErrorMessage( errorMessage );
 

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorEncoder.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorEncoder.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordErrorEncoder.java Mon Sep 24 03:18:05 2007
@@ -26,7 +26,7 @@
 
 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.server.kerberos.shared.messages.KerberosError;
 
 
 /**
@@ -48,7 +48,7 @@
     public void encode( ByteBuffer buf, ChangePasswordError message ) throws IOException
     {
         // Build error message bytes
-        ErrorMessage errorMessage = message.getErrorMessage();
+        KerberosError errorMessage = message.getErrorMessage();
         ErrorMessageEncoder errorEncoder = new ErrorMessageEncoder();
         byte[] errorBytes = errorEncoder.encode( errorMessage );
 

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestDecoder.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestDecoder.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestDecoder.java Mon Sep 24 03:18:05 2007
@@ -27,7 +27,7 @@
 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.ApplicationRequest;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
 
 
@@ -48,11 +48,11 @@
     {
         ChangePasswordRequestModifier modifier = new ChangePasswordRequestModifier();
 
-        buf.getShort(); // message length
-
+        modifier.setMessageLength( buf.getShort() );
         modifier.setProtocolVersionNumber( buf.getShort() );
 
         short authHeaderLength = buf.getShort();
+        modifier.setAuthHeaderLength( authHeaderLength );
 
         byte[] undecodedAuthHeader = new byte[authHeaderLength];
         buf.get( undecodedAuthHeader, 0, authHeaderLength );

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestEncoder.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestEncoder.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/io/ChangePasswordRequestEncoder.java Mon Sep 24 03:18:05 2007
@@ -26,7 +26,7 @@
 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.ApplicationRequest;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
 
 

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordError.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordError.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordError.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordError.java Mon Sep 24 03:18:05 2007
@@ -20,7 +20,7 @@
 package org.apache.directory.server.changepw.messages;
 
 
-import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
+import org.apache.directory.server.kerberos.shared.messages.KerberosError;
 
 
 /**
@@ -29,7 +29,7 @@
  */
 public class ChangePasswordError extends AbstractPasswordMessage
 {
-    private ErrorMessage errorMessage;
+    private KerberosError errorMessage;
 
 
     /**
@@ -40,20 +40,21 @@
      * @param authHeaderLength
      * @param errorMessage
      */
-    public ChangePasswordError( short versionNumber, ErrorMessage errorMessage )
+    public ChangePasswordError( short messageLength, short versionNumber, short authHeaderLength,
+        KerberosError errorMessage )
     {
-        super( versionNumber );
+        super( messageLength, versionNumber, authHeaderLength );
 
         this.errorMessage = errorMessage;
     }
 
 
     /**
-     * Returns the {@link ErrorMessage}.
+     * Returns the {@link KerberosError}.
      *
-     * @return The {@link ErrorMessage}.
+     * @return The {@link KerberosError}.
      */
-    public ErrorMessage getErrorMessage()
+    public KerberosError getErrorMessage()
     {
         return errorMessage;
     }

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordErrorModifier.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordErrorModifier.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordErrorModifier.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordErrorModifier.java Mon Sep 24 03:18:05 2007
@@ -20,7 +20,7 @@
 package org.apache.directory.server.changepw.messages;
 
 
-import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
+import org.apache.directory.server.kerberos.shared.messages.KerberosError;
 
 
 /**
@@ -29,7 +29,7 @@
  */
 public class ChangePasswordErrorModifier extends AbstractPasswordMessageModifier
 {
-    private ErrorMessage errorMessage;
+    private KerberosError errorMessage;
 
 
     /**
@@ -39,16 +39,16 @@
      */
     public ChangePasswordError getChangePasswordError()
     {
-        return new ChangePasswordError( versionNumber, errorMessage );
+        return new ChangePasswordError( messageLength, versionNumber, authHeaderLength, errorMessage );
     }
 
 
     /**
-     * Sets the {@link ErrorMessage}.
+     * Sets the {@link KerberosError}.
      *
      * @param errorMessage
      */
-    public void setErrorMessage( ErrorMessage errorMessage )
+    public void setErrorMessage( KerberosError errorMessage )
     {
         this.errorMessage = errorMessage;
     }

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequest.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequest.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequest.java Mon Sep 24 03:18:05 2007
@@ -20,7 +20,7 @@
 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.ApplicationRequest;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
 
 
@@ -37,13 +37,16 @@
     /**
      * Creates a new instance of ChangePasswordRequest.
      *
+     * @param messageLength
      * @param versionNumber
+     * @param authHeaderLength
      * @param authHeader
      * @param privateMessage
      */
-    public ChangePasswordRequest( short versionNumber, ApplicationRequest authHeader, PrivateMessage privateMessage )
+    public ChangePasswordRequest( short messageLength, short versionNumber, short authHeaderLength,
+        ApplicationRequest authHeader, PrivateMessage privateMessage )
     {
-        super( versionNumber );
+        super( messageLength, versionNumber, authHeaderLength );
 
         this.authHeader = authHeader;
         this.privateMessage = privateMessage;

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequestModifier.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequestModifier.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequestModifier.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/messages/ChangePasswordRequestModifier.java Mon Sep 24 03:18:05 2007
@@ -20,7 +20,7 @@
 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.ApplicationRequest;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
 
 
@@ -41,7 +41,7 @@
      */
     public ChangePasswordRequest getChangePasswordMessage()
     {
-        return new ChangePasswordRequest( versionNumber, authHeader, privateMessage );
+        return new ChangePasswordRequest( messageLength, versionNumber, authHeaderLength, authHeader, privateMessage );
     }
 
 

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java Mon Sep 24 03:18:05 2007
@@ -36,9 +36,9 @@
 import org.apache.directory.server.changepw.service.ChangePasswordChain;
 import org.apache.directory.server.changepw.service.ChangePasswordContext;
 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.KerberosError;
 import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
+import org.apache.directory.server.kerberos.shared.messages.value.types.KerberosErrorType;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.IoHandler;
@@ -155,7 +155,7 @@
                 log.warn( ke.getMessage() );
             }
 
-            ErrorMessage errorMessage = getErrorMessage( config.getServicePrincipal(), ke );
+            KerberosError errorMessage = getErrorMessage( config.getServicePrincipal(), ke );
 
             ChangePasswordErrorModifier modifier = new ChangePasswordErrorModifier();
             modifier.setErrorMessage( errorMessage );
@@ -187,20 +187,21 @@
     }
 
 
-    private ErrorMessage getErrorMessage( KerberosPrincipal principal, KerberosException exception )
+    private KerberosError getErrorMessage( KerberosPrincipal principal, KerberosException exception )
     {
-        ErrorMessageModifier modifier = new ErrorMessageModifier();
-
+        KerberosError kerberosError = new KerberosError();
+        
         KerberosTime now = new KerberosTime();
 
-        modifier.setErrorCode( exception.getErrorCode() );
-        modifier.setExplanatoryText( exception.getMessage() );
-        modifier.setServerPrincipal( principal );
-        modifier.setServerTime( now );
-        modifier.setServerMicroSecond( 0 );
-        modifier.setExplanatoryData( buildExplanatoryData( exception ) );
+        kerberosError.setErrorCode( KerberosErrorType.getTypeByOrdinal( exception.getErrorCode() ) );
+        kerberosError.setExplanatoryText( exception.getMessage() );
+        kerberosError.setServerPrincipal( principal );
+        
+        kerberosError.setServerTime( now );
+        kerberosError.setServerMicroseconds( 0 );
+        kerberosError.setExplanatoryData( buildExplanatoryData( exception ) );
 
-        return modifier.getErrorMessage();
+        return kerberosError;
     }
 
 

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/BuildReply.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/BuildReply.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/BuildReply.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/BuildReply.java Mon Sep 24 03:18:05 2007
@@ -34,7 +34,6 @@
 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;
@@ -64,13 +63,12 @@
 
         // create priv message
         // user-data component is short result code
-        EncKrbPrivPartModifier modifier = new EncKrbPrivPartModifier();
+        EncKrbPrivPart encKrbPrivPart = new EncKrbPrivPart();
         byte[] resultCode =
             { ( byte ) 0x00, ( byte ) 0x00 };
-        modifier.setUserData( resultCode );
+        encKrbPrivPart.setUserData( resultCode );
 
-        modifier.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
-        EncKrbPrivPart privPart = modifier.getEncKrbPrivPart();
+        encKrbPrivPart.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
 
         // get the subsession key from the Authenticator
         EncryptionKey subSessionKey = authenticator.getSubSessionKey();
@@ -79,7 +77,7 @@
 
         try
         {
-            encPrivPart = cipherTextHandler.seal( subSessionKey, privPart, KeyUsage.NUMBER13 );
+            encPrivPart = cipherTextHandler.seal( subSessionKey, encKrbPrivPart, KeyUsage.NUMBER13 );
         }
         catch ( KerberosException ke )
         {

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordContext.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordContext.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/ChangePasswordContext.java Mon Sep 24 03:18:05 2007
@@ -25,7 +25,7 @@
 import org.apache.directory.server.changepw.ChangePasswordConfiguration;
 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.application.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;

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/GetAuthHeader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/GetAuthHeader.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/GetAuthHeader.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/GetAuthHeader.java Mon Sep 24 03:18:05 2007
@@ -20,10 +20,8 @@
 package org.apache.directory.server.changepw.service;
 
 
-import org.apache.directory.server.changepw.exceptions.ChangePasswordException;
-import org.apache.directory.server.changepw.exceptions.ErrorType;
 import org.apache.directory.server.changepw.messages.ChangePasswordRequest;
-import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
+import org.apache.directory.server.kerberos.shared.messages.application.ApplicationRequest;
 import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.chain.IoHandlerCommand;
@@ -44,16 +42,6 @@
     {
         ChangePasswordContext changepwContext = ( ChangePasswordContext ) session.getAttribute( getContextKey() );
         ChangePasswordRequest request = ( ChangePasswordRequest ) changepwContext.getRequest();
-
-        if ( request.getVersionNumber() != 1 )
-        {
-            throw new ChangePasswordException( ErrorType.KRB5_KPASSWD_BAD_VERSION );
-        }
-
-        if ( request.getAuthHeader() == null || request.getAuthHeader().getTicket() == null )
-        {
-            throw new ChangePasswordException( ErrorType.KRB5_KPASSWD_AUTHERROR );
-        }
 
         ApplicationRequest authHeader = request.getAuthHeader();
         Ticket ticket = authHeader.getTicket();

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/GetServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/GetServerEntry.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/GetServerEntry.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/GetServerEntry.java Mon Sep 24 03:18:05 2007
@@ -22,7 +22,7 @@
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
-import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
+import org.apache.directory.server.kerberos.shared.messages.value.types.KerberosErrorType;
 import org.apache.directory.server.kerberos.shared.service.GetPrincipalStoreEntry;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.mina.common.IoSession;
@@ -43,7 +43,7 @@
         KerberosPrincipal principal = changepwContext.getTicket().getServerPrincipal();
         PrincipalStore store = changepwContext.getStore();
 
-        changepwContext.setServerEntry( getEntry( principal, store, ErrorType.KDC_ERR_S_PRINCIPAL_UNKNOWN ) );
+        changepwContext.setServerEntry( getEntry( principal, store, KerberosErrorType.KDC_ERR_S_PRINCIPAL_UNKNOWN ) );
 
         next.execute( session, message );
     }

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/MonitorContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/MonitorContext.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/MonitorContext.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/MonitorContext.java Mon Sep 24 03:18:05 2007
@@ -25,7 +25,7 @@
 import javax.security.auth.kerberos.KerberosPrincipal;
 
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
-import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
+import org.apache.directory.server.kerberos.shared.messages.application.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.messages.value.HostAddress;

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicket.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicket.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicket.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicket.java Mon Sep 24 03:18:05 2007
@@ -23,9 +23,9 @@
 import javax.security.auth.kerberos.KerberosPrincipal;
 
 import org.apache.directory.server.changepw.ChangePasswordConfiguration;
-import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
 import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
 import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
+import org.apache.directory.server.kerberos.shared.messages.value.types.KerberosErrorType;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.chain.IoHandlerCommand;
 
@@ -49,7 +49,7 @@
 
         if ( !ticket.getRealm().equals( primaryRealm ) || !ticket.getServerPrincipal().equals( changepwPrincipal ) )
         {
-            throw new KerberosException( ErrorType.KRB_AP_ERR_NOT_US );
+            throw new KerberosException( KerberosErrorType.KRB_AP_ERR_NOT_US );
         }
 
         next.execute( session, message );

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicketAuthHeader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicketAuthHeader.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicketAuthHeader.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicketAuthHeader.java Mon Sep 24 03:18:05 2007
@@ -22,17 +22,13 @@
 
 import java.net.InetAddress;
 
-import org.apache.directory.server.changepw.exceptions.ChangePasswordException;
-import org.apache.directory.server.changepw.exceptions.ErrorType;
-import org.apache.directory.server.changepw.messages.ChangePasswordRequest;
 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.messages.ApplicationRequest;
+import org.apache.directory.server.kerberos.shared.messages.application.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.messages.value.EncryptionKey;
-import org.apache.directory.server.kerberos.shared.messages.value.TicketFlags;
 import org.apache.directory.server.kerberos.shared.replay.ReplayCache;
 import org.apache.directory.server.kerberos.shared.service.VerifyAuthHeader;
 import org.apache.mina.common.IoSession;
@@ -64,14 +60,7 @@
         CipherTextHandler cipherTextHandler = changepwContext.getCipherTextHandler();
 
         Authenticator authenticator = verifyAuthHeader( authHeader, ticket, serverKey, clockSkew, replayCache,
-            emptyAddressesAllowed, clientAddress, cipherTextHandler, KeyUsage.NUMBER11, false );
-
-        ChangePasswordRequest request = ( ChangePasswordRequest ) changepwContext.getRequest();
-
-        if ( request.getVersionNumber() == 1 && !ticket.getFlag( TicketFlags.INITIAL ) )
-        {
-            throw new ChangePasswordException( ErrorType.KRB5_KPASSWD_INITIAL_FLAG_NEEDED );
-        }
+            emptyAddressesAllowed, clientAddress, cipherTextHandler, KeyUsage.NUMBER11 );
 
         changepwContext.setAuthenticator( authenticator );
 

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/ChangepwProtocolHandlerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/ChangepwProtocolHandlerTest.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/ChangepwProtocolHandlerTest.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-changepw/src/test/java/org/apache/directory/server/changepw/protocol/ChangepwProtocolHandlerTest.java Mon Sep 24 03:18:05 2007
@@ -42,22 +42,15 @@
 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.MessageType;
 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.PrincipalNameModifier;
-import org.apache.directory.server.kerberos.shared.messages.value.PrincipalNameType;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.TicketFactory;
 import org.apache.mina.common.IoFilterChain;

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcConfiguration.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcConfiguration.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcConfiguration.java Mon Sep 24 03:18:05 2007
@@ -82,15 +82,12 @@
     /** The default for allowing proxiable tickets */
     private static final boolean DEFAULT_TGS_PROXIABLE_ALLOWED = true;
 
-    /** The default for allowing postdated tickets */
-    private static final boolean DEFAULT_TGS_POSTDATED_ALLOWED = true;
+    /** The default for allowing postdatable tickets */
+    private static final boolean DEFAULT_TGS_POSTDATE_ALLOWED = true;
 
     /** The default for allowing renewable tickets */
     private static final boolean DEFAULT_TGS_RENEWABLE_ALLOWED = true;
 
-    /** The default for verifying the body checksum */
-    private static final boolean DEFAULT_VERIFY_BODY_CHECKSUM = true;
-
     /** The encryption types. */
     private EncryptionType[] encryptionTypes;
 
@@ -121,15 +118,12 @@
     /** Whether proxiable addresses are allowed. */
     private boolean isProxiableAllowed = DEFAULT_TGS_PROXIABLE_ALLOWED;
 
-    /** Whether postdated tickets are allowed. */
-    private boolean isPostdatedAllowed = DEFAULT_TGS_POSTDATED_ALLOWED;
+    /** Whether postdating is allowed. */
+    private boolean isPostdateAllowed = DEFAULT_TGS_POSTDATE_ALLOWED;
 
     /** Whether renewable tickets are allowed. */
     private boolean isRenewableAllowed = DEFAULT_TGS_RENEWABLE_ALLOWED;
 
-    /** Whether to verify the body checksum. */
-    private boolean isBodyChecksumVerified = DEFAULT_VERIFY_BODY_CHECKSUM;
-
 
     /**
      * Creates a new instance of KdcConfiguration.
@@ -175,11 +169,11 @@
 
 
     /**
-     * @return the isPostdatedAllowed
+     * @return the isPostdateAllowed
      */
-    public boolean isPostdatedAllowed()
+    public boolean isPostdateAllowed()
     {
-        return isPostdatedAllowed;
+        return isPostdateAllowed;
     }
 
 
@@ -265,11 +259,11 @@
 
 
     /**
-     * @param isPostdatedAllowed the isPostdatedAllowed to set
+     * @param isPostdateAllowed the isPostdateAllowed to set
      */
-    public void setPostdatedAllowed( boolean isPostdatedAllowed )
+    public void setPostdateAllowed( boolean isPostdateAllowed )
     {
-        this.isPostdatedAllowed = isPostdatedAllowed;
+        this.isPostdateAllowed = isPostdateAllowed;
     }
 
 
@@ -371,24 +365,6 @@
     }
 
 
-    /**
-     * @return the isBodyChecksumVerified
-     */
-    public boolean isBodyChecksumVerified()
-    {
-        return isBodyChecksumVerified;
-    }
-
-
-    /**
-     * @param isBodyChecksumVerified the isBodyChecksumVerified to set
-     */
-    public void setBodyChecksumVerified( boolean isBodyChecksumVerified )
-    {
-        this.isBodyChecksumVerified = isBodyChecksumVerified;
-    }
-
-
     private void prepareEncryptionTypes()
     {
         String[] encryptionTypeStrings = DEFAULT_ENCRYPTION_TYPES;
@@ -397,13 +373,12 @@
 
         for ( String enc : encryptionTypeStrings )
         {
-            for ( EncryptionType type : EncryptionType.VALUES )
-            {
-                if ( type.getName().equalsIgnoreCase( enc ) )
-                {
-                    encTypes.add( type );
-                }
-            }
+        	EncryptionType et = EncryptionType.getByName( enc );
+        	
+        	if ( et != EncryptionType.UNKNOWN )
+        	{
+        		encTypes.add( et );
+        	}
         }
 
         encryptionTypes = encTypes.toArray( new EncryptionType[encTypes.size()] );

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorReply.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorReply.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorReply.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorReply.java Mon Sep 24 03:18:05 2007
@@ -20,6 +20,7 @@
 package org.apache.directory.server.kerberos.kdc;
 
 
+import org.apache.directory.server.kerberos.shared.messages.KerberosError;
 import org.apache.directory.server.kerberos.shared.messages.KdcReply;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.chain.IoHandlerCommand;
@@ -36,57 +37,58 @@
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( MonitorReply.class );
 
-    private String serviceName;
-
     private String contextKey = "context";
 
 
-    /**
-     * Creates a new instance of MonitorReply.
-     *
-     * @param serviceName
-     */
-    public MonitorReply( String serviceName )
-    {
-        this.serviceName = serviceName;
-    }
-
-
     public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
         KdcContext kdcContext = ( KdcContext ) session.getAttribute( getContextKey() );
         Object reply = kdcContext.getReply();
 
-        if ( log.isDebugEnabled() )
+        if ( reply instanceof KdcReply )
         {
-            if ( reply instanceof KdcReply )
+            KdcReply success = ( KdcReply ) reply;
+
+            if ( log.isDebugEnabled() )
             {
-                KdcReply success = ( KdcReply ) reply;
+                StringBuffer sb = new StringBuffer();
 
-                try
+                sb.append( "Responding to authentication request with reply:" );
+                sb.append( "\n\t" + "client realm:          " + success.getClientRealm() );
+                sb.append( "\n\t" + "server realm:          " + success.getServerRealm() );
+                sb.append( "\n\t" + "serverPrincipal:       " + success.getServerPrincipal() );
+                sb.append( "\n\t" + "clientPrincipal:       " + success.getClientPrincipal() );
+                sb.append( "\n\t" + "hostAddresses:         " + success.getClientAddresses() );
+                sb.append( "\n\t" + "start time:            " + success.getStartTime() );
+                sb.append( "\n\t" + "end time:              " + success.getEndTime() );
+                sb.append( "\n\t" + "auth time:             " + success.getAuthTime() );
+                sb.append( "\n\t" + "renew till time:       " + success.getRenewTill() );
+                sb.append( "\n\t" + "messageType:           " + success.getMessageType() );
+                sb.append( "\n\t" + "nonce:                 " + success.getNonce() );
+                sb.append( "\n\t" + "protocolVersionNumber: " + success.getProtocolVersionNumber() );
+
+                log.debug( sb.toString() );
+            }
+        }
+        else
+        {
+            if ( reply instanceof KerberosError )
+            {
+                KerberosError error = ( KerberosError ) reply;
+
+                if ( log.isDebugEnabled() )
                 {
                     StringBuffer sb = new StringBuffer();
 
-                    sb.append( "Responding with " + serviceName + " reply:" );
-                    sb.append( "\n\t" + "messageType:           " + success.getMessageType() );
-                    sb.append( "\n\t" + "protocolVersionNumber: " + success.getProtocolVersionNumber() );
-                    sb.append( "\n\t" + "nonce:                 " + success.getNonce() );
-                    sb.append( "\n\t" + "clientPrincipal:       " + success.getClientPrincipal() );
-                    sb.append( "\n\t" + "client realm:          " + success.getClientRealm() );
-                    sb.append( "\n\t" + "serverPrincipal:       " + success.getServerPrincipal() );
-                    sb.append( "\n\t" + "server realm:          " + success.getServerRealm() );
-                    sb.append( "\n\t" + "auth time:             " + success.getAuthTime() );
-                    sb.append( "\n\t" + "start time:            " + success.getStartTime() );
-                    sb.append( "\n\t" + "end time:              " + success.getEndTime() );
-                    sb.append( "\n\t" + "renew-till time:       " + success.getRenewTill() );
-                    sb.append( "\n\t" + "hostAddresses:         " + success.getClientAddresses() );
+                    sb.append( "Responding to authentication request with error:" );
+                    sb.append( "\n\t" + "serverPrincipal:       " + error.getServerPrincipal() );
+                    sb.append( "\n\t" + "clientPrincipal:       " + error.getClientPrincipal() );
+                    sb.append( "\n\t" + "server time:           " + error.getClientTime() );
+                    sb.append( "\n\t" + "client time:           " + error.getServerTime() );
+                    sb.append( "\n\t" + "error code:            " + error.getErrorCode() );
+                    sb.append( "\n\t" + "explanatory text:      " + error.getExplanatoryText() );
 
                     log.debug( sb.toString() );
-                }
-                catch ( Exception e )
-                {
-                    // This is a monitor.  No exceptions should bubble up.
-                    log.error( "Error in reply monitor", e );
                 }
             }
         }

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorRequest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorRequest.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorRequest.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorRequest.java Mon Sep 24 03:18:05 2007
@@ -20,6 +20,8 @@
 package org.apache.directory.server.kerberos.kdc;
 
 
+import java.util.List;
+
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.messages.KdcRequest;
 import org.apache.mina.common.IoSession;
@@ -37,57 +39,35 @@
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( MonitorRequest.class );
 
-    private String serviceName;
-
     private String contextKey = "context";
 
 
-    /**
-     * Creates a new instance of MonitorRequest.
-     *
-     * @param serviceName
-     */
-    public MonitorRequest( String serviceName )
-    {
-        this.serviceName = serviceName;
-    }
-
-
     public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
         KdcContext kdcContext = ( KdcContext ) session.getAttribute( getContextKey() );
         KdcRequest request = kdcContext.getRequest();
+        String clientAddress = kdcContext.getClientAddress().getHostAddress();
 
         if ( log.isDebugEnabled() )
         {
-            try
-            {
-                String clientAddress = kdcContext.getClientAddress().getHostAddress();
-
-                StringBuffer sb = new StringBuffer();
+            StringBuffer sb = new StringBuffer();
 
-                sb.append( "Received " + serviceName + " request:" );
-                sb.append( "\n\t" + "messageType:           " + request.getMessageType() );
-                sb.append( "\n\t" + "protocolVersionNumber: " + request.getProtocolVersionNumber() );
-                sb.append( "\n\t" + "clientAddress:         " + clientAddress );
-                sb.append( "\n\t" + "nonce:                 " + request.getNonce() );
-                sb.append( "\n\t" + "kdcOptions:            " + request.getKdcOptions() );
-                sb.append( "\n\t" + "clientPrincipal:       " + request.getClientPrincipal() );
-                sb.append( "\n\t" + "serverPrincipal:       " + request.getServerPrincipal() );
-                sb.append( "\n\t" + "encryptionType:        " + getEncryptionTypes( request ) );
-                sb.append( "\n\t" + "realm:                 " + request.getRealm() );
-                sb.append( "\n\t" + "from time:             " + request.getFrom() );
-                sb.append( "\n\t" + "till time:             " + request.getTill() );
-                sb.append( "\n\t" + "renew-till time:       " + request.getRtime() );
-                sb.append( "\n\t" + "hostAddresses:         " + request.getAddresses() );
+            sb.append( "Responding to authentication request:" );
+            sb.append( "\n\t" + "realm:                 " + request.getRealm() );
+            sb.append( "\n\t" + "serverPrincipal:       " + request.getServerPrincipal() );
+            sb.append( "\n\t" + "clientPrincipal:       " + request.getClientPrincipal() );
+            sb.append( "\n\t" + "clientAddress:         " + clientAddress );
+            sb.append( "\n\t" + "hostAddresses:         " + request.getAddresses() );
+            sb.append( "\n\t" + "encryptionType:        " + getEncryptionTypes( request ) );
+            sb.append( "\n\t" + "from krb time:         " + request.getFrom() );
+            sb.append( "\n\t" + "realm krb time:        " + request.getRenewtime() );
+            sb.append( "\n\t" + "kdcOptions:            " + request.getKdcOptions() );
+            sb.append( "\n\t" + "messageType:           " + request.getMessageType() );
+            sb.append( "\n\t" + "nonce:                 " + request.getNonce() );
+            sb.append( "\n\t" + "protocolVersionNumber: " + request.getProtocolVersionNumber() );
+            sb.append( "\n\t" + "till:                  " + request.getTill() );
 
-                log.debug( sb.toString() );
-            }
-            catch ( Exception e )
-            {
-                // This is a monitor.  No exceptions should bubble up.
-                log.error( "Error in request monitor", e );
-            }
+            log.debug( sb.toString() );
         }
 
         next.execute( session, message );
@@ -96,18 +76,23 @@
 
     protected String getEncryptionTypes( KdcRequest request )
     {
-        EncryptionType[] etypes = request.getEType();
+        List<EncryptionType> eTypes = request.getEType();
 
         StringBuffer sb = new StringBuffer();
+        boolean isFirst = true;
 
-        for ( int ii = 0; ii < etypes.length; ii++ )
+        for ( EncryptionType eType:eTypes )
         {
-            sb.append( etypes[ii].toString() );
-
-            if ( ii < etypes.length - 1 )
+            if ( isFirst )
+            {
+                isFirst = false;
+            }
+            else
             {
                 sb.append( ", " );
             }
+
+            sb.append( eType.toString() );
         }
 
         return sb.toString();

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectEncryptionType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectEncryptionType.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectEncryptionType.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectEncryptionType.java Mon Sep 24 03:18:05 2007
@@ -20,9 +20,11 @@
 package org.apache.directory.server.kerberos.kdc;
 
 
+import java.util.List;
+
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
-import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
 import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
+import org.apache.directory.server.kerberos.shared.messages.value.types.KerberosErrorType;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.chain.IoHandlerCommand;
 import org.slf4j.Logger;
@@ -46,7 +48,7 @@
         KdcContext kdcContext = ( KdcContext ) session.getAttribute( getContextKey() );
         KdcConfiguration config = kdcContext.getConfig();
 
-        EncryptionType[] requestedTypes = kdcContext.getRequest().getEType();
+        List<EncryptionType> requestedTypes = kdcContext.getRequest().getEType();
 
         EncryptionType bestType = getBestEncryptionType( requestedTypes, config.getEncryptionTypes() );
 
@@ -54,7 +56,7 @@
 
         if ( bestType == null )
         {
-            throw new KerberosException( ErrorType.KDC_ERR_ETYPE_NOSUPP );
+            throw new KerberosException( KerberosErrorType.KDC_ERR_ETYPE_NOSUPP );
         }
 
         kdcContext.setEncryptionType( bestType );
@@ -63,13 +65,13 @@
     }
 
 
-    protected EncryptionType getBestEncryptionType( EncryptionType[] requestedTypes, EncryptionType[] configuredTypes )
+    protected EncryptionType getBestEncryptionType( List<EncryptionType> requestedTypes, EncryptionType[] configuredTypes )
     {
-        for ( int ii = 0; ii < requestedTypes.length; ii++ )
+        for ( EncryptionType eType:requestedTypes )
         {
             for ( int jj = 0; jj < configuredTypes.length; jj++ )
             {
-                if ( requestedTypes[ii] == configuredTypes[jj] )
+                if ( eType == configuredTypes[jj] )
                 {
                     return configuredTypes[jj];
                 }

Modified: directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java?rev=578743&r1=578742&r2=578743&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java (original)
+++ directory/apacheds/branches/apacheds-kerberos/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java Mon Sep 24 03:18:05 2007
@@ -20,11 +20,11 @@
 package org.apache.directory.server.kerberos.kdc.authentication;
 
 
-import org.apache.directory.server.kerberos.shared.messages.AuthenticationReply;
+import org.apache.directory.server.kerberos.shared.messages.AuthServerReply;
 import org.apache.directory.server.kerberos.shared.messages.KdcRequest;
 import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
 import org.apache.directory.server.kerberos.shared.messages.value.LastRequest;
-import org.apache.directory.server.kerberos.shared.messages.value.TicketFlags;
+import org.apache.directory.server.kerberos.shared.messages.value.flags.TicketFlags;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.chain.IoHandlerCommand;
 
@@ -43,7 +43,7 @@
         KdcRequest request = authContext.getRequest();
         Ticket ticket = authContext.getTicket();
 
-        AuthenticationReply reply = new AuthenticationReply();
+        AuthServerReply reply = new AuthServerReply();
 
         reply.setClientPrincipal( request.getClientPrincipal() );
         reply.setTicket( ticket );
@@ -51,7 +51,7 @@
 
         // TODO - fetch lastReq for this client; requires store
         reply.setLastRequest( new LastRequest() );
-        // TODO - resp.key-expiration := client.expiration; requires store
+        // TODO    - resp.key-expiration := client.expiration; requires store
 
         reply.setNonce( request.getNonce() );
 
@@ -60,7 +60,7 @@
         reply.setStartTime( ticket.getStartTime() );
         reply.setEndTime( ticket.getEndTime() );
 
-        if ( ticket.getFlags().get( TicketFlags.RENEWABLE ) )
+        if ( TicketFlags.isRenewable( ticket.getFlags() ) )
         {
             reply.setRenewTill( ticket.getRenewTill() );
         }



Mime
View raw message