Return the type (OAuth1 or OAuth2) of given resource owner.

@param string $resourceOwner

@return string
962330
public static function getResourceOwnerType($resourceOwner)
    {
        $resourceOwner = strtolower($resourceOwner);
        if ('oauth1' === $resourceOwner || 'oauth2' === $resourceOwner) {
            return $resourceOwner;
        }

        if (\in_array($resourceOwner, static::$resourceOwners['oauth1'], true)) {
            return 'oauth1';
        }

        return 'oauth2';
    }
436982
def get_instance_type(self, port):
        """"""
        if port[portbindings.VNIC_TYPE] == portbindings.VNIC_BAREMETAL:
            return a_const.BAREMETAL_RESOURCE
        owner_to_type = {
            n_const.DEVICE_OWNER_DHCP: a_const.DHCP_RESOURCE,
            n_const.DEVICE_OWNER_DVR_INTERFACE: a_const.ROUTER_RESOURCE,
            trunk_consts.TRUNK_SUBPORT_OWNER: a_const.VM_RESOURCE}
        if port['device_owner'] in owner_to_type.keys():
            return owner_to_type[port['device_owner']]
        elif port['device_owner'].startswith(
                n_const.DEVICE_OWNER_COMPUTE_PREFIX):
            return a_const.VM_RESOURCE
        return None
939778
public function setOwner($user) {
		if ($this->isLink()) {
			return lchown($this->pathname, $user);
		} else {
			return chown($this->pathname, $user);
		}
	}
97939
protected function bootAuthResourceOwner()
	{
		if (config('api.auth_resource_owner', true)
			&& !Auth::check()
			&& Request::input('access_token', Request::header('Authorization'))
		) {
			if ($user_id = Authentication::instance()->userId()) {
				Auth::onceUsingId($user_id);
			}
		}
	}
155288
protected function getOwner() {
    $uid = NULL;

    if ($account = $this->currentUser->getAccount()) {
      $uid = $account->id();

      // Check if the user had stored "session" data before loggin in, and use
      // that "session" id as the owner instead of user id.
      if ($owner = $this->getOwnerReference($uid)) {
        return $owner;
      }
    }

    $cookies = $this->getCookies();
    if (!empty($cookies['Drupal_visitor_' . self::SESSION_ID_COOKIE])) {
      $sid = $cookies['Drupal_visitor_' . self::SESSION_ID_COOKIE];
      // If there's a logged in user and a stored "session" id cookie we want
      // to create a reference to it so if they log in on a different computer
      // they can retrieve their "session" data.
      if ($uid) {
        $this->setOwnerReference($uid, $sid);
      }

      return $sid;
    }

    // If user is logged in use their id as the owner.
    if ($uid) {
      return $uid;
    }

    // If we got this far it's an anonymous user (drupal and commerce), so
    // generate a "session" id and save it for later use.
    $sid = $this->generateSessionId();
    $this->setCookie(self::SESSION_ID_COOKIE, $sid);

    return $sid;
  }
201411
protected function getResourceName($resource)
    {
        if ($resource instanceof ResourceInterface) {
            $resource = $resource->getName();
        }

        if (false === is_string($resource)) {
            throw new InvalidArgumentException(
                'Resource argument must be string or an object implemented "Rad\Authorization\Rbac\ResourceInterface".'
            );
        }

        return $resource;
    }
44623
private function getResourceObjectType(?string $resourceClass, ResourceMetadata $resourceMetadata, bool $input, ?string $queryName, ?string $mutationName, bool $wrapped = false, int $depth = 0): GraphQLType
    {
        $shortName = $resourceMetadata->getShortName();

        if (null !== $mutationName) {
            $shortName = $mutationName.ucfirst($shortName);
        }
        if ($input) {
            $shortName .= 'Input';
        } elseif (null !== $mutationName) {
            if ($depth > 0) {
                $shortName .= 'Nested';
            }
            $shortName .= 'Payload';
        }
        if ($wrapped && null !== $mutationName) {
            $shortName .= 'Data';
        }

        if (isset($this->graphqlTypes[$shortName])) {
            return $this->graphqlTypes[$shortName];
        }

        $ioMetadata = $resourceMetadata->getGraphqlAttribute(null === $mutationName ? 'query' : $mutationName, $input ? 'input' : 'output', null, true);
        if (null !== $ioMetadata && \array_key_exists('class', $ioMetadata) && null !== $ioMetadata['class']) {
            $resourceClass = $ioMetadata['class'];
        }

        $wrapData = !$wrapped && null !== $mutationName && !$input && $depth < 1;

        $configuration = [
            'name' => $shortName,
            'description' => $resourceMetadata->getDescription(),
            'resolveField' => $this->defaultFieldResolver,
            'fields' => function () use ($resourceClass, $resourceMetadata, $input, $mutationName, $queryName, $wrapData, $depth, $ioMetadata) {
                if ($wrapData) {
                    $queryNormalizationContext = $resourceMetadata->getGraphqlAttribute($queryName ?? 'query', 'normalization_context', [], true);
                    $mutationNormalizationContext = $resourceMetadata->getGraphqlAttribute($mutationName ?? '', 'normalization_context', [], true);
                    // Use a new type for the wrapped object only if there is a specific normalization context for the mutation.
                    // If not, use the query type in order to ensure the client cache could be used.
                    $useWrappedType = $queryNormalizationContext !== $mutationNormalizationContext;

                    return [
                        lcfirst($resourceMetadata->getShortName()) => $useWrappedType ?
                            $this->getResourceObjectType($resourceClass, $resourceMetadata, $input, $queryName, $mutationName, true, $depth) :
                            $this->getResourceObjectType($resourceClass, $resourceMetadata, $input, $queryName, null, true, $depth),
                        'clientMutationId' => GraphQLType::string(),
                    ];
                }

                return $this->getResourceObjectTypeFields($resourceClass, $resourceMetadata, $input, $queryName, $mutationName, $depth, $ioMetadata);
            },
            'interfaces' => $wrapData ? [] : [$this->getNodeInterface()],
        ];

        return $this->graphqlTypes[$shortName] = $input ? GraphQLType::nonNull(new InputObjectType($configuration)) : new ObjectType($configuration);
    }
1105301
public function getResourceUserPermission(ResourceInterface $resource, UserInterface $user)
    {
        $query = $this->getRepository()->createQueryBuilder('r')
            ->select('r')
            ->where('r.resource_class = :resourceClass AND r.resource_id=:resourceId AND r.user=:user')
            ->setParameter('resourceClass', $resource->getClass())
            ->setParameter('resourceId', $resource->getId())
            ->setParameter('user', $user)
            ->getQuery();

        return $query->getOneOrNullResult();
    }
1370357
function isAllowed(/*iAuthResource*/ $resource = null, /*iIdentity*/ $role = null)
    {
        $role = ($role) ?: $this->getAuthAdapter()->identity();

        if (!is_object($resource)
            || (!$resource instanceof PermResource || !method_exists($resource, 'getRouteName'))
        )
            throw new \Exception('Invalid Resource Type, Can`t Check The Permissions.');

        // All has access on home, but authorized users has access on other routes
        return ($resource->getRouteName() == 'home' || $role->hasAuthenticated());
    }
437767
public function getOwnerUser()
    {
        $reflection = ClassUtils::newReflectionObject($this);

        if ($reflection->hasMethod('getUser')) {
            return $this->getUser();
        }
        elseif ($reflection->hasMethod('getUserProfile')) {
            return $this->getUserProfile() ? $this->getUserProfile()->getUser() : null;
        }

        return null;
    }
1131827
private function getResourcesType(string $className): ?string
    {
        $resourceType = null;
        if (array_key_exists(ResourceAuthorizationRulesInterface::class, class_implements($className)) === true) {
            /** @var ResourceAuthorizationRulesInterface $className */
            $resourceType = $className::getResourcesType();
        }

        return $resourceType;
    }
157142
protected function createResourceOwner(array $response, AccessToken $token)
  {
    $result = isset($response['result']) ? $response['result'] : [];

    /**
     * @var $result AuthUserDetailsResponse
     */
    if(!($result instanceof AuthUserDetailsResponse))
    {
      $result = AuthUserDetailsResponse::make($result);
    }
    $user = new OAuthUser(
      [
        'uid'         => $result->userFid,
        'nickname'    => ValueAs::nonempty(
          $result->displayName,
          $result->firstName,
          $result->lastName,
          $result->username,
          $result->userFid
        ),
        'locale'      => $result->language,
        'location'    => $result->timezone,
        'name'        => $result->displayName,
        'imageUrl'    => $result->avatarUrl,
        'firstName'   => $result->firstName,
        'lastName'    => $result->lastName,
        'description' => $result->description,
        'email'       => $result->username,
      ], $result->userFid
    );
    $user->setAuthUserDetails($result);
    return $user;
  }
597122
public function getResourceUri($resource)
    {
        if (! Str::contains($resource, '.')) {
            return $resource;
        }

        // Once we have built the base URI, we'll remove the wildcard holder for this
        // base resource name so that the individual route adders can suffix these
        // paths however they need to, as some do not have any wildcards at all.
        $segments = explode('.', $resource);

        $uri = $this->getNestedResourceUri($segments);

        return str_replace('/{'.$this->getResourceWildcard(end($segments)).'}', '', $uri);
    }
41901
function getOwnerId()
    {
        if ($this->withIdentity() instanceof iIdentityOfUser)
        {
            /** @var IdentityOAuthToken|iIdentityOfUser $identity */
            $identity = $this->withIdentity();
            $userId   = $identity->getOwnerId();
        }
        else
        {
            $userInfo = $this->getAuthInfo();
            $userId   = $userInfo['user']['uid'];
        }


        return $userId;
    }
1056222
private function getSettingsFromRepository(SettingsOwnerInterface $owner = null)
    {
        $settings = array();

        foreach (array_keys($this->settingsConfiguration) as $name) {
            try {
                $this->validateSetting($name, $owner);
                $settings[$name] = null;
            } catch (WrongScopeException $e) {
                continue;
            }
        }

        /** @var Setting $setting */
        foreach ($this->repository->findBy(
            array('ownerId' => $owner === null ? null : $owner->getSettingIdentifier())
        ) as $setting) {
            if (array_key_exists($setting->getName(), $settings)) {
                $settings[$setting->getName()] = $this->serializer->unserialize($setting->getValue());
            }
        }

        return $settings;
    }
974082
public function getRegistrar()
    {
        if (isset($this->registrar)) {
            return $this->registrar;
        }

        return $this->registrar = new ResourceRegistrar($this);
    }
484395
public function getAdminOwner()
    {
        $repo = $this->dm->getRepository($this->organizationClass);

        return $repo->findOneBy([
            'adminOwner' => true
        ]);
    }