Search in sources :

Example 1 with TestPersonManager

use of org.alfresco.repo.security.person.TestPersonManager in project alfresco-remote-api by Alfresco.

the class AbstractWorkflowRestApiTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    ApplicationContext appContext = getServer().getApplicationContext();
    namespaceService = (NamespaceService) appContext.getBean("NamespaceService");
    workflowService = (WorkflowService) appContext.getBean("WorkflowService");
    MutableAuthenticationService authenticationService = (MutableAuthenticationService) appContext.getBean("AuthenticationService");
    PersonService personService = (PersonService) appContext.getBean("PersonService");
    SearchService searchService = (SearchService) appContext.getBean("SearchService");
    FileFolderService fileFolderService = (FileFolderService) appContext.getBean("FileFolderService");
    nodeService = (NodeService) appContext.getBean("NodeService");
    // for the purposes of the tests make sure workflow engine is enabled/visible.
    WorkflowAdminServiceImpl workflowAdminService = (WorkflowAdminServiceImpl) appContext.getBean("workflowAdminService");
    this.wfTestHelper = new WorkflowTestHelper(workflowAdminService, getEngine(), true);
    AuthorityService authorityService = (AuthorityService) appContext.getBean("AuthorityService");
    personManager = new TestPersonManager(authenticationService, personService, nodeService);
    groupManager = new TestGroupManager(authorityService);
    authenticationComponent = (AuthenticationComponent) appContext.getBean("authenticationComponent");
    dictionaryService = (DictionaryService) appContext.getBean("dictionaryService");
    personManager.createPerson(USER1);
    personManager.createPerson(USER2);
    personManager.createPerson(USER3);
    authenticationComponent.setSystemUserAsCurrentUser();
    groupManager.addUserToGroup(GROUP, USER2);
    packageRef = workflowService.createPackage(null);
    NodeRef companyHome = searchService.selectNodes(nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE), COMPANY_HOME, null, namespaceService, false).get(0);
    contentNodeRef = fileFolderService.create(companyHome, TEST_CONTENT + System.currentTimeMillis(), ContentModel.TYPE_CONTENT).getNodeRef();
    authenticationComponent.clearCurrentSecurityContext();
}
Also used : TestPersonManager(org.alfresco.repo.security.person.TestPersonManager) NodeRef(org.alfresco.service.cmr.repository.NodeRef) ApplicationContext(org.springframework.context.ApplicationContext) PersonService(org.alfresco.service.cmr.security.PersonService) SearchService(org.alfresco.service.cmr.search.SearchService) AuthorityService(org.alfresco.service.cmr.security.AuthorityService) WorkflowAdminServiceImpl(org.alfresco.repo.workflow.WorkflowAdminServiceImpl) FileFolderService(org.alfresco.service.cmr.model.FileFolderService) MutableAuthenticationService(org.alfresco.service.cmr.security.MutableAuthenticationService) WorkflowTestHelper(org.alfresco.repo.workflow.WorkflowTestHelper) TestGroupManager(org.alfresco.repo.security.person.TestGroupManager)

Example 2 with TestPersonManager

use of org.alfresco.repo.security.person.TestPersonManager in project alfresco-remote-api by Alfresco.

the class ReplicationRestApiTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    ApplicationContext appContext = getServer().getApplicationContext();
    nodeService = (NodeService) appContext.getBean("NodeService");
    replicationService = (ReplicationService) appContext.getBean("ReplicationService");
    actionTrackingService = (ActionTrackingService) appContext.getBean("actionTrackingService");
    repositoryHelper = (Repository) appContext.getBean("repositoryHelper");
    transactionService = (TransactionService) appContext.getBean("transactionService");
    MutableAuthenticationService authenticationService = (MutableAuthenticationService) appContext.getBean("AuthenticationService");
    PersonService personService = (PersonService) appContext.getBean("PersonService");
    personManager = new TestPersonManager(authenticationService, personService, nodeService);
    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();
    personManager.createPerson(USER_NORMAL);
    // Ensure we start with no replication definitions
    // (eg another test left them behind)
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    for (ReplicationDefinition rd : replicationService.loadReplicationDefinitions()) {
        replicationService.deleteReplicationDefinition(rd);
    }
    txn.commit();
    // Grab a reference to the data dictionary
    dataDictionary = nodeService.getChildByName(repositoryHelper.getCompanyHome(), ContentModel.ASSOC_CONTAINS, "Data Dictionary");
    AuthenticationUtil.clearCurrentSecurityContext();
}
Also used : TestPersonManager(org.alfresco.repo.security.person.TestPersonManager) UserTransaction(javax.transaction.UserTransaction) ApplicationContext(org.springframework.context.ApplicationContext) ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition) PersonService(org.alfresco.service.cmr.security.PersonService) MutableAuthenticationService(org.alfresco.service.cmr.security.MutableAuthenticationService)

Example 3 with TestPersonManager

use of org.alfresco.repo.security.person.TestPersonManager in project alfresco-remote-api by Alfresco.

the class RunningActionRestApiTest method setUp.

@SuppressWarnings("unchecked")
@Override
protected void setUp() throws Exception {
    super.setUp();
    ApplicationContext appContext = getServer().getApplicationContext();
    nodeService = (NodeService) appContext.getBean("NodeService");
    replicationService = (ReplicationService) appContext.getBean("ReplicationService");
    actionTrackingService = (ActionTrackingService) appContext.getBean("actionTrackingService");
    repositoryHelper = (Repository) appContext.getBean("repositoryHelper");
    transactionService = (TransactionService) appContext.getBean("transactionService");
    executingActionsCache = (SimpleCache<String, ExecutionDetails>) appContext.getBean("executingActionsCache");
    MutableAuthenticationService authenticationService = (MutableAuthenticationService) appContext.getBean("AuthenticationService");
    PersonService personService = (PersonService) appContext.getBean("PersonService");
    personManager = new TestPersonManager(authenticationService, personService, nodeService);
    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();
    personManager.createPerson(USER_NORMAL);
    // Ensure we start with no replication definitions
    // (eg another test left them behind)
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    for (ReplicationDefinition rd : replicationService.loadReplicationDefinitions()) {
        replicationService.deleteReplicationDefinition(rd);
    }
    txn.commit();
    // Grab a reference to the data dictionary
    dataDictionary = nodeService.getChildByName(repositoryHelper.getCompanyHome(), ContentModel.ASSOC_CONTAINS, "Data Dictionary");
    AuthenticationUtil.clearCurrentSecurityContext();
}
Also used : TestPersonManager(org.alfresco.repo.security.person.TestPersonManager) UserTransaction(javax.transaction.UserTransaction) ApplicationContext(org.springframework.context.ApplicationContext) ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition) PersonService(org.alfresco.service.cmr.security.PersonService) ExecutionDetails(org.alfresco.service.cmr.action.ExecutionDetails) MutableAuthenticationService(org.alfresco.service.cmr.security.MutableAuthenticationService)

Aggregations

TestPersonManager (org.alfresco.repo.security.person.TestPersonManager)3 MutableAuthenticationService (org.alfresco.service.cmr.security.MutableAuthenticationService)3 PersonService (org.alfresco.service.cmr.security.PersonService)3 ApplicationContext (org.springframework.context.ApplicationContext)3 UserTransaction (javax.transaction.UserTransaction)2 ReplicationDefinition (org.alfresco.service.cmr.replication.ReplicationDefinition)2 TestGroupManager (org.alfresco.repo.security.person.TestGroupManager)1 WorkflowAdminServiceImpl (org.alfresco.repo.workflow.WorkflowAdminServiceImpl)1 WorkflowTestHelper (org.alfresco.repo.workflow.WorkflowTestHelper)1 ExecutionDetails (org.alfresco.service.cmr.action.ExecutionDetails)1 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 SearchService (org.alfresco.service.cmr.search.SearchService)1 AuthorityService (org.alfresco.service.cmr.security.AuthorityService)1