Class BasicCredential
java.lang.Object
se.swedenconnect.security.credential.AbstractPkiCredential
se.swedenconnect.security.credential.BasicCredential
- All Implemented Interfaces:
PkiCredential
A basic implementation of the
PkiCredential
interface.- Author:
- Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
-
Nested Class Summary
Nested classes/interfaces inherited from interface se.swedenconnect.security.credential.PkiCredential
PkiCredential.Metadata
-
Constructor Summary
ConstructorDescriptionBasicCredential
(X509Certificate certificate, PrivateKey privateKey) Constructor setting the certificate and private key.BasicCredential
(KeyPair keyPair) Constructor accepting aKeyPair
.BasicCredential
(PublicKey publicKey, PrivateKey privateKey) Constructor setting the public and private keys.BasicCredential
(List<X509Certificate> certificates, PrivateKey privateKey) Constructor assigning a certificate chain and private key. -
Method Summary
Modifier and TypeMethodDescriptionGets a certificate chain for the credential, where the first element is the entity certificate (PkiCredential.getCertificate()
).protected String
Gets the certificate serial number, and if no certificate is available a UUID is used.Gets the private key.protected PublicKey
If a credential without a certificate is created, this method must be overridden and return the installedPublicKey
.Methods inherited from class se.swedenconnect.security.credential.AbstractPkiCredential
getMetadata, getName, getPublicKey, setName, 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
destroy, getCertificate, isHardwareCredential, transform
-
Constructor Details
-
BasicCredential
Constructor accepting aKeyPair
.- Parameters:
keyPair
- the key pair- Throws:
IllegalArgumentException
- if key pair is not valid
-
BasicCredential
public BasicCredential(@Nonnull PublicKey publicKey, @Nonnull PrivateKey privateKey) throws IllegalArgumentException Constructor setting the public and private keys.- Parameters:
publicKey
- the public keyprivateKey
- the private key- Throws:
IllegalArgumentException
- if the public and private key does not make up a valid key pair
-
BasicCredential
public BasicCredential(@Nonnull X509Certificate certificate, @Nonnull PrivateKey privateKey) throws IllegalArgumentException Constructor setting the certificate and private key.- Parameters:
certificate
- the certificateprivateKey
- the private key- Throws:
IllegalArgumentException
- if the public key from the certificate and private key does not make up a valid key pair
-
BasicCredential
Constructor assigning a certificate chain and private key.- Parameters:
certificates
- the certificate chain where the entity certificate is placed firstprivateKey
- the private key
-
-
Method Details
-
getPrivateKey
Gets the private key.- Returns:
- the private key
-
getCertificateChain
Gets a certificate chain for the credential, where the first element is the entity certificate (PkiCredential.getCertificate()
). If no certificate is configured for the credential an empty list is returned.- Returns:
- a list of certificates, or an empty list
-
getStandalonePublicKey
Description copied from class:AbstractPkiCredential
If a credential without a certificate is created, this method must be overridden and return the installedPublicKey
.- Overrides:
getStandalonePublicKey
in classAbstractPkiCredential
- Returns:
- the standalone public key, or
null
if a certificate is present
-
getDefaultName
Gets the certificate serial number, and if no certificate is available a UUID is used.- Specified by:
getDefaultName
in classAbstractPkiCredential
- Returns:
- the credential name
-