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:
- February 12, 2019
- Author:
- Javier Rojas Blum, Yuriy Movchan
-
-
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, Use use)
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, Use use)
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 keyStoreSecret)
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, generateKey, 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(java.lang.String keyStoreSecret)
-
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, Use use) throws java.security.NoSuchProviderException, java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterException, java.security.cert.CertificateException, java.io.IOException, org.bouncycastle.operator.OperatorCreationException, java.security.KeyStoreException
- Specified by:
generateKey
in classAbstractCryptoProvider
- Throws:
java.security.NoSuchProviderException
java.security.NoSuchAlgorithmException
java.security.InvalidAlgorithmParameterException
java.security.cert.CertificateException
java.io.IOException
org.bouncycastle.operator.OperatorCreationException
java.security.KeyStoreException
-
getAliasByAlgorithmForDeletion
public java.lang.String getAliasByAlgorithmForDeletion(Algorithm algorithm, java.lang.String newAlias, Use use) 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 java.lang.Exception
- Specified by:
sign
in classAbstractCryptoProvider
- Throws:
java.lang.Exception
-
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 java.lang.Exception
- Specified by:
verifySignature
in classAbstractCryptoProvider
- Throws:
java.lang.Exception
-
deleteKey
public boolean deleteKey(java.lang.String alias) throws java.lang.Exception
- Specified by:
deleteKey
in classAbstractCryptoProvider
- Throws:
java.lang.Exception
-
getPublicKey
public java.security.PublicKey getPublicKey(java.lang.String alias)
-
getKeyId
public java.lang.String getKeyId(JSONWebKeySet jsonWebKeySet, Algorithm algorithm, Use use) throws java.lang.Exception
- Overrides:
getKeyId
in classAbstractCryptoProvider
- Throws:
java.lang.Exception
-
getPrivateKey
public java.security.PrivateKey getPrivateKey(java.lang.String alias) throws java.security.UnrecoverableKeyException, java.security.NoSuchAlgorithmException, java.security.KeyStoreException
- Specified by:
getPrivateKey
in classAbstractCryptoProvider
- Throws:
java.security.UnrecoverableKeyException
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
-
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()
-
-