public class SecurityUtils
extends java.lang.Object
Constructor and Description |
---|
SecurityUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
asymmetricSign(java.security.interfaces.RSAPrivateKey key,
byte[] source,
int offset,
int length) |
static boolean |
asymmetricVerify(java.security.interfaces.RSAPublicKey key,
byte[] source,
int offset,
int length,
byte[] signature,
int sigOff,
int sigLen) |
static java.lang.String |
certificateThumbprintToString(byte[] buf) |
static byte[] |
decryptDESede(byte[] toDecrypt,
byte[] keyBytes)
Performs symmetric decryption using DESede.
|
static byte[] |
decryptRSA(byte[] source,
java.security.Key key) |
static byte[] |
encryptDESede(byte[] toEncrypt,
byte[] keyBytes)
Performs symmetric encryption using DESede.
|
static byte[] |
generateDESedKey() |
static java.lang.String |
getCertificateThumbprint(java.security.cert.X509Certificate certificate)
Returns a to-stringed hash of the certificate encoded bytes.
|
static byte[] |
getCertificateThumbprintBytes(java.security.cert.X509Certificate certificate)
Returns a hash of the certificate encoded bytes.
|
static org.bouncycastle.crypto.params.RSAKeyParameters |
getKeyParameter(java.security.interfaces.RSAKey key)
Returns a parameter object suitable for initializing a Bouncy Castle RSAEngine asymmetric block cipher
|
static org.bouncycastle.crypto.params.RSAKeyParameters |
getPrivateKeyParameter(java.security.interfaces.RSAPrivateKey key)
Returns a parameter object suitable for initializing a Bouncy Castle RSAEngine asymmetric block cipher
|
static org.bouncycastle.crypto.params.RSAKeyParameters |
getPublicKeyParameter(java.security.interfaces.RSAPublicKey key)
Returns a parameter object suitable for initializing a Bouncy Castle RSAEngine asymmetric block cipher
|
static byte[] |
md5(java.io.File file) |
static byte[] |
md5(java.io.InputStream stream) |
static java.security.cert.X509Certificate |
parseX509Certificate(byte[] input)
Creates an X509Certificate object from DER encoded binary or PEM encoded ASCII
|
static java.util.List<java.security.cert.X509Certificate> |
parseX509Certificates(byte[] input) |
static java.util.List<java.security.cert.X509Certificate> |
parseX509Certificates(java.io.InputStream inputStream) |
static byte[] |
sha1(byte[] input)
Performs a sha1 digest on the given input array, returning the digest as a byte array
|
static java.lang.String |
sha1String(java.lang.String input)
Performs a sha1 digest on the input string encoded as UTF-8, returns the digest as Base64-ed bytes.
|
public static org.bouncycastle.crypto.params.RSAKeyParameters getKeyParameter(java.security.interfaces.RSAKey key)
public static org.bouncycastle.crypto.params.RSAKeyParameters getPublicKeyParameter(java.security.interfaces.RSAPublicKey key)
public static org.bouncycastle.crypto.params.RSAKeyParameters getPrivateKeyParameter(java.security.interfaces.RSAPrivateKey key)
public static byte[] sha1(byte[] input)
public static java.lang.String sha1String(java.lang.String input)
public static byte[] md5(java.io.File file) throws java.io.IOException, java.io.FileNotFoundException
java.io.IOException
java.io.FileNotFoundException
public static byte[] md5(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
public static java.security.cert.X509Certificate parseX509Certificate(byte[] input) throws java.security.cert.CertificateException
java.security.cert.CertificateException
public static java.util.List<java.security.cert.X509Certificate> parseX509Certificates(byte[] input) throws java.security.cert.CertificateException
java.security.cert.CertificateException
public static java.util.List<java.security.cert.X509Certificate> parseX509Certificates(java.io.InputStream inputStream) throws java.security.cert.CertificateException
java.security.cert.CertificateException
public static byte[] asymmetricSign(java.security.interfaces.RSAPrivateKey key, byte[] source, int offset, int length) throws java.lang.Exception
java.lang.Exception
public static boolean asymmetricVerify(java.security.interfaces.RSAPublicKey key, byte[] source, int offset, int length, byte[] signature, int sigOff, int sigLen)
public static byte[] decryptRSA(byte[] source, java.security.Key key) throws java.lang.Exception
java.lang.Exception
public static byte[] encryptDESede(byte[] toEncrypt, byte[] keyBytes) throws java.lang.Exception
toEncrypt
- A byte[] to encrypt. Must not be null.keyBytes
- The key to use. must be 24 bytes long.java.lang.Exception
public static byte[] decryptDESede(byte[] toDecrypt, byte[] keyBytes) throws java.lang.Exception
toDecrypt
- A byte[] to decrypt. Must not be null.keyBytes
- The key to use. must be 24 bytes long.java.lang.Exception
public static byte[] generateDESedKey() throws java.lang.Exception
java.lang.Exception
public static java.lang.String getCertificateThumbprint(java.security.cert.X509Certificate certificate) throws java.lang.Exception
certificate
- java.lang.Exception
public static java.lang.String certificateThumbprintToString(byte[] buf) throws java.lang.Exception
java.lang.Exception
public static byte[] getCertificateThumbprintBytes(java.security.cert.X509Certificate certificate) throws java.security.cert.CertificateEncodingException
certificate
- java.security.cert.CertificateEncodingException