mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added guest user support to FTP server/filesystem authenticator. Changed authentication to use the standard authentication classes so FTP should work with LDAP and Kerberos setups.
Fixed server session transaction rollback problem. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2308 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,6 +18,8 @@ package org.alfresco.filesys.server;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.SystemException;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
@@ -479,9 +481,27 @@ public abstract class SrvSession
|
||||
boolean created = false;
|
||||
|
||||
// If there is an active transaction check that it is the required type
|
||||
|
||||
|
||||
if ( m_transaction != null)
|
||||
{
|
||||
// Check if the current transaction is marked for rollback
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if ( m_transaction.getStatus() == Status.STATUS_MARKED_ROLLBACK ||
|
||||
m_transaction.getStatus() == Status.STATUS_ROLLEDBACK ||
|
||||
m_transaction.getStatus() == Status.STATUS_ROLLING_BACK)
|
||||
{
|
||||
// Rollback the current transaction
|
||||
|
||||
m_transaction.rollback();
|
||||
}
|
||||
}
|
||||
catch ( SystemException ex)
|
||||
{
|
||||
}
|
||||
|
||||
// Check if the transaction is a write transaction, if write has been requested
|
||||
|
||||
if ( readOnly == false && m_readOnlyTrans == true)
|
||||
@@ -530,6 +550,48 @@ public abstract class SrvSession
|
||||
return created;
|
||||
}
|
||||
|
||||
/**
|
||||
* End a transaction by either committing or rolling back
|
||||
*
|
||||
* @exception AlfrescoRuntimeException
|
||||
*/
|
||||
public final void endTransaction()
|
||||
throws AlfrescoRuntimeException
|
||||
{
|
||||
// Check if there is an active transaction
|
||||
|
||||
if ( m_transaction != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Commit or rollback the transaction
|
||||
|
||||
if ( m_transaction.getStatus() == Status.STATUS_MARKED_ROLLBACK)
|
||||
{
|
||||
// Transaction is marked for rollback
|
||||
|
||||
m_transaction.rollback();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Commit the transaction
|
||||
|
||||
m_transaction.commit();
|
||||
}
|
||||
}
|
||||
catch ( Exception ex)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to end transaction", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Clear the current transaction
|
||||
|
||||
m_transaction = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Determine if the session has an active transaction
|
||||
*
|
||||
|
@@ -21,6 +21,8 @@ import java.util.Random;
|
||||
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import net.sf.acegisecurity.Authentication;
|
||||
|
||||
import org.alfresco.config.ConfigElement;
|
||||
import org.alfresco.filesys.server.SrvSession;
|
||||
import org.alfresco.filesys.server.config.InvalidConfigurationException;
|
||||
@@ -139,7 +141,10 @@ public class AlfrescoAuthenticator extends SrvAuthenticator
|
||||
{
|
||||
// Use the existing authentication token
|
||||
|
||||
m_authComponent.setCurrentUser(client.getUserName());
|
||||
if ( client.isGuest())
|
||||
m_authComponent.setGuestUserAsCurrentUser();
|
||||
else
|
||||
m_authComponent.setCurrentUser(client.getUserName());
|
||||
|
||||
// Debug
|
||||
|
||||
@@ -151,11 +156,36 @@ public class AlfrescoAuthenticator extends SrvAuthenticator
|
||||
return client.getLogonType() != ClientInfo.LogonGuest ? AUTH_ALLOW : AUTH_GUEST;
|
||||
}
|
||||
|
||||
// Check if MD4 or passthru mode is configured
|
||||
// Check if this is a guest logon
|
||||
|
||||
int authSts = AUTH_DISALLOW;
|
||||
|
||||
if ( m_authComponent.getNTLMMode() == NTLMMode.MD4_PROVIDER)
|
||||
if ( client.isGuest())
|
||||
{
|
||||
// Check if guest logons are allowed
|
||||
|
||||
if ( allowGuest() == false)
|
||||
return AUTH_DISALLOW;
|
||||
|
||||
// Get a guest authentication token
|
||||
|
||||
m_authComponent.setGuestUserAsCurrentUser();
|
||||
Authentication authToken = m_authComponent.getCurrentAuthentication();
|
||||
|
||||
client.setAuthenticationToken( authToken);
|
||||
|
||||
// Set the home folder for the guest user
|
||||
|
||||
getHomeFolderForUser( client);
|
||||
|
||||
// Indicate logged on as guest
|
||||
|
||||
authSts = AUTH_GUEST;
|
||||
}
|
||||
|
||||
// Check if MD4 or passthru mode is configured
|
||||
|
||||
else if ( m_authComponent.getNTLMMode() == NTLMMode.MD4_PROVIDER)
|
||||
{
|
||||
// Perform local MD4 password check
|
||||
|
||||
|
@@ -129,6 +129,24 @@ public class ClientInfo
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the password as a character array
|
||||
*
|
||||
* @return char[]
|
||||
*/
|
||||
public final char[] getPasswordAsCharArray()
|
||||
{
|
||||
char[] cpwd = null;
|
||||
|
||||
if (m_password != null)
|
||||
{
|
||||
String pwd = new String(m_password);
|
||||
cpwd = new char[pwd.length()];
|
||||
pwd.getChars(0, pwd.length(), cpwd, 0);
|
||||
}
|
||||
return cpwd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the client has specified an ANSI password
|
||||
*
|
||||
|
Reference in New Issue
Block a user