Search in sources :

Example 21 with AdaptrisSecurityException

use of com.adaptris.security.exc.AdaptrisSecurityException in project interlok by adaptris.

the class DecryptionServiceTest method testFailedDecryptionWithBranch.

@Test
public void testFailedDecryptionWithBranch() throws Exception {
    String url = createKeystore();
    EncryptionSigningService input = new EncryptionSigningService();
    applyConfigForTests(input, url);
    DecryptionService output = new DecryptionService();
    applyConfigForTests(output, url);
    output.setFailId(FAIL);
    output.setSuccessId(SUCCESS);
    output.setLocalPartner(NON_EXISTENT_ALIAS);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(EXAMPLE_MSG);
    execute(input, msg);
    execute(output, msg);
    assertEquals(FAIL, msg.getNextServiceId());
    assertTrue(msg.getObjectHeaders().containsKey(CoreConstants.OBJ_METADATA_EXCEPTION));
    assertTrue(msg.getObjectHeaders().get(CoreConstants.OBJ_METADATA_EXCEPTION) instanceof AdaptrisSecurityException);
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) AdaptrisSecurityException(com.adaptris.security.exc.AdaptrisSecurityException) Test(org.junit.Test)

Example 22 with AdaptrisSecurityException

use of com.adaptris.security.exc.AdaptrisSecurityException in project interlok by adaptris.

the class TestKeyStore method testKeystoreImportCertificateInvalidFilename.

@Test
public void testKeystoreImportCertificateInvalidFilename() throws Exception {
    ksp = KeystoreFactory.getDefault().create(kloc);
    ksp.load();
    try {
        ksp.setCertificate(String.valueOf(new Random().nextInt()), "XXXX");
        fail("Import of missing cert succeeded");
    } catch (AdaptrisSecurityException e) {
        // expected
        ;
    }
}
Also used : Random(java.util.Random) AdaptrisSecurityException(com.adaptris.security.exc.AdaptrisSecurityException) Test(org.junit.Test)

Example 23 with AdaptrisSecurityException

use of com.adaptris.security.exc.AdaptrisSecurityException in project interlok by adaptris.

the class TestKeyStore method testKeystoreImportCertificateChainInvalidAlias.

@Test
public void testKeystoreImportCertificateChainInvalidAlias() throws Exception {
    config.importPrivateKey(cfg.getProperty(Config.KEYSTORE_TEST_URL), cfg.getProperty(Config.KEYSTORE_IMPORT_PKCS12_FILE), true);
    ksp = KeystoreFactory.getDefault().create(kloc);
    ksp.load();
    try {
        ksp.importCertificateChain(String.valueOf(new Random().nextInt()), cfg.getProperty(Config.KEYSTORE_COMMON_KEYSTORE_PW).toCharArray(), cfg.getProperty(Config.KEYSTORE_IMPORT_CERTCHAIN_FILE));
        fail("Import of non-existent certchain succeeded");
    } catch (AdaptrisSecurityException e) {
        // expected
        ;
    }
    ksp.commit();
}
Also used : Random(java.util.Random) AdaptrisSecurityException(com.adaptris.security.exc.AdaptrisSecurityException) Test(org.junit.Test)

Aggregations

AdaptrisSecurityException (com.adaptris.security.exc.AdaptrisSecurityException)23 CertException (com.adaptris.security.exc.CertException)11 KeystoreException (com.adaptris.security.exc.KeystoreException)10 EncryptException (com.adaptris.security.exc.EncryptException)7 VerifyException (com.adaptris.security.exc.VerifyException)7 IOException (java.io.IOException)7 DecryptException (com.adaptris.security.exc.DecryptException)5 GeneralSecurityException (java.security.GeneralSecurityException)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 NoSuchProviderException (java.security.NoSuchProviderException)5 PrivateKey (java.security.PrivateKey)5 X509Certificate (java.security.cert.X509Certificate)4 Test (org.junit.Test)4 Certificate (java.security.cert.Certificate)3 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 HttpException (com.adaptris.http.HttpException)2 HttpsClient (com.adaptris.http.HttpsClient)2 Alias (com.adaptris.security.keystore.Alias)2 KeystoreFactory (com.adaptris.security.keystore.KeystoreFactory)2 KeystoreLocation (com.adaptris.security.keystore.KeystoreLocation)2