--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Credentials xmlns="urn:mace:shibboleth:credentials:1.0" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:mace:shibboleth:credentials:1.0 credentials.xsd">
+
+ <FileResolver Id="test">
+ <Certificate format="PEM">
+ <Path>/conf/test.pemcrt</Path>
+ </Certificate>
+ <Key format="PEM" password="test123">
+ <Path>/conf/test.pkcs8.enc.pemkey</Path>
+ </Key>
+ </FileResolver>
+</Credentials>
\ No newline at end of file
inputBytes.toByteArray(),
"-----BEGIN DSA PRIVATE KEY-----",
"-----END DSA PRIVATE KEY-----"));
+
+ } else if (str.matches("^.*-----BEGIN ENCRYPTED PRIVATE KEY-----.*$")) {
+ in.close();
+ log.debug("Key appears to be DSA in raw format.");
+ return getEncryptedPkcs8Key(
+ singleDerFromPEM(
+ inputBytes.toByteArray(),
+ "-----BEGIN ENCRYPTED PRIVATE KEY-----",
+ "-----END ENCRYPTED PRIVATE KEY-----"), password.toCharArray());
}
}
in.close();
}
}
- public void testKeyStoreX509_PEM_PKCS8_Encrypted_RSA_Key() {
+ public void testKeyStoreX509_DER_PKCS8_Encrypted_RSA_Key() {
try {
InputStream inStream = new FileInputStream("data/credentials11.xml");
fail("Failed to load credentials: " + e);
}
}
+
+ public void testKeyStoreX509_PEM_PKCS8_Encrypted_RSA_Key() {
+
+ try {
+ InputStream inStream = new FileInputStream("data/credentials12.xml");
+ parser.parse(new InputSource(inStream));
+ Credentials credentials = new Credentials(parser.getDocument().getDocumentElement());
+
+ assertTrue("Credential could not be found.", credentials.containsCredential("test"));
+ Credential credential = credentials.getCredential("test");
+
+ assertTrue(
+ "Credential was loaded with an incorrect type.",
+ credential.getCredentialType() == Credential.X509);
+ assertNotNull("Private key was not loaded correctly.", credential.getPrivateKey());
+ assertEquals(
+ "Unexpected X509 certificate found.",
+ credential.getX509Certificate().getSubjectDN().getName(),
+ "CN=shib2.internet2.edu, OU=Unknown, O=Unknown, ST=Unknown, C=Unknown");
+ assertEquals(
+ "Unexpected certificate chain length.",
+ new Integer(credential.getX509CertificateChain().length),
+ new Integer(3));
+ assertEquals(
+ "Unexpected X509 certificate found.",
+ credential.getX509CertificateChain()[2].getSubjectDN().getName(),
+ "CN=HEPKI Master CA -- 20020701A, OU=Division of Information Technology, O=University of Wisconsin, L=Madison, ST=Wisconsin, C=US");
+ } catch (Exception e) {
+ fail("Failed to load credentials: " + e);
+ }
+ }
}