001: /*************************************************************************
002: * *
003: * EJBCA: The OpenSource Certificate Authority *
004: * *
005: * This software is free software; you can redistribute it and/or *
006: * modify it under the terms of the GNU Lesser General Public *
007: * License as published by the Free Software Foundation; either *
008: * version 2.1 of the License, or any later version. *
009: * *
010: * See terms of license at gnu.org. *
011: * *
012: *************************************************************************/package org.ejbca.core.model.ca.caadmin;
013:
014: import java.security.NoSuchProviderException;
015: import java.security.cert.CertificateException;
016: import java.security.cert.X509Certificate;
017: import java.util.ArrayList;
018: import java.util.Collection;
019: import java.util.Date;
020: import java.util.List;
021:
022: import org.ejbca.core.model.ca.catoken.CATokenInfo;
023: import org.ejbca.util.CertTools;
024: import org.ejbca.util.StringTools;
025:
026: /**
027: * Holds nonsensitive information about a X509CA.
028: *
029: * @version $Id: X509CAInfo.java,v 1.16 2008/01/24 16:10:26 anatom Exp $
030: */
031: public class X509CAInfo extends CAInfo {
032:
033: private List policies;
034: private boolean useauthoritykeyidentifier;
035: private boolean authoritykeyidentifiercritical;
036: private boolean usecrlnumber;
037: private boolean crlnumbercritical;
038: private String defaultcrldistpoint;
039: private String defaultcrlissuer;
040: private String defaultocsplocator;
041: private String cadefinedfreshestcrl;
042: private String subjectaltname;
043: private boolean useUTF8PolicyText;
044: private boolean usePrintableStringSubjectDN;
045: private boolean useLdapDNOrder;
046: private boolean useCrlDistributionPointOnCrl;
047: private boolean crlDistributionPointOnCrlCritical;
048:
049: /**
050: * Constructor that should be used when creating CA and retreiving CA info.
051: */
052: public X509CAInfo(String subjectdn, String name, int status,
053: Date updateTime, String subjectaltname,
054: int certificateprofileid, int validity, Date expiretime,
055: int catype, int signedby, Collection certificatechain,
056: CATokenInfo catokeninfo, String description,
057: int revokationreason, Date revokationdate, List policies,
058: int crlperiod, int crlIssueInterval, int crlOverlapTime,
059: int deltacrlperiod, Collection crlpublishers,
060: boolean useauthoritykeyidentifier,
061: boolean authoritykeyidentifiercritical,
062: boolean usecrlnumber, boolean crlnumbercritical,
063: String defaultcrldistpoint, String defaultcrlissuer,
064: String defaultocspservicelocator,
065: String cadefinedfreshestcrl, boolean finishuser,
066: Collection extendedcaserviceinfos,
067: boolean useUTF8PolicyText, Collection approvalSettings,
068: int numOfReqApprovals, boolean usePrintableStringSubjectDN,
069: boolean useLdapDnOrder,
070: boolean useCrlDistributionPointOnCrl,
071: boolean crlDistributionPointOnCrlCritical) {
072: this .subjectdn = StringTools.strip(CertTools
073: .stringToBCDNString(subjectdn));
074: this .caid = this .subjectdn.hashCode();
075: this .name = name;
076: this .status = status;
077: this .updatetime = updateTime;
078: this .validity = validity;
079: this .expiretime = expiretime;
080: this .catype = catype;
081: this .signedby = signedby;
082: // Due to a bug in Glassfish, we need to make sure all certificates in this
083: // Array i of SUNs own provider
084: try {
085: if (certificatechain != null) {
086: X509Certificate[] certs = (X509Certificate[]) certificatechain
087: .toArray(new X509Certificate[0]);
088: ArrayList list = CertTools.getCertCollectionFromArray(
089: certs, CertTools.SYSTEM_SECURITY_PROVIDER);
090: this .certificatechain = list;
091: } else {
092: this .certificatechain = null;
093: }
094: } catch (CertificateException e) {
095: throw new IllegalArgumentException(e);
096: } catch (NoSuchProviderException e) {
097: throw new IllegalArgumentException(e);
098: }
099: this .catokeninfo = catokeninfo;
100: this .description = description;
101: this .revokationreason = revokationreason;
102: this .revokationdate = revokationdate;
103: this .policies = policies;
104: this .crlperiod = crlperiod;
105: this .crlIssueInterval = crlIssueInterval;
106: this .crlOverlapTime = crlOverlapTime;
107: this .deltacrlperiod = deltacrlperiod;
108: this .crlpublishers = crlpublishers;
109: this .useauthoritykeyidentifier = useauthoritykeyidentifier;
110: this .authoritykeyidentifiercritical = authoritykeyidentifiercritical;
111: this .usecrlnumber = usecrlnumber;
112: this .crlnumbercritical = crlnumbercritical;
113: this .defaultcrldistpoint = defaultcrldistpoint;
114: this .defaultcrlissuer = defaultcrlissuer;
115: this .defaultocsplocator = defaultocspservicelocator;
116: this .cadefinedfreshestcrl = cadefinedfreshestcrl;
117: this .finishuser = finishuser;
118: this .subjectaltname = subjectaltname;
119: this .certificateprofileid = certificateprofileid;
120: this .extendedcaserviceinfos = extendedcaserviceinfos;
121: this .useUTF8PolicyText = useUTF8PolicyText;
122: this .approvalSettings = approvalSettings;
123: this .numOfReqApprovals = numOfReqApprovals;
124: this .usePrintableStringSubjectDN = usePrintableStringSubjectDN;
125: this .useLdapDNOrder = useLdapDnOrder;
126: this .useCrlDistributionPointOnCrl = useCrlDistributionPointOnCrl;
127: this .crlDistributionPointOnCrlCritical = crlDistributionPointOnCrlCritical;
128: }
129:
130: /**
131: * Constructor that should be used when updating CA data.
132: */
133: public X509CAInfo(int caid, int validity, CATokenInfo catokeninfo,
134: String description, int crlperiod, int crlIssueInterval,
135: int crlOverlapTime, int deltacrlperiod,
136: Collection crlpublishers,
137: boolean useauthoritykeyidentifier,
138: boolean authoritykeyidentifiercritical,
139: boolean usecrlnumber, boolean crlnumbercritical,
140: String defaultcrldistpoint, String defaultcrlissuer,
141: String defaultocspservicelocator,
142: String cadefinedfreshestcrl, boolean finishuser,
143: Collection extendedcaserviceinfos,
144: boolean useUTF8PolicyText, Collection approvalSettings,
145: int numOfReqApprovals, boolean usePrintableStringSubjectDN,
146: boolean useLdapDnOrder,
147: boolean useCrlDistributionPointOnCrl,
148: boolean crlDistributionPointOnCrlCritical) {
149: this .caid = caid;
150: this .validity = validity;
151: this .catokeninfo = catokeninfo;
152: this .description = description;
153: this .crlperiod = crlperiod;
154: this .crlIssueInterval = crlIssueInterval;
155: this .crlOverlapTime = crlOverlapTime;
156: this .deltacrlperiod = deltacrlperiod;
157: this .crlpublishers = crlpublishers;
158: this .useauthoritykeyidentifier = useauthoritykeyidentifier;
159: this .authoritykeyidentifiercritical = authoritykeyidentifiercritical;
160: this .usecrlnumber = usecrlnumber;
161: this .crlnumbercritical = crlnumbercritical;
162: this .defaultcrldistpoint = defaultcrldistpoint;
163: this .defaultcrlissuer = defaultcrlissuer;
164: this .defaultocsplocator = defaultocspservicelocator;
165: this .cadefinedfreshestcrl = cadefinedfreshestcrl;
166: this .finishuser = finishuser;
167: this .extendedcaserviceinfos = extendedcaserviceinfos;
168: this .useUTF8PolicyText = useUTF8PolicyText;
169: this .approvalSettings = approvalSettings;
170: this .numOfReqApprovals = numOfReqApprovals;
171: this .usePrintableStringSubjectDN = usePrintableStringSubjectDN;
172: this .useLdapDNOrder = useLdapDnOrder;
173: this .useCrlDistributionPointOnCrl = useCrlDistributionPointOnCrl;
174: this .crlDistributionPointOnCrlCritical = crlDistributionPointOnCrlCritical;
175: }
176:
177: public X509CAInfo() {
178: }
179:
180: public List getPolicies() {
181: return this .policies;
182: }
183:
184: public boolean getUseCRLNumber() {
185: return usecrlnumber;
186: }
187:
188: public void setUseCRLNumber(boolean usecrlnumber) {
189: this .usecrlnumber = usecrlnumber;
190: }
191:
192: public boolean getCRLNumberCritical() {
193: return crlnumbercritical;
194: }
195:
196: public void setCRLNumberCritical(boolean crlnumbercritical) {
197: this .crlnumbercritical = crlnumbercritical;
198: }
199:
200: public boolean getUseAuthorityKeyIdentifier() {
201: return useauthoritykeyidentifier;
202: }
203:
204: public void setUseAuthorityKeyIdentifier(
205: boolean useauthoritykeyidentifier) {
206: this .useauthoritykeyidentifier = useauthoritykeyidentifier;
207: }
208:
209: public boolean getAuthorityKeyIdentifierCritical() {
210: return authoritykeyidentifiercritical;
211: }
212:
213: public void setAuthorityKeyIdentifierCritical(
214: boolean authoritykeyidentifiercritical) {
215: this .authoritykeyidentifiercritical = authoritykeyidentifiercritical;
216: }
217:
218: public String getDefaultCRLDistPoint() {
219: return defaultcrldistpoint;
220: }
221:
222: public void setDefaultCRLDistPoint(String defaultCRLDistPoint) {
223: this .defaultcrldistpoint = defaultCRLDistPoint;
224: }
225:
226: public String getDefaultCRLIssuer() {
227: return defaultcrlissuer;
228: }
229:
230: public String getDefaultOCSPServiceLocator() {
231: return defaultocsplocator;
232: }
233:
234: public String getCADefinedFreshestCRL() {
235: return this .cadefinedfreshestcrl;
236: }
237:
238: public void setCADefinedFreshestCRL(String cADefinedFreshestCRL) {
239: this .cadefinedfreshestcrl = cADefinedFreshestCRL;
240: }
241:
242: public String getSubjectAltName() {
243: return subjectaltname;
244: }
245:
246: public boolean getUseUTF8PolicyText() {
247: return useUTF8PolicyText;
248: }
249:
250: public boolean getUsePrintableStringSubjectDN() {
251: return usePrintableStringSubjectDN;
252: }
253:
254: public boolean getUseLdapDnOrder() {
255: return useLdapDNOrder;
256: }
257:
258: public boolean getUseCrlDistributionPointOnCrl() {
259: return this .useCrlDistributionPointOnCrl;
260: }
261:
262: public void setUseCrlDistributionPointOnCrl(
263: boolean useCrlDistributionPointOnCrl) {
264: this .useCrlDistributionPointOnCrl = useCrlDistributionPointOnCrl;
265: }
266:
267: public boolean getCrlDistributionPointOnCrlCritical() {
268: return this.crlDistributionPointOnCrlCritical;
269: }
270:
271: }
|