Class Challenge

java.lang.Object
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
TokenChallenge

public class Challenge
extends AcmeJsonResource
A generic challenge. It can be used as a base class for actual challenge implementations, but it is also used if the ACME server offers a proprietary challenge that is unknown to acme4j.

Subclasses must override acceptable(String) so it only accepts the own type. prepareResponse(JSONBuilder) should be overridden to put all required data to the response.

See Also:
Serialized Form
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected static java.lang.String KEY_ERROR  
    protected static java.lang.String KEY_STATUS  
    protected static java.lang.String KEY_TYPE  
    protected static java.lang.String KEY_URL  
    protected static java.lang.String KEY_VALIDATED  
  • Constructor Summary

    Constructors
    Constructor Description
    Challenge​(Login login, JSON data)
    Creates a new generic Challenge object.
  • Method Summary

    Modifier and Type Method Description
    protected boolean acceptable​(java.lang.String type)
    Checks if the type is acceptable to this challenge.
    Problem getError()
    Returns a reason why the challenge has failed in the past, if returned by the server.
    Status getStatus()
    Returns the current status of the challenge.
    java.lang.String getType()
    Returns the challenge type by name (e.g.
    java.time.Instant getValidated()
    Returns the validation date, if returned by the server.
    protected void prepareResponse​(JSONBuilder response)
    Exports the response state, as preparation for triggering the challenge.
    protected void setJSON​(JSON json)
    Sets the JSON representation of the resource data.
    void trigger()
    Triggers this Challenge.

    Methods inherited from class org.shredzone.acme4j.AcmeJsonResource

    getJSON, invalidate, isValid, update

    Methods inherited from class org.shredzone.acme4j.AcmeResource

    getLocation, getLogin, getSession, rebind

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • getType

      public java.lang.String getType()
      Returns the challenge type by name (e.g. "http-01").
    • getStatus

      public Status getStatus()
      Returns the current status of the challenge.

      Possible values are: Status.PENDING, Status.PROCESSING, Status.VALID, Status.INVALID.

    • getValidated

      @Nullable public java.time.Instant getValidated()
      Returns the validation date, if returned by the server.
    • getError

      @Nullable public Problem 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 in Problem.getSubProblems().
    • prepareResponse

      protected void prepareResponse​(JSONBuilder response)
      Exports the response state, as preparation for triggering the challenge.
      Parameters:
      response - JSONBuilder to write the response to
    • acceptable

      protected boolean acceptable​(java.lang.String type)
      Checks if the type is acceptable to this challenge.
      Parameters:
      type - Type to check
      Returns:
      true if acceptable, false if not
    • setJSON

      protected void setJSON​(JSON json)
      Description copied from class: AcmeJsonResource
      Sets the JSON representation of the resource data.
      Overrides:
      setJSON in class AcmeJsonResource
      Parameters:
      json - New JSON data, must not be null.
    • trigger

      public void trigger() throws AcmeException
      Triggers this Challenge. The ACME server is requested to validate the response. Note that the validation is performed asynchronously by the ACME server.

      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