aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-maven-plugin
diff options
context:
space:
mode:
authorØyvind Grønnesby <oyving@verizonmedia.com>2019-10-08 11:27:15 +0200
committerØyvind Grønnesby <oyving@verizonmedia.com>2019-10-08 11:27:15 +0200
commitc4568fbebed3fe572453222892b631da97301f8e (patch)
tree408f7e03415e98b09cfab52894316e7eb57a9135 /vespa-maven-plugin
parent81390fb09c459e594a58f70ed7817278bfb7343e (diff)
When the privateKey is set, assume we don't need the certificate parameter
Diffstat (limited to 'vespa-maven-plugin')
-rw-r--r--vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java
index fac8b8b792a..9bd995ef106 100644
--- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java
+++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java
@@ -8,7 +8,9 @@ import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
+import java.io.IOException;
import java.net.URI;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -70,16 +72,15 @@ public abstract class AbstractVespaMojo extends AbstractMojo {
instance = firstNonBlank(instance, project.getProperties().getProperty("instance", "default"));
id = ApplicationId.from(tenant, application, instance);
- if (privateKey == null || privateKey.isEmpty()) {
- if (privateKeyFile == null || privateKeyFile.isEmpty()) {
- throw new IllegalArgumentException("Missing 'privateKey' or 'privateKeyFile' properties.");
- }
- privateKey = Paths.get(privateKeyFile);
+ if (privateKey != null) {
+ controller = ControllerHttpClient.withSignatureKey(URI.create(endpoint), privateKey, id);
+ } else if (privateKeyFile != null) {
+ controller = certificateFile == null
+ ? ControllerHttpClient.withSignatureKey(URI.create(endpoint), Paths.get(privateKeyFile), id)
+ : ControllerHttpClient.withKeyAndCertificate(URI.create(endpoint), Paths.get(privateKeyFile), Paths.get(certificateFile));
+ } else {
+ throw new IllegalArgumentException("One of the properties 'privateKey' or 'privateKeyFile' is required.");
}
-
- controller = certificateFile == null
- ? ControllerHttpClient.withSignatureKey(URI.create(endpoint), privateKey, id)
- : ControllerHttpClient.withKeyAndCertificate(URI.create(endpoint), Paths.get(privateKeyFile), Paths.get(certificateFile));
}
protected String projectPathOf(String first, String... rest) {