1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.crypto.store.wiki.internal; |
21 |
|
|
22 |
|
import java.util.Collection; |
23 |
|
|
24 |
|
import javax.inject.Named; |
25 |
|
import javax.inject.Singleton; |
26 |
|
|
27 |
|
import org.xwiki.component.annotation.Component; |
28 |
|
import org.xwiki.crypto.pkix.CertificateProvider; |
29 |
|
import org.xwiki.crypto.pkix.params.CertifiedPublicKey; |
30 |
|
import org.xwiki.crypto.store.CertificateStore; |
31 |
|
import org.xwiki.crypto.store.CertificateStoreException; |
32 |
|
import org.xwiki.crypto.store.StoreReference; |
33 |
|
import org.xwiki.crypto.store.wiki.internal.query.X509CertificateQuery; |
34 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
35 |
|
|
36 |
|
import com.xpn.xwiki.XWikiContext; |
37 |
|
import com.xpn.xwiki.XWikiException; |
38 |
|
|
39 |
|
|
40 |
|
@link |
41 |
|
|
42 |
|
@version |
43 |
|
@since |
44 |
|
|
45 |
|
@Component |
46 |
|
@Named("X509wiki") |
47 |
|
@Singleton |
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 4 |
Complexity Density: 0.67 |
|
48 |
|
public class X509CertificateWikiStore extends AbstractX509WikiStore implements CertificateStore |
49 |
|
{ |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
public static final String CERTIFICATECLASS_SPACE = "Crypto"; |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
public static final String CERTIFICATECLASS_NAME = "CertificateClass"; |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
public static final String CERTIFICATECLASS_FULLNAME = CERTIFICATECLASS_SPACE + "." + CERTIFICATECLASS_NAME; |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
public static final LocalDocumentReference CERTIFICATECLASS = |
69 |
|
new LocalDocumentReference(CERTIFICATECLASS_SPACE, CERTIFICATECLASS_NAME); |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
public static final String CERTIFICATECLASS_PROP_ISSUER = "issuer"; |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
public static final String CERTIFICATECLASS_PROP_SERIAL = "serial"; |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
public static final String CERTIFICATECLASS_PROP_SUBJECT = "subject"; |
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
public static final String CERTIFICATECLASS_PROP_KEYID = "keyid"; |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
public static final String CERTIFICATECLASS_PROP_CERTIFICATE = "certificate"; |
95 |
|
|
96 |
|
|
97 |
|
@inheritDoc |
98 |
|
|
99 |
|
@param@link |
100 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
101 |
8 |
@Override... |
102 |
|
public void store(StoreReference store, CertifiedPublicKey certificate) throws CertificateStoreException |
103 |
|
{ |
104 |
8 |
XWikiContext context = getXWikiContext(); |
105 |
|
|
106 |
8 |
try { |
107 |
8 |
context.getWiki().saveDocument(storeCertificate(store, certificate, context), context); |
108 |
|
} catch (XWikiException e) { |
109 |
0 |
throw new CertificateStoreException("Error while saving certificate to store [" + store + "]", e); |
110 |
|
} |
111 |
|
} |
112 |
|
|
113 |
|
|
114 |
|
@inheritDoc |
115 |
|
|
116 |
|
@param@link |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
118 |
6 |
@Override... |
119 |
|
public CertificateProvider getCertificateProvider(StoreReference store) throws CertificateStoreException |
120 |
|
{ |
121 |
6 |
return new X509CertificateProvider(resolveStore(store), getCertificateFactory(), getEncoder(), |
122 |
|
getQueryManager(), getSerializer()); |
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
|
@inheritDoc |
127 |
|
|
128 |
|
@param@link |
129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
130 |
2 |
@Override... |
131 |
|
public Collection<CertifiedPublicKey> getAllCertificates(StoreReference store) throws CertificateStoreException |
132 |
|
{ |
133 |
2 |
return new X509CertificateQuery(resolveStore(store), getCertificateFactory(), getEncoder(), getQueryManager(), |
134 |
|
getSerializer()).getCertificates(); |
135 |
|
} |
136 |
|
} |