Interface ICertificateEntityDao
public interface ICertificateEntityDao
DAO for reading and writing
CertificateEntity entities.- Since:
- 8.5.0
- Author:
- XIMA Media GmbH
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@NotNull CertificateEntitycreate(CertificateEntity entity) Creates a newCertificateEntityin the database.voiddelete(CertificateEntity entity) Deletes the specified certificate entity.booleanexistsByFingerprint(String certificateFingerprint, KeyStoreScope keyStoreScope) Returns whether aCertificateEntitywith the given SHA-256 fingerprint exists.booleanexistsByPublicKeyFingerprint(String publicKeyFingerprint, KeyStoreScope keyStoreScope) Returns whether aCertificateEntityexists in relation to the given public key SHA-256 fingerprint.@NotNull Optional<CertificateEntity> findByFingerprint(String certificateFingerprint, KeyStoreScope keyStoreScope) Retrieves aCertificateEntityby its SHA-256 fingerprint.@NotNull Optional<CertificateEntity> Retrieves aCertificateEntityby its ID.@NotNull Optional<CertificateEntity> findByPublicKeyFingerprint(String publicKeyFingerprint, KeyStoreScope keyStoreScope) Retrieves aCertificateEntityby its public key SHA-256 fingerprint.@NotNull Optional<CertificateEntity> findByPublicKeyFingerprint(String publicKeyFingerprint, Long keyStoreId) Retrieves aCertificateEntityby its public key SHA-256 fingerprint.@NotNull List<CertificateEntity> findValidCertificatesBySubject(Set<Long> tenantIds, Set<Long> userIds, boolean systemScope, String subject, Boolean hasKeyPair, Set<ECertificateUsageType> usageTypes, Set<String> keyAlgorithms, boolean subjectPartialMatch) Retrieves all valid certificates for a given tenant ID, user IDs, and the subject.@NotNull List<CertificateEntity> findValidCertificatesByUsageSubject(Set<Long> tenantIds, Set<Long> userIds, boolean systemScope, String usageSubject, ECertificateUsageType usageType, Boolean hasKeyPair, Set<String> keyAlgorithms, boolean usageSubjectPartialMatch) Retrieves all valid certificates for a given tenant ID, user IDs, usage type, and the usage subject.@NotNull Optional<CertificateEntity> getCurrentValidCertificateBySubject(Set<Long> tenantIds, Set<Long> userIds, boolean systemScope, String subject, Boolean hasKeyPair, Set<ECertificateUsageType> usageTypes, Set<String> keyAlgorithms) Retrieves the current valid certificate for a given tenant ID, it's user IDs, and subject.@NotNull Optional<CertificateEntity> getCurrentValidCertificateByUsageSubject(Set<Long> tenantIds, Set<Long> userIds, boolean systemScope, String usageSubject, ECertificateUsageType usageType, Boolean hasKeyPair, Set<String> keyAlgorithms) Retrieves the current valid certificate for a given tenant ID, it's user IDs, usage type, and usage subject.@NotNull intgetExpiredCertificateCountAt(Instant timestamp) Retrieves the number of certificates that are expired at the given timestamp.@NotNull List<CertificateEntity> getExpiredCertificatesAt(Instant timestamp) Retrieves all certificates that are expired at the given timestamp.@NotNull List<CertificateEntity> getTlsCertificatesForKeystoreScope(Long keyStoreId, Instant timestamp) Retrieves the TLS certificates for the keystore with the given ID that are valid at the instant given by the time stamp.@NotNull List<CertificateEntity> getTlsCertificatesForSystemScope(Instant timestamp) Retrieves the TLS certificates for the system scope that are valid at the instant given by the time stamp.@NotNull List<CertificateEntity> getTlsCertificatesForTenantScope(Long tenantIds, Instant timestamp) Retrieves the TLS certificates for the tenant with the given ID that are valid at the instant given by the time stamp.@NotNull CertificateEntityupdate(CertificateEntity entity) Updates the specifiedCertificateEntityin the database.
-
Method Details
-
create
@NotNull @NotNull CertificateEntity create(CertificateEntity entity) throws FcCertificateManagementException Creates a newCertificateEntityin the database.- Parameters:
entity- TheCertificateEntityto create.- Throws:
IllegalArgumentException- if the provided entity is null or has an IDFcCertificateManagementException- if the certificate could not be created
-
delete
Deletes the specified certificate entity.- Parameters:
entity- the certificate entity to delete.- Throws:
IllegalArgumentException- if the provided entity is nullFcCertificateManagementException- if the certificate could not be deleted
-
existsByFingerprint
Returns whether aCertificateEntitywith the given SHA-256 fingerprint exists.- Parameters:
certificateFingerprint- The SHA-256 fingerprint of the certificate.keyStoreScope- The key store scope, the existence check should be performed at.- Returns:
trueif a certificate with the specified fingerprint exists,falseotherwise.- Throws:
IllegalArgumentException- if the fingerprint is blank or the key store scope is invalid.
-
existsByPublicKeyFingerprint
Returns whether aCertificateEntityexists in relation to the given public key SHA-256 fingerprint.- Parameters:
publicKeyFingerprint- The SHA-256 fingerprint of the certificates corresponding public key.keyStoreScope- The key store scope, the existence check should be performed at.- Returns:
trueif a certificate with the specified public key fingerprint exists,falseotherwise.- Throws:
IllegalArgumentException- if the public key fingerprint is blank or the key store scope is invalid.
-
findByFingerprint
@NotNull @NotNull Optional<CertificateEntity> findByFingerprint(String certificateFingerprint, KeyStoreScope keyStoreScope) Retrieves aCertificateEntityby its SHA-256 fingerprint.- Parameters:
certificateFingerprint- The SHA-256 fingerprint of the certificate.keyStoreScope- The key store scope, the search should be performed at.- Returns:
- The
CertificateEntitywith the specified fingerprint, or an emptyOptionalif not found. - Throws:
IllegalArgumentException- if the fingerprint is blank or the key store scope is invalid.
-
findById
Retrieves aCertificateEntityby its ID.- Parameters:
id- the ID of the certificate to retrieve.- Returns:
- an
Optionalcontaining theCertificateEntityif found, or an emptyOptionalif not
-
findByPublicKeyFingerprint
@NotNull @NotNull Optional<CertificateEntity> findByPublicKeyFingerprint(String publicKeyFingerprint, Long keyStoreId) Retrieves aCertificateEntityby its public key SHA-256 fingerprint.- Parameters:
publicKeyFingerprint- The SHA-256 fingerprint of the certificate's public key.keyStoreId- The ID of the key store, the search should be performed at.- Returns:
- The
CertificateEntitywith the specified public key fingerprint, or an emptyOptionalif not found. - Throws:
IllegalArgumentException- if the public key fingerprint is blank or the key store scope is invalid.
-
findByPublicKeyFingerprint
@NotNull @NotNull Optional<CertificateEntity> findByPublicKeyFingerprint(String publicKeyFingerprint, KeyStoreScope keyStoreScope) Retrieves aCertificateEntityby its public key SHA-256 fingerprint.- Parameters:
publicKeyFingerprint- The SHA-256 fingerprint of the certificate's public key.keyStoreScope- The key store scope, the search should be performed at.- Returns:
- The
CertificateEntitywith the specified public key fingerprint, or an emptyOptionalif not found. - Throws:
IllegalArgumentException- if the public key fingerprint is blank or the key store scope is invalid.
-
findValidCertificatesBySubject
@NotNull @NotNull List<CertificateEntity> findValidCertificatesBySubject(Set<Long> tenantIds, Set<Long> userIds, boolean systemScope, String subject, Boolean hasKeyPair, Set<ECertificateUsageType> usageTypes, Set<String> keyAlgorithms, boolean subjectPartialMatch) Retrieves all valid certificates for a given tenant ID, user IDs, and the subject. All certificates, independent of their usages, are considered. This is in contrast tofindValidCertificatesByUsageSubject(Set, Set, boolean, String, ECertificateUsageType, Boolean, Set, boolean)which retrieves the certificates by their usage subject and usage type, and not by their certificate subject.- Parameters:
tenantIds- A set of tenant IDs to filter the certificates by. Can be empty if no tenant scoped certificates should be included.userIds- A set of user IDs to filter the certificates by. Can be empty if no user scoped certificates should be included.systemScope- if true, system scope certificates will be included in the search; if false, only tenant/user scope certificates will be included.subject- The of thesubjectto match.hasKeyPair- if true, only certificates with an associated private key will be returned; if false, only certificates without an associated private key will be returned; if null, certificates with and without an associated private key will be returned.usageTypes- Optional set ofECertificateUsageTypeto filter the certificates by their usage types. If null or empty, no filtering by usage type is applied.keyAlgorithms- Optional set of key algorithms to filter the certificates by their key algorithms. If null or empty, no filtering by key algorithm is applied.subjectPartialMatch- whether to perform a partial match on the subject. If true, certificates whose subjects contain the specified subject as a substring will be matched. If false, only exact matches will be considered.- Returns:
- A list of
CertificateEntityobjects that match the criteria.
-
findValidCertificatesByUsageSubject
@NotNull @NotNull List<CertificateEntity> findValidCertificatesByUsageSubject(Set<Long> tenantIds, Set<Long> userIds, boolean systemScope, String usageSubject, ECertificateUsageType usageType, Boolean hasKeyPair, Set<String> keyAlgorithms, boolean usageSubjectPartialMatch) Retrieves all valid certificates for a given tenant ID, user IDs, usage type, and the usage subject. Only certificates with non-blank usage subject are considered. This is in contrast tofindValidCertificatesBySubject(Set, Set, boolean, String, Boolean, Set, Set, boolean)which retrieves the certificates by their certificate subject, and not by their usage subject.- Parameters:
tenantIds- A set of tenant IDs to filter the certificates by. Can be empty if no tenant scoped certificates should be included.userIds- A set of user IDs to filter the certificates by. Can be empty if no user scoped certificates should be included.systemScope- if true, system scope certificates will be included in the search; if false, only tenant/user scope certificates will be included.usageSubject- The of theusage subjectto match.usageType- Theusage typeof the certificates to match. Must not be null.hasKeyPair- if true, only certificates with an associated private key will be returned; if false, only certificates without an associated private key will be returned; if null, certificates with and without an associated private key will be returned.keyAlgorithms- Optional set of key algorithms to filter the certificates by their key algorithms. If null or empty, no filtering by key algorithm is applied.usageSubjectPartialMatch- whether to perform a partial match on the usage subject. If true, certificates whose usage subjects contain the specified usage subject as a substring will be matched. If false, only exact matches will be considered.- Returns:
- A list of
CertificateEntityobjects that match the criteria.
-
getCurrentValidCertificateBySubject
@NotNull @NotNull Optional<CertificateEntity> getCurrentValidCertificateBySubject(Set<Long> tenantIds, Set<Long> userIds, boolean systemScope, String subject, Boolean hasKeyPair, Set<ECertificateUsageType> usageTypes, Set<String> keyAlgorithms) Retrieves the current valid certificate for a given tenant ID, it's user IDs, and subject. All certificates, independent of their usages, are considered. This is in contrast togetCurrentValidCertificateByUsageSubject(Set, Set, boolean, String, ECertificateUsageType, Boolean, Set)which retrieves the certificate by its usage subject and usage type, and not by its certificate subject.- Parameters:
tenantIds- A set of tenant IDs to filter the certificate by. Can be empty if no tenant scoped certificates should be included.userIds- A set of user IDs to filter the certificate by. Can be empty if no user scoped certificates should be included.systemScope- if true, system scope certificates will be included in the search; if false, only tenant/user scope certificates will be included.subject- Thesubjectof the certificate to match. Must not be blank.hasKeyPair- if true, only certificates with an associated private key will be returned; if false, only certificates without an associated private key will be returned; if null, certificates with and without an associated private key will be returned.usageTypes- Optional set ofECertificateUsageTypeto filter the certificate by its usage types. If null or empty, no filtering by usage type is applied.keyAlgorithms- Optional set of key algorithms to filter the certificate by its key algorithms. If null or empty, no filtering by key algorithm is applied.- Returns:
- An
Optionalcontaining theCertificateEntityif found, or empty if no valid certificate exists. - Throws:
IllegalArgumentException- if the subject is blank or not a valid X.501 distinguished name.
-
getCurrentValidCertificateByUsageSubject
@NotNull @NotNull Optional<CertificateEntity> getCurrentValidCertificateByUsageSubject(Set<Long> tenantIds, Set<Long> userIds, boolean systemScope, String usageSubject, ECertificateUsageType usageType, Boolean hasKeyPair, Set<String> keyAlgorithms) Retrieves the current valid certificate for a given tenant ID, it's user IDs, usage type, and usage subject. Only certificates with non-blank usage subject are considered. This is in contrast togetCurrentValidCertificateBySubject(Set, Set, boolean, String, Boolean, Set, Set)which retrieves the certificate by its certificate subject and not by its usage subject.- Parameters:
tenantIds- A set of tenant IDs associated with the tenant. Can be empty if no tenant scoped certificates should be included.userIds- A set of user IDs associated with the tenant. Can be empty if no user scoped certificates should be included.systemScope- if true, system scope certificates will be included in the search; if false, only tenant/user scope certificates will be included.usageSubject- Theusage subjectof the certificate to match. Must not be blank.usageType- Theusage typeof the certificate to match. Must not be null.hasKeyPair- if true, only certificates with an associated private key will be returned; if false, only certificates without an associated private key will be returned; if null, certificates with and without an associated private key will be returned.keyAlgorithms- Optional set of key algorithms to filter the certificate by its key algorithms. If null or empty, no filtering by key algorithm is applied.- Returns:
- An
Optionalcontaining theCertificateEntityif found, or empty if no valid certificate exists.
-
getExpiredCertificateCountAt
Retrieves the number of certificates that are expired at the given timestamp.- Parameters:
timestamp- the instant at which the certificate should be expired.- Returns:
- the number of certificates, that are expired at the given timestamp
-
getExpiredCertificatesAt
Retrieves all certificates that are expired at the given timestamp.- Parameters:
timestamp- the instant at which the certificate should be expired.- Returns:
- a list of
CertificateEntityobjects representing the certificates that are expired at the given time stamp.
-
getTlsCertificatesForTenantScope
@NotNull @NotNull List<CertificateEntity> getTlsCertificatesForTenantScope(Long tenantIds, Instant timestamp) Retrieves the TLS certificates for the tenant with the given ID that are valid at the instant given by the time stamp. For tenants all TLS certificates of that tenant and all TLS system certificates are returned.- Parameters:
tenantIds- the ID of the tenant to search for. This must be a valid ID.timestamp- the instant at which the certificate should be valid. This must be a valid instant.- Returns:
- a list of
CertificateEntityobjects representing the TLS certificates for the given tenant scope that are valid at the given time stamp ordered by the valid from date. - Throws:
IllegalArgumentException- if the tenant ID or timestamp is null.
-
getTlsCertificatesForKeystoreScope
@NotNull @NotNull List<CertificateEntity> getTlsCertificatesForKeystoreScope(Long keyStoreId, Instant timestamp) Retrieves the TLS certificates for the keystore with the given ID that are valid at the instant given by the time stamp. For keystores all TLS certificates of that keystore are returned.- Parameters:
keyStoreId- the ID of the keystore to search for. This must be a valid ID.timestamp- the instant at which the certificate should be valid. This must be a valid instant.- Returns:
- a list of
CertificateEntityobjects representing the TLS certificates for the given keystore scope that are valid at the given time stamp ordered by the valid from date. - Throws:
IllegalArgumentException- if the keystore ID or timestamp is null.
-
getTlsCertificatesForSystemScope
Retrieves the TLS certificates for the system scope that are valid at the instant given by the time stamp. For the system scope all TLS system certificates are returned.- Parameters:
timestamp- the instant at which the certificate should be valid. This must be a valid instant.- Returns:
- a list of
CertificateEntityobjects representing the TLS certificates for the system scope that are valid at the given time stamp ordered by the valid from date. - Throws:
IllegalArgumentException- if the timestamp is null.
-
update
@NotNull @NotNull CertificateEntity update(CertificateEntity entity) throws FcCertificateManagementException Updates the specifiedCertificateEntityin the database.- Parameters:
entity- TheCertificateEntityto update.- Throws:
IllegalArgumentException- if the provided entity is null or has no IDFcCertificateManagementException- if the certificate could not be updated
-