Class DefaultApiKeyGenerator
java.lang.Object
com.broadleafcommerce.auth.server.service.apikey.DefaultApiKeyGenerator
- All Implemented Interfaces:
ApiKeyGenerator
Default implementation of
ApiKeyGenerator that creates keys formatted with visibility and
environment prefixes.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultApiKeyGenerator(ApiKeyHasher apiKeyHasher, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected ApiKeyGenerationResultbuildApiKeyGenerationResult(String plaintextKey, String displaySafeKeyPreview, String secureHash) protected StringbuildDisplaySafeKeyPreview(String visibilityPrefix, String envPrefix, String hexPrefix, String hexSuffix) protected StringbuildPlaintextKey(String visibilityPrefix, String envPrefix, String hexPrefix, String hexSuffix) protected StringdeterminePrefixForEnvironment(AuthorizedClient authorizedClient) protected StringdeterminePrefixForVisibilityType(AuthorizedClient authorizedClient) generate(ApiKeyGenerationRequest request) Uses aBytesKeyGeneratorto generate a cryptographically strong API key conforming to the format{visibilityPrefix}_{env}_{8 char hex prefix}_{32 char hex}.protected Stringprotected Stringprotected ApiKeyHasherprotected org.springframework.security.crypto.keygen.BytesKeyGeneratorprotected org.springframework.security.crypto.keygen.BytesKeyGeneratorprotected com.broadleafcommerce.common.extension.TypeFactoryprotected org.springframework.security.crypto.keygen.BytesKeyGeneratorprotected org.springframework.security.crypto.keygen.BytesKeyGenerator
-
Constructor Details
-
DefaultApiKeyGenerator
public DefaultApiKeyGenerator(ApiKeyHasher apiKeyHasher, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
instantiateHexPrefixGenerator
protected org.springframework.security.crypto.keygen.BytesKeyGenerator instantiateHexPrefixGenerator() -
instantiateHexSuffixGenerator
protected org.springframework.security.crypto.keygen.BytesKeyGenerator instantiateHexSuffixGenerator() -
generate
Uses aBytesKeyGeneratorto generate a cryptographically strong API key conforming to the format{visibilityPrefix}_{env}_{8 char hex prefix}_{32 char hex}.- Specified by:
generatein interfaceApiKeyGenerator- Parameters:
request- the request containing configuration details for the key- Returns:
- the result containing the raw key, the hash, and a display-safe preview
-
determinePrefixForVisibilityType
-
determinePrefixForEnvironment
-
generateHexPrefix
-
generateHexSuffix
-
buildPlaintextKey
-
buildDisplaySafeKeyPreview
-
buildApiKeyGenerationResult
protected ApiKeyGenerationResult buildApiKeyGenerationResult(String plaintextKey, String displaySafeKeyPreview, String secureHash) - Parameters:
plaintextKey- the generated plaintext keydisplaySafeKeyPreview- the previewsecureHash- the hash- Returns:
- a new generation result Authentication Service 3.0.0, Release Train 3.0.0
-
getApiKeyHasher
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getHexPrefixGenerator
protected org.springframework.security.crypto.keygen.BytesKeyGenerator getHexPrefixGenerator() -
getHexSuffixGenerator
protected org.springframework.security.crypto.keygen.BytesKeyGenerator getHexSuffixGenerator()
-