public class AuthorizationService extends Object
RequestInterceptor.| Modifier and Type | Field and Description |
|---|---|
static DateTimeFormatter |
DONT_TRUNCATE_ZERO_MILLIS
The constant DONT_TRUNCATE_ZERO_MILIS.
|
| Constructor and Description |
|---|
AuthorizationService(BaseConfiguration configuration)
Instantiates a new Authorization service.
|
AuthorizationService(BaseConfiguration configuration,
com.licensespring.internal.services.DateProvider provider)
Instantiates a new Authorization service.
|
| Modifier and Type | Method and Description |
|---|---|
Map<String,String> |
addSignatureToHeaders(Map<String,String> headers)
Adds "Authorization" and "Content-Type" headers and adds them to provided Map.
|
PublicKey |
buildPublicKey()
Build public key from saved .pem file
|
void |
changeOAuthClientSecret(String clientSecret)
Changes the OAuth client secret
|
boolean |
checkSignature(LicenseData data,
String hardwareId,
LicenseIdentity licenseIdentity)
Checks if signature is valid.
|
boolean |
checkSignature(String signature,
String dataToVerify) |
String |
computeHMACSHA256(String stringToSign) |
String |
createOfflineSignature(String date,
String licenseKey,
String hardwareId,
String signingKey)
Creates signature by joining provided parameters with "\n".
|
String |
createSignature(Map<String,String> params)
Creates signature from the given parameters map.
|
String |
createSignature(String date,
String licenseKey,
String hardwareId,
String idKey)
Creates signature from provided parameters
|
String |
createSignatureString(Map<String,String> params)
Creates signature by joining all params with "\n"
|
Map<String,String> |
generateHeaders()
Generates "Authorization" and "Content-Type" headers.
|
OAuthTokenRequest |
getOAuthCredentials()
Gets the current OAuth credentials.
|
String |
hmac(String stringToSign)
Sign String with HMAC Algorithm
|
byte[] |
readPemFile()
Read .pem file from resources folder
|
void |
setDateProvider(com.licensespring.internal.services.DateProvider dateProvider)
Provider of the current date.
|
void |
updateOAuthCredentials(String clientId,
String clientSecret)
Updates OAuth credentials (both client ID and secret)
|
void |
verify(LicenseIdentity identity,
String hardwareId,
LicenseData licenseData)
Method for verifying signature that was used to sign request.
|
public static final DateTimeFormatter DONT_TRUNCATE_ZERO_MILLIS
public AuthorizationService(BaseConfiguration configuration, com.licensespring.internal.services.DateProvider provider)
configuration - the configurationprovider - the providerpublic AuthorizationService(BaseConfiguration configuration)
configuration - the configurationpublic void changeOAuthClientSecret(String clientSecret)
clientSecret - the new client secretpublic void updateOAuthCredentials(String clientId, String clientSecret)
public OAuthTokenRequest getOAuthCredentials()
public Map<String,String> generateHeaders()
public Map<String,String> addSignatureToHeaders(Map<String,String> headers)
headers - Headers mappublic String createSignature(Map<String,String> params)
params - Parameters mappublic String createSignature(String date, String licenseKey, String hardwareId, String idKey)
date - DatelicenseKey - License keyhardwareId - Hardware IDidKey - API key or client idpublic String createOfflineSignature(String date, String licenseKey, String hardwareId, String signingKey)
date - DatelicenseKey - License keyhardwareId - Hardware IDsigningKey - API key or client idpublic String createSignatureString(Map<String,String> params)
params - Params mappublic void verify(LicenseIdentity identity, String hardwareId, LicenseData licenseData)
identity - License identityhardwareId - Hardware IDlicenseData - License datapublic boolean checkSignature(LicenseData data, String hardwareId, LicenseIdentity licenseIdentity) throws GeneralSecurityException
data - License datahardwareId - Hardware IDlicenseIdentity - License identityGeneralSecurityException - a problem with verification datapublic boolean checkSignature(String signature, String dataToVerify) throws NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException, SignatureException
public PublicKey buildPublicKey() throws NoSuchAlgorithmException, InvalidKeySpecException
NoSuchAlgorithmException - the no such algorithm exceptionInvalidKeySpecException - the invalid key spec exceptionpublic byte[] readPemFile()
public String hmac(String stringToSign)
stringToSign - String to signpublic void setDateProvider(com.licensespring.internal.services.DateProvider dateProvider)
Copyright © 2026 Cense Data Inc.. All rights reserved.