static void toJson(PfxOptions obj, java.util.Map<String, Object> json) { if (obj.getPassword() != null) { json.put("password", obj.getPassword()); } if (obj.getPath() != null) { json.put("path", obj.getPath()); } if (obj.getValue() != null) { json.put("value", java.util.Base64.getEncoder().encodeToString(obj.getValue().getBytes())); } } }
/** * Copy constructor * * @param other the options to copy */ public PfxOptions(PfxOptions other) { super(); this.password = other.getPassword(); this.path = other.getPath(); this.value = other.getValue(); }
@Test public void testPKCS12OptionsJson() throws Exception { PfxOptions options = new PfxOptions(new JsonObject()); assertEquals(null, options.getPassword()); assertEquals(null, options.getPath()); assertEquals(null, options.getValue()); String password = TestUtils.randomAlphaString(100); String path = TestUtils.randomAlphaString(100); String value = TestUtils.randomAlphaString(100); options = new PfxOptions(new JsonObject(). put("password", password). put("path", path). put("value", value.getBytes())); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(Buffer.buffer(value), options.getValue()); }
if (pkcs12.getPath() != null) { value = () -> vertx.fileSystem().readFileBlocking(vertx.resolveFile(pkcs12.getPath()).getAbsolutePath()); } else if (pkcs12.getValue() != null) { value = pkcs12::getValue; } else {
@Test public void testCopyPKCS12Options() throws Exception { PfxOptions options = new PfxOptions(); 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 PfxOptions(options); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); options = new PfxOptions(options.toJson()); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); }
static void toJson(PfxOptions obj, java.util.Map<String, Object> json) { if (obj.getPassword() != null) { json.put("password", obj.getPassword()); } if (obj.getPath() != null) { json.put("path", obj.getPath()); } if (obj.getValue() != null) { json.put("value", java.util.Base64.getEncoder().encodeToString(obj.getValue().getBytes())); } } }
/** * Copy constructor * * @param other the options to copy */ public PfxOptions(PfxOptions other) { super(); this.password = other.getPassword(); this.path = other.getPath(); this.value = other.getValue(); }
@Test public void testPKCS12OptionsJson() throws Exception { PfxOptions options = new PfxOptions(new JsonObject()); assertEquals(null, options.getPassword()); assertEquals(null, options.getPath()); assertEquals(null, options.getValue()); String password = TestUtils.randomAlphaString(100); String path = TestUtils.randomAlphaString(100); String value = TestUtils.randomAlphaString(100); options = new PfxOptions(new JsonObject(). put("password", password). put("path", path). put("value", value.getBytes())); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(Buffer.buffer(value), options.getValue()); }
if (pkcs12.getPath() != null) { value = () -> vertx.fileSystem().readFileBlocking(vertx.resolveFile(pkcs12.getPath()).getAbsolutePath()); } else if (pkcs12.getValue() != null) { value = pkcs12::getValue; } else {
@Test public void testCopyPKCS12Options() throws Exception { PfxOptions options = new PfxOptions(); 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 PfxOptions(options); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); options = new PfxOptions(options.toJson()); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); }