Package net.solarnetwork.security
Class SnsAuthorizationBuilder
java.lang.Object
net.solarnetwork.security.AbstractAuthorizationBuilder<SnsAuthorizationBuilder>
net.solarnetwork.security.SnsAuthorizationBuilder
Builder for
Authorization header values using the SolarNode Setup
(SNS) authentication scheme.
This helper is designed with different communication protocols in mind, such as HTTP and STOMP, so the terms used are generic enough to apply in different contexts.
- Since:
- 1.78
- Version:
- 1.0
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe authorization scheme name.static final StringThe message used to sign the derived signing key.Fields inherited from class net.solarnetwork.security.AbstractAuthorizationBuilder
AUTHORIZATION_COMPONENT_CREDENTIAL, AUTHORIZATION_COMPONENT_HEADERS, AUTHORIZATION_COMPONENT_SIGNATURE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringcomputeCanonicalRequestMessage(String[] headerNames) Compute the canonical request message.Set the request date.reset()Reset all values to their defaults.protected StringGet the authorization scheme name.protected StringGet the signing key message.Methods inherited from class net.solarnetwork.security.AbstractAuthorizationBuilder
appendContentSha256, appendHeaders, build, build, buildSignature, buildSignature, computeCanonicalRequestMessage, computeSignatureData, computeSigningKey, contentSha256, getContentSha256, getDate, getHeaders, getPath, getVerb, header, headers, headerValue, headerValues, host, path, saveSigningKey, signingKey, signingKeyHex, sortedHeaderNames, verb
-
Field Details
-
SCHEME_NAME
The authorization scheme name.- See Also:
-
SIGNING_KEY_MESSAGE
The message used to sign the derived signing key.- See Also:
-
-
Constructor Details
-
SnsAuthorizationBuilder
Construct with a credential.The builder will be initialized and then
reset()will be called so default values are configured.- Parameters:
identifier- the bearer's identifier, such as a token ID or username
-
-
Method Details
-
reset
Reset all values to their defaults.All properties will be set to null except the following:
- verb
- will be set to GET
- path
- Will be set to /
- date
- will be set to the current time
- signingKey
- this value will not be changed
- Overrides:
resetin classAbstractAuthorizationBuilder<SnsAuthorizationBuilder>- Returns:
- The builder.
-
date
Set the request date.This will also set the date header with the date's formatted value.
- Overrides:
datein classAbstractAuthorizationBuilder<SnsAuthorizationBuilder>- Parameters:
date- the date to use, or null for the current system time viaInstant.now(); will be truncated to second resolution- Returns:
- this builder
-
signingKeyMessageLiteral
Description copied from class:AbstractAuthorizationBuilderGet the signing key message.- Specified by:
signingKeyMessageLiteralin classAbstractAuthorizationBuilder<SnsAuthorizationBuilder>- Returns:
- the signing key message
-
schemeName
Description copied from class:AbstractAuthorizationBuilderGet the authorization scheme name.- Specified by:
schemeNamein classAbstractAuthorizationBuilder<SnsAuthorizationBuilder>- Returns:
- the scheme name
-
computeCanonicalRequestMessage
Description copied from class:AbstractAuthorizationBuilderCompute the canonical request message.- Specified by:
computeCanonicalRequestMessagein classAbstractAuthorizationBuilder<SnsAuthorizationBuilder>- Parameters:
headerNames- the header names to include in the signature- Returns:
- the canonical request message
-