You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2025/01/17 09:10:53 UTC

(directory-server) 01/09: Code refactoring for PDU to be presented properly

This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git

commit cfd7f406d18ef76664728141f7f8ca1d43f028fa
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Fri Jan 17 09:54:31 2025 +0100

    Code refactoring for PDU to be presented properly
---
 .../kerberos/codec/EncryptionKeyDecoderTest.java   |  64 +++-----
 .../kerberos/codec/PrincipalNameDecoderTest.java   | 182 +++++----------------
 .../server/operations/bind/BogusNtlmProvider.java  |   7 +-
 service/ApacheDS.launch                            |  30 ++--
 4 files changed, 82 insertions(+), 201 deletions(-)

diff --git a/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncryptionKeyDecoderTest.java b/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncryptionKeyDecoderTest.java
index 50540c6b5a..e10768d90d 100644
--- a/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncryptionKeyDecoderTest.java
+++ b/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncryptionKeyDecoderTest.java
@@ -55,20 +55,11 @@ public class EncryptionKeyDecoderTest
         stream.put( new byte[]
             {
                 0x30, 0x0F,
-                ( byte ) 0xA0, 0x03, // keytype
-                0x02,
-                0x01,
-                0x02,
-                ( byte ) 0xA1,
-                0x08, // keyvalue
-                0x04,
-                0x06,
-                'k',
-                'e',
-                'y',
-                'v',
-                'a',
-                'l'
+                  ( byte ) 0xA0, 0x03, // keytype
+                  0x02, 0x01, 0x02,
+                  ( byte ) 0xA1, 0x08, // keyvalue
+                    0x04, 0x06,
+                      'k', 'e', 'y', 'v', 'a', 'l'
         } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
@@ -142,7 +133,7 @@ public class EncryptionKeyDecoderTest
         stream.put( new byte[]
             {
                 0x30, 0x02,
-                ( byte ) 0xA0, 0x00
+                  ( byte ) 0xA0, 0x00
         } );
 
         stream.flip();
@@ -164,8 +155,8 @@ public class EncryptionKeyDecoderTest
         stream.put( new byte[]
             {
                 0x30, 0x04,
-                ( byte ) 0xA0, 0x02,
-                0x02, 0x00
+                  ( byte ) 0xA0, 0x02,
+                    0x02, 0x00
         } );
 
         stream.flip();
@@ -187,15 +178,9 @@ public class EncryptionKeyDecoderTest
         stream.put( new byte[]
             {
                 0x30, 0x0A,
-                ( byte ) 0xA1, 0x08, // keyvalue
-                0x04,
-                0x06,
-                'k',
-                'e',
-                'y',
-                'v',
-                'a',
-                'l'
+                  ( byte ) 0xA1, 0x08, // keyvalue
+                    0x04, 0x06,
+                      'k', 'e', 'y', 'v', 'a', 'l'
         } );
 
         stream.flip();
@@ -217,10 +202,8 @@ public class EncryptionKeyDecoderTest
         stream.put( new byte[]
             {
                 0x30, 0x05,
-                ( byte ) 0xA0, 0x03, // keytype
-                0x02,
-                0x01,
-                0x02
+                  ( byte ) 0xA0, 0x03, // keytype
+                    0x02, 0x01, 0x02
         } );
 
         stream.flip();
@@ -242,12 +225,9 @@ public class EncryptionKeyDecoderTest
         stream.put( new byte[]
             {
                 0x30, 0x07,
-                ( byte ) 0xA0, 0x03, // keytype
-                0x02,
-                0x01,
-                0x02,
-                ( byte ) 0xA1,
-                0x00
+                  ( byte ) 0xA0, 0x03, // keytype
+                    0x02, 0x01, 0x02,
+                    ( byte ) 0xA1, 0x00
         } );
 
         stream.flip();
@@ -269,14 +249,10 @@ public class EncryptionKeyDecoderTest
         stream.put( new byte[]
             {
                 0x30, 0x09,
-                ( byte ) 0xA0, 0x03, // keytype
-                0x02,
-                0x01,
-                0x02,
-                ( byte ) 0xA1,
-                0x02,
-                0x04,
-                0x00
+                  ( byte ) 0xA0, 0x03, // keytype
+                    0x02, 0x01, 0x02,
+                    ( byte ) 0xA1, 0x02,
+                      0x04, 0x00
         } );
 
         stream.flip();
diff --git a/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java b/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java
index 8b613f7faf..18634a381d 100644
--- a/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java
+++ b/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java
@@ -54,44 +54,16 @@ public class PrincipalNameDecoderTest
 
         stream.put( new byte[]
             { 0x30, 0x27,
-                ( byte ) 0xA0, 0x03, // name-type
-                0x02,
-                0x01,
-                0x01, // NT-PRINCIPAL
-                ( byte ) 0xA1,
-                0x20, // name-string
-                0x30,
-                0x1E,
-                0x1B,
-                0x08,
-                'h',
-                'n',
-                'e',
-                'l',
-                's',
-                'o',
-                'n',
-                '1',
-                0x1B,
-                0x08,
-                'h',
-                'n',
-                'e',
-                'l',
-                's',
-                'o',
-                'n',
-                '2',
-                0x1B,
-                0x08,
-                'h',
-                'n',
-                'e',
-                'l',
-                's',
-                'o',
-                'n',
-                '3',
+                ( byte ) 0xA0, 0x03,            // name-type
+                  0x02, 0x01, 0x01,             // NT-PRINCIPAL
+                  ( byte ) 0xA1, 0x20,          // name-string
+                    0x30, 0x1E,
+                      0x1B, 0x08,
+                        'h', 'n', 'e', 'l', 's', 'o', 'n', '1',
+                      0x1B, 0x08,
+                        'h', 'n', 'e', 'l', 's', 'o', 'n', '2',
+                      0x1B, 0x08,
+                      'h', 'n', 'e', 'l', 's', 'o', 'n', '3'
         } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
@@ -197,9 +169,8 @@ public class PrincipalNameDecoderTest
 
         stream.put( new byte[]
             { 0x30, 0x04,
-                ( byte ) 0xA0, 0x02, // name-type
-                0x02,
-                0x00 // NT-PRINCIPAL
+                ( byte ) 0xA0, 0x02,    // name-type
+                  0x02, 0x00            // NT-PRINCIPAL
         } );
 
         stream.flip();
@@ -225,14 +196,10 @@ public class PrincipalNameDecoderTest
 
         stream.put( new byte[]
             { 0x30, 0x09,
-                ( byte ) 0xA0, 0x03, // name-type
-                0x02,
-                0x01,
-                0x7F, // NT-PRINCIPAL
-                ( byte ) 0xA1,
-                0x02, // name-string
-                0x30,
-                0x00
+                ( byte ) 0xA0, 0x03,    // name-type
+                  0x02, 0x01, 0x7F,     // NT-PRINCIPAL
+                  ( byte ) 0xA1, 0x02,  // name-string
+                    0x30, 0x00
         } );
 
         stream.flip();
@@ -259,11 +226,8 @@ public class PrincipalNameDecoderTest
         stream.put( new byte[]
             { 0x30, 0x07,
                 ( byte ) 0xA0, 0x03, // name-type
-                0x02,
-                0x01,
-                0x01, // NT-PRINCIPAL
-                ( byte ) 0xA1,
-                0x00 // name-string
+                0x02, 0x01, 0x01, // NT-PRINCIPAL
+                  ( byte ) 0xA1, 0x00 // name-string
         } );
 
         stream.flip();
@@ -290,13 +254,9 @@ public class PrincipalNameDecoderTest
         stream.put( new byte[]
             { 0x30, 0x09,
                 ( byte ) 0xA0, 0x03, // name-type
-                0x02,
-                0x01,
-                0x01, // NT-PRINCIPAL
-                ( byte ) 0xA1,
-                0x02, // name-string
-                0x30,
-                0x00
+                  0x02, 0x01, 0x01, // NT-PRINCIPAL
+                  ( byte ) 0xA1, 0x02, // name-string
+                    0x30, 0x00
         } );
 
         stream.flip();
@@ -323,15 +283,10 @@ public class PrincipalNameDecoderTest
         stream.put( new byte[]
             { 0x30, 0x0B,
                 ( byte ) 0xA0, 0x03, // name-type
-                0x02,
-                0x01,
-                0x01, // NT-PRINCIPAL
-                ( byte ) 0xA1,
-                0x04, // name-string
-                0x30,
-                0x02,
-                0x1B,
-                0x00
+                  0x02, 0x01, 0x01, // NT-PRINCIPAL
+                  ( byte ) 0xA1, 0x04, // name-string
+                    0x30, 0x02,
+                      0x1B, 0x00
         } );
 
         stream.flip();
@@ -357,44 +312,16 @@ public class PrincipalNameDecoderTest
 
         stream.put( new byte[]
             { 0x30, 0x27,
-                ( byte ) 0xA0, 0x03, // name-type
-                0x02,
-                0x01,
-                0x01, // NT-PRINCIPAL
-                ( byte ) 0xA1,
-                0x20, // name-string
-                0x30,
-                0x1E,
-                0x1B,
-                0x08,
-                'h',
-                'n',
-                'e',
-                'l',
-                's',
-                'o',
-                'n',
-                '1',
-                0x1B,
-                0x08,
-                'h',
-                'n',
-                'e',
-                '\r',
-                's',
-                'o',
-                'n',
-                '2',
-                0x1B,
-                0x08,
-                'h',
-                'n',
-                'e',
-                'l',
-                's',
-                'o',
-                'n',
-                '3',
+                ( byte ) 0xA0, 0x03,        // name-type
+                  0x02, 0x01, 0x01,         // NT-PRINCIPAL
+                  ( byte ) 0xA1, 0x20,      // name-string
+                    0x30, 0x1E,
+                      0x1B, 0x08,
+                        'h', 'n', 'e', 'l', 's', 'o', 'n', '1',
+                      0x1B, 0x08,
+                        'h', 'n', 'e', '\r', 's', 'o', 'n', '2',
+                      0x1B, 0x08,
+                        'h', 'n', 'e', 'l', 's', 'o', 'n', '3'
         } );
 
         stream.flip();
@@ -421,38 +348,13 @@ public class PrincipalNameDecoderTest
         stream.put( new byte[]
             { 0x30, 0x22,
                 ( byte ) 0xA1, 0x20, // name-string
-                0x30,
-                0x1E,
-                0x1B,
-                0x08,
-                'h',
-                'n',
-                'e',
-                'l',
-                's',
-                'o',
-                'n',
-                '1',
-                0x1B,
-                0x08,
-                'h',
-                'n',
-                'e',
-                '\r',
-                's',
-                'o',
-                'n',
-                '2',
-                0x1B,
-                0x08,
-                'h',
-                'n',
-                'e',
-                'l',
-                's',
-                'o',
-                'n',
-                '3',
+                  0x30, 0x1E,
+                    0x1B, 0x08,
+                      'h', 'n', 'e', 'l', 's', 'o', 'n', '1',
+                    0x1B, 0x08,
+                      'h', 'n', 'e', 'l', 's', 'o', 'n', '2',
+                    0x1B, 0x08,
+                      'h', 'n', 'e', 'l', 's', 'o', 'n', '3'
         } );
 
         stream.flip();
diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/bind/BogusNtlmProvider.java b/server-integ/src/test/java/org/apache/directory/server/operations/bind/BogusNtlmProvider.java
index d39758b802..7b1751c685 100644
--- a/server-integ/src/test/java/org/apache/directory/server/operations/bind/BogusNtlmProvider.java
+++ b/server-integ/src/test/java/org/apache/directory/server/operations/bind/BogusNtlmProvider.java
@@ -23,7 +23,6 @@ package org.apache.directory.server.operations.bind;
 
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.server.ldap.handlers.sasl.ntlm.NtlmProvider;
-import org.apache.mina.core.session.IoSession;
 
 
 /**
@@ -38,16 +37,18 @@ public class BogusNtlmProvider implements NtlmProvider
     private byte[] type3response;
 
 
-    public boolean authenticate( IoSession session, byte[] type3response ) throws Exception
+    public boolean authenticate( byte[] type3response ) throws Exception
     {
         this.type3response = type3response;
+        
         return true;
     }
 
 
-    public byte[] generateChallenge( IoSession session, byte[] type1reponse ) throws Exception
+    public byte[] generateChallenge( byte[] type1reponse ) throws Exception
     {
         this.type1response = type1reponse;
+        
         return Strings.getBytesUtf8( "challenge" );
     }
 
diff --git a/service/ApacheDS.launch b/service/ApacheDS.launch
index 35e09b22b6..ec15764fd7 100644
--- a/service/ApacheDS.launch
+++ b/service/ApacheDS.launch
@@ -1,17 +1,19 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/apacheds-service/src/main/java/org/apache/directory/server/UberjarMain.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
-<mapEntry key="[debug]" value="org.eclipse.jdt.launching.localJavaApplication"/>
-<mapEntry key="[run]" value="org.eclipse.jdt.launching.localJavaApplication"/>
-</mapAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.apache.directory.server.UberjarMain"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="./target/instance"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="apacheds-service"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dlog4j.configuration=file:./log4j.properties -Dapacheds.log.dir=./target/instance/log -Dapacheds.controls= -Dapacheds.extendedOperations= -Dapacheds.extendedOperations= -Dapacheds.intermediateResponses="/>
+    <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+        <listEntry value="/apacheds-service/src/main/java/org/apache/directory/server/UberjarMain.java"/>
+    </listAttribute>
+    <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+        <listEntry value="1"/>
+    </listAttribute>
+    <mapAttribute key="org.eclipse.debug.core.preferred_launchers">
+        <mapEntry key="[debug]" value="org.eclipse.jdt.launching.localJavaApplication"/>
+        <mapEntry key="[run]" value="org.eclipse.jdt.launching.localJavaApplication"/>
+    </mapAttribute>
+    <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
+    <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.apache.directory.server.UberjarMain"/>
+    <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="./target/instance"/>
+    <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="apacheds-service"/>
+    <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
+    <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dlog4j.configuration=file:./log4j.properties -Dapacheds.log.dir=./target/instance/log -Dapacheds.controls= -Dapacheds.extendedOperations= -Dapacheds.extendedOperations= -Dapacheds.intermediateResponses="/>
 </launchConfiguration>