directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r546746 - in /directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared: crypto/encryption/CipherTextHandler.java io/decoder/EncApRepPartDecoder.java io/encoder/ApplicationRequestEncoder.java
Date Wed, 13 Jun 2007 06:13:42 GMT
Author: erodriguez
Date: Tue Jun 12 23:13:42 2007
New Revision: 546746

URL: http://svn.apache.org/viewvc?view=rev&rev=546746
Log:
Changes related to client-side Change Password:
o  Added new EncApRepPart decoder.
o  Enabled decoder in CipherTextHandler.
o  Fixed encoding bug in new ApplicationRequestEncoder.

Added:
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncApRepPartDecoder.java
  (with props)
Modified:
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/ApplicationRequestEncoder.java

Modified: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java?view=diff&rev=546746&r1=546745&r2=546746
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
(original)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
Tue Jun 12 23:13:42 2007
@@ -32,6 +32,7 @@
 import org.apache.directory.server.kerberos.shared.io.decoder.AuthorizationDataDecoder;
 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.EncKrbPrivPartDecoder;
 import org.apache.directory.server.kerberos.shared.io.decoder.EncTicketPartDecoder;
 import org.apache.directory.server.kerberos.shared.io.decoder.EncryptedTimestampDecoder;
@@ -98,6 +99,7 @@
         map.put( EncryptedTimeStamp.class, EncryptedTimestampDecoder.class );
         map.put( AuthorizationData.class, AuthorizationDataDecoder.class );
         map.put( EncKrbPrivPart.class, EncKrbPrivPartDecoder.class );
+        map.put( EncApRepPart.class, EncApRepPartDecoder.class );
 
         DEFAULT_DECODERS = Collections.unmodifiableMap( map );
     }

Added: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncApRepPartDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncApRepPartDecoder.java?view=auto&rev=546746
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncApRepPartDecoder.java
(added)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncApRepPartDecoder.java
Tue Jun 12 23:13:42 2007
@@ -0,0 +1,108 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.kerberos.shared.io.decoder;
+
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import org.apache.directory.server.kerberos.shared.messages.Encodable;
+import org.apache.directory.server.kerberos.shared.messages.components.EncApRepPart;
+import org.apache.directory.server.kerberos.shared.messages.components.EncApRepPartModifier;
+import org.apache.directory.shared.asn1.der.ASN1InputStream;
+import org.apache.directory.shared.asn1.der.DERApplicationSpecific;
+import org.apache.directory.shared.asn1.der.DEREncodable;
+import org.apache.directory.shared.asn1.der.DERGeneralizedTime;
+import org.apache.directory.shared.asn1.der.DERInteger;
+import org.apache.directory.shared.asn1.der.DERSequence;
+import org.apache.directory.shared.asn1.der.DERTaggedObject;
+
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 502338 $, $Date: 2007-02-01 11:59:43 -0800 (Thu, 01 Feb 2007) $
+ */
+public class EncApRepPartDecoder implements Decoder, DecoderFactory
+{
+    public Decoder getDecoder()
+    {
+        return new EncApRepPartDecoder();
+    }
+
+
+    public Encodable decode( byte[] encodedEncApRepPart ) throws IOException
+    {
+        ASN1InputStream ais = new ASN1InputStream( encodedEncApRepPart );
+
+        DERApplicationSpecific app = ( DERApplicationSpecific ) ais.readObject();
+
+        DERSequence apRepPart = ( DERSequence ) app.getObject();
+
+        return decodeEncApRepPartSequence( apRepPart );
+    }
+
+
+    /**
+     * Decodes a {@link DERSequence} into a {@link EncApRepPart}.
+     * 
+     * EncAPRepPart    ::= [APPLICATION 27] SEQUENCE {
+     *         ctime           [0] KerberosTime,
+     *         cusec           [1] Microseconds,
+     *         subkey          [2] EncryptionKey OPTIONAL,
+     *         seq-number      [3] UInt32 OPTIONAL
+     * }
+     *
+     * @param sequence
+     * @return The {@link EncApRepPart}.
+     */
+    private EncApRepPart decodeEncApRepPartSequence( DERSequence sequence )
+    {
+        EncApRepPartModifier modifier = new EncApRepPartModifier();
+
+        for ( Enumeration e = sequence.getObjects(); e.hasMoreElements(); )
+        {
+            DERTaggedObject object = ( DERTaggedObject ) e.nextElement();
+            int tag = object.getTagNo();
+            DEREncodable derObject = object.getObject();
+
+            switch ( tag )
+            {
+                case 0:
+                    DERGeneralizedTime tag0 = ( DERGeneralizedTime ) derObject;
+                    modifier.setClientTime( KerberosTimeDecoder.decode( tag0 ) );
+                    break;
+                case 1:
+                    DERInteger tag1 = ( DERInteger ) derObject;
+                    modifier.setClientMicroSecond( new Integer( tag1.intValue() ) );
+                    break;
+                case 2:
+                    DERSequence tag2 = ( DERSequence ) derObject;
+                    modifier.setSubSessionKey( EncryptionKeyDecoder.decode( tag2 ) );
+                    break;
+                case 3:
+                    DERInteger tag3 = ( DERInteger ) derObject;
+                    modifier.setSequenceNumber( new Integer( tag3.intValue() ) );
+                    break;
+            }
+        }
+
+        return modifier.getEncApRepPart();
+    }
+}

Propchange: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncApRepPartDecoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/ApplicationRequestEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/ApplicationRequestEncoder.java?view=diff&rev=546746&r1=546745&r2=546746
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/ApplicationRequestEncoder.java
(original)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/ApplicationRequestEncoder.java
Tue Jun 12 23:13:42 2007
@@ -26,8 +26,8 @@
 import org.apache.directory.server.kerberos.shared.messages.ApplicationRequest;
 import org.apache.directory.shared.asn1.der.ASN1OutputStream;
 import org.apache.directory.shared.asn1.der.DERApplicationSpecific;
+import org.apache.directory.shared.asn1.der.DERBitString;
 import org.apache.directory.shared.asn1.der.DERInteger;
-import org.apache.directory.shared.asn1.der.DEROctetString;
 import org.apache.directory.shared.asn1.der.DERSequence;
 import org.apache.directory.shared.asn1.der.DERTaggedObject;
 
@@ -79,7 +79,7 @@
 
         sequence.add( new DERTaggedObject( 0, DERInteger.valueOf( message.getProtocolVersionNumber()
) ) );
         sequence.add( new DERTaggedObject( 1, DERInteger.valueOf( message.getMessageType().getOrdinal()
) ) );
-        sequence.add( new DERTaggedObject( 2, new DEROctetString( message.getApOptions().getBytes()
) ) );
+        sequence.add( new DERTaggedObject( 2, new DERBitString( message.getApOptions().getBytes()
) ) );
         sequence.add( new DERTaggedObject( 3, TicketEncoder.encode( message.getTicket() )
) );
         sequence.add( new DERTaggedObject( 4, EncryptedDataEncoder.encodeSequence( message.getEncPart()
) ) );
 



Mime
View raw message