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

File X509CertificateGenerationParameters.java

 

Coverage histogram

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

Code metrics

0
10
8
2
151
50
8
0.8
1.25
4
1

Classes

Class Line # Actions
X509CertificateGenerationParameters 31 10 0% 8 0
1.0100%
X509CertificateGenerationParameters.Version 36 0 - 0 0
-1.0 -
 

Contributing tests

This file is covered by 6 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.params.x509certificate;
21   
22    import org.xwiki.crypto.pkix.params.CertificateGenerationParameters;
23    import org.xwiki.crypto.pkix.params.x509certificate.extension.X509Extensions;
24   
25    /**
26    * X.509 common certificate parameters.
27    *
28    * @version $Id: 700762a5ce6c20700370aea5c7be3d23ba0612b8 $
29    * @since 5.4
30    */
 
31    public class X509CertificateGenerationParameters implements CertificateGenerationParameters
32    {
33    /**
34    * X.509 version.
35    */
 
36    public enum Version
37    {
38    /**
39    * Request a version 1 X.509 certificate.
40    */
41    V1,
42   
43    /**
44    * Request a version 2 X.509 certificate (actually unsupported).
45    */
46    V2,
47   
48    /**
49    * Request a version 3 X.509 certificate.
50    */
51    V3
52    }
53   
54    private static final int DEFAULT_VALIDITY = 500;
55   
56    private final Version version;
57   
58    private final int validity;
59   
60    private final X509Extensions extensions;
61   
62    /**
63    * Create a new instance with the default parameters.
64    *
65    * The default certificate version will be V1.
66    * The default validity will be 500 days.
67    */
 
68  3 toggle public X509CertificateGenerationParameters()
69    {
70  3 this(DEFAULT_VALIDITY);
71    }
72   
73    /**
74    * Create a new instance with the given arguments.
75    *
76    * The default certificate version will be V3.
77    * The default validity will be 500 days.
78    *
79    * @param extensions the common v3 certificate extensions for all certificate issued by a generator, or null for
80    * none.
81    */
 
82  7 toggle public X509CertificateGenerationParameters(X509Extensions extensions)
83    {
84  7 this(DEFAULT_VALIDITY, extensions);
85    }
86   
87    /**
88    * Create a new instance with the given arguments.
89    *
90    * The default certificate version will be V1.
91    *
92    * @param validity the validity period in days from the time of issuance.
93    */
 
94  3 toggle public X509CertificateGenerationParameters(int validity)
95    {
96  3 this(Version.V1, validity, null);
97    }
98   
99    /**
100    * Create a new instance with the given arguments.
101    *
102    * The default certificate version will be V3.
103    *
104    * @param validity the validity period in days from the time of issuance.
105    * @param extensions the common v3 certificate extensions for all certificate issued by a generator, or null for
106    * none.
107    */
 
108  7 toggle public X509CertificateGenerationParameters(int validity, X509Extensions extensions)
109    {
110  7 this(Version.V3, validity, extensions);
111    }
112   
113    /**
114    * Create a new instance with the given arguments.
115    *
116    * @param version the X.509 version of certificate to create.
117    * @param validity the validity period in days from the time of issuance.
118    * @param extensions the common v3 certificate extensions for all certificate issued by a generator, or null for
119    * none.
120    */
 
121  10 toggle public X509CertificateGenerationParameters(Version version, int validity, X509Extensions extensions)
122    {
123  10 this.version = version;
124  10 this.validity = validity;
125  10 this.extensions = extensions;
126    }
127   
128    /**
129    * @return the X.509 version of the certificate to generate.
130    */
 
131  10 toggle public Version getX509Version()
132    {
133  10 return this.version;
134    }
135   
136    /**
137    * @return the validity period in days from the time of issuance.
138    */
 
139  10 toggle public int getValidity()
140    {
141  10 return this.validity;
142    }
143   
144    /**
145    * @return the common v3 certificate extensions for all certificate issued by a generator, or null for none.
146    */
 
147  7 toggle public X509Extensions getExtensions()
148    {
149  7 return this.extensions;
150    }
151    }