Class ManagedPkiCredential
java.lang.Object
se.swedenconnect.security.credential.AbstractPkiCredential
se.swedenconnect.security.credential.AbstractReloadablePkiCredential
se.swedenconnect.security.credential.container.ManagedPkiCredential
- All Implemented Interfaces:
PkiCredential,ReloadablePkiCredential
A managed
PkiCredential is used when a PkiCredentialContainer returns credentials. The recipient of a
managed credential may invoke destroy() to remove the credential from the container, and also update the
certifcate of the managed credential.- Author:
- Martin Lindström
-
Nested Class Summary
Nested classes/interfaces inherited from interface se.swedenconnect.security.credential.PkiCredential
PkiCredential.Metadata -
Constructor Summary
ConstructorsConstructorDescriptionManagedPkiCredential(PkiCredential managedCredential, Consumer<PkiCredential> destroyCallback, Consumer<X509Certificate[]> updateCertificateCallback) Constructor setting the credential to be managed and callbacks to be used by the underlying container. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()If not already destroyed, the method will invoke thePkiCredential.destroy()method on the managed credential, and then invoke the destroy callback to inform the owning container about that the credential should be removed.If a certificate or certificate chain has been added after the creation of the managed credential, this chain will be returned, otherwise the credential's original chain.protected StringIf the credentialnameproperty is not explicitly assigned usingAbstractPkiCredential.setName(String)a name is calculated based on a credential's properties.getName()Gets the name of the credential.Returns thePrivateKeyof the managed credential.Gets the public key.booleanPredicate that tells whether this credential resides in a hardware module.voidreload()If the managed credential implementsReloadablePkiCredential, theReloadablePkiCredential.reload()method will be called on the managed credential.voidsetCertificate(X509Certificate certificate) Assigns a new certificate for the credential.voidsetCertificateChain(List<X509Certificate> certificates) Assigns a new certificate chain for the credential.voidWillMethods inherited from class se.swedenconnect.security.credential.AbstractReloadablePkiCredential
getTestFunction, setTestFunctionMethods inherited from class se.swedenconnect.security.credential.AbstractPkiCredential
getMetadata, getStandalonePublicKey, updateMetadataValidityPropertiesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface se.swedenconnect.security.credential.PkiCredential
getCertificate, getMetadata, transform
-
Constructor Details
-
ManagedPkiCredential
public ManagedPkiCredential(@Nonnull PkiCredential managedCredential, @Nonnull Consumer<PkiCredential> destroyCallback, @Nullable Consumer<X509Certificate[]> updateCertificateCallback) Constructor setting the credential to be managed and callbacks to be used by the underlying container.- Parameters:
managedCredential- the credential being manageddestroyCallback- a callback that is invoked if thedestroy()method is calledupdateCertificateCallback- optional callback that is invoked ifsetCertificate(X509Certificate)orsetCertificateChain(List)is called. This gives the owner of the managed credential the possibility to update the underlying credential
-
-
Method Details
-
setCertificate
Assigns a new certificate for the credential. This certificate must still form a valid key pair given the private key.- Parameters:
certificate- the new certificate
-
setCertificateChain
Assigns a new certificate chain for the credential. This first certificate (entity certificate) must still form a valid key pair given the private key.- Parameters:
certificates- the new certificate chain (entity certificate must be placed first)
-
getCertificateChain
If a certificate or certificate chain has been added after the creation of the managed credential, this chain will be returned, otherwise the credential's original chain.- Returns:
- a list of certificates, or an empty list
-
getPublicKey
Gets the public key.- Specified by:
getPublicKeyin interfacePkiCredential- Overrides:
getPublicKeyin classAbstractPkiCredential- Returns:
- the public key
-
getPrivateKey
Returns thePrivateKeyof the managed credential.- Returns:
- the private key
-
isHardwareCredential
public boolean isHardwareCredential()Predicate that tells whether this credential resides in a hardware module.- Returns:
trueif the credential resides in a hardware module andfalseotherwise
-
getName
Gets the name of the credential. If no name has been explicitly assigned, the default name is used.- Specified by:
getNamein interfacePkiCredential- Overrides:
getNamein classAbstractPkiCredential- Returns:
- the name
-
setName
Will- Overrides:
setNamein classAbstractPkiCredential- Parameters:
name- the name
-
getDefaultName
Description copied from class:AbstractPkiCredentialIf the credentialnameproperty is not explicitly assigned usingAbstractPkiCredential.setName(String)a name is calculated based on a credential's properties.- Specified by:
getDefaultNamein classAbstractPkiCredential- Returns:
- the credential name
-
destroy
public void destroy()If not already destroyed, the method will invoke thePkiCredential.destroy()method on the managed credential, and then invoke the destroy callback to inform the owning container about that the credential should be removed. -
reload
If the managed credential implementsReloadablePkiCredential, theReloadablePkiCredential.reload()method will be called on the managed credential.- Throws:
Exception- for reloading errors
-