|
dxFeed Graal CXX API v9.0.0
|
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 (StringParam string) |
| Constructs an AuthToken from the specified string. | |
| static AuthToken | createBasicToken (StringParam userPassword) |
| Constructs an AuthToken with the specified username and password per RFC2617. | |
| static AuthToken | createBasicToken (StringParam user, StringParam password) |
| Constructs an AuthToken with the specified username and password per RFC2617. | |
| static AuthToken | createBasicTokenOrNull (StringParam user, StringParam password) |
| Constructs an AuthToken with the specified username and password per RFC2617. | |
| static AuthToken | createBearerToken (StringParam token) |
| Constructs an AuthToken with the specified bearer token per RFC6750. | |
| static AuthToken | createBearerTokenOrNull (StringParam token) |
| Constructs an AuthToken with the specified bearer token per RFC6750. | |
| static AuthToken | createCustomToken (StringParam scheme, StringParam value) |
| Constructs an AuthToken with a custom scheme and value. | |
Static Public Attributes | |
| static constexpr char | BASIC_SCHEME [] = "Basic" |
| String representation for Basic (Base64(login:password)) authorization. | |
| static constexpr char | BEARER_SCHEME [] = "Bearer" |
| String representation for the Bearer (token) authorization. | |
| static const AuthToken | NULL_TOKEN {} |
| A stub that is needed to simulate null AuthToken without using std::optional. | |
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:
|
static |
Constructs an AuthToken with the specified username and password per RFC2617.
Username and password can be empty.
| user | The username. |
| password | The password. |
| InvalidArgumentException | if the username or the password is not valid UTF-8 (the message names the offset, not the bytes). |
|
static |
Constructs an AuthToken with the specified username and password per RFC2617.
Username and password can be empty.
| userPassword | the string (or c-string or string view) containing the username and password in the format "username:password" |
| InvalidArgumentException | if the userPassword is not valid UTF-8 (the message names the offset, not the bytes). |
| JavaException("InvalidFormatException") | if the userPassword is malformed |
|
static |
Constructs an AuthToken with the specified username and password per RFC2617.
If both the username and password are empty, returns AuthToken::NULL_TOKEN.
| user | the username |
| password | the password |
|
static |
Constructs an AuthToken with the specified bearer token per RFC6750.
| token | the access token |
| InvalidArgumentException | if the token is not valid UTF-8 (the message names the offset, not the bytes). |
| JavaException("InvalidFormatException") | if the token is empty |
|
static |
Constructs an AuthToken with the specified bearer token per RFC6750.
| token | the access token |
|
static |
Constructs an AuthToken with a custom scheme and value.
| scheme | the custom scheme |
| value | the custom value |
| InvalidArgumentException | if the scheme or the value is not valid UTF-8 (for the value the message names the offset, not the bytes). |
| JavaException("InvalidFormatException") | if the scheme or value is empty |
| std::string AuthToken::getHttpAuthorization | ( | ) | const |
Returns the HTTP authorization header value.
References String::NUL.
| std::string AuthToken::getPassword | ( | ) | const |
Returns the password or dxfcpp::String::NUL (std::string{"<null>"}) if it is not known or applicable.
References String::NUL.
| std::string AuthToken::getScheme | ( | ) | const |
| std::string AuthToken::getUser | ( | ) | const |
Returns the username or dxfcpp::String::NUL (std::string{"<null>"}) if it is not known or applicable.
References String::NUL.
| std::string AuthToken::getValue | ( | ) | const |
Returns the access token for RFC6750 or the Base64-encoded "username:password" for RFC2617.
References String::NUL.
|
static |
Constructs an AuthToken from the specified string.
| string | The string (or c-string or string view) with a space-separated scheme and value. |
| JavaException("InvalidFormatException") | if the string is malformed, or if the scheme is "Basic" but the format does not comply with RFC2617 |