dxFeed Graal CXX API v4.0.0
Loading...
Searching...
No Matches
AuthToken Struct Reference

The AuthToken class represents an authorization token and encapsulates information about the authorization scheme and its associated value. More...

#include <AuthToken.hpp>

Public Member Functions

std::string getHttpAuthorization () const
 Returns the HTTP authorization header value.
 
std::string getUser () const
 Returns the username or dxfcpp::String::NUL (std::string{"<null>"}) if it is not known or applicable.
 
std::string getPassword () const
 Returns the password or dxfcpp::String::NUL (std::string{"<null>"}) if it is not known or applicable.
 
std::string getScheme () const
 Returns the authentication scheme.
 
std::string getValue () const
 Returns the access token for RFC6750 or the Base64-encoded "username:password" for RFC2617.
 

Static Public Member Functions

static AuthToken valueOf (const StringLikeWrapper &string)
 Constructs an AuthToken from the specified string.
 
static AuthToken createBasicToken (const StringLikeWrapper &userPassword)
 Constructs an AuthToken with the specified username and password per RFC2617.
 
static AuthToken createBasicToken (const StringLikeWrapper &user, const StringLikeWrapper &password)
 Constructs an AuthToken with the specified username and password per RFC2617.
 
static AuthToken createBasicTokenOrNull (const StringLikeWrapper &user, const StringLikeWrapper &password)
 Constructs an AuthToken with the specified username and password per RFC2617.
 
static AuthToken createBearerToken (const StringLikeWrapper &token)
 Constructs an AuthToken with the specified bearer token per RFC6750.
 
static AuthToken createBearerTokenOrNull (const StringLikeWrapper &token)
 Constructs an AuthToken with the specified bearer token per RFC6750.
 
static AuthToken createCustomToken (const StringLikeWrapper &scheme, const StringLikeWrapper &value)
 Constructs an AuthToken with a custom scheme and value.
 

Detailed Description

The AuthToken class represents an authorization token and encapsulates information about the authorization scheme and its associated value.

An AuthToken consists of the following components:

  • Scheme - The authorization scheme (e.g., "Basic" or "Bearer").
  • Value - The encoded value, which is scheme-dependent (e.g., an access token per RFC6750 or Base64-encoded "user:password" per RFC2617).
  • String representation - A string that combines the scheme and value in the format: [scheme + " " + value].

Member Function Documentation

◆ createBasicToken() [1/2]

AuthToken AuthToken::createBasicToken ( const StringLikeWrapper & user,
const StringLikeWrapper & password )
static

Constructs an AuthToken with the specified username and password per RFC2617.

Username and password can be empty.

Parameters
userThe username.
passwordThe password.
Returns
The constructed AuthToken.

◆ createBasicToken() [2/2]

AuthToken AuthToken::createBasicToken ( const StringLikeWrapper & userPassword)
static

Constructs an AuthToken with the specified username and password per RFC2617.

Username and password can be empty.

Parameters
userPasswordthe string (or c-string or string view) containing the username and password in the format "username:password"
Returns
The constructed AuthToken.
Exceptions
JavaException("InvalidFormatException")if the userPassword is malformed

◆ createBasicTokenOrNull()

AuthToken AuthToken::createBasicTokenOrNull ( const StringLikeWrapper & user,
const StringLikeWrapper & password )
static

Constructs an AuthToken with the specified username and password per RFC2617.

If both the username and password are empty returns AuthToken::NULL_TOKEN.

Parameters
userthe username
passwordthe password
Returns
the constructed AuthToken or AuthToken::NULL_TOKEN

◆ createBearerToken()

AuthToken AuthToken::createBearerToken ( const StringLikeWrapper & token)
static

Constructs an AuthToken with the specified bearer token per RFC6750.

Parameters
tokenthe access token
Returns
the constructed AuthToken
Exceptions
JavaException("InvalidFormatException")if the token is empty

◆ createBearerTokenOrNull()

AuthToken AuthToken::createBearerTokenOrNull ( const StringLikeWrapper & token)
static

Constructs an AuthToken with the specified bearer token per RFC6750.

Parameters
tokenthe access token
Returns
the constructed AuthToken or AuthToken::NULL_TOKEN.

◆ createCustomToken()

AuthToken AuthToken::createCustomToken ( const StringLikeWrapper & scheme,
const StringLikeWrapper & value )
static

Constructs an AuthToken with a custom scheme and value.

Parameters
schemethe custom scheme
valuethe custom value
Returns
the constructed AuthToken
Exceptions
JavaException("InvalidFormatException")if the scheme or value is empty

◆ getHttpAuthorization()

std::string AuthToken::getHttpAuthorization ( ) const

Returns the HTTP authorization header value.

Returns
the HTTP authorization header value

◆ getPassword()

std::string AuthToken::getPassword ( ) const

Returns the password or dxfcpp::String::NUL (std::string{"<null>"}) if it is not known or applicable.

Returns
the password, or dxfcpp::String::NUL (std::string{"<null>"}) if not known or applicable

◆ getScheme()

std::string AuthToken::getScheme ( ) const

Returns the authentication scheme.

Returns
the authentication scheme

◆ getUser()

std::string AuthToken::getUser ( ) const

Returns the username or dxfcpp::String::NUL (std::string{"<null>"}) if it is not known or applicable.

Returns
the username, or dxfcpp::String::NUL (std::string{"<null>"}) if not known or applicable

◆ getValue()

std::string AuthToken::getValue ( ) const

Returns the access token for RFC6750 or the Base64-encoded "username:password" for RFC2617.

Returns
the access token or Base64-encoded "username:password"

◆ valueOf()

AuthToken AuthToken::valueOf ( const StringLikeWrapper & string)
static

Constructs an AuthToken from the specified string.

Parameters
stringThe string (or c-string or string view) with space-separated scheme and value.
Returns
The constructed AuthToken.
Exceptions
JavaException("InvalidFormatException")if the string is malformed, or if the scheme is "Basic" but the format does not comply with RFC2617
See also
toString()