use of org.apache.qpid.test.utils.tls.KeyCertificatePair in project qpid-broker-j by apache.
the class TrustManagerTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
final KeyCertificatePair caPair = TlsResourceBuilder.createKeyPairAndRootCA(DN_CA);
final KeyPair keyPair1 = TlsResourceBuilder.createRSAKeyPair();
final KeyPair keyPair2 = TlsResourceBuilder.createRSAKeyPair();
final KeyCertificatePair untrustedKeyCertPair = TlsResourceBuilder.createSelfSigned(DN_UNTRUSTED);
_ca = caPair.getCertificate();
_app1 = TlsResourceBuilder.createCertificateForClientAuthorization(keyPair1, caPair, DN_APP1);
_app2 = TlsResourceBuilder.createCertificateForClientAuthorization(keyPair2, caPair, DN_APP2);
_untrusted = untrustedKeyCertPair.getCertificate();
}
use of org.apache.qpid.test.utils.tls.KeyCertificatePair in project qpid-broker-j by apache.
the class FileTrustStoreTest method generateTrustStoreAndCrlAsDataUrl.
private StoreAndCrl<String> generateTrustStoreAndCrlAsDataUrl() throws Exception {
final KeyCertificatePair caPair = TlsResourceBuilder.createKeyPairAndRootCA(DN_CA);
final KeyCertificatePair keyCertPair1 = TlsResourceBuilder.createKeyPairAndCertificate(DN_FOO, caPair);
final KeyCertificatePair keyCertPair2 = TlsResourceBuilder.createKeyPairAndCertificate(DN_BAR, caPair);
final String trustStoreAsDataUrl = TLS_RESOURCE.createKeyStoreAsDataUrl(new CertificateEntry(CERTIFICATE_ALIAS_A, keyCertPair1.getCertificate()), new CertificateEntry(CERTIFICATE_ALIAS_B, keyCertPair2.getCertificate()));
final String crlAsDataUrl = TLS_RESOURCE.createCrlAsDataUrl(caPair, keyCertPair2.getCertificate());
return new StoreAndCrl<>(trustStoreAsDataUrl, crlAsDataUrl, caPair);
}
use of org.apache.qpid.test.utils.tls.KeyCertificatePair in project qpid-broker-j by apache.
the class FileTrustStoreTest method testCreatePeersOnlyTrustStoreFromFile_Success.
@Test
public void testCreatePeersOnlyTrustStoreFromFile_Success() throws Exception {
final KeyCertificatePair keyPairAndRootCA = TlsResourceBuilder.createKeyPairAndRootCA(DN_CA);
final Path keyStoreFile = TLS_RESOURCE.createTrustStore(DN_FOO, keyPairAndRootCA);
Map<String, Object> attributes = new HashMap<>();
attributes.put(FileTrustStore.NAME, NAME);
attributes.put(FileTrustStore.STORE_URL, keyStoreFile.toFile().getAbsolutePath());
attributes.put(FileTrustStore.PASSWORD, TLS_RESOURCE.getSecret());
attributes.put(FileTrustStore.PEERS_ONLY, true);
attributes.put(FileTrustStore.TRUST_STORE_TYPE, TLS_RESOURCE.getKeyStoreType());
final FileTrustStore<?> fileTrustStore = createFileTrustStore(attributes);
TrustManager[] trustManagers = fileTrustStore.getTrustManagers();
assertNotNull(trustManagers);
assertEquals("Unexpected number of trust managers", 1, trustManagers.length);
assertNotNull("Trust manager unexpected null", trustManagers[0]);
final boolean condition = trustManagers[0] instanceof QpidPeersOnlyTrustManager;
assertTrue("Trust manager unexpected null", condition);
}
use of org.apache.qpid.test.utils.tls.KeyCertificatePair in project qpid-broker-j by apache.
the class NonJavaKeyStoreTest method testCreationOfKeyStoreWithNonMatchingPrivateKeyAndCertificate.
@Test
public void testCreationOfKeyStoreWithNonMatchingPrivateKeyAndCertificate() throws Exception {
final KeyCertificatePair keyCertPair2 = generateSelfSignedCertificate();
final Map<String, Object> attributes = new HashMap<>();
attributes.put(NonJavaKeyStore.NAME, NAME);
attributes.put(NonJavaKeyStore.PRIVATE_KEY_URL, getPrivateKeyAsDataUrl(_keyCertPair.getPrivateKey()));
attributes.put(NonJavaKeyStore.CERTIFICATE_URL, getCertificateAsDataUrl(keyCertPair2.getCertificate()));
attributes.put(NonJavaKeyStore.TYPE, NON_JAVA_KEY_STORE);
KeyStoreTestHelper.checkExceptionThrownDuringKeyStoreCreation(FACTORY, BROKER, KeyStore.class, attributes, "Private key does not match certificate");
}
use of org.apache.qpid.test.utils.tls.KeyCertificatePair in project qpid-broker-j by apache.
the class SiteSpecificTrustStoreTest method setUpSiteSpecificTrustStore.
@Before
public void setUpSiteSpecificTrustStore() throws Exception {
int connectTimeout = Integer.getInteger("SiteSpecificTrustStoreTest.connectTimeout", 1000);
int readTimeout = Integer.getInteger("SiteSpecificTrustStoreTest.readTimeout", 1000);
setTestSystemProperty(SiteSpecificTrustStore.TRUST_STORE_SITE_SPECIFIC_CONNECT_TIMEOUT, String.valueOf(connectTimeout));
setTestSystemProperty(SiteSpecificTrustStore.TRUST_STORE_SITE_SPECIFIC_READ_TIMEOUT, String.valueOf(readTimeout));
_caKeyCertPair = TlsResourceBuilder.createKeyPairAndRootCA(EXPECTED_ISSUER);
_keyCertPair = TlsResourceBuilder.createKeyPairAndCertificate(EXPECTED_SUBJECT, _caKeyCertPair);
final KeyCertificatePair keyCertPair2 = TlsResourceBuilder.createKeyPairAndCertificate(DN_BAR, _caKeyCertPair);
_clrUrl = TLS_RESOURCE.createCrlAsDataUrl(_caKeyCertPair, keyCertPair2.getCertificate());
}
Aggregations