public class DefaultCryptoService extends Object implements org.wso2.carbon.crypto.api.CryptoService, org.wso2.carbon.crypto.api.PrivateKeyRetriever
CryptoService| Constructor and Description |
|---|
DefaultCryptoService() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
areExternalCryptoProvidersAvailable()
Returns true if there is at least one
ExternalCryptoProvider registered with the service, false otherwise. |
boolean |
areInternalCryptoProvidersAvailable()
Returns true if there is at least one
InternalCryptoProvider registered with the service,
false otherwise. |
byte[] |
decrypt(byte[] ciphertext,
String algorithm,
String javaSecurityAPIProvider) |
byte[] |
decrypt(byte[] ciphertext,
String algorithm,
String javaSecurityAPIProvider,
org.wso2.carbon.crypto.api.CryptoContext cryptoContext) |
byte[] |
encrypt(byte[] cleartext,
String algorithm,
String javaSecurityAPIProvider) |
byte[] |
encrypt(byte[] cleartext,
String algorithm,
String javaSecurityAPIProvider,
org.wso2.carbon.crypto.api.CryptoContext cryptoContext) |
Certificate |
getCertificate(org.wso2.carbon.crypto.api.CryptoContext cryptoContext) |
org.wso2.carbon.crypto.api.ExternalCryptoProvider |
getMostSuitableExternalProvider()
Returns the most suitable
ExternalCryptoProvider for the operations, among the registered providers. |
org.wso2.carbon.crypto.api.InternalCryptoProvider |
getMostSuitableInternalProvider()
Returns the most suitable
InternalCryptoProvider for the operations, among the registered providers. |
PrivateKey |
getPrivateKey(org.wso2.carbon.crypto.api.CryptoContext cryptoContext) |
void |
overrideKeyResolverPriority(String keyResolverClassName,
int keyResolverPriority)
Overrides the priority of the given key resolver, with the given new priority.
|
void |
registerExternalCryptoProvider(org.wso2.carbon.crypto.api.ExternalCryptoProvider provider)
Registers a
ExternalCryptoProvider with this service. |
void |
registerInternalCryptoProvider(org.wso2.carbon.crypto.api.InternalCryptoProvider internalCryptoProvider)
Registers a
InternalCryptoProvider with this service. |
void |
registerKeyResolver(org.wso2.carbon.crypto.api.KeyResolver keyResolver)
Registers a new key resolver.
|
void |
setExternalCryptoProviderClassName(String externalCryptoProviderClassName)
Sets the preferred external provider class name, which was read from a configuration.
|
void |
setInternalCryptoProviderClassName(String internalCryptoProviderClassName)
Sets the preferred internal provider class name, which was read from a configuration.
|
byte[] |
sign(byte[] data,
String algorithm,
String javaSecurityAPIProvider,
org.wso2.carbon.crypto.api.CryptoContext cryptoContext) |
void |
unregisterAllExternalCryptoProviders()
Unregisters all the registered external crypto providers.
|
void |
unregisterAllInternalCryptoProviders()
Unregisters all the registered providers.
|
void |
unregisterExternalCryptoProvider(org.wso2.carbon.crypto.api.ExternalCryptoProvider externalCryptoProvider)
Unregisters the given external crypto provider.
|
void |
unregisterInternalCryptoProvider(org.wso2.carbon.crypto.api.InternalCryptoProvider internalCryptoProvider)
Unregisters the given internal crypto provider.
|
void |
unregisterKeyResolver(org.wso2.carbon.crypto.api.KeyResolver keyResolver)
Unregisters the given key resolver.
|
boolean |
verifySignature(byte[] data,
byte[] signature,
String algorithm,
String javaSecurityAPIProvider,
org.wso2.carbon.crypto.api.CryptoContext cryptoContext) |
public byte[] encrypt(byte[] cleartext,
String algorithm,
String javaSecurityAPIProvider)
throws org.wso2.carbon.crypto.api.CryptoException
encrypt in interface org.wso2.carbon.crypto.api.CryptoServicecleartext - Cleartext to be encrypted.algorithm - The encryption / decryption algorithmjavaSecurityAPIProvider - The Java Security API provider.org.wso2.carbon.crypto.api.CryptoExceptionpublic byte[] decrypt(byte[] ciphertext,
String algorithm,
String javaSecurityAPIProvider)
throws org.wso2.carbon.crypto.api.CryptoException
decrypt in interface org.wso2.carbon.crypto.api.CryptoServiceciphertext - The ciphertext to be decrypted.algorithm - The signature + hashing algorithm to be used in signing.javaSecurityAPIProvider - The Java Security API provider.org.wso2.carbon.crypto.api.CryptoExceptionpublic byte[] sign(byte[] data,
String algorithm,
String javaSecurityAPIProvider,
org.wso2.carbon.crypto.api.CryptoContext cryptoContext)
throws org.wso2.carbon.crypto.api.CryptoException
sign in interface org.wso2.carbon.crypto.api.CryptoServicedata - The content which the signature should be generated against.algorithm - The signature + hashing algorithm to be used in signing.javaSecurityAPIProvider - The Java Security API provider.cryptoContext - The context information which is needed to discover the private key.org.wso2.carbon.crypto.api.CryptoExceptionpublic byte[] decrypt(byte[] ciphertext,
String algorithm,
String javaSecurityAPIProvider,
org.wso2.carbon.crypto.api.CryptoContext cryptoContext)
throws org.wso2.carbon.crypto.api.CryptoException
decrypt in interface org.wso2.carbon.crypto.api.CryptoServiceciphertext - The content which the signature should be generated against.algorithm - The signature + hashing algorithm to be used in signing.javaSecurityAPIProvider - The Java Security API provider.cryptoContext - The context information which is needed to discover the private key.org.wso2.carbon.crypto.api.CryptoExceptionpublic byte[] encrypt(byte[] cleartext,
String algorithm,
String javaSecurityAPIProvider,
org.wso2.carbon.crypto.api.CryptoContext cryptoContext)
throws org.wso2.carbon.crypto.api.CryptoException
encrypt in interface org.wso2.carbon.crypto.api.CryptoServicecleartext - The cleartext to be encrypted.algorithm - The signature + hashing algorithm to be used in signing.javaSecurityAPIProvider - The Java Security API provider.cryptoContext - The context information which is needed to discover the public key of the
external entity.org.wso2.carbon.crypto.api.CryptoExceptionpublic boolean verifySignature(byte[] data,
byte[] signature,
String algorithm,
String javaSecurityAPIProvider,
org.wso2.carbon.crypto.api.CryptoContext cryptoContext)
throws org.wso2.carbon.crypto.api.CryptoException
verifySignature in interface org.wso2.carbon.crypto.api.CryptoServicedata - The data which was the signature generated on.signature - The signature bytes of data.algorithm - The signature + hashing algorithm to be used in signing.javaSecurityAPIProvider - The Java Security API provider.cryptoContext - The context information which is needed to discover the public key of the
external entity.org.wso2.carbon.crypto.api.CryptoExceptionpublic Certificate getCertificate(org.wso2.carbon.crypto.api.CryptoContext cryptoContext) throws org.wso2.carbon.crypto.api.CryptoException
getCertificate in interface org.wso2.carbon.crypto.api.CryptoServicecryptoContext - The context information which is used to discover the public key of the external entity.org.wso2.carbon.crypto.api.CryptoExceptionpublic PrivateKey getPrivateKey(org.wso2.carbon.crypto.api.CryptoContext cryptoContext) throws org.wso2.carbon.crypto.api.CryptoException
getPrivateKey in interface org.wso2.carbon.crypto.api.PrivateKeyRetrievercryptoContext - org.wso2.carbon.crypto.api.CryptoExceptionpublic void registerKeyResolver(org.wso2.carbon.crypto.api.KeyResolver keyResolver)
keyResolver - The key resolver to be registered.public void unregisterKeyResolver(org.wso2.carbon.crypto.api.KeyResolver keyResolver)
keyResolver - The key resolver to be unregistered.public void registerInternalCryptoProvider(org.wso2.carbon.crypto.api.InternalCryptoProvider internalCryptoProvider)
InternalCryptoProvider with this service.
These providers are used for internal crypto needs.internalCryptoProvider - public void unregisterAllInternalCryptoProviders()
public void unregisterInternalCryptoProvider(org.wso2.carbon.crypto.api.InternalCryptoProvider internalCryptoProvider)
internalCryptoProvider - public boolean areInternalCryptoProvidersAvailable()
InternalCryptoProvider registered with the service,
false otherwise.public org.wso2.carbon.crypto.api.InternalCryptoProvider getMostSuitableInternalProvider()
throws org.wso2.carbon.crypto.api.CryptoException
InternalCryptoProvider for the operations, among the registered providers.org.wso2.carbon.crypto.api.CryptoExceptionpublic void registerExternalCryptoProvider(org.wso2.carbon.crypto.api.ExternalCryptoProvider provider)
ExternalCryptoProvider with this service.
These providers are used for crypto needs which involves an external entity
(e.g. Signing messages for an external application).provider - public void unregisterExternalCryptoProvider(org.wso2.carbon.crypto.api.ExternalCryptoProvider externalCryptoProvider)
externalCryptoProvider - public void unregisterAllExternalCryptoProviders()
public boolean areExternalCryptoProvidersAvailable()
ExternalCryptoProvider registered with the service, false otherwise.public org.wso2.carbon.crypto.api.ExternalCryptoProvider getMostSuitableExternalProvider()
throws org.wso2.carbon.crypto.api.CryptoException
ExternalCryptoProvider for the operations, among the registered providers.org.wso2.carbon.crypto.api.CryptoExceptionpublic void setInternalCryptoProviderClassName(String internalCryptoProviderClassName)
internalCryptoProviderClassName - The preferred internal crypto provider class name.public void setExternalCryptoProviderClassName(String externalCryptoProviderClassName)
externalCryptoProviderClassName - The preferred external crypto provider class name.public void overrideKeyResolverPriority(String keyResolverClassName, int keyResolverPriority)
keyResolverClassName - The class name of the key resolver whose priority should be overridden.keyResolverPriority - The new priority.Copyright © 2018 WSO2. All rights reserved.