diff --git a/config/alfresco/authentication-services-context.xml b/config/alfresco/authentication-services-context.xml
index 76eb6276c6..8a45100508 100644
--- a/config/alfresco/authentication-services-context.xml
+++ b/config/alfresco/authentication-services-context.xml
@@ -531,4 +531,11 @@
8
+
+
+
+ ${alfresco_user_store.adminusername}
+ ${alfresco_user_store.adminpassword}
+
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/cmis/property/CMISPropertyServiceTest.java b/source/java/org/alfresco/cmis/property/CMISPropertyServiceTest.java
index de9ad4f6bb..11d4a762c8 100644
--- a/source/java/org/alfresco/cmis/property/CMISPropertyServiceTest.java
+++ b/source/java/org/alfresco/cmis/property/CMISPropertyServiceTest.java
@@ -47,16 +47,16 @@ public class CMISPropertyServiceTest extends BaseCMISTest
{
NodeRef folder = fileFolderService.create(rootNodeRef, "BaseFolder", ContentModel.TYPE_FOLDER).getNodeRef();
Map properties = cmisPropertyService.getProperties(folder);
- assertEquals(properties.get(CMISMapping.PROP_OBJECT_ID), folder.toString());
+ assertEquals(folder.toString(), properties.get(CMISMapping.PROP_OBJECT_ID));
assertNull(properties.get(CMISMapping.PROP_URI));
- assertEquals(properties.get(CMISMapping.PROP_OBJECT_TYPE_ID), CMISMapping.FOLDER_TYPE_ID.getTypeId());
- assertEquals(properties.get(CMISMapping.PROP_CREATED_BY), authenticationComponent.getCurrentUserName());
+ assertEquals(CMISMapping.FOLDER_TYPE_ID.getTypeId(), properties.get(CMISMapping.PROP_OBJECT_TYPE_ID));
+ assertEquals(authenticationComponent.getCurrentUserName(), properties.get(CMISMapping.PROP_CREATED_BY));
assertNotNull(properties.get(CMISMapping.PROP_CREATION_DATE));
- assertEquals(properties.get(CMISMapping.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName());
+ assertEquals(authenticationComponent.getCurrentUserName(), properties.get(CMISMapping.PROP_LAST_MODIFIED_BY));
assertNotNull(properties.get(CMISMapping.PROP_LAST_MODIFICATION_DATE));
assertNull(properties.get(CMISMapping.PROP_CHANGE_TOKEN));
- assertEquals(properties.get(CMISMapping.PROP_NAME), "BaseFolder");
+ assertEquals("BaseFolder", properties.get(CMISMapping.PROP_NAME));
assertNull(properties.get(CMISMapping.PROP_IS_IMMUTABLE));
assertNull(properties.get(CMISMapping.PROP_IS_LATEST_VERSION));
@@ -74,7 +74,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest
assertNull(properties.get(CMISMapping.PROP_CONTENT_STREAM_FILENAME));
assertNull(properties.get(CMISMapping.PROP_CONTENT_STREAM_URI));
- assertEquals(properties.get(CMISMapping.PROP_PARENT_ID), rootNodeRef.toString());
+ assertEquals(rootNodeRef.toString(), properties.get(CMISMapping.PROP_PARENT_ID));
assertNull(properties.get(CMISMapping.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS));
}
@@ -109,7 +109,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest
assertEquals(properties.get(CMISMapping.PROP_CONTENT_STREAM_LENGTH), 0L);
assertEquals(properties.get(CMISMapping.PROP_CONTENT_STREAM_MIME_TYPE), "application/octet-stream");
assertEquals(properties.get(CMISMapping.PROP_CONTENT_STREAM_FILENAME), "BaseContent");
- assertEquals(properties.get(CMISMapping.PROP_CONTENT_STREAM_URI), null);
+ assertEquals(null, properties.get(CMISMapping.PROP_CONTENT_STREAM_URI));
assertNull(properties.get(CMISMapping.PROP_PARENT_ID));
assertNull(properties.get(CMISMapping.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS));
diff --git a/source/java/org/alfresco/jcr/item/ItemTest.java b/source/java/org/alfresco/jcr/item/ItemTest.java
index a5083c82f5..d4c7d4f375 100644
--- a/source/java/org/alfresco/jcr/item/ItemTest.java
+++ b/source/java/org/alfresco/jcr/item/ItemTest.java
@@ -70,7 +70,7 @@ public class ItemTest extends BaseJCRTest
public void test_ALFCOM_1655() throws RepositoryException
{
- SimpleCredentials user = new SimpleCredentials("admin", "admin".toCharArray());
+ SimpleCredentials user = new SimpleCredentials(getAdminUserName(), "admin".toCharArray());
session = repository.login(user, getWorkspace());
@@ -143,7 +143,7 @@ public class ItemTest extends BaseJCRTest
public void test_ALFCOM_1507() throws RepositoryException
{
- SimpleCredentials user = new SimpleCredentials("admin", "admin".toCharArray());
+ SimpleCredentials user = new SimpleCredentials(getAdminUserName(), "admin".toCharArray());
session = repository.login(user, "SpacesStore");
@@ -233,7 +233,7 @@ public class ItemTest extends BaseJCRTest
public void test_JAWS_191() throws RepositoryException
{
- SimpleCredentials user = new SimpleCredentials("admin", "admin".toCharArray());
+ SimpleCredentials user = new SimpleCredentials(getAdminUserName(), "admin".toCharArray());
session = repository.login(user, "SpacesStore");
diff --git a/source/java/org/alfresco/jcr/test/BaseJCRTest.java b/source/java/org/alfresco/jcr/test/BaseJCRTest.java
index 3058612139..de5c75f111 100644
--- a/source/java/org/alfresco/jcr/test/BaseJCRTest.java
+++ b/source/java/org/alfresco/jcr/test/BaseJCRTest.java
@@ -30,6 +30,7 @@ import junit.framework.TestCase;
import org.alfresco.jcr.repository.RepositoryFactory;
import org.alfresco.jcr.repository.RepositoryImpl;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.repository.StoreRef;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -44,6 +45,7 @@ public class BaseJCRTest extends TestCase
private RepositoryImpl repositoryImpl;
protected Repository repository;
protected StoreRef storeRef;
+ protected String adminUserName;
protected static ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:org/alfresco/jcr/test/test-context.xml");
@@ -51,6 +53,11 @@ public class BaseJCRTest extends TestCase
{
return storeRef.getIdentifier();
}
+
+ protected String getAdminUserName()
+ {
+ return adminUserName;
+ }
@Override
protected void setUp() throws Exception
@@ -60,6 +67,7 @@ public class BaseJCRTest extends TestCase
repositoryImpl = (RepositoryImpl)applicationContext.getBean(RepositoryFactory.REPOSITORY_BEAN);
repositoryImpl.setDefaultWorkspace(storeRef.getIdentifier());
repository = repositoryImpl;
+ adminUserName = AuthenticationUtil.getAdminUserName();
}
}
diff --git a/source/java/org/alfresco/repo/activities/ActivityServiceImplTest.java b/source/java/org/alfresco/repo/activities/ActivityServiceImplTest.java
index f6945dda4c..3b75d11e7f 100644
--- a/source/java/org/alfresco/repo/activities/ActivityServiceImplTest.java
+++ b/source/java/org/alfresco/repo/activities/ActivityServiceImplTest.java
@@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.List;
import org.alfresco.repo.jscript.ClasspathScriptLocation;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.activities.ActivityService;
import org.alfresco.service.cmr.activities.FeedControl;
import org.alfresco.service.cmr.repository.ScriptLocation;
@@ -46,7 +47,6 @@ public class ActivityServiceImplTest extends BaseSpringTest
private ScriptService scriptService;
private AuthenticationService authenticationService;
- private static final String ADMIN_UN = "admin";
private static final String ADMIN_PW = "admin";
private static final String USER_UN = "bob";
@@ -62,7 +62,7 @@ public class ActivityServiceImplTest extends BaseSpringTest
this.authenticationService = (AuthenticationService)applicationContext.getBean("authenticationService");
- authenticationService.authenticate(ADMIN_UN, ADMIN_PW.toCharArray());
+ authenticationService.authenticate(AuthenticationUtil.getAdminUserName(), ADMIN_PW.toCharArray());
}
protected void onTearDownInTransaction() throws Exception
diff --git a/source/java/org/alfresco/repo/admin/BaseInterpreter.java b/source/java/org/alfresco/repo/admin/BaseInterpreter.java
index 6eda55a803..09e80689ae 100755
--- a/source/java/org/alfresco/repo/admin/BaseInterpreter.java
+++ b/source/java/org/alfresco/repo/admin/BaseInterpreter.java
@@ -57,7 +57,6 @@ public abstract class BaseInterpreter extends AbstractLifecycleBean
* Current context
*/
private String username = null;
- protected final static String DEFAULT_ADMIN = "admin";
/**
* Last command issued
@@ -75,7 +74,7 @@ public abstract class BaseInterpreter extends AbstractLifecycleBean
{
BaseInterpreter console = getConsoleBean(context, beanName);
- console.username = DEFAULT_ADMIN;
+ console.username = AuthenticationUtil.getAdminUserName();
console.rep();
System.exit(0);
}
diff --git a/source/java/org/alfresco/repo/audit/AuditServiceTest.java b/source/java/org/alfresco/repo/audit/AuditServiceTest.java
index 7d86d1b9bf..39dcea826d 100644
--- a/source/java/org/alfresco/repo/audit/AuditServiceTest.java
+++ b/source/java/org/alfresco/repo/audit/AuditServiceTest.java
@@ -153,11 +153,11 @@ public class AuditServiceTest extends BaseSpringTest
}
authenticationService.createAuthentication("lemur", "lemur".toCharArray());
- if (authenticationDAO.userExists("admin"))
+ if (authenticationDAO.userExists(AuthenticationUtil.getAdminUserName()))
{
- authenticationService.deleteAuthentication("admin");
+ authenticationService.deleteAuthentication(AuthenticationUtil.getAdminUserName());
}
- authenticationService.createAuthentication("admin", "admin".toCharArray());
+ authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
authenticationComponent.clearCurrentSecurityContext();
}
diff --git a/source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleaner.java b/source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleaner.java
index 1224d0e0c8..e00dd3b459 100644
--- a/source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleaner.java
+++ b/source/java/org/alfresco/repo/avm/AVMDeploymentAttemptCleaner.java
@@ -49,7 +49,6 @@ import org.apache.commons.logging.LogFactory;
public class AVMDeploymentAttemptCleaner
{
// defaults in case these properties are not configured in Spring
- protected String adminUserName = "admin";
protected long maxAge = 180L;
protected NodeService nodeService;
@@ -63,11 +62,6 @@ public class AVMDeploymentAttemptCleaner
{
}
- public void setAdminUserName(String adminUserName)
- {
- this.adminUserName = adminUserName;
- }
-
public void setMaxAge(long maxAge)
{
this.maxAge = new Long(maxAge);
@@ -117,7 +111,7 @@ public class AVMDeploymentAttemptCleaner
};
// perform the work as the system user
- AuthenticationUtil.runAs(authorisedWork, this.adminUserName);
+ AuthenticationUtil.runAs(authorisedWork, AuthenticationUtil.getAdminUserName());
}
/**
diff --git a/source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java b/source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java
index 7b989fd175..6b61d5e540 100644
--- a/source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java
+++ b/source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java
@@ -80,7 +80,6 @@ import org.apache.commons.logging.LogFactory;
public class AVMExpiredContentProcessor
{
// defaults in case these properties are not configured in Spring
- protected String adminUserName = "admin";
protected String workflowName = "jbpm$wcmwf:changerequest";
protected List workflowStores;
@@ -109,7 +108,7 @@ public class AVMExpiredContentProcessor
public void setAdminUserName(String adminUserName)
{
- this.adminUserName = adminUserName;
+ // NOTE: ignore, just for backwards compatible Spring config
}
public void setWorkflowName(String workflowName)
@@ -201,7 +200,7 @@ public class AVMExpiredContentProcessor
};
// perform the work as the system user
- AuthenticationUtil.runAs(authorisedWork, this.adminUserName);
+ AuthenticationUtil.runAs(authorisedWork, AuthenticationUtil.getAdminRoleName());
// now we know everything worked ok, let the virtualisation server
// know about all the new workflow sandboxes created (just the main stores)
diff --git a/source/java/org/alfresco/repo/avm/AVMServiceLocalTest.java b/source/java/org/alfresco/repo/avm/AVMServiceLocalTest.java
index 6dafae1191..4be7c0f210 100644
--- a/source/java/org/alfresco/repo/avm/AVMServiceLocalTest.java
+++ b/source/java/org/alfresco/repo/avm/AVMServiceLocalTest.java
@@ -36,6 +36,7 @@ import junit.framework.TestCase;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.util.RemoteBulkLoader;
import org.alfresco.repo.domain.PropertyValue;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avmsync.AVMDifference;
@@ -88,7 +89,7 @@ public class AVMServiceLocalTest extends TestCase
excluder = (NameMatcher) fContext.getBean("globalPathExcluder");
AuthenticationService authService = (AuthenticationService)fContext.getBean("AuthenticationService");
- authService.authenticate("admin", "admin".toCharArray());
+ authService.authenticate(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
}
if (fService.getStore("main") == null)
diff --git a/source/java/org/alfresco/repo/avm/AVMServicePermissionsTest.java b/source/java/org/alfresco/repo/avm/AVMServicePermissionsTest.java
index 3fa4c4681f..6b12bae256 100644
--- a/source/java/org/alfresco/repo/avm/AVMServicePermissionsTest.java
+++ b/source/java/org/alfresco/repo/avm/AVMServicePermissionsTest.java
@@ -182,11 +182,11 @@ public class AVMServicePermissionsTest extends TestCase
}
authenticationService.createAuthentication("lemur", "lemur".toCharArray());
- if (authenticationDAO.userExists("admin"))
+ if (authenticationDAO.userExists(AuthenticationUtil.getAdminUserName()))
{
- authenticationService.deleteAuthentication("admin");
+ authenticationService.deleteAuthentication(AuthenticationUtil.getAdminUserName());
}
- authenticationService.createAuthentication("admin", "admin".toCharArray());
+ authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
if (authenticationDAO.userExists("manager"))
{
@@ -401,7 +401,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testStoreAcls() throws Exception
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -415,8 +415,8 @@ public class AVMServicePermissionsTest extends TestCase
assertTrue(checkHasPermission("andy", nodeRef, PermissionService.ALL_PERMISSIONS, true));
assertTrue(checkPermission("lemur", storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
assertTrue(checkHasPermission("lemur", nodeRef, PermissionService.ALL_PERMISSIONS, true));
- assertTrue(checkPermission("admin", storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
- assertTrue(checkHasPermission("admin", nodeRef, PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkHasPermission(AuthenticationUtil.getAdminUserName(), nodeRef, PermissionService.ALL_PERMISSIONS, true));
permissionService.setPermission(nodeRef.getStoreRef(), "andy", PermissionService.ALL_PERMISSIONS, true);
@@ -424,8 +424,8 @@ public class AVMServicePermissionsTest extends TestCase
assertTrue(checkHasPermission("andy", nodeRef, PermissionService.ALL_PERMISSIONS, true));
assertTrue(checkPermission("lemur", storeName + ":/base", PermissionService.ALL_PERMISSIONS, false));
assertTrue(checkHasPermission("lemur", nodeRef, PermissionService.ALL_PERMISSIONS, false));
- assertTrue(checkPermission("admin", storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
- assertTrue(checkHasPermission("admin", nodeRef, PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkHasPermission(AuthenticationUtil.getAdminUserName(), nodeRef, PermissionService.ALL_PERMISSIONS, true));
permissionService.deletePermission(nodeRef.getStoreRef(), "andy", PermissionService.ALL_PERMISSIONS);
@@ -433,8 +433,8 @@ public class AVMServicePermissionsTest extends TestCase
assertTrue(checkHasPermission("andy", nodeRef, PermissionService.ALL_PERMISSIONS, false));
assertTrue(checkPermission("lemur", storeName + ":/base", PermissionService.ALL_PERMISSIONS, false));
assertTrue(checkHasPermission("lemur", nodeRef, PermissionService.ALL_PERMISSIONS, false));
- assertTrue(checkPermission("admin", storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
- assertTrue(checkHasPermission("admin", nodeRef, PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkHasPermission(AuthenticationUtil.getAdminUserName(), nodeRef, PermissionService.ALL_PERMISSIONS, true));
permissionService.deletePermissions(nodeRef.getStoreRef());
@@ -442,8 +442,8 @@ public class AVMServicePermissionsTest extends TestCase
assertTrue(checkHasPermission("andy", nodeRef, PermissionService.ALL_PERMISSIONS, true));
assertTrue(checkPermission("lemur", storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
assertTrue(checkHasPermission("lemur", nodeRef, PermissionService.ALL_PERMISSIONS, true));
- assertTrue(checkPermission("admin", storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
- assertTrue(checkHasPermission("admin", nodeRef, PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkHasPermission(AuthenticationUtil.getAdminUserName(), nodeRef, PermissionService.ALL_PERMISSIONS, true));
permissionService.setPermission(nodeRef.getStoreRef(), "andy", PermissionService.ALL_PERMISSIONS, true);
assertTrue(checkHasPermission("andy", nodeRef, PermissionService.ALL_PERMISSIONS, true));
@@ -454,8 +454,8 @@ public class AVMServicePermissionsTest extends TestCase
assertTrue(checkHasPermission("andy", nodeRef, PermissionService.ALL_PERMISSIONS, true));
assertTrue(checkPermission("lemur", storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
assertTrue(checkHasPermission("lemur", nodeRef, PermissionService.ALL_PERMISSIONS, true));
- assertTrue(checkPermission("admin", storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
- assertTrue(checkHasPermission("admin", nodeRef, PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkHasPermission(AuthenticationUtil.getAdminUserName(), nodeRef, PermissionService.ALL_PERMISSIONS, true));
assertEquals(permissionService.getAllSetPermissions(nodeRef.getStoreRef()).size(), 3);
permissionService.clearPermission(nodeRef.getStoreRef(), "andy");
@@ -464,8 +464,8 @@ public class AVMServicePermissionsTest extends TestCase
assertTrue(checkHasPermission("andy", nodeRef, PermissionService.ALL_PERMISSIONS, false));
assertTrue(checkPermission("lemur", storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
assertTrue(checkHasPermission("lemur", nodeRef, PermissionService.ALL_PERMISSIONS, true));
- assertTrue(checkPermission("admin", storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
- assertTrue(checkHasPermission("admin", nodeRef, PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkHasPermission(AuthenticationUtil.getAdminUserName(), nodeRef, PermissionService.ALL_PERMISSIONS, true));
assertEquals(permissionService.getAllSetPermissions(nodeRef.getStoreRef()).size(), 1);
permissionService.clearPermission(nodeRef.getStoreRef(), "lemur");
@@ -474,8 +474,8 @@ public class AVMServicePermissionsTest extends TestCase
assertTrue(checkHasPermission("andy", nodeRef, PermissionService.ALL_PERMISSIONS, false));
assertTrue(checkPermission("lemur", storeName + ":/base", PermissionService.ALL_PERMISSIONS, false));
assertTrue(checkHasPermission("lemur", nodeRef, PermissionService.ALL_PERMISSIONS, false));
- assertTrue(checkPermission("admin", storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
- assertTrue(checkHasPermission("admin", nodeRef, PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + ":/base", PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkHasPermission(AuthenticationUtil.getAdminUserName(), nodeRef, PermissionService.ALL_PERMISSIONS, true));
}
finally
@@ -496,7 +496,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testSimpleUpdate() throws Throwable
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -572,7 +572,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testUpdateWithPermissions() throws Exception
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -653,7 +653,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testComplexStore_AlterInheritance()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -674,9 +674,9 @@ public class AVMServicePermissionsTest extends TestCase
NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, desc.getPath());
permissionService.setPermission(nodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.ALL_PERMISSIONS, true);
- assertTrue(checkPermission("admin", storeName + ":/base", PermissionService.READ, true));
- assertTrue(checkPermission("admin", storeName + "-layer-base:/layer-to-base", PermissionService.READ, true));
- assertTrue(checkPermission("admin", storeName + "-layer-base:/layer-to-base", PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + ":/base", PermissionService.READ, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + "-layer-base:/layer-to-base", PermissionService.READ, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + "-layer-base:/layer-to-base", PermissionService.ALL_PERMISSIONS, true));
// True as unset defaults to allow
assertTrue(checkPermission("lemur", storeName + ":/base", PermissionService.READ, true));
assertTrue(checkPermission("lemur", storeName + "-layer-base:/layer-to-base", PermissionService.READ, true));
@@ -687,9 +687,9 @@ public class AVMServicePermissionsTest extends TestCase
permissionService.setPermission(nodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.ALL_PERMISSIONS, true);
permissionService.deletePermission(nodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.ALL_PERMISSIONS);
- assertTrue(checkPermission("admin", storeName + ":/base", PermissionService.READ, true));
- assertTrue(checkPermission("admin", storeName + "-layer-base:/layer-to-base", PermissionService.READ, true));
- assertTrue(checkPermission("admin", storeName + "-layer-base:/layer-to-base", PermissionService.ALL_PERMISSIONS, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + ":/base", PermissionService.READ, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + "-layer-base:/layer-to-base", PermissionService.READ, true));
+ assertTrue(checkPermission(AuthenticationUtil.getAdminUserName(), storeName + "-layer-base:/layer-to-base", PermissionService.ALL_PERMISSIONS, true));
// True as unset defaults to allow
assertTrue(checkPermission("lemur", storeName + ":/base", PermissionService.READ, false));
assertTrue(checkPermission("lemur", storeName + "-layer-base:/layer-to-base", PermissionService.READ, true));
@@ -767,7 +767,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testComplexStore_AddPermissionsToMiddle()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -935,7 +935,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testComplexStore_AddPermissionsToBottom()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -1102,7 +1102,7 @@ public class AVMServicePermissionsTest extends TestCase
*/
public void testSimpleFilePermissionDiff() throws Throwable
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String baseStore = "main";
String layeredStore = "layer";
@@ -1205,7 +1205,7 @@ public class AVMServicePermissionsTest extends TestCase
*/
public void testSimpleDirectoryPermissionDiff0() throws Throwable
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String baseStore = "main";
String layeredStore = "layer";
@@ -1299,7 +1299,7 @@ public class AVMServicePermissionsTest extends TestCase
*/
public void testSimpleDirectoryPermissionDiff1() throws Throwable
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String baseStore = "main";
String layeredStore = "layer";
@@ -1400,7 +1400,7 @@ public class AVMServicePermissionsTest extends TestCase
*/
public void testSimpleDirectoryPermissionDiff2() throws Throwable
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String baseStore = "main";
String layeredStore = "layer";
@@ -1500,7 +1500,7 @@ public class AVMServicePermissionsTest extends TestCase
*/
public void testSimpleDirectoryPermissionDiff3() throws Throwable
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String baseStore = "main";
String layeredStore = "layer";
@@ -1648,7 +1648,7 @@ public class AVMServicePermissionsTest extends TestCase
*/
public void testSimpleDirectoryPermissionDiff4() throws Throwable
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String baseStore = "main";
String layeredStore = "layer";
@@ -1824,7 +1824,7 @@ public class AVMServicePermissionsTest extends TestCase
*/
public void testSimpleDirectoryPermissionDiff5() throws Throwable
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String baseStore = "main";
String layeredStore = "layer";
@@ -1980,7 +1980,7 @@ public class AVMServicePermissionsTest extends TestCase
*/
public void testSimpleDirectoryPermissionDiff6() throws Throwable
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String baseStore = "main";
String layeredStore = "layer";
@@ -2226,7 +2226,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testRedirectLayeredDirectory()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -2531,7 +2531,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testCopy()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -2648,7 +2648,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testBranches()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -2766,7 +2766,7 @@ public class AVMServicePermissionsTest extends TestCase
@SuppressWarnings("unused")
public void testWCMStyleTemplateAsBranch()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
String branchName = storeName + "-Branch";
try
@@ -2861,7 +2861,7 @@ public class AVMServicePermissionsTest extends TestCase
*/
public void testSimpleExternalLayer() throws Exception
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -3098,7 +3098,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testSimpleInternalLayer()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -3341,7 +3341,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testMutationsWithSimpleLayers()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -3465,7 +3465,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testRenamePlainDirectory()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -3586,7 +3586,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testRenamePlainFile()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -3706,7 +3706,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testRenamePlainDirectoryIntoLayer()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
@@ -3784,7 +3784,7 @@ public class AVMServicePermissionsTest extends TestCase
public void testRenamePlainFileIntoLayer()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
String storeName = "PermissionsTest-" + getName() + "-" + (new Date().getTime());
try
{
diff --git a/source/java/org/alfresco/repo/avm/AVMServiceRemoteSystemTest.java b/source/java/org/alfresco/repo/avm/AVMServiceRemoteSystemTest.java
index 52d0ec04a1..7ed6e709c0 100644
--- a/source/java/org/alfresco/repo/avm/AVMServiceRemoteSystemTest.java
+++ b/source/java/org/alfresco/repo/avm/AVMServiceRemoteSystemTest.java
@@ -24,6 +24,7 @@
package org.alfresco.repo.avm;
import org.alfresco.repo.remote.ClientTicketHolder;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.remote.AVMRemote;
import org.alfresco.service.cmr.security.AuthenticationService;
@@ -47,7 +48,7 @@ public class AVMServiceRemoteSystemTest extends AVMServiceLocalTest
excluder = (NameMatcher) fContext.getBean("globalPathExcluder");
AuthenticationService authService = (AuthenticationService)fContext.getBean("authenticationService");
- authService.authenticate("admin", "admin".toCharArray());
+ authService.authenticate(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
String ticket = authService.getCurrentTicket();
((ClientTicketHolder)fContext.getBean("clientTicketHolder")).setTicket(ticket);
}
diff --git a/source/java/org/alfresco/repo/avm/AVMServiceTest.java b/source/java/org/alfresco/repo/avm/AVMServiceTest.java
index 1ee248f884..1942d65adb 100644
--- a/source/java/org/alfresco/repo/avm/AVMServiceTest.java
+++ b/source/java/org/alfresco/repo/avm/AVMServiceTest.java
@@ -51,6 +51,7 @@ import org.alfresco.repo.avm.util.BulkLoader;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.sandbox.SandboxConstants;
@@ -371,7 +372,7 @@ public class AVMServiceTest extends AVMServiceTestBase
fService = oldService;
fLockingService.removeStoreLocks("main");
fLockingService.removeWebProject("main");
- authService.authenticate("admin", "admin".toCharArray());
+ authService.authenticate(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
fService.purgeStore("main--admin");
}
}
diff --git a/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java b/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java
index 1119a9c3d1..a310e24612 100644
--- a/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java
+++ b/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java
@@ -156,7 +156,7 @@ public class AVMServiceTestBase extends TestCase
);
}
- fAuthService.authenticate("admin", "admin".toCharArray());
+ fAuthService.authenticate(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
if (fService.getStore("main") != null)
{
diff --git a/source/java/org/alfresco/repo/avm/AbstractSpringContextTest.java b/source/java/org/alfresco/repo/avm/AbstractSpringContextTest.java
index 640f5654f7..21b6e4e745 100644
--- a/source/java/org/alfresco/repo/avm/AbstractSpringContextTest.java
+++ b/source/java/org/alfresco/repo/avm/AbstractSpringContextTest.java
@@ -24,6 +24,7 @@
*/
package org.alfresco.repo.avm;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.security.AuthenticationService;
@@ -50,7 +51,7 @@ public abstract class AbstractSpringContextTest extends AbstractDependencyInject
permissionService = servReg.getPermissionService();
assertNotNull(permissionService);
- authenticationService.authenticate("admin", "admin".toCharArray());
+ authenticationService.authenticate(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
}
@Override
diff --git a/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceTest.java b/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceTest.java
index ac8a332254..c233025fb9 100644
--- a/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceTest.java
+++ b/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceTest.java
@@ -34,6 +34,7 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.attributes.AttributeService;
import org.alfresco.service.cmr.avm.locking.AVMLock;
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
@@ -323,7 +324,7 @@ public class AVMLockingServiceTest extends TestCase
assertFalse(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Willow"));
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Tara"));
assertFalse(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Xander"));
- assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "admin"));
+ assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", AuthenticationUtil.getAdminUserName()));
}
catch (Exception e)
{
diff --git a/source/java/org/alfresco/repo/i18n/MessageServiceImplTest.java b/source/java/org/alfresco/repo/i18n/MessageServiceImplTest.java
index b8bd68469f..e1131d8ea2 100644
--- a/source/java/org/alfresco/repo/i18n/MessageServiceImplTest.java
+++ b/source/java/org/alfresco/repo/i18n/MessageServiceImplTest.java
@@ -59,7 +59,6 @@ public class MessageServiceImplTest extends TestCase implements MessageDeployer
* Test user details
*/
private static final String PWD = "admin";
- private static final String USER_NAME = "admin";
/**
* Test store ref
@@ -92,14 +91,14 @@ public class MessageServiceImplTest extends TestCase implements MessageDeployer
// Get a reference to the root node
NodeRef rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);
- // Create an authenticate the user
- if(!authenticationService.authenticationExists(USER_NAME))
+ // Create and authenticate the user
+ if(!authenticationService.authenticationExists(AuthenticationUtil.getAdminUserName()))
{
- authenticationService.createAuthentication(USER_NAME, PWD.toCharArray());
+ authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), PWD.toCharArray());
}
// Authenticate - as admin
- authenticationService.authenticate(USER_NAME, PWD.toCharArray());
+ authenticationService.authenticate(AuthenticationUtil.getAdminUserName(), PWD.toCharArray());
// Store test messages in repo
String pattern = "classpath*:" + BASE_RESOURCE_CLASSPATH + BASE_BUNDLE_NAME + "*";
diff --git a/source/java/org/alfresco/repo/jscript/ScriptBehaviourTest.java b/source/java/org/alfresco/repo/jscript/ScriptBehaviourTest.java
index c0749e8359..7ba5bd1b57 100644
--- a/source/java/org/alfresco/repo/jscript/ScriptBehaviourTest.java
+++ b/source/java/org/alfresco/repo/jscript/ScriptBehaviourTest.java
@@ -32,6 +32,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -74,7 +75,7 @@ public class ScriptBehaviourTest extends BaseSpringTest
this.serviceRegistry = (ServiceRegistry)this.applicationContext.getBean("ServiceRegistry");
AuthenticationComponent authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent");
- authenticationComponent.setCurrentUser("admin");
+ authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
// Create the store and get the root node reference
this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
diff --git a/source/java/org/alfresco/repo/model/ml/tools/AbstractMultilingualTestCases.java b/source/java/org/alfresco/repo/model/ml/tools/AbstractMultilingualTestCases.java
index 538d0f9428..2e550ae000 100644
--- a/source/java/org/alfresco/repo/model/ml/tools/AbstractMultilingualTestCases.java
+++ b/source/java/org/alfresco/repo/model/ml/tools/AbstractMultilingualTestCases.java
@@ -29,6 +29,7 @@ import junit.framework.TestCase;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.archive.NodeArchiveService;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
@@ -83,7 +84,7 @@ public abstract class AbstractMultilingualTestCases extends TestCase
editionService = (EditionService) ctx.getBean("EditionService");
// Run as admin
- authenticationComponent.setCurrentUser("admin");
+ authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
// Create a folder to work in
RetryingTransactionCallback createFolderCallback = new RetryingTransactionCallback()
diff --git a/source/java/org/alfresco/repo/node/FFCLoadsOfFiles.java b/source/java/org/alfresco/repo/node/FFCLoadsOfFiles.java
index 197a8f82c0..8a78aba1fc 100644
--- a/source/java/org/alfresco/repo/node/FFCLoadsOfFiles.java
+++ b/source/java/org/alfresco/repo/node/FFCLoadsOfFiles.java
@@ -32,6 +32,7 @@ import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -73,7 +74,7 @@ public class FFCLoadsOfFiles
// authenticate
AuthenticationService authenticationService = serviceRegistry.getAuthenticationService();
- authenticationService.authenticate("admin", "admin".toCharArray());
+ authenticationService.authenticate(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
// use TransactionWork to wrap service calls in a user transaction
diff --git a/source/java/org/alfresco/repo/preference/PreferenceServiceImpl.java b/source/java/org/alfresco/repo/preference/PreferenceServiceImpl.java
index f59c8cdde4..6cddff0c49 100644
--- a/source/java/org/alfresco/repo/preference/PreferenceServiceImpl.java
+++ b/source/java/org/alfresco/repo/preference/PreferenceServiceImpl.java
@@ -357,7 +357,7 @@ public class PreferenceServiceImpl implements PreferenceService
return null;
}
- }, "admin");
+ }, AuthenticationUtil.getAdminUserName());
}
else
{
diff --git a/source/java/org/alfresco/repo/rule/BaseRuleTest.java b/source/java/org/alfresco/repo/rule/BaseRuleTest.java
index 02cab9aafc..045fd5a354 100644
--- a/source/java/org/alfresco/repo/rule/BaseRuleTest.java
+++ b/source/java/org/alfresco/repo/rule/BaseRuleTest.java
@@ -35,6 +35,7 @@ import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
import org.alfresco.repo.configuration.ConfigurableService;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ActionService;
@@ -127,7 +128,7 @@ public class BaseRuleTest extends BaseSpringTest
this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent");
//authenticationComponent.setSystemUserAsCurrentUser();
- authenticationComponent.setCurrentUser("admin");
+ authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
// Get the rule type
this.ruleType = this.ruleService.getRuleType(RULE_TYPE_NAME);
diff --git a/source/java/org/alfresco/repo/rule/RuleServiceCoverageTest.java b/source/java/org/alfresco/repo/rule/RuleServiceCoverageTest.java
index 0d1170c732..ef3c80e266 100644
--- a/source/java/org/alfresco/repo/rule/RuleServiceCoverageTest.java
+++ b/source/java/org/alfresco/repo/rule/RuleServiceCoverageTest.java
@@ -63,6 +63,7 @@ import org.alfresco.repo.dictionary.M2Aspect;
import org.alfresco.repo.dictionary.M2Model;
import org.alfresco.repo.dictionary.M2Property;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.action.Action;
@@ -171,7 +172,7 @@ public class RuleServiceCoverageTest extends TestCase
{
public Object execute() throws Exception
{
- authenticationComponent.setCurrentUser("admin");
+ authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
return null;
}
};
diff --git a/source/java/org/alfresco/repo/rule/RuleServiceImplTest.java b/source/java/org/alfresco/repo/rule/RuleServiceImplTest.java
index 6a2736535f..b8485051b5 100644
--- a/source/java/org/alfresco/repo/rule/RuleServiceImplTest.java
+++ b/source/java/org/alfresco/repo/rule/RuleServiceImplTest.java
@@ -35,6 +35,7 @@ import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
import org.alfresco.repo.action.executer.ImageTransformActionExecuter;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.repository.ContentWriter;
@@ -363,7 +364,7 @@ public class RuleServiceImplTest extends BaseRuleTest
this.permissionService.setPermission(this.nodeRef, "coordUser", PermissionService.COORDINATOR, true);
this.permissionService.setInheritParentPermissions(this.nodeRef, true);
- this.authenticationService.authenticate("admin", "admin".toCharArray());
+ this.authenticationService.authenticate(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
Rule rule2 = createTestRule();
this.ruleService.saveRule(this.nodeRef, rule2);
this.authenticationService.clearCurrentSecurityContext();
diff --git a/source/java/org/alfresco/repo/search/SearchServiceTest.java b/source/java/org/alfresco/repo/search/SearchServiceTest.java
index 6e30d0c463..118bed588c 100644
--- a/source/java/org/alfresco/repo/search/SearchServiceTest.java
+++ b/source/java/org/alfresco/repo/search/SearchServiceTest.java
@@ -30,6 +30,7 @@ import junit.framework.TestCase;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -114,9 +115,9 @@ public class SearchServiceTest extends TestCase
authenticationService.createAuthentication("andy", "andy".toCharArray());
}
- if (!authenticationDAO.userExists("admin"))
+ if (!authenticationDAO.userExists(AuthenticationUtil.getAdminUserName()))
{
- authenticationService.createAuthentication("admin", "admin".toCharArray());
+ authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
}
if (!authenticationDAO.userExists("administrator"))
@@ -165,7 +166,7 @@ public class SearchServiceTest extends TestCase
public void testAdmim()
{
- authenticationComponent.setCurrentUser("admin");
+ authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
SearchParameters sp = new SearchParameters();
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery("PATH:\"//*\"");
diff --git a/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java b/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java
index 0082156b1b..f44ea52c54 100644
--- a/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java
+++ b/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java
@@ -289,7 +289,7 @@ public class AuthenticationTest extends TestCase
long start;
long end;
- authenticationComponent.authenticate("admin", "admin".toCharArray());
+ authenticationComponent.authenticate(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
for (int i = 0; i < 10000; i++)
{
String id = "TestUser-" + i;
diff --git a/source/java/org/alfresco/repo/security/authentication/AuthenticationUtil.java b/source/java/org/alfresco/repo/security/authentication/AuthenticationUtil.java
index cd0c67cb42..c0f179dbb2 100644
--- a/source/java/org/alfresco/repo/security/authentication/AuthenticationUtil.java
+++ b/source/java/org/alfresco/repo/security/authentication/AuthenticationUtil.java
@@ -41,11 +41,12 @@ import org.alfresco.util.EqualsHelper;
import org.alfresco.util.log.NDC;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.InitializingBean;
/**
* Utility helper methods to change the authenticated context for threads.
*/
-public abstract class AuthenticationUtil
+public class AuthenticationUtil implements InitializingBean
{
static Log s_logger = LogFactory.getLog(AuthenticationUtil.class);
@@ -59,10 +60,32 @@ public abstract class AuthenticationUtil
Result doWork() throws Exception;
}
+ private static boolean initialized = false;
+
public static final String SYSTEM_USER_NAME = "System";
-
+ private static String defaultAdminUserName = PermissionService.ADMINISTRATOR_AUTHORITY;
+ private static String defaultGuestUserName = PermissionService.GUEST_AUTHORITY;
private static boolean mtEnabled = false;
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet() throws Exception
+ {
+ // at this point default admin and guest names have been assigned
+ initialized = true;
+ }
+
+ public void setDefaultAdminUserName(String defaultAdminUserName)
+ {
+ AuthenticationUtil.defaultAdminUserName = defaultAdminUserName;
+ }
+
+ public void setDefaultGuestUserName(String defaultGuestUserName)
+ {
+ AuthenticationUtil.defaultGuestUserName = defaultGuestUserName;
+ }
+
public static void setMtEnabled(boolean mtEnabled)
{
if (!AuthenticationUtil.mtEnabled)
@@ -375,19 +398,45 @@ public abstract class AuthenticationUtil
/**
* Get the name of the system user
*
- * @return String
+ * @return system user name
*/
public static String getSystemUserName()
{
return SYSTEM_USER_NAME;
}
+
+ /**
+ * 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");
+ }
+ return defaultAdminUserName;
+ }
+ /*
+ * Get the name of admin role
+ */
+ public static String getAdminRoleName()
+ {
+ return PermissionService.ADMINISTRATOR_AUTHORITY;
+ }
+
/**
* Get the name of the Guest User
*/
public static String getGuestUserName()
{
- return PermissionService.GUEST_AUTHORITY.toLowerCase();
+ if (!initialized)
+ {
+ throw new IllegalStateException("AuthenticationUtil not yet initialised; default guest username not available");
+ }
+ return defaultGuestUserName;
}
/**
@@ -545,4 +594,5 @@ public abstract class AuthenticationUtil
NDC.push("User:" + userName);
}
}
+
}
diff --git a/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java b/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java
index c08123a5c2..a0705735b7 100644
--- a/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java
+++ b/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java
@@ -35,6 +35,7 @@ import junit.framework.TestCase;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.security.permissions.impl.AclDaoComponent;
import org.alfresco.service.ServiceRegistry;
@@ -100,11 +101,11 @@ public class AuthorityServiceTest extends TestCase
tx.begin();
for (String user : pubAuthorityService.getAllAuthorities(AuthorityType.USER))
{
- if (user.equals("guest"))
+ if (user.equals(AuthenticationUtil.getGuestUserName()))
{
continue;
}
- else if (user.equals("admin"))
+ else if (user.equals(AuthenticationUtil.getAdminUserName()))
{
continue;
}
@@ -138,9 +139,9 @@ public class AuthorityServiceTest extends TestCase
authenticationService.createAuthentication("andy", "andy".toCharArray());
}
- if (!authenticationDAO.userExists("admin"))
+ if (!authenticationDAO.userExists(AuthenticationUtil.getAdminUserName()))
{
- authenticationService.createAuthentication("admin", "admin".toCharArray());
+ authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
}
if (!authenticationDAO.userExists("administrator"))
@@ -211,7 +212,7 @@ public class AuthorityServiceTest extends TestCase
public void testAdminUser()
{
- authenticationComponent.setCurrentUser("admin");
+ authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
assertTrue(authorityService.hasAdminAuthority());
assertTrue(pubAuthorityService.hasAdminAuthority());
assertEquals(3, authorityService.getAuthorities().size());
diff --git a/source/java/org/alfresco/repo/security/authority/SimpleAuthorityServiceTest.java b/source/java/org/alfresco/repo/security/authority/SimpleAuthorityServiceTest.java
index bfb1c039a1..a5577f3935 100644
--- a/source/java/org/alfresco/repo/security/authority/SimpleAuthorityServiceTest.java
+++ b/source/java/org/alfresco/repo/security/authority/SimpleAuthorityServiceTest.java
@@ -86,9 +86,9 @@ public class SimpleAuthorityServiceTest extends TestCase
authenticationService.createAuthentication("andy", "andy".toCharArray());
}
- if (!authenticationDAO.userExists("admin"))
+ if (!authenticationDAO.userExists(AuthenticationUtil.getAdminUserName()))
{
- authenticationService.createAuthentication("admin", "admin".toCharArray());
+ authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
}
if (!authenticationDAO.userExists("administrator"))
@@ -117,7 +117,7 @@ public class SimpleAuthorityServiceTest extends TestCase
{
assertFalse(authorityService.authorityExists("woof"));
- authenticationComponent.setCurrentUser("admin");
+ authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
assertTrue(authorityService.hasAdminAuthority());
assertTrue(pubAuthorityService.hasAdminAuthority());
assertEquals(3, authorityService.getAuthorities().size());
diff --git a/source/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java b/source/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java
index cad71f47b2..bfcdbb4a7b 100644
--- a/source/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java
+++ b/source/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java
@@ -31,6 +31,7 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.db.NodeDaoService;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.security.permissions.PermissionReference;
import org.alfresco.repo.security.permissions.PermissionServiceSPI;
@@ -140,11 +141,11 @@ public class AbstractPermissionTest extends BaseSpringTest
}
authenticationService.createAuthentication("lemur", "lemur".toCharArray());
- if(authenticationDAO.userExists("admin"))
+ if(authenticationDAO.userExists(AuthenticationUtil.getAdminUserName()))
{
- authenticationService.deleteAuthentication("admin");
+ authenticationService.deleteAuthentication(AuthenticationUtil.getAdminUserName());
}
- authenticationService.createAuthentication("admin", "admin".toCharArray());
+ authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
authenticationComponent.clearCurrentSecurityContext();
}
diff --git a/source/java/org/alfresco/repo/security/permissions/impl/AclDaoComponentTest.java b/source/java/org/alfresco/repo/security/permissions/impl/AclDaoComponentTest.java
index 6b6abee88e..270d36c5e2 100644
--- a/source/java/org/alfresco/repo/security/permissions/impl/AclDaoComponentTest.java
+++ b/source/java/org/alfresco/repo/security/permissions/impl/AclDaoComponentTest.java
@@ -168,11 +168,11 @@ public class AclDaoComponentTest extends TestCase
}
authenticationService.createAuthentication("lemur", "lemur".toCharArray());
- if(authenticationDAO.userExists("admin"))
+ if(authenticationDAO.userExists(AuthenticationUtil.getAdminUserName()))
{
- authenticationService.deleteAuthentication("admin");
+ authenticationService.deleteAuthentication(AuthenticationUtil.getAdminUserName());
}
- authenticationService.createAuthentication("admin", "admin".toCharArray());
+ authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
authenticationComponent.clearCurrentSecurityContext();
}
diff --git a/source/java/org/alfresco/repo/security/permissions/impl/PermissionServiceTest.java b/source/java/org/alfresco/repo/security/permissions/impl/PermissionServiceTest.java
index ad2ccff861..20dd7144d2 100644
--- a/source/java/org/alfresco/repo/security/permissions/impl/PermissionServiceTest.java
+++ b/source/java/org/alfresco/repo/security/permissions/impl/PermissionServiceTest.java
@@ -97,7 +97,7 @@ public class PermissionServiceTest extends AbstractPermissionTest
public void testDelete()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
NodeRef n1 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"), ContentModel.TYPE_FOLDER).getChildRef();
NodeRef n2 = nodeService.createNode(n1, ContentModel.ASSOC_CONTAINS, QName.createQName("{namespace}two"), ContentModel.TYPE_FOLDER).getChildRef();
@@ -144,7 +144,7 @@ public class PermissionServiceTest extends AbstractPermissionTest
*/
public void testPositionInformation()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
NodeRef one = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"), ContentModel.TYPE_FOLDER).getChildRef();
NodeRef two = nodeService.createNode(one, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}two"), ContentModel.TYPE_FOLDER).getChildRef();
NodeRef three = nodeService.createNode(two, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}three"), ContentModel.TYPE_FOLDER).getChildRef();
@@ -226,7 +226,7 @@ public class PermissionServiceTest extends AbstractPermissionTest
public void test_AR_2055()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
NodeRef folder = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"), ContentModel.TYPE_FOLDER).getChildRef();
runAs("andy");
@@ -242,7 +242,7 @@ public class PermissionServiceTest extends AbstractPermissionTest
}
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
permissionService.setPermission(folder, "andy", PermissionService.ALL_PERMISSIONS, true);
FileFolderServiceImpl.makeFolders(serviceRegistry.getFileFolderService(), folder, pathElements, ContentModel.TYPE_FOLDER);
@@ -251,7 +251,7 @@ public class PermissionServiceTest extends AbstractPermissionTest
public void testRunAsRealAndEffectiveUsersWithPriorAuthentication()
{
- runAs("admin");
+ runAs(AuthenticationUtil.getAdminUserName());
final NodeRef n1 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"), ContentModel.TYPE_FOLDER).getChildRef();
@@ -266,12 +266,12 @@ public class PermissionServiceTest extends AbstractPermissionTest
public Object doWork() throws Exception
{
assertEquals("andy", AuthenticationUtil.getFullyAuthenticatedUser());
- assertEquals("admin", AuthenticationUtil.getRunAsUser());
+ assertEquals(AuthenticationUtil.getAdminUserName(), AuthenticationUtil.getRunAsUser());
assertTrue(permissionService.hasPermission(n1, getPermission(PermissionService.CONTRIBUTOR)) == AccessStatus.ALLOWED);
assertEquals("andy", AuthenticationUtil.getFullyAuthenticatedUser());
- assertEquals("admin", AuthenticationUtil.getRunAsUser());
+ assertEquals(AuthenticationUtil.getAdminUserName(), AuthenticationUtil.getRunAsUser());
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork