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

File BcX509v1TBSCertificateBuilder.java

 

Coverage histogram

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

Code metrics

0
15
8
1
97
61
8
0.53
1.88
8
1

Classes

Class Line # Actions
BcX509v1TBSCertificateBuilder 39 15 0% 8 0
1.0100%
 

Contributing tests

This file is covered by 2 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    package org.xwiki.crypto.pkix.internal;
21   
22    import java.math.BigInteger;
23    import java.util.Date;
24   
25    import org.bouncycastle.asn1.ASN1Integer;
26    import org.bouncycastle.asn1.x509.TBSCertificate;
27    import org.bouncycastle.asn1.x509.Time;
28    import org.bouncycastle.asn1.x509.V1TBSCertificateGenerator;
29    import org.xwiki.crypto.params.cipher.asymmetric.PublicKeyParameters;
30    import org.xwiki.crypto.pkix.params.PrincipalIndentifier;
31    import org.xwiki.crypto.signer.Signer;
32   
33    /**
34    * To Be Signed version 1 certificate builder.
35    *
36    * @version $Id: a726027135acc59bfae8d28a3af238ca7617e2d6 $
37    * @since 5.4
38    */
 
39    public class BcX509v1TBSCertificateBuilder implements BcX509TBSCertificateBuilder
40    {
41    private final V1TBSCertificateGenerator tbsGen = new V1TBSCertificateGenerator();
42   
 
43  3 toggle @Override
44    public BcX509TBSCertificateBuilder setSerialNumber(BigInteger serial)
45    {
46  3 this.tbsGen.setSerialNumber(new ASN1Integer(serial));
47  3 return this;
48    }
49   
 
50  3 toggle @Override
51    public BcX509TBSCertificateBuilder setSubjectPublicKeyInfo(PublicKeyParameters subject)
52    {
53  3 this.tbsGen.setSubjectPublicKeyInfo(BcUtils.getSubjectPublicKeyInfo(subject));
54  3 return this;
55    }
56   
 
57  3 toggle @Override
58    public BcX509TBSCertificateBuilder setIssuer(PrincipalIndentifier issuer)
59    {
60  3 this.tbsGen.setIssuer(BcUtils.getX500Name(issuer));
61  3 return this;
62    }
63   
 
64  3 toggle @Override
65    public BcX509TBSCertificateBuilder setSubject(PrincipalIndentifier subject)
66    {
67  3 this.tbsGen.setSubject(BcUtils.getX500Name(subject));
68  3 return this;
69    }
70   
 
71  3 toggle @Override
72    public BcX509TBSCertificateBuilder setStartDate(Date time)
73    {
74  3 this.tbsGen.setStartDate(new Time(time));
75  3 return this;
76    }
77   
 
78  3 toggle @Override
79    public BcX509TBSCertificateBuilder setEndDate(Date time)
80    {
81  3 this.tbsGen.setEndDate(new Time(time));
82  3 return this;
83    }
84   
 
85  3 toggle @Override
86    public BcX509TBSCertificateBuilder setSignature(Signer signer)
87    {
88  3 this.tbsGen.setSignature(BcUtils.getSignerAlgoritmIdentifier(signer));
89  3 return this;
90    }
91   
 
92  3 toggle @Override
93    public TBSCertificate build()
94    {
95  3 return this.tbsGen.generateTBSCertificate();
96    }
97    }