mirror of https://github.com/shred/acme4j
parent
4c4cf5b5cf
commit
2b61478f13
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* acme4j - Java ACME client
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Richard "Shred" Körber
|
|
||||||
* http://acme4j.shredzone.org
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
package org.shredzone.acme4j.challenge;
|
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import org.shredzone.acme4j.Session;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements the {@value TYPE} challenge.
|
|
||||||
*/
|
|
||||||
public class OutOfBand01Challenge extends Challenge {
|
|
||||||
private static final long serialVersionUID = -7459595198486630582L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Challenge type name: {@value}
|
|
||||||
*/
|
|
||||||
public static final String TYPE = "oob-01";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new generic {@link OutOfBand01Challenge} object.
|
|
||||||
*
|
|
||||||
* @param session
|
|
||||||
* {@link Session} to bind to.
|
|
||||||
*/
|
|
||||||
public OutOfBand01Challenge(Session session) {
|
|
||||||
super(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the validation URL to be visited by the customer in order to complete the
|
|
||||||
* challenge.
|
|
||||||
*/
|
|
||||||
public URL getValidationUrl() {
|
|
||||||
return getJSON().get("href").asURL();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -25,7 +25,6 @@ import org.shredzone.acme4j.Session;
|
||||||
import org.shredzone.acme4j.challenge.Challenge;
|
import org.shredzone.acme4j.challenge.Challenge;
|
||||||
import org.shredzone.acme4j.challenge.Dns01Challenge;
|
import org.shredzone.acme4j.challenge.Dns01Challenge;
|
||||||
import org.shredzone.acme4j.challenge.Http01Challenge;
|
import org.shredzone.acme4j.challenge.Http01Challenge;
|
||||||
import org.shredzone.acme4j.challenge.OutOfBand01Challenge;
|
|
||||||
import org.shredzone.acme4j.challenge.TlsSni02Challenge;
|
import org.shredzone.acme4j.challenge.TlsSni02Challenge;
|
||||||
import org.shredzone.acme4j.connector.Connection;
|
import org.shredzone.acme4j.connector.Connection;
|
||||||
import org.shredzone.acme4j.connector.DefaultConnection;
|
import org.shredzone.acme4j.connector.DefaultConnection;
|
||||||
|
@ -68,7 +67,6 @@ public abstract class AbstractAcmeProvider implements AcmeProvider {
|
||||||
map.put(Dns01Challenge.TYPE, Dns01Challenge::new);
|
map.put(Dns01Challenge.TYPE, Dns01Challenge::new);
|
||||||
map.put(TlsSni02Challenge.TYPE, TlsSni02Challenge::new);
|
map.put(TlsSni02Challenge.TYPE, TlsSni02Challenge::new);
|
||||||
map.put(Http01Challenge.TYPE, Http01Challenge::new);
|
map.put(Http01Challenge.TYPE, Http01Challenge::new);
|
||||||
map.put(OutOfBand01Challenge.TYPE, OutOfBand01Challenge::new);
|
|
||||||
|
|
||||||
return Collections.unmodifiableMap(map);
|
return Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* acme4j - Java ACME client
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Richard "Shred" Körber
|
|
||||||
* http://acme4j.shredzone.org
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
package org.shredzone.acme4j.challenge;
|
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
|
|
||||||
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.shredzone.acme4j.Session;
|
|
||||||
import org.shredzone.acme4j.Status;
|
|
||||||
import org.shredzone.acme4j.toolbox.JSONBuilder;
|
|
||||||
import org.shredzone.acme4j.toolbox.TestUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unit tests for {@link OutOfBand01Challenge}.
|
|
||||||
*/
|
|
||||||
public class OutOfBandChallengeTest {
|
|
||||||
private static Session session;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void setup() throws IOException {
|
|
||||||
session = TestUtils.session();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test that {@link OutOfBand01Challenge} is returning the validation URL.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testHttpChallenge() throws IOException {
|
|
||||||
OutOfBand01Challenge challenge = new OutOfBand01Challenge(session);
|
|
||||||
challenge.unmarshall(getJSON("oobChallenge"));
|
|
||||||
|
|
||||||
assertThat(challenge.getType(), is(OutOfBand01Challenge.TYPE));
|
|
||||||
assertThat(challenge.getStatus(), is(Status.UNKNOWN));
|
|
||||||
assertThat(challenge.getValidationUrl(),
|
|
||||||
is(new URL("https://example.com/validate/evaGxfADs6pSRb2LAv9IZ")));
|
|
||||||
|
|
||||||
JSONBuilder cb = new JSONBuilder();
|
|
||||||
challenge.respond(cb);
|
|
||||||
|
|
||||||
assertThat(cb.toString(), sameJSONAs("{\"type\": \"oob-01\"}"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -30,7 +30,6 @@ import org.shredzone.acme4j.Session;
|
||||||
import org.shredzone.acme4j.challenge.Challenge;
|
import org.shredzone.acme4j.challenge.Challenge;
|
||||||
import org.shredzone.acme4j.challenge.Dns01Challenge;
|
import org.shredzone.acme4j.challenge.Dns01Challenge;
|
||||||
import org.shredzone.acme4j.challenge.Http01Challenge;
|
import org.shredzone.acme4j.challenge.Http01Challenge;
|
||||||
import org.shredzone.acme4j.challenge.OutOfBand01Challenge;
|
|
||||||
import org.shredzone.acme4j.challenge.TlsSni02Challenge;
|
import org.shredzone.acme4j.challenge.TlsSni02Challenge;
|
||||||
import org.shredzone.acme4j.connector.Connection;
|
import org.shredzone.acme4j.connector.Connection;
|
||||||
import org.shredzone.acme4j.connector.DefaultConnection;
|
import org.shredzone.acme4j.connector.DefaultConnection;
|
||||||
|
@ -155,12 +154,8 @@ public class AbstractAcmeProviderTest {
|
||||||
Challenge c6 = provider.createChallenge(session, "foobar-01");
|
Challenge c6 = provider.createChallenge(session, "foobar-01");
|
||||||
assertThat(c6, is(nullValue()));
|
assertThat(c6, is(nullValue()));
|
||||||
|
|
||||||
Challenge c7 = provider.createChallenge(session, OutOfBand01Challenge.TYPE);
|
Challenge c7 = provider.createChallenge(session, "");
|
||||||
assertThat(c7, not(nullValue()));
|
assertThat(c7, is(nullValue()));
|
||||||
assertThat(c7, instanceOf(OutOfBand01Challenge.class));
|
|
||||||
|
|
||||||
Challenge c8 = provider.createChallenge(session, "");
|
|
||||||
assertThat(c8, is(nullValue()));
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
provider.createChallenge(session, (String) null);
|
provider.createChallenge(session, (String) null);
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"type": "oob-01",
|
|
||||||
"href": "https://example.com/validate/evaGxfADs6pSRb2LAv9IZ"
|
|
||||||
}
|
|
|
@ -11,4 +11,3 @@ The ACME specifications define these standard challenges:
|
||||||
* [http-01](./http-01.html)
|
* [http-01](./http-01.html)
|
||||||
* [dns-01](./dns-01.html)
|
* [dns-01](./dns-01.html)
|
||||||
* [tls-sni-02](./tls-sni-02.html)
|
* [tls-sni-02](./tls-sni-02.html)
|
||||||
* [oob-01](./oob-01.html)
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
# oob-01 Challenge
|
|
||||||
|
|
||||||
The `oob-01` challenge is an "out of band" challenge that is used when there is no automatic way of validating ownership of a domain. The client is instead required to perform actions outside of the ACME protocol.
|
|
||||||
|
|
||||||
`OutOfBand01Challenge` implements this challenge. Its `getValidationUrl()` method returns a URL that refers to a web page with further instructions about the actions to be taken by the domain owner.
|
|
||||||
|
|
||||||
The challenge must be triggered _before_ the URL is presented to the domain owner.
|
|
||||||
|
|
||||||
> __Note:__ Due to the nature of this challenge, it may take hours or even days until the domain owner finishes the actions and the challenge state changes to `VALID`.
|
|
|
@ -40,7 +40,6 @@
|
||||||
<item name="http-01" href="challenge/http-01.html"/>
|
<item name="http-01" href="challenge/http-01.html"/>
|
||||||
<item name="dns-01" href="challenge/dns-01.html"/>
|
<item name="dns-01" href="challenge/dns-01.html"/>
|
||||||
<item name="tls-sni-02" href="challenge/tls-sni-02.html"/>
|
<item name="tls-sni-02" href="challenge/tls-sni-02.html"/>
|
||||||
<item name="oob-01" href="challenge/oob-01.html"/>
|
|
||||||
</item>
|
</item>
|
||||||
<item name="CAs" href="ca/index.html">
|
<item name="CAs" href="ca/index.html">
|
||||||
<item name="Let's Encrypt" href="ca/letsencrypt.html"/>
|
<item name="Let's Encrypt" href="ca/letsencrypt.html"/>
|
||||||
|
|
Loading…
Reference in New Issue