View Javadoc
1   package org.codehaus.mojo.keytool.requests;
2   
3   /*
4    * Copyright 2005-2013 The Codehaus
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License" );
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.io.File;
20  import java.util.ArrayList;
21  import java.util.List;
22  
23  /**
24   * Request to do a Generate certificate from a certificate request using the KeyTool tool.
25   * <strong>Note:</strong> Such a request requires a jdk &gt;= 1.7.
26   *
27   * @author tchemit
28   * @since 1.1
29   */
30  public class KeyToolGenerateCertificateRequest
31      extends AbstractKeyToolRequestWithKeyStoreAndAliasParameters
32  {
33  
34      /**
35       * Key password.
36       * See <a href="http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/keytool.html#Commands">options</a>.
37       */
38      private String keypass;
39  
40      /**
41       * Output in RFC style.
42       * See <a href="http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/keytool.html#Commands">options</a>.
43       */
44      private boolean rfc;
45  
46      /**
47       * input file name.
48       * See <a href="http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/keytool.html#Commands">options</a>.
49       */
50      private File infile;
51  
52      /**
53       * output file name.
54       * See <a href="http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/keytool.html#Commands">options</a>.
55       */
56      private File outfile;
57  
58      /**
59       * Signature algorithm name.
60       * See <a href="http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/keytool.html#Commands">options</a>.
61       */
62      private String sigalg;
63  
64      /**
65       * Distinguished name.
66       * See <a href="http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/keytool.html#Commands">options</a>.
67       */
68      private String dname;
69  
70      /**
71       * Certificate validity start date/time.
72       * See <a href="http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/keytool.html#Commands">options</a>.
73       */
74      private String startdate;
75  
76      /**
77       * X.509 extension.
78       * See <a href="http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/keytool.html#Commands">options</a>.
79       */
80      private List<String> exts = new ArrayList<>();
81  
82      /**
83       * Validity number of days.
84       * See <a href="http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/keytool.html#Commands">options</a>.
85       */
86      private String validity;
87  
88      /**
89       * Gets the value of the {@link #rfc} field.
90       *
91       * @return the value of the {@link #rfc} field
92       */
93      public boolean isRfc()
94      {
95          return rfc;
96      }
97  
98      /**
99       * <p>Setter for the field <code>rfc</code>.</p>
100      *
101      * @param rfc value of the field {@link #rfc} to set
102      */
103     public void setRfc( boolean rfc )
104     {
105         this.rfc = rfc;
106     }
107 
108     /**
109      * Gets the value of the {@link #infile} field.
110      *
111      * @return the value of the {@link #infile} field
112      */
113     public File getInfile()
114     {
115         return infile;
116     }
117 
118     /**
119      * <p>Setter for the field <code>infile</code>.</p>
120      *
121      * @param infile value of the field {@link #infile} to set
122      */
123     public void setInfile( File infile )
124     {
125         this.infile = infile;
126     }
127 
128     /**
129      * Gets the value of the {@link #outfile} field.
130      *
131      * @return the value of the {@link #outfile} field
132      */
133     public File getOutfile()
134     {
135         return outfile;
136     }
137 
138     /**
139      * <p>Setter for the field <code>outfile</code>.</p>
140      *
141      * @param outfile value of the field {@link #outfile} to set
142      */
143     public void setOutfile( File outfile )
144     {
145         this.outfile = outfile;
146     }
147 
148     /**
149      * Gets the value of the {@link #sigalg} field.
150      *
151      * @return the value of the {@link #sigalg} field
152      */
153     public String getSigalg()
154     {
155         return sigalg;
156     }
157 
158     /**
159      * <p>Setter for the field <code>sigalg</code>.</p>
160      *
161      * @param sigalg value of the field {@link #sigalg} to set
162      */
163     public void setSigalg( String sigalg )
164     {
165         this.sigalg = sigalg;
166     }
167 
168     /**
169      * Gets the value of the {@link #dname} field.
170      *
171      * @return the value of the {@link #dname} field
172      */
173     public String getDname()
174     {
175         return dname;
176     }
177 
178     /**
179      * <p>Setter for the field <code>dname</code>.</p>
180      *
181      * @param dname value of the field {@link #dname} to set
182      */
183     public void setDname( String dname )
184     {
185         this.dname = dname;
186     }
187 
188     /**
189      * Gets the value of the {@link #startdate} field.
190      *
191      * @return the value of the {@link #startdate} field
192      */
193     public String getStartdate()
194     {
195         return startdate;
196     }
197 
198     /**
199      * <p>Setter for the field <code>startdate</code>.</p>
200      *
201      * @param startdate value of the field {@link #startdate} to set
202      */
203     public void setStartdate( String startdate )
204     {
205         this.startdate = startdate;
206     }
207 
208     /**
209      * Gets the value of the {@link #exts} field.
210      *
211      * @return the value of the {@link #exts} field
212      */
213     public String getExt()
214     {
215         return exts.isEmpty() ? null : exts.get(0);
216     }
217 
218     /**
219      * <p>setExt.</p>
220      *
221      * @param ext value of the field {@link #exts} to set
222      */
223     public void setExt( String ext )
224     {
225         exts.clear();
226 
227         if (ext != null)
228         {
229             exts.add(ext);
230         }
231     }
232 
233     /**
234      * <p>Setter for the field <code>exts</code>.</p>
235      *
236      * @param exts values of the field {@link #exts} to set
237      * @since 1.6
238      */
239     public void setExts( List<String> exts )
240     {
241         this.exts.clear();
242 
243         if (exts != null)
244         {
245             this.exts.addAll(exts);
246         }
247     }
248 
249     /**
250      * Gets the values of the {@link #exts} field.
251      *
252      * @return the values of the {@link #exts} field
253      * @since 1.6
254      */
255     public List<String> getExts()
256     {
257         return exts;
258     }
259 
260     /**
261      * Gets the value of the {@link #validity} field.
262      *
263      * @return the value of the {@link #validity} field
264      */
265     public String getValidity()
266     {
267         return validity;
268     }
269 
270     /**
271      * <p>Setter for the field <code>validity</code>.</p>
272      *
273      * @param validity value of the field {@link #validity} to set
274      */
275     public void setValidity( String validity )
276     {
277         this.validity = validity;
278     }
279 
280     /**
281      * Gets the value of the {@code keypass} field.
282      *
283      * @return the value of the {@code keypass} field.
284      */
285     public String getKeypass()
286     {
287         return keypass;
288     }
289 
290     /**
291      * Sets the new given value to the field {@code keypass} of the request.
292      *
293      * @param keypass the new value of the field {@code keypass}.
294      */
295     public void setKeypass( String keypass )
296     {
297         this.keypass = keypass;
298     }
299 }