KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > model > ca > certificateprofiles > EndUserCertificateProfile


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13  
14 package org.ejbca.core.model.ca.certificateprofiles;
15
16 import java.util.ArrayList JavaDoc;
17
18 /**
19  * EndUserCertificateProfile is a class defining the fixed characteristics of an enduser certificate type
20  *
21 * @version $Id: EndUserCertificateProfile.java,v 1.3 2006/05/28 14:21:08 anatom Exp $
22   */

23 public class EndUserCertificateProfile extends CertificateProfile{
24
25     // Public Constants
26

27     public static final String JavaDoc CERTIFICATEPROFILENAME = "ENDUSER";
28
29     // Public Methods
30
/** Creates a certificate with the characteristics of an end user.
31      * General options are set in the superclass's default contructor that is called automatically.
32      * You can override the general options by defining them again with different parameters here.
33      */

34     public EndUserCertificateProfile() {
35
36       setType(TYPE_ENDENTITY);
37
38       // Standard key usages for end users are: digitalSignature | keyEncipherment or nonRepudiation
39
// Default key usage is digitalSignature | keyEncipherment
40
// Create an array for KeyUsage acoording to X509Certificate.getKeyUsage()
41
setUseKeyUsage(true);
42       setKeyUsage(new boolean[9]);
43       setKeyUsage(DIGITALSIGNATURE,true);
44       setKeyUsage(KEYENCIPHERMENT,true);
45       setKeyUsageCritical(true);
46
47       setUseExtendedKeyUsage(true);
48       ArrayList JavaDoc eku = new ArrayList JavaDoc();
49       eku.add(new Integer JavaDoc(SERVERAUTH));
50       eku.add(new Integer JavaDoc(CLIENTAUTH));
51       eku.add(new Integer JavaDoc(EMAILPROTECTION));
52       eku.add(new Integer JavaDoc(IPSECENDSYSTEM));
53       eku.add(new Integer JavaDoc(IPSECUSER));
54       setExtendedKeyUsage(eku);
55       setExtendedKeyUsageCritical(false);
56       
57     }
58
59     // Public Methods.
60
public void upgrade(){
61         if(Float.compare(LATEST_VERSION, getVersion()) != 0) {
62             // New version of the class, upgrade
63
super.upgrade();
64         }
65     }
66
67
68     // Private fields.
69

70 }
71
Popular Tags