public class Auth
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Auth.AuthMethod
Authentication methods
|
static class |
Auth.AuthOptions
Authentication options when instancing the Ably library
|
static interface |
Auth.TokenCallback
An interface implemented by a callback that provides either tokens,
or signed token requests, in response to a request with given token params.
|
static class |
Auth.TokenDetails
A class providing details of a token and its associated metadata,
provided when the system successfully requests a token from the system.
|
static class |
Auth.TokenParams
A class providing parameters of a token request.
|
static class |
Auth.TokenRequest
A class providing parameters of a token request.
|
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
clientId
The clientId for this library instance
Spec RSA7b
|
static java.lang.String |
WILDCARD_CLIENTID |
| Modifier and Type | Method and Description |
|---|---|
void |
assertAuthorizationHeader(boolean forceRenew)
Get the Authorization header, forcing the creation of a new token if requested
|
Auth.TokenDetails |
assertValidToken() |
Auth.TokenDetails |
authorise(Auth.TokenParams params,
Auth.AuthOptions options)
Deprecated.
|
Auth.TokenDetails |
authorize(Auth.TokenParams params,
Auth.AuthOptions options)
Ensure valid auth credentials are present.
|
java.lang.String |
checkClientId(BaseMessage msg,
boolean allowNullClientId,
boolean connected)
Verify that a message, possibly containing a clientId,
is compatible with Auth.clientId if it is set
|
void |
clearCachedServerTime()
For testing purposes we need method to clear cached timeDelta
|
Auth.TokenRequest |
createTokenRequest(Auth.TokenParams params,
Auth.AuthOptions options)
Create a signed token request based on known credentials
and the given token params.
|
Auth.AuthMethod |
getAuthMethod()
Get the authentication method for this library instance.
|
Auth.AuthOptions |
getAuthOptions()
Get (a copy of) auth options currently set in this Auth.
|
java.lang.String |
getAuthorizationHeader() |
Param[] |
getAuthParams()
Get query params representing the current authentication method and credentials.
|
java.lang.String |
getBasicCredentials()
Get the credentials for HTTP basic auth, if available.
|
java.lang.String |
getEncodedToken() |
Auth.TokenDetails |
getTokenDetails() |
void |
onAuthError(ErrorInfo err) |
Auth.TokenDetails |
renew()
Renew auth credentials.
|
Auth.TokenDetails |
requestToken(Auth.TokenParams params,
Auth.AuthOptions tokenOptions)
Make a token request.
|
long |
serverTimestamp()
Using time delta obtained before guess current server time
|
void |
setClientId(java.lang.String clientId)
Set the clientId, after first initialisation in the construction of the library
therefore an existing null value is significant - it means that ClientOptions.clientId
was null
|
static long |
timestamp() |
public java.lang.String clientId
public static final java.lang.String WILDCARD_CLIENTID
public Auth.TokenDetails authorize(Auth.TokenParams params, Auth.AuthOptions options) throws AblyException
params - an object containing the request params:
- key: (optional) the key to use; if not specified, the key
passed in constructing the Rest interface may be used
- ttl: (optional) the requested life of any new token in ms. If none
is specified a default of 1 hour is provided. The maximum lifetime
is 24hours; any request exceeeding that lifetime will be rejected
with an error.
- capability: (optional) the capability to associate with the access token.
If none is specified, a token will be requested with all of the
capabilities of the specified key.
- clientId: (optional) a client Id to associate with the token
- timestamp: (optional) the time in ms since the epoch. If none is specified,
the system will be queried for a time value to use.
- queryTime (optional) boolean indicating that the Ably system should be
queried for the current time when none is specified explicitly.options - AblyException@Deprecated public Auth.TokenDetails authorise(Auth.TokenParams params, Auth.AuthOptions options) throws AblyException
AblyExceptionpublic Auth.TokenDetails requestToken(Auth.TokenParams params, Auth.AuthOptions tokenOptions) throws AblyException
params - : see authorize(io.ably.lib.rest.Auth.TokenParams, io.ably.lib.rest.Auth.AuthOptions) for paramstokenOptions - : see authorize(io.ably.lib.rest.Auth.TokenParams, io.ably.lib.rest.Auth.AuthOptions) for optionsAblyExceptionpublic Auth.TokenRequest createTokenRequest(Auth.TokenParams params, Auth.AuthOptions options) throws AblyException
params - : see authorize(io.ably.lib.rest.Auth.TokenParams, io.ably.lib.rest.Auth.AuthOptions) for paramsoptions - : see authorize(io.ably.lib.rest.Auth.TokenParams, io.ably.lib.rest.Auth.AuthOptions) for optionsAblyExceptionpublic Auth.AuthMethod getAuthMethod()
public java.lang.String getBasicCredentials()
public Param[] getAuthParams() throws AblyException
AblyExceptionpublic Auth.AuthOptions getAuthOptions()
public Auth.TokenDetails renew() throws AblyException
AblyExceptionpublic void onAuthError(ErrorInfo err)
public static long timestamp()
public Auth.TokenDetails getTokenDetails()
public java.lang.String getEncodedToken()
public Auth.TokenDetails assertValidToken() throws AblyException
AblyExceptionpublic void assertAuthorizationHeader(boolean forceRenew)
throws AblyException
forceRenew - AblyExceptionpublic java.lang.String getAuthorizationHeader()
public void setClientId(java.lang.String clientId)
throws AblyException
clientId - AblyExceptionpublic java.lang.String checkClientId(BaseMessage msg, boolean allowNullClientId, boolean connected) throws AblyException
msg - allowNullClientId: - true if it is ok for there to be no resolved clientIdconnected: - true if connected; if false it is ok for the library to be unidentifiedAblyExceptionpublic long serverTimestamp()
public void clearCachedServerTime()