|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.ws.soap.security.callback.AbstractCallbackHandler
org.springframework.ws.soap.security.xwss.callback.CryptographyCallbackHandler
org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler
public class KeyStoreCallbackHandler
Callback handler that uses Java Security KeyStores to handle cryptographic callbacks. Allows for
specific key stores to be set for various cryptographic operations.
KeyStoreFactoryBean. The exact stores to be set depends on the cryptographic operations that are to be
performed by this handler. The table underneath show the key store to be used for each operation: | Cryptographic operation | Key store used |
| Certificate validation | first keyStore, then trustStore |
| Decryption based on private key | keyStore |
| Decryption based on symmetric key | symmetricStore |
| Encryption based on certificate | trustStore |
| Encryption based on symmetric key | symmetricStore |
| Signing | keyStore |
| Signature verification | trustStore |
symmetricStore is not set, it will default to the
keyStore. If the key or trust store is not set, this handler will use the standard Java mechanism to
load or create it. See loadDefaultKeyStore() and loadDefaultTrustStore().
KeyStoreCallbackHandler to validate incoming
certificates or signatures, you would use a trust store, like so:
<bean id="keyStoreHandler" class="org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler">
<property name="trustStore" ref="trustStore"/>
</bean>
<bean id="trustStore" class="org.springframework.ws.soap.security.support.KeyStoreFactoryBean">
<property name="location" value="classpath:truststore.jks"/>
<property name="password" value="changeit"/>
</bean>
If you want to use it to decrypt incoming certificates or sign outgoing messages, you would use a key store, like
so:
<bean id="keyStoreHandler" class="org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler">
<property name="keyStore" ref="keyStore"/>
<property name="privateKeyPassword" value="changeit"/>
</bean>
<bean id="keyStore" class="org.springframework.ws.soap.security.support.KeyStoreFactoryBean">
<property name="location" value="classpath:keystore.jks"/>
<property name="password" value="changeit"/>
</bean>
CertificateValidationCallbacks,
DecryptionKeyCallbacks, EncryptionKeyCallbacks, SignatureKeyCallbacks, and
SignatureVerificationKeyCallbacks. It throws an UnsupportedCallbackException for others.
KeyStore,
KeyStoreFactoryBean,
CertificateValidationCallback,
DecryptionKeyCallback,
EncryptionKeyCallback,
SignatureKeyCallback,
SignatureVerificationKeyCallback,
The
standard Java trust store mechanism| Field Summary |
|---|
| Fields inherited from class org.springframework.ws.soap.security.callback.AbstractCallbackHandler |
|---|
logger |
| Constructor Summary | |
|---|---|
KeyStoreCallbackHandler()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
|
protected java.security.cert.X509Certificate |
getCertificate(java.security.PublicKey pk)
|
protected java.security.cert.X509Certificate |
getCertificate(java.lang.String alias)
|
protected java.security.cert.X509Certificate |
getCertificateFromTrustStore(byte[] subjectKeyIdentifier)
|
protected java.security.cert.X509Certificate |
getCertificateFromTrustStore(java.security.PublicKey pk)
|
protected java.security.cert.X509Certificate |
getCertificateFromTrustStore(java.lang.String alias)
|
protected java.security.cert.X509Certificate |
getCertificateFromTrustStore(java.lang.String issuerName,
java.math.BigInteger serialNumber)
|
protected java.security.PrivateKey |
getPrivateKey(byte[] keyIdentifier)
|
protected java.security.PrivateKey |
getPrivateKey(java.security.PublicKey publicKey)
|
protected java.security.PrivateKey |
getPrivateKey(java.lang.String alias)
|
protected java.security.PrivateKey |
getPrivateKey(java.lang.String issuerName,
java.math.BigInteger serialNumber)
|
protected java.security.PrivateKey |
getPrivateKey(java.security.cert.X509Certificate certificate)
|
protected byte[] |
getSubjectKeyIdentifier(java.security.cert.X509Certificate cert)
|
protected javax.crypto.SecretKey |
getSymmetricKey(java.lang.String alias)
|
protected void |
handleAliasPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureKeyCallback.AliasPrivKeyCertRequest request)
Template method that handles SignatureKeyCallbacks with AliasPrivKeyCertRequests. |
protected void |
handleAliasSymmetricKeyRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.DecryptionKeyCallback.AliasSymmetricKeyRequest request)
Template method that handles DecryptionKeyCallbacks with AliasSymmetricKeyRequests. |
protected void |
handleAliasSymmetricKeyRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.EncryptionKeyCallback.AliasSymmetricKeyRequest request)
Template method that handles EncryptionKeyCallbacks with AliasSymmetricKeyRequests. |
protected void |
handleAliasX509CertificateRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.EncryptionKeyCallback.AliasX509CertificateRequest request)
Template method that handles EncryptionKeyCallbacks with AliasX509CertificateRequests. |
protected void |
handleCertificateValidationCallback(com.sun.xml.wss.impl.callback.CertificateValidationCallback callback)
Template method that handles CertificateValidationCallbacks. |
protected void |
handleDefaultPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureKeyCallback.DefaultPrivKeyCertRequest request)
Template method that handles SignatureKeyCallbacks with DefaultPrivKeyCertRequests. |
protected void |
handleDefaultX509CertificateRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.EncryptionKeyCallback.DefaultX509CertificateRequest request)
Template method that handles EncryptionKeyCallbacks with DefaultX509CertificateRequests. |
protected void |
handlePublicKeyBasedPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest request)
Template method that handles SignatureKeyCallbacks with PublicKeyBasedPrivKeyCertRequests. |
protected void |
handlePublicKeyBasedPrivKeyRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest request)
Template method that handles DecryptionKeyCallbacks with PublicKeyBasedPrivKeyRequests. |
protected void |
handlePublicKeyBasedRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.EncryptionKeyCallback.PublicKeyBasedRequest request)
Template method that handles EncryptionKeyCallbacks with PublicKeyBasedRequests. |
protected void |
handlePublicKeyBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.PublicKeyBasedRequest request)
Template method that handles SignatureKeyCallbacks with PublicKeyBasedRequests. |
protected void |
handleX509CertificateBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509CertificateBasedRequest request)
Template method that handles DecryptionKeyCallbacks with X509CertificateBasedRequests. |
protected void |
handleX509IssuerSerialBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509IssuerSerialBasedRequest request)
Template method that handles DecryptionKeyCallbacks with X509IssuerSerialBasedRequests. |
protected void |
handleX509IssuerSerialBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest request)
Template method that handles SignatureKeyCallbacks with X509IssuerSerialBasedRequests. |
protected void |
handleX509SubjectKeyIdentifierBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest request)
Template method that handles DecryptionKeyCallbacks with X509SubjectKeyIdentifierBasedRequests. |
protected void |
handleX509SubjectKeyIdentifierBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest request)
Template method that handles SignatureKeyCallbacks with PublicKeyBasedPrivKeyCertRequests. |
protected void |
loadDefaultKeyStore()
Loads the key store indicated by system properties. |
protected void |
loadDefaultTrustStore()
Loads a default trust store. |
void |
setDefaultAlias(java.lang.String defaultAlias)
Sets the key store alias for the default certificate and private key. |
void |
setKeyStore(java.security.KeyStore keyStore)
Sets the default key store. |
void |
setPrivateKeyPassword(java.lang.String privateKeyPassword)
Sets the password used to retrieve private keys from the keystore. |
void |
setSymmetricKeyPassword(java.lang.String symmetricKeyPassword)
Sets the password used to retrieve keys from the symmetric keystore. |
void |
setSymmetricStore(java.security.KeyStore symmetricStore)
Sets the key store used for encryption and decryption using symmetric keys. |
void |
setTrustStore(java.security.KeyStore trustStore)
Sets the key store used for signature verifications and encryptions. |
| Methods inherited from class org.springframework.ws.soap.security.xwss.callback.CryptographyCallbackHandler |
|---|
handleDecryptionKeyCallback, handleEncryptionKeyCallback, handleInternal, handlePrivateKeyRequest, handlePrivKeyCertRequest, handleSignatureKeyCallback, handleSignatureVerificationKeyCallback, handleSymmetricKeyRequest, handleSymmetricKeyRequest, handleX509CertificateRequest, handleX509CertificateRequest |
| Methods inherited from class org.springframework.ws.soap.security.callback.AbstractCallbackHandler |
|---|
handle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public KeyStoreCallbackHandler()
| Method Detail |
|---|
public void setDefaultAlias(java.lang.String defaultAlias)
public void setKeyStore(java.security.KeyStore keyStore)
KeyStoreFactoryBean,
loadDefaultTrustStore()public void setPrivateKeyPassword(java.lang.String privateKeyPassword)
public void setSymmetricKeyPassword(java.lang.String symmetricKeyPassword)
setPrivateKeyPassword(String)public void setSymmetricStore(java.security.KeyStore symmetricStore)
keyStore property.
KeyStoreFactoryBean,
setKeyStore(java.security.KeyStore)public void setTrustStore(java.security.KeyStore trustStore)
KeyStoreFactoryBean,
loadDefaultTrustStore()
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exception
protected final void handleAliasPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureKeyCallback.AliasPrivKeyCertRequest request)
throws java.io.IOException
CryptographyCallbackHandlerSignatureKeyCallbacks with AliasPrivKeyCertRequests.
Called from handlePrivKeyCertRequest(). Default implementation throws an
UnsupportedCallbackException.
handleAliasPrivKeyCertRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handleAliasSymmetricKeyRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.DecryptionKeyCallback.AliasSymmetricKeyRequest request)
throws java.io.IOException
CryptographyCallbackHandlerDecryptionKeyCallbacks with AliasSymmetricKeyRequests.
Called from handleSymmetricKeyRequest(). Default implementation throws an
UnsupportedCallbackException.
handleAliasSymmetricKeyRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handleAliasSymmetricKeyRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.EncryptionKeyCallback.AliasSymmetricKeyRequest request)
throws java.io.IOException
CryptographyCallbackHandlerEncryptionKeyCallbacks with AliasSymmetricKeyRequests.
Called from handleSymmetricKeyRequest(). Default implementation throws an
UnsupportedCallbackException.
handleAliasSymmetricKeyRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handleAliasX509CertificateRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.EncryptionKeyCallback.AliasX509CertificateRequest request)
throws java.io.IOException
CryptographyCallbackHandlerEncryptionKeyCallbacks with AliasX509CertificateRequests.
Called from handleX509CertificateRequest(). Default implementation throws an
UnsupportedCallbackException.
handleAliasX509CertificateRequest in class CryptographyCallbackHandlerjava.io.IOExceptionprotected final void handleCertificateValidationCallback(com.sun.xml.wss.impl.callback.CertificateValidationCallback callback)
CryptographyCallbackHandlerCertificateValidationCallbacks. Called from
handleInternal(). Default implementation throws an UnsupportedCallbackException.
handleCertificateValidationCallback in class CryptographyCallbackHandler
protected final void handleDefaultPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureKeyCallback.DefaultPrivKeyCertRequest request)
throws java.io.IOException
CryptographyCallbackHandlerSignatureKeyCallbacks with DefaultPrivKeyCertRequests.
Called from handlePrivKeyCertRequest(). Default implementation throws an
UnsupportedCallbackException.
handleDefaultPrivKeyCertRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handleDefaultX509CertificateRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.EncryptionKeyCallback.DefaultX509CertificateRequest request)
throws java.io.IOException
CryptographyCallbackHandlerEncryptionKeyCallbacks with DefaultX509CertificateRequests.
Called from handleX509CertificateRequest(). Default implementation throws an
UnsupportedCallbackException.
handleDefaultX509CertificateRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handlePublicKeyBasedPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest request)
throws java.io.IOException
CryptographyCallbackHandlerSignatureKeyCallbacks with PublicKeyBasedPrivKeyCertRequests.
Called from handlePrivKeyCertRequest(). Default implementation throws an
UnsupportedCallbackException.
handlePublicKeyBasedPrivKeyCertRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handlePublicKeyBasedPrivKeyRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest request)
throws java.io.IOException
CryptographyCallbackHandlerDecryptionKeyCallbacks with PublicKeyBasedPrivKeyRequests.
Called from handlePrivateKeyRequest(). Default implementation throws an
UnsupportedCallbackException.
handlePublicKeyBasedPrivKeyRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handlePublicKeyBasedRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.EncryptionKeyCallback.PublicKeyBasedRequest request)
throws java.io.IOException
CryptographyCallbackHandlerEncryptionKeyCallbacks with PublicKeyBasedRequests. Called
from handleX509CertificateRequest(). Default implementation throws an
UnsupportedCallbackException.
handlePublicKeyBasedRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handlePublicKeyBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.PublicKeyBasedRequest request)
throws java.io.IOException
CryptographyCallbackHandlerSignatureKeyCallbacks with PublicKeyBasedRequests. Called
from handlePrivKeyCertRequest(). Default implementation throws an
UnsupportedCallbackException.
handlePublicKeyBasedRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handleX509CertificateBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509CertificateBasedRequest request)
throws java.io.IOException
CryptographyCallbackHandlerDecryptionKeyCallbacks with X509CertificateBasedRequests.
Called from handlePrivateKeyRequest(). Default implementation throws an
UnsupportedCallbackException.
handleX509CertificateBasedRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handleX509IssuerSerialBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509IssuerSerialBasedRequest request)
throws java.io.IOException
CryptographyCallbackHandlerDecryptionKeyCallbacks with X509IssuerSerialBasedRequests.
Called from handlePrivateKeyRequest(). Default implementation throws an
UnsupportedCallbackException.
handleX509IssuerSerialBasedRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handleX509IssuerSerialBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest request)
throws java.io.IOException
CryptographyCallbackHandlerSignatureKeyCallbacks with X509IssuerSerialBasedRequests.
Called from handlePrivKeyCertRequest(). Default implementation throws an
UnsupportedCallbackException.
handleX509IssuerSerialBasedRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handleX509SubjectKeyIdentifierBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback callback,
com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest request)
throws java.io.IOException
CryptographyCallbackHandlerDecryptionKeyCallbacks with X509SubjectKeyIdentifierBasedRequests.
Called from handlePrivateKeyRequest(). Default implementation throws an
UnsupportedCallbackException.
handleX509SubjectKeyIdentifierBasedRequest in class CryptographyCallbackHandlerjava.io.IOException
protected final void handleX509SubjectKeyIdentifierBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback callback,
com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest request)
throws java.io.IOException
CryptographyCallbackHandlerSignatureKeyCallbacks with PublicKeyBasedPrivKeyCertRequests.
Called from handlePrivKeyCertRequest(). Default implementation throws an
UnsupportedCallbackException.
handleX509SubjectKeyIdentifierBasedRequest in class CryptographyCallbackHandlerjava.io.IOException
protected java.security.cert.X509Certificate getCertificate(java.lang.String alias)
throws java.io.IOException
java.io.IOException
protected java.security.cert.X509Certificate getCertificate(java.security.PublicKey pk)
throws java.io.IOException
java.io.IOException
protected java.security.cert.X509Certificate getCertificateFromTrustStore(java.lang.String alias)
throws java.io.IOException
java.io.IOException
protected java.security.cert.X509Certificate getCertificateFromTrustStore(byte[] subjectKeyIdentifier)
throws java.io.IOException
java.io.IOException
protected java.security.cert.X509Certificate getCertificateFromTrustStore(java.security.PublicKey pk)
throws java.io.IOException
java.io.IOException
protected java.security.cert.X509Certificate getCertificateFromTrustStore(java.lang.String issuerName,
java.math.BigInteger serialNumber)
throws java.io.IOException
java.io.IOException
protected java.security.PrivateKey getPrivateKey(java.lang.String alias)
throws java.io.IOException
java.io.IOException
protected java.security.PrivateKey getPrivateKey(java.security.PublicKey publicKey)
throws java.io.IOException
java.io.IOException
protected java.security.PrivateKey getPrivateKey(java.security.cert.X509Certificate certificate)
throws java.io.IOException
java.io.IOException
protected java.security.PrivateKey getPrivateKey(byte[] keyIdentifier)
throws java.io.IOException
java.io.IOException
protected java.security.PrivateKey getPrivateKey(java.lang.String issuerName,
java.math.BigInteger serialNumber)
throws java.io.IOException
java.io.IOExceptionprotected final byte[] getSubjectKeyIdentifier(java.security.cert.X509Certificate cert)
protected javax.crypto.SecretKey getSymmetricKey(java.lang.String alias)
throws java.io.IOException
java.io.IOExceptionprotected void loadDefaultKeyStore()
KeyStoreUtils.loadDefaultKeyStore().
protected void loadDefaultTrustStore()
KeyStoreUtils.loadDefaultTrustStore().
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||