mirror of https://github.com/shred/acme4j
Minor code cleanup
parent
c7917b3c44
commit
e528cad215
|
@ -426,13 +426,7 @@ public class DefaultConnection implements Connection {
|
|||
if ("userActionRequired".equals(error)) {
|
||||
URI tos = collectLinks("terms-of-service").stream()
|
||||
.findFirst()
|
||||
.map(it -> {
|
||||
try {
|
||||
return conn.getURL().toURI().resolve(it);
|
||||
} catch (URISyntaxException ex) {
|
||||
throw new AcmeProtocolException("Invalid TOS URI", ex);
|
||||
}
|
||||
})
|
||||
.map(this::resolveUri)
|
||||
.orElse(null);
|
||||
throw new AcmeUserActionRequiredException(problem, tos);
|
||||
}
|
||||
|
@ -532,4 +526,24 @@ public class DefaultConnection implements Connection {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a relative URI against the connection's last URL.
|
||||
*
|
||||
* @param uri
|
||||
* URI to resolve
|
||||
* @return Absolute URI of the given link, or {@code null} if the URI was
|
||||
* {@code null}.
|
||||
*/
|
||||
private URI resolveUri(String uri) {
|
||||
if (uri == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return conn.getURL().toURI().resolve(uri);
|
||||
} catch (URISyntaxException ex) {
|
||||
throw new AcmeProtocolException("Invalid URI", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue