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.challenge.Challenge;
|
||||||
import org.shredzone.acme4j.connector.Connection;
|
import org.shredzone.acme4j.connector.Connection;
|
||||||
import org.shredzone.acme4j.exception.AcmeException;
|
import org.shredzone.acme4j.exception.AcmeException;
|
||||||
|
import org.shredzone.acme4j.exception.AcmeLazyLoadingException;
|
||||||
import org.shredzone.acme4j.exception.AcmeProtocolException;
|
import org.shredzone.acme4j.exception.AcmeProtocolException;
|
||||||
import org.shredzone.acme4j.toolbox.JSON;
|
import org.shredzone.acme4j.toolbox.JSON;
|
||||||
|
|
||||||
|
@ -131,11 +132,16 @@ public class Login {
|
||||||
* @param location
|
* @param location
|
||||||
* Location URL of the order
|
* Location URL of the order
|
||||||
* @return {@link Challenge} bound to the login
|
* @return {@link Challenge} bound to the login
|
||||||
|
* @since 2.8
|
||||||
*/
|
*/
|
||||||
public Challenge bindChallenge(URL location) throws AcmeException {
|
public Challenge bindChallenge(URL location) {
|
||||||
Connection connect = session.connect();
|
try {
|
||||||
connect.sendSignedPostAsGetRequest(location, this);
|
Connection connect = session.connect();
|
||||||
return createChallenge(connect.readJsonResponse());
|
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
|
* {@link AcmeException} that was raised
|
||||||
*/
|
*/
|
||||||
public AcmeLazyLoadingException(AcmeResource resource, AcmeException cause) {
|
public AcmeLazyLoadingException(AcmeResource resource, AcmeException cause) {
|
||||||
super(requireNonNull(resource).getClass().getSimpleName() + " "
|
this(requireNonNull(resource).getClass(), requireNonNull(resource).getLocation(), cause);
|
||||||
+ requireNonNull(resource).getLocation(), requireNonNull(cause));
|
}
|
||||||
type = resource.getClass();
|
|
||||||
location = resource.getLocation();
|
/**
|
||||||
|
* 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);
|
verify(mockProvider).createChallenge(login, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that binding to a challenge invokes createChallenge
|
* Test that binding to a challenge invokes createChallenge
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue