1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.crypto.pkix; |
21 |
|
|
22 |
|
import java.io.FilterInputStream; |
23 |
|
import java.io.InputStream; |
24 |
|
import java.io.OutputStream; |
25 |
|
import java.security.GeneralSecurityException; |
26 |
|
|
27 |
|
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; |
28 |
|
import org.bouncycastle.operator.ContentSigner; |
29 |
|
import org.xwiki.crypto.pkix.internal.BcUtils; |
30 |
|
import org.xwiki.crypto.pkix.params.CertifiedKeyPair; |
31 |
|
import org.xwiki.crypto.pkix.params.CertifiedPublicKey; |
32 |
|
import org.xwiki.crypto.signer.Signer; |
33 |
|
import org.xwiki.crypto.signer.SignerFactory; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
|
|
| 43.6% |
Uncovered Elements: 22 (39) |
Complexity: 19 |
Complexity Density: 0.95 |
|
41 |
|
public final class CertifyingSigner implements Signer, ContentSigner |
42 |
|
{ |
43 |
|
private final CertifiedPublicKey certifier; |
44 |
|
|
45 |
|
private final Signer signer; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
@param |
51 |
|
@param |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
53 |
11 |
private CertifyingSigner(CertifiedPublicKey certifier, Signer signer)... |
54 |
|
{ |
55 |
11 |
this.certifier = certifier; |
56 |
11 |
this.signer = signer; |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
@param |
63 |
|
@param |
64 |
|
@param |
65 |
|
@return |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
11 |
public static CertifyingSigner getInstance(boolean forSigning, CertifiedKeyPair certifier, SignerFactory factory)... |
68 |
|
{ |
69 |
11 |
return new CertifyingSigner(certifier.getCertificate(), |
70 |
|
factory.getInstance(forSigning, certifier.getPrivateKey())); |
71 |
|
} |
72 |
|
|
73 |
|
|
74 |
|
@return |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
11 |
public CertifiedPublicKey getCertifier()... |
77 |
|
{ |
78 |
11 |
return this.certifier; |
79 |
|
} |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
0 |
@Override... |
82 |
|
public String getAlgorithmName() |
83 |
|
{ |
84 |
0 |
return this.signer.getAlgorithmName(); |
85 |
|
} |
86 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
87 |
4 |
@Override... |
88 |
|
public boolean isForSigning() |
89 |
|
{ |
90 |
4 |
return this.signer.isForSigning(); |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
93 |
0 |
@Override... |
94 |
|
public FilterInputStream getInputStream(InputStream is) |
95 |
|
{ |
96 |
0 |
return this.signer.getInputStream(is); |
97 |
|
} |
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
99 |
11 |
@Override... |
100 |
|
public OutputStream getOutputStream() |
101 |
|
{ |
102 |
11 |
return this.signer.getOutputStream(); |
103 |
|
} |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
0 |
@Override... |
106 |
|
public void update(byte input) |
107 |
|
{ |
108 |
0 |
this.signer.update(input); |
109 |
|
} |
110 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
111 |
0 |
@Override... |
112 |
|
public void update(byte[] input) |
113 |
|
{ |
114 |
0 |
this.signer.update(input); |
115 |
|
} |
116 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
117 |
0 |
@Override... |
118 |
|
public void update(byte[] input, int inputOffset, int inputLen) |
119 |
|
{ |
120 |
0 |
this.signer.update(input, inputOffset, inputLen); |
121 |
|
} |
122 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
123 |
4 |
@Override... |
124 |
|
public byte[] generate() throws GeneralSecurityException |
125 |
|
{ |
126 |
4 |
return this.signer.generate(); |
127 |
|
} |
128 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
129 |
0 |
@Override... |
130 |
|
public byte[] generate(byte[] input) throws GeneralSecurityException |
131 |
|
{ |
132 |
0 |
return this.signer.generate(input); |
133 |
|
} |
134 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
0 |
@Override... |
136 |
|
public byte[] generate(byte[] input, int inputOffset, int inputLen) throws GeneralSecurityException |
137 |
|
{ |
138 |
0 |
return this.signer.generate(input, inputOffset, inputLen); |
139 |
|
} |
140 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
0 |
@Override... |
142 |
|
public boolean verify(byte[] signature) throws GeneralSecurityException |
143 |
|
{ |
144 |
0 |
return this.signer.verify(signature); |
145 |
|
} |
146 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
147 |
0 |
@Override... |
148 |
|
public boolean verify(byte[] signature, byte[] input) throws GeneralSecurityException |
149 |
|
{ |
150 |
0 |
return this.signer.verify(signature, input); |
151 |
|
} |
152 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
153 |
0 |
@Override... |
154 |
|
public boolean verify(byte[] signature, int signOffset, int signLen, byte[] input, int inputOffset, int inputLen) |
155 |
|
throws GeneralSecurityException |
156 |
|
{ |
157 |
0 |
return this.signer.verify(signature, signOffset, signLen, input, inputOffset, inputLen); |
158 |
|
} |
159 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
160 |
0 |
@Override... |
161 |
|
public byte[] getEncoded() |
162 |
|
{ |
163 |
0 |
return this.signer.getEncoded(); |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
@inheritDoc |
170 |
|
|
171 |
|
@since |
172 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
173 |
25 |
@Override... |
174 |
|
public AlgorithmIdentifier getAlgorithmIdentifier() |
175 |
|
{ |
176 |
25 |
return BcUtils.getSignerAlgoritmIdentifier(this.signer); |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
@inheritDoc |
181 |
|
|
182 |
|
@since |
183 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
184 |
7 |
@Override... |
185 |
|
public byte[] getSignature() |
186 |
|
{ |
187 |
7 |
return ((ContentSigner) this.signer).getSignature(); |
188 |
|
} |
189 |
|
} |