1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package org.xwiki.crypto.signer.internal.cms; |
22 |
|
|
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Collection; |
25 |
|
import java.util.Collections; |
26 |
|
|
27 |
|
import org.xwiki.crypto.pkix.params.CertifiedPublicKey; |
28 |
|
import org.xwiki.crypto.signer.param.CMSSignedDataVerified; |
29 |
|
import org.xwiki.crypto.signer.param.CMSSignerVerifiedInformation; |
30 |
|
|
31 |
|
|
32 |
|
@link |
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 91.7% |
Uncovered Elements: 2 (24) |
Complexity: 9 |
Complexity Density: 0.64 |
|
37 |
|
public class BcCMSSignedDataVerified implements CMSSignedDataVerified |
38 |
|
{ |
39 |
|
private final Collection<CMSSignerVerifiedInformation> signatures = new ArrayList<CMSSignerVerifiedInformation>(); |
40 |
|
|
41 |
|
private final Collection<CertifiedPublicKey> certificates = new ArrayList<CertifiedPublicKey>(); |
42 |
|
|
43 |
|
private final String contentType; |
44 |
|
|
45 |
|
private final byte[] content; |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
47 |
9 |
BcCMSSignedDataVerified(String contentType, byte[] content)... |
48 |
|
{ |
49 |
9 |
this.contentType = contentType; |
50 |
9 |
this.content = content; |
51 |
|
} |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
53 |
10 |
void addCertificate(CertifiedPublicKey certificate)... |
54 |
|
{ |
55 |
10 |
this.certificates.add(certificate); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
9 |
void addSignature(CMSSignerVerifiedInformation signature)... |
59 |
|
{ |
60 |
9 |
this.signatures.add(signature); |
61 |
|
} |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
15 |
@Override... |
64 |
|
public Collection<CMSSignerVerifiedInformation> getSignatures() |
65 |
|
{ |
66 |
15 |
return Collections.unmodifiableCollection(this.signatures); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
6 |
@Override... |
70 |
|
public Collection<CertifiedPublicKey> getCertificates() |
71 |
|
{ |
72 |
6 |
return Collections.unmodifiableCollection(this.certificates); |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
5 |
@Override... |
76 |
|
public String getContentType() |
77 |
|
{ |
78 |
5 |
return this.contentType; |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
5 |
@Override... |
82 |
|
public byte[] getContent() |
83 |
|
{ |
84 |
5 |
return this.content; |
85 |
|
} |
86 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
87 |
6 |
@Override... |
88 |
|
public boolean isVerified() |
89 |
|
{ |
90 |
6 |
boolean result = !this.signatures.isEmpty(); |
91 |
6 |
for (CMSSignerVerifiedInformation signature : this.signatures) { |
92 |
6 |
result &= signature.isVerified(); |
93 |
6 |
if (!result) { |
94 |
0 |
break; |
95 |
|
} |
96 |
|
} |
97 |
6 |
return result; |
98 |
|
} |
99 |
|
} |