mirror of https://github.com/shred/acme4j
Checkstyle fixes
parent
a8047704aa
commit
f609a797cb
|
@ -46,14 +46,14 @@ public class Identifier implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Type constant for DNS identifiers.
|
* Type constant for DNS identifiers.
|
||||||
*/
|
*/
|
||||||
public static final String DNS = "dns";
|
public static final String TYPE_DNS = "dns";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type constant for IP identifiers.
|
* Type constant for IP identifiers.
|
||||||
*
|
*
|
||||||
* @see <a href="https://tools.ietf.org/html/draft-ietf-acme-ip">draft-ietf-acme-ip</a>
|
* @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_TYPE = "type";
|
||||||
private static final String KEY_VALUE = "value";
|
private static final String KEY_VALUE = "value";
|
||||||
|
@ -61,28 +61,6 @@ public class Identifier implements Serializable {
|
||||||
private final String type;
|
private final String type;
|
||||||
private final String value;
|
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}.
|
* Creates a new {@link Identifier}.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -112,6 +90,28 @@ public class Identifier implements Serializable {
|
||||||
this(json.get(KEY_TYPE).asString(), json.get(KEY_VALUE).asString());
|
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.
|
* Returns the identifier type.
|
||||||
*/
|
*/
|
||||||
|
@ -134,7 +134,7 @@ public class Identifier implements Serializable {
|
||||||
* if this is not a DNS identifier.
|
* if this is not a DNS identifier.
|
||||||
*/
|
*/
|
||||||
public String getDomain() {
|
public String getDomain() {
|
||||||
if (!DNS.equals(type)) {
|
if (!TYPE_DNS.equals(type)) {
|
||||||
throw new AcmeProtocolException("expected 'dns' identifier, but found '" + type + "'");
|
throw new AcmeProtocolException("expected 'dns' identifier, but found '" + type + "'");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -148,7 +148,7 @@ public class Identifier implements Serializable {
|
||||||
* if this is not a DNS identifier.
|
* if this is not a DNS identifier.
|
||||||
*/
|
*/
|
||||||
public InetAddress getIP() {
|
public InetAddress getIP() {
|
||||||
if (!IP.equals(type)) {
|
if (!TYPE_IP.equals(type)) {
|
||||||
throw new AcmeProtocolException("expected 'ip' identifier, but found '" + type + "'");
|
throw new AcmeProtocolException("expected 'ip' identifier, but found '" + type + "'");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -183,6 +183,6 @@ public class Identifier implements Serializable {
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return type.hashCode() ^ value.hashCode();
|
return type.hashCode() ^ value.hashCode();
|
||||||
};
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class Order extends AcmeJsonResource {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public List<String> getDomains() {
|
public List<String> getDomains() {
|
||||||
return getIdentifiers().stream()
|
return getIdentifiers().stream()
|
||||||
.filter(i -> Identifier.DNS.equals(i.getType()))
|
.filter(i -> Identifier.TYPE_DNS.equals(i.getType()))
|
||||||
.map(Identifier::getDomain)
|
.map(Identifier::getDomain)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ public class IdentifierTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstants() {
|
public void testConstants() {
|
||||||
assertThat(Identifier.DNS, is("dns"));
|
assertThat(Identifier.TYPE_DNS, is("dns"));
|
||||||
assertThat(Identifier.IP, is("ip"));
|
assertThat(Identifier.TYPE_IP, is("ip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -62,12 +62,12 @@ public class IdentifierTest {
|
||||||
@Test
|
@Test
|
||||||
public void testDns() {
|
public void testDns() {
|
||||||
Identifier id1 = Identifier.dns("example.com");
|
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.getValue(), is("example.com"));
|
||||||
assertThat(id1.getDomain(), is("example.com"));
|
assertThat(id1.getDomain(), is("example.com"));
|
||||||
|
|
||||||
Identifier id2 = Identifier.dns("ëxämþlë.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.getValue(), is("xn--xml-qla7ae5k.com"));
|
||||||
assertThat(id2.getDomain(), is("xn--xml-qla7ae5k.com"));
|
assertThat(id2.getDomain(), is("xn--xml-qla7ae5k.com"));
|
||||||
}
|
}
|
||||||
|
@ -80,12 +80,12 @@ public class IdentifierTest {
|
||||||
@Test
|
@Test
|
||||||
public void testIp() throws UnknownHostException {
|
public void testIp() throws UnknownHostException {
|
||||||
Identifier id1 = Identifier.ip(InetAddress.getByName("192.168.1.2"));
|
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.getValue(), is("192.168.1.2"));
|
||||||
assertThat(id1.getIP().getHostAddress(), 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"));
|
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.getValue(), is("2001:db8:85a3:0:0:8a2e:370:7334"));
|
||||||
assertThat(id2.getIP().getHostAddress(), is("2001:db8:85a3:0:0:8a2e:370:7334"));
|
assertThat(id2.getIP().getHostAddress(), is("2001:db8:85a3:0:0:8a2e:370:7334"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue