directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1041525 - /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
Date Thu, 02 Dec 2010 18:49:25 GMT
Author: elecharny
Date: Thu Dec  2 18:49:24 2010
New Revision: 1041525

URL: http://svn.apache.org/viewvc?rev=1041525&view=rev
Log:
Fixed the encode method, removed the Encoder map

Modified:
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.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=1041525&r1=1041524&r2=1041525&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
Thu Dec  2 18:49:24 2010
@@ -22,6 +22,7 @@ package org.apache.directory.server.kerb
 
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -41,10 +42,14 @@ import org.apache.directory.server.kerbe
 import org.apache.directory.server.kerberos.shared.messages.components.EncKdcRepPart;
 import org.apache.directory.server.kerberos.shared.messages.components.EncKrbPrivPart;
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptedTimeStamp;
+import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
+import org.apache.directory.shared.kerberos.components.AuthorizationData;
 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.messages.Authenticator;
+import org.apache.directory.shared.kerberos.messages.KerberosMessage;
 
 
 /**
@@ -56,10 +61,9 @@ import org.apache.directory.shared.kerbe
  */
 public class CipherTextHandler
 {
-    /** a map of the default encodable class names to the encoder class names */
-    private static final Map DEFAULT_ENCODERS;
     /** a map of the default encodable class names to the decoder class names */
     private static final Map DEFAULT_DECODERS;
+    
     /** a map of the default encryption types to the encryption engine class names */
     private static final Map DEFAULT_CIPHERS;
 
@@ -67,15 +71,10 @@ public class CipherTextHandler
     {
         Map<Class, Class> map = new HashMap<Class, Class>();
 
-        DEFAULT_ENCODERS = Collections.unmodifiableMap( map );
-    }
-
-    static
-    {
-        Map<Class, Class> map = new HashMap<Class, Class>();
-
         map.put( EncTicketPart.class, EncTicketPartDecoder.class );
+        map.put( Authenticator.class, AuthenticatorDecoder.class );
         map.put( EncryptedTimeStamp.class, EncryptedTimestampDecoder.class );
+        map.put( AuthorizationData.class, AuthorizationDataDecoder.class );
         map.put( EncKrbPrivPart.class, EncKrbPrivPartDecoder.class );
         map.put( EncApRepPart.class, EncApRepPartDecoder.class );
         map.put( EncKdcRepPart.class, EncKdcRepPartDecoder.class );
@@ -106,13 +105,15 @@ public class CipherTextHandler
      * @return The Kerberos EncryptedData.
      * @throws KerberosException
      */
-    public EncryptedData seal( EncryptionKey key, Encodable encodable, KeyUsage usage ) throws
KerberosException
+    public EncryptedData seal( EncryptionKey key, KerberosMessage message, KeyUsage usage
) throws KerberosException
     {
         try
         {
-            return encrypt( key, encode( encodable ), usage );
+            int bufferSize = message.computeLength();
+            ByteBuffer buffer = ByteBuffer.allocate( bufferSize );
+            return encrypt( key, message.encode( buffer ).array(), usage );
         }
-        catch ( IOException ioe )
+        catch ( EncoderException ioe )
         {
             throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY, ioe );
         }
@@ -167,12 +168,6 @@ public class CipherTextHandler
     }
 
 
-    private byte[] encode( Encodable encodable ) throws IOException
-    {
-        return null;
-    }
-
-
     private Encodable decode( Class encodable, byte[] plainText ) throws IOException
     {
         Class clazz = ( Class ) DEFAULT_DECODERS.get( encodable );



Mime
View raw message