/** * Creates a new account. * * @param session * {@link Session} to be used for registration * @return {@link Account} referring to the new account */ public Account create(Session session) throws AcmeException { return createLogin(session).getAccount(); }
/** * Logs into an existing account. * * @param accountLocation * Location {@link URL} of the account * @param accountKeyPair * Account {@link KeyPair} * @return {@link Login} to this account */ public Login login(URL accountLocation, KeyPair accountKeyPair) { return new Login(accountLocation, accountKeyPair, this); }
@Override public int sendCertificateRequest(URL url, Login login) throws AcmeException { return sendSignedRequest(url, null, login.getSession(), login.getKeyPair(), login.getAccountLocation(), MIME_CERTIFICATE_CHAIN); }
Login login = new Login(location, keyPair, session); JSON json = conn.readJsonResponse(); if (json != null) { login.getAccount().setJSON(json);
/** * Gets the {@link Session} this resource is bound with. */ protected Session getSession() { return getLogin().getSession(); }
if (Arrays.equals(getLogin().getKeyPair().getPrivate().getEncoded(), newKeyPair.getPrivate().getEncoded())) { throw new IllegalArgumentException("newKeyPair must actually be a new key pair"); payloadClaim.putKey("oldKey", getLogin().getKeyPair().getPublic()); getLogin().setKeyPair(newKeyPair); } catch (JoseException ex) { throw new AcmeProtocolException("Cannot sign key-change", ex);
protected Account(Login login) { super(login, login.getAccountLocation()); }
/** * Returns the authorization string. * <p> * The default is {@code token + '.' + base64url(jwkThumbprint)}. Subclasses may * override this method if a different algorithm is used. */ public String getAuthorization() { try { PublicKey pk = getLogin().getKeyPair().getPublic(); PublicJsonWebKey jwk = PublicJsonWebKey.Factory.newPublicJwk(pk); return getToken() + '.' + base64UrlEncode(jwk.calculateThumbprint("SHA-256")); } catch (JoseException ex) { throw new AcmeProtocolException("Cannot compute key thumbprint", ex); } }
Authorization auth = getLogin().bindAuthorization(authLocation); JSON json = conn.readJsonResponse(); if (json != null) {
Login login = new Login(location, keyPair, session); JSON json = conn.readJsonResponse(); if (json != null) { login.getAccount().setJSON(json);
/** * Gets the {@link Session} this resource is bound with. */ protected Session getSession() { return getLogin().getSession(); }
if (Arrays.equals(getLogin().getKeyPair().getPrivate().getEncoded(), newKeyPair.getPrivate().getEncoded())) { throw new IllegalArgumentException("newKeyPair must actually be a new key pair"); payloadClaim.putKey("oldKey", getLogin().getKeyPair().getPublic()); getLogin().setKeyPair(newKeyPair); } catch (JoseException ex) { throw new AcmeProtocolException("Cannot sign key-change", ex);
protected Account(Login login) { super(login, login.getAccountLocation()); }
/** * Returns the authorization string. * <p> * The default is {@code token + '.' + base64url(jwkThumbprint)}. Subclasses may * override this method if a different algorithm is used. */ public String getAuthorization() { try { PublicKey pk = getLogin().getKeyPair().getPublic(); PublicJsonWebKey jwk = PublicJsonWebKey.Factory.newPublicJwk(pk); return getToken() + '.' + base64UrlEncode(jwk.calculateThumbprint("SHA-256")); } catch (JoseException ex) { throw new AcmeProtocolException("Cannot compute key thumbprint", ex); } }
Authorization auth = getLogin().bindAuthorization(authLocation); JSON json = conn.readJsonResponse(); if (json != null) {
@Override public int sendSignedRequest(URL url, JSONBuilder claims, Login login) throws AcmeException { return sendSignedRequest(url, claims, login.getSession(), login.getKeyPair(), login.getAccountLocation(), MIME_JSON); }
/** * Creates a new account. * * @param session * {@link Session} to be used for registration * @return {@link Account} referring to the new account */ public Account create(Session session) throws AcmeException { return createLogin(session).getAccount(); }
/** * Reads the next batch of URLs from the server, and fills the queue with the URLs. If * there is a "next" header, it is used for the next batch of URLs. */ private void readAndQueue() throws AcmeException { Session session = login.getSession(); try (Connection conn = session.connect()) { conn.sendSignedPostAsGetRequest(nextUrl, login); JSON json = conn.readJsonResponse(); if (json != null) { fillUrlList(json); } nextUrl = conn.getLinks("next").stream().findFirst().orElse(null); } }
/** * Logs into an existing account. * * @param accountLocation * Location {@link URL} of the account * @param accountKeyPair * Account {@link KeyPair} * @return {@link Login} to this account */ public Login login(URL accountLocation, KeyPair accountKeyPair) { return new Login(accountLocation, accountKeyPair, this); }
@Override public int sendCertificateRequest(URL url, Login login) throws AcmeException { return sendSignedRequest(url, null, login.getSession(), login.getKeyPair(), login.getAccountLocation(), MIME_CERTIFICATE_CHAIN); }