Java Code Examples for org.alfresco.repo.tenant.TenantService#SEPARATOR

The following examples show how to use org.alfresco.repo.tenant.TenantService#SEPARATOR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuthenticationUtil.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get the name of the default admin user (the admin user created during bootstrap)
 * 
 * @return admin user name
 */
public static String getAdminUserName()
{
    if (!initialized)
    {
        throw new IllegalStateException("AuthenticationUtil not yet initialised; default admin username not available");
    }
    
    if (isMtEnabled())
    {
        String runAsUser = AuthenticationUtil.getRunAsUser();
        if (runAsUser != null)
        {
            String tenantDomain = AuthenticationUtil.getUserTenant(runAsUser).getSecond();
            
            if (! TenantService.DEFAULT_DOMAIN.equals(tenantDomain))
            {
                return defaultAdminUserName + TenantService.SEPARATOR + tenantDomain;
            }
        }
    }
    
    return defaultAdminUserName;
}
 
Example 2
Source File: LocalFeedTaskProcessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected String getTenantName(String name, String tenantDomain)
{
    if (name == null)
    {
        return name;
    }
    
    String nameDomain = getTenantDomain(name);
    if (nameDomain.equals(TenantService.DEFAULT_DOMAIN))
    {
        if (! TenantService.DEFAULT_DOMAIN.equals(tenantDomain))
        {
            // no domain, so add it as a prefix (between two domain separators)
            name = TenantService.SEPARATOR + tenantDomain + TenantService.SEPARATOR + name;
        }
    }
    else
    {
        if (! tenantDomain.equals(nameDomain))
        {
            throw new AlfrescoRuntimeException("domain mismatch: expected = " + tenantDomain + ", actual = " + nameDomain);
        }
    }
    
    return name;
}
 
Example 3
Source File: AuthenticationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Test for ACE-4909
 */
public void testCheckUserDisabledTenant()
{
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
    String domainName = "ace4909.domain";
    String userName = "ace4909" + TenantService.SEPARATOR + domainName;
    Map<QName, Serializable> props = createPersonProperties(userName);
    NodeRef userNodeRef = personService.createPerson(props);
    assertNotNull(userNodeRef);
    authenticationService.createAuthentication(userName, "passwd".toCharArray());
    tenantAdminService.createTenant(domainName, TENANT_ADMIN_PW.toCharArray(), null);
    tenantAdminService.disableTenant(domainName);
    assertTrue("The user should exist", dao.userExists(userName));
}
 
Example 4
Source File: AuthenticationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Test for ACE-4909
 */
public void testCheckUserDeletedTenant()
{
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
    String domainName = "ace4909.domain";
    String userName = "ace4909" + TenantService.SEPARATOR + domainName;
    Map<QName, Serializable> props = createPersonProperties(userName);
    NodeRef userNodeRef = personService.createPerson(props);
    assertNotNull(userNodeRef);
    authenticationService.createAuthentication(userName, "passwd".toCharArray());
    tenantAdminService.createTenant(domainName, TENANT_ADMIN_PW.toCharArray(), null);
    tenantAdminService.deleteTenant(domainName);
    assertTrue("The user should exist", dao.userExists(userName));
}