Package org.apereo.cas.util.cipher
Class AbstractCipherExecutor<T,R>
- java.lang.Object
-
- org.apereo.cas.util.cipher.AbstractCipherExecutor<T,R>
-
- All Implemented Interfaces:
org.apereo.cas.util.crypto.CipherExecutor<T,R>,org.apereo.cas.util.crypto.DecodableCipher<T,R>,org.apereo.cas.util.crypto.EncodableCipher<T,R>
- Direct Known Subclasses:
BaseBinaryCipherExecutor,BaseStringCipherExecutor
public abstract class AbstractCipherExecutor<T,R> extends java.lang.Object implements org.apereo.cas.util.crypto.CipherExecutor<T,R>Abstract cipher to provide common operations around signing objects.- Since:
- 4.2
-
-
Constructor Summary
Constructors Constructor Description AbstractCipherExecutor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconfigureSigningKey(java.lang.String signingSecretKey)Sets signing key.protected voidconfigureSigningKeyFromPrivateKeyResource(java.lang.String signingSecretKey)Configure signing key from private key resource.static java.security.PrivateKeyextractPrivateKeyFromResource(java.lang.String signingSecretKey)Extract private key from resource private key.static java.security.PublicKeyextractPublicKeyFromResource(java.lang.String secretKeyToUse)Extract public key from resource public key.protected java.lang.StringgetSigningAlgorithmFor(java.security.Key signingKey)Gets signing algorithm for.booleanisEnabled()protected byte[]sign(byte[] value, java.security.Key signingKey)Sign the array by first turning it into a base64 encoded string.protected byte[]signWith(byte[] value, java.lang.String algHeaderValue)Sign value with given parameters.protected byte[]signWith(byte[] value, java.lang.String algHeaderValue, java.security.Key key)Sign with byte [ ].protected byte[]verifySignature(byte[] value, java.security.Key activeSigningKey)Verify signature.
-
-
-
Method Detail
-
extractPrivateKeyFromResource
public static java.security.PrivateKey extractPrivateKeyFromResource(java.lang.String signingSecretKey)
Extract private key from resource private key.- Parameters:
signingSecretKey- the signing secret key- Returns:
- the private key
-
extractPublicKeyFromResource
public static java.security.PublicKey extractPublicKeyFromResource(java.lang.String secretKeyToUse)
Extract public key from resource public key.- Parameters:
secretKeyToUse- the secret key to use- Returns:
- the public key
-
isEnabled
public boolean isEnabled()
-
sign
protected byte[] sign(byte[] value, java.security.Key signingKey)Sign the array by first turning it into a base64 encoded string.- Parameters:
value- the valuesigningKey- the signing key- Returns:
- the byte [ ]
-
signWith
protected byte[] signWith(byte[] value, java.lang.String algHeaderValue)Sign value with given parameters.- Parameters:
value- the valuealgHeaderValue- the alg header value- Returns:
- the byte [ ]
-
signWith
protected byte[] signWith(byte[] value, java.lang.String algHeaderValue, java.security.Key key)Sign with byte [ ].- Parameters:
value- the valuealgHeaderValue- the alg header valuekey- the key- Returns:
- the byte [ ]
-
configureSigningKey
protected void configureSigningKey(java.lang.String signingSecretKey)
Sets signing key. If the key provided is resolved as a private key, then will create use the private key as is, and will sign values using RSA. Otherwise, AES is used.- Parameters:
signingSecretKey- the signing secret key
-
configureSigningKeyFromPrivateKeyResource
protected void configureSigningKeyFromPrivateKeyResource(java.lang.String signingSecretKey)
Configure signing key from private key resource.- Parameters:
signingSecretKey- the signing secret key
-
verifySignature
protected byte[] verifySignature(byte[] value, java.security.Key activeSigningKey)Verify signature.- Parameters:
value- the valueactiveSigningKey- the active signing key- Returns:
- the value associated with the signature, which may have to be decoded, or null.
-
getSigningAlgorithmFor
protected java.lang.String getSigningAlgorithmFor(java.security.Key signingKey)
Gets signing algorithm for.- Parameters:
signingKey- the signing key- Returns:
- the signing algorithm for
-
-