KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > ejb > ca > caadmin > CertificateProfileDataBean


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.ejb.ca.caadmin;
15
16 import org.apache.log4j.Logger;
17 import org.ejbca.core.ejb.BaseEntityBean;
18 import org.ejbca.core.model.ca.certificateprofiles.CACertificateProfile;
19 import org.ejbca.core.model.ca.certificateprofiles.CertificateProfile;
20 import org.ejbca.core.model.ca.certificateprofiles.EndUserCertificateProfile;
21 import org.ejbca.core.model.ca.certificateprofiles.RootCACertificateProfile;
22
23
24 import javax.ejb.CreateException JavaDoc;
25 import java.util.HashMap JavaDoc;
26
27
28 /**
29  * Entity bean should not be used directly, use though Session beans. Entity Bean representing a
30  * certificate type in the ca web interface. Information stored:
31  * <pre>
32  * id (Primary key)
33  * CertificateProfile name
34  * CertificateProfile data
35  * </pre>
36  *
37  * @version $Id: CertificateProfileDataBean.java,v 1.4 2006/11/10 09:28:51 anatom Exp $
38  *
39  * @ejb.bean description="This enterprise bean entity represents a CRL with accompanying data"
40  * display-name="CertificateProfileDataEB"
41  * name="CertificateProfileData"
42  * jndi-name="CertificateProfileData"
43  * view-type="local"
44  * type="CMP"
45  * reentrant="False"
46  * cmp-version="2.x"
47  * transaction-type="Container"
48  * schema="CertificateProfileDataBean"
49  * primkey-field="id"
50  *
51  * @ejb.pk class="java.lang.Integer"
52  * generate="false"
53  *
54  * @ejb.persistence table-name = "CertificateProfileData"
55  *
56  * @ejb.home local-extends="javax.ejb.EJBLocalHome"
57  * local-class="org.ejbca.core.ejb.ca.store.CertificateProfileDataLocalHome"
58  *
59  * @ejb.interface local-extends="javax.ejb.EJBLocalObject"
60  * local-class="org.ejbca.core.ejb.ca.store.CertificateProfileDataLocal"
61  *
62  * @ejb.finder description="findByCertificateProfileName"
63  * signature="CRLDataLocal findByCertificateProfileName(java.lang.String name)"
64  * query="SELECT OBJECT(a) from CertificateProfileDataBean a WHERE a.certificateProfileName=?1"
65  *
66  * @ejb.finder description="findAll"
67  * signature="Collection findAll()"
68  * query="SELECT OBJECT(a) from CertificateProfileDataBean AS a"
69  *
70  * @ejb.transaction type="Required"
71  *
72  * @jonas.jdbc-mapping
73  * jndi-name="${datasource.jndi-name}"
74  */

75 public abstract class CertificateProfileDataBean extends BaseEntityBean {
76     private static final Logger log = Logger.getLogger(CertificateProfileDataBean.class);
77
78     /**
79      * @ejb.pk-field
80      * @ejb.persistence column-name="id"
81      * @ejb.interface-method
82      */

83     public abstract Integer JavaDoc getId();
84
85     /**
86      */

87     public abstract void setId(Integer JavaDoc id);
88
89     /**
90      * @ejb.persistence column-name="certificateProfileName"
91      * @ejb.interface-method
92      */

93     public abstract String JavaDoc getCertificateProfileName();
94
95     /**
96      * @ejb.interface-method
97      */

98     public abstract void setCertificateProfileName(String JavaDoc certificateprofilename);
99
100     /**
101      * @ejb.persistence column-name="data"
102      * @weblogic.ora.columntyp@
103      */

104     public abstract HashMap JavaDoc getData();
105
106     /**
107      */

108     public abstract void setData(HashMap JavaDoc data);
109
110     /**
111      * Method that returns the certificate profiles and updates it if nessesary.
112      *
113      * @ejb.interface-method
114      */

115     public CertificateProfile getCertificateProfile() {
116         CertificateProfile returnval = null;
117
118         switch (((Integer JavaDoc) (getData().get(CertificateProfile.TYPE))).intValue()) {
119             case CertificateProfile.TYPE_ROOTCA:
120                 returnval = new RootCACertificateProfile();
121
122                 break;
123             case CertificateProfile.TYPE_SUBCA:
124                 returnval = new CACertificateProfile();
125                 break;
126             case CertificateProfile.TYPE_ENDENTITY:
127             default :
128                 returnval = new EndUserCertificateProfile();
129         }
130
131         returnval.loadData(getData());
132
133         return returnval;
134     }
135
136     /**
137      * Method that saves the certificate profile to database.
138      *
139      * @ejb.interface-method
140      */

141     public void setCertificateProfile(CertificateProfile profile) {
142         setData((HashMap JavaDoc) profile.saveData());
143     }
144
145     //
146
// Fields required by Container
147
//
148

149     /**
150      * Entity Bean holding data of a raadmin profile.
151      *
152      * @param certificateprofilename DOCUMENT ME!
153      * @param certificateprofilename
154      * @param certificateprofile is the CertificateProfile.
155      * @ejb.create-method
156      */

157     public Integer JavaDoc ejbCreate(Integer JavaDoc id, String JavaDoc certificateprofilename,
158                              CertificateProfile certificateprofile) throws CreateException JavaDoc {
159         setId(id);
160         setCertificateProfileName(certificateprofilename);
161         setCertificateProfile(certificateprofile);
162         log.debug("Created certificateprofile " + certificateprofilename);
163
164         return id;
165     }
166
167     public void ejbPostCreate(Integer JavaDoc id, String JavaDoc certificateprofilename,
168                               CertificateProfile certificateprofile) {
169         // Do nothing. Required.
170
}
171 }
172
Popular Tags