public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, JksOptions obj) { for (java.util.Map.Entry<String, Object> member : json) { switch (member.getKey()) { case "password": if (member.getValue() instanceof String) { obj.setPassword((String)member.getValue()); } break; case "path": if (member.getValue() instanceof String) { obj.setPath((String)member.getValue()); } break; case "value": if (member.getValue() instanceof String) { obj.setValue(io.vertx.core.buffer.Buffer.buffer(java.util.Base64.getDecoder().decode((String)member.getValue()))); } break; } } }
@Test public void testJKSValue() throws Exception { JksOptions options = Cert.SERVER_JKS.get(); Buffer store = vertx.fileSystem().readFileBlocking(options.getPath()); options.setPath(null).setValue(store); testKeyStore(options); }
@Test public void testCopyJKSOptions() throws Exception { JksOptions options = new JksOptions(); String password = TestUtils.randomAlphaString(100); String path = TestUtils.randomAlphaString(100); Buffer value = Buffer.buffer(TestUtils.randomAlphaString(100)); options.setPassword(password); options.setPath(path); options.setValue(value); options = new JksOptions(options); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); options = new JksOptions(options.toJson()); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); }
public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, JksOptions obj) { for (java.util.Map.Entry<String, Object> member : json) { switch (member.getKey()) { case "password": if (member.getValue() instanceof String) { obj.setPassword((String)member.getValue()); } break; case "path": if (member.getValue() instanceof String) { obj.setPath((String)member.getValue()); } break; case "value": if (member.getValue() instanceof String) { obj.setValue(io.vertx.core.buffer.Buffer.buffer(java.util.Base64.getDecoder().decode((String)member.getValue()))); } break; } } }
@Test public void testJKSValue() throws Exception { JksOptions options = Cert.SERVER_JKS.get(); Buffer store = vertx.fileSystem().readFileBlocking(options.getPath()); options.setPath(null).setValue(store); testKeyStore(options); }
jksOptions.setPath(jksTrustStore.getPath()); } else { jksOptions.setValue(io.vertx.core.buffer.Buffer.buffer(jksTrustStore.getContent())); jksOptions.setPath(jksKeyStore.getPath()); } else if (jksKeyStore.getContent() != null && !jksKeyStore.getContent().isEmpty()) { jksOptions.setValue(io.vertx.core.buffer.Buffer.buffer(jksKeyStore.getContent()));
jksOptions.setPath(jksTrustStore.getPath()); } else { jksOptions.setValue(io.vertx.core.buffer.Buffer.buffer(jksTrustStore.getContent())); jksOptions.setPath(jksKeyStore.getPath()); } else if (jksKeyStore.getContent() != null && !jksKeyStore.getContent().isEmpty()) { jksOptions.setValue(io.vertx.core.buffer.Buffer.buffer(jksKeyStore.getContent()));
private JksOptions getJksOptions(String key, String defaultResource) { JsonObject config = config() .getJsonObject(key, new JsonObject()); JksOptions jksOptions = new JksOptions() .setPassword(config.getString("password", "secret")) .setValue(getResource(config.getString("resourceName", defaultResource))); return jksOptions; }
@Test public void testCopyJKSOptions() throws Exception { JksOptions options = new JksOptions(); String password = TestUtils.randomAlphaString(100); String path = TestUtils.randomAlphaString(100); Buffer value = Buffer.buffer(TestUtils.randomAlphaString(100)); options.setPassword(password); options.setPath(path); options.setValue(value); options = new JksOptions(options); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); options = new JksOptions(options.toJson()); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); }
jksOptions.setPath(jksTrustStore.getPath()); } else if (jksTrustStore.getContent() != null && !jksTrustStore.getContent().isEmpty()) { jksOptions.setValue(io.vertx.core.buffer.Buffer.buffer(jksTrustStore.getContent())); } else { throw new EndpointException("Missing JKS value for endpoint " + endpoint.getName()); jksOptions.setPath(jksKeyStore.getPath()); } else if (jksKeyStore.getContent() != null && !jksKeyStore.getContent().isEmpty()) { jksOptions.setValue(io.vertx.core.buffer.Buffer.buffer(jksKeyStore.getContent()));
jksOptions.setPath(jksTrustStore.getPath()); } else if (jksTrustStore.getContent() != null && !jksTrustStore.getContent().isEmpty()) { jksOptions.setValue(io.vertx.core.buffer.Buffer.buffer(jksTrustStore.getContent())); } else { throw new EndpointException("Missing JKS value for endpoint " + endpoint.getName()); jksOptions.setPath(jksKeyStore.getPath()); } else if (jksKeyStore.getContent() != null && !jksKeyStore.getContent().isEmpty()) { jksOptions.setValue(io.vertx.core.buffer.Buffer.buffer(jksKeyStore.getContent()));