- add TenantService hooks to org.alfresco.repo.security services

- Authentication, Person, Permission, Authority
- add user/tenant-based logging via log4j NDC (nested diagnostic context)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6399 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2007-08-02 10:56:30 +00:00
parent 56a0b7e164
commit 65f660c26c
11 changed files with 141 additions and 22 deletions

View File

@@ -35,7 +35,9 @@ import net.sf.acegisecurity.context.security.SecureContextImpl;
import net.sf.acegisecurity.providers.UsernamePasswordAuthenticationToken;
import net.sf.acegisecurity.providers.dao.User;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.security.PermissionService;
import org.apache.log4j.NDC;
public abstract class AuthenticationUtil
{
@@ -151,8 +153,33 @@ public abstract class AuthenticationUtil
}
authentication.setAuthenticated(true);
sc.setAuthentication(authentication);
// Support for logging tenant domain / username (via log4j NDC)
String userName = SYSTEM_USER_NAME;
if (authentication.getPrincipal() instanceof UserDetails)
{
userName = ((UserDetails) authentication.getPrincipal()).getUsername();
}
logNDC(userName);
return authentication;
}
public static void logNDC(String userName)
{
NDC.remove();
int idx = userName.indexOf(TenantService.SEPARATOR);
if ((idx != -1) && (idx < (userName.length()-1)))
{
NDC.push("Tenant:"+userName.substring(idx+1)+" User:"+userName.substring(0,idx));
}
else
{
NDC.push("User:"+userName);
}
}
/**
* Get the current authentication context