directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1042207 - 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 16:17:59 GMT
Author: elecharny
Date: Sat Dec  4 16:17:59 2010
New Revision: 1042207

URL: http://svn.apache.org/viewvc?rev=1042207&view=rev
Log:
Moved the decoding of data structure to the KerbeorsDecoder 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
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.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=1042207&r1=1042206&r2=1042207&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 16:17:59 2010
@@ -38,11 +38,7 @@ 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;
@@ -222,39 +218,4 @@ 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=1042207&r1=1042206&r2=1042207&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 16:17:59 2010
@@ -32,6 +32,7 @@ import javax.security.auth.kerberos.Kerb
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.kerberos.kdc.KdcContext;
 import org.apache.directory.server.kerberos.kdc.KdcServer;
+import org.apache.directory.server.kerberos.protocol.KerberosUdpDecoder;
 import org.apache.directory.server.kerberos.sam.SamException;
 import org.apache.directory.server.kerberos.sam.SamSubsystem;
 import org.apache.directory.server.kerberos.shared.KerberosConstants;
@@ -275,7 +276,7 @@ public class AuthenticationService
                 {
                     if ( paData.getPaDataType().equals( PaDataType.PA_ENC_TIMESTAMP ) )
                     {
-                        EncryptedData dataValue = cipherTextHandler.decodeEncryptedData(
paData.getPaDataValue() );
+                        EncryptedData dataValue = KerberosUdpDecoder.decodeEncryptedData(
paData.getPaDataValue() );
                         timestamp = ( PaEncTsEnc ) cipherTextHandler.unseal( PaEncTimestamp.class,
                             clientKey, dataValue, KeyUsage.NUMBER1 );
                     }

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.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/protocol/KerberosUdpDecoder.java?rev=1042207&r1=1042206&r2=1042207&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.java
Sat Dec  4 16:17:59 2010
@@ -23,12 +23,17 @@ package org.apache.directory.server.kerb
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
+import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
+import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.TLVStateEnum;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.kerberos.codec.KerberosMessageContainer;
+import org.apache.directory.shared.kerberos.codec.encryptedData.EncryptedDataContainer;
+import org.apache.directory.shared.kerberos.components.EncryptedData;
+import org.apache.directory.shared.kerberos.exceptions.ErrorType;
 import org.apache.directory.shared.ldap.codec.LdapDecoder;
 import org.apache.mina.core.buffer.IoBuffer;
 import org.apache.mina.core.session.IoSession;
@@ -61,6 +66,8 @@ public class KerberosUdpDecoder extends 
         ByteBuffer buf = in.buf();
         KerberosMessageContainer kerberosMessageContainer = ( KerberosMessageContainer )
session.getAttribute( KERBEROS_MESSAGE_CONTAINER );
 
+        //System.out.println( "IN : " + StringTools.dumpBytes( buf.array() ) );
+        
         if ( kerberosMessageContainer == null )
         {
             kerberosMessageContainer = new KerberosMessageContainer();
@@ -102,4 +109,39 @@ public class KerberosUdpDecoder extends 
             }
         }
     }
+    
+    
+    /**
+     * Decode 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 static 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;
+    }
 }



Mime
View raw message