1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.crypto.script; |
21 |
|
|
22 |
|
import java.io.File; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Named; |
26 |
|
import javax.inject.Singleton; |
27 |
|
|
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.crypto.store.CertificateStore; |
30 |
|
import org.xwiki.crypto.store.FileStoreReference; |
31 |
|
import org.xwiki.crypto.store.KeyStore; |
32 |
|
import org.xwiki.crypto.store.StoreReference; |
33 |
|
import org.xwiki.crypto.store.WikiStoreReference; |
34 |
|
import org.xwiki.environment.Environment; |
35 |
|
import org.xwiki.model.reference.DocumentReference; |
36 |
|
import org.xwiki.model.reference.SpaceReference; |
37 |
|
import org.xwiki.script.service.ScriptService; |
38 |
|
import org.xwiki.security.authorization.ContextualAuthorizationManager; |
39 |
|
import org.xwiki.stability.Unstable; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@version |
45 |
|
@since |
46 |
|
|
47 |
|
@Component |
48 |
|
@Named(CryptoScriptService.ROLEHINT + '.' + StoreScriptService.ROLEHINT) |
49 |
|
@Singleton |
50 |
|
@Unstable |
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 8 |
Complexity Density: 0.73 |
|
51 |
|
public class StoreScriptService implements ScriptService |
52 |
|
{ |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
public static final String ROLEHINT = "store"; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
@Inject |
62 |
|
private Environment environment; |
63 |
|
|
64 |
|
@Inject |
65 |
|
@Named("X509file") |
66 |
|
private KeyStore x509FileKeyStore; |
67 |
|
|
68 |
|
@Inject |
69 |
|
@Named("X509wiki") |
70 |
|
private KeyStore x509WikiKeyStore; |
71 |
|
|
72 |
|
@Inject |
73 |
|
@Named("X509wiki") |
74 |
|
private CertificateStore x509WikiCertificateStore; |
75 |
|
|
76 |
|
@Inject |
77 |
|
private ContextualAuthorizationManager contextualAuthorizationManager; |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
79 |
0 |
private StoreReference getFileStoreReference(String filename, boolean multi)... |
80 |
|
{ |
81 |
0 |
File file; |
82 |
|
|
83 |
0 |
if (!filename.startsWith("/")) { |
84 |
0 |
file = new File(environment.getPermanentDirectory(), filename); |
85 |
|
} else { |
86 |
0 |
file = new File(filename); |
87 |
|
} |
88 |
0 |
return new FileStoreReference(file, multi); |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
@param |
95 |
|
|
96 |
|
@return |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
0 |
public ScriptingKeyStore getX509FileKeyStore(String filename)... |
99 |
|
{ |
100 |
0 |
return new ScriptingKeyStore(x509FileKeyStore, getFileStoreReference(filename, true), |
101 |
|
contextualAuthorizationManager); |
102 |
|
} |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
@param |
108 |
|
|
109 |
|
@return |
110 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
111 |
0 |
public ScriptingKeyStore getX509FileSingleKeyStore(String filename)... |
112 |
|
{ |
113 |
0 |
return new ScriptingKeyStore(x509FileKeyStore, getFileStoreReference(filename, false), |
114 |
|
contextualAuthorizationManager); |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
@param |
121 |
|
@return |
122 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
123 |
0 |
public ScriptingKeyStore getX509SpaceKeyStore(SpaceReference reference)... |
124 |
|
{ |
125 |
0 |
return new ScriptingKeyStore(x509WikiKeyStore, new WikiStoreReference(reference), |
126 |
|
contextualAuthorizationManager); |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
@param |
133 |
|
@return |
134 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
0 |
public ScriptingKeyStore getX509DocumentKeyStore(DocumentReference reference)... |
136 |
|
{ |
137 |
0 |
return new ScriptingKeyStore(x509WikiKeyStore, new WikiStoreReference(reference), |
138 |
|
contextualAuthorizationManager); |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
@param |
145 |
|
@return |
146 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
147 |
0 |
public ScriptingCertificateStore getX509SpaceCertificateStore(SpaceReference reference)... |
148 |
|
{ |
149 |
0 |
return new ScriptingCertificateStore(x509WikiCertificateStore, new WikiStoreReference(reference), |
150 |
|
contextualAuthorizationManager); |
151 |
|
} |
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
@param |
157 |
|
@return |
158 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
159 |
0 |
public ScriptingCertificateStore getX509DocumentCertificateStore(DocumentReference reference)... |
160 |
|
{ |
161 |
0 |
return new ScriptingCertificateStore(x509WikiCertificateStore, new WikiStoreReference(reference), |
162 |
|
contextualAuthorizationManager); |
163 |
|
} |
164 |
|
} |