directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1042205 - in /directory/apacheds/branches/apacheds-kerberos-codec-2.0: kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/ protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/au...
Date Sat, 04 Dec 2010 15:45:11 GMT
Author: elecharny
Date: Sat Dec  4 15:45:11 2010
New Revision: 1042205

URL: http://svn.apache.org/viewvc?rev=1042205&view=rev
Log:
Added the EncryptedData decoder in the CipherTextHandler class

Modified:
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java?rev=1042205&r1=1042204&r2=1042205&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
Sat Dec  4 15:45:11 2010
@@ -38,7 +38,11 @@ import org.apache.directory.server.kerbe
 import org.apache.directory.server.kerberos.shared.io.decoder.EncryptedTimestampDecoder;
 import org.apache.directory.server.kerberos.shared.messages.Encodable;
 import org.apache.directory.shared.asn1.AbstractAsn1Object;
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
+import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.kerberos.codec.encryptedData.EncryptedDataContainer;
 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
 import org.apache.directory.shared.kerberos.components.EncKdcRepPart;
 import org.apache.directory.shared.kerberos.components.EncKrbPrivPart;
@@ -218,4 +222,39 @@ public class CipherTextHandler
             throw new KerberosException( ErrorType.KDC_ERR_ETYPE_NOSUPP, ie );
         }
     }
+    
+    
+    /**
+     * Decrypt an EncrytedData structure
+     * 
+     * @param data The byte array containing the data structure to decode
+     * @return An instance of EncryptedData
+     * @throws KerberosException If the decoding fails
+     */
+    public EncryptedData decodeEncryptedData( byte[] data ) throws KerberosException
+    {
+        ByteBuffer stream = ByteBuffer.allocate( data.length );
+        stream.put( data );
+        stream.flip();
+        
+        // Allocate a EncryptedData Container
+        Asn1Container encryptedDataContainer = new EncryptedDataContainer();
+
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        // Decode the EncryptedData PDU
+        try
+        {
+            kerberosDecoder.decode( stream, encryptedDataContainer );
+        }
+        catch ( DecoderException de )
+        {
+            throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY, de );
+        }
+
+        // get the decoded EncryptedData
+        EncryptedData encryptedData = ( ( EncryptedDataContainer ) encryptedDataContainer
).getEncryptedData();
+
+        return encryptedData;
+    }
 }

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java?rev=1042205&r1=1042204&r2=1042205&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java
Sat Dec  4 15:45:11 2010
@@ -43,13 +43,9 @@ import org.apache.directory.server.kerbe
 import org.apache.directory.server.kerberos.shared.messages.KdcReply;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
-import org.apache.directory.shared.asn1.ber.Asn1Container;
-import org.apache.directory.shared.asn1.ber.Asn1Decoder;
-import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.kerberos.KerberosTime;
 import org.apache.directory.shared.kerberos.KerberosUtils;
-import org.apache.directory.shared.kerberos.codec.encryptedData.EncryptedDataContainer;
 import org.apache.directory.shared.kerberos.codec.options.KdcOptions;
 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
 import org.apache.directory.shared.kerberos.codec.types.PaDataType;
@@ -279,29 +275,7 @@ public class AuthenticationService
                 {
                     if ( paData.getPaDataType().equals( PaDataType.PA_ENC_TIMESTAMP ) )
                     {
-                        byte[] data = paData.getPaDataValue();
-                        ByteBuffer stream = ByteBuffer.allocate( data.length );
-                        stream.put( data );
-                        stream.flip();
-                        
-                        // Allocate a EncryptedData Container
-                        Asn1Container encryptedDataContainer = new EncryptedDataContainer();
-
-                        Asn1Decoder kerberosDecoder = new Asn1Decoder();
-
-                        // Decode the EncryptedData PDU
-                        try
-                        {
-                            kerberosDecoder.decode( stream, encryptedDataContainer );
-                        }
-                        catch ( DecoderException de )
-                        {
-                            throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY,
de );
-                        }
-
-                        // get the decoded EncryptedData
-                        EncryptedData dataValue = ( ( EncryptedDataContainer ) encryptedDataContainer
).getEncryptedData();
-
+                        EncryptedData dataValue = cipherTextHandler.decodeEncryptedData(
paData.getPaDataValue() );
                         timestamp = ( PaEncTsEnc ) cipherTextHandler.unseal( PaEncTimestamp.class,
                             clientKey, dataValue, KeyUsage.NUMBER1 );
                     }



Mime
View raw message