mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixes for:
- ALF-1692 "Error message appears when trying to log in with incorrect tenant-username" - ALF-3489 "Inconsistency in how Alfresco handles case sensitivity in tenant creation and tenant login" git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29547 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -41,6 +41,7 @@ import org.alfresco.repo.dictionary.DictionaryComponent;
|
|||||||
import org.alfresco.repo.importer.ImporterBootstrap;
|
import org.alfresco.repo.importer.ImporterBootstrap;
|
||||||
import org.alfresco.repo.node.db.DbNodeServiceImpl;
|
import org.alfresco.repo.node.db.DbNodeServiceImpl;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationContext;
|
import org.alfresco.repo.security.authentication.AuthenticationContext;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.repo.site.SiteAVMBootstrap;
|
import org.alfresco.repo.site.SiteAVMBootstrap;
|
||||||
@@ -71,7 +72,6 @@ import org.springframework.extensions.surf.util.ParameterCheck;
|
|||||||
* MT Admin Service Implementation.
|
* MT Admin Service Implementation.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationContextAware, InitializingBean
|
public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationContextAware, InitializingBean
|
||||||
{
|
{
|
||||||
// Logger
|
// Logger
|
||||||
@@ -343,10 +343,12 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
/**
|
/**
|
||||||
* @see TenantAdminService.createTenant()
|
* @see TenantAdminService.createTenant()
|
||||||
*/
|
*/
|
||||||
public void createTenant(final String tenantDomain, final char[] tenantAdminRawPassword, String rootContentStoreDir)
|
public void createTenant(String tenantDomain, final char[] tenantAdminRawPassword, String rootContentStoreDir)
|
||||||
{
|
{
|
||||||
ParameterCheck.mandatory("tenantAdminRawPassword", tenantAdminRawPassword);
|
ParameterCheck.mandatory("tenantAdminRawPassword", tenantAdminRawPassword);
|
||||||
|
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
|
|
||||||
initTenant(tenantDomain, rootContentStoreDir);
|
initTenant(tenantDomain, rootContentStoreDir);
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -406,13 +408,15 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
/**
|
/**
|
||||||
* Export tenant - equivalent to the tenant admin running a 'complete repo' export from the Web Client Admin
|
* Export tenant - equivalent to the tenant admin running a 'complete repo' export from the Web Client Admin
|
||||||
*/
|
*/
|
||||||
public void exportTenant(final String tenantDomain, final File directoryDestination)
|
public void exportTenant(String tenantDomain, final File directoryDestination)
|
||||||
{
|
{
|
||||||
|
final String lowerTenantDomain = getTenantDomain(tenantDomain);
|
||||||
|
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||||
{
|
{
|
||||||
public Object doWork()
|
public Object doWork()
|
||||||
{
|
{
|
||||||
repositoryExporterService.export(directoryDestination, tenantDomain);
|
repositoryExporterService.export(directoryDestination, lowerTenantDomain);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, getSystemUser(tenantDomain));
|
}, getSystemUser(tenantDomain));
|
||||||
@@ -423,8 +427,10 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
/**
|
/**
|
||||||
* Create tenant by restoring from a complete repository export. This is equivalent to a bootstrap import using restore-context.xml.
|
* Create tenant by restoring from a complete repository export. This is equivalent to a bootstrap import using restore-context.xml.
|
||||||
*/
|
*/
|
||||||
public void importTenant(final String tenantDomain, final File directorySource, String rootContentStoreDir)
|
public void importTenant(String tenantDomain, final File directorySource, String rootContentStoreDir)
|
||||||
{
|
{
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
|
|
||||||
initTenant(tenantDomain, rootContentStoreDir);
|
initTenant(tenantDomain, rootContentStoreDir);
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -472,6 +478,8 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
// Check that all the passed values are not null
|
// Check that all the passed values are not null
|
||||||
ParameterCheck.mandatory("tenantDomain", tenantDomain);
|
ParameterCheck.mandatory("tenantDomain", tenantDomain);
|
||||||
|
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
|
|
||||||
return (getTenantAttributes(tenantDomain) != null);
|
return (getTenantAttributes(tenantDomain) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,9 +518,11 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
|
|
||||||
public void enableTenant(String tenantDomain)
|
public void enableTenant(String tenantDomain)
|
||||||
{
|
{
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
|
|
||||||
if (! existsTenant(tenantDomain))
|
if (! existsTenant(tenantDomain))
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Tenant does not exist: " + tenantDomain);
|
throw new AuthenticationException("Tenant does not exist: " + tenantDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEnabledTenant(tenantDomain))
|
if (isEnabledTenant(tenantDomain))
|
||||||
@@ -553,9 +563,11 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
|
|
||||||
public void disableTenant(String tenantDomain)
|
public void disableTenant(String tenantDomain)
|
||||||
{
|
{
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
|
|
||||||
if (! existsTenant(tenantDomain))
|
if (! existsTenant(tenantDomain))
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Tenant does not exist: " + tenantDomain);
|
throw new AuthenticationException("Tenant does not exist: " + tenantDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isEnabledTenant(tenantDomain))
|
if (! isEnabledTenant(tenantDomain))
|
||||||
@@ -567,7 +579,9 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void disableTenant(String tenantDomain, boolean notifyTenantDeployers)
|
public void disableTenant(String tenantDomain, boolean notifyTenantDeployers)
|
||||||
{
|
{
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
|
|
||||||
if (notifyTenantDeployers)
|
if (notifyTenantDeployers)
|
||||||
{
|
{
|
||||||
// notify listeners that tenant has been disabled
|
// notify listeners that tenant has been disabled
|
||||||
@@ -597,6 +611,8 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
// Check that all the passed values are not null
|
// Check that all the passed values are not null
|
||||||
ParameterCheck.mandatory("tenantDomain", tenantDomain);
|
ParameterCheck.mandatory("tenantDomain", tenantDomain);
|
||||||
|
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
|
|
||||||
Tenant tenant = getTenantAttributes(tenantDomain);
|
Tenant tenant = getTenantAttributes(tenantDomain);
|
||||||
if (tenant != null)
|
if (tenant != null)
|
||||||
{
|
{
|
||||||
@@ -629,9 +645,10 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
|
|
||||||
public Tenant getTenant(String tenantDomain)
|
public Tenant getTenant(String tenantDomain)
|
||||||
{
|
{
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
if (! existsTenant(tenantDomain))
|
if (! existsTenant(tenantDomain))
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Tenant does not exist: " + tenantDomain);
|
throw new AuthenticationException("Tenant does not exist: " + tenantDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Tenant(tenantDomain, isEnabledTenant(tenantDomain), getRootContentStoreDir(tenantDomain));
|
return new Tenant(tenantDomain, isEnabledTenant(tenantDomain), getRootContentStoreDir(tenantDomain));
|
||||||
@@ -642,9 +659,11 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
*/
|
*/
|
||||||
public void deleteTenant(String tenantDomain)
|
public void deleteTenant(String tenantDomain)
|
||||||
{
|
{
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
|
|
||||||
if (! existsTenant(tenantDomain))
|
if (! existsTenant(tenantDomain))
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Tenant does not exist: " + tenantDomain);
|
throw new AuthenticationException("Tenant does not exist: " + tenantDomain);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1151,7 +1170,7 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("No such tenant " + tenantDomain);
|
throw new AuthenticationException("No such tenant " + tenantDomain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1240,11 +1259,13 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
|
|
||||||
public String getDomainUser(String baseUsername, String tenantDomain)
|
public String getDomainUser(String baseUsername, String tenantDomain)
|
||||||
{
|
{
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
return tenantService.getDomainUser(baseUsername, tenantDomain);
|
return tenantService.getDomainUser(baseUsername, tenantDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDomain(String name)
|
public String getDomain(String name)
|
||||||
{
|
{
|
||||||
|
name = getTenantDomain(name);
|
||||||
return tenantService.getDomain(name);
|
return tenantService.getDomain(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1275,4 +1296,10 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
|
|||||||
{
|
{
|
||||||
return authenticationContext.getGuestUserName(tenantDomain);
|
return authenticationContext.getGuestUserName(tenantDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getTenantDomain(String tenantDomain)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("tenantDomain", tenantDomain);
|
||||||
|
return tenantDomain.toLowerCase(I18NUtil.getLocale());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
|||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -564,8 +565,7 @@ public class MultiTServiceImpl implements TenantService
|
|||||||
int idx = username.lastIndexOf(SEPARATOR);
|
int idx = username.lastIndexOf(SEPARATOR);
|
||||||
if ((idx > 0) && (idx < (username.length()-1)))
|
if ((idx > 0) && (idx < (username.length()-1)))
|
||||||
{
|
{
|
||||||
String tenantDomain = username.substring(idx+1);
|
String tenantDomain = getTenantDomain(username.substring(idx+1));
|
||||||
|
|
||||||
checkTenantEnabled(tenantDomain);
|
checkTenantEnabled(tenantDomain);
|
||||||
|
|
||||||
return tenantDomain;
|
return tenantDomain;
|
||||||
@@ -592,6 +592,7 @@ public class MultiTServiceImpl implements TenantService
|
|||||||
// Check that all the passed values are not null
|
// Check that all the passed values are not null
|
||||||
ParameterCheck.mandatory("name", name);
|
ParameterCheck.mandatory("name", name);
|
||||||
|
|
||||||
|
name = getTenantDomain(name);
|
||||||
String tenantDomain = getCurrentUserDomain();
|
String tenantDomain = getCurrentUserDomain();
|
||||||
|
|
||||||
String nameDomain = DEFAULT_DOMAIN;
|
String nameDomain = DEFAULT_DOMAIN;
|
||||||
@@ -634,7 +635,8 @@ public class MultiTServiceImpl implements TenantService
|
|||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Invalid tenant domain: " + tenantDomain);
|
throw new AlfrescoRuntimeException("Invalid tenant domain: " + tenantDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
return baseUsername + SEPARATOR + tenantDomain;
|
return baseUsername + SEPARATOR + tenantDomain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -653,6 +655,7 @@ public class MultiTServiceImpl implements TenantService
|
|||||||
*/
|
*/
|
||||||
public Tenant getTenant(String tenantDomain)
|
public Tenant getTenant(String tenantDomain)
|
||||||
{
|
{
|
||||||
|
tenantDomain = getTenantDomain(tenantDomain);
|
||||||
Tenant tenant = tenantsCache.get(tenantDomain);
|
Tenant tenant = tenantsCache.get(tenantDomain);
|
||||||
if (tenant == null)
|
if (tenant == null)
|
||||||
{
|
{
|
||||||
@@ -708,4 +711,10 @@ public class MultiTServiceImpl implements TenantService
|
|||||||
tenantsCache.remove(tenantDomain);
|
tenantsCache.remove(tenantDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getTenantDomain(String tenantDomain)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("tenantDomain", tenantDomain);
|
||||||
|
return tenantDomain.toLowerCase(I18NUtil.getLocale());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user