diff options
author | Bjørn Christian Seime <bjorncs@oath.com> | 2018-05-24 13:23:16 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@oath.com> | 2018-05-24 13:23:16 +0200 |
commit | aaafe2ddda2ed6e094b79556ceb4033e8dd78dfb (patch) | |
tree | d7fc852bb9ca05eeba7e8e9fb07f308ae5d721dd /vespa-athenz | |
parent | 762cc80910eb731df15111faa5536dc22c830f6c (diff) |
Add SIA utility class
Diffstat (limited to 'vespa-athenz')
-rw-r--r-- | vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java new file mode 100644 index 00000000000..adaafab4617 --- /dev/null +++ b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java @@ -0,0 +1,39 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.athenz.utils; + +import com.yahoo.vespa.athenz.api.AthenzService; + +import java.nio.file.Path; +import java.nio.file.Paths; + +/** + * Misc utility methods for SIA provided credentials + * + * @author bjorncs + */ +public class SiaUtils { + public static final Path DEFAULT_SIA_DIRECTORY = Paths.get("/var/lib/sia"); + + private SiaUtils() {} + + public static Path getPrivateKeyFile(AthenzService service) { + return getPrivateKeyFile(DEFAULT_SIA_DIRECTORY, service); + } + + public static Path getPrivateKeyFile(Path root, AthenzService service) { + return root + .resolve("keys") + .resolve(String.format("%s.%s.key.pem", service.getDomainName(), service.getName())); + } + + public static Path getCertificateFile(AthenzService service) { + return getCertificateFile(DEFAULT_SIA_DIRECTORY, service); + } + + public static Path getCertificateFile(Path root, AthenzService service) { + return root + .resolve("certs") + .resolve(String.format("%s.%s.cert.pem", service.getDomainName(), service.getName())); + } + +} |