Search in sources :

Example 11 with JsonbConfig

use of jakarta.json.bind.JsonbConfig in project zilla by aklivity.

the class SseConditionConfigAdapterTest method initJson.

@Before
public void initJson() {
    JsonbConfig config = new JsonbConfig().withAdapters(new SseConditionConfigAdapter());
    jsonb = JsonbBuilder.create(config);
}
Also used : JsonbConfig(jakarta.json.bind.JsonbConfig) Before(org.junit.Before)

Example 12 with JsonbConfig

use of jakarta.json.bind.JsonbConfig in project zilla by aklivity.

the class FileSystemOptionsConfigAdapterTest method initJson.

@Before
public void initJson() {
    JsonbConfig config = new JsonbConfig().withAdapters(new FileSystemOptionsConfigAdapter());
    jsonb = JsonbBuilder.create(config);
}
Also used : JsonbConfig(jakarta.json.bind.JsonbConfig) Before(org.junit.Before)

Example 13 with JsonbConfig

use of jakarta.json.bind.JsonbConfig in project zilla by aklivity.

the class SseKafkaConditionConfigAdapterTest method initJson.

@Before
public void initJson() {
    JsonbConfig config = new JsonbConfig().withAdapters(new SseKafkaConditionConfigAdapter());
    jsonb = JsonbBuilder.create(config);
}
Also used : JsonbConfig(jakarta.json.bind.JsonbConfig) Before(org.junit.Before)

Example 14 with JsonbConfig

use of jakarta.json.bind.JsonbConfig in project zilla by aklivity.

the class ZpmEncrypt method writeSecurity.

private void writeSecurity(ZpmSecurity security) throws IOException {
    Path securityFile = settingsDir.resolve("security.json");
    Jsonb builder = JsonbBuilder.newBuilder().withConfig(new JsonbConfig().withFormatting(true)).build();
    createDirectories(settingsDir);
    try (OutputStream out = newOutputStream(securityFile)) {
        builder.toJson(security, out);
    }
}
Also used : Path(java.nio.file.Path) Jsonb(jakarta.json.bind.Jsonb) JsonbConfig(jakarta.json.bind.JsonbConfig) OutputStream(java.io.OutputStream) Files.newOutputStream(java.nio.file.Files.newOutputStream)

Example 15 with JsonbConfig

use of jakarta.json.bind.JsonbConfig in project zilla by aklivity.

the class ZpmInstall method readSettings.

private void readSettings(Path settingsDir) throws IOException, PlexusCipherException {
    Path settingsFile = settingsDir.resolve("settings.json");
    ZpmSettings settings = new ZpmSettings();
    settings.credentials = emptyList();
    Jsonb builder = JsonbBuilder.newBuilder().withConfig(new JsonbConfig().withFormatting(true)).build();
    if (Files.exists(settingsFile)) {
        try (InputStream in = newInputStream(settingsFile)) {
            settings = builder.fromJson(in, ZpmSettings.class);
        }
    }
    if (settings.credentials.size() > 0) {
        Path securityFile = settingsDir.resolve("security.json");
        ZpmSecurity security = new ZpmSecurity();
        if (Files.exists(securityFile)) {
            try (InputStream in = newInputStream(securityFile)) {
                security = builder.fromJson(in, ZpmSecurity.class);
            }
        }
        security.secret = decryptSecret(security.secret, SYSTEM_PROPERTY_SEC_LOCATION);
        for (ZpmCredentials credentials : settings.credentials) {
            String realm = defaultRealmIfNecessary(credentials);
            String host = credentials.host;
            String username = credentials.username;
            String password = ZpmSecrets.decryptSecret(credentials.password, security.secret);
            CredentialsStore.INSTANCE.addCredentials(realm, host, username, password);
        }
    }
}
Also used : Path(java.nio.file.Path) ZpmSettings(io.aklivity.zilla.manager.internal.settings.ZpmSettings) Jsonb(jakarta.json.bind.Jsonb) JsonbConfig(jakarta.json.bind.JsonbConfig) ZpmCredentials(io.aklivity.zilla.manager.internal.settings.ZpmCredentials) Files.newInputStream(java.nio.file.Files.newInputStream) InputStream(java.io.InputStream) ZpmSecurity(io.aklivity.zilla.manager.internal.settings.ZpmSecurity)

Aggregations

JsonbConfig (jakarta.json.bind.JsonbConfig)45 Before (org.junit.Before)28 Jsonb (jakarta.json.bind.Jsonb)12 Test (org.junit.jupiter.api.Test)5 InputStream (java.io.InputStream)4 Files.newInputStream (java.nio.file.Files.newInputStream)3 Path (java.nio.file.Path)3 ZpmSecurity (io.aklivity.zilla.manager.internal.settings.ZpmSecurity)2 Annot8ComponentDescriptor (io.annot8.api.components.Annot8ComponentDescriptor)2 Descriptor (io.annot8.common.serialization.TestNested.Descriptor)2 OutputStream (java.io.OutputStream)2 Files.newOutputStream (java.nio.file.Files.newOutputStream)2 ZpmCredentials (io.aklivity.zilla.manager.internal.settings.ZpmCredentials)1 ZpmSettings (io.aklivity.zilla.manager.internal.settings.ZpmSettings)1 Engine (io.aklivity.zilla.runtime.engine.Engine)1 EngineConfiguration (io.aklivity.zilla.runtime.engine.EngineConfiguration)1 BindingConfig (io.aklivity.zilla.runtime.engine.config.BindingConfig)1 NamespaceConfig (io.aklivity.zilla.runtime.engine.config.NamespaceConfig)1 RouteConfig (io.aklivity.zilla.runtime.engine.config.RouteConfig)1 VaultConfig (io.aklivity.zilla.runtime.engine.config.VaultConfig)1