1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.crypto.script

File ScriptingCertificateStore.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

0
8
4
1
91
38
4
0.5
2
4
1

Classes

Class Line # Actions
ScriptingCertificateStore 42 8 0% 4 12
0.00%
 

Contributing tests

No tests hitting this source file were found.

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.script;
21   
22    import java.util.Collection;
23   
24    import org.xwiki.crypto.pkix.CertificateProvider;
25    import org.xwiki.crypto.pkix.params.CertifiedPublicKey;
26    import org.xwiki.crypto.script.internal.AbstractScriptingStore;
27    import org.xwiki.crypto.store.CertificateStore;
28    import org.xwiki.crypto.store.CertificateStoreException;
29    import org.xwiki.crypto.store.StoreReference;
30    import org.xwiki.security.authorization.AccessDeniedException;
31    import org.xwiki.security.authorization.ContextualAuthorizationManager;
32    import org.xwiki.security.authorization.Right;
33    import org.xwiki.stability.Unstable;
34   
35    /**
36    * Wrapper over {@link CertificateStore} for scripting.
37    *
38    * @version $Id: f3c65462a4f6c62a27bd5fb3911b4909c1b5df16 $
39    * @since 8.4RC1
40    */
41    @Unstable
 
42    public class ScriptingCertificateStore extends AbstractScriptingStore
43    {
44    private CertificateStore store;
45   
 
46  0 toggle ScriptingCertificateStore(CertificateStore store, StoreReference reference,
47    ContextualAuthorizationManager contextualAuthorizationManager)
48    {
49  0 super(reference, contextualAuthorizationManager);
50  0 this.store = store;
51    }
52   
53    /**
54    * Store a certificate into a certificate store.
55    *
56    * @param certificate the certificate to store.
57    * @throws CertificateStoreException on error.
58    * @throws AccessDeniedException if you do not have edit access rights to the store.
59    */
 
60  0 toggle public void store(CertifiedPublicKey certificate) throws CertificateStoreException, AccessDeniedException
61    {
62  0 checkAccess(Right.EDIT);
63  0 store.store(storeReference, certificate);
64    }
65   
66    /**
67    * Return a certificate provider providing from the given certificate store.
68    *
69    * @return a certificate provider.
70    * @throws CertificateStoreException on error.
71    * @throws AccessDeniedException if you do not have edit access rights to the store.
72    */
 
73  0 toggle public CertificateProvider getCertificateProvider() throws CertificateStoreException, AccessDeniedException
74    {
75  0 checkAccess(Right.VIEW);
76  0 return store.getCertificateProvider(storeReference);
77    }
78   
79    /**
80    * Return all the certificates available in a certificate store.
81    *
82    * @return a collection of certificates.
83    * @throws CertificateStoreException on error.
84    * @throws AccessDeniedException if you do not have edit access rights to the store.
85    */
 
86  0 toggle public Collection<CertifiedPublicKey> getAllCertificates() throws CertificateStoreException, AccessDeniedException
87    {
88  0 checkAccess(Right.VIEW);
89  0 return store.getAllCertificates(storeReference);
90    }
91    }