Package org.certificateservices.messages
Interface ContextMessageSecurityProvider
-
- All Superinterfaces:
MessageSecurityProvider
- All Known Subinterfaces:
HSMMessageSecurityProvider
- All Known Implementing Classes:
DummyMessageSecurityProvider,PKCS11MessageSecurityProvider,SimpleMessageSecurityProvider
public interface ContextMessageSecurityProvider extends MessageSecurityProvider
Extended MessageSecurityProvider interface for enabling the context used by the caller in order to use a specific signing/decryption key depending on related organsiation and or use case.The interface basically adds a Context parameter to every method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classContextMessageSecurityProvider.ContextClass representing a context in which a ContextMessageSecurityProvider should determine keys and validation logic to return.
-
Field Summary
Fields Modifier and Type Field Description static ContextMessageSecurityProvider.ContextDEFAULT_CONTEXTDefault context is null.-
Fields inherited from interface org.certificateservices.messages.MessageSecurityProvider
DEFAULT_DECRYPTIONKEY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.security.cert.X509CertificategetDecryptionCertificate(ContextMessageSecurityProvider.Context context, java.lang.String keyId)Fetches the decryption certificate of related key id.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(ContextMessageSecurityProvider.Context context, java.lang.String keyId)Fetches a private key given it's unique identifier.java.util.Set<java.lang.String>getDecryptionKeyIds(ContextMessageSecurityProvider.Context context)Returns key identifiers of all available decryption keys.EncryptionAlgorithmSchemegetEncryptionAlgorithmScheme(ContextMessageSecurityProvider.Context context)Method to fetch the EncryptionAlgorithmScheme to use when encrypting messages.java.lang.StringgetProvider(ContextMessageSecurityProvider.Context context)Method to retrieve JCE provider that should be used with keys provided by this provider.SigningAlgorithmSchemegetSigningAlgorithmScheme(ContextMessageSecurityProvider.Context context)Method to fetch the SigningAlgorithmScheme to use when signing messages.java.security.cert.X509CertificategetSigningCertificate(ContextMessageSecurityProvider.Context context)Fetches the signing certificate used to create the digital signatures of the XML file.java.security.PrivateKeygetSigningKey(ContextMessageSecurityProvider.Context context)Fetches the signing key used to create the digital signatures of the XML file.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.-
Methods inherited from interface org.certificateservices.messages.MessageSecurityProvider
getDecryptionCertificate, getDecryptionCertificateChain, getDecryptionKey, getDecryptionKeyIds, getEncryptionAlgorithmScheme, getProvider, getSigningAlgorithmScheme, getSigningCertificate, getSigningKey, isValidAndAuthorized
-
-
-
-
Field Detail
-
DEFAULT_CONTEXT
static final ContextMessageSecurityProvider.Context DEFAULT_CONTEXT
Default context is null.
-
-
Method Detail
-
getSigningKey
java.security.PrivateKey getSigningKey(ContextMessageSecurityProvider.Context context) throws MessageProcessingException
Fetches the signing key used to create the digital signatures of the XML file.- Parameters:
context- the related context, null for default context.- Returns:
- the signing key used.
- Throws:
MessageProcessingException- if key isn't accessible or activated.
-
getSigningCertificate
java.security.cert.X509Certificate getSigningCertificate(ContextMessageSecurityProvider.Context context) throws MessageProcessingException
Fetches the signing certificate used to create the digital signatures of the XML file.- Parameters:
context- the related context, null for default context.- Returns:
- the signing certificate used.
- Throws:
MessageProcessingException- if certificate isn't accessible.
-
getDecryptionKey
java.security.PrivateKey getDecryptionKey(ContextMessageSecurityProvider.Context context, java.lang.String keyId) throws MessageProcessingException
Fetches a private key given it's unique identifier.- 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
java.security.cert.X509Certificate getDecryptionCertificate(ContextMessageSecurityProvider.Context context, java.lang.String keyId) throws MessageProcessingException
Fetches the decryption certificate of related key id.- 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
java.security.cert.X509Certificate[] getDecryptionCertificateChain(ContextMessageSecurityProvider.Context context, java.lang.String keyId) throws MessageProcessingException
Fetches the decryption certificate chain of related key id can be one or more in size.- 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
java.util.Set<java.lang.String> getDecryptionKeyIds(ContextMessageSecurityProvider.Context context) throws MessageProcessingException
Returns key identifiers of all available decryption keys.- Parameters:
context- the related context, null for default context.- Returns:
- key identifiers of all available decryption keys.
- Throws:
MessageProcessingException
-
isValidAndAuthorized
boolean isValidAndAuthorized(ContextMessageSecurityProvider.Context context, java.security.cert.X509Certificate signCertificate, java.lang.String organisation) throws java.lang.IllegalArgumentException, MessageProcessingException
Method in charge of validating a certificate used to sign a PKI message and also check if the certificate is authorized to generate messages.- 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.
-
getEncryptionAlgorithmScheme
EncryptionAlgorithmScheme getEncryptionAlgorithmScheme(ContextMessageSecurityProvider.Context context) throws MessageProcessingException
Method to fetch the EncryptionAlgorithmScheme to use when encrypting messages.- Returns:
- Configured EncryptionAlgorithmScheme to use.
- Throws:
MessageProcessingException- if internal error determining algorithm scheme to use
-
getSigningAlgorithmScheme
SigningAlgorithmScheme getSigningAlgorithmScheme(ContextMessageSecurityProvider.Context context) throws MessageProcessingException
Method to fetch the SigningAlgorithmScheme to use when signing messages.- 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
java.lang.String getProvider(ContextMessageSecurityProvider.Context context)
Method to retrieve JCE provider that should be used with keys provided by this provider.- 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.
-
-