Class Session

java.lang.Object
org.shredzone.acme4j.Session

public class Session
extends java.lang.Object
A session stores the ACME server URI. It also tracks communication parameters.
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected java.time.ZonedDateTime directoryExpires  
    protected java.time.ZonedDateTime directoryLastModified  
  • Constructor Summary

    Constructors
    Constructor Description
    Session​(java.lang.String serverUri)
    Creates a new Session.
    Session​(java.net.URI serverUri)
    Creates a new Session.
    Session​(java.net.URI serverUri, AcmeProvider provider)
    Creates a new Session using the given AcmeProvider.
  • Method Summary

    Modifier and Type Method Description
    Connection connect()
    Returns a new Connection to the ACME server.
    java.time.ZonedDateTime getDirectoryExpires()
    Returns the date when the current directory records will expire.
    java.time.ZonedDateTime getDirectoryLastModified()
    Returns the date when the directory has been modified the last time.
    java.util.Locale getLocale()
    Gets the current locale of this session.
    Metadata getMetadata()
    Gets the metadata of the provider's directory.
    java.lang.String getNonce()
    Gets the last base64 encoded nonce, or null if the session is new.
    java.net.Proxy getProxy()
    Deprecated.
    Use networkSettings().getProxy()
    java.net.URI getServerUri()
    Gets the ACME server URI of this session.
    boolean hasDirectory()
    Returns true if a directory is available.
    Login login​(java.net.URL accountLocation, java.security.KeyPair accountKeyPair)
    Logs into an existing account.
    NetworkSettings networkSettings()
    Returns the current NetworkSettings.
    AcmeProvider provider()
    Returns the AcmeProvider that is used for this session.
    java.net.URL resourceUrl​(Resource resource)
    Gets the URL of the given Resource.
    void setDirectoryExpires​(java.time.ZonedDateTime directoryExpires)
    Sets the date when the current directory will expire.
    void setDirectoryLastModified​(java.time.ZonedDateTime directoryLastModified)
    Sets the date when the directory has been modified the last time.
    void setLocale​(java.util.Locale locale)
    Sets the locale used in this session.
    void setNonce​(java.lang.String nonce)
    Sets the base64 encoded nonce received by the server.
    void setProxy​(java.net.Proxy proxy)
    Deprecated.
    Use networkSettings().setProxy(Proxy)

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • Session

      public Session​(java.lang.String serverUri)
      Creates a new Session.
      Parameters:
      serverUri - URI string of the ACME server
    • Session

      public Session​(java.net.URI serverUri)
      Creates a new Session.
      Parameters:
      serverUri - URI of the ACME server
      Throws:
      java.lang.IllegalArgumentException - if no ACME provider was found for the server URI.
    • Session

      public Session​(java.net.URI serverUri, AcmeProvider provider)
      Creates a new Session using the given AcmeProvider.

      This constructor should only be used for testing purposes.

      Parameters:
      serverUri - URI of the ACME server
      provider - AcmeProvider to be used
      Since:
      2.8
  • Method Details

    • login

      public Login login​(java.net.URL accountLocation, java.security.KeyPair accountKeyPair)
      Logs into an existing account.
      Parameters:
      accountLocation - Location URL of the account
      accountKeyPair - Account KeyPair
      Returns:
      Login to this account
    • getServerUri

      public java.net.URI getServerUri()
      Gets the ACME server URI of this session.
    • getNonce

      @Nullable public java.lang.String getNonce()
      Gets the last base64 encoded nonce, or null if the session is new.
    • setNonce

      public void setNonce​(@Nullable java.lang.String nonce)
      Sets the base64 encoded nonce received by the server.
    • getLocale

      public java.util.Locale getLocale()
      Gets the current locale of this session.
    • setLocale

      public void setLocale​(@Nullable java.util.Locale locale)
      Sets the locale used in this session. The locale is passed to the server as Accept-Language header. The server may respond with localized messages.
    • getProxy

      @Deprecated public java.net.Proxy getProxy()
      Deprecated.
      Use networkSettings().getProxy()
      Gets the Proxy to be used for connections.
    • setProxy

      @Deprecated public void setProxy​(@Nullable java.net.Proxy proxy)
      Deprecated.
      Use networkSettings().setProxy(Proxy)
      Sets a Proxy that is to be used for all connections. If null, Proxy.NO_PROXY is used, which is also the default.
    • networkSettings

      Returns the current NetworkSettings.
      Returns:
      NetworkSettings
      Since:
      2.8
    • provider

      Returns the AcmeProvider that is used for this session.
      Returns:
      AcmeProvider
    • connect

      public Connection connect()
      Returns a new Connection to the ACME server.
      Returns:
      Connection
    • resourceUrl

      public java.net.URL resourceUrl​(Resource resource) throws AcmeException
      Gets the URL of the given Resource. This may involve connecting to the server and getting a directory. The result is cached.
      Parameters:
      resource - Resource to get the URL of
      Returns:
      URL of the resource
      Throws:
      AcmeException - if the server does not offer the Resource
    • getMetadata

      Gets the metadata of the provider's directory. This may involve connecting to the server and getting a directory. The result is cached.
      Returns:
      Metadata. May contain no data, but is never null.
      Throws:
      AcmeException
    • getDirectoryLastModified

      @Nullable public java.time.ZonedDateTime getDirectoryLastModified()
      Returns the date when the directory has been modified the last time.
      Returns:
      The last modification date of the directory, or null if unknown (directory has not been read yet or did not provide this information).
      Since:
      2.10
    • setDirectoryLastModified

      public void setDirectoryLastModified​(@Nullable java.time.ZonedDateTime directoryLastModified)
      Sets the date when the directory has been modified the last time. Should only be invoked by AcmeProvider implementations.
      Parameters:
      directoryLastModified - The last modification date of the directory, or null if unknown (directory has not been read yet or did not provide this information).
      Since:
      2.10
    • getDirectoryExpires

      @Nullable public java.time.ZonedDateTime getDirectoryExpires()
      Returns the date when the current directory records will expire. A fresh copy of the directory will be fetched automatically after that instant.
      Returns:
      The expiration date, or null if the server did not provide this information.
      Since:
      2.10
    • setDirectoryExpires

      public void setDirectoryExpires​(@Nullable java.time.ZonedDateTime directoryExpires)
      Sets the date when the current directory will expire. Should only be invoked by AcmeProvider implementations.
      Parameters:
      directoryExpires - Expiration date, or null if the server did not provide this information.
      Since:
      2.10
    • hasDirectory

      public boolean hasDirectory()
      Returns true if a directory is available. Should only be invoked by AcmeProvider implementations.
      Returns:
      true if a directory is available.
      Since:
      2.10