Package org.opensaml.security.crypto
Class KeySupportTest
- java.lang.Object
-
- org.opensaml.security.crypto.KeySupportTest
-
public class KeySupportTest extends Object
Unit test forKeySupport.
-
-
Field Summary
Fields Modifier and Type Field Description private StringdsaPrivKeyDERNoEncryptLocation of non-encrypted, DER formatted, dSA private key.private StringdsaPrivKeyPEMEncryptLocation of encrypted, PEM formatted, DSA private key.private StringdsaPrivKeyPEMNoEncryptLocation of non-encrypted, PEM formatted, dSA private key.private StringecPrivKeyPEMNoEncryptLocation of non-encrypted, PEM formatted, EC private key.private static StringINVALID_BASE64_KEYAn invalid base64 string.private org.slf4j.Loggerlogprivate char[]privKeyPasswordPassword for private key.private StringrsaPrivKeyDERNoEncryptLocation of non-encrypted, DER formatted, RSA private key.private StringrsaPrivKeyPEMEncryptLocation of encrypted, PEM formatted, RSA private key.private StringrsaPrivKeyPEMNoEncryptLocation of non-encrypted, PEM formatted, RSA private key.
-
Constructor Summary
Constructors Constructor Description KeySupportTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object[][]decodeSecretKeyData()voidtestBuildJavaDSAPublicKeyWithInvalidBase64()voidtestBuildJavaECPublicKeyWithInvalidBase64()voidtestBuildJavaRSAPublicKeyWithInvalidBase64()voidtestDecodeDSAPrivateKeyDERNoEncrypt()Test decoding an DSA private key, in DER format, without encryption.voidtestDecodeDSAPrivateKeyPEMEncrypt()Test decoding an DSA private key, in PEM format, with encryption.voidtestDecodeDSAPrivateKeyPEMNoEncrypt()Test decoding an DSA private key, in PEM format, without encryption.voidtestDecodeECPrivateKeyPEMNoEncrypt()Test decoding an EC private key, in PEM format, without encryption.voidtestDecodeRSAPrivateKeyDERNoEncrypt()Test decoding an RSA private key, in DER format, without encryption.voidtestDecodeRSAPrivateKeyPEMEncrypt()Test decoding an RSA private key, in PEM format, with encryption.voidtestDecodeRSAPrivateKeyPEMNoEncrypt()Test decoding an RSA private key, in PEM format, without encryption.voidtestDecodeSecretKey(Integer keyLengthBits, String algorithm)voidtestDerivePublicKey()Test deriving a public key from an RSA and DSA private key.voidtestKeyLength()voidtestKeyPairMatching()Test the evaluation that 2 keys are members of the same key pair.protected PrivateKeytestPrivKey(String keyFile, char[] password, String algo)Generic key testing.
-
-
-
Field Detail
-
log
private final org.slf4j.Logger log
-
rsaPrivKeyPEMNoEncrypt
private String rsaPrivKeyPEMNoEncrypt
Location of non-encrypted, PEM formatted, RSA private key.
-
rsaPrivKeyDERNoEncrypt
private String rsaPrivKeyDERNoEncrypt
Location of non-encrypted, DER formatted, RSA private key.
-
dsaPrivKeyPEMNoEncrypt
private String dsaPrivKeyPEMNoEncrypt
Location of non-encrypted, PEM formatted, dSA private key.
-
dsaPrivKeyDERNoEncrypt
private String dsaPrivKeyDERNoEncrypt
Location of non-encrypted, DER formatted, dSA private key.
-
privKeyPassword
private char[] privKeyPassword
Password for private key.
-
rsaPrivKeyPEMEncrypt
private String rsaPrivKeyPEMEncrypt
Location of encrypted, PEM formatted, RSA private key.
-
dsaPrivKeyPEMEncrypt
private String dsaPrivKeyPEMEncrypt
Location of encrypted, PEM formatted, DSA private key.
-
ecPrivKeyPEMNoEncrypt
private String ecPrivKeyPEMNoEncrypt
Location of non-encrypted, PEM formatted, EC private key.
-
INVALID_BASE64_KEY
private static final String INVALID_BASE64_KEY
An invalid base64 string.- See Also:
- Constant Field Values
-
-
Method Detail
-
testDecodeRSAPrivateKeyPEMNoEncrypt
public void testDecodeRSAPrivateKeyPEMNoEncrypt() throws ExceptionTest decoding an RSA private key, in PEM format, without encryption.- Throws:
Exception- if something goes wrong
-
testDecodeRSAPrivateKeyPEMEncrypt
public void testDecodeRSAPrivateKeyPEMEncrypt() throws ExceptionTest decoding an RSA private key, in PEM format, with encryption.- Throws:
Exception- if something goes wrong
-
testDecodeRSAPrivateKeyDERNoEncrypt
public void testDecodeRSAPrivateKeyDERNoEncrypt() throws ExceptionTest decoding an RSA private key, in DER format, without encryption.- Throws:
Exception- if something goes wrong
-
testDecodeDSAPrivateKeyPEMNoEncrypt
public void testDecodeDSAPrivateKeyPEMNoEncrypt() throws ExceptionTest decoding an DSA private key, in PEM format, without encryption.- Throws:
Exception- if something goes wrong
-
testDecodeDSAPrivateKeyPEMEncrypt
public void testDecodeDSAPrivateKeyPEMEncrypt() throws ExceptionTest decoding an DSA private key, in PEM format, with encryption.- Throws:
Exception- if something goes wrong
-
testDecodeDSAPrivateKeyDERNoEncrypt
public void testDecodeDSAPrivateKeyDERNoEncrypt() throws ExceptionTest decoding an DSA private key, in DER format, without encryption.- Throws:
Exception- if something goes wrong
-
testDecodeECPrivateKeyPEMNoEncrypt
public void testDecodeECPrivateKeyPEMNoEncrypt() throws ExceptionTest decoding an EC private key, in PEM format, without encryption.- Throws:
Exception- if something goes wrong
-
testDerivePublicKey
public void testDerivePublicKey() throws ExceptionTest deriving a public key from an RSA and DSA private key.- Throws:
Exception- if something goes wrong
-
testKeyPairMatching
public void testKeyPairMatching() throws NoSuchAlgorithmException, NoSuchProviderException, org.opensaml.security.SecurityExceptionTest the evaluation that 2 keys are members of the same key pair.- Throws:
NoSuchProviderException- ...NoSuchAlgorithmException- ...org.opensaml.security.SecurityException- ...
-
testKeyLength
public void testKeyLength() throws NoSuchAlgorithmException, NoSuchProviderException
-
decodeSecretKeyData
@DataProvider public Object[][] decodeSecretKeyData()
-
testDecodeSecretKey
public void testDecodeSecretKey(Integer keyLengthBits, String algorithm) throws NoSuchAlgorithmException, KeyException
- Throws:
NoSuchAlgorithmExceptionKeyException
-
testBuildJavaDSAPublicKeyWithInvalidBase64
public void testBuildJavaDSAPublicKeyWithInvalidBase64() throws KeyException- Throws:
KeyException
-
testBuildJavaRSAPublicKeyWithInvalidBase64
public void testBuildJavaRSAPublicKeyWithInvalidBase64() throws KeyException- Throws:
KeyException
-
testBuildJavaECPublicKeyWithInvalidBase64
public void testBuildJavaECPublicKeyWithInvalidBase64() throws KeyException- Throws:
KeyException
-
testPrivKey
protected PrivateKey testPrivKey(String keyFile, char[] password, String algo) throws Exception
Generic key testing.- Parameters:
keyFile- ...password- ...algo- ...- Returns:
- the private key
- Throws:
Exception- if something goes wrong
-
-