You need to create a new key pair and set it via useKeyPair(KeyPair)
. Your
account will be identified by the public part of that key pair, so make sure to store
it safely! There is no automatic way to regain access to your account if the key pair
is lost.
Depending on the CA you register with, you might need to give additional information.
- You might need to agree to the terms of service via
agreeToTermsOfService()
. - You might need to give at least one contact URI.
- You might need to provide a key identifier (e.g. your customer number) and
a shared secret via
withKeyIdentifier(String, SecretKey)
.
It is not possible to modify an existing account with the AccountBuilder
. To
modify an existing account, use Account.modify()
and
Account.changeKey(KeyPair)
.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddContact
(String contact) Add a contact address to the list of contacts.addContact
(URI contact) Add a contact URI to the list of contacts.Add an email address to the list of contacts.Documents that the user has agreed to the terms of service.Creates a new account.createLogin
(Session session) Creates a new account.Signals that only an existing account should be returned.useKeyPair
(KeyPair keyPair) Sets theKeyPair
to be used for this account.withKeyIdentifier
(String kid, String encodedMacKey) Sets a Key Identifier and MAC key provided by the CA.withKeyIdentifier
(String kid, SecretKey macKey) Sets a Key Identifier and MAC key provided by the CA.withMacAlgorithm
(String macAlgorithm) Sets the MAC key algorithm that is provided by the CA.
-
Constructor Details
-
AccountBuilder
public AccountBuilder()
-
-
Method Details
-
addContact
Add a contact URI to the list of contacts.A contact URI may be e.g. an email address or a phone number. It depends on the CA what kind of contact URIs are accepted, and how many must be provided as minimum.
- Parameters:
contact
- Contact URI- Returns:
- itself
-
addContact
Add a contact address to the list of contacts.This is a convenience call for
addContact(URI)
.- Parameters:
contact
- Contact URI as string- Returns:
- itself
- Throws:
IllegalArgumentException
- if there is a syntax error in the URI string
-
addEmail
Add an email address to the list of contacts.This is a convenience call for
addContact(String)
that doesn't require to prepend the "mailto" scheme to an email address.- Parameters:
email
- Contact email without "mailto" scheme (e.g. test@gmail.com)- Returns:
- itself
- Throws:
IllegalArgumentException
- if there is a syntax error in the URI string
-
agreeToTermsOfService
Documents that the user has agreed to the terms of service.If the CA requires the user to agree to the terms of service, it is your responsibility to present them to the user, and actively ask for their agreement. A link to the terms of service is provided via
session.getMetadata().getTermsOfService()
.- Returns:
- itself
-
onlyExisting
Signals that only an existing account should be returned. The server will not create a new account if the key is not known.If you have lost your account's location URL, but still have your account's key pair, you can register your account again with the same key, and use
onlyExisting()
to make sure that your existing account is returned. If your key is unknown to the server, an error is thrown once the account is to be created.- Returns:
- itself
-
useKeyPair
Sets theKeyPair
to be used for this account.Only the public key of the pair is sent to the server for registration. acme4j will never send the private key part.
Make sure to store your key pair safely after registration! There is no automatic way to regain access to your account if the key pair is lost.
- Parameters:
keyPair
- Account'sKeyPair
- Returns:
- itself
-
withKeyIdentifier
Sets a Key Identifier and MAC key provided by the CA. Use this if your CA requires an individual account identification (e.g. your customer number) and a shared secret for registration. See the documentation of your CA about how to retrieve the key identifier and MAC key.- Parameters:
kid
- Key IdentifiermacKey
- MAC key- Returns:
- itself
- See Also:
-
withKeyIdentifier
Sets a Key Identifier and MAC key provided by the CA. Use this if your CA requires an individual account identification (e.g. your customer number) and a shared secret for registration. See the documentation of your CA about how to retrieve the key identifier and MAC key.This is a convenience call of
withKeyIdentifier(String, SecretKey)
that accepts a base64url encoded MAC key, so both parameters can be passed in as strings.- Parameters:
kid
- Key IdentifierencodedMacKey
- Base64url encoded MAC key.- Returns:
- itself
- See Also:
-
withMacAlgorithm
Sets the MAC key algorithm that is provided by the CA. To be used in combination with key identifier. By default, the algorithm is deduced from the size of the MAC key. If a different size is needed, it can be set using this method.- Parameters:
macAlgorithm
- the algorithm to be set in thealg
field, e.g."HS512"
.- Returns:
- itself
- Since:
- 3.1.0
-
create
Creates a new account.Use this method to finally create your account with the given parameters. Do not use the
AccountBuilder
after invoking this method.- Parameters:
session
-Session
to be used for registration- Returns:
Account
referring to the new account- Throws:
AcmeException
- See Also:
-
createLogin
Creates a new account.This method is identical to
create(Session)
, but returns aLogin
that is ready to be used.- Parameters:
session
-Session
to be used for registration- Returns:
Login
referring to the new account- Throws:
AcmeException
-