Package org.certificateservices.messages
Class DummyMessageSecurityProvider
- java.lang.Object
-
- org.certificateservices.messages.DummyMessageSecurityProvider
-
- All Implemented Interfaces:
ContextMessageSecurityProvider,MessageSecurityProvider
public class DummyMessageSecurityProvider extends java.lang.Object implements ContextMessageSecurityProvider
Dummy PKI Message Security Provider returning a self-signed certificate used for testing.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.certificateservices.messages.ContextMessageSecurityProvider
ContextMessageSecurityProvider.Context
-
-
Field Summary
-
Fields inherited from interface org.certificateservices.messages.ContextMessageSecurityProvider
DEFAULT_CONTEXT
-
Fields inherited from interface org.certificateservices.messages.MessageSecurityProvider
DEFAULT_DECRYPTIONKEY
-
-
Constructor Summary
Constructors Constructor Description DummyMessageSecurityProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.security.cert.X509CertificategetDecryptionCertificate(java.lang.String keyId)Fetches the decryption certificate of related key id.java.security.cert.X509CertificategetDecryptionCertificate(ContextMessageSecurityProvider.Context context, java.lang.String keyId)Fetches the decryption certificate of related key id.java.security.cert.X509Certificate[]getDecryptionCertificateChain(java.lang.String keyId)Fetches the decryption certificate chain of related key id can be one or more in size..java.security.cert.X509Certificate[]getDecryptionCertificateChain(ContextMessageSecurityProvider.Context context, java.lang.String keyId)Fetches the decryption certificate chain of related key id can be one or more in size.java.security.PrivateKeygetDecryptionKey(java.lang.String keyId)Fetches a private key given it's unique identifier.java.security.PrivateKeygetDecryptionKey(ContextMessageSecurityProvider.Context context, java.lang.String keyId)Fetches a private key given it's unique identifier.java.util.Set<java.lang.String>getDecryptionKeyIds()Returns key identifiers of all available decryption keys.java.util.Set<java.lang.String>getDecryptionKeyIds(ContextMessageSecurityProvider.Context context)Returns key identifiers of all available decryption keys.EncryptionAlgorithmSchemegetEncryptionAlgorithmScheme()Method to fetch the EncryptionAlgorithmScheme to use when encrypting messages.EncryptionAlgorithmSchemegetEncryptionAlgorithmScheme(ContextMessageSecurityProvider.Context context)Method to fetch the EncryptionAlgorithmScheme to use when encrypting messages.java.lang.StringgetOrganisationCalled()java.lang.StringgetProvider()Method to retrieve JCE provider that should be used with keys provided by this provider.java.lang.StringgetProvider(ContextMessageSecurityProvider.Context context)Method to retrieve JCE provider that should be used with keys provided by this provider.SigningAlgorithmSchemegetSigningAlgorithmScheme()Method to fetch the SigningAlgorithmScheme to use when signing messages.SigningAlgorithmSchemegetSigningAlgorithmScheme(ContextMessageSecurityProvider.Context context)Method to fetch the SigningAlgorithmScheme to use when signing messages.java.security.cert.X509CertificategetSigningCertificate()Fetches the signing certificate used to create the digital signatures of the XML file.java.security.cert.X509CertificategetSigningCertificate(ContextMessageSecurityProvider.Context context)Fetches the signing certificate used to create the digital signatures of the XML file.java.security.PrivateKeygetSigningKey()Method fetching the signing key from the dummy keystore.java.security.PrivateKeygetSigningKey(ContextMessageSecurityProvider.Context context)Fetches the signing key used to create the digital signatures of the XML file.booleangetValidCallDone()booleanisValidAndAuthorized(java.security.cert.X509Certificate signCertificate, java.lang.String organisation)Method in charge of validating a certificate used to sign a PKI message and also check if the certificate is authorized to generate messages.booleanisValidAndAuthorized(ContextMessageSecurityProvider.Context context, java.security.cert.X509Certificate signCertificate, java.lang.String organisation)Method in charge of validating a certificate used to sign a PKI message and also check if the certificate is authorized to generate messages.voidresetCounters()
-
-
-
Method Detail
-
getSigningKey
public java.security.PrivateKey getSigningKey() throws MessageProcessingExceptionMethod fetching the signing key from the dummy keystore.- Specified by:
getSigningKeyin interfaceMessageSecurityProvider- Returns:
- the signing key used.
- Throws:
MessageProcessingException- if key isn't accessible or activated.- See Also:
MessageSecurityProvider.getSigningKey()
-
getSigningKey
public java.security.PrivateKey getSigningKey(ContextMessageSecurityProvider.Context context) throws MessageProcessingException
Description copied from interface:ContextMessageSecurityProviderFetches the signing key used to create the digital signatures of the XML file.- Specified by:
getSigningKeyin interfaceContextMessageSecurityProvider- Parameters:
context- the related context, null for default context.- Returns:
- the signing key used.
- Throws:
MessageProcessingException- if key isn't accessible or activated.
-
getSigningCertificate
public java.security.cert.X509Certificate getSigningCertificate() throws java.lang.IllegalArgumentException, MessageProcessingExceptionDescription copied from interface:MessageSecurityProviderFetches the signing certificate used to create the digital signatures of the XML file.- Specified by:
getSigningCertificatein interfaceMessageSecurityProvider- Returns:
- the signing certificate used.
- Throws:
MessageProcessingException- if certificate isn't accessible.java.lang.IllegalArgumentException- See Also:
MessageSecurityProvider.getSigningCertificate()
-
getSigningCertificate
public java.security.cert.X509Certificate getSigningCertificate(ContextMessageSecurityProvider.Context context) throws MessageProcessingException
Description copied from interface:ContextMessageSecurityProviderFetches the signing certificate used to create the digital signatures of the XML file.- Specified by:
getSigningCertificatein interfaceContextMessageSecurityProvider- Parameters:
context- the related context, null for default context.- Returns:
- the signing certificate used.
- Throws:
MessageProcessingException- if certificate isn't accessible.
-
isValidAndAuthorized
public boolean isValidAndAuthorized(java.security.cert.X509Certificate signCertificate, java.lang.String organisation) throws java.lang.IllegalArgumentException, MessageProcessingExceptionDescription copied from interface:MessageSecurityProviderMethod in charge of validating a certificate used to sign a PKI message and also check if the certificate is authorized to generate messages.- Specified by:
isValidAndAuthorizedin interfaceMessageSecurityProvider- Parameters:
signCertificate- the certificate used to sign the message.organisation- the related organisation to the message, null if no organisation lookup should be done.- Returns:
- true if the sign certificate is valid and authorized to sign messages.
- Throws:
java.lang.IllegalArgumentException- if arguments were invalid.MessageProcessingException- if internal error occurred validating the certificate.- See Also:
MessageSecurityProvider.isValidAndAuthorized(X509Certificate, String)
-
isValidAndAuthorized
public boolean isValidAndAuthorized(ContextMessageSecurityProvider.Context context, java.security.cert.X509Certificate signCertificate, java.lang.String organisation) throws java.lang.IllegalArgumentException, MessageProcessingException
Description copied from interface:ContextMessageSecurityProviderMethod in charge of validating a certificate used to sign a PKI message and also check if the certificate is authorized to generate messages.- Specified by:
isValidAndAuthorizedin interfaceContextMessageSecurityProvider- Parameters:
context- the related context, null for default context.signCertificate- the certificate used to sign the message.organisation- the related organisation to the message, null if no organisation lookup should be done.- Returns:
- true if the sign certificate is valid and authorized to sign messages.
- Throws:
java.lang.IllegalArgumentException- if arguments were invalid.MessageProcessingException- if internal error occurred validating the certificate.
-
resetCounters
public void resetCounters()
-
getValidCallDone
public boolean getValidCallDone()
-
getOrganisationCalled
public java.lang.String getOrganisationCalled()
-
getDecryptionKey
public java.security.PrivateKey getDecryptionKey(java.lang.String keyId) throws MessageProcessingExceptionDescription copied from interface:MessageSecurityProviderFetches a private key given it's unique identifier.- Specified by:
getDecryptionKeyin interfaceMessageSecurityProvider- Parameters:
keyId- unique identifier of the key, if null should a default key be retrieved- Returns:
- the related decryption key.
- Throws:
MessageProcessingException
-
getDecryptionKey
public java.security.PrivateKey getDecryptionKey(ContextMessageSecurityProvider.Context context, java.lang.String keyId) throws MessageProcessingException
Description copied from interface:ContextMessageSecurityProviderFetches a private key given it's unique identifier.- Specified by:
getDecryptionKeyin interfaceContextMessageSecurityProvider- Parameters:
context- the related context, null for default context.keyId- unique identifier of the key, if null should a default key be retrieved- Returns:
- the related decryption key.
- Throws:
MessageProcessingException
-
getDecryptionCertificate
public java.security.cert.X509Certificate getDecryptionCertificate(java.lang.String keyId) throws MessageProcessingExceptionDescription copied from interface:MessageSecurityProviderFetches the decryption certificate of related key id.- Specified by:
getDecryptionCertificatein interfaceMessageSecurityProvider- Parameters:
keyId- unique identifier of the key, if null should a default key certificate be retrieved- Returns:
- the related decryption certificate.
- Throws:
MessageProcessingException- if certificate isn't accessible.
-
getDecryptionCertificate
public java.security.cert.X509Certificate getDecryptionCertificate(ContextMessageSecurityProvider.Context context, java.lang.String keyId) throws MessageProcessingException
Description copied from interface:ContextMessageSecurityProviderFetches the decryption certificate of related key id.- Specified by:
getDecryptionCertificatein interfaceContextMessageSecurityProvider- Parameters:
context- the related context, null for default context.keyId- unique identifier of the key, if null should a default key certificate be retrieved- Returns:
- the related decryption certificate.
- Throws:
MessageProcessingException- if certificate isn't accessible.
-
getDecryptionCertificateChain
public java.security.cert.X509Certificate[] getDecryptionCertificateChain(java.lang.String keyId) throws MessageProcessingExceptionDescription copied from interface:MessageSecurityProviderFetches the decryption certificate chain of related key id can be one or more in size..- Specified by:
getDecryptionCertificateChainin interfaceMessageSecurityProvider- Parameters:
keyId- unique identifier of the key, if null should a default key certificate be retrieved- Returns:
- the related decryption certificate chain
- Throws:
MessageProcessingException- if certificate isn't accessible.
-
getDecryptionCertificateChain
public java.security.cert.X509Certificate[] getDecryptionCertificateChain(ContextMessageSecurityProvider.Context context, java.lang.String keyId) throws MessageProcessingException
Description copied from interface:ContextMessageSecurityProviderFetches the decryption certificate chain of related key id can be one or more in size.- Specified by:
getDecryptionCertificateChainin interfaceContextMessageSecurityProvider- Parameters:
context- the related context, null for default context.keyId- unique identifier of the key, if null should a default key certificate be retrieved- Returns:
- the related decryption certificate chain
- Throws:
MessageProcessingException- if certificate isn't accessible.
-
getDecryptionKeyIds
public java.util.Set<java.lang.String> getDecryptionKeyIds() throws MessageProcessingExceptionDescription copied from interface:MessageSecurityProviderReturns key identifiers of all available decryption keys.- Specified by:
getDecryptionKeyIdsin interfaceMessageSecurityProvider- Returns:
- key identifiers of all available decryption keys.
- Throws:
MessageProcessingException
-
getDecryptionKeyIds
public java.util.Set<java.lang.String> getDecryptionKeyIds(ContextMessageSecurityProvider.Context context) throws MessageProcessingException
Description copied from interface:ContextMessageSecurityProviderReturns key identifiers of all available decryption keys.- Specified by:
getDecryptionKeyIdsin interfaceContextMessageSecurityProvider- Parameters:
context- the related context, null for default context.- Returns:
- key identifiers of all available decryption keys.
- Throws:
MessageProcessingException
-
getEncryptionAlgorithmScheme
public EncryptionAlgorithmScheme getEncryptionAlgorithmScheme() throws MessageProcessingException
Description copied from interface:MessageSecurityProviderMethod to fetch the EncryptionAlgorithmScheme to use when encrypting messages.- Specified by:
getEncryptionAlgorithmSchemein interfaceMessageSecurityProvider- Returns:
- Configured EncryptionAlgorithmScheme to use.
- Throws:
MessageProcessingException- if internal error determining algorithm scheme to use
-
getEncryptionAlgorithmScheme
public EncryptionAlgorithmScheme getEncryptionAlgorithmScheme(ContextMessageSecurityProvider.Context context) throws MessageProcessingException
Description copied from interface:ContextMessageSecurityProviderMethod to fetch the EncryptionAlgorithmScheme to use when encrypting messages.- Specified by:
getEncryptionAlgorithmSchemein interfaceContextMessageSecurityProvider- Returns:
- Configured EncryptionAlgorithmScheme to use.
- Throws:
MessageProcessingException- if internal error determining algorithm scheme to use
-
getSigningAlgorithmScheme
public SigningAlgorithmScheme getSigningAlgorithmScheme() throws MessageProcessingException
Description copied from interface:MessageSecurityProviderMethod to fetch the SigningAlgorithmScheme to use when signing messages.- Specified by:
getSigningAlgorithmSchemein interfaceMessageSecurityProvider- Returns:
- Configured SigningAlgorithmScheme to use.
- Throws:
MessageProcessingException- if internal error determining algorithm scheme to use
-
getProvider
public java.lang.String getProvider()
Method to retrieve JCE provider that should be used with keys provided by this provider.- Specified by:
getProviderin interfaceMessageSecurityProvider- Returns:
- name of an JCE Provider that should be installed prior to usage of this MessageSecurityProvider if null should the JRE configured list of security providers be used.
-
getSigningAlgorithmScheme
public SigningAlgorithmScheme getSigningAlgorithmScheme(ContextMessageSecurityProvider.Context context) throws MessageProcessingException
Description copied from interface:ContextMessageSecurityProviderMethod to fetch the SigningAlgorithmScheme to use when signing messages.- Specified by:
getSigningAlgorithmSchemein interfaceContextMessageSecurityProvider- Parameters:
context- the related context, null for default context.- Returns:
- Configured SigningAlgorithmScheme to use.
- Throws:
MessageProcessingException- if internal error determining algorithm scheme to use
-
getProvider
public java.lang.String getProvider(ContextMessageSecurityProvider.Context context)
Method to retrieve JCE provider that should be used with keys provided by this provider.- Specified by:
getProviderin interfaceContextMessageSecurityProvider- Returns:
- name of an JCE Provider that should be installed prior to usage of this MessageSecurityProvider if null should the JRE configured list of security providers be used.
-
-