diff options
author | Bjørn Christian Seime <bjorncs@oath.com> | 2018-01-11 13:33:50 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@oath.com> | 2018-01-16 13:32:30 +0100 |
commit | e0c79b6d0e85d7962ba3fd7a3b0054a72991f88c (patch) | |
tree | 2a58d5e33bfa48ebcda1e8bc98f64cde98b1a8f9 /vespa-athenz | |
parent | 2f55bdbcdfb09c0a1f031c93cb3152582f2d0f81 (diff) |
Move AthenzDomain to vespa-athenz
Diffstat (limited to 'vespa-athenz')
-rw-r--r-- | vespa-athenz/pom.xml | 25 | ||||
-rw-r--r-- | vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/AthenzDomain.java | 71 | ||||
-rw-r--r-- | vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/package-info.java | 9 |
3 files changed, 105 insertions, 0 deletions
diff --git a/vespa-athenz/pom.xml b/vespa-athenz/pom.xml index cf5cb4d1be6..a095b723c35 100644 --- a/vespa-athenz/pom.xml +++ b/vespa-athenz/pom.xml @@ -99,6 +99,31 @@ <groupId>com.yahoo.vespa</groupId> <artifactId>bundle-plugin</artifactId> <extensions>true</extensions> + <configuration> + <useCommonAssemblyIds>false</useCommonAssemblyIds> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>attach-artifacts</id> + <phase>package</phase> + <goals> + <goal>attach-artifact</goal> + </goals> + <configuration> + <artifacts> + <artifact> + <file>target/${project.artifactId}-deploy.jar</file> + <type>jar</type> + <classifier>deploy</classifier> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> </plugin> </plugins> </build> diff --git a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/AthenzDomain.java b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/AthenzDomain.java new file mode 100644 index 00000000000..72d7785c282 --- /dev/null +++ b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/AthenzDomain.java @@ -0,0 +1,71 @@ +// 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.api; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +import java.util.Objects; +import java.util.regex.Pattern; + +/** + * @author bjorncs + */ +public class AthenzDomain { + + private static final Pattern NAME_PATTERN = Pattern.compile("[a-zA-Z0-9_][a-zA-Z0-9_\\-.]*[a-zA-Z0-9_]"); + + private final String name; + + @JsonCreator + public AthenzDomain(String name) { + validateName(name); + this.name = name; + } + + private static void validateName(String name) { + if (!NAME_PATTERN.matcher(name).matches()) { + throw new IllegalArgumentException("Not a valid domain name: '" + name + "'"); + } + } + + @JsonValue + public String getName() { + return name; + } + + public boolean isTopLevelDomain() { + return !name.contains("."); + } + + public AthenzDomain getParent() { + return new AthenzDomain(name.substring(0, lastDot())); + } + + public String getNameSuffix() { + return name.substring(lastDot() + 1); + } + + private int lastDot() { + return name.lastIndexOf('.'); + } + + @Override + public String toString() { + return "AthenzDomain{" + + "name='" + name + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + AthenzDomain that = (AthenzDomain) o; + return Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } +} diff --git a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/package-info.java b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/package-info.java new file mode 100644 index 00000000000..ddba56395d2 --- /dev/null +++ b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/package-info.java @@ -0,0 +1,9 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +/** + * @author bjorncs + */ + +@ExportPackage +package com.yahoo.vespa.athenz.api; + +import com.yahoo.osgi.annotation.ExportPackage;
\ No newline at end of file |