Ejemplo n.º 1
0
 @Test(
     expectedExceptions = CryptoException.class,
     expectedExceptionsMessageRegExp = "Invalid input parameter. Certificate can not be null")
 public void testCheckIfCertificateIsTrustedUsingInvalidInput_ThrowsCryptoException()
     throws Exception {
   JKSTrustStore trustStore = new JKSTrustStore("truststore.jks", null);
   trustStore.isTrusted(null, null);
 }
Ejemplo n.º 2
0
 @Test
 public void testCheckIfCertificateIsTrusted_Ok() throws Exception {
   JKSTrustStore trustStore = new JKSTrustStore("truststore.jks", null);
   Assert.assertTrue(
       trustStore.isTrusted(
           (X509Certificate) X509CertUtil.toCert(Util.toByteArray(TestUtil.load("server.crt"))),
           null));
 }
Ejemplo n.º 3
0
 @Test(
     expectedExceptions = CryptoException.class,
     expectedExceptionsMessageRegExp = "General security error occurred. Uninitialized keystore")
 public void testUseUninitializedKeyStore_ThrowsCryptoException() throws Exception {
   JKSTrustStore trustStore = new JKSTrustStore(KeyStore.getInstance("JKS"), null);
   trustStore.isTrusted(
       (X509Certificate) X509CertUtil.toCert(Util.toByteArray(TestUtil.load("server.crt"))), null);
 }
Ejemplo n.º 4
0
 @Test
 public void testCheckIfCertificateIsTrustedWithEmail_Ok() throws Exception {
   JKSTrustStore trustStore =
       new JKSTrustStore(
           "truststore.jks",
           null,
           new X509CertificateSubjectRdnSelector("[email protected]"));
   Assert.assertTrue(
       trustStore.isTrusted(
           (X509Certificate) X509CertUtil.toCert(Util.toByteArray(TestUtil.load("server.crt"))),
           null));
 }
Ejemplo n.º 5
0
 @Test(
     expectedExceptions = InvalidCertificateException.class,
     expectedExceptionsMessageRegExp =
         "Invalid certificated subject with subjectDN [email protected].*")
 public void
     testCheckIfCertificateIsTrustedWithInvalidEmail_ThrowsInvalidCertificateSubjectException()
         throws Exception {
   JKSTrustStore trustStore =
       new JKSTrustStore(
           "truststore.jks",
           null,
           new X509CertificateSubjectRdnSelector("[email protected]"));
   Assert.assertTrue(
       trustStore.isTrusted(
           (X509Certificate) X509CertUtil.toCert(Util.toByteArray(TestUtil.load("server.crt"))),
           null));
 }