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
|
boolean |
checkSignature(LicenseData data,
String hardwareId,
LicenseIdentity licenseIdentity)
Checks if signature is valid.
|
boolean |
checkSignature(String signature,
String dataToVerify) |
String |
createOfflineSignature(String date,
String licenseKey,
String hardwareId,
String apiKey)
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 apiKey)
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.
|
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 |
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 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 apiKey)
date - DatelicenseKey - License keyhardwareId - Hardware IDapiKey - API keypublic String createOfflineSignature(String date, String licenseKey, String hardwareId, String apiKey)
date - DatelicenseKey - License keyhardwareId - Hardware IDapiKey - API keypublic 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 © 2024 Cense Data Inc.. All rights reserved.