示例#1
0
 public function testLegacyAuthMechanismCallback()
 {
     $backend = new Backend();
     $backend->setLegacyAuthMechanismCallback(function (array $params) {
         if (isset($params['ping'])) {
             return 'pong';
         }
         return 'foobar';
     });
     $this->assertEquals('pong', $backend->getLegacyAuthMechanism(['ping' => true]));
     $this->assertEquals('foobar', $backend->getLegacyAuthMechanism(['other' => true]));
     $this->assertEquals('foobar', $backend->getLegacyAuthMechanism());
 }
示例#2
0
 /**
  * Serialize config to JSON
  *
  * @return array
  */
 public function jsonSerialize()
 {
     $result = [];
     if (!is_null($this->id)) {
         $result['id'] = $this->id;
     }
     $result['mountPoint'] = $this->mountPoint;
     $result['backend'] = $this->backend->getIdentifier();
     $result['authMechanism'] = $this->authMechanism->getIdentifier();
     $result['backendOptions'] = $this->backendOptions;
     if (!is_null($this->priority)) {
         $result['priority'] = $this->priority;
     }
     if (!empty($this->applicableUsers)) {
         $result['applicableUsers'] = $this->applicableUsers;
     }
     if (!empty($this->applicableGroups)) {
         $result['applicableGroups'] = $this->applicableGroups;
     }
     if (!empty($this->mountOptions)) {
         $result['mountOptions'] = $this->mountOptions;
     }
     if (!is_null($this->status)) {
         $result['status'] = $this->status;
     }
     if (!is_null($this->statusMessage)) {
         $result['statusMessage'] = $this->statusMessage;
     }
     return $result;
 }
示例#3
0
 /**
  * Serialize config to JSON
  *
  * @return array
  */
 public function jsonSerialize()
 {
     $result = [];
     if (!is_null($this->id)) {
         $result['id'] = $this->id;
     }
     $result['mountPoint'] = $this->mountPoint;
     $result['backend'] = $this->backend->getIdentifier();
     $result['authMechanism'] = $this->authMechanism->getIdentifier();
     $result['backendOptions'] = $this->backendOptions;
     if (!is_null($this->priority)) {
         $result['priority'] = $this->priority;
     }
     if (!empty($this->applicableUsers)) {
         $result['applicableUsers'] = $this->applicableUsers;
     }
     if (!empty($this->applicableGroups)) {
         $result['applicableGroups'] = $this->applicableGroups;
     }
     if (!empty($this->mountOptions)) {
         $result['mountOptions'] = $this->mountOptions;
     }
     if (!is_null($this->status)) {
         $result['status'] = $this->status;
     }
     if (!is_null($this->statusMessage)) {
         $result['statusMessage'] = $this->statusMessage;
     }
     $result['userProvided'] = $this->authMechanism instanceof IUserProvided;
     $result['type'] = $this->getType() === self::MOUNT_TYPE_PERSONAl ? 'personal' : 'system';
     return $result;
 }
示例#4
0
 /**
  * Check a backend if a user is allowed to mount it
  *
  * @param Backend $backend
  * @return bool
  */
 protected function isAllowedUserBackend(Backend $backend)
 {
     if ($this->userMountingAllowed && array_intersect($backend->getIdentifierAliases(), $this->userMountingBackends)) {
         return true;
     }
     return false;
 }
示例#5
0
 private function validateParam($key, &$value, Backend $storageBackend, AuthMechanism $authBackend)
 {
     $params = array_merge($storageBackend->getParameters(), $authBackend->getParameters());
     foreach ($params as $param) {
         /** @var DefinitionParameter $param */
         if ($param->getName() === $key) {
             if ($param->getType() === DefinitionParameter::VALUE_BOOLEAN) {
                 $value = $value === 'true';
             }
             return true;
         }
     }
     return false;
 }