mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
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:
parent
af56b1ebac
commit
2fece79cd2
@ -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();
|
||||||
@ -410,33 +411,39 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (personService.personExists(userName))
|
String name = AuthenticationUtil.runAs(new RunAsWork<String>()
|
||||||
{
|
{
|
||||||
NodeRef userNode = personService.getPerson(userName);
|
public String doWork() throws Exception
|
||||||
if (userNode != null)
|
|
||||||
{
|
{
|
||||||
// Get the person name and use that as the current user to line up with permission checks
|
if (personService.personExists(userName))
|
||||||
String personName = (String) nodeService.getProperty(userNode, ContentModel.PROP_USERNAME);
|
{
|
||||||
return setCurrentUserImpl(personName);
|
NodeRef userNode = personService.getPerson(userName);
|
||||||
|
if (userNode != null)
|
||||||
|
{
|
||||||
|
// Get the person name and use that as the current user to line up with permission checks
|
||||||
|
return (String) nodeService.getProperty(userNode, ContentModel.PROP_USERNAME);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Get user name
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Get user name
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
}, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantService.getUserDomain(userName)));
|
||||||
{
|
|
||||||
// Set using the user name
|
return setCurrentUserImpl(name);
|
||||||
return setCurrentUserImpl(userName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Set using the user name
|
|
||||||
return setCurrentUserImpl(userName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (AuthenticationException ae)
|
catch (AuthenticationException ae)
|
||||||
{
|
{
|
||||||
this.ae = ae;
|
this.ae = ae;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user