MT - fix required, post merge of r8066

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8518 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka 2008-03-12 10:13:53 +00:00
parent af56b1ebac
commit 2fece79cd2

View File

@ -33,6 +33,7 @@ import net.sf.acegisecurity.providers.dao.User;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@ -145,7 +146,7 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
public Authentication setCurrentUser(final String userName) throws AuthenticationException public Authentication setCurrentUser(final String userName) throws AuthenticationException
{ {
if (AuthenticationUtil.getSystemUserName().equals(userName)) if (isSystemUserName(userName))
{ {
return setCurrentUserImpl(userName); return setCurrentUserImpl(userName);
} }
@ -178,11 +179,11 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
try try
{ {
UserDetails ud = null; UserDetails ud = null;
if (userName.equals(AuthenticationUtil.SYSTEM_USER_NAME)) if (isSystemUserName(userName))
{ {
GrantedAuthority[] gas = new GrantedAuthority[1]; GrantedAuthority[] gas = new GrantedAuthority[1];
gas[0] = new GrantedAuthorityImpl("ROLE_SYSTEM"); gas[0] = new GrantedAuthorityImpl("ROLE_SYSTEM");
ud = new User(AuthenticationUtil.SYSTEM_USER_NAME, "", true, true, true, true, gas); ud = new User(userName, "", true, true, true, true, gas);
} }
else if (isGuestUserName(userName)) else if (isGuestUserName(userName))
{ {
@ -283,7 +284,7 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
*/ */
public boolean isSystemUserName(String userName) public boolean isSystemUserName(String userName)
{ {
return ((userName != null) && tenantService.getBaseNameUser(userName).equals(getSystemUserName())); return (getSystemUserName().equals(tenantService.getBaseNameUser(userName)));
} }
/** /**
@ -343,7 +344,7 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
private boolean isGuestUserName(String userName) private boolean isGuestUserName(String userName)
{ {
return ((userName != null) && tenantService.getBaseNameUser(userName).equalsIgnoreCase(PermissionService.GUEST_AUTHORITY)); return (PermissionService.GUEST_AUTHORITY.equalsIgnoreCase(tenantService.getBaseNameUser(userName)));
} }
protected abstract boolean implementationAllowsGuestLogin(); protected abstract boolean implementationAllowsGuestLogin();
@ -409,6 +410,10 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
public Authentication execute() throws Throwable public Authentication execute() throws Throwable
{ {
try try
{
String name = AuthenticationUtil.runAs(new RunAsWork<String>()
{
public String doWork() throws Exception
{ {
if (personService.personExists(userName)) if (personService.personExists(userName))
{ {
@ -416,27 +421,29 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
if (userNode != null) if (userNode != null)
{ {
// Get the person name and use that as the current user to line up with permission checks // Get the person name and use that as the current user to line up with permission checks
String personName = (String) nodeService.getProperty(userNode, ContentModel.PROP_USERNAME); return (String) nodeService.getProperty(userNode, ContentModel.PROP_USERNAME);
return setCurrentUserImpl(personName);
} }
else else
{ {
// Set using the user name // Get user name
return setCurrentUserImpl(userName); return userName;
} }
} }
else else
{ {
// Set using the user name // Get user name
return setCurrentUserImpl(userName); return userName;
} }
} }
}, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantService.getUserDomain(userName)));
return setCurrentUserImpl(name);
}
catch (AuthenticationException ae) catch (AuthenticationException ae)
{ {
this.ae = ae; this.ae = ae;
return null; return null;
} }
} }
} }
} }