Examples of CaOptions


Examples of io.vertx.core.net.CaOptions

    }
  }

  @Test
  public void testCaInvalidPath() {
    testInvalidTrustStore(new CaOptions().addCertPath("/invalid.pem"), "java.nio.file.NoSuchFileException: /invalid.pem");
  }
View Full Code Here

Examples of io.vertx.core.net.CaOptions

    };
    for (int i = 0;i < contents.length;i++) {
      Path file = testFolder.newFile("vertx" + UUID.randomUUID().toString() + ".pem").toPath();
      Files.write(file, Collections.singleton(contents[i]));
      String expectedMessage = messages[i];
      testInvalidTrustStore(new CaOptions().addCertPath(file.toString()), expectedMessage);
    }
  }
View Full Code Here

Examples of io.vertx.core.net.CaOptions

      case JKS:
        return new JKSOptions().setPath(findFileOnClasspath("tls/client-truststore.jks")).setPassword("wibble");
      case PKCS12:
        return new PKCS12Options().setPath(findFileOnClasspath("tls/client-truststore.p12")).setPassword("wibble");
      case PEM:
        return new CaOptions().addCertPath(findFileOnClasspath("tls/server-cert.pem"));
      case PEM_CA:
        return new CaOptions().addCertPath(findFileOnClasspath("tls/ca/ca-cert.pem"));
      default:
        return null;
    }
  }
View Full Code Here

Examples of io.vertx.core.net.CaOptions

      case JKS:
        return new JKSOptions().setPath(findFileOnClasspath("tls/server-truststore.jks")).setPassword("wibble");
      case PKCS12:
        return new PKCS12Options().setPath(findFileOnClasspath("tls/server-truststore.p12")).setPassword("wibble");
      case PEM:
        return new CaOptions().addCertPath(findFileOnClasspath("tls/client-cert.pem"));
      case PEM_CA:
        return new CaOptions().addCertPath(findFileOnClasspath("tls/ca/ca-cert.pem"));
      default:
        return null;
    }
  }
View Full Code Here

Examples of io.vertx.core.net.CaOptions

    assertEquals(certValue, options.getCertValue());
  }

  @Test
  public void testCaOptions() throws Exception {
    CaOptions options = new CaOptions();

    assertEquals(Collections.emptyList(), options.getCertPaths());
    assertNullPointerException(() -> options.addCertPath(null));
    assertIllegalArgumentException(() -> options.addCertPath(""));
    String randString = TestUtils.randomAlphaString(100);
    options.addCertPath(randString);
    assertEquals(Collections.singletonList(randString), options.getCertPaths());

    assertEquals(Collections.emptyList(), options.getCertValues());
    assertNullPointerException(() -> options.addCertValue(null));
    randString = TestUtils.randomAlphaString(100);
    options.addCertValue(Buffer.buffer(randString));
    assertEquals(Collections.singletonList(Buffer.buffer(randString)), options.getCertValues());
  }
View Full Code Here

Examples of io.vertx.core.net.CaOptions

    assertEquals(Collections.singletonList(Buffer.buffer(randString)), options.getCertValues());
  }

  @Test
  public void testCaOptionsJson() throws Exception {
    CaOptions options = new CaOptions(new JsonObject());

    assertEquals(Collections.emptyList(), options.getCertPaths());
    assertEquals(Collections.emptyList(), options.getCertValues());

    String certPath = TestUtils.randomAlphaString(100);
    String certValue = TestUtils.randomAlphaString(100);
    JsonObject json = new JsonObject().
        put("certPaths", new JsonArray().add(certPath)).
        put("certValues", new JsonArray().add(certValue.getBytes()));
    options = new CaOptions(json);
    assertEquals(Collections.singletonList(certPath), options.getCertPaths());
    assertEquals(Collections.singletonList(Buffer.buffer(certValue)), options.getCertValues());
  }
View Full Code Here

Examples of io.vertx.core.net.CaOptions

    assertEquals(Collections.singletonList(Buffer.buffer(certValue)), options.getCertValues());
  }

  @Test
  public void testDefaultCaOptionsJson() {
    CaOptions def = new CaOptions();
    CaOptions json = new CaOptions(new JsonObject());
    assertEquals(def.getCertPaths(), json.getCertPaths());
    assertEquals(def.getCertValues(), json.getCertValues());
  }
View Full Code Here

Examples of io.vertx.core.net.CaOptions

    assertEquals(def.getCertValues(), json.getCertValues());
  }

  @Test
  public void testCopyCaOptions() throws Exception {
    CaOptions options = new CaOptions(new JsonObject());
    String certPath = TestUtils.randomAlphaString(100);
    Buffer certValue = Buffer.buffer(TestUtils.randomAlphaString(100));
    options.addCertPath(certPath);
    options.addCertValue(certValue);
    options = new CaOptions(options);
    assertEquals(Collections.singletonList(certPath), options.getCertPaths());
    assertEquals(Collections.singletonList(certValue), options.getCertValues());
  }
View Full Code Here

Examples of io.vertx.core.net.CaOptions

    testTrustStore(getServerTrustOptions(TS.PEM));
  }

  @Test
  public void testCaPathValue() throws Exception {
    CaOptions options = (CaOptions) getServerTrustOptions(TS.PEM);
    options.getCertPaths().
        stream().
        map(vertx.fileSystem()::readFileSync).
        forEach(options::addCertValue);
    options.getCertPaths().clear();
    testTrustStore(options);
  }
View Full Code Here

Examples of io.vertx.core.net.CaOptions

  public static KeyStoreHelper create(VertxInternal vertx, TrustStoreOptions options) {
    if (options instanceof KeyStoreOptions) {
      return create(vertx, (KeyStoreOptions) options);
    } else if (options instanceof CaOptions) {
      CaOptions caOptions = (CaOptions) options;
      Stream<Buffer> certValues = caOptions.
          getCertPaths().
          stream().
          map(path -> vertx.resolveFile(path).getAbsolutePath()).
          map(vertx.fileSystem()::readFileSync);
      certValues = Stream.concat(certValues, caOptions.getCertValues().stream());
      return new CA(certValues);
    } else {
      return null;
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.