directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r165431 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/pojo/SpnegoNegTokenInitPOJO.java
Date Sat, 30 Apr 2005 23:13:08 GMT
Author: elecharny
Date: Sat Apr 30 16:13:06 2005
New Revision: 165431

URL: http://svn.apache.org/viewcvs?rev=165431&view=rev
Log:
Improved the way length are tested by adding expectedLength for sub-elements into this class.

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/pojo/SpnegoNegTokenInitPOJO.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/pojo/SpnegoNegTokenInitPOJO.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/pojo/SpnegoNegTokenInitPOJO.java?rev=165431&r1=165430&r2=165431&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/pojo/SpnegoNegTokenInitPOJO.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/pojo/SpnegoNegTokenInitPOJO.java
Sat Apr 30 16:13:06 2005
@@ -30,8 +30,23 @@
 {
     //~ Instance fields ----------------------------------------------------------------------------
 
-    /** The mechTypes */
+    /** The mechTypes. It's an array, as it allows us to pre-allocate a specific number of
OID */
     private OID[]       mechTypeList;
+    
+    /** The expected length of the NegTokenInitSequence element */
+    private int negTokenInitSequenceExpectedLength;
+    
+    /** The expected length of the mech types element */
+    private int mechTypesExpectedLength;
+    
+    /** The expected length of the mech types list element*/
+    private int mechTypeListExpectedLength;
+    
+    /** The maximum number of mech types in the array. Initialized to 10 */
+    private int 		mechTypeListMaxSize = 10;
+    
+    /** The current number of mech types stored in the array */
+    private int 		mechTypeListCurrentSize;
 
     /** The delegate flag */
     private boolean     delegFlag;
@@ -67,7 +82,27 @@
      */
     public SpnegoNegTokenInitPOJO()
     {
-        // We should not create this kind of object directly
+        // We should not create this kind of object directly, it must
+        // be created through the factory.
+        
+        // Allocating 10 OID should be enough...
+        // Ideally, we might want to allocate this array from a pool 
+        mechTypeList = new OID[mechTypeListMaxSize];
+        
+        mechTypeListCurrentSize = 0;
+        
+        negTokenInitSequenceExpectedLength = 0;
+        mechTypesExpectedLength = 0;
+        mechTypeListExpectedLength = 0;
+        
+        // Sets the flag to false.
+        delegFlag = false;
+        mutualFlag = false;
+        replayFlag = false;
+        sequenceFlag = false;
+        anonFlag = false;
+        confFlag = false;
+        integFlag = false;
     }
 
     //~ Methods ------------------------------------------------------------------------------------
@@ -79,6 +114,41 @@
      */
     public void free()
     {
+        // We have to free the OID's
+        for ( int i = 0; i < mechTypeListCurrentSize ; i++ )
+        {
+            if ( mechTypeList[i] != null )
+            {
+                mechTypeList[i].free();
+                mechTypeList[i] = null;
+            }
+        }
+        
+        // Free the mech token and the list MIC
+        if (mechToken != null)
+        {
+            mechToken.free();
+        }
+        
+        if (mechListMIC != null)
+        {
+            mechListMIC.free();
+        }
+        
+        mechTypeListCurrentSize = 0;
+        
+        negTokenInitSequenceExpectedLength = 0;
+        mechTypesExpectedLength = 0;
+        mechTypeListExpectedLength = 0;
+        
+        // Resets the flag to false.
+        delegFlag = false;
+        mutualFlag = false;
+        replayFlag = false;
+        sequenceFlag = false;
+        anonFlag = false;
+        confFlag = false;
+        integFlag = false;
 
         // put back the object in the pool
         super.free();
@@ -219,9 +289,17 @@
      *
      * @param mechTypeList The mechTypeList to set.
      */
-    public void setMechTypeList( OID[] mechTypeList )
+    public void addMechTypeList( OID mechType )
     {
-        this.mechTypeList = mechTypeList;
+        if ( mechTypeList.length == mechTypeListMaxSize)
+        {
+            // If the maximum size is reached, we will allocate 10 more slots.
+            mechTypeListMaxSize += 10;
+            OID[] newMechTypesList = new OID[mechTypeListMaxSize];
+            System.arraycopy(this.mechTypeList, 0, newMechTypesList, 0, mechTypeList.length);
+        }
+        
+        mechTypeList[mechTypeListCurrentSize++] = mechType;
     }
 
     /**
@@ -282,5 +360,62 @@
     public void setSequenceFlag( boolean sequenceFlag )
     {
         this.sequenceFlag = sequenceFlag;
+    }
+    
+    /**
+     * @return Returns the mechTypeListCurrentSize.
+     */
+    public int getMechTypeListCurrentSize() {
+        return mechTypeListCurrentSize;
+    }
+    
+    /**
+     * @param mechTypeListCurrentSize The mechTypeListCurrentSize to set.
+     */
+    public void setMechTypeListCurrentSize(int mechTypeListCurrentSize) {
+        this.mechTypeListCurrentSize = mechTypeListCurrentSize;
+    }
+    
+    /**
+     * @return Returns the negTokenInitSequenceExpectedLength.
+     */
+    public int getNegTokenInitSequenceExpectedLength() {
+        return negTokenInitSequenceExpectedLength;
+    }
+    
+    /**
+     * @param negTokenInitSequenceExpectedLength The negTokenInitSequenceExpectedLength to
set.
+     */
+    public void setNegTokenInitSequenceExpectedLength(
+            int negTokenInitSequenceExpectedLength) {
+        this.negTokenInitSequenceExpectedLength = negTokenInitSequenceExpectedLength;
+    }
+    
+    /**
+     * @return Returns the mechTypesExpectedLength.
+     */
+    public int getMechTypesExpectedLength() {
+        return mechTypesExpectedLength;
+    }
+    
+    /**
+     * @param mechTypeExpectedLength The mechTypeExpectedLength to set.
+     */
+    public void setMechTypesExpectedLength(int mechTypesExpectedLength) {
+        this.mechTypesExpectedLength = mechTypesExpectedLength;
+    }
+    
+    /**
+     * @return Returns the mechTypeListExpectedLength.
+     */
+    public int getMechTypeListExpectedLength() {
+        return mechTypeListExpectedLength;
+    }
+    
+    /**
+     * @param mechTypeListExpectedLength The mechTypeListExpectedLength to set.
+     */
+    public void setMechTypeListExpectedLength(int mechTypeListExpectedLength) {
+        this.mechTypeListExpectedLength = mechTypeListExpectedLength;
     }
 }



Mime
View raw message