Checkstyle fixes

pull/81/head
Richard Körber 2018-08-22 18:14:40 +02:00
parent a8047704aa
commit f609a797cb
No known key found for this signature in database
GPG Key ID: AAB9FD19C78AA3E0
3 changed files with 34 additions and 34 deletions

View File

@ -46,14 +46,14 @@ public class Identifier implements Serializable {
/**
* Type constant for DNS identifiers.
*/
public static final String DNS = "dns";
public static final String TYPE_DNS = "dns";
/**
* Type constant for IP identifiers.
*
* @see <a href="https://tools.ietf.org/html/draft-ietf-acme-ip">draft-ietf-acme-ip</a>
*/
public static final String IP = "ip";
public static final String TYPE_IP = "ip";
private static final String KEY_TYPE = "type";
private static final String KEY_VALUE = "value";
@ -61,28 +61,6 @@ public class Identifier implements Serializable {
private final String type;
private final String value;
/**
* Creates a new DNS identifier for the given domain name.
*
* @param domain
* Domain name. Unicode domains are automatically ASCII encoded.
* @return New {@link Identifier}
*/
public static Identifier dns(String domain) {
return new Identifier(DNS, toAce(domain));
}
/**
* Creates a new IP identifier for the given {@link InetAddress}.
*
* @param ip
* {@link InetAddress}
* @return New {@link Identifier}
*/
public static Identifier ip(InetAddress ip) {
return new Identifier(IP, ip.getHostAddress());
}
/**
* Creates a new {@link Identifier}.
* <p>
@ -112,6 +90,28 @@ public class Identifier implements Serializable {
this(json.get(KEY_TYPE).asString(), json.get(KEY_VALUE).asString());
}
/**
* Creates a new DNS identifier for the given domain name.
*
* @param domain
* Domain name. Unicode domains are automatically ASCII encoded.
* @return New {@link Identifier}
*/
public static Identifier dns(String domain) {
return new Identifier(TYPE_DNS, toAce(domain));
}
/**
* Creates a new IP identifier for the given {@link InetAddress}.
*
* @param ip
* {@link InetAddress}
* @return New {@link Identifier}
*/
public static Identifier ip(InetAddress ip) {
return new Identifier(TYPE_IP, ip.getHostAddress());
}
/**
* Returns the identifier type.
*/
@ -134,7 +134,7 @@ public class Identifier implements Serializable {
* if this is not a DNS identifier.
*/
public String getDomain() {
if (!DNS.equals(type)) {
if (!TYPE_DNS.equals(type)) {
throw new AcmeProtocolException("expected 'dns' identifier, but found '" + type + "'");
}
return value;
@ -148,7 +148,7 @@ public class Identifier implements Serializable {
* if this is not a DNS identifier.
*/
public InetAddress getIP() {
if (!IP.equals(type)) {
if (!TYPE_IP.equals(type)) {
throw new AcmeProtocolException("expected 'ip' identifier, but found '" + type + "'");
}
try {
@ -183,6 +183,6 @@ public class Identifier implements Serializable {
@Override
public int hashCode() {
return type.hashCode() ^ value.hashCode();
};
}
}

View File

@ -77,7 +77,7 @@ public class Order extends AcmeJsonResource {
@Deprecated
public List<String> getDomains() {
return getIdentifiers().stream()
.filter(i -> Identifier.DNS.equals(i.getType()))
.filter(i -> Identifier.TYPE_DNS.equals(i.getType()))
.map(Identifier::getDomain)
.collect(toList());
}

View File

@ -31,8 +31,8 @@ public class IdentifierTest {
@Test
public void testConstants() {
assertThat(Identifier.DNS, is("dns"));
assertThat(Identifier.IP, is("ip"));
assertThat(Identifier.TYPE_DNS, is("dns"));
assertThat(Identifier.TYPE_IP, is("ip"));
}
@Test
@ -62,12 +62,12 @@ public class IdentifierTest {
@Test
public void testDns() {
Identifier id1 = Identifier.dns("example.com");
assertThat(id1.getType(), is(Identifier.DNS));
assertThat(id1.getType(), is(Identifier.TYPE_DNS));
assertThat(id1.getValue(), is("example.com"));
assertThat(id1.getDomain(), is("example.com"));
Identifier id2 = Identifier.dns("ëxämþlë.com");
assertThat(id2.getType(), is(Identifier.DNS));
assertThat(id2.getType(), is(Identifier.TYPE_DNS));
assertThat(id2.getValue(), is("xn--xml-qla7ae5k.com"));
assertThat(id2.getDomain(), is("xn--xml-qla7ae5k.com"));
}
@ -80,12 +80,12 @@ public class IdentifierTest {
@Test
public void testIp() throws UnknownHostException {
Identifier id1 = Identifier.ip(InetAddress.getByName("192.168.1.2"));
assertThat(id1.getType(), is(Identifier.IP));
assertThat(id1.getType(), is(Identifier.TYPE_IP));
assertThat(id1.getValue(), is("192.168.1.2"));
assertThat(id1.getIP().getHostAddress(), is("192.168.1.2"));
Identifier id2 = Identifier.ip(InetAddress.getByName("2001:db8:85a3::8a2e:370:7334"));
assertThat(id2.getType(), is(Identifier.IP));
assertThat(id2.getType(), is(Identifier.TYPE_IP));
assertThat(id2.getValue(), is("2001:db8:85a3:0:0:8a2e:370:7334"));
assertThat(id2.getIP().getHostAddress(), is("2001:db8:85a3:0:0:8a2e:370:7334"));
}