setAccountIdentifier() public method

Set the account identifier
public setAccountIdentifier ( string $accountIdentifier ) : void
$accountIdentifier string The account identifier
return void
 /**
  * Creates a new account and sets the given password and roles
  *
  * @param string $identifier Identifier of the account, must be unique
  * @param string $password The clear text password
  * @param array $roleIdentifiers Optionally an array of role identifiers to assign to the new account
  * @param string $authenticationProviderName Optional name of the authentication provider the account is affiliated with
  * @param string $passwordHashingStrategy Optional password hashing strategy to use for the password
  * @return Account A new account, not yet added to the account repository
  */
 public function createAccountWithPassword($identifier, $password, $roleIdentifiers = [], $authenticationProviderName = 'DefaultProvider', $passwordHashingStrategy = 'default')
 {
     $account = new Account();
     $account->setAccountIdentifier($identifier);
     $account->setCredentialsSource($this->hashService->hashPassword($password, $passwordHashingStrategy));
     $account->setAuthenticationProviderName($authenticationProviderName);
     $roles = [];
     foreach ($roleIdentifiers as $roleIdentifier) {
         $roles[] = $this->policyService->getRole($roleIdentifier);
     }
     $account->setRoles($roles);
     return $account;
 }
 /**
  * @test
  */
 public function authenticateTagsSessionWithAccountIdentifier()
 {
     $account = new Account();
     $account->setAccountIdentifier('admin');
     $securityContext = $this->getMockBuilder(Context::class)->setMethods(['getAuthenticationStrategy', 'getAuthenticationTokens', 'refreshTokens', 'refreshRoles'])->getMock();
     $token = $this->createMock(TokenInterface::class);
     $token->expects($this->any())->method('getAccount')->will($this->returnValue($account));
     $token->expects($this->atLeastOnce())->method('isAuthenticated')->will($this->returnValue(true));
     $securityContext->expects($this->atLeastOnce())->method('getAuthenticationTokens')->will($this->returnValue([$token]));
     $this->mockSession->expects($this->once())->method('addTag')->with('TYPO3-Flow-Security-Account-21232f297a57a5a743894a0e4a801fc3');
     $this->authenticationProviderManager->_set('providers', []);
     $this->authenticationProviderManager->_set('securityContext', $securityContext);
     $this->authenticationProviderManager->authenticate();
 }
 /**
  * Creates a new account, assigns it the given roles and authenticates it.
  * The created account is returned for further modification, for example for attaching a Party object to it.
  *
  * @param array $roleNames A list of roles the new account should have
  * @return Security\Accountt The created account
  */
 protected function authenticateRoles(array $roleNames)
 {
     $account = new Security\Account();
     $account->setAccountIdentifier('TestAccount');
     $roles = [];
     foreach ($roleNames as $roleName) {
         $roles[] = $this->policyService->getRole($roleName);
     }
     $account->setRoles($roles);
     $this->authenticateAccount($account);
     return $account;
 }
 /**
  * @test
  */
 public function shutdownCreatesSpecialDataEntryForSessionWithAuthenticatedAccounts()
 {
     $session = new Session();
     $this->inject($session, 'bootstrap', $this->mockBootstrap);
     $this->inject($session, 'objectManager', $this->mockObjectManager);
     $this->inject($session, 'settings', $this->settings);
     $this->inject($session, 'metaDataCache', $this->createCache('Meta'));
     $this->inject($session, 'storageCache', $this->createCache('Storage'));
     $session->initializeObject();
     $session->start();
     $account = new Account();
     $account->setAccountIdentifier('admin');
     $account->setAuthenticationProviderName('MyProvider');
     $token = new UsernamePassword();
     $token->setAuthenticationStatus(TokenInterface::AUTHENTICATION_SUCCESSFUL);
     $token->setAccount($account);
     $this->mockSecurityContext->expects($this->any())->method('isInitialized')->will($this->returnValue(true));
     $this->mockSecurityContext->expects($this->any())->method('getAuthenticationTokens')->will($this->returnValue([$token]));
     $session->close();
     $this->httpRequest->setCookie($this->httpResponse->getCookie('TYPO3_Flow_Session'));
     $session->resume();
     $this->assertEquals(['MyProvider:admin'], $session->getData('TYPO3_Flow_Security_Accounts'));
 }
 /**
  * @test
  */
 public function administratorsCanSeeTestEntityAAssociatedToATestEntityBSomeoneElsesAccount()
 {
     $myAccount = $this->authenticateRoles(['Neos.Flow:Administrator']);
     $myAccount->setAccountIdentifier('MyAccount');
     $myAccount->setAuthenticationProviderName('SomeProvider');
     $andisAccount = new Security\Account();
     $andisAccount->setAccountIdentifier('Andi');
     $andisAccount->setAuthenticationProviderName('SomeProvider');
     $this->persistenceManager->add($myAccount);
     $this->persistenceManager->add($andisAccount);
     $testEntityB = new Fixtures\TestEntityB('testEntityB');
     $testEntityB->setOwnerAccount($myAccount);
     $testEntityA = new Fixtures\TestEntityA($testEntityB);
     $testEntityB2 = new Fixtures\TestEntityB('testEntityB2');
     $testEntityB2->setOwnerAccount($andisAccount);
     $testEntityA2 = new Fixtures\TestEntityA($testEntityB2);
     $this->testEntityADoctrineRepository->add($testEntityA);
     $this->testEntityADoctrineRepository->add($testEntityA2);
     $testEntityAIdentifier = $this->persistenceManager->getIdentifierByObject($testEntityA);
     $testEntityA2Identifier = $this->persistenceManager->getIdentifierByObject($testEntityA2);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $result = $this->testEntityADoctrineRepository->findAllWithDql();
     $this->assertTrue(count($result) === 2);
     $this->assertNotNull($this->persistenceManager->getObjectByIdentifier($testEntityAIdentifier, Fixtures\TestEntityA::class));
     $this->assertNotNull($this->persistenceManager->getObjectByIdentifier($testEntityA2Identifier, Fixtures\TestEntityA::class));
     $this->restrictableEntityDoctrineRepository->removeAll();
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
 }