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

File BcCMSSignedDataVerified.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
14
8
1
99
59
9
0.64
1.75
8
1.12

Classes

Class Line # Actions
BcCMSSignedDataVerified 37 14 0% 9 2
0.916666791.7%
 

Contributing tests

This file is covered by 7 tests. .

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   
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    * Internal implementation of a {@link CMSSignedDataVerified}.
33    *
34    * @version $Id: a953826c11cc0c82766df2907dea649471e24f2f $
35    * @since 6.0M1
36    */
 
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   
 
47  9 toggle BcCMSSignedDataVerified(String contentType, byte[] content)
48    {
49  9 this.contentType = contentType;
50  9 this.content = content;
51    }
52   
 
53  10 toggle void addCertificate(CertifiedPublicKey certificate)
54    {
55  10 this.certificates.add(certificate);
56    }
57   
 
58  9 toggle void addSignature(CMSSignerVerifiedInformation signature)
59    {
60  9 this.signatures.add(signature);
61    }
62   
 
63  15 toggle @Override
64    public Collection<CMSSignerVerifiedInformation> getSignatures()
65    {
66  15 return Collections.unmodifiableCollection(this.signatures);
67    }
68   
 
69  6 toggle @Override
70    public Collection<CertifiedPublicKey> getCertificates()
71    {
72  6 return Collections.unmodifiableCollection(this.certificates);
73    }
74   
 
75  5 toggle @Override
76    public String getContentType()
77    {
78  5 return this.contentType;
79    }
80   
 
81  5 toggle @Override
82    public byte[] getContent()
83    {
84  5 return this.content;
85    }
86   
 
87  6 toggle @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    }