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:
Steven Glover
2011-08-04 12:35:45 +00:00
parent 7d30b7b050
commit 5857c90025
2 changed files with 51 additions and 15 deletions

View File

@@ -41,6 +41,7 @@ import org.alfresco.repo.dictionary.DictionaryComponent;
import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.repo.node.db.DbNodeServiceImpl;
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.RunAsWork;
import org.alfresco.repo.site.SiteAVMBootstrap;
@@ -71,7 +72,6 @@ import org.springframework.extensions.surf.util.ParameterCheck;
* MT Admin Service Implementation.
*
*/
public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationContextAware, InitializingBean
{
// Logger
@@ -343,10 +343,12 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
/**
* @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);
tenantDomain = getTenantDomain(tenantDomain);
initTenant(tenantDomain, rootContentStoreDir);
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
*/
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>()
{
public Object doWork()
{
repositoryExporterService.export(directoryDestination, tenantDomain);
repositoryExporterService.export(directoryDestination, lowerTenantDomain);
return null;
}
}, 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.
*/
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);
try
@@ -472,6 +478,8 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
// Check that all the passed values are not null
ParameterCheck.mandatory("tenantDomain", tenantDomain);
tenantDomain = getTenantDomain(tenantDomain);
return (getTenantAttributes(tenantDomain) != null);
}
@@ -510,9 +518,11 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
public void enableTenant(String tenantDomain)
{
tenantDomain = getTenantDomain(tenantDomain);
if (! existsTenant(tenantDomain))
{
throw new AlfrescoRuntimeException("Tenant does not exist: " + tenantDomain);
throw new AuthenticationException("Tenant does not exist: " + tenantDomain);
}
if (isEnabledTenant(tenantDomain))
@@ -553,9 +563,11 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
public void disableTenant(String tenantDomain)
{
tenantDomain = getTenantDomain(tenantDomain);
if (! existsTenant(tenantDomain))
{
throw new AlfrescoRuntimeException("Tenant does not exist: " + tenantDomain);
throw new AuthenticationException("Tenant does not exist: " + tenantDomain);
}
if (! isEnabledTenant(tenantDomain))
@@ -568,6 +580,8 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
public void disableTenant(String tenantDomain, boolean notifyTenantDeployers)
{
tenantDomain = getTenantDomain(tenantDomain);
if (notifyTenantDeployers)
{
// 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
ParameterCheck.mandatory("tenantDomain", tenantDomain);
tenantDomain = getTenantDomain(tenantDomain);
Tenant tenant = getTenantAttributes(tenantDomain);
if (tenant != null)
{
@@ -629,9 +645,10 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
public Tenant getTenant(String tenantDomain)
{
tenantDomain = getTenantDomain(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));
@@ -642,9 +659,11 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
*/
public void deleteTenant(String tenantDomain)
{
tenantDomain = getTenantDomain(tenantDomain);
if (! existsTenant(tenantDomain))
{
throw new AlfrescoRuntimeException("Tenant does not exist: " + tenantDomain);
throw new AuthenticationException("Tenant does not exist: " + tenantDomain);
}
else
{
@@ -1151,7 +1170,7 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
}
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)
{
tenantDomain = getTenantDomain(tenantDomain);
return tenantService.getDomainUser(baseUsername, tenantDomain);
}
public String getDomain(String name)
{
name = getTenantDomain(name);
return tenantService.getDomain(name);
}
@@ -1275,4 +1296,10 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
{
return authenticationContext.getGuestUserName(tenantDomain);
}
protected String getTenantDomain(String tenantDomain)
{
ParameterCheck.mandatory("tenantDomain", tenantDomain);
return tenantDomain.toLowerCase(I18NUtil.getLocale());
}
}

View File

@@ -31,6 +31,7 @@ import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.springframework.extensions.surf.util.I18NUtil;
import org.springframework.extensions.surf.util.ParameterCheck;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -564,8 +565,7 @@ public class MultiTServiceImpl implements TenantService
int idx = username.lastIndexOf(SEPARATOR);
if ((idx > 0) && (idx < (username.length()-1)))
{
String tenantDomain = username.substring(idx+1);
String tenantDomain = getTenantDomain(username.substring(idx+1));
checkTenantEnabled(tenantDomain);
return tenantDomain;
@@ -592,6 +592,7 @@ public class MultiTServiceImpl implements TenantService
// Check that all the passed values are not null
ParameterCheck.mandatory("name", name);
name = getTenantDomain(name);
String tenantDomain = getCurrentUserDomain();
String nameDomain = DEFAULT_DOMAIN;
@@ -635,6 +636,7 @@ public class MultiTServiceImpl implements TenantService
throw new AlfrescoRuntimeException("Invalid tenant domain: " + tenantDomain);
}
tenantDomain = getTenantDomain(tenantDomain);
return baseUsername + SEPARATOR + tenantDomain;
}
}
@@ -653,6 +655,7 @@ public class MultiTServiceImpl implements TenantService
*/
public Tenant getTenant(String tenantDomain)
{
tenantDomain = getTenantDomain(tenantDomain);
Tenant tenant = tenantsCache.get(tenantDomain);
if (tenant == null)
{
@@ -708,4 +711,10 @@ public class MultiTServiceImpl implements TenantService
tenantsCache.remove(tenantDomain);
}
protected String getTenantDomain(String tenantDomain)
{
ParameterCheck.mandatory("tenantDomain", tenantDomain);
return tenantDomain.toLowerCase(I18NUtil.getLocale());
}
}