Enable a grant type on the server.

@param GrantTypeInterface $grantType
@param null|DateInterval  $accessTokenTTL
327576
public function enableGrantType(GrantTypeInterface $grantType, DateInterval $accessTokenTTL = null)
    {
        if ($accessTokenTTL instanceof DateInterval === false) {
            $accessTokenTTL = new DateInterval('PT1H');
        }

        $grantType->setAccessTokenRepository($this->accessTokenRepository);
        $grantType->setClientRepository($this->clientRepository);
        $grantType->setScopeRepository($this->scopeRepository);
        $grantType->setDefaultScope($this->defaultScope);
        $grantType->setPrivateKey($this->privateKey);
        $grantType->setEmitter($this->getEmitter());
        $grantType->setEncryptionKey($this->encryptionKey);

        $this->enabledGrantTypes[$grantType->getIdentifier()] = $grantType;
        $this->grantTypeAccessTokenTTL[$grantType->getIdentifier()] = $accessTokenTTL;
    }
115031
public function setRequestType($requestType)
    {
        $requestType = $this->str($requestType)->caseUpper();

        if (!$requestType->equals('GET') && !$requestType->equals('POST')) {
            throw new OAuth2Exception('Invalid request type provided "' . $requestType->val() . '".
										Possible values are GET and POST.'
            );
        }

        $this->requestType = $requestType->val();
    }
1241581
public function canAccess(?ResourceAccessCheckerInterface $resourceAccessChecker, ResourceMetadata $resourceMetadata, string $resourceClass, ResolveInfo $info, $object = null, string $operationName = null): void
    {
        if (null === $resourceAccessChecker) {
            return;
        }

        $isGranted = $resourceMetadata->getGraphqlAttribute($operationName ?? '', 'access_control', null, true);
        if (null === $isGranted || $resourceAccessChecker->isGranted($resourceClass, $isGranted, ['object' => $object])) {
            return;
        }

        throw Error::createLocatedError($resourceMetadata->getGraphqlAttribute($operationName ?? '', 'access_control_message', 'Access Denied.'), $info->fieldNodes, $info->path);
    }
385055
public function create($token, $expireTime, $accessToken)
    {
        $this->getDbConnection()->insert('oauth_refresh_token', [
            'refresh_token' => $token,
            'access_token' => $accessToken,
            'expire_time' => $expireTime
        ]);
    }
161627
public function setAccessToken($token, $clientId, $userId, $expiryTimestamp, $scope = null)
    {
        $authTokenDataMapper = $this->getTokenDataMapper(Entity\AccessToken::class);

        $client = $this->getClientDataMapper()->findByUuid($clientId);

        if (! $accessToken = $authTokenDataMapper->findByToken($token)) {
            $accessToken = new Entity\AccessToken(null, $token, $client);
        } else {
            $accessToken->setClient($client);
        }

        if ($userId) {
            $user = $this->getUserDataMapper()->findByUuid($userId);

            if ($user instanceof $this->userClass) {
                $accessToken->setUser($user);
            }
        }

        $expiryDate = is_int($expiryTimestamp) ? new DateTime('@' . $expiryTimestamp) : null;
        $accessToken->setExpiryDate($expiryDate);

        if ($scope) {
            $scopes = $this->getScopeDataMapper()->findScopes(explode(' ', $scope));
            $accessToken->setScopes($scopes);
        }

        $authTokenDataMapper->save($accessToken);
    }
432504
public function createFeedPost($channelIdentifier, $accessToken, $content, $share = false)
    {
        if ($this->apiVersionIsGreaterThanV3() && !is_numeric($channelIdentifier)) {
            throw new InvalidIdentifierException('channel');
        }

        if (!is_string($content)) {
            throw new InvalidTypeException('Content', 'string', gettype($content));
        }

        if (!is_bool($share)) {
            throw new InvalidTypeException('Share', 'boolean', gettype($share));
        }

        $params = [
            'share' => $share,
            'content' => $content,
        ];

        return $this->post(sprintf('feed/%s/posts', $channelIdentifier), $params, $accessToken);
    }
575393
public function getBearerToken($grantType = 'client_credentials')
    {
        $request = $this->createRequest('/oauth2/token');
        $request->setPostParameter('grant_type', $grantType);
        $this->signRequest($request, new BasicToken());

        return $this->createBearerToken($this->sendRequest($request));
    }
628243
public function issueAccessToken()
    {
        $grantType = $this->getRequest()->request->get('grant_type');
        if (is_null($grantType)) {
            throw new Exception\InvalidRequestException('grant_type');
        }

        // Ensure grant type is one that is recognised and is enabled
        if (!in_array($grantType, array_keys($this->grantTypes))) {
            throw new Exception\UnsupportedGrantTypeException($grantType);
        }

        // Complete the flow
        return $this->getGrantType($grantType)->completeFlow();
    }
751529
protected function sendRequestWithClientParams($endpoint, array $params, $accessToken = null)
    {
        $params += $this->getClientParams();
        $params += [
            'grant_type' => 'authorization_code'
        ];

        $accessToken = $accessToken ?: $this->app->getAccessToken();

        $this->lastRequest = new SteeinRequest($this->app, $accessToken, 'POST', $endpoint, $params, null);
        return $this->client->sendRequest($this->lastRequest);
    }
1187696
protected function createAccessToken(array $response, AbstractGrant $grant)
  {
    if($grant instanceof FortifiGrant)
    {
      return $grant->handleResponse($response);
    }
    return new AccessToken($response);
  }
329449
public function hasGrantType($grantType)
    {
        $grants = explode(',', $this->Grants);

        return !empty($grants) && in_array($grantType, $grants);
    }
93209
public function changeAccessibilityDate(
        ResourceNode $node,
        $accessibleFrom,
        $accessibleUntil
    )
    {
        if ($node->getResourceType()->getName() === 'directory') {
            $descendants = $this->resourceNodeRepo->findDescendants($node);

            foreach ($descendants as $descendant) {
                $descendant->setAccessibleFrom($accessibleFrom);
                $descendant->setAccessibleUntil($accessibleUntil);
                $this->om->persist($descendant);
            }
            $this->om->flush();
        }
    }
721743
public function grantPermission($accessEntityUuid, $accessEntityClass, $accessLevel, $grantedBy)
    {
        return $this->permissionsDataSource->grantPermission($accessEntityUuid, $accessEntityClass, $accessLevel, $grantedBy);
    }
412137
public function add($roleUri, $accessUri)
    {
		$uri = explode('#', $accessUri);
		list($type, $ext, $mod, $act) = explode('_', $uri[1]);
		
		$role = new \core_kernel_classes_Resource($roleUri);
		$module = new \core_kernel_classes_Resource($this->makeEMAUri($ext, $mod));
		$actionAccessProperty = new \core_kernel_classes_Property(static::PROPERTY_ACL_GRANTACCESS);
		$moduleAccessProperty = new \core_kernel_classes_Property(static::PROPERTY_ACL_GRANTACCESS);
		
		$values = $role->getPropertyValues($actionAccessProperty);
		if (!in_array($accessUri, $values)) {
		    $role->setPropertyValue($actionAccessProperty, $accessUri);
            $this->getEventManager()->trigger(new AccessRightAddedEvent($roleUri, $accessUri));
            $controllerClassName = MapHelper::getControllerFromUri($module->getUri());
		    CacheHelper::flushControllerAccess($controllerClassName);
		} else {
		    \common_Logger::w('Tried to regrant access for role '.$role->getUri().' to action '.$accessUri);
		}
    }
74679
public function assert(
        Acl $acl,
        RoleInterface $role = null,
        ResourceInterface $resource = null,
        $privilege = null
    ) {
        if (!$role instanceof UserInterface || !$resource instanceof ApplicationInterface) {
            return false;
        }

        /* @var $resource ApplicationInterface|DraftableEntityInterface */

        $permissions = $resource->getPermissions();

        /* If application is a draft, only the associated user may view and edit.
         * As an anonymous user is not saved with the entity, we need to check the 'change' permission.
         */
        if ($resource->isDraft()) {
            return $role === $resource->getUser() || $permissions->isGranted($role, PermissionsInterface::PERMISSION_CHANGE);
        }

        if (ApplicationInterface::PERMISSION_SUBSEQUENT_ATTACHMENT_UPLOAD == $privilege) {
            // only applicant is allowed to upload subsequent attachments
            return $permissions->isAssigned($role) && $permissions->isGranted($role, PermissionsInterface::PERMISSION_VIEW);
        }
        
        $permission = 'read' == $privilege ? PermissionsInterface::PERMISSION_VIEW : PermissionsInterface::PERMISSION_CHANGE;
        return $permissions->isGranted($role, $permission);
    }
1253184
public function setAccessToken($accessToken)
    {
        if (is_string($accessToken)) {
            $accessToken = new AccessToken($accessToken);
        }
        if (is_object($accessToken) && $accessToken instanceof AccessToken) {
            $this->accessToken = $accessToken;
        } else {
            throw new \InvalidArgumentException('$accessToken must be instance of \LinkedIn\AccessToken class');
        }
        return $this;
    }
211414
public function issueToken(IAccessToken $accessToken)
    {
        $scopes = $accessToken->getScopes();

        // in case of doctrine collections, etc
        if ($scopes instanceof \Traversable) {
            $scopes = iterator_to_array($scopes);
        }

        return $this->refreshTokenStorage->generate(
            $accessToken->getUser(),
            $accessToken->getClient(),
            $scopes
        );
    }