use of com.adaptris.security.certificate.CertificateBuilder in project interlok by adaptris.
the class TestCertificateGeneration method testCertificateToKeystore.
@Test
public void testCertificateToKeystore() throws Exception {
String commonName = String.valueOf(random.nextInt(1000));
CertificateBuilder builder = Config.getInstance().getBuilder(commonName);
Certificate selfCert = builder.createSelfSignedCertificate();
builder.getPrivateKey();
ksp = KeystoreFactory.getDefault().create(ksc);
try {
ksp.load();
} catch (Exception e) {
;
}
ksp.setCertificate(commonName, selfCert);
ksp.commit();
}
use of com.adaptris.security.certificate.CertificateBuilder in project interlok by adaptris.
the class TestPassword method specificMicrosoftSetup.
/*
* Ensure that the Windows-MY keystore actually has a certificate
* chain and a private key
*/
private void specificMicrosoftSetup() throws Exception {
String username = System.getProperty("user.name");
KeyStore ks = KeyStore.getInstance("Windows-MY");
ks.load(null, null);
if (!ks.containsAlias(username)) {
CertificateBuilder builder = Config.getInstance().getBuilder(username);
X509Certificate[] chain = new X509Certificate[1];
chain[0] = (X509Certificate) builder.createSelfSignedCertificate();
ks.setKeyEntry(username, builder.getPrivateKey(), username.toCharArray(), chain);
}
}
use of com.adaptris.security.certificate.CertificateBuilder in project interlok by adaptris.
the class TestCertificateGeneration method testEncodedCertificateToKeystore.
@Test
public void testEncodedCertificateToKeystore() throws Exception {
String commonName = String.valueOf(random.nextInt(1000));
CertificateBuilder builder = Config.getInstance().getBuilder(commonName);
Certificate selfCert = builder.createSelfSignedCertificate();
builder.getPrivateKey();
ksp = KeystoreFactory.getDefault().create(ksc);
try {
ksp.load();
} catch (Exception e) {
;
}
ksp.setCertificate(commonName, new ByteArrayInputStream(selfCert.getEncoded()));
ksp.commit();
}
use of com.adaptris.security.certificate.CertificateBuilder in project interlok by adaptris.
the class TestCertificateGeneration method testCreateCertificateRequest.
@Test
public void testCreateCertificateRequest() {
try {
String commonName = String.valueOf(random.nextInt(1000));
CertificateBuilder builder = Config.getInstance().getBuilder(commonName);
Certificate selfCert = builder.createSelfSignedCertificate();
PrivateKey privkey = builder.getPrivateKey();
String s = CertRequestHandler.createRequest(selfCert, privkey);
logR.trace(s);
} catch (Exception e) {
logR.error(e.getMessage(), e);
fail(e.getMessage());
}
}
use of com.adaptris.security.certificate.CertificateBuilder in project interlok by adaptris.
the class TestCertificateGeneration method testCertificateGeneration.
@Test
public void testCertificateGeneration() throws Exception {
String commonName = String.valueOf(random.nextInt(1000));
CertificateBuilder builder = Config.getInstance().getBuilder(commonName);
Certificate selfCert = builder.createSelfSignedCertificate();
CertificateHandler ch = CertificateHandlerFactory.getInstance().generateHandler(selfCert);
String signatureAlgorithm = ch.getSignatureAlgorithm();
String property = cfg.getProperty(Config.CERTIFICATE_SIGALG);
// AlgorithmID algorithmID = SecurityUtil.getAlgorithmID(signatureAlgorithm);
// AlgorithmID configID = SecurityUtil.getAlgorithmID(property);
assertEquals("Signature Algorithm", signatureAlgorithm, property);
assertEquals("Key Algorithm", cfg.getProperty(Config.CERTIFICATE_KEYALG), ch.getKeyAlgorithm());
}
Aggregations