java.lang.Object
org.shredzone.acme4j.connector.DefaultConnection
- Alle implementierten Schnittstellen:
AutoCloseable,Connection
Default implementation of
Connection. It communicates with the ACME server via
HTTP, with a client that is provided by the given HttpConnector.-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected final HttpClientprotected final HttpConnectorprotected HttpResponse<InputStream> -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungDefaultConnection(HttpConnector httpConnector) Creates a newDefaultConnection. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidclose()Closes theConnection, releasing all resources.Returns the expiration date of the resource, if present.Returns the content of the last-modified header, if present.Gets one or more relation links from the header.Gets a location from theLocationheader.getNonce()Gets the nonce from the nonce header.Returns the Retry-After header if present.Reads a certificate and its chain of issuers.Reads a server response as JSON object.voidresetNonce(Session session) Resets the session nonce, by fetching a new one.intsendCertificateRequest(URL url, Login login) Sends a signed POST-as-GET request for a certificate resource.intsendRequest(URL url, Session session, ZonedDateTime ifModifiedSince) Sends a simple GET request.protected voidsendRequest(Session session, URL url, Consumer<HttpRequest.Builder> body) Sends a HTTP request via http client.intsendSignedPostAsGetRequest(URL url, Login login) Sends a signed POST-as-GET request.intsendSignedRequest(URL url, JSONBuilder claims, Login login) Sends a signed POST request.intsendSignedRequest(URL url, JSONBuilder claims, Session session, KeyPair keypair) Sends a signed POST request.protected intsendSignedRequest(URL url, JSONBuilder claims, Session session, KeyPair keypair, URL accountLocation, String accept) Sends a signed POST request.Von Klasse geerbte Methoden java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitVon Schnittstelle geerbte Methoden org.shredzone.acme4j.connector.Connection
handleRetryAfter
-
Felddetails
-
httpConnector
-
httpClient
-
lastResponse
-
-
Konstruktordetails
-
DefaultConnection
Creates a newDefaultConnection.- Parameter:
httpConnector-HttpConnectorto be used for HTTP connections
-
-
Methodendetails
-
resetNonce
Beschreibung aus Schnittstelle kopiert:ConnectionResets the session nonce, by fetching a new one.- Angegeben von:
resetNoncein SchnittstelleConnection- Parameter:
session-Sessioninstance to fetch a nonce for- Löst aus:
AcmeException
-
sendRequest
public int sendRequest(URL url, Session session, @Nullable ZonedDateTime ifModifiedSince) throws AcmeException Beschreibung aus Schnittstelle kopiert:ConnectionSends a simple GET request.If the response code was not HTTP status 200, an
AcmeExceptionmatching the error is raised.- Angegeben von:
sendRequestin SchnittstelleConnection- Parameter:
url-URLto send the request to.session-Sessioninstance to be used for trackingifModifiedSince-ZonedDateTimeto be sent as "If-Modified-Since" header, ornullif this header is not to be used- Gibt zurück:
- HTTP status that was returned
- Löst aus:
AcmeException
-
sendCertificateRequest
Beschreibung aus Schnittstelle kopiert:ConnectionSends a signed POST-as-GET request for a certificate resource. Requires aLoginfor the session andKeyPair. TheLoginaccount location is sent in a "kid" protected header.If the server does not return a 200 class status code, an
AcmeExceptionis raised matching the error.- Angegeben von:
sendCertificateRequestin SchnittstelleConnection- Parameter:
url-URLto send the request to.login-Logininstance to be used for signing and tracking.- Gibt zurück:
- HTTP 200 class status that was returned
- Löst aus:
AcmeException
-
sendSignedPostAsGetRequest
Beschreibung aus Schnittstelle kopiert:ConnectionSends a signed POST-as-GET request. Requires aLoginfor the session andKeyPair. TheLoginaccount location is sent in a "kid" protected header.If the server does not return a 200 class status code, an
AcmeExceptionis raised matching the error.- Angegeben von:
sendSignedPostAsGetRequestin SchnittstelleConnection- Parameter:
url-URLto send the request to.login-Logininstance to be used for signing and tracking.- Gibt zurück:
- HTTP 200 class status that was returned
- Löst aus:
AcmeException
-
sendSignedRequest
Beschreibung aus Schnittstelle kopiert:ConnectionSends a signed POST request. Requires aLoginfor the session andKeyPair. TheLoginaccount location is sent in a "kid" protected header.If the server does not return a 200 class status code, an
AcmeExceptionis raised matching the error.- Angegeben von:
sendSignedRequestin SchnittstelleConnection- Parameter:
url-URLto send the request to.claims-JSONBuildercontaining claims.login-Logininstance to be used for signing and tracking.- Gibt zurück:
- HTTP 200 class status that was returned
- Löst aus:
AcmeException
-
sendSignedRequest
public int sendSignedRequest(URL url, JSONBuilder claims, Session session, KeyPair keypair) throws AcmeException Beschreibung aus Schnittstelle kopiert:ConnectionSends a signed POST request. Only requires aSession. TheKeyPairis sent in a "jwk" protected header field.If the server does not return a 200 class status code, an
AcmeExceptionis raised matching the error.- Angegeben von:
sendSignedRequestin SchnittstelleConnection- Parameter:
url-URLto send the request to.claims-JSONBuildercontaining claims.session-Sessioninstance to be used for tracking.keypair-KeyPairto be used for signing.- Gibt zurück:
- HTTP 200 class status that was returned
- Löst aus:
AcmeException
-
readJsonResponse
Beschreibung aus Schnittstelle kopiert:ConnectionReads a server response as JSON object.- Angegeben von:
readJsonResponsein SchnittstelleConnection- Gibt zurück:
- The JSON response.
- Löst aus:
AcmeException
-
readCertificates
Beschreibung aus Schnittstelle kopiert:ConnectionReads a certificate and its chain of issuers.- Angegeben von:
readCertificatesin SchnittstelleConnection- Gibt zurück:
- List of X.509 certificate and chain that was read.
- Löst aus:
AcmeException
-
getNonce
Beschreibung aus Schnittstelle kopiert:ConnectionGets the nonce from the nonce header.- Angegeben von:
getNoncein SchnittstelleConnection- Gibt zurück:
- Base64 encoded nonce, or empty if no nonce header was set
-
getLocation
Beschreibung aus Schnittstelle kopiert:ConnectionGets a location from theLocationheader.Relative links are resolved against the last request's URL.
- Angegeben von:
getLocationin SchnittstelleConnection- Gibt zurück:
- Location
URL
-
getLastModified
Beschreibung aus Schnittstelle kopiert:ConnectionReturns the content of the last-modified header, if present.- Angegeben von:
getLastModifiedin SchnittstelleConnection- Gibt zurück:
- Date in the Last-Modified header, or empty if the server did not provide this information.
-
getExpiration
Beschreibung aus Schnittstelle kopiert:ConnectionReturns the expiration date of the resource, if present.- Angegeben von:
getExpirationin SchnittstelleConnection- Gibt zurück:
- Expiration date, either from the Cache-Control or Expires header. If empty, the server did not provide an expiration date, or forbid caching.
-
getLinks
Beschreibung aus Schnittstelle kopiert:ConnectionGets one or more relation links from the header. The result is expected to be a URL.Relative links are resolved against the last request's URL.
- Angegeben von:
getLinksin SchnittstelleConnection- Parameter:
relation- Link relation- Gibt zurück:
- Collection of links. Empty if there was no such relation.
-
close
Beschreibung aus Schnittstelle kopiert:ConnectionCloses theConnection, releasing all resources.- Angegeben von:
closein SchnittstelleAutoCloseable- Angegeben von:
closein SchnittstelleConnection
-
sendRequest
protected void sendRequest(Session session, URL url, Consumer<HttpRequest.Builder> body) throws IOException Sends a HTTP request via http client. This is the central method to be used for sending. It will create aHttpRequestby using the request builder, configure commnon headers, and then send the request viaHttpClient.- Parameter:
session-Sessionto be used for sendingurl- TargetURLbody- Callback that completes theHttpRequest.Builderwith the request body (e.g. HTTP method, request body, more headers).- Löst aus:
IOException
-
sendSignedRequest
protected int sendSignedRequest(URL url, @Nullable JSONBuilder claims, Session session, KeyPair keypair, @Nullable URL accountLocation, String accept) throws AcmeException Sends a signed POST request.- Parameter:
url-URLto send the request to.claims-JSONBuildercontaining claims.nullfor POST-as-GET request.session-Sessioninstance to be used for signing and trackingkeypair-KeyPairto be used for signingaccountLocation- If set, the account location is set as "kid" header. Ifnull, the public key is set as "jwk" header.accept- Accept header- Gibt zurück:
- HTTP 200 class status that was returned
- Löst aus:
AcmeException
-
getRetryAfter
Beschreibung aus Schnittstelle kopiert:ConnectionReturns the Retry-After header if present.- Angegeben von:
getRetryAfterin SchnittstelleConnection
-