1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.crypto.store.wiki.internal.query

File AbstractX509SubjectQuery.java

 

Coverage histogram

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

Code metrics

0
2
2
1
77
26
2
1
1
2
1

Classes

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

Contributing tests

This file is covered by 6 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.util.List;
23   
24    import org.xwiki.crypto.BinaryStringEncoder;
25    import org.xwiki.crypto.pkix.params.PrincipalIndentifier;
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.
35    *
36    * @version $Id: 2cb2fc500b5bac28423a1148a5a4c773b1df7f44 $
37    * @since 6.1M2
38    */
 
39    public abstract class AbstractX509SubjectQuery extends AbstractX509StoreQuery
40    {
41    private static final String SUBJECT = "subject";
42   
43    private static final String WHERE_STATEMENT =
44    " and obj." + X509CertificateWikiStore.CERTIFICATECLASS_PROP_SUBJECT + "=:" + SUBJECT;
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  6 toggle public AbstractX509SubjectQuery(EntityReference store, String select, String from, String where,
59    BinaryStringEncoder encoder, QueryManager queryManager, EntityReferenceSerializer<String> serializer)
60    throws CertificateStoreException
61    {
62  6 super(store, select, from, WHERE_STATEMENT + where, encoder, queryManager, serializer);
63    }
64   
65    /**
66    * Execute the query.
67    *
68    * @param subject the subject name
69    * @return the query result.
70    * @throws QueryException on query error.
71    */
 
72  2 toggle protected <T> List<T> execute(PrincipalIndentifier subject) throws QueryException
73    {
74  2 return getQuery().bindValue(SUBJECT, subject.getName()).execute();
75    }
76   
77    }