mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
MT - fix testCOCIandSearch (fallout from CHK-9517)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16688 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -416,6 +416,20 @@ public class AuthenticationUtil implements InitializingBean
|
|||||||
{
|
{
|
||||||
throw new IllegalStateException("AuthenticationUtil not yet initialised; default admin username not available");
|
throw new IllegalStateException("AuthenticationUtil not yet initialised; default admin username not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isMtEnabled())
|
||||||
|
{
|
||||||
|
String runAsUser = AuthenticationUtil.getRunAsUser();
|
||||||
|
if (runAsUser != null)
|
||||||
|
{
|
||||||
|
String[] parts = splitUserTenant(runAsUser);
|
||||||
|
if (parts.length == 2)
|
||||||
|
{
|
||||||
|
return defaultAdminUserName + TenantService.SEPARATOR + parts[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return defaultAdminUserName;
|
return defaultAdminUserName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,13 +590,13 @@ public class AuthenticationUtil implements InitializingBean
|
|||||||
public static void logNDC(String userName)
|
public static void logNDC(String userName)
|
||||||
{
|
{
|
||||||
NDC.remove();
|
NDC.remove();
|
||||||
|
|
||||||
if (isMtEnabled())
|
if (isMtEnabled())
|
||||||
{
|
{
|
||||||
int idx = userName.indexOf(TenantService.SEPARATOR);
|
String[] parts = splitUserTenant(userName);
|
||||||
if ((idx != -1) && (idx < (userName.length() - 1)))
|
if (parts.length == 2)
|
||||||
{
|
{
|
||||||
NDC.push("Tenant:" + userName.substring(idx + 1) + " User:" + userName.substring(0, idx));
|
NDC.push("Tenant:" + parts[1] + " User:" + parts[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -594,5 +608,9 @@ public class AuthenticationUtil implements InitializingBean
|
|||||||
NDC.push("User:" + userName);
|
NDC.push("User:" + userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String[] splitUserTenant(String userName)
|
||||||
|
{
|
||||||
|
return userName.split(TenantService.SEPARATOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -174,13 +174,30 @@ public class AuthorityServiceImpl implements AuthorityService, InitializingBean
|
|||||||
|
|
||||||
// Check named admin users
|
// Check named admin users
|
||||||
Set<String> adminUsers = this.authenticationService.getDefaultAdministratorUserNames();
|
Set<String> adminUsers = this.authenticationService.getDefaultAdministratorUserNames();
|
||||||
|
|
||||||
// note: for multi-tenancy, this currently relies on a naming convention which assumes that all tenant admins will
|
|
||||||
// have the same base name as the default non-tenant specific admin. Typically "admin" is the default required admin user,
|
|
||||||
// although, if for example "bob" is also listed as an admin then all tenant-specific bob's will also have admin authority
|
|
||||||
String currentUserBaseName = tenantService.getBaseNameUser(currentUserName);
|
String currentUserBaseName = tenantService.getBaseNameUser(currentUserName);
|
||||||
boolean isAdminUser = (adminUsers.contains(currentUserName) || adminUsers.contains(currentUserBaseName));
|
|
||||||
|
boolean isAdminUser = false;
|
||||||
|
if (tenantService.isEnabled())
|
||||||
|
{
|
||||||
|
// note: for multi-tenancy, this currently relies on a naming convention which assumes that all tenant admins will
|
||||||
|
// have the same base name as the default non-tenant specific admin. Typically "admin" is the default required admin user,
|
||||||
|
// although, if for example "bob" is also listed as an admin then all tenant-specific bob's will also have admin authority
|
||||||
|
|
||||||
|
for (String adminUser : adminUsers)
|
||||||
|
{
|
||||||
|
if (adminUser.equals(currentUserName) || tenantService.getBaseNameUser(adminUser).equals(currentUserBaseName))
|
||||||
|
{
|
||||||
|
isAdminUser = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isAdminUser = adminUsers.contains(currentUserName);
|
||||||
|
}
|
||||||
|
|
||||||
// Check named admin groups
|
// Check named admin groups
|
||||||
if (!isAdminUser && !adminGroups.isEmpty())
|
if (!isAdminUser && !adminGroups.isEmpty())
|
||||||
{
|
{
|
||||||
|
@@ -1242,7 +1242,7 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
{
|
{
|
||||||
return baseAdminUsername;
|
return baseAdminUsername;
|
||||||
}
|
}
|
||||||
return AuthenticationUtil.getAdminUserName();
|
return getBaseNameUser(AuthenticationUtil.getAdminUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSystemUser(String tenantDomain)
|
private String getSystemUser(String tenantDomain)
|
||||||
|
Reference in New Issue
Block a user