directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1038983 - in /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos: codec/options/Options.java components/EncKdcRepPart.java flags/AbstractKerberosFlags.java messages/ApReq.java
Date Thu, 25 Nov 2010 10:21:14 GMT
Author: elecharny
Date: Thu Nov 25 10:21:13 2010
New Revision: 1038983

URL: http://svn.apache.org/viewvc?rev=1038983&view=rev
Log:
Fixed the way we deal with KerberosFlags

Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/Options.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags/AbstractKerberosFlags.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/ApReq.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/Options.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/Options.java?rev=1038983&r1=1038982&r2=1038983&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/Options.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/Options.java
Thu Nov 25 10:21:13 2010
@@ -20,7 +20,7 @@
 package org.apache.directory.shared.kerberos.codec.options;
 
 
-import org.apache.directory.shared.asn1.primitives.BitString;
+import org.apache.directory.shared.kerberos.flags.AbstractKerberosFlags;
 
 
 /**
@@ -28,7 +28,7 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class Options extends BitString
+public abstract class Options extends AbstractKerberosFlags
 {
     /**
      * Creates a new BitSet with a specific number of bits.

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java?rev=1038983&r1=1038982&r2=1038983&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncKdcRepPart.java
Thu Nov 25 10:21:13 2010
@@ -552,7 +552,7 @@ public class EncKdcRepPart extends Abstr
             // The flags
             buffer.put( ( byte )KerberosConstants.ENC_KDC_REP_PART_FLAGS_TAG );
             buffer.put( TLV.getBytes( 0x07 ) );
-            // TODO : add the flags
+            Value.encode( buffer, flags );
             
             // The authtime
             buffer.put( ( byte )KerberosConstants.ENC_KDC_REP_PART_AUTH_TIME_TAG );

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags/AbstractKerberosFlags.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags/AbstractKerberosFlags.java?rev=1038983&r1=1038982&r2=1038983&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags/AbstractKerberosFlags.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags/AbstractKerberosFlags.java
Thu Nov 25 10:21:13 2010
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.shared.kerberos.flags;
 
+import org.apache.directory.shared.asn1.primitives.BitString;
+
 
 /**
  * An implementation of a BitString for any KerberosFlags. The different values
@@ -29,7 +31,7 @@ package org.apache.directory.shared.kerb
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class AbstractKerberosFlags implements KerberosFlags
+public abstract class AbstractKerberosFlags extends BitString
 {
     /**
      * The maximum size of the BitString as specified for Kerberos flags.
@@ -45,6 +47,7 @@ public abstract class AbstractKerberosFl
      */
     public AbstractKerberosFlags()
     {
+        super( MAX_SIZE );
         value = 0;
     }
 
@@ -57,8 +60,28 @@ public abstract class AbstractKerberosFl
      */
     public AbstractKerberosFlags( int value )
     {
+        super( MAX_SIZE );
+
         this.value = value;
     }
+    
+    
+    /**
+     * Store the flags contained in the given integer value
+     * @param value The list of flags to set, as a int
+     */
+    public void setData( int value )
+    {
+        byte[] bytes = new byte[5];
+        
+        // The first byte contains the number of unused bytes, 0 here as we store 32 bits
+        bytes[0] = 0;
+        
+        bytes[1] = (byte)(value >> 24);
+        bytes[3] = (byte)( (value >> 16) & 0x00FF );
+        bytes[3] = (byte)( (value >> 8) & 0x00FF );
+        bytes[4] = (byte)(value & 0x00FF);
+    }
 
     
     /**
@@ -66,12 +89,14 @@ public abstract class AbstractKerberosFl
      */
     public AbstractKerberosFlags( byte[] flags )
     {
+        super( MAX_SIZE );
+        
         if ( ( flags == null ) || ( flags.length != 4 ) )
         {
             throw new IllegalArgumentException( "The given flags is not correct" );
         }
         
-        value = ( ( flags[0] & 0x00FF ) << 24 ) | ( ( flags[1] & 0x00FF ) <<
16 ) | ( ( flags[2] & 0x00FF ) << 8 ) | ( 0x00FF & flags[3] ); 
+        value = ( ( flags[0] & 0x00FF ) << 24 ) | ( ( flags[1] & 0x00FF ) <<
16 ) | ( ( flags[2] & 0x00FF ) << 8 ) | ( 0x00FF & flags[3] );
     }
     
     
@@ -130,6 +155,7 @@ public abstract class AbstractKerberosFl
     public void setFlag( KerberosFlag flag )
     {
         int pos = MAX_SIZE - 1 - flag.getValue();
+        setBit( pos );
         value |= 1 << pos;
     }
     
@@ -141,7 +167,9 @@ public abstract class AbstractKerberosFl
      */
     public void setFlag( int flag )
     {
-        value |= 1 << ( MAX_SIZE - 1 - flag );
+        int pos = MAX_SIZE - 1 - flag;
+        setBit( pos );
+        value |= 1 << pos;
     }
     
 
@@ -152,7 +180,9 @@ public abstract class AbstractKerberosFl
      */
     public void clearFlag( KerberosFlag flag )
     {
-        value &= ~( 1 << ( MAX_SIZE - 1 - flag.getValue() ) );
+        int pos = MAX_SIZE - 1 - flag.getOrdinal();
+        clearBit( pos );
+        value &= ~( 1 << pos );
     }
     
     
@@ -163,6 +193,8 @@ public abstract class AbstractKerberosFl
      */
     public void clearFlag( int flag )
     {
-        value &= ~( 1 << ( MAX_SIZE - 1 - flag ) );
+        int pos = MAX_SIZE - 1 - flag;
+        clearBit( pos );
+        value &= ~( 1 << pos );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/ApReq.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/ApReq.java?rev=1038983&r1=1038982&r2=1038983&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/ApReq.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/ApReq.java
Thu Nov 25 10:21:13 2010
@@ -123,9 +123,9 @@ public class ApReq extends KerberosMessa
      *
      * @param option
      */
-    public void setOption( int option )
+    public void setOption( ApOptions apOptions )
     {
-        apOptions.set( option );
+        this.apOptions = apOptions;
     }
 
 



Mime
View raw message