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.approval;
013:
014: import java.io.Serializable;
015: import java.util.Collection;
016: import java.util.Date;
017:
018: import org.ejbca.core.model.SecConst;
019:
020: /**
021: * Value Object containing all the information about an approval
022: * such as approvalid, approvaltype, endentityprofileid, caid,
023: * reqadmincertissuerdn, reqadmincertsn, status, approvals (Collection),
024: * requestdata, requestdate, expiredate, remainingapprovals
025: *
026: * @author Philip Vendil
027: * @version $Id: ApprovalDataVO.java,v 1.7 2008/02/26 15:37:12 herrvendil Exp $
028: */
029:
030: public class ApprovalDataVO implements Serializable {
031:
032: private static final long serialVersionUID = -1L;
033:
034: // Status constants
035: public static final int STATUS_WAITINGFORAPPROVAL = -1;
036: public static final int STATUS_APPROVED = 0;
037: public static final int STATUS_REJECTED = -2;
038: public static final int STATUS_EXPIRED = -3;
039: public static final int STATUS_EXPIREDANDNOTIFIED = -4; // Used to mark that the requestor havebee notified that the request havebeen expired.
040: public static final int STATUS_EXECUTED = -5;
041: public static final int STATUS_EXECUTIONFAILED = -6;
042: public static final int STATUS_EXECUTIONDENIED = -7;
043:
044: // Approval types
045:
046: public static final int APPROVALTYPE_DUMMY = 0;
047: public static final int APPROVALTYPE_VIEWHARDTOKENDATA = 1;
048: public static final int APPROVALTYPE_ADDENDENTITY = 2;
049: public static final int APPROVALTYPE_EDITENDENTITY = 3;
050: public static final int APPROVALTYPE_CHANGESTATUSENDENTITY = 4;
051: public static final int APPROVALTYPE_KEYRECOVERY = 5;
052: public static final int APPROVALTYPE_GENERATETOKEN = 6;
053: public static final int APPROVALTYPE_REVOKEENDENTITY = 7;
054: public static final int APPROVALTYPE_REVOKEANDDELETEENDENTITY = 8;
055: public static final int APPROVALTYPE_REVOKECERTIFICATE = 9;
056: public static final int APPROVALTYPE_ACTIVATECATOKEN = 10;
057:
058: //IMPORTANT REMEMBER TO SET THE RESOURCES IN BOTH INTERNAL AND ADMINWEB LANGUAGE FILES
059: public static final String[] APPROVALTYPENAMES = { "DUMMY",
060: "APVIEWHARDTOKENDATA", "APADDENDENTITY", "APEDITENDENTITY",
061: "APCHANGESTATUSENDENTITY", "APKEYRECOVERY",
062: "APGENERATETOKEN", "APREVOKEENDENTITY",
063: "APREVOKEDELETEENDENTITY", "APREVOKECERTIFICATE",
064: "APACTIVATECATOKEN" };
065:
066: /**
067: * Used to indicate that the approcal is applicable to any ca.
068: */
069: public static final int ANY_CA = SecConst.ALLCAS;
070:
071: /**
072: * Used to indicate that the approcal is applicable to any end entity profile.
073: */
074: public static final int ANY_ENDENTITYPROFILE = SecConst.PROFILE_NO_PROFILE;
075:
076: private int id = 0;
077: private int approvalId = 0;
078: private int approvalType = 0;
079: private int endEntityProfileiId = 0;
080: private int cAId = 0;
081: private String reqadmincertissuerdn = null;
082: private String reqadmincertsn = null;
083: private int status = 0;
084: private Collection approvals = null;
085: private ApprovalRequest approvalRequest = null;
086: private Date requestDate = null;
087: private Date expireDate = null;
088: private int remainingApprovals = 0;
089:
090: /**
091: * @param id unique row id
092: * @param approvalId Constructed from action data as actiontype, admin, username etc. It should
093: * result in the same approvalid if the admin tries to request the same action twice.
094: * @param approvalType Type of action that should be approved, should be one of ApprovalDataVO.APPROVALTYPE_
095: * constants ex: ApprovalDataVO.APPROVALTYPE_VIEWHARDTOKENDATA
096: * @param endEntityProfileiId For RA specific approval requests should the related end entity profile id be specified
097: * for non ra request should this field be set to ApprovalDataVO.ANY_ENDENTITYPROFILE
098: * @param cAId For CA specific approval requests should the related ca id be specified
099: * for non ca request should this field be set to ApprovalDataVO.ANY_CA
100: * @param reqadmincertissuerdn The issuerdn of the administrator certificate that generated the request.
101: * @param reqadmincertsn The serialnumber of the administrator certificate that generated the request. String in Hex
102: * @param status Should be one of ApprovalDataVO.STATUS_ constants
103: * @param approvals Collection of created Approvals (never null)
104: * @param approvalRequest The ApprovalRequest
105: * @param requestDate Date the request for approval were added
106: * @param expireDate Date the request for action or the approvel action will expire, Long.MAX_VALUE
107: * means that the request/approval never expires
108: * @param remainingApprovals Indicates the number of approvals that remains in order to execute the action.
109: */
110: public ApprovalDataVO(int id, int approvalId, int approvalType,
111: int endEntityProfileiId, int cAId,
112: String reqadmincertissuerdn, String reqadmincertsn,
113: int status, Collection approvals,
114: ApprovalRequest approvalRequest, Date requestDate,
115: Date expireDate, int remainingApprovals) {
116: super ();
117: this .id = id;
118: this .approvalId = approvalId;
119: this .approvalType = approvalType;
120: this .endEntityProfileiId = endEntityProfileiId;
121: this .cAId = cAId;
122: this .reqadmincertissuerdn = reqadmincertissuerdn;
123: this .reqadmincertsn = reqadmincertsn;
124: this .status = status;
125: this .approvals = approvals;
126: this .approvalRequest = approvalRequest;
127: this .requestDate = requestDate;
128: this .expireDate = expireDate;
129: this .remainingApprovals = remainingApprovals;
130: }
131:
132: /**
133: * Constructed from action data as actiontype, admin, username etc. It should
134: * result in the same approvalid if the admin tries to request the same action twice.
135: *
136: * @return Returns the approvalId.
137: */
138: public int getApprovalId() {
139: return approvalId;
140: }
141:
142: /**
143: * The ApprovalRequest
144: *
145: * @return Returns the approvalRequest.
146: */
147: public ApprovalRequest getApprovalRequest() {
148: return approvalRequest;
149: }
150:
151: /**
152: * Collection of created Approvals (never null)
153: *
154: * @return Returns the approvals.
155: */
156: public Collection getApprovals() {
157: return approvals;
158: }
159:
160: /**
161: * Type of action that should be approved, should be one of ApprovalDataVO.APPROVALTYPE_
162: * constants ex: ApprovalDataVO.APPROVALTYPE_VIEWHARDTOKENDATA
163: *
164: * @return Returns the approvalType.
165: */
166: public int getApprovalType() {
167: return approvalType;
168: }
169:
170: /**
171: * For CA specific approval requests should the related ca id be specified
172: * for non ca request should this field be set to ApprovalDataVO.ANY_CA
173: *
174: * @return Returns the cAId.
175: */
176: public int getCAId() {
177: return cAId;
178: }
179:
180: /**
181: * For RA specific approval requests should the related end entity profile id be specified
182: * for non ra request should this field be set to ApprovalDataVO.ANY_ENDENTITYPROFILE
183: *
184: * @return Returns the endEntityProfileiId.
185: */
186: public int getEndEntityProfileiId() {
187: return endEntityProfileiId;
188: }
189:
190: /**
191: * Date the request for action or the approvel action will expire, Long.MAX_VALUE
192: * means that the request/approval never expires
193: *
194: * @return Returns the expireDate.
195: */
196: public Date getExpireDate() {
197: return expireDate;
198: }
199:
200: /**
201: * @return Returns the id.
202: */
203: public int getId() {
204: return id;
205: }
206:
207: /**
208: * Indicates the number of approvals that remains in order to execute the action
209: * @return Returns the remainingApprovals.
210: */
211: public int getRemainingApprovals() {
212: return remainingApprovals;
213: }
214:
215: /**
216: * The issuerdn of the administrator certificate that generated the request.
217: *
218: * @return Returns the reqadmincertissuerdn.
219: */
220: public String getReqadmincertissuerdn() {
221: return reqadmincertissuerdn;
222: }
223:
224: /**
225: * The serialnumber of the administrator certificate that generated the request. String in Hex
226: *
227: * @return Returns the reqadmincertsn.
228: */
229: public String getReqadmincertsn() {
230: return reqadmincertsn;
231: }
232:
233: /**
234: * Date the request for approval were added
235: *
236: * @return Returns the requestDate.
237: */
238: public Date getRequestDate() {
239: return requestDate;
240: }
241:
242: /**
243: * Should be one of ApprovalDataVO.STATUS_ constants
244: *
245: * @return Returns the status.
246: */
247: public int getStatus() {
248: return status;
249: }
250:
251: }
|