directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r589780 [1/2] - in /directory/apacheds/branches/bigbang/kerberos-shared/src: main/java/org/apache/directory/server/kerberos/shared/ main/java/org/apache/directory/server/kerberos/shared/io/decoder/ main/java/org/apache/directory/server/kerb...
Date Mon, 29 Oct 2007 18:15:07 GMT
Author: elecharny
Date: Mon Oct 29 11:14:59 2007
New Revision: 589780

URL: http://svn.apache.org/viewvc?rev=589780&view=rev
Log:
o Refactored the Ticket structure
o Added a KerberosConstant class for common constants like kerberos version
o Removed the MessageType class and replaced it with a KerberosMessageType enum
o Removed the TicketModifier class
o Added a package Flags and all the Flags (kerberos, ticket)
o Added an InvalidTicketException
o Modified the PrincipalName to returns a KerberosPrincipal
o Added some test for Ticket
o Fixed some warnings and added some doco

Added:
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosConstants.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosMessageType.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/InvalidTicketException.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/AbstractKerberosFlags.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/KerberosFlag.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/KerberosFlags.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/TicketFlag.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/TicketFlags.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/components/
    directory/apacheds/branches/bigbang/kerberos-shared/src/test/java/org/apache/directory/server/kerberos/shared/messages/components/TicketTest.java
Removed:
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/MessageType.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/TicketModifier.java
Modified:
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosUtils.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/ApplicationRequestDecoder.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/ErrorMessageDecoder.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/KdcReplyDecoder.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/KdcRequestDecoder.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/LastRequestDecoder.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/PrivateMessageDecoder.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/TicketDecoder.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/TicketEncoder.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/ApplicationRequest.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/AuthenticationReply.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/ErrorMessage.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KdcReply.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KdcRequest.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KerberosMessage.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/TicketGrantReply.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/ApplicationReply.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/CredentialMessage.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/PrivateMessage.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/SafeMessage.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/EncApRepPart.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/EncKrbPrivPart.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/Ticket.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalName.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/service/VerifyAuthHeader.java
    directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/store/TicketFactory.java

Added: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosConstants.java?rev=589780&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosConstants.java (added)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosConstants.java Mon Oct 29 11:14:59 2007
@@ -0,0 +1,32 @@
+/*
+ *  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;
+
+/**
+ * An cass to define Kerberos constants
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class KerberosConstants
+{
+    /** The Kerbersion version 5 */
+    public static final int KERBEROS_V5 = 5;
+}

Added: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosMessageType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosMessageType.java?rev=589780&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosMessageType.java (added)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosMessageType.java Mon Oct 29 11:14:59 2007
@@ -0,0 +1,117 @@
+/*
+ *  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;
+
+/**
+ * An enum listing all the Kerberos V5 messages :
+ * 
+ *   AS-REQ    (10) : Authentication Serveur Request
+ *   AS-REP    (11) : Authentication Serveur Response
+ *   TGS-REQ   (12) : Ticket Granting Server Request
+ *   TGS-REP   (13) : Ticket Granting Server Response
+ *   AP-REQ    (14) : Application Request
+ *   AP-REP    (15) : Application Response
+ *   KRB-SAFE  (20) : Safe (checksummed) application message
+ *   KRB-PRIV  (21) : Private (encrypted) application message
+ *   KRB-CRED  (22) : Private (encrypted) message to forward credentials
+ *   ENC_AP_REP_PART (27) : Encrypted application reply part
+ *   ENC_PRIV_PART (28) : Encrypted private message part
+ *   KRB-ERROR (30) : A kerberos error response
+ *   
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public enum KerberosMessageType
+{
+    AS_REQ( 10, "initial authentication request" ),
+    AS_REP( 11, "initial authentication response"),
+    TGS_REQ( 12, "request for authentication based on TGT" ),
+    TGS_REP( 13, "response to authentication based on TGT" ),
+    AP_REQ( 14, "application request" ), 
+    AP_REP( 15, "application response" ), 
+    KRB_SAFE( 20, "safe (checksummed) application message" ), 
+    KRB_PRIV( 21,  "private (encrypted) application message" ), 
+    KRB_CRED( 22, "private (encrypted) message to forward credentials" ),
+    ENC_AP_REP_PART( 27, "encrypted application reply part" ),
+    ENC_PRIV_PART( 28, "encrypted private message part" ),
+    KRB_ERROR( 30, "error response" );
+    
+    private int value;
+    private String message;
+    
+    /**
+     * Creates a new instance of KerberosMessageType.
+     */
+    private KerberosMessageType( int value, String message )
+    {
+        this.value = value;
+        this.message = message;
+    }
+
+    
+    /**
+     * Get the int value for this element
+     *
+     * @return The int value of this element
+     */
+    public int getOrdinal()
+    {
+        return value;
+    }
+    
+    
+    /**
+     * Get the message associated with this element
+     *
+     * @return The message associated with this element
+     */
+    public String getMessage()
+    {
+        return message;
+    }
+    
+    
+    /**
+     * Get the instance of a KerberosMessageType from an int value
+     *
+     * @param value The int value 
+     * @return A KerberosMessageType associated with this value
+     */
+    public static KerberosMessageType getTypeByOrdinal( int value )
+    {
+        switch ( value )
+        {
+            case 10 : return AS_REQ;
+            case 11 : return AS_REP;
+            case 12 : return TGS_REQ;
+            case 13 : return TGS_REP;
+            case 14 : return AP_REQ; 
+            case 15 : return AP_REP; 
+            case 20 : return KRB_SAFE; 
+            case 21 : return KRB_PRIV; 
+            case 22 : return KRB_CRED;
+            case 27 : return ENC_AP_REP_PART;
+            case 28 : return ENC_PRIV_PART;
+            case 30 : return KRB_ERROR;
+            default : return null;
+        }
+    }
+}

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosUtils.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosUtils.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/KerberosUtils.java Mon Oct 29 11:14:59 2007
@@ -25,6 +25,7 @@
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
+import org.apache.directory.server.kerberos.shared.messages.value.PrincipalName;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 /**
@@ -37,7 +38,8 @@
     /** A constant for integer optional values */
     public static final int NULL = -1;
 
-    private static final List<String> EMPTY_PRINCIPAL_NAME = new ArrayList<String>();
+    /** An empty list of principal names */
+    public static final List<String> EMPTY_PRINCIPAL_NAME = new ArrayList<String>();
     
     /**
      * Parse a KerberosPrincipal instance and return the names. The Principal name
@@ -195,5 +197,27 @@
         }
         
         return nameComponents;
+    }
+    
+    
+    /**
+     * Constructs a KerberosPrincipal from a PrincipalName and an 
+     * optional realm
+     *
+     * @param principal The principal name and type
+     * @param realm The optional realm
+     * 
+     * @return A KerberosPrincipal
+     */
+    public static KerberosPrincipal getKerberosPrincipal( PrincipalName principal, String realm )
+    {
+        String name = principal.getNameString(); 
+        
+        if ( !StringTools.isEmpty( realm ) )
+        {
+            name += '@' + realm;
+        }
+        
+        return new KerberosPrincipal( name, principal.getNameType().getOrdinal() );
     }
 }

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/ApplicationRequestDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/ApplicationRequestDecoder.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/ApplicationRequestDecoder.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/ApplicationRequestDecoder.java Mon Oct 29 11:14:59 2007
@@ -23,8 +23,8 @@
 import java.io.IOException;
 import java.util.Enumeration;
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
-import org.apache.directory.server.kerberos.shared.messages.MessageType;
 import org.apache.directory.server.kerberos.shared.messages.value.ApOptions;
 import org.apache.directory.shared.asn1.der.ASN1InputStream;
 import org.apache.directory.shared.asn1.der.DERApplicationSpecific;
@@ -74,7 +74,7 @@
     {
         ApplicationRequest authHeader = new ApplicationRequest();
 
-        for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+        for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
         {
             DERTaggedObject object = ( ( DERTaggedObject ) e.nextElement() );
             int tag = object.getTagNo();
@@ -86,10 +86,12 @@
                     DERInteger tag0 = ( DERInteger ) derObject;
                     authHeader.setProtocolVersionNumber( tag0.intValue() );
                     break;
+                    
                 case 1:
                     DERInteger tag1 = ( DERInteger ) derObject;
-                    authHeader.setMessageType( MessageType.getTypeByOrdinal( tag1.intValue() ) );
+                    authHeader.setMessageType( KerberosMessageType.getTypeByOrdinal( tag1.intValue() ) );
                     break;
+                    
                 case 2:
                     DERBitString apOptions = ( DERBitString ) derObject;
                     authHeader.setApOptions( new ApOptions( apOptions.getOctets() ) );
@@ -98,6 +100,7 @@
                     DERApplicationSpecific tag3 = ( DERApplicationSpecific ) derObject;
                     authHeader.setTicket( TicketDecoder.decode( tag3 ) );
                     break;
+                    
                 case 4:
                     DERSequence tag4 = ( DERSequence ) derObject;
                     authHeader.setEncPart( EncryptedDataDecoder.decode( tag4 ) );

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/ErrorMessageDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/ErrorMessageDecoder.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/ErrorMessageDecoder.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/ErrorMessageDecoder.java Mon Oct 29 11:14:59 2007
@@ -88,7 +88,7 @@
         KerberosPrincipalModifier clientModifier = new KerberosPrincipalModifier();
         KerberosPrincipalModifier serverModifier = new KerberosPrincipalModifier();
 
-        for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+        for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
         {
             DERTaggedObject object = ( DERTaggedObject ) e.nextElement();
             int tag = object.getTagNo();

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/KdcReplyDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/KdcReplyDecoder.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/KdcReplyDecoder.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/KdcReplyDecoder.java Mon Oct 29 11:14:59 2007
@@ -26,8 +26,8 @@
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.messages.KdcReply;
-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.EncryptedData;
 import org.apache.directory.server.kerberos.shared.messages.value.KerberosPrincipalModifier;
@@ -81,14 +81,14 @@
      }*/
     private KdcReply decodeKdcReplySequence( DERSequence sequence ) throws IOException
     {
-        MessageType msgType = MessageType.NULL;
+        KerberosMessageType msgType = null;
         PaData[] paData = null;
         Ticket ticket = null;
         EncryptedData encPart = null;
 
         KerberosPrincipalModifier modifier = new KerberosPrincipalModifier();
 
-        for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+        for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
         {
             DERTaggedObject object = ( DERTaggedObject ) e.nextElement();
             int tag = object.getTagNo();
@@ -100,26 +100,32 @@
                     // DERInteger tag0 = ( DERInteger ) derObject;
                     // int pvno = tag0.intValue();
                     break;
+                    
                 case 1:
                     DERInteger tag1 = ( DERInteger ) derObject;
-                    msgType = MessageType.getTypeByOrdinal( tag1.intValue() );
+                    msgType = KerberosMessageType.getTypeByOrdinal( tag1.intValue() );
                     break;
+                    
                 case 2:
                     DERSequence tag2 = ( DERSequence ) derObject;
                     paData = PreAuthenticationDataDecoder.decodeSequence( tag2 );
                     break;
+                    
                 case 3:
                     DERGeneralString tag3 = ( DERGeneralString ) derObject;
                     modifier.setRealm( tag3.getString() );
                     break;
+                    
                 case 4:
                     DERSequence tag4 = ( DERSequence ) derObject;
                     modifier.setPrincipalName( PrincipalNameDecoder.decode( tag4 ) );
                     break;
+                    
                 case 5:
                     DERApplicationSpecific tag5 = ( DERApplicationSpecific ) derObject;
                     ticket = TicketDecoder.decode( tag5 );
                     break;
+                    
                 case 6:
                     DERSequence tag6 = ( DERSequence ) derObject;
                     encPart = ( EncryptedDataDecoder.decode( tag6 ) );

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/KdcRequestDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/KdcRequestDecoder.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/KdcRequestDecoder.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/KdcRequestDecoder.java Mon Oct 29 11:14:59 2007
@@ -24,8 +24,8 @@
 import java.nio.ByteBuffer;
 import java.util.Enumeration;
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 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.value.KdcOptions;
 import org.apache.directory.server.kerberos.shared.messages.value.PaData;
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBody;
@@ -79,13 +79,13 @@
     private KdcRequest decodeKdcRequestSequence( DERSequence sequence ) throws IOException
     {
         int pvno = 5;
-        MessageType msgType = MessageType.NULL;
+        KerberosMessageType msgType = null;
 
         PaData[] paData = null;
         RequestBody requestBody = null;
         byte[] bodyBytes = null;
 
-        for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+        for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
         {
             DERTaggedObject object = ( DERTaggedObject ) e.nextElement();
             int tag = object.getTagNo();
@@ -97,14 +97,17 @@
                     DERInteger tag1 = ( DERInteger ) derObject;
                     pvno = tag1.intValue();
                     break;
+                    
                 case 2:
                     DERInteger tag2 = ( DERInteger ) derObject;
-                    msgType = MessageType.getTypeByOrdinal( tag2.intValue() );
+                    msgType = KerberosMessageType.getTypeByOrdinal( tag2.intValue() );
                     break;
+                    
                 case 3:
                     DERSequence tag3 = ( DERSequence ) derObject;
                     paData = PreAuthenticationDataDecoder.decodeSequence( tag3 );
                     break;
+                    
                 case 4:
                     DERSequence tag4 = ( DERSequence ) derObject;
                     requestBody = decodeRequestBody( tag4 );
@@ -147,7 +150,7 @@
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
 
-        for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+        for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
         {
             DERTaggedObject object = ( DERTaggedObject ) e.nextElement();
             int tag = object.getTagNo();

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/LastRequestDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/LastRequestDecoder.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/LastRequestDecoder.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/LastRequestDecoder.java Mon Oct 29 11:14:59 2007
@@ -50,7 +50,7 @@
         LastRequestEntry[] entries = new LastRequestEntry[sequence.size()];
 
         int ii = 0;
-        for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+        for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
         {
             DERSequence object = ( DERSequence ) e.nextElement();
             LastRequestEntry entry = decode( object );
@@ -67,7 +67,7 @@
         LastRequestType type = LastRequestType.NONE;
         KerberosTime value = null;
 
-        for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+        for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
         {
             DERTaggedObject object = ( DERTaggedObject ) e.nextElement();
             int tag = object.getTagNo();

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/PrivateMessageDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/PrivateMessageDecoder.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/PrivateMessageDecoder.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/PrivateMessageDecoder.java Mon Oct 29 11:14:59 2007
@@ -23,7 +23,7 @@
 import java.io.IOException;
 import java.util.Enumeration;
 
-import org.apache.directory.server.kerberos.shared.messages.MessageType;
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.messages.application.PrivateMessage;
 import org.apache.directory.shared.asn1.der.ASN1InputStream;
 import org.apache.directory.shared.asn1.der.DERApplicationSpecific;
@@ -62,7 +62,7 @@
     {
         PrivateMessage message = new PrivateMessage();
 
-        for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+        for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
         {
             DERTaggedObject object = ( DERTaggedObject ) e.nextElement();
             int tag = object.getTagNo();
@@ -74,10 +74,12 @@
                     DERInteger tag0 = ( DERInteger ) derObject;
                     message.setProtocolVersionNumber( tag0.intValue() );
                     break;
+                    
                 case 1:
                     DERInteger tag1 = ( DERInteger ) derObject;
-                    message.setMessageType( MessageType.getTypeByOrdinal( tag1.intValue() ) );
+                    message.setMessageType( KerberosMessageType.getTypeByOrdinal( tag1.intValue() ) );
                     break;
+                    
                 case 3:
                     DERSequence tag3 = ( DERSequence ) derObject;
                     message.setEncryptedPart( EncryptedDataDecoder.decode( tag3 ) );

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/TicketDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/TicketDecoder.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/TicketDecoder.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/TicketDecoder.java Mon Oct 29 11:14:59 2007
@@ -24,7 +24,6 @@
 import java.util.Enumeration;
 
 import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
-import org.apache.directory.server.kerberos.shared.messages.components.TicketModifier;
 import org.apache.directory.shared.asn1.der.ASN1InputStream;
 import org.apache.directory.shared.asn1.der.DERApplicationSpecific;
 import org.apache.directory.shared.asn1.der.DEREncodable;
@@ -69,7 +68,7 @@
         Ticket[] tickets = new Ticket[sequence.size()];
 
         int ii = 0;
-        for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+        for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
         {
             DERApplicationSpecific object = ( DERApplicationSpecific ) e.nextElement();
             tickets[ii] = decode( object );
@@ -91,9 +90,9 @@
     {
         DERSequence sequence = ( DERSequence ) app.getObject();
 
-        TicketModifier modifier = new TicketModifier();
+        Ticket ticket = new Ticket();
 
-        for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+        for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
         {
             DERTaggedObject object = ( DERTaggedObject ) e.nextElement();
             int tag = object.getTagNo();
@@ -103,23 +102,26 @@
             {
                 case 0:
                     DERInteger tag0 = ( DERInteger ) derObject;
-                    modifier.setTicketVersionNumber( tag0.intValue() );
+                    ticket.setTktVno( tag0.intValue() );
                     break;
+                    
                 case 1:
                     DERGeneralString tag1 = ( DERGeneralString ) derObject;
-                    modifier.setServerRealm( tag1.getString() );
+                    ticket.setRealm( tag1.getString() );
                     break;
+                    
                 case 2:
                     DERSequence tag2 = ( DERSequence ) derObject;
-                    modifier.setServerName( PrincipalNameDecoder.decode( tag2 ) );
+                    ticket.setSName( PrincipalNameDecoder.decode( tag2 ) );
                     break;
+                    
                 case 3:
                     DERSequence tag3 = ( DERSequence ) derObject;
-                    modifier.setEncPart( EncryptedDataDecoder.decode( tag3 ) );
+                    ticket.setEncPart( EncryptedDataDecoder.decode( tag3 ) );
                     break;
             }
         }
 
-        return modifier.getTicket();
+        return ticket;
     }
 }

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/TicketEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/TicketEncoder.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/TicketEncoder.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/TicketEncoder.java Mon Oct 29 11:14:59 2007
@@ -69,9 +69,9 @@
     {
         DERSequence vector = new DERSequence();
 
-        vector.add( new DERTaggedObject( 0, DERInteger.valueOf( ticket.getVersionNumber() ) ) );
+        vector.add( new DERTaggedObject( 0, DERInteger.valueOf( ticket.getTktVno() ) ) );
         vector.add( new DERTaggedObject( 1, DERGeneralString.valueOf( ticket.getRealm() ) ) );
-        vector.add( new DERTaggedObject( 2, PrincipalNameEncoder.encode( ticket.getServerPrincipal() ) ) );
+        vector.add( new DERTaggedObject( 2, PrincipalNameEncoder.encode( ticket.getSName() ) ) );
         vector.add( new DERTaggedObject( 3, EncryptedDataEncoder.encodeSequence( ticket.getEncPart() ) ) );
 
         DERApplicationSpecific ticketSequence = null;

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/ApplicationRequest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/ApplicationRequest.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/ApplicationRequest.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/ApplicationRequest.java Mon Oct 29 11:14:59 2007
@@ -20,6 +20,7 @@
 package org.apache.directory.server.kerberos.shared.messages;
 
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 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;
@@ -41,7 +42,7 @@
      */
     public ApplicationRequest()
     {
-        super( MessageType.KRB_AP_REQ );
+        super( KerberosMessageType.AP_REQ );
         // used by ASN1 decoder
     }
 
@@ -55,7 +56,7 @@
      */
     public ApplicationRequest( ApOptions apOptions, Ticket ticket, EncryptedData encPart )
     {
-        super( MessageType.KRB_AP_REQ );
+        super( KerberosMessageType.AP_REQ );
         this.apOptions = apOptions;
         this.ticket = ticket;
         this.encPart = encPart;

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/AuthenticationReply.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/AuthenticationReply.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/AuthenticationReply.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/AuthenticationReply.java Mon Oct 29 11:14:59 2007
@@ -22,6 +22,7 @@
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 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.PaData;
@@ -38,7 +39,7 @@
      */
     public AuthenticationReply()
     {
-        super( MessageType.KRB_AS_REP );
+        super( KerberosMessageType.AS_REP );
     }
 
 
@@ -53,6 +54,6 @@
     public AuthenticationReply( PaData[] paData, KerberosPrincipal clientPrincipal, Ticket ticket,
         EncryptedData encPart )
     {
-        super( paData, clientPrincipal, ticket, encPart, MessageType.KRB_AS_REP );
+        super( paData, clientPrincipal, ticket, encPart, KerberosMessageType.AS_REP );
     }
 }

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/ErrorMessage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/ErrorMessage.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/ErrorMessage.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/ErrorMessage.java Mon Oct 29 11:14:59 2007
@@ -22,6 +22,7 @@
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
 
 
@@ -59,7 +60,7 @@
         int serverMicroSecond, int errorCode, KerberosPrincipal clientPrincipal, KerberosPrincipal serverPrincipal,
         String explanatoryText, byte[] explanatoryData )
     {
-        super( MessageType.KRB_ERROR );
+        super( KerberosMessageType.KRB_ERROR );
 
         this.clientTime = clientTime;
         this.clientMicroSecond = clientMicroSecond;

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KdcReply.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KdcReply.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KdcReply.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KdcReply.java Mon Oct 29 11:14:59 2007
@@ -22,6 +22,7 @@
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.messages.components.EncKdcRepPart;
 import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData;
@@ -52,7 +53,7 @@
      *
      * @param msgType
      */
-    public KdcReply( MessageType msgType )
+    public KdcReply( KerberosMessageType msgType )
     {
         super( msgType );
     }
@@ -68,7 +69,7 @@
      * @param msgType
      */
     public KdcReply( PaData[] paData, KerberosPrincipal clientPrincipal, Ticket ticket,
-        EncryptedData encPart, MessageType msgType )
+        EncryptedData encPart, KerberosMessageType msgType )
     {
         this( msgType );
         this.paData = paData;

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KdcRequest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KdcRequest.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KdcRequest.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KdcRequest.java Mon Oct 29 11:14:59 2007
@@ -22,6 +22,7 @@
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData;
@@ -51,7 +52,7 @@
      * @param preAuthData
      * @param requestBody
      */
-    public KdcRequest( int pvno, MessageType messageType, PaData[] preAuthData, RequestBody requestBody )
+    public KdcRequest( int pvno, KerberosMessageType messageType, PaData[] preAuthData, RequestBody requestBody )
     {
         super( pvno, messageType );
         this.preAuthData = preAuthData;
@@ -68,7 +69,7 @@
      * @param requestBody
      * @param bodyBytes
      */
-    public KdcRequest( int pvno, MessageType messageType, PaData[] preAuthData, RequestBody requestBody,
+    public KdcRequest( int pvno, KerberosMessageType messageType, PaData[] preAuthData, RequestBody requestBody,
         byte[] bodyBytes )
     {
         this( pvno, messageType, preAuthData, requestBody );

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KerberosMessage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KerberosMessage.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KerberosMessage.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/KerberosMessage.java Mon Oct 29 11:14:59 2007
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.server.kerberos.shared.messages;
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
+
 
 /**
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -32,7 +34,7 @@
     public static final int PVNO = 5;
 
     private int protocolVersionNumber;
-    private MessageType messageType;
+    private KerberosMessageType messageType;
 
 
     /**
@@ -40,7 +42,7 @@
      *
      * @param type
      */
-    public KerberosMessage( MessageType type )
+    public KerberosMessage( KerberosMessageType type )
     {
         this( PVNO, type );
     }
@@ -52,7 +54,7 @@
      * @param versionNumber
      * @param type
      */
-    public KerberosMessage( int versionNumber, MessageType type )
+    public KerberosMessage( int versionNumber, KerberosMessageType type )
     {
         protocolVersionNumber = versionNumber;
         messageType = type;
@@ -64,7 +66,7 @@
      *
      * @return The {@link MessageType}.
      */
-    public MessageType getMessageType()
+    public KerberosMessageType getMessageType()
     {
         return messageType;
     }
@@ -75,7 +77,7 @@
      *
      * @param type
      */
-    public void setMessageType( MessageType type )
+    public void setMessageType( KerberosMessageType type )
     {
         messageType = type;
     }

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/TicketGrantReply.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/TicketGrantReply.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/TicketGrantReply.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/TicketGrantReply.java Mon Oct 29 11:14:59 2007
@@ -22,6 +22,7 @@
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 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.PaData;
@@ -38,7 +39,7 @@
      */
     public TicketGrantReply()
     {
-        super( MessageType.KRB_TGS_REP );
+        super( KerberosMessageType.TGS_REP );
     }
 
 
@@ -53,6 +54,6 @@
     public TicketGrantReply( PaData[] pAData, KerberosPrincipal clientPrincipal, Ticket ticket,
         EncryptedData encPart )
     {
-        super( pAData, clientPrincipal, ticket, encPart, MessageType.KRB_TGS_REP );
+        super( pAData, clientPrincipal, ticket, encPart, KerberosMessageType.TGS_REP );
     }
 }

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/ApplicationReply.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/ApplicationReply.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/ApplicationReply.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/ApplicationReply.java Mon Oct 29 11:14:59 2007
@@ -20,8 +20,8 @@
 package org.apache.directory.server.kerberos.shared.messages.application;
 
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.messages.KerberosMessage;
-import org.apache.directory.server.kerberos.shared.messages.MessageType;
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData;
 
 
@@ -41,7 +41,7 @@
      */
     public ApplicationReply( EncryptedData encPart )
     {
-        super( MessageType.KRB_AP_REP );
+        super( KerberosMessageType.AP_REP );
         encryptedPart = encPart;
     }
 

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/CredentialMessage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/CredentialMessage.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/CredentialMessage.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/CredentialMessage.java Mon Oct 29 11:14:59 2007
@@ -20,8 +20,8 @@
 package org.apache.directory.server.kerberos.shared.messages.application;
 
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.messages.KerberosMessage;
-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.EncryptedData;
 
@@ -44,7 +44,7 @@
      */
     public CredentialMessage( EncryptedData encPart, Ticket[] tickets )
     {
-        super( MessageType.KRB_CRED );
+        super( KerberosMessageType.KRB_CRED );
         this.encPart = encPart;
         this.tickets = tickets;
     }

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/PrivateMessage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/PrivateMessage.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/PrivateMessage.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/PrivateMessage.java Mon Oct 29 11:14:59 2007
@@ -20,8 +20,8 @@
 package org.apache.directory.server.kerberos.shared.messages.application;
 
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.messages.KerberosMessage;
-import org.apache.directory.server.kerberos.shared.messages.MessageType;
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData;
 
 
@@ -39,7 +39,7 @@
      */
     public PrivateMessage()
     {
-        super( MessageType.KRB_PRIV );
+        super( KerberosMessageType.KRB_PRIV );
         // used by ASN.1 decoder
     }
 
@@ -51,7 +51,7 @@
      */
     public PrivateMessage( EncryptedData encryptedPart )
     {
-        super( MessageType.KRB_PRIV );
+        super( KerberosMessageType.KRB_PRIV );
         this.encryptedPart = encryptedPart;
     }
 

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/SafeMessage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/SafeMessage.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/SafeMessage.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/application/SafeMessage.java Mon Oct 29 11:14:59 2007
@@ -20,8 +20,8 @@
 package org.apache.directory.server.kerberos.shared.messages.application;
 
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.messages.KerberosMessage;
-import org.apache.directory.server.kerberos.shared.messages.MessageType;
 import org.apache.directory.server.kerberos.shared.messages.value.Checksum;
 import org.apache.directory.server.kerberos.shared.messages.value.HostAddress;
 import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
@@ -45,7 +45,7 @@
      */
     public SafeMessage( SafeBody safeBody, Checksum cksum )
     {
-        super( MessageType.KRB_SAFE );
+        super( KerberosMessageType.KRB_SAFE );
         this.safeBody = safeBody;
         this.cksum = cksum;
     }

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/EncApRepPart.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/EncApRepPart.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/EncApRepPart.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/EncApRepPart.java Mon Oct 29 11:14:59 2007
@@ -20,9 +20,9 @@
 package org.apache.directory.server.kerberos.shared.messages.components;
 
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.messages.Encodable;
 import org.apache.directory.server.kerberos.shared.messages.KerberosMessage;
-import org.apache.directory.server.kerberos.shared.messages.MessageType;
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
 import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
 
@@ -51,7 +51,7 @@
      */
     public EncApRepPart( KerberosTime clientTime, int cusec, EncryptionKey subSessionKey, Integer sequenceNumber )
     {
-        super( MessageType.ENC_AP_REP_PART );
+        super( KerberosMessageType.ENC_AP_REP_PART );
 
         this.clientTime = clientTime;
         this.cusec = cusec;

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/EncKrbPrivPart.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/EncKrbPrivPart.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/EncKrbPrivPart.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/EncKrbPrivPart.java Mon Oct 29 11:14:59 2007
@@ -20,9 +20,9 @@
 package org.apache.directory.server.kerberos.shared.messages.components;
 
 
+import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.messages.Encodable;
 import org.apache.directory.server.kerberos.shared.messages.KerberosMessage;
-import org.apache.directory.server.kerberos.shared.messages.MessageType;
 import org.apache.directory.server.kerberos.shared.messages.value.HostAddress;
 import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
 
@@ -56,7 +56,7 @@
     public EncKrbPrivPart( byte[] userData, KerberosTime timestamp, Integer usec, Integer sequenceNumber,
         HostAddress senderAddress, HostAddress recipientAddress )
     {
-        super( MessageType.ENC_PRIV_PART );
+        super( KerberosMessageType.ENC_PRIV_PART );
 
         this.userData = userData;
         this.timestamp = timestamp;

Added: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/InvalidTicketException.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/InvalidTicketException.java?rev=589780&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/InvalidTicketException.java (added)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/InvalidTicketException.java Mon Oct 29 11:14:59 2007
@@ -0,0 +1,45 @@
+/*
+ *  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.components;
+
+import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
+import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
+
+/**
+ * A exception used when there was an error while creating a Ticket
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */ 
+public class InvalidTicketException extends KerberosException
+{
+    static final long serialVersionUID = 1L;
+
+
+    public InvalidTicketException( ErrorType errorType )
+    {
+        super( errorType );
+    }
+
+
+    public InvalidTicketException( ErrorType errorType, String explanation )
+    {
+        super( errorType, explanation );
+    }
+
+}

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/Ticket.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/Ticket.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/Ticket.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/components/Ticket.java Mon Oct 29 11:14:59 2007
@@ -20,15 +20,30 @@
 package org.apache.directory.server.kerberos.shared.messages.components;
 
 
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+import java.text.ParseException;
+
 import javax.security.auth.kerberos.KerberosPrincipal;
 
+import org.apache.directory.server.kerberos.shared.KerberosUtils;
+import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
 import org.apache.directory.server.kerberos.shared.messages.value.AuthorizationData;
 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.HostAddresses;
 import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
-import org.apache.directory.server.kerberos.shared.messages.value.TicketFlags;
+import org.apache.directory.server.kerberos.shared.messages.value.PrincipalName;
 import org.apache.directory.server.kerberos.shared.messages.value.TransitedEncoding;
+import org.apache.directory.server.kerberos.shared.messages.value.flags.TicketFlags;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -37,43 +52,77 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class Ticket
+public class Ticket extends AbstractAsn1Object
 {
-    /**
-     * Constant for the {@link Ticket} version number (5).
-     */
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( Ticket.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+    
+    /** Constant for the {@link Ticket} version number (5) */
     public static final int TICKET_VNO = 5;
 
-    private int versionNumber;
-    private KerberosPrincipal serverPrincipal;
+    /** The Kerberos version number. Should be 5 */
+    private int tktvno;
+    
+    /** A storage for a byte array representation of the realm */
+    private byte[] realmBytes;
+    
+    /** The server principal name */
+    private PrincipalName sName;
+    
+    /** The server realm */
+    private String realm;
+    
+    /** The encoded part */
     private EncryptedData encPart;
+    
+    /** The decoded ticket part */
     private EncTicketPart encTicketPart;
 
+    // Storage for computed lengths
+    private transient int tktvnoLength;
+    private transient int realmLength;
+    private transient int sNameLength;
+    private transient int encPartLength;
+    private transient int ticketSeqLength;
+    private transient int ticketLength;
 
     /**
      * Creates a new instance of Ticket.
      *
-     * @param serverPrincipal
-     * @param encPart
+     * @param serverPrincipal The server principal
+     * @param encPart The encoded part
      */
-    public Ticket( KerberosPrincipal serverPrincipal, EncryptedData encPart )
+    public Ticket( KerberosPrincipal serverPrincipal, EncryptedData encPart ) throws InvalidTicketException
     {
         this( TICKET_VNO, serverPrincipal, encPart );
+
+        setServerPrincipal( serverPrincipal );
     }
 
 
     /**
      * Creates a new instance of Ticket.
+     */
+    public Ticket()
+    {
+    }
+    
+    
+    /**
+     * Creates a new instance of Ticket.
      *
-     * @param versionNumber
-     * @param serverPrincipal
-     * @param encPart
+     * @param tktvno The Kerberos version number
+     * @param serverPrincipal The server principal
+     * @param encPart The encoded part
      */
-    public Ticket( int versionNumber, KerberosPrincipal serverPrincipal, EncryptedData encPart )
+    public Ticket( int tktvno, KerberosPrincipal serverPrincipal, EncryptedData encPart ) throws InvalidTicketException
     {
-        this.versionNumber = versionNumber;
-        this.serverPrincipal = serverPrincipal;
+        this.tktvno = tktvno;
         this.encPart = encPart;
+        setServerPrincipal( serverPrincipal );
     }
 
 
@@ -93,12 +142,33 @@
      *
      * @return The version number.
      */
-    public int getVersionNumber()
+    public int getTktVno()
     {
-        return versionNumber;
+        return tktvno;
     }
+    
+    
+    /**
+     * Set the ticket version number
+     * @param tktvno the ticket version number
+     */
+    public void setTktVno( int tktvno )
+    {
+        this.tktvno = tktvno;
+    }
+
 
+    /**
+     * Returns the server {@link PrincipalName}.
+     *
+     * @return The server {@link PrincipalName}.
+     */
+    public PrincipalName getSName()
+    {
+        return sName;
+    }
 
+    
     /**
      * Returns the server {@link KerberosPrincipal}.
      *
@@ -106,9 +176,38 @@
      */
     public KerberosPrincipal getServerPrincipal()
     {
-        return serverPrincipal;
+        return KerberosUtils.getKerberosPrincipal( sName, realm );
     }
 
+    
+    /**
+     * Set the server principalName
+     * @param sName the server principalName
+     */
+    public void setSName( PrincipalName sName )
+    {
+        this.sName = sName;
+    }
+    
+
+    /**
+     * Set the server KerberosPrincipal
+     * @param sName the server KerberosPrincipal
+     */
+    public void setServerPrincipal( KerberosPrincipal serverPrincipal ) throws InvalidTicketException
+    {
+        try
+        {
+            sName = new PrincipalName( serverPrincipal.getName(), serverPrincipal.getNameType() );
+            realm = serverPrincipal.getRealm();
+        }
+        catch ( ParseException pe )
+        {
+            LOG.error( "Cannot create a ticket for the {} KerberosPrincipal, error : {}", serverPrincipal, pe.getMessage() );
+            throw new InvalidTicketException( ErrorType.KRB_ERR_GENERIC, "Cannot create a ticket : " + pe.getMessage() );
+        }
+    }
+    
 
     /**
      * Returns the server realm.
@@ -117,11 +216,21 @@
      */
     public String getRealm()
     {
-        return serverPrincipal.getRealm();
+        return realm;
     }
 
 
     /**
+     * Set the server realm
+     * @param realm the server realm
+     */
+    public void setRealm( String realm )
+    {
+        this.realm = realm;
+    }
+    
+   
+    /**
      * Returns the {@link EncryptedData}.
      *
      * @return The {@link EncryptedData}.
@@ -131,6 +240,16 @@
         return encPart;
     }
 
+    
+    /**
+     * Set the encrypted ticket part
+     * @param encPart the encrypted ticket part
+     */
+    public void setEncPart( EncryptedData encPart )
+    {
+        this.encPart = encPart; 
+    }
+    
 
     /**
      * Returns the {@link EncTicketPart}.
@@ -147,7 +266,7 @@
      * Returns the {@link AuthorizationData}.
      *
      * @return The {@link AuthorizationData}.
-     */
+     *
     public AuthorizationData getAuthorizationData()
     {
         return encTicketPart.getAuthorizationData();
@@ -158,7 +277,7 @@
      * Returns the auth {@link KerberosTime}.
      *
      * @return The auth {@link KerberosTime}.
-     */
+     *
     public KerberosTime getAuthTime()
     {
         return encTicketPart.getAuthTime();
@@ -169,7 +288,7 @@
      * Returns the client {@link HostAddresses}.
      *
      * @return The client {@link HostAddresses}.
-     */
+     *
     public HostAddresses getClientAddresses()
     {
         return encTicketPart.getClientAddresses();
@@ -180,21 +299,31 @@
      * Returns the client {@link KerberosPrincipal}.
      *
      * @return The client {@link KerberosPrincipal}.
-     */
+     *
     public KerberosPrincipal getClientPrincipal()
     {
         return encTicketPart.getClientPrincipal();
     }
 
+    /**
+     * Returns the client {@link PrincipalName}.
+     *
+     * @return The client {@link PrincipalName}.
+     *
+    public PrincipalName getClientPrincipalName()
+    {
+        return encTicketPart.getClientPrincipalName();
+    }
+
 
     /**
      * Returns the client realm.
      *
      * @return The client realm.
-     */
+     *
     public String getClientRealm()
     {
-        return encTicketPart.getClientPrincipal().getRealm();
+        return encTicketPart.getClientRealm();
     }
 
 
@@ -202,7 +331,7 @@
      * Returns the end {@link KerberosTime}.
      *
      * @return The end {@link KerberosTime}.
-     */
+     *
     public KerberosTime getEndTime()
     {
         return encTicketPart.getEndTime();
@@ -213,18 +342,28 @@
      * Returns the {@link TicketFlags}.
      *
      * @return The {@link TicketFlags}.
-     */
+     *
     public TicketFlags getFlags()
     {
         return encTicketPart.getFlags();
     }
 
+    /**
+     * Returns the integer value for the {@link TicketFlags}.
+     *
+     * @return The {@link TicketFlags}.
+     *
+    public int getFlagsIntValue()
+    {
+        return encTicketPart.getFlags().getIntValue();
+    }
+
 
     /**
      * Returns the renew till {@link KerberosTime}.
      *
      * @return The renew till {@link KerberosTime}.
-     */
+     *
     public KerberosTime getRenewTill()
     {
         return encTicketPart.getRenewTill();
@@ -235,7 +374,7 @@
      * Returns the session {@link EncryptionKey}.
      *
      * @return The session {@link EncryptionKey}.
-     */
+     *
     public EncryptionKey getSessionKey()
     {
         return encTicketPart.getSessionKey();
@@ -246,7 +385,7 @@
      * Returns the start {@link KerberosTime}.
      *
      * @return The start {@link KerberosTime}.
-     */
+     *
     public KerberosTime getStartTime()
     {
         return encTicketPart.getStartTime();
@@ -257,7 +396,7 @@
      * Returns the {@link TransitedEncoding}.
      *
      * @return The {@link TransitedEncoding}.
-     */
+     *
     public TransitedEncoding getTransitedEncoding()
     {
         return encTicketPart.getTransitedEncoding();
@@ -269,9 +408,131 @@
      *
      * @param flag
      * @return true if the flag at the given index is set.
-     */
+     *
     public boolean getFlag( int flag )
     {
-        return encTicketPart.getFlags().get( flag );
+        return encTicketPart.getFlags().isFlagSet( flag );
+    }
+
+    /**
+     * Compute the Ticket length
+     * 
+     * Ticket :
+     * 
+     * 0x61 L1 Ticket [APPLICATION 1]
+     *  |
+     *  +--> 0x30 L2 Ticket SEQUENCE
+     *        |
+     *        +--> 0xA0 L3 tkt-vno tag
+     *        |     |
+     *        |     +--> 0x02 L3-1 tkt-vno (int, 5)
+     *        |
+     *        +--> 0xA1 L4 realm tag
+     *        |     |
+     *        |     +--> 0x1B L4-1 realm (KerberosString)
+     *        |
+     *        +--> 0xA2 L5 sname (PrincipalName)
+     *        |
+     *        +--> 0xA3 L6 enc-part (EncryptedData)
+     */
+    public int computeLength()
+    {
+        // Compute the Ticket version length.
+        tktvnoLength = 1 + TLV.getNbBytes( tktvno ) + Value.getNbBytes( tktvno );
+
+        // Compute the Ticket realm length.
+        realmBytes = StringTools.getBytesUtf8( realm );
+        realmLength = 1 + TLV.getNbBytes( realmBytes.length ) + realmBytes.length;
+
+        // Compute the principal length
+        sNameLength = sName.computeLength();
+        
+        // Compute the encrypted data
+        encPartLength = encPart.computeLength();
+
+        // Compute the sequence size
+        ticketSeqLength = 
+            1 + TLV.getNbBytes( tktvnoLength ) + tktvnoLength +
+            1 + TLV.getNbBytes( realmLength ) + realmLength +
+            1 + TLV.getNbBytes( sNameLength ) + sNameLength + 
+            1 + TLV.getNbBytes( encPartLength ) + encPartLength;
+        
+        // compute the global size
+        ticketLength = 1 + TLV.getNbBytes( ticketSeqLength ) + ticketSeqLength;
+        
+        return 1 + TLV.getNbBytes( ticketLength ) + ticketLength;
+    }
+    
+    /**
+     * Encode the Ticket message to a PDU. 
+     * 
+     * Ticket :
+     * 
+     * 0x61 LL
+     *   0x30 LL
+     *     0xA0 LL tktvno 
+     *     0xA1 LL realm
+     *     0xA2 LL
+     *       sname (PrincipalName)
+     *     0xA3 LL
+     *       enc-part (EncryptedData)
+     * 
+     * @param buffer The buffer where to put the PDU. It should have been allocated
+     * before, with the right size.
+     * @return The constructed PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if ( buffer == null )
+        {
+            buffer = ByteBuffer.allocate( computeLength() );
+        }
+
+        try
+        {
+            // The Ticket APPLICATION Tag
+            buffer.put( (byte)0x61 );
+            buffer.put( TLV.getBytes( ticketLength ) );
+
+            // The Ticket SEQUENCE Tag
+            buffer.put( UniversalTag.SEQUENCE_TAG );
+            buffer.put( TLV.getBytes( ticketSeqLength ) );
+
+            // The tkt-vno Tag and value
+            buffer.put( ( byte ) 0xA0 );
+            buffer.put( TLV.getBytes( tktvnoLength ) );
+            Value.encode( buffer, tktvno );
+
+            // The realm Tag and value
+            buffer.put( ( byte ) 0xA1 );
+            buffer.put( TLV.getBytes( realmLength ) );
+            buffer.put( UniversalTag.GENERALIZED_STRING_TAG );
+            buffer.put( TLV.getBytes( realmBytes.length ) );
+            buffer.put( realmBytes );
+
+            // The sname Tag and value
+            buffer.put( ( byte ) 0xA2 );
+            buffer.put( TLV.getBytes( sNameLength ) );
+            sName.encode( buffer );
+            
+            // The encPartLength Tag and value
+            buffer.put( ( byte ) 0xA3 );
+            buffer.put( TLV.getBytes( encPartLength ) );
+            encPart.encode( buffer );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            LOG.error( "Cannot encode the Ticket object, the PDU size is {} when only {} bytes has been allocated", 1
+                + TLV.getNbBytes( ticketLength ) + ticketLength, buffer.capacity() );
+            throw new EncoderException( "The PDU buffer size is too small !" );
+        }
+
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "Ticket encoding : {}", StringTools.dumpBytes( buffer.array() ) );
+            LOG.debug( "Ticket initial value : {}", toString() );
+        }
+
+        return buffer;
     }
 }

Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalName.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalName.java?rev=589780&r1=589779&r2=589780&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalName.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalName.java Mon Oct 29 11:14:59 2007
@@ -108,7 +108,7 @@
 
 
 /**
- * A principal Name, componsed of a type and N names.
+ * A principal Name, composed of a type and N names.
  * 
  * PrincipalName   ::= SEQUENCE {
  *        name-type       [0] Int32,
@@ -159,9 +159,16 @@
      *
      * @param principal A Sun kerberosPrincipal instance
      */
-    public PrincipalName( KerberosPrincipal principal ) throws ParseException
+    public PrincipalName( KerberosPrincipal principal )
     {
-        nameString = KerberosUtils.getNames( principal );
+        try
+        {
+            nameString = KerberosUtils.getNames( principal );
+        }
+        catch ( ParseException pe )
+        {
+            nameString = KerberosUtils.EMPTY_PRINCIPAL_NAME;
+        }
 
         this.nameType = PrincipalNameType.getTypeByOrdinal( principal.getNameType() );
     }

Added: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/AbstractKerberosFlags.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/AbstractKerberosFlags.java?rev=589780&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/AbstractKerberosFlags.java (added)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/AbstractKerberosFlags.java Mon Oct 29 11:14:59 2007
@@ -0,0 +1,226 @@
+/*
+ *  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.flags;
+
+import org.apache.directory.shared.asn1.primitives.BitString;
+
+/**
+ * An implementation of a BitString for any KerberosFlags. The different values
+ * are stored in an int, as there can't be more than 32 flags (TicketFlag).
+ * 
+ * Some basic operations are implemented in this abstract class, like those
+ * manipulating flags.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 540371 $, $Date: 2007-05-22 02:00:43 +0200 (Tue, 22 May 2007) $
+ */
+public abstract class AbstractKerberosFlags extends BitString implements KerberosFlags
+{
+    /** The associated value */
+    protected int value;
+    
+    /**
+     * Standard constructor, which create a BitString containing 32 bits
+     */
+    public AbstractKerberosFlags()
+    {
+        super( 32 );
+    }
+
+    /**
+     * Standard constructor, taking a byte array
+     */
+    public AbstractKerberosFlags( byte[] flags )
+    {
+        super( flags );
+    }
+    
+    /**
+     * A static method to get the bayte array representation of an int
+     * @return The byte array for a list of flags.
+     */
+    public static byte[] getBytes( int flags )
+    {
+        return new byte[]{
+                (byte)( flags >>> 24), 
+                (byte)( ( flags >> 16 ) & 0x00ff ), 
+                (byte)( ( flags >> 8 ) & 0x00ff ), 
+                (byte)( flags & 0x00ff ) };
+    }
+    
+    /**
+     * @return The byte array for a KerberosFlags
+     */
+    public byte[] getBytes()
+    {
+        return getData();
+        /*new byte[]{
+                (byte)( value >>> 24), 
+                (byte)( ( value >> 16 ) & 0x00ff ), 
+                (byte)( ( value >> 8 ) & 0x00ff ), 
+                (byte)( value & 0x00ff ) };*/
+    }
+
+    /**
+     * Returns the int value associated with the flags
+     */
+    public int getIntValue()
+    {
+        return value;
+    }
+    
+    
+    
+    /**
+     * Check if a flag is set
+     * @param flags The flags to test
+     * @param flag The flag to check
+     * @return True if the flag is set in the list of flags
+     */
+    public static boolean isFlagSet( int flags, int flag )
+    {
+        return ( flags & ( 1 << flag) ) != 0;
+    }
+    
+    /**
+     * Check if a flag is set
+     * @param flags The flags to test
+     * @param flag The flag to check
+     * @return True if the flag is set in the list of flags
+     */
+    /*public static boolean isFlagSet( int flags, KerberosFlag flag )
+    {
+        return ( flags & ( 1 << flag.getOrdinal() ) ) != 0;
+    }*/
+    
+    /**
+     * Check if a flag is set for the actual value
+     * 
+     * @param flag The flag to check
+     * @return True if the flag is set in the list of flags
+     */
+    public boolean isFlagSet( KerberosFlag flag )
+    {
+        return ( value & ( 1 << flag.getOrdinal() ) ) != 0;
+    }
+    
+    /**
+     * Check if a flag is set
+     * @param flags The flags to test
+     * @return True if the flag is set in the list of flags
+     */
+    public boolean isFlagSet( int flag )
+    {
+        return ( flag & ( 1 << value ) ) != 0;
+    }
+    
+    /**
+     * Set a flag in a list of flags
+     * 
+     * @param flags The list of flags
+     * @param flag The flag to set
+     */
+    /*public static int setFlag( int flags, KerberosFlag flag )
+    {
+        flags |= 1 << flag.getOrdinal();
+        return flags;
+    }*/
+    
+    /**
+     * Set a flag in a list of flags
+     * 
+     * @param flag The flag to set
+     */
+    public void setFlag( KerberosFlag flag )
+    {
+        value |= 1 << flag.getOrdinal();
+        setBit( flag.getOrdinal() );
+    }
+    
+    /**
+     * Set a flag in a list of flags
+     * 
+     * @param flag The flag to set
+     */
+    public void setFlag( int flag )
+    {
+        value |= 1 << flag;
+        setBit( flag );
+    }
+    
+    
+    /**
+     * Modify a byte array to an integer value
+     * @param value The 4 bytes byte array to transform.
+     * @return The int which contains the bytes value.
+     */
+    public void setFlags( byte[] bytes )
+    {
+        if ( (bytes== null ) || ( bytes.length != 4 ) )
+        {
+            value = -1;
+        }
+        
+        value = ( bytes[0] << 24 ) + ( bytes[1] << 16 ) + ( bytes[2] << 8 ) + bytes[3];
+        setData( bytes );
+    }
+    
+    /**
+     * clear a flag in a list of flags
+     * 
+     * @param flags The list of flags
+     * @param flag The flag to set
+     */
+    /*public static void clearFlag( int flags, KerberosFlag flag )
+    {
+        flags &= ~( 1 << flag.getOrdinal() );
+    }*/
+
+    /**
+     * clear a flag in a list of flags
+     * 
+     * @param flag The flag to set
+     */
+    public void clearFlag( KerberosFlag flag )
+    {
+        value &= ~( 1 << flag.getOrdinal() );
+        clearBit( flag.getOrdinal() );
+    }
+    
+    /**
+     * clear a flag in a list of flags
+     * 
+     * @param flag The flag to set
+     */
+    public void clearFlag( int flag )
+    {
+        value &= ~( 1 << flag );
+        clearBit( flag );
+    }
+    
+    /**
+     * @return The hex value for this flag, in its position.
+     * For instance, getting the flag 5 will return 0x0000 0010 
+     */
+    public int getHexValue()
+    {
+        return 1 << value;
+    }
+}

Added: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/KerberosFlag.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/KerberosFlag.java?rev=589780&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/KerberosFlag.java (added)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/KerberosFlag.java Mon Oct 29 11:14:59 2007
@@ -0,0 +1,34 @@
+/*
+ *  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.flags;
+
+/**
+ * This interface must be implemented by all the inherited Flag classes :
+ * - TicketFlag
+ * - ApOption
+ * - KdcOption
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ *
+ */
+public interface KerberosFlag
+{
+    public int getOrdinal();
+}

Added: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/KerberosFlags.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/KerberosFlags.java?rev=589780&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/KerberosFlags.java (added)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/flags/KerberosFlags.java Mon Oct 29 11:14:59 2007
@@ -0,0 +1,37 @@
+/*
+ *  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.flags;
+
+/**
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ *
+ */
+public interface KerberosFlags
+{
+    public byte[] getBytes();
+    public int getIntValue();
+    public boolean isFlagSet( KerberosFlag flag );
+    public boolean isFlagSet( int flag );
+    public void setFlag( KerberosFlag flag );
+    public void setFlag( int flag );
+    public void clearFlag( KerberosFlag flag );
+    public void clearFlag( int flag );
+}



Mime
View raw message