mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.0 to HEAD
12178: Authenticate now required since introduction of public service usage in 3.0 test and authentication util changes. 12180: Build fix for updating person properties - set all existing to keep quota properties. 12187: MT - fix missing merge and fallout post authentication util changes 12199: Usage Service - fix unit test fallout post authentication util changes 12204: Authenticate now required since introduction of public service usage in 3.0 test and authentication util changes 12206: Authenticate now required since authentication util changes 12210: Module fixes - to use new authentication util api changes git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12515 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -334,6 +334,15 @@ public abstract class AuthenticationUtil
|
||||
public static boolean isRunAsUserTheSystemUser()
|
||||
{
|
||||
String runAsUser = getRunAsUser();
|
||||
if ((runAsUser != null) && isMtEnabled())
|
||||
{
|
||||
// get base username
|
||||
int idx = runAsUser.indexOf(TenantService.SEPARATOR);
|
||||
if (idx != -1)
|
||||
{
|
||||
runAsUser = runAsUser.substring(0, idx);
|
||||
}
|
||||
}
|
||||
return EqualsHelper.nullSafeEquals(runAsUser, AuthenticationUtil.SYSTEM_USER_NAME);
|
||||
}
|
||||
|
||||
@@ -411,79 +420,47 @@ public abstract class AuthenticationUtil
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((originalRunAsAuthentication != null) && (isMtEnabled()))
|
||||
{
|
||||
String originalRunAsUserName = getUserName(originalRunAsAuthentication);
|
||||
int idx = originalRunAsUserName.indexOf(TenantService.SEPARATOR);
|
||||
if ((idx != -1) && (idx < (originalRunAsUserName.length() - 1)))
|
||||
{
|
||||
if (uid.equals(AuthenticationUtil.getSystemUserName()))
|
||||
{
|
||||
uid = uid + TenantService.SEPARATOR + originalRunAsUserName.substring(idx + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
AuthenticationUtil.setRunAsUser(uid);
|
||||
}
|
||||
result = runAsWork.doWork();
|
||||
return result;
|
||||
}
|
||||
catch (Throwable exception)
|
||||
{
|
||||
// Re-throw the exception
|
||||
if (exception instanceof RuntimeException)
|
||||
{
|
||||
throw (RuntimeException) exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException("Error during run as.", exception);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (originalFullAuthentication == null)
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
else
|
||||
{
|
||||
AuthenticationUtil.setFullAuthentication(originalFullAuthentication);
|
||||
AuthenticationUtil.setRunAsAuthentication(originalRunAsAuthentication);
|
||||
}
|
||||
}
|
||||
// String effectiveUser = AuthenticationUtil.getCurrentEffectiveUserName();
|
||||
// String realUser = AuthenticationUtil.getCurrentRealUserName();
|
||||
//
|
||||
// R result = null;
|
||||
// try
|
||||
// {
|
||||
// if(realUser == null)
|
||||
// {
|
||||
// AuthenticationUtil.setCurrentRealUser(uid);
|
||||
// }
|
||||
// AuthenticationUtil.setCurrentEffectiveUser(uid);
|
||||
// result = runAsWork.doWork();
|
||||
// return result;
|
||||
// }
|
||||
// catch (Throwable exception)
|
||||
// {
|
||||
//
|
||||
// // Re-throw the exception
|
||||
// if (exception instanceof RuntimeException)
|
||||
// {
|
||||
// throw (RuntimeException) exception;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new RuntimeException("Error during run as.", exception);
|
||||
// }
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// if(realUser == null)
|
||||
// {
|
||||
// AuthenticationUtil.clearCurrentSecurityContext();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if(!realUser.equals(AuthenticationUtil.getCurrentRealUserName()))
|
||||
// {
|
||||
// AuthenticationUtil.setCurrentRealUser(realUser);
|
||||
// s_logger.warn("Resetting real user which has changed in RunAs block");
|
||||
// }
|
||||
// AuthenticationUtil.setCurrentEffectiveUser(effectiveUser);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
||||
catch (Throwable exception)
|
||||
{
|
||||
// Re-throw the exception
|
||||
if (exception instanceof RuntimeException)
|
||||
{
|
||||
throw (RuntimeException) exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException("Error during run as.", exception);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (originalFullAuthentication == null)
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
else
|
||||
{
|
||||
AuthenticationUtil.setFullAuthentication(originalFullAuthentication);
|
||||
AuthenticationUtil.setRunAsAuthentication(originalRunAsAuthentication);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ThreadLocal<Stack<Authentication>> threadLocalFullAuthenticationStack;
|
||||
|
Reference in New Issue
Block a user