diff --git a/config/alfresco/subsystems/fileServers/default/file-servers-context.xml b/config/alfresco/subsystems/fileServers/default/file-servers-context.xml
index 7f327c9828..f344bce6de 100644
--- a/config/alfresco/subsystems/fileServers/default/file-servers-context.xml
+++ b/config/alfresco/subsystems/fileServers/default/file-servers-context.xml
@@ -276,14 +276,18 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/java/org/alfresco/filesys/alfresco/AlfrescoClientInfo.java b/source/java/org/alfresco/filesys/alfresco/AlfrescoClientInfo.java
index 6badc4119e..e662d235e0 100644
--- a/source/java/org/alfresco/filesys/alfresco/AlfrescoClientInfo.java
+++ b/source/java/org/alfresco/filesys/alfresco/AlfrescoClientInfo.java
@@ -1,7 +1,5 @@
package org.alfresco.filesys.alfresco;
-import net.sf.acegisecurity.Authentication;
-
import org.alfresco.jlan.server.auth.ClientInfo;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -31,10 +29,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/
public class AlfrescoClientInfo extends ClientInfo {
- // Authentication token
-
- private Authentication m_authToken;
-
// Authentication ticket, used for web access without having to re-authenticate
private String m_authTicket;
@@ -62,26 +56,6 @@ public class AlfrescoClientInfo extends ClientInfo {
super(user, pwd);
}
- /**
- * Check if the client has an authentication token
- *
- * @return boolean
- */
- public final boolean hasAuthenticationToken()
- {
- return m_authToken != null ? true : false;
- }
-
- /**
- * Return the authentication token
- *
- * @return Authentication
- */
- public final Authentication getAuthenticationToken()
- {
- return m_authToken;
- }
-
/**
* Check if the client has an authentication ticket
*
@@ -122,16 +96,6 @@ public class AlfrescoClientInfo extends ClientInfo {
return m_homeNode;
}
- /**
- * Set the authentication toekn
- *
- * @param token Authentication
- */
- public final void setAuthenticationToken(Authentication token)
- {
- m_authToken = token;
- }
-
/**
* Set the authentication ticket
*
diff --git a/source/java/org/alfresco/filesys/auth/cifs/AlfrescoCifsAuthenticator.java b/source/java/org/alfresco/filesys/auth/cifs/AlfrescoCifsAuthenticator.java
index 8a1377778d..f6cffc57b9 100644
--- a/source/java/org/alfresco/filesys/auth/cifs/AlfrescoCifsAuthenticator.java
+++ b/source/java/org/alfresco/filesys/auth/cifs/AlfrescoCifsAuthenticator.java
@@ -20,8 +20,6 @@ package org.alfresco.filesys.auth.cifs;
import java.security.NoSuchAlgorithmException;
-import net.sf.acegisecurity.Authentication;
-
import org.alfresco.filesys.alfresco.AlfrescoClientInfo;
import org.alfresco.jlan.server.SrvSession;
import org.alfresco.jlan.server.auth.AuthContext;
@@ -31,6 +29,7 @@ import org.alfresco.jlan.server.auth.NTLanManAuthContext;
import org.alfresco.jlan.server.core.SharedDevice;
import org.alfresco.jlan.smb.server.SMBSrvSession;
import org.alfresco.jlan.util.HexDump;
+import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.repo.security.authentication.NTLMMode;
import org.alfresco.repo.security.authentication.ntlm.NTLMPassthruToken;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
@@ -111,20 +110,28 @@ public class AlfrescoCifsAuthenticator extends CifsAuthenticatorBase
// Check if the client is already authenticated, and it is not a null logon
- if ( alfClient.getAuthenticationToken() != null && client.getLogonType() != ClientInfo.LogonNull)
+ try
{
- // Use the existing authentication token
-
- getAuthenticationComponent().setCurrentUser(client.getUserName());
-
- // Debug
-
- if ( logger.isDebugEnabled())
- logger.debug("Re-using existing authentication token");
-
- // Return the authentication status
-
- return client.getLogonType() != ClientInfo.LogonGuest ? AUTH_ALLOW : AUTH_GUEST;
+ if ( alfClient.hasAuthenticationTicket() && client.getLogonType() != ClientInfo.LogonNull)
+ {
+ // Use the existing authentication token
+
+ getAuthenticationService().validate(alfClient.getAuthenticationTicket(), null);
+
+ // Debug
+
+ if ( logger.isDebugEnabled())
+ logger.debug("Re-using existing authentication token");
+
+ // Return the authentication status
+
+ return client.getLogonType() != ClientInfo.LogonGuest ? AUTH_ALLOW : AUTH_GUEST;
+ }
+ }
+ catch (AuthenticationException ex)
+ {
+ // Ticket no longer valid or maximum tickets exceeded
+ alfClient.setAuthenticationTicket(null);
}
// Check if this is a guest logon
@@ -379,7 +386,8 @@ public class AlfrescoCifsAuthenticator extends CifsAuthenticatorBase
// Set the current user to be authenticated, save the authentication token
AlfrescoClientInfo alfClient = (AlfrescoClientInfo) client;
- alfClient.setAuthenticationToken( getAuthenticationComponent().setCurrentUser(client.getUserName()));
+ getAuthenticationComponent().setCurrentUser(client.getUserName());
+ alfClient.setAuthenticationTicket(getAuthenticationService().getCurrentTicket());
// Get the users home folder node, if available
@@ -393,6 +401,10 @@ public class AlfrescoCifsAuthenticator extends CifsAuthenticatorBase
return ICifsAuthenticator.AUTH_ALLOW;
}
+ catch (AuthenticationException ex)
+ {
+ // Ticket no longer valid or maximum tickets exceeded
+ }
catch (NoSuchAlgorithmException ex)
{
}
@@ -461,13 +473,14 @@ public class AlfrescoCifsAuthenticator extends CifsAuthenticatorBase
// Authenticate the user
- Authentication genAuthToken = null;
+ String ticket = null;
try
{
// Run the second stage of the passthru authentication
- genAuthToken = getNTLMAuthenticator().authenticate( authToken);
+ getNTLMAuthenticator().authenticate( authToken);
+ ticket = getAuthenticationService().getCurrentTicket();
// Check if the user has been logged on as a guest
@@ -500,10 +513,10 @@ public class AlfrescoCifsAuthenticator extends CifsAuthenticatorBase
client.setLogonType( ClientInfo.LogonNormal);
}
- // Set the current user to be authenticated, save the authentication token
+ // Set the current user to be authenticated, save the authentication ticket
AlfrescoClientInfo alfClient = (AlfrescoClientInfo) client;
- alfClient.setAuthenticationToken( genAuthToken);
+ alfClient.setAuthenticationTicket(ticket);
// Get the users home folder node, if available
@@ -512,7 +525,11 @@ public class AlfrescoCifsAuthenticator extends CifsAuthenticatorBase
// DEBUG
if ( logger.isDebugEnabled())
- logger.debug("Auth token " + genAuthToken);
+ logger.debug("Auth ticket " + ticket);
+ }
+ catch (AuthenticationException ex)
+ {
+ // Ticket no longer valid or maximum tickets exceeded
}
catch ( Exception ex)
{
diff --git a/source/java/org/alfresco/filesys/auth/cifs/CifsAuthenticatorBase.java b/source/java/org/alfresco/filesys/auth/cifs/CifsAuthenticatorBase.java
index 9e3170b1fd..05c9f7d88f 100644
--- a/source/java/org/alfresco/filesys/auth/cifs/CifsAuthenticatorBase.java
+++ b/source/java/org/alfresco/filesys/auth/cifs/CifsAuthenticatorBase.java
@@ -18,9 +18,6 @@
*/
package org.alfresco.filesys.auth.cifs;
-import net.sf.acegisecurity.Authentication;
-
-import org.springframework.extensions.config.ConfigElement;
import org.alfresco.filesys.AlfrescoConfigSection;
import org.alfresco.filesys.alfresco.AlfrescoClientInfo;
import org.alfresco.filesys.repo.ContentContext;
@@ -37,6 +34,8 @@ import org.alfresco.jlan.server.filesys.SrvDiskInfo;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.management.subsystems.ActivateableBean;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationException;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.MD4PasswordEncoder;
import org.alfresco.repo.security.authentication.MD4PasswordEncoderImpl;
import org.alfresco.repo.security.authentication.ntlm.NLTMAuthenticator;
@@ -51,6 +50,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.extensions.config.ConfigElement;
/**
* CIFS Authenticator Base Class
@@ -309,9 +309,9 @@ public abstract class CifsAuthenticatorBase extends CifsAuthenticator implements
// Get a guest authentication token
getAuthenticationService().authenticateAsGuest();
- Authentication authToken = getAuthenticationComponent().getCurrentAuthentication();
+ String ticket = getAuthenticationService().getCurrentTicket();
- alfClient.setAuthenticationToken( authToken);
+ alfClient.setAuthenticationTicket(ticket);
// Set the home folder for the guest user
@@ -374,27 +374,34 @@ public abstract class CifsAuthenticatorBase extends CifsAuthenticator implements
*/
protected final String mapUserNameToPerson(final String userName)
{
- return doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback()
+ // Do the lookup as the system user
+ return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork()
{
-
- public String execute() throws Throwable
+ public String doWork() throws Exception
{
- // Get the home folder for the user
-
- String personName = getPersonService().getUserIdentifier(userName);
-
- // Check if the person exists
-
- if (personName == null)
+ return doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback()
{
- // Force creation of a person if possible
- getPersonService().getPerson(userName);
- personName = getPersonService().getUserIdentifier(userName);
- return personName == null ? userName : personName;
- }
- return personName;
+
+ public String execute() throws Throwable
+ {
+ // Get the home folder for the user
+
+ String personName = getPersonService().getUserIdentifier(userName);
+
+ // Check if the person exists
+
+ if (personName == null)
+ {
+ // Force creation of a person if possible
+ getPersonService().getPerson(userName);
+ personName = getPersonService().getUserIdentifier(userName);
+ return personName == null ? userName : personName;
+ }
+ return personName;
+ }
+ });
}
- });
+ }, AuthenticationUtil.getSystemUserName());
}
/**
@@ -403,29 +410,52 @@ public abstract class CifsAuthenticatorBase extends CifsAuthenticator implements
* @param client
* ClientInfo
*/
- public void setCurrentUser(ClientInfo client) {
+ public void setCurrentUser(final ClientInfo client) {
// Check the account type and setup the authentication context
- if (client == null || client.isNullSession())
+ doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback