Package io.jans.as.model.crypto
Class AuthCryptoProvider
- java.lang.Object
-
- io.jans.as.model.crypto.AbstractCryptoProvider
-
- io.jans.as.model.crypto.AuthCryptoProvider
-
public class AuthCryptoProvider extends AbstractCryptoProvider
- Version:
- November 22, 2021
- Author:
- Javier Rojas Blum, Yuriy Movchan, Sergey Manoylo
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.log4j.Logger
LOG
-
Constructor Summary
Constructors Constructor Description AuthCryptoProvider()
AuthCryptoProvider(java.lang.String keyStoreFile, java.lang.String keyStoreSecret, java.lang.String dnName)
AuthCryptoProvider(java.lang.String keyStoreFile, java.lang.String keyStoreSecret, java.lang.String dnName, boolean rejectNoneAlg)
AuthCryptoProvider(java.lang.String keyStoreFile, java.lang.String keyStoreSecret, java.lang.String dnName, boolean rejectNoneAlg, KeySelectionStrategy keySelectionStrategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(java.lang.String keyId)
boolean
deleteKey(java.lang.String alias)
org.json.JSONObject
generateKey(Algorithm algorithm, java.lang.Long expirationTime)
org.json.JSONObject
generateKey(Algorithm algorithm, java.lang.Long expirationTime, int keyLength)
java.security.cert.X509Certificate
generateV3Certificate(java.security.KeyPair keyPair, java.lang.String issuer, java.lang.String signatureAlgorithm, java.lang.Long expirationTime)
java.lang.String
getAliasByAlgorithmForDeletion(Algorithm algorithm, java.lang.String newAlias)
java.lang.String
getDnName()
java.lang.String
getKeyId(JSONWebKeySet jsonWebKeySet, Algorithm algorithm, Use use)
java.util.List<java.lang.String>
getKeys()
java.security.KeyStore
getKeyStore()
java.lang.String
getKeyStoreFile()
java.lang.String
getKeyStoreSecret()
java.security.PrivateKey
getPrivateKey(java.lang.String alias)
java.security.PublicKey
getPublicKey(java.lang.String alias)
SignatureAlgorithm
getSignatureAlgorithm(java.lang.String alias)
void
load()
java.lang.String
sign(java.lang.String signingInput, java.lang.String alias, java.lang.String sharedSecret, SignatureAlgorithm signatureAlgorithm)
boolean
verifySignature(java.lang.String signingInput, java.lang.String encodedSignature, java.lang.String alias, org.json.JSONObject jwks, java.lang.String sharedSecret, SignatureAlgorithm signatureAlgorithm)
-
Methods inherited from class io.jans.as.model.crypto.AbstractCryptoProvider
checkKeyExpiration, generateJwks, getJwksRequestParam, getKeyRegenerationIntervalInDays, getPublicKey, setKeyRegenerationIntervalInDays
-
-
-
-
Constructor Detail
-
AuthCryptoProvider
public AuthCryptoProvider() throws java.security.KeyStoreException
- Throws:
java.security.KeyStoreException
-
AuthCryptoProvider
public AuthCryptoProvider(java.lang.String keyStoreFile, java.lang.String keyStoreSecret, java.lang.String dnName) throws java.security.KeyStoreException
- Throws:
java.security.KeyStoreException
-
AuthCryptoProvider
public AuthCryptoProvider(java.lang.String keyStoreFile, java.lang.String keyStoreSecret, java.lang.String dnName, boolean rejectNoneAlg) throws java.security.KeyStoreException
- Throws:
java.security.KeyStoreException
-
AuthCryptoProvider
public AuthCryptoProvider(java.lang.String keyStoreFile, java.lang.String keyStoreSecret, java.lang.String dnName, boolean rejectNoneAlg, KeySelectionStrategy keySelectionStrategy) throws java.security.KeyStoreException
- Throws:
java.security.KeyStoreException
-
-
Method Detail
-
load
public void load() throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException
- Throws:
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException
-
getKeyStoreFile
public java.lang.String getKeyStoreFile()
-
getKeyStoreSecret
public java.lang.String getKeyStoreSecret()
-
getDnName
public java.lang.String getDnName()
-
generateKey
public org.json.JSONObject generateKey(Algorithm algorithm, java.lang.Long expirationTime) throws CryptoProviderException
- Specified by:
generateKey
in classAbstractCryptoProvider
- Throws:
CryptoProviderException
-
generateKey
public org.json.JSONObject generateKey(Algorithm algorithm, java.lang.Long expirationTime, int keyLength) throws CryptoProviderException
- Specified by:
generateKey
in classAbstractCryptoProvider
- Throws:
CryptoProviderException
-
getAliasByAlgorithmForDeletion
public java.lang.String getAliasByAlgorithmForDeletion(Algorithm algorithm, java.lang.String newAlias) throws java.security.KeyStoreException
- Throws:
java.security.KeyStoreException
-
containsKey
public boolean containsKey(java.lang.String keyId)
- Specified by:
containsKey
in classAbstractCryptoProvider
-
sign
public java.lang.String sign(java.lang.String signingInput, java.lang.String alias, java.lang.String sharedSecret, SignatureAlgorithm signatureAlgorithm) throws CryptoProviderException
- Specified by:
sign
in classAbstractCryptoProvider
- Throws:
CryptoProviderException
-
verifySignature
public boolean verifySignature(java.lang.String signingInput, java.lang.String encodedSignature, java.lang.String alias, org.json.JSONObject jwks, java.lang.String sharedSecret, SignatureAlgorithm signatureAlgorithm) throws CryptoProviderException
- Specified by:
verifySignature
in classAbstractCryptoProvider
- Throws:
CryptoProviderException
-
deleteKey
public boolean deleteKey(java.lang.String alias) throws CryptoProviderException
- Specified by:
deleteKey
in classAbstractCryptoProvider
- Throws:
CryptoProviderException
-
getPublicKey
public java.security.PublicKey getPublicKey(java.lang.String alias) throws CryptoProviderException
- Specified by:
getPublicKey
in classAbstractCryptoProvider
- Throws:
CryptoProviderException
-
getKeyId
public java.lang.String getKeyId(JSONWebKeySet jsonWebKeySet, Algorithm algorithm, Use use) throws CryptoProviderException
- Overrides:
getKeyId
in classAbstractCryptoProvider
- Throws:
CryptoProviderException
-
getPrivateKey
public java.security.PrivateKey getPrivateKey(java.lang.String alias) throws CryptoProviderException
- Specified by:
getPrivateKey
in classAbstractCryptoProvider
- Throws:
CryptoProviderException
-
generateV3Certificate
public java.security.cert.X509Certificate generateV3Certificate(java.security.KeyPair keyPair, java.lang.String issuer, java.lang.String signatureAlgorithm, java.lang.Long expirationTime) throws org.bouncycastle.cert.CertIOException, org.bouncycastle.operator.OperatorCreationException, java.security.cert.CertificateException
- Throws:
org.bouncycastle.cert.CertIOException
org.bouncycastle.operator.OperatorCreationException
java.security.cert.CertificateException
-
getKeys
public java.util.List<java.lang.String> getKeys()
- Overrides:
getKeys
in classAbstractCryptoProvider
-
getSignatureAlgorithm
public SignatureAlgorithm getSignatureAlgorithm(java.lang.String alias) throws java.security.KeyStoreException
- Throws:
java.security.KeyStoreException
-
getKeyStore
public java.security.KeyStore getKeyStore()
-
-