directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1468429 - in /directory/apacheds/trunk/kerberos-client2/src: main/java/org/apache/directory/kerberos/client/KerberosChannel.java test/java/org/apache/directory/kerberos/client/KdcConnectionTest.java
Date Tue, 16 Apr 2013 14:24:19 GMT
Author: kayyagari
Date: Tue Apr 16 14:24:19 2013
New Revision: 1468429

URL: http://svn.apache.org/r1468429
Log:
o altered UDP transport handling to work on localhost
o fixed the wrong UDP response buffer size
o added a test for UDP connection

Modified:
    directory/apacheds/trunk/kerberos-client2/src/main/java/org/apache/directory/kerberos/client/KerberosChannel.java
    directory/apacheds/trunk/kerberos-client2/src/test/java/org/apache/directory/kerberos/client/KdcConnectionTest.java

Modified: directory/apacheds/trunk/kerberos-client2/src/main/java/org/apache/directory/kerberos/client/KerberosChannel.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-client2/src/main/java/org/apache/directory/kerberos/client/KerberosChannel.java?rev=1468429&r1=1468428&r2=1468429&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-client2/src/main/java/org/apache/directory/kerberos/client/KerberosChannel.java
(original)
+++ directory/apacheds/trunk/kerberos-client2/src/main/java/org/apache/directory/kerberos/client/KerberosChannel.java
Tue Apr 16 14:24:19 2013
@@ -41,6 +41,8 @@ public class KerberosChannel
     
     private int timeOut = 60000;
 
+    private SocketAddress udpServerAddr = null;
+    
     public void openConnection( String hostName, int  portNo, int timeOut, boolean isTcp
) throws IOException
     {
         this.useTcp = isTcp;
@@ -55,8 +57,8 @@ public class KerberosChannel
         }
         else
         {
-            SocketAddress bindaddr = new InetSocketAddress( hostName, portNo );
-            udpSocket = new DatagramSocket( bindaddr );
+            udpServerAddr = new InetSocketAddress( hostName, portNo );
+            udpSocket = new DatagramSocket();
         }
     }
 
@@ -86,10 +88,11 @@ public class KerberosChannel
         }
         else
         {
-            DatagramPacket reqPacket = new DatagramPacket( reqData, reqData.length );
+            DatagramPacket reqPacket = new DatagramPacket( reqData, reqData.length, udpServerAddr
);
             udpSocket.send( reqPacket );
             
-            DatagramPacket repPacket = new DatagramPacket( new byte[1], 1);
+            byte[] buffer = new byte[2048];
+            DatagramPacket repPacket = new DatagramPacket( buffer, buffer.length );
             udpSocket.receive( repPacket );
             
             byte[] receivedData = repPacket.getData();

Modified: directory/apacheds/trunk/kerberos-client2/src/test/java/org/apache/directory/kerberos/client/KdcConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-client2/src/test/java/org/apache/directory/kerberos/client/KdcConnectionTest.java?rev=1468429&r1=1468428&r2=1468429&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-client2/src/test/java/org/apache/directory/kerberos/client/KdcConnectionTest.java
(original)
+++ directory/apacheds/trunk/kerberos-client2/src/test/java/org/apache/directory/kerberos/client/KdcConnectionTest.java
Tue Apr 16 14:24:19 2013
@@ -27,10 +27,6 @@ import static org.junit.Assert.fail;
 
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
 import org.apache.directory.api.ldap.model.entry.Entry;
-import org.apache.directory.kerberos.client.KdcConnection;
-import org.apache.directory.kerberos.client.ServiceTicket;
-import org.apache.directory.kerberos.client.TgTicket;
-import org.apache.directory.kerberos.client.TgtRequest;
 import org.apache.directory.server.annotations.CreateChngPwdServer;
 import org.apache.directory.server.annotations.CreateKdcServer;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -43,7 +39,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.core.kerberos.KeyDerivationInterceptor;
-import org.apache.directory.server.kerberos.changepwd.exceptions.ChangePasswdErrorType;
+import org.apache.directory.server.protocol.shared.transport.Transport;
+import org.apache.directory.server.protocol.shared.transport.UdpTransport;
 import org.apache.directory.shared.kerberos.exceptions.KerberosException;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -76,13 +73,15 @@ import org.junit.runner.RunWith;
     searchBaseDn = "dc=example,dc=com",
     transports =
         {
-            @CreateTransport(protocol = "TCP")
+            @CreateTransport(protocol = "TCP"),
+            @CreateTransport(protocol = "UDP")
     },
     chngPwdServer = @CreateChngPwdServer
     (
         transports =
         {
-            @CreateTransport(protocol = "TCP")
+            @CreateTransport(protocol = "TCP"),
+            @CreateTransport(protocol = "UDP")
         }    
     ))
 @ApplyLdifs({
@@ -162,7 +161,7 @@ public class KdcConnectionTest extends A
     
     
     @Test
-    public void testGettingInitialTicket() throws Exception
+    public void testGettingInitialTicketTcp() throws Exception
     {
         TgTicket tgt = conn.getTgt( principalName, userPassword );
         assertNotNull( tgt );
@@ -171,6 +170,19 @@ public class KdcConnectionTest extends A
 
     
     @Test
+    public void testGettingInitialTicketUdp() throws Exception
+    {
+        KdcConnection udpConn = KdcConnection.createUdpConnection( "localhost", getUdpPort()
);
+        udpConn.setEncryptionTypes( kdcServer.getConfig().getEncryptionTypes() );
+        udpConn.setTimeout( Integer.MAX_VALUE );
+        
+        TgTicket tgt = udpConn.getTgt( principalName, userPassword );
+        assertNotNull( tgt );
+        assertFalse( tgt.isForwardable() );
+    }
+
+    
+    @Test
     public void testTgtFlags() throws Exception
     {
         TgtRequest tgtReq = new TgtRequest();
@@ -230,4 +242,18 @@ public class KdcConnectionTest extends A
         
         return entry.getDn().getName();
     }
+
+    private int getUdpPort()
+    {
+        for ( Transport t : kdcServer.getTransports() )
+        {
+            if ( t instanceof UdpTransport )
+            {
+                return t.getPort();
+            }
+        }
+
+        return -1;
+    }
+
 }



Mime
View raw message