Overview

Namespaces

  • Genetsis
    • core
      • activityid
      • user
  • None

Classes

  • AccessToken
  • ClientToken
  • Encryption
  • FileCache
  • LogConfig
  • LoginStatus
  • LoginStatusType
  • OAuth
  • OAuthConfig
  • OauthTemplate
  • RefreshToken
  • Request
  • StoredToken
  • Things
  • User

Interfaces

  • iTokenTypes

Exceptions

  • InvalidGrantException
  • Overview
  • Namespace
  • Class

Class OAuth

This class wraps all methods for interactions with OAuth service, for user authentication and validation. Also generates the URLs to perform this operations as register or login.

Namespace: Genetsis\core
Package: Genetsis
Category: Helper
Version: 1.0
Located at core/OAuth.php
Methods summary
public static mixed
# doGetClientToken( string $endpoint_url )

Gets a "client_token" for the current web client.

Gets a "client_token" for the current web client.

Parameters

$endpoint_url
The endpoint where "client_token" is requested.

Returns

mixed

An instance of Genetsis\core\ClientToken with data retrieved or FALSE.

Throws

Exception
If there is an error.
public static
# storeToken( Genetsis\core\StoredToken $token )

Stores a token in a cookie

Stores a token in a cookie

Parameters

$token
An object with token data to be stored.

Throws

Exception
public static mixed
# doGetAccessToken( string $endpoint_url, string $code, string $redirect_url )

Gets an "access_token" for the current web client.

Gets an "access_token" for the current web client.

Parameters

$endpoint_url
The endpoint where "access_token" is requested.
$code
The authorization code returned by Genetsis ID.
$redirect_url
Where the user will be redirected.

Returns

mixed

An instance of Genetsis\core\AccessToken with data retrieved or FALSE.

Throws

Exception
If there is an error.
public static boolean
# doRefreshToken( string $endpoint_url )

Updates tokens.

Updates tokens.

Parameters

$endpoint_url
The endpoint where the request will be sent.

Returns

boolean

TRUE if the tokens have been updated or FALSE otherwise.

Throws

Exception
If there is an error.
public static Genetsis\core\LoginStatus
# doValidateBearer( string $endpoint_url )

Checks if user is logged.

Checks if user is logged.

Parameters

$endpoint_url
The endpoint where the request will be sent.

Returns

Genetsis\core\LoginStatus
An object with user status.

Throws

Exception
If there is an error.
public static mixed
# doExchangeSession( string $endpoint_url, string $cookie_value )

Checks if user is logged by Exchange Session (SSO)

Checks if user is logged by Exchange Session (SSO)

Parameters

$endpoint_url
The endpoint where the request will be sent.
$cookie_value
The content of the cookie that stores the SSO.

Returns

mixed

An instance of Genetsis\core\AccessToken if its connected or NULL if not.

Throws

Exception
If there is an error.
public static
# doLogout( string $endpoint_url )

Performs revocation process. Removes all tokens from that user.

Performs revocation process. Removes all tokens from that user.

Parameters

$endpoint_url
The endpoint where the request will be sent.

Throws

Exception
If there is an error.
public static
# deleteStoredToken( string $name )

Removes a specific token.

Removes a specific token.

It will removed from SESSION and COOKIE.

Parameters

$name
token we want to remove. Are defined in Genetsis\core\iTokenTypes
public static boolean
# hasToken( string $name )

Checks if we have a specific token.

Checks if we have a specific token.

Parameters

$name
The token we want to check. Are defined in Genetsis\core\iTokenTypes

Returns

boolean
TRUE if exists or FALSE otherwise.
public static boolean|Genetsis\core\AccessToken|Genetsis\core\ClientToken|Genetsis\core\RefreshToken|mixed|string
# getStoredToken( string $name )

Returns a specific stored token. SESSION has more priority than COOKIE.

Returns a specific stored token. SESSION has more priority than COOKIE.

Parameters

$name
The token we want to recover. Are defined in Genetsis\core\iTokenTypes

Returns

boolean|Genetsis\core\AccessToken|Genetsis\core\ClientToken|Genetsis\core\RefreshToken|mixed|string

An instance of Genetsis\core\StoredToken or FALSE if we can't recover it.

Throws

Exception
public static mixed
# doGetOpinator( string $endpoint_url, string $scope, Genetsis\core\StoredToken $token )

Get The Url for access to the Opinator.

Get The Url for access to the Opinator.

Parameters

$endpoint_url
The endpoint where the request will be sent.
$scope
Section-key identifier of the web client propietary of Opinator
$token
Token

Returns

mixed
$token Token, an access_token if user is logged, a client_token if user is not login

Throws

Exception
If there is an error.
public static boolean
# doCheckUserCompleted( string $endpoint_url, string $scope )

Checks if the user has completed all required data for the specified section (scope).

Checks if the user has completed all required data for the specified section (scope).

Parameters

$endpoint_url
The endpoint where the request will be sent.
$scope

Section-key identifier of the web client. The section-key is located in "oauthconf.xml" file.

Returns

boolean

TRUE if the user has completed all required data or FALSE if not.

Throws

Exception
If there is an error.
Constants summary
string GRANT_TYPE_AUTH_CODE

Different AUTH method.

Different AUTH method.

# 'authorization_code'
string GRANT_TYPE_REFRESH_TOKEN
# 'refresh_token'
string GRANT_TYPE_CLIENT_CREDENTIALS
# 'client_credentials'
string GRANT_TYPE_VALIDATE_BEARER
# 'urn:es.cocacola:oauth2:grant_type:validate_bearer'
string GRANT_TYPE_EXCHANGE_SESSION
# 'urn:es.cocacola:oauth2:grant_type:exchange_session'
integer DEFAULT_EXPIRES_IN

Default expiration time. In seconds.

Default expiration time. In seconds.

# 900
float SAFETY_RANGE_EXPIRES_IN

Indicates the percentage to be subtracted from the number of seconds of "expires_in" to not be so close to the expiration date of the token.

Indicates the percentage to be subtracted from the number of seconds of "expires_in" to not be so close to the expiration date of the token.

# 0.10
string SSO_COOKIE_NAME

Cookie name for SSO (Single Sign-Out).

Cookie name for SSO (Single Sign-Out).

# 'datr'
API documentation generated by ApiGen