com.netease.cloud.auth
public abstract class AbstractSigner extends Object implements Signer
Not intended to be sub-classed by developers.
Constructor and Description |
---|
AbstractSigner() |
Modifier and Type | Method and Description |
---|---|
protected String |
getCanonicalizedEndpoint(URI endpoint) |
protected String |
getCanonicalizedQueryString(Map<String,String> parameters)
Examines the specified query string parameters and returns a
canonicalized form.
|
protected String |
getCanonicalizedQueryString(Request<?> request) |
protected String |
getCanonicalizedResourcePath(String resourcePath) |
protected String |
getRequestPayload(Request<?> request) |
protected String |
getRequestPayloadWithoutQueryParams(Request<?> request) |
protected byte[] |
hash(String text)
Hashes the string contents (assumed to be UTF-8) using the SHA-256
algorithm.
|
protected Credentials |
sanitizeCredentials(Credentials credentials)
Loads the individual access key ID and secret key from the specified
credentials, ensuring that access to the credentials is synchronized on
the credentials object itself, and trimming any extra whitespace from the
credentials.
|
protected byte[] |
sign(byte[] data,
byte[] key,
SigningAlgorithm algorithm) |
protected byte[] |
sign(String stringData,
byte[] key,
SigningAlgorithm algorithm) |
protected String |
signAndBase64Encode(byte[] data,
String key,
SigningAlgorithm algorithm)
Computes an RFC 2104-compliant HMAC signature for an array of bytes and
returns the result as a Base64 encoded string.
|
protected String |
signAndBase64Encode(String data,
String key,
SigningAlgorithm algorithm)
Computes an RFC 2104-compliant HMAC signature and returns the result as a
Base64 encoded string.
|
protected String signAndBase64Encode(String data, String key, SigningAlgorithm algorithm) throws ClientException
ClientException
protected String signAndBase64Encode(byte[] data, String key, SigningAlgorithm algorithm) throws ClientException
ClientException
protected byte[] sign(String stringData, byte[] key, SigningAlgorithm algorithm) throws ClientException
ClientException
protected byte[] sign(byte[] data, byte[] key, SigningAlgorithm algorithm) throws ClientException
ClientException
protected byte[] hash(String text) throws ClientException
text
- The string to hash.ClientException
- If the hash cannot be computed.protected String getCanonicalizedQueryString(Map<String,String> parameters)
The canonicalized query string is formed by first sorting all the query string parameters, then URI encoding both the key and value and then joining them, in order, separating key value pairs with an '&'.
parameters
- The query string parameters to be canonicalized.protected String getRequestPayloadWithoutQueryParams(Request<?> request)
protected Credentials sanitizeCredentials(Credentials credentials)
Returns either a BasicSessionCredentials
or a
BasicCredentials
object, depending on the input type.
credentials
- Copyright © 2017. All Rights Reserved.