Exemple #1
0
 /**
  * Adds the given token to the access entities
  * 
  * @param \Zepi\Api\AccessControl\Entity\Token $token
  * @return false|\Zepi\Api\AccessControl\Entity\Token
  * 
  * @throws \Zepi\Api\AccessControl\Exception Cannot add the token. Name is already in use.
  * @throws \Zepi\Api\AccessControl\Exception Cannot add the token. Internal softeware error.
  */
 public function addToken(Token $token)
 {
     // If the name already is used we cannot add a new token
     if ($this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $token->getName())) {
         throw new Exception('Cannot add the token. Name is already in use.');
     }
     // Add the access entity
     $uuid = $this->accessControlManager->addAccessEntity($token);
     if ($uuid === false) {
         throw new Exception('Cannot add the token. Internal software error.');
     }
     return $token;
 }
Exemple #2
0
 /**
  * Adds the given user to the access entities
  * 
  * @param \Zepi\Web\AccessControl\Entity\User $user
  * @return false|\Zepi\Web\AccessControl\Entity\User
  * 
  * @throws \Zepi\Web\AccessControl\Exception Cannot add the user. Username is already in use.
  * @throws \Zepi\Web\AccessControl\Exception Cannot add the user. Internal software error.
  */
 public function addUser(User $user)
 {
     // If the username already is used we cannot add a new user
     if ($this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $user->getName())) {
         throw new Exception('Cannot add the user. Username is already in use.');
     }
     // Add the access entity
     $uuid = $this->accessControlManager->addAccessEntity($user);
     if ($uuid === false) {
         throw new Exception('Cannot add the user. Internal software error.');
     }
     return $user;
 }
Exemple #3
0
 /**
  * Adds the given group to the access entities
  * 
  * @param \Zepi\Web\AccessControl\Entity\Group $group
  * @return false|\Zepi\Web\AccessControl\Entity\Group
  * 
  * @throws \Zepi\Web\AccessControl\Exception Cannot add the group. The name of the group is already in use.
  * @throws \Zepi\Web\AccessControl\Exception Cannot add the group. Internal software error.
  */
 public function addGroup(Group $group)
 {
     // If the name of the group already is used we cannot add a new group
     if ($this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $group->getName())) {
         throw new Exception('Cannot add the group. The name of the group is already in use.');
     }
     // Add the access entity
     $uuid = $this->accessControlManager->addAccessEntity($group);
     if ($uuid === false) {
         throw new Exception('Cannot add the group. Internal software error.');
     }
     return $group;
 }