directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r562644 - in /directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared: io/decoder/ io/encoder/ messages/value/
Date Sat, 04 Aug 2007 02:46:20 GMT
Author: erodriguez
Date: Fri Aug  3 19:46:19 2007
New Revision: 562644

URL: http://svn.apache.org/viewvc?view=rev&rev=562644
Log:
Changes to support in pre-authentication for encryption types:
o  Added decoder for ETYPE-INFO to support client-side.
o  Added codecs for ETYPE-INFO2, new structure added in RFC 4120.

Added:
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncryptionTypeInfo2Decoder.java
  (with props)
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncryptionTypeInfoDecoder.java
  (with props)
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/EncryptionTypeInfo2Encoder.java
  (with props)
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/EncryptionTypeInfo2Entry.java
  (with props)
Modified:
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/PreAuthenticationDataEncoder.java

Added: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncryptionTypeInfo2Decoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncryptionTypeInfo2Decoder.java?view=auto&rev=562644
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncryptionTypeInfo2Decoder.java
(added)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncryptionTypeInfo2Decoder.java
Fri Aug  3 19:46:19 2007
@@ -0,0 +1,117 @@
+/*
+ *  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.crypto.encryption.EncryptionType;
+import org.apache.directory.server.kerberos.shared.messages.value.EncryptionTypeInfo2Entry;
+import org.apache.directory.shared.asn1.der.ASN1InputStream;
+import org.apache.directory.shared.asn1.der.DEREncodable;
+import org.apache.directory.shared.asn1.der.DERGeneralString;
+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;
+
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 540371 $, $Date: 2007-05-21 17:00:43 -0700 (Mon, 21 May 2007) $
+ */
+public class EncryptionTypeInfo2Decoder
+{
+    /**
+     * Decodes a byte array into an array of {@link EncryptionTypeInfo2Entry}.
+     *
+     * @param encodedEntries
+     * @return The array of {@link EncryptionTypeInfo2Entry}.
+     * @throws IOException
+     */
+    public EncryptionTypeInfo2Entry[] decode( byte[] encodedEntries ) throws IOException
+    {
+        ASN1InputStream ais = new ASN1InputStream( encodedEntries );
+
+        DERSequence sequence = ( DERSequence ) ais.readObject();
+
+        return decodeSequence( sequence );
+    }
+
+
+    /**
+     * ETYPE-INFO2             ::= SEQUENCE SIZE (1..MAX) OF ETYPE-INFO2-ENTRY
+     */
+    protected static EncryptionTypeInfo2Entry[] decodeSequence( DERSequence sequence )
+    {
+        EncryptionTypeInfo2Entry[] entrySequence = new EncryptionTypeInfo2Entry[sequence.size()];
+
+        int ii = 0;
+        for ( Enumeration<DERSequence> e = sequence.getObjects(); e.hasMoreElements();
)
+        {
+            DERSequence object = e.nextElement();
+            entrySequence[ii] = decode( object );
+            ii++;
+        }
+
+        return entrySequence;
+    }
+
+
+    /**
+     * ETYPE-INFO2-ENTRY       ::= SEQUENCE {
+     *         etype           [0] Int32,
+     *         salt            [1] KerberosString OPTIONAL,
+     *         s2kparams       [2] OCTET STRING OPTIONAL
+     * }
+     */
+    protected static EncryptionTypeInfo2Entry decode( DERSequence sequence )
+    {
+        EncryptionType encryptionType = EncryptionType.NULL;
+        String salt = new String();
+        byte[] s2kparams = new byte[0];
+
+        for ( Enumeration<DERTaggedObject> e = sequence.getObjects(); e.hasMoreElements();
)
+        {
+            DERTaggedObject object = e.nextElement();
+            int tag = object.getTagNo();
+            DEREncodable derObject = object.getObject();
+
+            switch ( tag )
+            {
+                case 0:
+                    DERInteger tag0 = ( DERInteger ) derObject;
+                    encryptionType = EncryptionType.getTypeByOrdinal( tag0.intValue() );
+                    break;
+                case 1:
+                    DERGeneralString tag1 = ( DERGeneralString ) derObject;
+                    salt = tag1.getString();
+                    break;
+                case 2:
+                    DEROctetString tag2 = ( DEROctetString ) derObject;
+                    s2kparams = tag2.getOctets();
+                    break;
+            }
+        }
+
+        return new EncryptionTypeInfo2Entry( encryptionType, salt, s2kparams );
+    }
+}

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

Added: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncryptionTypeInfoDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncryptionTypeInfoDecoder.java?view=auto&rev=562644
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncryptionTypeInfoDecoder.java
(added)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/decoder/EncryptionTypeInfoDecoder.java
Fri Aug  3 19:46:19 2007
@@ -0,0 +1,110 @@
+/*
+ *  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.crypto.encryption.EncryptionType;
+import org.apache.directory.server.kerberos.shared.messages.value.EncryptionTypeInfoEntry;
+import org.apache.directory.shared.asn1.der.ASN1InputStream;
+import org.apache.directory.shared.asn1.der.DEREncodable;
+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;
+
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 540371 $, $Date: 2007-05-21 17:00:43 -0700 (Mon, 21 May 2007) $
+ */
+public class EncryptionTypeInfoDecoder
+{
+    /**
+     * Decodes a byte array into an array of {@link EncryptionTypeInfoEntry}.
+     *
+     * @param encodedEntries
+     * @return The array of {@link EncryptionTypeInfoEntry}.
+     * @throws IOException
+     */
+    public EncryptionTypeInfoEntry[] decode( byte[] encodedEntries ) throws IOException
+    {
+        ASN1InputStream ais = new ASN1InputStream( encodedEntries );
+
+        DERSequence sequence = ( DERSequence ) ais.readObject();
+
+        return decodeSequence( sequence );
+    }
+
+
+    /**
+     * ETYPE-INFO              ::= SEQUENCE OF ETYPE-INFO-ENTRY
+     */
+    protected static EncryptionTypeInfoEntry[] decodeSequence( DERSequence sequence )
+    {
+        EncryptionTypeInfoEntry[] entrySequence = new EncryptionTypeInfoEntry[sequence.size()];
+
+        int ii = 0;
+        for ( Enumeration<DERSequence> e = sequence.getObjects(); e.hasMoreElements();
)
+        {
+            DERSequence object = e.nextElement();
+            entrySequence[ii] = decode( object );
+            ii++;
+        }
+
+        return entrySequence;
+    }
+
+
+    /**
+     * ETYPE-INFO-ENTRY        ::= SEQUENCE {
+     *     etype               [0] Int32,
+     *     salt                [1] OCTET STRING OPTIONAL
+     * }
+     */
+    protected static EncryptionTypeInfoEntry decode( DERSequence sequence )
+    {
+        EncryptionType encryptionType = EncryptionType.NULL;
+        byte[] salt = new byte[0];
+
+        for ( Enumeration<DERTaggedObject> e = sequence.getObjects(); e.hasMoreElements();
)
+        {
+            DERTaggedObject object = e.nextElement();
+            int tag = object.getTagNo();
+            DEREncodable derObject = object.getObject();
+
+            switch ( tag )
+            {
+                case 0:
+                    DERInteger type = ( DERInteger ) derObject;
+                    encryptionType = EncryptionType.getTypeByOrdinal( type.intValue() );
+                    break;
+                case 1:
+                    DEROctetString value = ( DEROctetString ) derObject;
+                    salt = value.getOctets();
+                    break;
+            }
+        }
+
+        return new EncryptionTypeInfoEntry( encryptionType, salt );
+    }
+}

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

Added: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/EncryptionTypeInfo2Encoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/EncryptionTypeInfo2Encoder.java?view=auto&rev=562644
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/EncryptionTypeInfo2Encoder.java
(added)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/EncryptionTypeInfo2Encoder.java
Fri Aug  3 19:46:19 2007
@@ -0,0 +1,100 @@
+/*
+ *  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.encoder;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.directory.server.kerberos.shared.messages.value.EncryptionTypeInfo2Entry;
+import org.apache.directory.shared.asn1.der.ASN1OutputStream;
+import org.apache.directory.shared.asn1.der.DERGeneralString;
+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;
+
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 540371 $, $Date: 2007-05-21 17:00:43 -0700 (Mon, 21 May 2007) $
+ */
+public class EncryptionTypeInfo2Encoder
+{
+    /**
+     * Encodes an array of {@link EncryptionTypeInfo2Entry}s into a byte array.
+     *
+     * @param entries
+     * @return The byte array.
+     * @throws IOException
+     */
+    public static byte[] encode( EncryptionTypeInfo2Entry[] entries ) throws IOException
+    {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ASN1OutputStream aos = new ASN1OutputStream( baos );
+        aos.writeObject( encodeSequence( entries ) );
+        aos.close();
+
+        return baos.toByteArray();
+    }
+
+
+    /**
+     * ETYPE-INFO2             ::= SEQUENCE SIZE (1..MAX) OF ETYPE-INFO2-ENTRY
+     */
+    protected static DERSequence encodeSequence( EncryptionTypeInfo2Entry[] entries )
+    {
+        DERSequence sequence = new DERSequence();
+
+        for ( int ii = 0; ii < entries.length; ii++ )
+        {
+            sequence.add( encode( entries[ii] ) );
+        }
+
+        return sequence;
+    }
+
+
+    /**
+     * ETYPE-INFO2-ENTRY       ::= SEQUENCE {
+     *         etype           [0] Int32,
+     *         salt            [1] KerberosString OPTIONAL,
+     *         s2kparams       [2] OCTET STRING OPTIONAL
+     * }
+     */
+    protected static DERSequence encode( EncryptionTypeInfo2Entry entry )
+    {
+        DERSequence sequence = new DERSequence();
+
+        sequence.add( new DERTaggedObject( 0, DERInteger.valueOf( entry.getEncryptionType().getOrdinal()
) ) );
+
+        if ( entry.getSalt() != null )
+        {
+            sequence.add( new DERTaggedObject( 1, DERGeneralString.valueOf( entry.getSalt()
) ) );
+        }
+
+        if ( entry.getS2kParams() != null )
+        {
+            sequence.add( new DERTaggedObject( 2, new DEROctetString( entry.getS2kParams()
) ) );
+        }
+
+        return sequence;
+    }
+}

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

Modified: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/PreAuthenticationDataEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/PreAuthenticationDataEncoder.java?view=diff&rev=562644&r1=562643&r2=562644
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/PreAuthenticationDataEncoder.java
(original)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/io/encoder/PreAuthenticationDataEncoder.java
Fri Aug  3 19:46:19 2007
@@ -56,6 +56,9 @@
     }
 
 
+    /**
+     * METHOD-DATA     ::= SEQUENCE OF PA-DATA
+     */
     protected static DERSequence encodeSequence( PreAuthenticationData[] preAuth )
     {
         DERSequence sequence = new DERSequence();

Added: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/EncryptionTypeInfo2Entry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/EncryptionTypeInfo2Entry.java?view=auto&rev=562644
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/EncryptionTypeInfo2Entry.java
(added)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/EncryptionTypeInfo2Entry.java
Fri Aug  3 19:46:19 2007
@@ -0,0 +1,83 @@
+/*
+ *  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.messages.value;
+
+
+import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
+
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 540371 $, $Date: 2007-05-21 17:00:43 -0700 (Mon, 21 May 2007) $
+ */
+public class EncryptionTypeInfo2Entry
+{
+    private EncryptionType encryptionType;
+    private String salt;
+    private byte[] s2kparams;
+
+
+    /**
+     * Creates a new instance of {@link EncryptionTypeInfo2Entry}.
+     *
+     * @param encryptionType
+     * @param salt
+     * @param s2kparams
+     */
+    public EncryptionTypeInfo2Entry( EncryptionType encryptionType, String salt, byte[] s2kparams
)
+    {
+        this.encryptionType = encryptionType;
+        this.salt = salt;
+        this.s2kparams = s2kparams;
+    }
+
+
+    /**
+     * Returns the {@link EncryptionType}.
+     *
+     * @return The {@link EncryptionType}.
+     */
+    public EncryptionType getEncryptionType()
+    {
+        return encryptionType;
+    }
+
+
+    /**
+     * Returns the salt.
+     *
+     * @return The salt.
+     */
+    public String getSalt()
+    {
+        return salt;
+    }
+
+
+    /**
+     * Returns the s2kparams.
+     * 
+     * @return The s2kparams.
+     */
+    public byte[] getS2kParams()
+    {
+        return s2kparams;
+    }
+}

Propchange: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/EncryptionTypeInfo2Entry.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message