You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/11/25 18:45:20 UTC

svn commit: r1039110 - /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncAsRepPart.java

Author: elecharny
Date: Thu Nov 25 17:45:20 2010
New Revision: 1039110

URL: http://svn.apache.org/viewvc?rev=1039110&view=rev
Log:
Created the class

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

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncAsRepPart.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncAsRepPart.java?rev=1039110&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncAsRepPart.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncAsRepPart.java Thu Nov 25 17:45:20 2010
@@ -0,0 +1,94 @@
+/*
+ *  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.EncKdcRepPart;
+
+
+/**
+ * EncASRepPart message. 
+ *  It will store the object described by the ASN.1 grammar :
+ * <pre>
+ * EncASRepPart    ::= [APPLICATION 25] EncKDCRepPart
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EncAsRepPart extends EncKdcRepPart
+{
+    // Storage for computed lengths
+    private transient int encKdcRepPartLength;
+
+    /**
+     * Creates a new instance of EncAsRepPart.
+     */
+    public EncAsRepPart() 
+    {
+        super( KerberosMessageType.ENC_AS_REP_PART );
+    }
+
+    
+    /**
+     * Compute the EncAsRepPart length
+     * <pre>
+     * EncAsRepPart :
+     * 
+     * 0x79 L1 AS-REP message
+     *  |
+     *  +-->  0x30 L2 EncKdcRepPart sequence
+     * </pre>
+     */
+    public int computeLength()
+    {
+        encKdcRepPartLength = super.computeLength();
+        return 1 + TLV.getNbBytes( encKdcRepPartLength ) + encKdcRepPartLength;
+    }
+    
+    
+    /**
+     * Encode the EncAsRepPart 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 EncAsRepPart Tag
+        buffer.put( (byte)KerberosConstants.ENC_AS_REP_PART_TAG );
+        buffer.put( TLV.getBytes( encKdcRepPartLength ) );
+        
+        // The EncKdcRepPart --------------------------------------------------------
+        super.encode( buffer );
+        
+        return buffer;
+    }
+}