added bindChallenge

pull/81/head
Anders Mikkelsen 2019-10-18 01:40:16 +02:00
parent 0343a81a9f
commit 3426ea4ea2
3 changed files with 23 additions and 0 deletions

View File

@ -123,6 +123,18 @@ public class Login {
return new Order(this, requireNonNull(location, "location"));
}
/**
* Creates a new instance of {@link Challenge} and binds it to this login.
*
* @param location
* Location URL of the challenge
* @return
* {@link Challenge} bound to the login
*/
public Challenge bindChallenge(URL location) {
return new Challenge(this, requireNonNull(location, "location"));
}
/**
* Creates a {@link Challenge} instance for the given challenge data.
*

View File

@ -13,6 +13,7 @@
*/
package org.shredzone.acme4j.challenge;
import java.net.URL;
import java.time.Instant;
import javax.annotation.CheckForNull;
@ -51,6 +52,11 @@ public class Challenge extends AcmeJsonResource {
protected static final String KEY_VALIDATED = "validated";
protected static final String KEY_ERROR = "error";
public Challenge(Login login, URL location) {
super(login, location);
}
/**
* Creates a new generic {@link Challenge} object.
*

View File

@ -83,6 +83,11 @@ public class LoginTest {
assertThat(order, is(notNullValue()));
assertThat(order.getLogin(), is(login));
assertThat(order.getLocation(), is(resourceUrl));
Challenge challenge = login.bindChallenge(resourceUrl);
assertThat(challenge, is(notNullValue()));
assertThat(challenge.getLogin(), is(login));
assertThat(challenge.getLocation(), is(resourceUrl));
}
/**