directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1033244 - in /directory: apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/ apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ shared/trunk/ldap/src/mai...
Date Tue, 09 Nov 2010 21:37:15 GMT
Author: elecharny
Date: Tue Nov  9 21:37:15 2010
New Revision: 1033244

URL: http://svn.apache.org/viewvc?rev=1033244&view=rev
Log:
o Made the Options class inherit from BitString
o Fixed some few minor things

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/KdcReqBody.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.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=1033244&r1=1033243&r2=1033244&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
Tue Nov  9 21:37:15 2010
@@ -20,7 +20,7 @@
 package org.apache.directory.shared.kerberos.codec.options;
 
 
-import java.util.BitSet;
+import org.apache.directory.shared.asn1.primitives.BitString;
 
 
 /**
@@ -28,23 +28,15 @@ import java.util.BitSet;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class Options
+public abstract class Options extends BitString
 {
-    /** The Bits storage */
-    private BitSet options;
-    
-    /** The size for the BitSet */
-    private int maxSize;
-
-
     /**
      * Creates a new BitSet with a specific number of bits.
      * @param maxSize The number of bits to allocate
      */
     protected Options( int maxSize )
     {
-        this.maxSize = maxSize;
-        options = new BitSet( maxSize );
+        super( maxSize );
     }
 
 
@@ -69,12 +61,12 @@ public abstract class Options
      */
     public boolean get( int index )
     {
-        if ( index >= maxSize )
+        if ( index >= size() )
         {
             throw new ArrayIndexOutOfBoundsException();
         }
         
-        return options.get( index );
+        return super.getBit( index );
     }
 
 
@@ -85,12 +77,12 @@ public abstract class Options
      */
     public void set( int index )
     {
-        if ( ( index < 0 ) || ( index > options.size() ) )
+        if ( ( index < 0 ) || ( index > size() ) )
         {
             return;
         }
         
-        options.set( index );
+        setBit( index );
     }
 
 
@@ -101,12 +93,12 @@ public abstract class Options
      */
     public void clear( int index )
     {
-        if ( ( index < 0 ) || ( index > options.size() ) )
+        if ( ( index < 0 ) || ( index > size() ) )
         {
             return;
         }
         
-        options.clear( index );
+        clearBit( index );
     }
 
 
@@ -119,28 +111,17 @@ public abstract class Options
      */
     public byte[] getBytes()
     {
-        byte[] bytes = new byte[maxSize / 8];
-
-        for ( int i = 0; i < maxSize; i++ )
-        {
-            if ( options.get( i ) )
-            {
-                bytes[bytes.length - i / 8 - 1] |= 1 << ( i % 8 );
-            }
-        }
-        return bytes;
+        return super.getData();
     }
 
 
+    /**
+     * Set the array of bytes representing the bits
+     * @param bytes The bytes to store
+     */
     protected void setBytes( byte[] bytes )
     {
-        for ( int i = 0; i < bytes.length * 8; i++ )
-        {
-            if ( ( bytes[bytes.length - i / 8 - 1] & ( 1 << ( i % 8 ) ) ) >
0 )
-            {
-                options.set( i);
-            }
-        }
+        super.setData( bytes );
     }
     
     
@@ -149,13 +130,6 @@ public abstract class Options
      */
     public String toString()
     {
-        StringBuilder sb = new StringBuilder();
-        
-        for ( int i = maxSize - 1; i >= 0; i-- )
-        {
-            sb.append( options.get( i ) ? "1" : "0" );
-        }
-        
-        return sb.toString();
+        return super.toString();
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KdcReqBody.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KdcReqBody.java?rev=1033244&r1=1033243&r2=1033244&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KdcReqBody.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/KdcReqBody.java
Tue Nov  9 21:37:15 2010
@@ -463,8 +463,8 @@ public class KdcReqBody
      */
     public int computeLength()
     {
-        // The KdcOptions length
-        kdcOptionsLength = 1 + 1 + kdcOptions.getBytes().length;
+        // The KdcOptions length (we have to add the unusedBits byte
+        kdcOptionsLength = 1 + 1 + 1 + kdcOptions.getBytes().length;
         
         // The cname length
         if ( cName != null )
@@ -609,7 +609,7 @@ public class KdcReqBody
         buffer.put( TLV.getBytes( kdcOptionsLength ) );
         
         // The value
-        //aaa
+        Value.encode( buffer, kdcOptions );
         
         // The cname if any ---------------------------------------------------
         if ( cName != null )

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java?rev=1033244&r1=1033243&r2=1033244&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java
Tue Nov  9 21:37:15 2010
@@ -27,7 +27,7 @@ import org.apache.directory.shared.i18n.
 
 /**
  * Implement the Bit String primitive type. A BitString is internally stored as
- * an array of int.
+ * an array of byte.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */



Mime
View raw message