directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1041508 - in /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src: main/java/org/apache/directory/shared/kerberos/components/ test/java/org/apache/directory/shared/kerberos/codec/
Date Thu, 02 Dec 2010 18:04:29 GMT
Author: elecharny
Date: Thu Dec  2 18:04:29 2010
New Revision: 1041508

URL: http://svn.apache.org/viewvc?rev=1041508&view=rev
Log:
Split the LastReq in two classes :
- the LastReq itself, with additional methods
- the LastReqEntry

Added:
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReqEntry.java
Modified:
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AuthorizationData.java
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AuthorizationDataEntry.java
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReq.java
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/LastReqDecoderTest.java

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AuthorizationData.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AuthorizationData.java?rev=1041508&r1=1041507&r2=1041508&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AuthorizationData.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AuthorizationData.java
Thu Dec  2 18:04:29 2010
@@ -252,15 +252,6 @@ public class AuthorizationData extends A
 
 
     /**
-     * @see Object#toString()
-     */
-    public String toString()
-    {
-        return toString( "" );
-    }
-    
-
-    /**
      * {@inheritDoc}
      */
     @Override
@@ -326,9 +317,16 @@ public class AuthorizationData extends A
         
         for ( AuthorizationDataEntry ad : authorizationData )
         {
-            sb.append( tabs ).append( ad );
+            sb.append( ad.toString( tabs + "    " ) );
         }
 
         return sb.toString();
     }
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return toString( "" );
+    }
 }

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AuthorizationDataEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AuthorizationDataEntry.java?rev=1041508&r1=1041507&r2=1041508&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AuthorizationDataEntry.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/AuthorizationDataEntry.java
Thu Dec  2 18:04:29 2010
@@ -176,15 +176,24 @@ public class AuthorizationDataEntry
     /**
      * @see Object#toString()
      */
-    public String toString()
+    public String toString( String tabs )
     {
         StringBuilder sb = new StringBuilder();
         
-        sb.append( "AuthorizationDataEntry : {\n" );
-        sb.append( "    adType : " ).append( adType ).append( "\n" );
-        sb.append( "    adData : " ).append( StringTools.dumpBytes( adData ) ).append( "\n"
);
-        sb.append( "}" );
+        sb.append( tabs ).append( "AuthorizationDataEntry : {\n" );
+        sb.append( tabs ).append( "    adType : " ).append( adType ).append( "\n" );
+        sb.append( tabs ).append( "    adData : " ).append( StringTools.dumpBytes( adData
) ).append( "\n" );
+        sb.append( tabs ).append( "}" );
         return sb.toString();
     }
+    
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return toString( "" );
+    }
 }
 

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReq.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReq.java?rev=1041508&r1=1041507&r2=1041508&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReq.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReq.java
Thu Dec  2 18:04:29 2010
@@ -59,38 +59,11 @@ public class LastReq extends AbstractAsn
     /** Speedup for logs */
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-    // The inner class storing the individual LastReqs
-    public class LR
-    {
-        /** The LastReq type. */
-        private LastReqType lrType;
-
-        /** The LastReq value */
-        private KerberosTime lrValue;
-
-
-        /**
-         * @return the LastReqType
-         */
-        public LastReqType getLrType()
-        {
-            return lrType;
-        }
-
-        /**
-         * @return the lr-value
-         */
-        public KerberosTime getLrValue()
-        {
-            return lrValue;
-        }
-    }
-    
     /** The list of LastReq elements */
-    private List<LR> lastReqs = new ArrayList<LR>();
+    private List<LastReqEntry> lastReqs = new ArrayList<LastReqEntry>();
     
-    /** The current LR being processed */
-    private LR currentLR;
+    /** The current LastReqEntry being processed */
+    private LastReqEntry currentLR;
 
 
     // Storage for computed lengths
@@ -113,7 +86,7 @@ public class LastReq extends AbstractAsn
      */
     public LastReqType getCurrentLrType()
     {
-        return currentLR.lrType;
+        return currentLR.getLrType();
     }
 
 
@@ -122,7 +95,7 @@ public class LastReq extends AbstractAsn
      */
     public void setCurrentLrType( LastReqType lrType )
     {
-        currentLR.lrType = lrType;
+        currentLR.setLrType( lrType );
     }
 
 
@@ -131,7 +104,7 @@ public class LastReq extends AbstractAsn
      */
     public KerberosTime getCurrentLrValue()
     {
-        return currentLR.lrValue;
+        return currentLR.getLrValue();
     }
 
 
@@ -140,14 +113,14 @@ public class LastReq extends AbstractAsn
      */
     public void setCurrentLrValue( KerberosTime lrValue )
     {
-        currentLR.lrValue = lrValue;
+        currentLR.setLrValue( lrValue );
     }
 
 
     /**
      * @return the CurrentLR
      */
-    public LR getCurrentLR()
+    public LastReqEntry getCurrentLR()
     {
         return currentLR;
     }
@@ -158,15 +131,25 @@ public class LastReq extends AbstractAsn
      */
     public void createNewLR()
     {
-        currentLR = new LR();
+        currentLR = new LastReqEntry();
         lastReqs.add( currentLR );
     }
 
 
     /**
+     * Add a new LastReqEntry
+     * @param lastReqEntry The enry to add
+     */
+    public void addEntry( LastReqEntry lastReqEntry)
+    {
+        lastReqs.add( lastReqEntry );
+    }
+
+
+    /**
      * @return the LastReqs
      */
-    public List<LR> getLastReqs()
+    public List<LastReqEntry> getLastReqs()
     {
         return lastReqs;
     }
@@ -199,11 +182,11 @@ public class LastReq extends AbstractAsn
         lrValueTagLen = new int[lastReqs.size()];
         lastReqSeqLen = new int[lastReqs.size()];
         
-        for ( LR lr : lastReqs )
+        for ( LastReqEntry lre : lastReqs )
         {
-            int lrTypeLen = Value.getNbBytes( lr.lrType.getValue() );
+            int lrTypeLen = Value.getNbBytes( lre.getLrType().getValue() );
             lrTypeTagLen[i] = 1 + TLV.getNbBytes( lrTypeLen ) + lrTypeLen;
-            byte[] lrValyeBytes = lr.lrValue.getBytes();
+            byte[] lrValyeBytes = lre.getLrValue().getBytes();
             lrValueTagLen[i] = 1 + TLV.getNbBytes( lrValyeBytes.length ) + lrValyeBytes.length;
             
             lastReqSeqLen[i] = 1 + TLV.getNbBytes( lrTypeTagLen[i] ) + lrTypeTagLen[i] +

@@ -250,7 +233,7 @@ public class LastReq extends AbstractAsn
             
             int i = 0;
             
-            for ( LR lr : lastReqs )
+            for ( LastReqEntry lre : lastReqs )
             {
                 buffer.put( UniversalTag.SEQUENCE.getValue() );
                 buffer.put( TLV.getBytes( lastReqSeqLen[i] ) );
@@ -258,7 +241,7 @@ public class LastReq extends AbstractAsn
                 // the lrType
                 buffer.put( ( byte ) KerberosConstants.LAST_REQ_LR_TYPE_TAG );
                 buffer.put( TLV.getBytes( lrTypeTagLen[i] ) );
-                Value.encode( buffer, lr.lrType.getValue() );
+                Value.encode( buffer, lre.getLrType().getValue() );
     
                 // the lrValue tag
                 buffer.put( ( byte ) KerberosConstants.LAST_REQ_LR_VALUE_TAG );
@@ -267,7 +250,7 @@ public class LastReq extends AbstractAsn
                 // the lrValue value
                 buffer.put( ( byte ) UniversalTag.GENERALIZED_TIME.getValue() );
                 buffer.put( ( byte ) 0x0F );
-                buffer.put( lr.lrValue.getBytes() );
+                buffer.put( lre.getLrValue().getBytes() );
             }
         }
         catch ( BufferOverflowException boe )
@@ -290,20 +273,26 @@ public class LastReq extends AbstractAsn
     /**
      * @see Object#toString()
      */
-    public String toString()
+    public String toString( String tabs )
     {
         StringBuilder sb = new StringBuilder();
 
-        sb.append( "LastReq : {\n" );
+        sb.append( tabs ).append( "LastReq : \n" );
         
-        for ( LR lr : lastReqs )
+        for ( LastReqEntry lre : lastReqs )
         {
-            sb.append( "    {\n" );
-            sb.append( "        lr-type: " ).append( lr.lrType ).append( '\n' );
-            sb.append( "        lr-value: " ).append( lr.lrValue ).append( '\n');
-            sb.append( "    }\n" );
+            sb.append( lre.toString( tabs + "    " ) );
         }
 
         return sb.toString();
     }
+    
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return toString( "" );
+    }
 }

Added: directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReqEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReqEntry.java?rev=1041508&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReqEntry.java
(added)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/LastReqEntry.java
Thu Dec  2 18:04:29 2010
@@ -0,0 +1,117 @@
+/*
+ *  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.components;
+
+import org.apache.directory.shared.kerberos.KerberosTime;
+import org.apache.directory.shared.kerberos.codec.types.LastReqType;
+
+/**
+ * The data structure hold into the LastReq element 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LastReqEntry
+{
+    /** The LastReq type. */
+    private LastReqType lrType;
+
+    /** The LastReq value */
+    private KerberosTime lrValue;
+
+
+    /**
+     * Creates a new instance of LastReqEntry
+     */
+    public LastReqEntry()
+    {
+    }
+    
+    
+    /**
+     * Creates a new instance of LastReqEntry
+     * @param lrType The LastRequest type
+     * @param lrValue The associated Time
+     */
+    public LastReqEntry( LastReqType lrType, KerberosTime lrValue )
+    {
+        this.lrType = lrType;
+        this.lrValue = lrValue;
+    }
+    
+    
+    /**
+     * @return the LastReqType
+     */
+    public LastReqType getLrType()
+    {
+        return lrType;
+    }
+
+
+    /**
+     * @param lrType the lrType to set
+     */
+    public void setLrType( LastReqType lrType )
+    {
+        this.lrType = lrType;
+    }
+
+    
+    /**
+     * @return the lr-value
+     */
+    public KerberosTime getLrValue()
+    {
+        return lrValue;
+    }
+
+
+    /**
+     * @param lrValue the lrValue to set
+     */
+    public void setLrValue( KerberosTime lrValue )
+    {
+        this.lrValue = lrValue;
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString( String tabs )
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append( tabs ) .append( "LastRequestEntry : {\n" );
+        sb.append( tabs ) .append(  "    lrType : " ).append( lrType ).append( "\n" );
+        sb.append( tabs ) .append(  "    lrValue : " ).append( lrValue ).append( "\n" );
+        sb.append( tabs ) .append(  "}" );
+        
+        return sb.toString();
+    }
+    
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return toString( "" );
+    }
+}

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/LastReqDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/LastReqDecoderTest.java?rev=1041508&r1=1041507&r2=1041508&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/LastReqDecoderTest.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/LastReqDecoderTest.java
Thu Dec  2 18:04:29 2010
@@ -32,6 +32,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.kerberos.codec.lastReq.LastReqContainer;
 import org.apache.directory.shared.kerberos.codec.types.LastReqType;
 import org.apache.directory.shared.kerberos.components.LastReq;
+import org.apache.directory.shared.kerberos.components.LastReqEntry;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
 
@@ -88,10 +89,10 @@ public class LastReqDecoderTest
         String[] expected = new String[]{ "20101110154525Z", "20101110154526Z" };
         int i = 0;
         
-        for ( LastReq.LR lr : lastReq.getLastReqs() )
+        for ( LastReqEntry lre : lastReq.getLastReqs() )
         {
-            assertEquals( LastReqType.TIME_OF_INITIAL_REQ, lr.getLrType() );
-            assertEquals( expected[i++], lr.getLrValue().toString() );
+            assertEquals( LastReqType.TIME_OF_INITIAL_REQ, lre.getLrType() );
+            assertEquals( expected[i++], lre.getLrValue().toString() );
             
         }
 



Mime
View raw message