Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9664E954A for ; Wed, 14 Dec 2011 08:41:18 +0000 (UTC) Received: (qmail 27879 invoked by uid 500); 14 Dec 2011 08:41:18 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 27821 invoked by uid 500); 14 Dec 2011 08:41:17 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 27811 invoked by uid 99); 14 Dec 2011 08:41:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Dec 2011 08:41:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Dec 2011 08:41:13 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E7D5D2388993 for ; Wed, 14 Dec 2011 08:40:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1214110 - in /directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store: MultiBaseSearch.java SingleBaseSearch.java Date: Wed, 14 Dec 2011 08:40:51 -0000 To: commits@directory.apache.org From: saya@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111214084051.E7D5D2388993@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: saya Date: Wed Dec 14 08:40:51 2011 New Revision: 1214110 URL: http://svn.apache.org/viewvc?rev=1214110&view=rev Log: added txn demarcation for getting pricipal entry and changing password Modified: directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/MultiBaseSearch.java directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java Modified: directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/MultiBaseSearch.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/MultiBaseSearch.java?rev=1214110&r1=1214109&r2=1214110&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/MultiBaseSearch.java (original) +++ directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/store/MultiBaseSearch.java Wed Dec 14 08:40:51 2011 @@ -28,6 +28,7 @@ import javax.security.auth.kerberos.Kerb 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; @@ -50,14 +51,32 @@ class MultiBaseSearch implements Princip { private final Catalog catalog; private final DirectoryService directoryService; + private TxnManager txnManager; MultiBaseSearch( String catalogBaseDn, DirectoryService directoryService ) { this.directoryService = directoryService; + txnManager = directoryService.getTxnManager(); + try { - catalog = new KerberosCatalog( ( Map ) execute( directoryService.getSession(), new GetCatalog() ) ); + txnManager.beginTransaction( true ); + + try + { + catalog = new KerberosCatalog( ( Map ) execute( directoryService.getSession(), + new GetCatalog() ) ); + } + catch ( Exception e ) + { + txnManager.abortTransaction(); + + throw e; + } + + txnManager.commitTransaction(); + } catch ( Exception e ) { @@ -69,29 +88,81 @@ class MultiBaseSearch implements Princip public PrincipalStoreEntry getPrincipal( KerberosPrincipal principal ) throws Exception { + PrincipalStoreEntry entry = null; + try { - return ( PrincipalStoreEntry ) execute( directoryService.getSession(), new GetPrincipal( principal ) ); + txnManager.beginTransaction( true ); + + try + { + entry = ( PrincipalStoreEntry ) execute( directoryService.getSession(), new GetPrincipal( principal ) ); + } + catch ( NamingException ne ) + { + txnManager.abortTransaction(); + + throw ne; + } + + txnManager.commitTransaction(); + } - catch ( NamingException ne ) + catch ( Exception e ) { String message = I18n.err( I18n.ERR_625, principal.getRealm() ); - throw new ServiceConfigurationException( message, ne ); + throw new ServiceConfigurationException( message, e ); } + + return entry; } public String changePassword( KerberosPrincipal principal, String newPassword ) throws Exception { + String result = null; + boolean done = false; + try { - return ( String ) execute( directoryService.getSession(), new ChangePassword( principal, newPassword ) ); + do + { + txnManager.beginTransaction( false ); + + try + { + result = ( String ) execute( directoryService.getSession(), new ChangePassword( principal, newPassword ) ); + } + catch ( NamingException ne ) + { + txnManager.abortTransaction(); + + throw ne; + } + + done = true; + + try + { + txnManager.commitTransaction(); + } + catch ( Exception e ) + { + // TODO check for conflict + throw e; + } + } + while ( !done ); + } - catch ( NamingException ne ) + catch ( Exception e ) { String message = I18n.err( I18n.ERR_625, principal.getRealm() ); - throw new ServiceConfigurationException( message, ne ); + throw new ServiceConfigurationException( message, e ); } + + return result; + } 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=1214110&r1=1214109&r2=1214110&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 Wed Dec 14 08:40:51 2011 @@ -21,10 +21,12 @@ package org.apache.directory.server.kerb +import javax.naming.NamingException; 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; @@ -42,13 +44,14 @@ 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 ) @@ -61,12 +64,71 @@ class SingleBaseSearch implements Princi public PrincipalStoreEntry getPrincipal( KerberosPrincipal principal ) throws Exception { - return ( PrincipalStoreEntry ) new GetPrincipal( principal ).execute( session, searchBaseDn ); + + 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(); + + } + catch ( Exception e ) + { + String message = I18n.err( I18n.ERR_625, principal.getRealm() ); + throw new ServiceConfigurationException( message, e ); + } + + return entry; } public String changePassword( KerberosPrincipal principal, String newPassword ) throws Exception { - return (String) new ChangePassword( principal, newPassword ).execute( session, searchBaseDn ); + 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 ); + + return result; } }