public class X509Support extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
RSA |
static String |
SHA_256_WITH_RSA |
static String |
X_509_CERTIFICATE_TYPE |
| Constructor and Description |
|---|
X509Support(URL certificate)
Creates a new X509 support without any signing capabilities
|
X509Support(URL certificate,
URL privateKey)
Creates a new X509 support
|
X509Support(X509Certificate certificate)
Creates a new x509 support
|
X509Support(X509Certificate certificate,
RSAPrivateKey privateKey)
Creates a new x509 support
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
cipher(byte[] plainText)
cipher
|
byte[] |
decipher(byte[] bytes)
decipher
|
X509Certificate |
getCertificate()
Returns the certificate
|
RSAPrivateKey |
getPrivateKey()
Returns the private key (if there is one)
|
boolean |
isPrivateKeyAvailable()
Returns whether the private key is available
|
static X509Certificate |
readCertificate(URL certificateUrl)
Reads the x509 certificate from the given url
|
static RSAPrivateKey |
readPrivateKey(URL privateKeyUrl)
Reads a private key form a url
|
Signature |
sign(byte[] plainText)
sign
|
boolean |
verifySignature(byte[] plainText,
Signature signature)
verifySignature
|
@Nonnull public static final String RSA
@Nonnull public static final String SHA_256_WITH_RSA
@Nonnull public static final String X_509_CERTIFICATE_TYPE
public X509Support(@Nonnull URL certificate) throws IOException, GeneralSecurityException
certificate - the certificateIOException - if any.GeneralSecurityException - if any.@Inject public X509Support(@Nonnull URL certificate, @PrivateKeyUrl @Nullable URL privateKey) throws IOException, GeneralSecurityException
certificate - the certificateprivateKey - the private key (if available)IOException - if any.GeneralSecurityException - if any.public X509Support(@Nonnull X509Certificate certificate)
certificate - the certificatepublic X509Support(@Nonnull X509Certificate certificate, @Nullable RSAPrivateKey privateKey)
certificate - the certificateprivateKey - the (optional) private keypublic boolean isPrivateKeyAvailable()
@Nonnull public byte[] cipher(@Nonnull byte[] plainText) throws GeneralSecurityException
cipher
plainText - an array of byte.GeneralSecurityException - if any.@Nonnull public byte[] decipher(@Nonnull byte[] bytes) throws GeneralSecurityException
decipher
bytes - an array of byte.GeneralSecurityException - if any.@Nonnull public Signature sign(@Nonnull byte[] plainText) throws GeneralSecurityException
sign
plainText - an array of byte.GeneralSecurityException - if any.public boolean verifySignature(@Nonnull byte[] plainText, @Nonnull Signature signature) throws GeneralSecurityException
verifySignature
plainText - an array of byte.signature - a com.cedarsoft.crypt.Signature object.GeneralSecurityException - if any.@Nonnull public X509Certificate getCertificate()
@Nonnull public RSAPrivateKey getPrivateKey()
@Nullable public static RSAPrivateKey readPrivateKey(@Nullable URL privateKeyUrl) throws IOException, GeneralSecurityException
privateKeyUrl - the url containing the private keyIOException - if any.GeneralSecurityException - if any.@Nonnull public static X509Certificate readCertificate(@Nonnull URL certificateUrl) throws IOException, GeneralSecurityException
certificateUrl - the certificate urlIOException - if any.GeneralSecurityException - if any.Copyright © 2007–2016 cedarsoft GmbH. All rights reserved.