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 TypeMethodDescriptionvoid
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.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 String
If the credentialname
property 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 thePrivateKey
of the managed credential.Gets the public key.boolean
Predicate that tells whether this credential resides in a hardware module.void
reload()
If the managed credential implementsReloadablePkiCredential
, theReloadablePkiCredential.reload()
method will be called on the managed credential.void
setCertificate
(X509Certificate certificate) Assigns a new certificate for the credential.void
setCertificateChain
(List<X509Certificate> certificates) Assigns a new certificate chain for the credential.void
WillMethods inherited from class se.swedenconnect.security.credential.AbstractReloadablePkiCredential
getTestFunction, setTestFunction
Methods inherited from class se.swedenconnect.security.credential.AbstractPkiCredential
getMetadata, getStandalonePublicKey, updateMetadataValidityProperties
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
getPublicKey
in interfacePkiCredential
- Overrides:
getPublicKey
in classAbstractPkiCredential
- Returns:
- the public key
-
getPrivateKey
Returns thePrivateKey
of the managed credential.- Returns:
- the private key
-
isHardwareCredential
public boolean isHardwareCredential()Predicate that tells whether this credential resides in a hardware module.- Returns:
true
if the credential resides in a hardware module andfalse
otherwise
-
getName
Gets the name of the credential. If no name has been explicitly assigned, the default name is used.- Specified by:
getName
in interfacePkiCredential
- Overrides:
getName
in classAbstractPkiCredential
- Returns:
- the name
-
setName
Will- Overrides:
setName
in classAbstractPkiCredential
- Parameters:
name
- the name
-
getDefaultName
Description copied from class:AbstractPkiCredential
If the credentialname
property is not explicitly assigned usingAbstractPkiCredential.setName(String)
a name is calculated based on a credential's properties.- Specified by:
getDefaultName
in 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
-