예제 #1
0
 /**
  * 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 \TYPO3\FLOW3\Security\Account A new account, not yet added to the account repository
  */
 public function createAccountWithPassword($identifier, $password, $roleIdentifiers = array(), $authenticationProviderName = 'DefaultProvider', $passwordHashingStrategy = 'default')
 {
     $roles = array();
     foreach ($roleIdentifiers as $roleIdentifier) {
         $roles[] = new \TYPO3\FLOW3\Security\Policy\Role($roleIdentifier);
     }
     $account = new \TYPO3\FLOW3\Security\Account();
     $account->setAccountIdentifier($identifier);
     $account->setCredentialsSource($this->hashService->hashPassword($password, $passwordHashingStrategy));
     $account->setAuthenticationProviderName($authenticationProviderName);
     $account->setRoles($roles);
     return $account;
 }
예제 #2
0
 /**
  * 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 \TYPO3\FLOW3\Security\Account The created account
  * @api
  */
 protected function authenticateRoles(array $roleNames)
 {
     $account = new \TYPO3\FLOW3\Security\Account();
     $roles = array();
     foreach ($roleNames as $roleName) {
         $roles[] = new \TYPO3\FLOW3\Security\Policy\Role($roleName);
     }
     $account->setRoles($roles);
     $this->authenticateAccount($account);
     return $account;
 }