mirror of https://github.com/shred/acme4j
Throw AcmeLazyLoadingException on bindChallenge
parent
e7c2bf25f5
commit
8aa7e4ad8e
|
@ -25,6 +25,7 @@ import javax.annotation.concurrent.ThreadSafe;
|
|||
import org.shredzone.acme4j.challenge.Challenge;
|
||||
import org.shredzone.acme4j.connector.Connection;
|
||||
import org.shredzone.acme4j.exception.AcmeException;
|
||||
import org.shredzone.acme4j.exception.AcmeLazyLoadingException;
|
||||
import org.shredzone.acme4j.exception.AcmeProtocolException;
|
||||
import org.shredzone.acme4j.toolbox.JSON;
|
||||
|
||||
|
@ -131,11 +132,16 @@ public class Login {
|
|||
* @param location
|
||||
* Location URL of the order
|
||||
* @return {@link Challenge} bound to the login
|
||||
* @since 2.8
|
||||
*/
|
||||
public Challenge bindChallenge(URL location) throws AcmeException {
|
||||
Connection connect = session.connect();
|
||||
connect.sendSignedPostAsGetRequest(location, this);
|
||||
return createChallenge(connect.readJsonResponse());
|
||||
public Challenge bindChallenge(URL location) {
|
||||
try {
|
||||
Connection connect = session.connect();
|
||||
connect.sendSignedPostAsGetRequest(location, this);
|
||||
return createChallenge(connect.readJsonResponse());
|
||||
} catch (AcmeException ex) {
|
||||
throw new AcmeLazyLoadingException(Challenge.class, location, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,10 +43,24 @@ public class AcmeLazyLoadingException extends RuntimeException {
|
|||
* {@link AcmeException} that was raised
|
||||
*/
|
||||
public AcmeLazyLoadingException(AcmeResource resource, AcmeException cause) {
|
||||
super(requireNonNull(resource).getClass().getSimpleName() + " "
|
||||
+ requireNonNull(resource).getLocation(), requireNonNull(cause));
|
||||
type = resource.getClass();
|
||||
location = resource.getLocation();
|
||||
this(requireNonNull(resource).getClass(), requireNonNull(resource).getLocation(), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link AcmeLazyLoadingException}.
|
||||
*
|
||||
* @param type
|
||||
* {@link AcmeResource} type to be loaded
|
||||
* @param location
|
||||
* Resource location
|
||||
* @param cause
|
||||
* {@link AcmeException} that was raised
|
||||
* @since 2.8
|
||||
*/
|
||||
public AcmeLazyLoadingException(Class<? extends AcmeResource> type, URL location, AcmeException cause) {
|
||||
super(requireNonNull(type).getSimpleName() + " " + requireNonNull(location), requireNonNull(cause));
|
||||
this.type = type;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -138,7 +138,6 @@ public class LoginTest {
|
|||
verify(mockProvider).createChallenge(login, data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that binding to a challenge invokes createChallenge
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue