Package com.iizix.server.acme
Class LetsEncryptDomain
- java.lang.Object
- com.iizix.prop.GProp<GProp<?>[]>
- com.iizix.prop.PropCnr
- com.iizix.server.acme.LetsEncryptDomain
- All Implemented Interfaces:
EventListener
,IGProp<GProp<?>[]>
,IPropCnr
,java.lang.Cloneable
- Direct Known Subclasses:
EditorLetsEncryptDomain
public class LetsEncryptDomain extends PropCnr
Property container holding information about a Let's Encrypt domain with automatic certificate renewal in the server.
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ALIAS
The alias for the certificate.static java.lang.String
AUTO_ACCEPT
Flag for auto-accept.static java.lang.String
DEFAULT_PASSWORD
Default password for keystore.static java.lang.String
EXPIRE_DAYS
The number of days before certificate expiration when a new certificate is requested from Let's Encrypt.static java.lang.String
ID_PASSWORD
The PKCS#12 identity password.static java.lang.String
ID_PKCS12
The PKCS#12 identity.static java.lang.String
TOS_ACCEPT_URI
The URI of the Terms-of-Service for Let's Encrypt that must be accepted.static java.lang.String
TOS_URI
The URI of the Terms-of-Service for Let's Encrypt that has been accepted.Fields inherited from class com.iizix.prop.PropCnr
EMPTY, EMPTY_CLASSES, EMPTY_CNRS, EXTENDS_FRAMEWORK_ERROR_ID
Fields inherited from class com.iizix.prop.GProp
GPDEBUG, PROP_ATTR_STRING_EDITOR_PROP, PROP_ATTR_STRING_ERRORED_NAME, PROP_ATTR_STRING_EXTENDS, PROP_ATTR_STRING_EXTENDS_FINAL, PROP_ATTR_STRING_EXTENDS_PRIVATE, PROP_ATTR_STRING_NULLABLE, PROP_ATTR_STRING_PRIVATE, PROP_ATTR_STRING_PRIVATE_CHANGE_EVENT, PROP_ATTR_STRING_READ_ONLY, PROP_USER_1, PROP_USER_2
Fields inherited from interface com.iizix.prop.IGProp
EQC_ERROR_IGNORE_ALL, EQC_ERROR_IGNORE_REFERENCES, EQC_IGNORE_ARRAY, EQC_IGNORE_VOLATILE_OR_EDITOR, EQC_PRIVATE, EQC_SAVE_FILE, EXT_CONTAINER_EXTENDS, EXT_CONTAINER_EXTENDS_VALID, EXT_EXTENDED, EXT_FINAL, EXT_OVERRIDES, EXT_OVERRIDES_FINAL_ERR, EXT_PRIVATE
Constructor Summary
Constructors Constructor Description LetsEncryptDomain()
Creates the port configuration without a name.LetsEncryptDomain(Atom atom)
Creates the port configuration with a name.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptTermsOfService(java.lang.String uri)
Called to accept a Terms-of-Service agreement.void
addConnectorReference(PortConfig config)
Adds a Jetty HTTP connector that references this domain.LetsEncryptDomain
clone()
Creates a clone out of this property.java.lang.String
getDescription()
Gets the description of the port configuration.java.lang.String
getDomain()
Gets the domain name.java.util.Date
getExpirationDate()
Gets the expiration date of the identities first certificate alias.int
getExpirationDayCount()
Gets the number of days before certificate expiration when a new certificate is requested from Let's Encrypt.java.security.KeyStore
getKeyStore()
Gets the KeyStore from a PKCS#12 identity property and password.java.security.KeyStore
getKeyStore(java.lang.StringBuilder pwReturn)
Gets the KeyStore from a PKCS#12 identity property and password.java.lang.String
getKeyStorePassword()
Gets the KeyStore password.java.lang.String
getNeedToAcceptTermsOfServiceURI()
Gets the Terms-of-Service agreement URI that needs to be accepted.LetsEncryptRenewal
getRenewalInstance()
Gets the certificate renewal instance.java.lang.String
getTermsOfServiceURI()
Gets the current Terms-of-Service agreement URIboolean
isAutoAcceptTermsOfServiceEnabled()
Returns the auto-accept Terms-of-Service agreement flag.void
onEventSelf(GEvent event)
Change of password or keystore invalidates the existing keystore cached.boolean
setNeedToAcceptTermsOfServiceURI(java.lang.String uri)
Gets the Terms-of-Service agreement URI that needs to be accepted.void
startRenewal(ServerShell server)
Starts the renewal processing for the server.boolean
updateIdentity(java.io.File file, java.lang.String password)
Updates the PKCS#12 identity from a file.Methods inherited from class com.iizix.prop.PropCnr
__transferChildProps, addPredefinedProps, addProp, addProp, addProp2, addProp2, appendPropValue, canRequestFocus, completeVirtualize, containsProp, containsProp, convertLoadedProp, couldRequestFocusIfVirtualized, createCopyOfAtom, createUniqueAtom, createUniqueAtom, createUniqueAtom, createVSReference, doPropEqualsArrayValues, doVirtualizePropCnr, enablePropCommunication, enablePropHashMap, equalsTree, equalsTree, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getBool, getBool, getBool, getBool, getChildPropError, getChildPropError, getChildPropErrorSeverity, getChildPropErrorSeverity, getErrorsProp, getExtendsContainer, getExtendsError, getExtendsName, getExtendsOverride, getExtendsPossibleClasses, getFirstProp, getFirstProp, getFocusEngine, getInt, getInt, getInt, getInt, getLong, getLong, getLong, getLong, getNumber, getNumber, getNumber, getNumber, getPossibleChildren, getPredefinedProps, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getPropBaseReference, getPropCnr, getPropCount, getPropCount, getPropIndex, getPropIndex, getPropIndexes, getProps, getProps, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue0, getReferences, getRetargetedVerifyContainer, getString, getString, getString, getString, getValueClasses, getVSReference, hasFocus, hasSendData, initializeElement, initializeExtendsFramework, initializeProp, initializeValue, initPropCnr, insertProp, insertProp2, isChild, isExtendsOverriden, isExtendsPropertyValid, isExtendsRoot, isPropAddRemoveAllowed, isPropCommunicating, isPropExtended, isSibling, list, list, logPropNotFound, maybeAddProp, onInsertProp, onPropDispose, onPropRemoved, onPropTreeInitialized, onReferenceEvent, paramString, prepare, removeAllProps, removeAllProps2, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, reorderProps, replaceProps, requestFocus, requestFocus, requestFocusEx, requestFocusEx, resolveReferences, resolveRuntimeReferences, setBool, setBool, setBool, setBool, setCreateRequiredProp, setExtendsName, setExtendsOverride, setInt, setInt, setInt, setLong, setLong, setLong, setLong, setNumber, setNumber, setNumber, setNumber, setProp, setProp, setProp, setProp2, setProp2, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setString, setString, setString, setString, shouldCreateProps, shouldSerializeToXML, toElementString, toNativeValue0, usePropHashMap, usesPropIndex, validateChildPropInValue, validateClassInstances, validatePropType, validatePropValue, verify, verifyInternalUseOnly, verifyTree, virtualize
Methods inherited from class com.iizix.prop.GProp
addPropError, addPropListener, convertPropError, dispose, equals, equals, equalsErrors, equalsObj, equalsPropValue, equalValues, extendsClone, finalize, fine, fine, finer, finer, finest, finest, fromElementString, getAliasName, getAppSessionGyro, getAppWorker, getAtomPath, getAttribute, getChildReferencePropName, getClientSessionGyro, getClientWorker, getConstraints, getEnvironment, getErroredPropItems, getErroredProps, getErrorsProp, getExtendsRootContainer, getFullPropName, getFullPropName, getFullPropNameDebug, getFullPropNameDebug, getListeners, getModuleFolder, getModuleFolder, getParent, getParent, getProjectName, getPropAtom, getPropError, getPropError, getPropErroredName, getPropErrorSeverity, getPropExtendsFlags, getPropFromPath, getPropFromPath, getPropFromReference, getPropFromReference, getPropIndex, getPropName, getPropPath, getPropPath, getPropReferenceTarget, getPropRootPropMgr, getPropTreeErrorSeverity, getPropValue, getPropValue, getPropValueObject, getReferencePropName, getRelativePropName, getRootFromName, getRootName, getRootParent, getRootParent, getTreeLock, hasChanged, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCreateRequired, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropForEditor, isPropNullable, isPropPrivate, isPropPrivateAtCreation, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropUSER, isPropValueTreeLockNeeded, isPropVirtualized, isPropVirtualizing, isPropVolatile, isPropVolatileOrEditorOnly, isProxied, list, list, list, mapAliasToReference, mapAliasToReference, mapReferenceToAlias, mapReferenceToAlias, mapReferenceToProjectRelative, modifyPropValue, moveProp, moveProp, moveProp, onEvent, onPrepare, onPropInvalidateCache, onPropParentChanged, onPropValueSet, onRemoteEvent, onVirtualizationCompleted, onVirtualized, paramValue, post, post, removePropError, removePropListener, removePropUSER, renameProp, renameProp2, resetChangedTree, setChanged, setConstraints, setConstraints, setParent, setPrivateChangeEventProp, setPrivateCreateRequiredProp, setPropError, setPropErroredName, setPropExtended, setPropExtendsFinal, setPropExtendsPrivate, setPropForEditor, setPropNullable, setPropPrivate, setPropReadOnly, setPropUSER, setPropValue, setPropValue, setPropValue, setPropValueIncognito, setPropVolatile, severe, severe, severe, shouldSerializeToXML, throwIfReadOnly, toNativeValue, toString, toString, triggerRemoteEvent, triggerRemoteEvent, validateProp, verifyHasPropertyItem, warning, warning, warning
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.iizix.prop.IGProp
addPropError, addPropListener, dispose, equals, fine, fine, finer, finer, finest, finest, fromElementString, getAppSessionGyro, getAtomPath, getClientSessionGyro, getConstraints, getEnvironment, getErroredPropItems, getErroredProps, getErrorsProp, getExtendsRootContainer, getFullPropName, getFullPropNameDebug, getModuleFolder, getModuleFolder, getParent, getParent, getPropAtom, getPropError, getPropError, getPropErrorSeverity, getPropExtendsFlags, getPropFromPath, getPropFromReference, getPropIndex, getPropName, getPropPath, getPropPath, getPropRootPropMgr, getPropTreeErrorSeverity, getPropValue, getPropValue, getReferencePropName, getRelativePropName, getRootParent, getTreeLock, hasChanged, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCreateRequired, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropNullable, isPropPrivate, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropVirtualized, list, list, list, mapAliasToReference, mapReferenceToAlias, mapReferenceToProjectRelative, moveProp, moveProp, moveProp, onEvent, onRemoteEvent, removePropError, removePropListener, renameProp, setChanged, setConstraints, setConstraints, setParent, setPrivateChangeEventProp, setPropError, setPropExtendsFinal, setPropExtendsPrivate, setPropNullable, setPropPrivate, setPropReadOnly, setPropValue, setPropValue, severe, severe, severe, toNativeValue, triggerRemoteEvent, triggerRemoteEvent, validateProp, verifyHasPropertyItem, warning, warning, warning
Methods inherited from interface com.iizix.prop.IPropCnr
canRequestFocus, canRequestFocus, couldRequestFocusIfVirtualized, couldRequestFocusIfVirtualized
Field Detail
ID_PKCS12
public static final java.lang.String ID_PKCS12
The PKCS#12 identity.- See Also:
- Constant Field Values
ID_PASSWORD
public static final java.lang.String ID_PASSWORD
The PKCS#12 identity password.- See Also:
- Constant Field Values
EXPIRE_DAYS
public static final java.lang.String EXPIRE_DAYS
The number of days before certificate expiration when a new certificate is requested from Let's Encrypt.- See Also:
- Constant Field Values
TOS_URI
public static final java.lang.String TOS_URI
The URI of the Terms-of-Service for Let's Encrypt that has been accepted.- See Also:
- Constant Field Values
TOS_ACCEPT_URI
public static final java.lang.String TOS_ACCEPT_URI
The URI of the Terms-of-Service for Let's Encrypt that must be accepted.- See Also:
- Constant Field Values
AUTO_ACCEPT
public static final java.lang.String AUTO_ACCEPT
Flag for auto-accept.- See Also:
- Constant Field Values
ALIAS
public static final java.lang.String ALIAS
The alias for the certificate.- See Also:
- Constant Field Values
DEFAULT_PASSWORD
public static final java.lang.String DEFAULT_PASSWORD
Default password for keystore.- See Also:
- Constant Field Values
Constructor Detail
LetsEncryptDomain
public LetsEncryptDomain()
Creates the port configuration without a name. The name must be set in all cases using thesetPropertyAtom
call.
LetsEncryptDomain
public LetsEncryptDomain(Atom atom)
Creates the port configuration with a name.- Parameters:
atom
- The name of the property.
Method Detail
clone
public LetsEncryptDomain clone()
Creates a clone out of this property. The cloning is overridden by the subclasses in order to handle cloning of its class variables appropriately.
onEventSelf
public void onEventSelf(GEvent event)
Change of password or keystore invalidates the existing keystore cached.- Specified by:
onEventSelf
in interfaceIGProp<GProp<?>[]>
- Overrides:
onEventSelf
in classGProp<GProp<?>[]>
- Parameters:
event
- The property event.
getKeyStorePassword
public java.lang.String getKeyStorePassword()
Gets the KeyStore password.- Returns:
- The password, "changeit" for default.
getKeyStore
public java.security.KeyStore getKeyStore() throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOException
Gets the KeyStore from a PKCS#12 identity property and password.- Returns:
- The configured KeyStore, or null if not defined.
- Throws:
java.security.KeyStoreException
- If no Provider supports a KeyStoreSpi implementation for the PKCS#12 type.java.security.NoSuchAlgorithmException
- If the algorithm used to check the integrity of the KeyStore cannot be found.java.security.cert.CertificateException
- If any of the certificates in the KeyStore could not be loaded.java.io.IOException
- If there is an I/O or format problem with the KeyStore data, if a password is required but not given, or if the given password was incorrect. If the error is due to a wrong password, the cause of the IOException should be an UnrecoverableKeyException.
getKeyStore
public java.security.KeyStore getKeyStore(java.lang.StringBuilder pwReturn) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOException
Gets the KeyStore from a PKCS#12 identity property and password.- Parameters:
pwReturn
- A StringBuilder instance that is filled with the password, null for none.- Returns:
- The configured KeyStore, or null if not defined.
- Throws:
java.security.KeyStoreException
- If no Provider supports a KeyStoreSpi implementation for the PKCS#12 type.java.security.NoSuchAlgorithmException
- If the algorithm used to check the integrity of the KeyStore cannot be found.java.security.cert.CertificateException
- If any of the certificates in the KeyStore could not be loaded.java.io.IOException
- If there is an I/O or format problem with the KeyStore data, if a password is required but not given, or if the given password was incorrect. If the error is due to a wrong password, the cause of the IOException should be an UnrecoverableKeyException.
updateIdentity
public boolean updateIdentity(java.io.File file, java.lang.String password) throws java.security.UnrecoverableKeyException, java.io.FileNotFoundException, java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOException, PropException
Updates the PKCS#12 identity from a file.- Parameters:
file
- The identity file.password
- The password, null for default "changeit".- Returns:
- true for changed, false for no change.
- Throws:
java.io.FileNotFoundException
- If the file is not found.java.security.NoSuchAlgorithmException
- If the algorithm used to check the integrity of the keystore cannot be found.java.security.cert.CertificateException
- If any of the certificates in the keystore could not be loaded.java.io.IOException
- If there is an I/O or format problem with the keystore data, if a password is required but not given, or if the given password was incorrect. If the error is due to a wrong password, the cause of the IOException should be an UnrecoverableKeyException.java.security.UnrecoverableKeyException
- If the key cannot be recovered (e.g. the given password is wrong).java.security.KeyStoreException
PropException
getExpirationDayCount
public int getExpirationDayCount()
Gets the number of days before certificate expiration when a new certificate is requested from Let's Encrypt.- Returns:
- The number of days in the range 1 to 89, default 7.
getExpirationDate
public java.util.Date getExpirationDate()
Gets the expiration date of the identities first certificate alias.- Returns:
- The date of expiry, or null if identity is not set or failed to load.
getDomain
public java.lang.String getDomain()
Gets the domain name.- Returns:
- The domain name as e.g. "hello.example.com".
getDescription
public java.lang.String getDescription()
Gets the description of the port configuration.- Returns:
- The description, or null for none.
getTermsOfServiceURI
public java.lang.String getTermsOfServiceURI()
Gets the current Terms-of-Service agreement URI- Returns:
- The ToS URI, or null if not received yet.
isAutoAcceptTermsOfServiceEnabled
public boolean isAutoAcceptTermsOfServiceEnabled()
Returns the auto-accept Terms-of-Service agreement flag.- Returns:
- true for auto-acceptance, false for manual acceptance.
acceptTermsOfService
public boolean acceptTermsOfService(java.lang.String uri)
Called to accept a Terms-of-Service agreement.- Parameters:
uri
- The ToS URI.- Returns:
- true if changed, false for no change.
- Throws:
java.lang.NullPointerException
- Ifuri
is null.
getNeedToAcceptTermsOfServiceURI
public java.lang.String getNeedToAcceptTermsOfServiceURI()
Gets the Terms-of-Service agreement URI that needs to be accepted.- Returns:
- The URI, or null for none.
setNeedToAcceptTermsOfServiceURI
public boolean setNeedToAcceptTermsOfServiceURI(java.lang.String uri)
Gets the Terms-of-Service agreement URI that needs to be accepted.- Parameters:
uri
- The URI, never null.- Returns:
- true if changed, false for no change.
- Throws:
java.lang.NullPointerException
- Ifuri
is null.
startRenewal
public void startRenewal(ServerShell server)
Starts the renewal processing for the server.- Parameters:
server
- The server.
getRenewalInstance
public LetsEncryptRenewal getRenewalInstance()
Gets the certificate renewal instance.- Returns:
- The renewal instance, or null if not started.
addConnectorReference
public void addConnectorReference(PortConfig config)
Adds a Jetty HTTP connector that references this domain.- Parameters:
config
- The port configuration.