Search in sources :

Example 1 with X509CertificateReferenceKeyIdentifierQuery

use of org.xwiki.crypto.store.wiki.internal.query.X509CertificateReferenceKeyIdentifierQuery in project xwiki-platform by xwiki.

the class AbstractX509WikiStore method findCertificate.

/**
 * Find the reference of the XObject storing a matching certificate in the given store.
 *
 * @param store the reference to a document or space used to store certificates.
 * @param publicKey the certificate to find the storage for.
 * @return a reference to the XObject storing a matching certificate, or null if none were found.
 * @throws CertificateStoreException on error.
 */
protected CertificateObjectReference findCertificate(StoreReference store, X509CertifiedPublicKey publicKey) throws CertificateStoreException {
    byte[] keyId = publicKey.getSubjectKeyIdentifier();
    CertificateObjectReference certRef;
    if (keyId != null) {
        certRef = new X509CertificateReferenceKeyIdentifierQuery(resolveStore(store), this.base64, this.queryManager, this.entityReferenceSerializer).getReference(keyId);
    } else {
        certRef = new X509CertificateReferenceIssuerAndSerialQuery(resolveStore(store), this.base64, this.queryManager, this.entityReferenceSerializer).getReference(publicKey.getIssuer(), publicKey.getSerialNumber());
    }
    return certRef;
}
Also used : X509CertificateReferenceKeyIdentifierQuery(org.xwiki.crypto.store.wiki.internal.query.X509CertificateReferenceKeyIdentifierQuery) X509CertificateReferenceIssuerAndSerialQuery(org.xwiki.crypto.store.wiki.internal.query.X509CertificateReferenceIssuerAndSerialQuery) CertificateObjectReference(org.xwiki.crypto.store.wiki.internal.query.CertificateObjectReference)

Aggregations

CertificateObjectReference (org.xwiki.crypto.store.wiki.internal.query.CertificateObjectReference)1 X509CertificateReferenceIssuerAndSerialQuery (org.xwiki.crypto.store.wiki.internal.query.X509CertificateReferenceIssuerAndSerialQuery)1 X509CertificateReferenceKeyIdentifierQuery (org.xwiki.crypto.store.wiki.internal.query.X509CertificateReferenceKeyIdentifierQuery)1