directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1035634 - in /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos: KerberosConstants.java messages/AsReq.java
Date Tue, 16 Nov 2010 13:32:34 GMT
Author: elecharny
Date: Tue Nov 16 13:32:33 2010
New Revision: 1035634

URL: http://svn.apache.org/viewvc?rev=1035634&view=rev
Log:
Added the missing parts to be able to handle AS-REQ message decoding

Added:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/AsReq.java
Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosConstants.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosConstants.java?rev=1035634&r1=1035633&r2=1035634&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosConstants.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosConstants.java
Tue Nov 16 13:32:33 2010
@@ -84,4 +84,7 @@ public class KerberosConstants
     public static final int KDC_REQ_MSG_TYPE_TAG = 0xA2;
     public static final int KDC_REQ_PA_DATA_TAG = 0xA3;
     public static final int KDC_REQ_KDC_REQ_BODY_TAG = 0xA4;
+    
+    /** AS-REQ's tags */
+    public static final int AS_REQ_TAG = 0x6A;
 }

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/AsReq.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/AsReq.java?rev=1035634&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/AsReq.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/AsReq.java
Tue Nov 16 13:32:33 2010
@@ -0,0 +1,93 @@
+/*
+ *  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.shared.kerberos.messages;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.kerberos.KerberosConstants;
+import org.apache.directory.shared.kerberos.KerberosMessageType;
+import org.apache.directory.shared.kerberos.components.KdcReq;
+
+
+/**
+ * AS-REQ message. It's just a KDC-REQ message with a message type set to 10.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AsReq extends KdcReq
+{
+    // Storage for computed lengths
+    private transient int kdcReqLength;
+    private transient int asReqLength;
+
+    /**
+     * Creates a new instance of AS-REQ.
+     */
+    public AsReq() 
+    {
+        super( KerberosMessageType.AS_REQ );
+    }
+
+    
+    /**
+     * Compute the AS-REQ length
+     * <pre>
+     * AS-REQ :
+     * 
+     * 0x6A L1 AS-REQ message
+     *  |
+     *  +-->  0x30 L2 KDC-REQ sequence
+     */
+    public int computeLength()
+    {
+        kdcReqLength = super.computeLength();
+        asReqLength = 1 + TLV.getNbBytes( kdcReqLength ) + kdcReqLength;
+        
+        return asReqLength;
+    }
+    
+    
+    /**
+     * Encode the AS-REQ component
+     * 
+     * @param buffer The buffer containing the encoded result
+     * @return The encoded component
+     * @throws EncoderException If the encoding failed
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if ( buffer == null )
+        {
+            buffer = ByteBuffer.allocate( computeLength() );
+        }
+        
+        // The AS-REQ SEQ Tag
+        buffer.put( (byte)KerberosConstants.AS_REQ_TAG );
+        buffer.put( TLV.getBytes( asReqLength ) );
+        
+        // The KDC-REQ --------------------------------------------------------
+        super.encode( buffer );
+        
+        return buffer;
+    }
+}



Mime
View raw message