directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1042226 - in /directory/apacheds/branches/apacheds-kerberos-codec-2.0: kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/ kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/i...
Date Sat, 04 Dec 2010 19:05:27 GMT
Author: elecharny
Date: Sat Dec  4 19:05:27 2010
New Revision: 1042226

URL: http://svn.apache.org/viewvc?rev=1042226&view=rev
Log:
o Removed some decoders
o Added the decode methods in the KerberosDecoder class

Removed:
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncApRepPartDecoder.java
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncKdcRepPartDecoder.java
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncKrbPrivPartDecoder.java
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncTicketPartDecoder.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
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosDecoder.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=1042226&r1=1042225&r2=1042226&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 19:05:27 2010
@@ -31,23 +31,15 @@ import org.apache.directory.server.i18n.
 import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
 import org.apache.directory.server.kerberos.shared.io.decoder.Decoder;
 import org.apache.directory.server.kerberos.shared.io.decoder.DecoderFactory;
-import org.apache.directory.server.kerberos.shared.io.decoder.EncApRepPartDecoder;
-import org.apache.directory.server.kerberos.shared.io.decoder.EncKdcRepPartDecoder;
-import org.apache.directory.server.kerberos.shared.io.decoder.EncKrbPrivPartDecoder;
-import org.apache.directory.server.kerberos.shared.io.decoder.EncTicketPartDecoder;
 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.codec.EncoderException;
 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;
-import org.apache.directory.shared.kerberos.components.EncTicketPart;
 import org.apache.directory.shared.kerberos.components.EncryptedData;
 import org.apache.directory.shared.kerberos.components.EncryptionKey;
 import org.apache.directory.shared.kerberos.components.PaEncTsEnc;
 import org.apache.directory.shared.kerberos.exceptions.ErrorType;
-import org.apache.directory.shared.kerberos.messages.EncApRepPart;
 
 
 /**
@@ -69,11 +61,7 @@ public class CipherTextHandler
     {
         Map<Class, Class> map = new HashMap<Class, Class>();
 
-        map.put( EncTicketPart.class, EncTicketPartDecoder.class );
         map.put( PaEncTsEnc.class, EncryptedTimestampDecoder.class );
-        map.put( EncKrbPrivPart.class, EncKrbPrivPartDecoder.class );
-        map.put( EncApRepPart.class, EncApRepPartDecoder.class );
-        map.put( EncKdcRepPart.class, EncKdcRepPartDecoder.class );
 
         DEFAULT_DECODERS = Collections.unmodifiableMap( map );
     }
@@ -156,6 +144,15 @@ public class CipherTextHandler
     }
 
 
+    /**
+     * Decrypt a block of data. 
+     * 
+     * @param key The key used to decrypt the data
+     * @param data The data to decrypt
+     * @param usage The key usage number
+     * @return The decrypted data as a byte[]
+     * @throws KerberosException If the decoding failed
+     */
     public byte[] decrypt( EncryptionKey key, EncryptedData data, KeyUsage usage ) throws
KerberosException
     {
         EncryptionEngine engine = getEngine( key );

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosDecoder.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/KerberosDecoder.java?rev=1042226&r1=1042225&r2=1042226&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosDecoder.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosDecoder.java
Sat Dec  4 19:05:27 2010
@@ -31,11 +31,19 @@ import org.apache.directory.shared.asn1.
 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.EncKdcRepPart.EncKdcRepPartContainer;
+import org.apache.directory.shared.kerberos.codec.encApRepPart.EncApRepPartContainer;
+import org.apache.directory.shared.kerberos.codec.encKrbPrivPart.EncKrbPrivPartContainer;
+import org.apache.directory.shared.kerberos.codec.encTicketPart.EncTicketPartContainer;
 import org.apache.directory.shared.kerberos.codec.encryptedData.EncryptedDataContainer;
 import org.apache.directory.shared.kerberos.codec.paEncTsEnc.PaEncTsEncContainer;
+import org.apache.directory.shared.kerberos.components.EncKdcRepPart;
+import org.apache.directory.shared.kerberos.components.EncKrbPrivPart;
+import org.apache.directory.shared.kerberos.components.EncTicketPart;
 import org.apache.directory.shared.kerberos.components.EncryptedData;
 import org.apache.directory.shared.kerberos.components.PaEncTsEnc;
 import org.apache.directory.shared.kerberos.exceptions.ErrorType;
+import org.apache.directory.shared.kerberos.messages.EncApRepPart;
 import org.apache.directory.shared.ldap.codec.LdapDecoder;
 import org.apache.mina.core.buffer.IoBuffer;
 import org.apache.mina.core.session.IoSession;
@@ -176,9 +184,149 @@ public class KerberosDecoder extends Pro
             throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY, de );
         }
 
-        // get the decoded EncryptedData
+        // get the decoded PaEncTsEnc
         PaEncTsEnc paEncTsEnc = ( ( PaEncTsEncContainer ) paEncTsEncContainer ).getPaEncTsEnc();
 
         return paEncTsEnc;
     }
+    
+    
+    /**
+     * Decode an EncApRepPart structure
+     * 
+     * @param data The byte array containing the data structure to decode
+     * @return An instance of EncApRepPart
+     * @throws KerberosException If the decoding fails
+     */
+    public static EncApRepPart decodeEncApRepPart( byte[] data ) throws KerberosException
+    {
+        ByteBuffer stream = ByteBuffer.allocate( data.length );
+        stream.put( data );
+        stream.flip();
+        
+        // Allocate a EncApRepPart Container
+        Asn1Container encApRepPartContainer = new EncApRepPartContainer();
+
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        // Decode the EncApRepPart PDU
+        try
+        {
+            kerberosDecoder.decode( stream, encApRepPartContainer );
+        }
+        catch ( DecoderException de )
+        {
+            throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY, de );
+        }
+
+        // get the decoded EncApRepPart
+        EncApRepPart encApRepPart = ( ( EncApRepPartContainer ) encApRepPartContainer ).getEncApRepPart();
+
+        return encApRepPart;
+    }
+    
+    
+    /**
+     * Decode an EncKdcRepPart structure
+     * 
+     * @param data The byte array containing the data structure to decode
+     * @return An instance of EncKdcRepPart
+     * @throws KerberosException If the decoding fails
+     */
+    public static EncKdcRepPart decodeEncKdcRepPart( byte[] data ) throws KerberosException
+    {
+        ByteBuffer stream = ByteBuffer.allocate( data.length );
+        stream.put( data );
+        stream.flip();
+        
+        // Allocate a EncKdcRepPart Container
+        Asn1Container encKdcRepPartContainer = new EncKdcRepPartContainer();
+
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        // Decode the EncKdcRepPart PDU
+        try
+        {
+            kerberosDecoder.decode( stream, encKdcRepPartContainer );
+        }
+        catch ( DecoderException de )
+        {
+            throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY, de );
+        }
+
+        // get the decoded EncKdcRepPart
+        EncKdcRepPart encKdcRepPart = ( ( EncKdcRepPartContainer ) encKdcRepPartContainer
).getEncKdcRepPart();
+
+        return encKdcRepPart;
+    }
+    
+    
+    /**
+     * Decode an EncKrbPrivPart structure
+     * 
+     * @param data The byte array containing the data structure to decode
+     * @return An instance of EncKrbPrivPart
+     * @throws KerberosException If the decoding fails
+     */
+    public static EncKrbPrivPart decodeEncKrbPrivPart( byte[] data ) throws KerberosException
+    {
+        ByteBuffer stream = ByteBuffer.allocate( data.length );
+        stream.put( data );
+        stream.flip();
+        
+        // Allocate a EncKrbPrivPart Container
+        Asn1Container encKrbPrivPartContainer = new EncKrbPrivPartContainer();
+
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        // Decode the EncKrbPrivPart PDU
+        try
+        {
+            kerberosDecoder.decode( stream, encKrbPrivPartContainer );
+        }
+        catch ( DecoderException de )
+        {
+            throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY, de );
+        }
+
+        // get the decoded EncKrbPrivPart
+        EncKrbPrivPart encKrbPrivPart = ( ( EncKrbPrivPartContainer ) encKrbPrivPartContainer
).getEncKrbPrivPart();
+
+        return encKrbPrivPart;
+    }
+    
+    
+    /**
+     * Decode an EncTicketPart structure
+     * 
+     * @param data The byte array containing the data structure to decode
+     * @return An instance of EncTicketPart
+     * @throws KerberosException If the decoding fails
+     */
+    public static EncTicketPart decodeEncTicketPart( byte[] data ) throws KerberosException
+    {
+        ByteBuffer stream = ByteBuffer.allocate( data.length );
+        stream.put( data );
+        stream.flip();
+        
+        // Allocate a EncTicketPart Container
+        Asn1Container encTicketPartContainer = new EncTicketPartContainer();
+
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        // Decode the EncTicketPart PDU
+        try
+        {
+            kerberosDecoder.decode( stream, encTicketPartContainer );
+        }
+        catch ( DecoderException de )
+        {
+            throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY, de );
+        }
+
+        // get the decoded EncTicketPart
+        EncTicketPart encTicketPart = ( ( EncTicketPartContainer ) encTicketPartContainer
).getEncTicketPart();
+
+        return encTicketPart;
+    }
 }



Mime
View raw message