directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1042204 - /directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java
Date Sat, 04 Dec 2010 15:28:58 GMT
Author: elecharny
Date: Sat Dec  4 15:28:57 2010
New Revision: 1042204

URL: http://svn.apache.org/viewvc?rev=1042204&view=rev
Log:
Added the EncryptedData decoder

Modified:
    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/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=1042204&r1=1042203&r2=1042204&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:28:57 2010
@@ -20,7 +20,6 @@
 package org.apache.directory.server.kerberos.kdc.authentication;
 
 
-import java.io.IOException;
 import java.net.InetAddress;
 import java.nio.ByteBuffer;
 import java.util.Date;
@@ -40,14 +39,17 @@ import org.apache.directory.server.kerbe
 import org.apache.directory.server.kerberos.shared.crypto.encryption.KeyUsage;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.RandomKeyFactory;
 import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
-import org.apache.directory.server.kerberos.shared.io.decoder.EncryptedDataDecoder;
 import org.apache.directory.server.kerberos.shared.messages.AuthenticationReply;
 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;
@@ -277,21 +279,29 @@ public class AuthenticationService
                 {
                     if ( paData.getPaDataType().equals( PaDataType.PA_ENC_TIMESTAMP ) )
                     {
-                        EncryptedData dataValue;
+                        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
                         {
-                            dataValue = EncryptedDataDecoder.decode( paData.getPaDataValue()
);
-                        }
-                        catch ( IOException ioe )
-                        {
-                            throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY,
ioe );
+                            kerberosDecoder.decode( stream, encryptedDataContainer );
                         }
-                        catch ( ClassCastException cce )
+                        catch ( DecoderException de )
                         {
-                            throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY,
cce );
+                            throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY,
de );
                         }
 
+                        // get the decoded EncryptedData
+                        EncryptedData dataValue = ( ( EncryptedDataContainer ) encryptedDataContainer
).getEncryptedData();
+
                         timestamp = ( PaEncTsEnc ) cipherTextHandler.unseal( PaEncTimestamp.class,
                             clientKey, dataValue, KeyUsage.NUMBER1 );
                     }



Mime
View raw message