From 16c2e77852ad20c66c712c51555d352f7b1647f9 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Wed, 17 Dec 2008 05:36:39 +0000 Subject: [PATCH] Merged V3.0 to HEAD 11375: MT - complete fix for ETHREEOH-189 11378: Supporting changes for license component in 3.0 (but not the license component itself ...) 11380: Fix for transaction error. ETHREEOH-451. 11383: Oracle upgrade and create SQL fixes (Can Entperprise-only later) 11384: Fix truelicense classpath in sdk-projects git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12424 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../webdav/auth/NTLMAuthenticationFilter.java | 118 +++++++++++++----- 1 file changed, 90 insertions(+), 28 deletions(-) diff --git a/source/java/org/alfresco/repo/webdav/auth/NTLMAuthenticationFilter.java b/source/java/org/alfresco/repo/webdav/auth/NTLMAuthenticationFilter.java index cee71fe1d4..b39bbcb9f8 100644 --- a/source/java/org/alfresco/repo/webdav/auth/NTLMAuthenticationFilter.java +++ b/source/java/org/alfresco/repo/webdav/auth/NTLMAuthenticationFilter.java @@ -42,6 +42,7 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import javax.transaction.Status; import javax.transaction.UserTransaction; import org.alfresco.filesys.ServerConfigurationBean; @@ -412,6 +413,7 @@ public class NTLMAuthenticationFilter implements Filter Type3NTLMMessage type3Msg = new Type3NTLMMessage(ntlmByts); processType3(type3Msg, req, resp, httpSess, chain); + return; } } @@ -664,9 +666,58 @@ public class NTLMAuthenticationFilter implements Filter if ( m_authComponent.getNTLMMode() == NTLMMode.MD4_PROVIDER) { - // Get the stored MD4 hashed password for the user, or null if the user does not exist + // Wrap the auth componenet calls in a transaction + + UserTransaction tx = m_transactionService.getUserTransaction(); + String md4hash = null; - String md4hash = m_authComponent.getMD4HashedPassword(userName); + try + { + tx.begin(); + + // Get the stored MD4 hashed password for the user, or null if the user does not exist + + md4hash = m_authComponent.getMD4HashedPassword(userName); + } + catch ( Throwable ex) { + + if ( logger.isDebugEnabled()) + logger.debug(ex); + } + finally { + + // Rollback/commit the transaction if still valid + + if ( tx != null) { + + try + { + // Commit or rollback the transaction + + if ( tx.getStatus() == Status.STATUS_MARKED_ROLLBACK || + tx.getStatus() == Status.STATUS_ROLLEDBACK || + tx.getStatus() == Status.STATUS_ROLLING_BACK) + { + // Transaction is marked for rollback + + tx.rollback(); + } + else + { + // Commit the transaction + + tx.commit(); + } + } + catch (Throwable ex) { + + if ( logger.isDebugEnabled()) + logger.debug(ex); + } + } + } + + // Check if we got a valid MD4 hashed password if ( md4hash != null) { @@ -772,33 +823,44 @@ public class NTLMAuthenticationFilter implements Filter // commit tx.commit(); + tx = null; } - catch (Throwable ex) - { - try - { - tx.rollback(); - } - catch (Exception ex2) - { - logger.error("Failed to rollback transaction", ex2); - } - if(ex instanceof RuntimeException) - { - throw (RuntimeException)ex; - } - else if(ex instanceof IOException) - { - throw (IOException)ex; - } - else if(ex instanceof ServletException) - { - throw (ServletException)ex; - } - else - { - throw new RuntimeException("Authentication setup failed", ex); - } + catch ( Throwable ex) { + + if ( logger.isDebugEnabled()) + logger.debug(ex); + } + finally { + + // Rollback/commit the transaction if still valid + + if ( tx != null) { + + try + { + // Commit or rollback the transaction + + if ( tx.getStatus() == Status.STATUS_MARKED_ROLLBACK || + tx.getStatus() == Status.STATUS_ROLLEDBACK || + tx.getStatus() == Status.STATUS_ROLLING_BACK) + { + // Transaction is marked for rollback + + tx.rollback(); + } + else + { + // Commit the transaction + + tx.commit(); + } + } + catch (Throwable ex) { + + if ( logger.isDebugEnabled()) + logger.debug(ex); + } + } } // Store the user