directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1468453 - in /directory/apacheds/trunk/kerberos-codec/src: main/java/org/apache/directory/shared/kerberos/ main/java/org/apache/directory/shared/kerberos/components/ test/java/org/apache/directory/server/kerberos/shared/messages/components...
Date Tue, 16 Apr 2013 15:05:08 GMT
Author: elecharny
Date: Tue Apr 16 15:05:07 2013
New Revision: 1468453

URL: http://svn.apache.org/r1468453
Log:
o Fixed the parsing of PrincipalName : the realm is not anymore part of the PrincipalName.
o Fixed the tests accordingly

Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosUtils.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalName.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/components/TicketTest.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalNameTest.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosUtils.java?rev=1468453&r1=1468452&r2=1468453&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosUtils.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosUtils.java
Tue Apr 16 15:05:07 2013
@@ -249,18 +249,6 @@ public class KerberosUtils
                     {
                         // We have reached the realm : let's get out
                         done = true;
-                        // We have a new name component
-
-                        if ( i - start > 0 )
-                        {
-                            String nameComponent = new String( chars, start, i - start );
-                            nameComponents.add( nameComponent );
-                            start = i + 1;
-                        }
-                        else
-                        {
-                            throw new ParseException( I18n.err( I18n.ERR_628 ), i );
-                        }
                     }
 
                     break;
@@ -270,6 +258,26 @@ public class KerberosUtils
 
             if ( done )
             {
+                // We have a new name component
+                if ( i - start > 0 )
+                {
+                    String nameComponent = new String( chars, start, i - start );
+                    nameComponents.add( nameComponent );
+                    start = i + 1;
+                }
+                else
+                {
+                    throw new ParseException( I18n.err( I18n.ERR_628 ), i );
+                }
+
+                break;
+            }
+            else if ( i + 1 == chars.length )
+            {
+                // We have a new name component
+                String nameComponent = new String( chars, start, i - start + 1 );
+                nameComponents.add( nameComponent );
+
                 break;
             }
         }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalName.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalName.java?rev=1468453&r1=1468452&r2=1468453&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalName.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalName.java
Tue Apr 16 15:05:07 2013
@@ -131,6 +131,9 @@ public class PrincipalName extends Abstr
     /** The principal name - we may have more than one - */
     private List<String> nameString = new ArrayList<String>();
 
+    /** The realm part */
+    private String realm;
+
     /** The principal name as a byte[], for encoding purpose */
     private List<byte[]> nameBytes;
 
@@ -175,14 +178,14 @@ public class PrincipalName extends Abstr
 
     /**
      * Creates a new instance of PrincipalName given a String and an 
-     * prinipal type.
+     * principal type.
      * 
      * @param nameString The name string, which can contains more than one nameComponent
      * @param nameType The principal name
      */
     public PrincipalName( String nameString, PrincipalNameType nameType ) throws ParseException
     {
-        this.nameString.add( nameString );
+        this.nameString = KerberosUtils.getNames( nameString );
         this.nameType = nameType;
     }
 

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/components/TicketTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/components/TicketTest.java?rev=1468453&r1=1468452&r2=1468453&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/components/TicketTest.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/components/TicketTest.java
Tue Apr 16 15:05:07 2013
@@ -62,28 +62,29 @@ public class TicketTest
 
         byte[] expectedResult = new byte[]
             {
-                0x61, ( byte ) 0x81, ( byte ) 0xFA,
-                0x30, ( byte ) 0x81, ( byte ) 0xF7,
+                0x61, ( byte ) 0x81, ( byte ) 0xE7,
+                0x30, ( byte ) 0x81, ( byte ) 0xE4,
                 ( byte ) 0xA0, 0x03,
                 0x02, 0x01, 0x05,
                 ( byte ) 0xA1, 0x0D,
                 0x1B, 0x0B,
                 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
-                ( byte ) 0xA2, 0x28,
-                0x30, 0x26,
+                ( byte ) 0xA2, 0x1D,
+                0x30, 0x1B,
                 ( byte ) 0xA0, 0x03,
                 0x02, 0x01, 0x01,
-                ( byte ) 0xA1, 0x1F,
-                0x30, 0x1D,
-                0x1B, 0x1B,
-                'k', 'a', 'd', 'm', 'i', 'n', '/',
-                'c', 'h', 'a', 'n', 'g', 'e', 'p', 'w', '@', 'E', 'X', 'A', 'M', 'P', 'L',
'E', '.', 'C', 'O', 'M',
-                ( byte ) 0xA3, ( byte ) 0x81, ( byte ) 0xB6,
-                0x30, ( byte ) 0x81, ( byte ) 0xB3,
+                ( byte ) 0xA1, 0x14,
+                0x30, 0x12,
+                0x1B, 0x06,
+                'k', 'a', 'd', 'm', 'i', 'n',
+                0x1B, 0x08,
+                'c', 'h', 'a', 'n', 'g', 'e', 'p', 'w',
+                ( byte ) 0xA3, ( byte ) 0x81, ( byte ) 0xAE,
+                0x30, ( byte ) 0x81, ( byte ) 0xAB,
                 ( byte ) 0xA0, 0x03,
                 0x02, 0x01, 0x03,
-                ( byte ) 0xA2, ( byte ) 0x81, ( byte ) 0xAB,
-                0x04, ( byte ) 0x81, ( byte ) 0xA8
+                ( byte ) 0xA2, ( byte ) 0x81, ( byte ) 0xA3,
+                0x04, ( byte ) 0x81, ( byte ) 0xA0
         };
 
         // We will just compared the first bytes (everything before the encrypted data)

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalNameTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalNameTest.java?rev=1468453&r1=1468452&r2=1468453&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalNameTest.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/PrincipalNameTest.java
Tue Apr 16 15:05:07 2013
@@ -24,15 +24,15 @@ import static org.junit.Assert.assertEqu
 
 import java.nio.ByteBuffer;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.shared.kerberos.codec.types.PrincipalNameType;
 import org.apache.directory.shared.kerberos.components.PrincipalName;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Test the PrincipalName encoding and decoding
@@ -108,12 +108,11 @@ public class PrincipalNameTest
 
         byte[] expectedResult = new byte[]
             {
-                0x30, 0x0B,
+                0x30, 0x09,
                 ( byte ) 0xA0, 0x03,
                 0x02, 0x01, 0x01,
-                ( byte ) 0xA1, 0x04,
-                0x30, 0x02,
-                0x1B, 0x00
+                ( byte ) 0xA1, 0x02,
+                0x30, 0x00
         };
 
         assertEquals( Strings.dumpBytes( expectedResult ), Strings.dumpBytes( encoded.array()
) );



Mime
View raw message