directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1226901 - in /directory/apacheds/branches/apacheds-txns: kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/ kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/
Date Tue, 03 Jan 2012 18:07:56 GMT
Author: elecharny
Date: Tue Jan  3 18:07:55 2012
New Revision: 1226901

URL: http://svn.apache.org/viewvc?rev=1226901&view=rev
Log:
Fixed the kerberos-tests by removing the txn layer from it, as the txn layer is already in
coreSession

Modified:
    directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java
    directory/apacheds/branches/apacheds-txns/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java

Modified: directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java?rev=1226901&r1=1226900&r2=1226901&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java
(original)
+++ directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java
Tue Jan  3 18:07:55 2012
@@ -20,12 +20,10 @@
 package org.apache.directory.server.kerberos.shared.store;
 
 
-
 import javax.security.auth.kerberos.KerberosPrincipal;
 
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
-import org.apache.directory.server.core.api.txn.TxnManager;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.kerberos.shared.store.operations.ChangePassword;
 import org.apache.directory.server.kerberos.shared.store.operations.GetPrincipal;
@@ -43,14 +41,13 @@ class SingleBaseSearch implements Princi
 {
     private final CoreSession session;
     private final Dn searchBaseDn;
-    private TxnManager txnManager;
+
 
     SingleBaseSearch( DirectoryService directoryService, Dn searchBaseDn )
     {
         try
         {
             session = directoryService.getAdminSession();
-            txnManager = directoryService.getTxnManager();
             this.searchBaseDn = searchBaseDn;
         }
         catch ( Exception e )
@@ -63,33 +60,19 @@ class SingleBaseSearch implements Princi
 
     public PrincipalStoreEntry getPrincipal( KerberosPrincipal principal ) throws Exception
     {
-        
+
         PrincipalStoreEntry entry = null;
-        
+
         try
         {
-            txnManager.beginTransaction( true );
-            
-            try
-            {
-                entry = ( PrincipalStoreEntry ) new GetPrincipal( principal ).execute( session,
searchBaseDn );
-            }
-            catch ( Exception e )
-            {
-                txnManager.abortTransaction();
-
-                throw e;
-            }
-            
-            txnManager.commitTransaction();
-
+            entry = ( PrincipalStoreEntry ) new GetPrincipal( principal ).execute( session,
searchBaseDn );
         }
         catch ( Exception e )
         {
             String message = I18n.err( I18n.ERR_625, principal.getRealm() );
             throw new ServiceConfigurationException( message, e );
         }
-        
+
         return entry;
     }
 
@@ -97,37 +80,9 @@ class SingleBaseSearch implements Princi
     public String changePassword( KerberosPrincipal principal, String newPassword ) throws
Exception
     {
         String result = null;
-        boolean done = false;
- 
-        do
-        {
-            txnManager.beginTransaction( false );
 
-            try
-            {
-                result = ( String ) new ChangePassword( principal, newPassword ).execute(
session, searchBaseDn );
-            }
-            catch ( Exception e )
-            {
-                txnManager.abortTransaction();
-
-                throw e;
-            }
-
-            done = true;
-            
-            try
-            {
-                txnManager.commitTransaction();
-            }
-            catch ( Exception e )
-            {
-                // TODO check for conflict
-                throw e;
-            }
-        }
-        while ( !done );
-        
+        result = ( String ) new ChangePassword( principal, newPassword ).execute( session,
searchBaseDn );
+
         return result;
     }
 }

Modified: directory/apacheds/branches/apacheds-txns/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java?rev=1226901&r1=1226900&r2=1226901&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java
(original)
+++ directory/apacheds/branches/apacheds-txns/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/AbstractKerberosITest.java
Tue Jan  3 18:07:55 2012
@@ -113,18 +113,18 @@ public class AbstractKerberosITest exten
      */
     protected void testObtainTickets( ObtainTicketParameters parameters ) throws Exception
     {
-        setupEnv(parameters);
+        setupEnv( parameters );
         try
         {
             Subject subject = new Subject();
-    
+
             KerberosTestUtils.obtainTGT( subject, USER_UID, USER_PASSWORD );
-            
+
             assertEquals( 1, subject.getPrivateCredentials().size() );
             assertEquals( 0, subject.getPublicCredentials().size() );
-    
+
             KerberosTestUtils.obtainServiceTickets( subject, USER_UID, LDAP_SERVICE_NAME,
HOSTNAME );
-    
+
             assertEquals( 2, subject.getPrivateCredentials().size() );
             assertEquals( 0, subject.getPublicCredentials().size() );
             for ( KerberosTicket kt : subject.getPrivateCredentials( KerberosTicket.class
) )
@@ -158,12 +158,12 @@ public class AbstractKerberosITest exten
         // Then set it to -1/1 to force UDP/TCP.
         parameters.oldUdpPrefLimit = getUdpPrefLimit();
         setUdpPrefLimit( parameters.transport == TcpTransport.class ? 1 : -1 );
-        
+
         // Save current value of sun.security.krb5.Checksum.CKSUMTYPE_DEFAULT field.
         // Then set it to the required checksum value
         parameters.oldCksumtypeDefault = getCksumtypeDefault();
         setCksumtypeDefault( parameters.checksumType.getValue() );
-        
+
         // create krb5.conf with proper encryption type
         String krb5confPath = createKrb5Conf( parameters.encryptionType );
         System.setProperty( "java.security.krb5.conf", krb5confPath );
@@ -182,7 +182,8 @@ public class AbstractKerberosITest exten
         createPrincipal( "uid=ldap", "Service", "LDAP Service",
             "ldap", "randall", servicePrincipal );
     }
-    
+
+
     protected void resetEnv( ObtainTicketParameters parameters )
         throws Exception
     {
@@ -190,6 +191,7 @@ public class AbstractKerberosITest exten
         setCksumtypeDefault( parameters.oldCksumtypeDefault );
     }
 
+
     private static Integer getUdpPrefLimit() throws Exception
     {
         Field udpPrefLimitField = getUdpPrefLimitField();
@@ -210,10 +212,10 @@ public class AbstractKerberosITest exten
     {
         String clazz = "sun.security.krb5.KrbKdcReq";
         Class<?> krbKdcReqClass = Class.forName( clazz );
-        
+
         // Absolutely ugly fix to get this method working with the latest JVM on Mac (1.6.0_29)
         Field udpPrefLimitField = null;
-        
+
         try
         {
             udpPrefLimitField = krbKdcReqClass.getDeclaredField( "udpPrefLimit" );
@@ -222,27 +224,28 @@ public class AbstractKerberosITest exten
         {
             udpPrefLimitField = krbKdcReqClass.getDeclaredField( "defaultUdpPrefLimit" );
         }
-        
+
         udpPrefLimitField.setAccessible( true );
         return udpPrefLimitField;
     }
-    
+
+
     private static Integer getCksumtypeDefault() throws Exception
     {
         Field cksumtypeDefaultField = getCksumtypeDefaultField();
         Object value = cksumtypeDefaultField.get( null );
         return ( Integer ) value;
     }
-    
-    
+
+
     private static void setCksumtypeDefault( int limit ) throws Exception
     {
         Field cksumtypeDefaultField = getCksumtypeDefaultField();
         cksumtypeDefaultField.setAccessible( true );
         cksumtypeDefaultField.set( null, limit );
     }
-    
-    
+
+
     private static Field getCksumtypeDefaultField() throws ClassNotFoundException, NoSuchFieldException
     {
         String clazz = "sun.security.krb5.Checksum";
@@ -252,6 +255,7 @@ public class AbstractKerberosITest exten
         return cksumtypeDefaultField;
     }
 
+
     /**
      * Creates the krb5.conf file for the test.
      * 
@@ -290,10 +294,10 @@ public class AbstractKerberosITest exten
         data += "default_tkt_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR;
         data += "default_tgs_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR;
         data += "permitted_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR;
-//        data += "default_checksum = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
-//        data += "ap_req_checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
-//        data += "checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
-        
+        //        data += "default_checksum = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
+        //        data += "ap_req_checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
+        //        data += "checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR;
+
         data += "[realms]" + SystemUtils.LINE_SEPARATOR;
         data += REALM + " = {" + SystemUtils.LINE_SEPARATOR;
         data += "kdc = " + HOSTNAME + ":" + kdcServer.getTransports()[0].getPort() + SystemUtils.LINE_SEPARATOR;
@@ -318,7 +322,7 @@ public class AbstractKerberosITest exten
         entry.add( "cn", cn );
         entry.add( "sn", sn );
         entry.add( "uid", uid );
-        entry.add( "userPassword", userPassword );
+        entry.add( "userPassword", Strings.getBytesUtf8( userPassword ) );
         entry.add( "krb5PrincipalName", principalName );
         entry.add( "krb5KeyVersionNumber", "0" );
         conn.add( entry );



Mime
View raw message