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

File AbstractX509KeyIdentifierQuery.java

 

Coverage histogram

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

Code metrics

0
2
2
1
78
26
2
1
1
2
1

Classes

Class Line # Actions
AbstractX509KeyIdentifierQuery 39 2 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 20 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.io.IOException;
23    import java.util.List;
24   
25    import org.xwiki.crypto.BinaryStringEncoder;
26    import org.xwiki.crypto.store.CertificateStoreException;
27    import org.xwiki.crypto.store.wiki.internal.X509CertificateWikiStore;
28    import org.xwiki.model.reference.EntityReference;
29    import org.xwiki.model.reference.EntityReferenceSerializer;
30    import org.xwiki.query.QueryException;
31    import org.xwiki.query.QueryManager;
32   
33    /**
34    * Abstract class to build queries on CertificateClass in a certificate store based on subject key identifier.
35    *
36    * @version $Id: 9da8b529176ac5aca42777b1e333969e643920fe $
37    * @since 6.1M2
38    */
 
39    public abstract class AbstractX509KeyIdentifierQuery extends AbstractX509StoreQuery
40    {
41    private static final String KEYID = "keyid";
42   
43    private static final String WHERE_STATEMENT =
44    " and obj." + X509CertificateWikiStore.CERTIFICATECLASS_PROP_KEYID + "=:" + KEYID;
45   
46    /**
47    * Create a query.
48    *
49    * @param store the reference of a document or a space where the certificate should be stored.
50    * @param select the select statement specific to the query.
51    * @param from the additional from statement specific to the query.
52    * @param where the additional where statement specific to the query.
53    * @param encoder a string encoder/decoder used to convert byte arrays to/from String.
54    * @param queryManager the query manager used to build queries.
55    * @param serializer the entity reference serializer to serialize the store reference for query
56    * @throws CertificateStoreException on error creating required queries.
57    */
 
58  20 toggle public AbstractX509KeyIdentifierQuery(EntityReference store, String select, String from, String where,
59    BinaryStringEncoder encoder, QueryManager queryManager, EntityReferenceSerializer<String>serializer)
60    throws CertificateStoreException
61    {
62  20 super(store, select, from, WHERE_STATEMENT + where, encoder, queryManager, serializer);
63    }
64   
65    /**
66    * Execute the query.
67    *
68    * @param keyId the subject key identifier.
69    * @return the query result.
70    * @throws IOException on encoding error.
71    * @throws QueryException on query error.
72    */
 
73  16 toggle protected <T> List<T> execute(byte[] keyId) throws IOException, QueryException
74    {
75  16 return getQuery().bindValue(KEYID, getEncoder().encode(keyId)).execute();
76    }
77   
78    }