public function permissions($permissions = null)
{
if (!$this->protect()) {
return $this;
}
if ($permissions === null) {
return $this->_allow;
}
if (is_string($permissions) && $permissions == 'all') {
$permissions = true;
}
if (is_string($permissions) && $permissions == 'none') {
$permissions = false;
}
if (is_array($permissions)) {
foreach ($permissions as $permission) {
if (!in_array($permission, $this->_availablePermissions)) {
throw new Exception(sprintf('Invalid permission: %s', $permission));
}
if (!$this->crypto()->permissionImplemented($permission)) {
throw new Exception(sprintf('Permission not implemented in crypto engine: %s', $permission));
}
}
}
$this->_allow = $permissions;
return $this;
}