- All Implemented Interfaces:
Serializable
,PollableResource
- Direct Known Subclasses:
TokenChallenge
Subclasses must override acceptable(String)
so it only accepts its
own type. prepareResponse(JSONBuilder)
can be overridden to put all
required data to the challenge response.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
protected static final String
protected static final String
protected static final String
protected static final String
Fields inherited from interface org.shredzone.acme4j.PollableResource
DEFAULT_RETRY_AFTER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
acceptable
(String type) Checks if the type is acceptable to this challenge.getError()
Returns a reason why the challenge has failed in the past, if returned by the server.Returns the current status of the challenge.getType()
Returns the challenge type by name (e.g.Returns the validation date, if returned by the server.protected void
prepareResponse
(JSONBuilder response) Prepares the response message for triggering the challenge.protected void
Sets the JSON representation of the resource data.void
trigger()
Triggers thisChallenge
.waitForCompletion
(Duration timeout) Waits until the challenge is completed.Methods inherited from class org.shredzone.acme4j.AcmeJsonResource
fetch, getJSON, getRetryAfter, invalidate, isValid, setRetryAfter, update
Methods inherited from class org.shredzone.acme4j.AcmeResource
finalize, getLocation, getLogin, getSession, rebind
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.shredzone.acme4j.PollableResource
fetch, waitForStatus
-
Field Details
-
KEY_TYPE
- See Also:
-
KEY_URL
- See Also:
-
KEY_STATUS
- See Also:
-
KEY_VALIDATED
- See Also:
-
KEY_ERROR
- See Also:
-
-
Constructor Details
-
Method Details
-
getType
Returns the challenge type by name (e.g. "http-01"). -
getStatus
Returns the current status of the challenge.Possible values are:
Status.PENDING
,Status.PROCESSING
,Status.VALID
,Status.INVALID
.A challenge is only completed when it reaches either status
Status.VALID
orStatus.INVALID
.- Specified by:
getStatus
in interfacePollableResource
-
getValidated
Returns the validation date, if returned by the server. -
getError
Returns a reason why the challenge has failed in the past, if returned by the server. If there are multiple errors, they can be found inProblem.getSubProblems()
. -
prepareResponse
Prepares the response message for triggering the challenge. Subclasses can add fields to theJSONBuilder
as required by the challenge. Implementations of subclasses should make sure thatprepareResponse(JSONBuilder)
of the superclass is invoked.- Parameters:
response
-JSONBuilder
to write the response to
-
acceptable
Checks if the type is acceptable to this challenge. This generic class only checks if the type is not blank. Subclasses should instead check if the given type matches expected challenge type.- Parameters:
type
- Type to check- Returns:
true
if acceptable,false
if not
-
setJSON
Description copied from class:AcmeJsonResource
Sets the JSON representation of the resource data.- Overrides:
setJSON
in classAcmeJsonResource
- Parameters:
json
- NewJSON
data, must not benull
.
-
trigger
Triggers thisChallenge
. The ACME server is requested to validate the response. Note that the validation is performed asynchronously by the ACME server.After a challenge is triggered, it changes to
Status.PENDING
. As soon as validation takes place, it changes toStatus.PROCESSING
. After validation the status changes toStatus.VALID
orStatus.INVALID
, depending on the outcome of the validation.If the challenge requires a resource to be set on your side (e.g. a DNS record or an HTTP file), it must be reachable from public before
trigger()
is invoked, and must not be taken down until the challenge has reachedStatus.VALID
orStatus.INVALID
.If this method is invoked a second time, the ACME server is requested to retry the validation. This can be useful if the client state has changed, for example after a firewall rule has been updated.
- Throws:
AcmeException
- See Also:
-
waitForCompletion
Waits until the challenge is completed.Is is completed if it reaches either
Status.VALID
orStatus.INVALID
.This method is synchronous and blocks the current thread.
- Parameters:
timeout
- Timeout until a terminal status must have been reached- Returns:
- Status that was reached
- Throws:
AcmeException
InterruptedException
- Since:
- 3.4.0
-