1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.crypto.store.wiki.internal.query

File AbstractX509IssuerAndSerialQuery.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
2
2
1
86
31
2
1
1
2
1

Classes

Class Line # Actions
AbstractX509IssuerAndSerialQuery 40 2 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 10 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.crypto.store.wiki.internal.query;
21   
22    import java.math.BigInteger;
23    import java.util.List;
24   
25    import org.xwiki.crypto.BinaryStringEncoder;
26    import org.xwiki.crypto.pkix.params.PrincipalIndentifier;
27    import org.xwiki.crypto.store.CertificateStoreException;
28    import org.xwiki.crypto.store.wiki.internal.X509CertificateWikiStore;
29    import org.xwiki.model.reference.EntityReference;
30    import org.xwiki.model.reference.EntityReferenceSerializer;
31    import org.xwiki.query.QueryException;
32    import org.xwiki.query.QueryManager;
33   
34    /**
35    * Abstract class to build queries on CertificateClass in a certificate store based on issuer and serial number.
36    *
37    * @version $Id: f3c69e32b79d2d4743641ccabbcb8fd4c410f1f8 $
38    * @since 6.1M2
39    */
 
40    public abstract class AbstractX509IssuerAndSerialQuery extends AbstractX509StoreQuery
41    {
42    private static final String ISSUER = "issuer";
43   
44    private static final String SERIAL = "serial";
45   
46    private static final String AND_OBJ = " and obj.";
47   
48    private static final String EQUAL = "=:";
49   
50    private static final String WHERE_STATEMENT =
51    AND_OBJ + X509CertificateWikiStore.CERTIFICATECLASS_PROP_ISSUER + EQUAL + ISSUER
52    + AND_OBJ + X509CertificateWikiStore.CERTIFICATECLASS_PROP_SERIAL + EQUAL + SERIAL;
53   
54    /**
55    * Create a query.
56    *
57    * @param store the reference of a document or a space where the certificate should be stored.
58    * @param select the select statement specific to the query.
59    * @param from the additional from statement specific to the query.
60    * @param where the additional where statement specific to the query.
61    * @param encoder a string encoder/decoder used to convert byte arrays to/from String.
62    * @param queryManager the query manager used to build queries.
63    * @param serializer the entity reference serializer to serialize the store reference for query
64    * @throws CertificateStoreException on error creating required queries.
65    */
 
66  10 toggle public AbstractX509IssuerAndSerialQuery(EntityReference store, String select, String from, String where,
67    BinaryStringEncoder encoder, QueryManager queryManager, EntityReferenceSerializer<String> serializer)
68    throws CertificateStoreException
69    {
70  10 super(store, select, from, WHERE_STATEMENT + where, encoder, queryManager, serializer);
71    }
72   
73    /**
74    * Execute the query.
75    *
76    * @param issuer the issuer name.
77    * @param serial the serial number.
78    * @return the query result.
79    * @throws QueryException on query error.
80    */
 
81  6 toggle protected <T> List<T> execute(PrincipalIndentifier issuer, BigInteger serial) throws QueryException
82    {
83  6 return getQuery().bindValue(ISSUER, issuer.getName()).bindValue(SERIAL, serial.toString()).execute();
84    }
85   
86    }