summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cmscore/request/ARequestQueue.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/request/ARequestQueue.java')
-rw-r--r--pki/base/common/src/com/netscape/cmscore/request/ARequestQueue.java415
1 files changed, 221 insertions, 194 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/request/ARequestQueue.java b/pki/base/common/src/com/netscape/cmscore/request/ARequestQueue.java
index fbc5052de..2da14467e 100644
--- a/pki/base/common/src/com/netscape/cmscore/request/ARequestQueue.java
+++ b/pki/base/common/src/com/netscape/cmscore/request/ARequestQueue.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.request;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -61,29 +62,31 @@ import com.netscape.certsrv.request.PolicyResult;
import com.netscape.certsrv.request.RequestId;
import com.netscape.certsrv.request.RequestStatus;
+
/**
- * The ARequestQueue class is an abstract class that implements most portions of
- * the IRequestQueue interface. This includes the state engine as defined for
- * processing IRequest objects.
+ * The ARequestQueue class is an abstract class that implements
+ * most portions of the IRequestQueue interface. This includes
+ * the state engine as defined for processing IRequest objects.
* <p>
* !Put state machine description here!
* <p>
- * This class defines several abstract protected functions that need to be
- * defined by the concrete implementation. In particular, this class does not
- * implement the operations for storing requests persistantly.
+ * This class defines several abstract protected functions that
+ * need to be defined by the concrete implementation. In
+ * particular, this class does not implement the operations
+ * for storing requests persistantly.
* <p>
- * This class also provides several accessor functions for setting fields in the
- * IRequest object. These functions are provided as an aid to saving and
- * restoring the state in the database.
+ * This class also provides several accessor functions for setting
+ * fields in the IRequest object. These functions are provided
+ * as an aid to saving and restoring the state in the database.
* <p>
- * This class also implements the locking operations specified by the
- * IRequestQueue interface.
+ * This class also implements the locking operations specified by
+ * the IRequestQueue interface.
* <p>
- *
* @author thayes
* @version $Revision$ $Date$
*/
-public abstract class ARequestQueue implements IRequestQueue {
+public abstract class ARequestQueue
+ implements IRequestQueue {
/**
* global request version for tracking request changes.
@@ -93,34 +96,37 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Create a new (unique) RequestId. (abstract)
* <p>
- * This method must be implemented by the specialized class to generate a
- * new id from data in the persistant store. This id is used to create a new
- * request object.
+ * This method must be implemented by the specialized class to
+ * generate a new id from data in the persistant store. This id
+ * is used to create a new request object.
* <p>
- *
- * @return a new RequestId object.
- * @exception EBaseException indicates that creation of the new id could not
- * be completed.
+ * @return
+ * a new RequestId object.
+ * @exception EBaseException
+ * indicates that creation of the new id could not be completed.
* @see RequestId
*/
- protected abstract RequestId newRequestId() throws EBaseException;
+ protected abstract RequestId newRequestId()
+ throws EBaseException;
/**
* Read a request from the persistant store. (abstract)
* <p>
- * This function is called to create the in-memory version of a request
- * object.
+ * This function is called to create the in-memory version of
+ * a request object.
* <p>
- * The implementation of this object can use the createRequest member
- * function to create a new instance of an IRequest, and use the
- * setRequestStatus, setCreationTime and setModificationTime functions to
- * set those values.
+ * The implementation of this object can use the createRequest
+ * member function to create a new instance of an IRequest, and
+ * use the setRequestStatus, setCreationTime and setModificationTime
+ * functions to set those values.
* <p>
- *
- * @param id the id of the request to read.
- * @return a new IRequest object. null is returned if the object cannot be
- * located.
- * @exception EBaseException TODO: this is not implemented yet
+ * @param id
+ * the id of the request to read.
+ * @return
+ * a new IRequest object. null is returned if the object cannot
+ * be located.
+ * @exception EBaseException
+ * TODO: this is not implemented yet
* @see #createRequest
* @see #setRequestStatus
* @see #setModificationTime
@@ -131,51 +137,56 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Add the request to the store. (abstract)
* <p>
- * This function is called when a new request immediately after creating a
- * new request.
+ * This function is called when a new request immediately after
+ * creating a new request.
* <p>
- *
- * @param request the request to add.
- * @exception EBaseException TODO: this is not implemented yet
+ * @param request
+ * the request to add.
+ * @exception EBaseException
+ * TODO: this is not implemented yet
*/
protected abstract void addRequest(IRequest request) throws EBaseException;
/**
* Modify the request in the store. (abstract)
* <p>
- * Update the persistant copy of this request with the current values in the
- * object.
+ * Update the persistant copy of this request with the
+ * current values in the object.
* <p>
- * Currently there are no hints for what has changed, so the entire request
- * should be updated.
+ * Currently there are no hints for what has changed, so
+ * the entire request should be updated.
* <p>
- *
* @param request
- * @exception EBaseException TODO: this is not implemented yet
+ * @exception EBaseException
+ * TODO: this is not implemented yet
*/
protected abstract void modifyRequest(IRequest request);
/**
- * Get complete list of RequestId values found i this queue.
+ * Get complete list of RequestId values found i this
+ * queue.
* <p>
- * This method can form the basis for creating other types of search/list
- * operations (although there are probably more efficient ways of doing
- * this. ARequestQueue implements default versions of some of the searching
- * by using this method as a basis.
+ * This method can form the basis for creating other types
+ * of search/list operations (although there are probably more
+ * efficient ways of doing this. ARequestQueue implements
+ * default versions of some of the searching by using this
+ * method as a basis.
* <p>
- * TODO: return IRequestList -or- just use listRequests as the basic engine.
+ * TODO: return IRequestList -or- just use listRequests as
+ * the basic engine.
* <p>
- *
- * @return an Enumeration that generates RequestId objects.
+ * @return
+ * an Enumeration that generates RequestId objects.
*/
abstract protected Enumeration getRawList();
/**
* protected access for setting the current state of a request.
* <p>
- *
- * @param request The request to be modified.
- * @param status The new value for the request status.
+ * @param request
+ * The request to be modified.
+ * @param status
+ * The new value for the request status.
*/
protected final void setRequestStatus(IRequest request, RequestStatus status) {
Request r = (Request) request;
@@ -186,9 +197,10 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* protected access for setting the modification time of a request.
* <p>
- *
- * @param request The request to be modified.
- * @param date The new value for the time.
+ * @param request
+ * The request to be modified.
+ * @param date
+ * The new value for the time.
*/
protected final void setModificationTime(IRequest request, Date date) {
Request r = (Request) request;
@@ -199,9 +211,10 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* protected access for setting the creation time of a request.
* <p>
- *
- * @param request The request to be modified.
- * @param date The new value for the time.
+ * @param request
+ * The request to be modified.
+ * @param date
+ * The new value for the time.
*/
protected final void setCreationTime(IRequest request, Date date) {
Request r = (Request) request;
@@ -212,19 +225,20 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* protected access for creating a new Request object
* <p>
- *
- * @param id The identifier for the new request
- * @return A new request object. The caller should fill in other data values
- * from the datastore.
+ * @param id
+ * The identifier for the new request
+ * @return
+ * A new request object. The caller should fill in other data
+ * values from the datastore.
*/
protected final IRequest createRequest(RequestId id, String requestType) {
Request r;
/*
* Determine the specialized class to create for this type
- *
- * TODO: this set of classes is an example only. The real set needs to
- * be determined and implemented.
+ *
+ * TODO: this set of classes is an example only. The real set
+ * needs to be determined and implemented.
*/
if (requestType != null && requestType.equals("enrollment")) {
r = new EnrollmentRequest(id);
@@ -236,15 +250,14 @@ public abstract class ARequestQueue implements IRequestQueue {
}
/**
- * Implements IRequestQueue.newRequest
+ * Implements IRequestQueue.newRequest
* <p>
- *
* @see IRequestQueue#newRequest
*/
- public IRequest newRequest(String requestType) throws EBaseException {
+ public IRequest newRequest(String requestType)
+ throws EBaseException {
if (requestType == null) {
- throw new EBaseException(CMS.getUserMessage(
- "CMS_BASE_INVALID_REQUEST_TYPE", "null"));
+ throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_REQUEST_TYPE", "null"));
}
RequestId rId = newRequestId();
IRequest r = createRequest(rId, requestType);
@@ -274,17 +287,16 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Implements IRequestQueue.cloneRequest
* <p>
- *
* @see IRequestQueue#cloneRequest
*/
- public IRequest cloneRequest(IRequest r) throws EBaseException {
- // 1. check for valid state. (Are any invalid ?)
+ public IRequest cloneRequest(IRequest r)
+ throws EBaseException {
+ // 1. check for valid state. (Are any invalid ?)
RequestStatus rs = r.getRequestStatus();
- if (rs == RequestStatus.BEGIN)
- throw new EBaseException("Invalid Status");
+ if (rs == RequestStatus.BEGIN) throw new EBaseException("Invalid Status");
- // 2. create new request
+ // 2. create new request
String reqType = r.getRequestType();
IRequest clone = newRequest(reqType);
@@ -304,10 +316,10 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Implements IRequestQueue.findRequest
* <p>
- *
* @see IRequestQueue#findRequest
*/
- public IRequest findRequest(RequestId id) throws EBaseException {
+ public IRequest findRequest(RequestId id)
+ throws EBaseException {
IRequest r;
// mTable.lock(id);
@@ -315,12 +327,12 @@ public abstract class ARequestQueue implements IRequestQueue {
r = readRequest(id);
// if (r == null) mTable.unlock(id);
-
+
return r;
}
private IRequestScheduler mRequestScheduler = null;
-
+
public void setRequestScheduler(IRequestScheduler scheduler) {
mRequestScheduler = scheduler;
}
@@ -332,10 +344,10 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Implements IRequestQueue.processRequest
* <p>
- *
* @see IRequestQueue#processRequest
*/
- public final void processRequest(IRequest r) throws EBaseException {
+ public final void processRequest(IRequest r)
+ throws EBaseException {
// #610553 Thread Scheduler
IRequestScheduler scheduler = getRequestScheduler();
@@ -348,8 +360,7 @@ public abstract class ARequestQueue implements IRequestQueue {
// 1. Check for valid state
RequestStatus rs = r.getRequestStatus();
- if (rs != RequestStatus.BEGIN)
- throw new EBaseException("Invalid Status");
+ if (rs != RequestStatus.BEGIN) throw new EBaseException("Invalid Status");
stateEngine(r);
} finally {
@@ -362,20 +373,19 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Implements IRequestQueue.markRequestPending
* <p>
- *
* @see IRequestQueue#markRequestPending
*/
- public final void markRequestPending(IRequest r) throws EBaseException {
+ public final void markRequestPending(IRequest r)
+ throws EBaseException {
// 1. Check for valid state
RequestStatus rs = r.getRequestStatus();
- if (rs != RequestStatus.BEGIN)
- throw new EBaseException("Invalid Status");
+ if (rs != RequestStatus.BEGIN) throw new EBaseException("Invalid Status");
- // 2. Change the request state. This method of making
- // a request PENDING does NOT invoke the PENDING notifiers.
- // To change this, just call stateEngine at the completion of this
- // routine.
+ // 2. Change the request state. This method of making
+ // a request PENDING does NOT invoke the PENDING notifiers.
+ // To change this, just call stateEngine at the completion of this
+ // routine.
setRequestStatus(r, RequestStatus.PENDING);
updateRequest(r);
@@ -385,10 +395,10 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Implements IRequestQueue.cloneAndMarkPending
* <p>
- *
* @see IRequestQueue#cloneAndMarkPending
*/
- public IRequest cloneAndMarkPending(IRequest r) throws EBaseException {
+ public IRequest cloneAndMarkPending(IRequest r)
+ throws EBaseException {
IRequest clone = cloneRequest(r);
markRequestPending(clone);
@@ -398,18 +408,17 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Implements IRequestQueue.approveRequest
* <p>
- *
* @see IRequestQueue#approveRequest
*/
- public final void approveRequest(IRequest r) throws EBaseException {
+ public final void approveRequest(IRequest r)
+ throws EBaseException {
// 1. Check for valid state
RequestStatus rs = r.getRequestStatus();
- if (rs != RequestStatus.PENDING)
- throw new EBaseException("Invalid Status");
+ if (rs != RequestStatus.PENDING) throw new EBaseException("Invalid Status");
- AgentApprovals aas = AgentApprovals.fromStringVector(r
- .getExtDataInStringVector(AgentApprovals.class.getName()));
+ AgentApprovals aas = AgentApprovals.fromStringVector(
+ r.getExtDataInStringVector(AgentApprovals.class.getName()));
if (aas == null) {
aas = new AgentApprovals();
}
@@ -417,8 +426,7 @@ public abstract class ARequestQueue implements IRequestQueue {
// Record agent who did this
String agentName = getUserIdentity();
- if (agentName == null)
- throw new EBaseException("Missing agent information");
+ if (agentName == null) throw new EBaseException("Missing agent information");
aas.addApproval(agentName);
r.setExtData(AgentApprovals.class.getName(), aas.toStringVector());
@@ -427,7 +435,8 @@ public abstract class ARequestQueue implements IRequestQueue {
if (pr == PolicyResult.ACCEPTED) {
setRequestStatus(r, RequestStatus.APPROVED);
- } else if (pr == PolicyResult.DEFERRED || pr == PolicyResult.REJECTED) {
+ } else if (pr == PolicyResult.DEFERRED ||
+ pr == PolicyResult.REJECTED) {
}
// Always update. The policy code may have made changes to the
@@ -440,17 +449,16 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Implements IRequestQueue.rejectRequest
* <p>
- *
* @see IRequestQueue#rejectRequest
*/
- public final void rejectRequest(IRequest r) throws EBaseException {
+ public final void rejectRequest(IRequest r)
+ throws EBaseException {
// 1. Check for valid state
RequestStatus rs = r.getRequestStatus();
- if (rs != RequestStatus.PENDING)
- throw new EBaseException("Invalid Status");
+ if (rs != RequestStatus.PENDING) throw new EBaseException("Invalid Status");
- // 2. Change state
+ // 2. Change state
setRequestStatus(r, RequestStatus.REJECTED);
updateRequest(r);
@@ -461,10 +469,10 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Implments IRequestQueue.cancelRequest
* <p>
- *
* @see IRequestQueue#cancelRequest
*/
- public final void cancelRequest(IRequest r) throws EBaseException {
+ public final void cancelRequest(IRequest r)
+ throws EBaseException {
setRequestStatus(r, RequestStatus.CANCELED);
updateRequest(r);
@@ -480,8 +488,7 @@ public abstract class ARequestQueue implements IRequestQueue {
setRequestStatus(r, RequestStatus.COMPLETE);
updateRequest(r);
- if (mNotify != null)
- mNotify.notify(r);
+ if (mNotify != null) mNotify.notify(r);
return;
}
@@ -489,10 +496,10 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Implements IRequestQueue.listRequests
* <p>
- * Should be overridden by the specialized class if a more efficient method
- * is available for implementing this operation.
+ * Should be overridden by the specialized class if
+ * a more efficient method is available for implementing
+ * this operation.
* <P>
- *
* @see IRequestQueue#listRequests
*/
public IRequestList listRequests() {
@@ -502,10 +509,10 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Implements IRequestQueue.listRequestsByStatus
* <p>
- * Should be overridden by the specialized class if a more efficient method
- * is available for implementing this operation.
+ * Should be overridden by the specialized class if
+ * a more efficient method is available for implementing
+ * this operation.
* <P>
- *
* @see IRequestQueue#listRequestsByStatus
*/
public IRequestList listRequestsByStatus(RequestStatus s) {
@@ -515,7 +522,6 @@ public abstract class ARequestQueue implements IRequestQueue {
/**
* Implements IRequestQueue.releaseRequest
* <p>
- *
* @see IRequestQueue#releaseRequest
*/
public final void releaseRequest(IRequest request) {
@@ -527,17 +533,17 @@ public abstract class ARequestQueue implements IRequestQueue {
String name = getUserIdentity();
- if (name != null)
- r.setExtData(IRequest.UPDATED_BY, name);
+ if (name != null) r.setExtData(IRequest.UPDATED_BY, name);
- // TODO: use a state flag to determine whether to call
- // addRequest or modifyRequest (see newRequest as well)
+ // TODO: use a state flag to determine whether to call
+ // addRequest or modifyRequest (see newRequest as well)
modifyRequest(r);
}
// PRIVATE functions
- private final void stateEngine(IRequest r) throws EBaseException {
+ private final void stateEngine(IRequest r)
+ throws EBaseException {
boolean complete = false;
while (!complete) {
@@ -611,14 +617,14 @@ public abstract class ARequestQueue implements IRequestQueue {
// write the queue name and request id
// write who changed it
// write what change (which state change) was made
- // - new (processRequest)
- // - approve
- // - reject
+ // - new (processRequest)
+ // - approve
+ // - reject
// Ordering
- // - make change in memory
- // - log change and result
- // - update record
+ // - make change in memory
+ // - log change and result
+ // - update record
}
/**
@@ -637,15 +643,15 @@ public abstract class ARequestQueue implements IRequestQueue {
*/
public void recover() {
if (CMS.isRunningMode()) {
- RecoverThread t = new RecoverThread(this);
+ RecoverThread t = new RecoverThread(this);
- t.start();
+ t.start();
}
}
/**
- * recover from a crash. Resends all requests that are in the APPROVED
- * state.
+ * recover from a crash. Resends all requests that are in
+ * the APPROVED state.
*/
public void recoverWillBlock() {
// Get a list of all requests that are APPROVED
@@ -658,7 +664,7 @@ public abstract class ARequestQueue implements IRequestQueue {
try {
request = findRequest(rid);
- // if (request == null) log_error
+ //if (request == null) log_error
// Recheck the status - should be the same!!
if (request.getRequestStatus() == RequestStatus.APPROVED) {
@@ -678,7 +684,7 @@ public abstract class ARequestQueue implements IRequestQueue {
// Constructor
protected ARequestQueue(IPolicy policy, IService service, INotify notify,
- INotify pendingNotify) {
+ INotify pendingNotify) {
mPolicy = policy;
mService = service;
mNotify = notify;
@@ -698,29 +704,44 @@ public abstract class ARequestQueue implements IRequestQueue {
protected ILogger mLogger;
}
+
//
// Table of RequestId values that are currently in use by some thread.
// The fact that the request is in this table constitutes a lock
// on the value.
//
/*
- * class RequestIDTable { public synchronized void lock(RequestId id) { while
- * (true) { if (mHashtable.put(id, id) == null) break;
- *
- * try { wait(); } catch (InterruptedException e) { }; } }
- *
- * public synchronized void unlock(RequestId id) { mHashtable.remove(id);
- *
- * notifyAll(); }
- *
- * // instance variables Hashtable mHashtable = new Hashtable(); }
+ class RequestIDTable {
+ public synchronized void lock(RequestId id) {
+ while (true) {
+ if (mHashtable.put(id, id) == null)
+ break;
+
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ };
+ }
+ }
+
+ public synchronized void unlock(RequestId id) {
+ mHashtable.remove(id);
+
+ notifyAll();
+ }
+
+ // instance variables
+ Hashtable mHashtable = new Hashtable();
+ }
*/
+
//
-// Request - implementation of the IRequest interface. This
+// Request - implementation of the IRequest interface. This
// version is returned by ARequestQueue (and its derivatives)
//
-class Request implements IRequest {
+class Request
+ implements IRequest {
// IRequest.getRequestId
public RequestId getRequestId() {
return mRequestId;
@@ -812,9 +833,9 @@ class Request implements IRequest {
Enumeration e = req.getExtDataKeys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
- if (!key.equals(IRequest.ISSUED_CERTS)
- && !key.equals(IRequest.ERRORS)
- && !key.equals(IRequest.REMOTE_REQID)) {
+ if (!key.equals(IRequest.ISSUED_CERTS) &&
+ !key.equals(IRequest.ERRORS) &&
+ !key.equals(IRequest.REMOTE_REQID)) {
if (req.isSimpleExtDataValue(key)) {
setExtData(key, req.getExtDataInString(key));
} else {
@@ -826,14 +847,15 @@ class Request implements IRequest {
/**
* This function used to check that the keys obeyed LDAP attribute name
- * syntax rules. Keys are being encoded now, so it is changed to just filter
- * out null and empty string keys.
- *
- * @param key The key to check
- * @return false if invalid
+ * syntax rules. Keys are being encoded now, so it is changed to just
+ * filter out null and empty string keys.
+ *
+ * @param key The key to check
+ * @return false if invalid
*/
protected boolean isValidExtDataKey(String key) {
- return key != null && (!key.equals(""));
+ return key != null &&
+ (! key.equals(""));
}
protected boolean isValidExtDataHashtableValue(Hashtable hash) {
@@ -843,12 +865,13 @@ class Request implements IRequest {
Enumeration keys = hash.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
- if (!((key instanceof String) && isValidExtDataKey((String) key))) {
+ if (! ((key instanceof String) &&
+ isValidExtDataKey((String)key)) ) {
return false;
}
Object value = hash.get(key);
- if (!(value instanceof String)) {
+ if (! (value instanceof String)) {
return false;
}
}
@@ -857,7 +880,7 @@ class Request implements IRequest {
}
public boolean setExtData(String key, String value) {
- if (!isValidExtDataKey(key)) {
+ if (! isValidExtDataKey(key)) {
return false;
}
if (value == null) {
@@ -869,7 +892,7 @@ class Request implements IRequest {
}
public boolean setExtData(String key, Hashtable value) {
- if (!(isValidExtDataKey(key) && isValidExtDataHashtableValue(value))) {
+ if ( !(isValidExtDataKey(key) && isValidExtDataHashtableValue(value)) ) {
return false;
}
@@ -886,10 +909,10 @@ class Request implements IRequest {
if (value == null) {
return null;
}
- if (!(value instanceof String)) {
+ if (! (value instanceof String)) {
return null;
}
- return (String) value;
+ return (String)value;
}
public Hashtable getExtDataInHashtable(String key) {
@@ -897,10 +920,10 @@ class Request implements IRequest {
if (value == null) {
return null;
}
- if (!(value instanceof Hashtable)) {
+ if (! (value instanceof Hashtable)) {
return null;
}
- return new ExtDataHashtable((Hashtable) value);
+ return new ExtDataHashtable((Hashtable)value);
}
public Enumeration getExtDataKeys() {
@@ -912,7 +935,7 @@ class Request implements IRequest {
}
public boolean setExtData(String key, String subkey, String value) {
- if (!(isValidExtDataKey(key) && isValidExtDataKey(subkey))) {
+ if (! (isValidExtDataKey(key) && isValidExtDataKey(subkey)) ) {
return false;
}
if (isSimpleExtDataValue(key)) {
@@ -922,7 +945,7 @@ class Request implements IRequest {
return false;
}
- Hashtable existingValue = (Hashtable) mExtData.get(key);
+ Hashtable existingValue = (Hashtable)mExtData.get(key);
if (existingValue == null) {
existingValue = new ExtDataHashtable();
mExtData.put(key, existingValue);
@@ -936,7 +959,7 @@ class Request implements IRequest {
if (value == null) {
return null;
}
- return (String) value.get(subkey);
+ return (String)value.get(subkey);
}
public boolean setExtData(String key, Integer value) {
@@ -1099,8 +1122,7 @@ class Request implements IRequest {
X509CertImpl[] certArray = new X509CertImpl[stringArray.length];
for (int index = 0; index < stringArray.length; index++) {
try {
- certArray[index] = new X509CertImpl(
- CMS.AtoB(stringArray[index]));
+ certArray[index] = new X509CertImpl(CMS.AtoB(stringArray[index]));
} catch (CertificateException e) {
return null;
}
@@ -1154,8 +1176,7 @@ class Request implements IRequest {
X509CertInfo[] certArray = new X509CertInfo[stringArray.length];
for (int index = 0; index < stringArray.length; index++) {
try {
- certArray[index] = new X509CertInfo(
- CMS.AtoB(stringArray[index]));
+ certArray[index] = new X509CertInfo(CMS.AtoB(stringArray[index]));
} catch (CertificateException e) {
return null;
}
@@ -1186,8 +1207,7 @@ class Request implements IRequest {
RevokedCertImpl[] certArray = new RevokedCertImpl[stringArray.length];
for (int index = 0; index < stringArray.length; index++) {
try {
- certArray[index] = new RevokedCertImpl(
- CMS.AtoB(stringArray[index]));
+ certArray[index] = new RevokedCertImpl(CMS.AtoB(stringArray[index]));
} catch (CRLException e) {
return null;
} catch (X509ExtensionException e) {
@@ -1203,7 +1223,7 @@ class Request implements IRequest {
return false;
}
try {
- stringArray = (String[]) stringVector.toArray(new String[0]);
+ stringArray = (String[])stringVector.toArray(new String[0]);
} catch (ArrayStoreException e) {
return false;
}
@@ -1225,8 +1245,7 @@ class Request implements IRequest {
return val.equalsIgnoreCase("true") || val.equalsIgnoreCase("ON");
}
- public boolean getExtDataInBoolean(String prefix, String type,
- boolean defVal) {
+ public boolean getExtDataInBoolean(String prefix, String type, boolean defVal) {
String val = getExtDataInString(prefix, type);
if (val == null)
return defVal;
@@ -1319,7 +1338,8 @@ class Request implements IRequest {
try {
// You must use DerInputStream
// using ByteArrayInputStream fails
- name = new CertificateSubjectName(new DerInputStream(nameData));
+ name = new CertificateSubjectName(
+ new DerInputStream(nameData));
} catch (IOException e) {
return null;
}
@@ -1354,7 +1374,7 @@ class Request implements IRequest {
Set arrayKeys = hashValue.keySet();
Vector listValue = new Vector(arrayKeys.size());
for (Iterator iter = arrayKeys.iterator(); iter.hasNext();) {
- String arrayKey = (String) iter.next();
+ String arrayKey = (String)iter.next();
try {
index = Integer.parseInt(arrayKey);
} catch (NumberFormatException e) {
@@ -1363,9 +1383,10 @@ class Request implements IRequest {
if (listValue.size() < (index + 1)) {
listValue.setSize(index + 1);
}
- listValue.set(index, hashValue.get(arrayKey));
+ listValue.set(index,
+ hashValue.get(arrayKey));
}
- return (String[]) listValue.toArray(new String[0]);
+ return (String[])listValue.toArray(new String[0]);
}
public IAttrSet asIAttrSet() {
@@ -1404,7 +1425,7 @@ class RequestIAttrSetWrapper implements IAttrSet {
public void set(String name, Object obj) throws EBaseException {
try {
- mRequest.setExtData(name, (String) obj);
+ mRequest.setExtData(name, (String)obj);
} catch (ClassCastException e) {
throw new EBaseException(e.toString());
}
@@ -1423,16 +1444,21 @@ class RequestIAttrSetWrapper implements IAttrSet {
}
}
+
/**
* Example of a specialized request class.
*/
-class EnrollmentRequest extends Request implements IEnrollmentRequest {
+class EnrollmentRequest
+ extends Request
+ implements IEnrollmentRequest {
EnrollmentRequest(RequestId id) {
super(id);
}
}
-class RequestListByStatus implements IRequestList {
+
+class RequestListByStatus
+ implements IRequestList {
public boolean hasMoreElements() {
return (mNext != null);
}
@@ -1475,16 +1501,14 @@ class RequestListByStatus implements IRequestList {
mNext = null;
while (mNext == null) {
- if (!mEnumeration.hasMoreElements())
- break;
-
+ if (!mEnumeration.hasMoreElements()) break;
+
rId = (RequestId) mEnumeration.nextElement();
try {
IRequest r = mQueue.findRequest(rId);
- if (r.getRequestStatus() == mStatus)
- mNext = rId;
+ if (r.getRequestStatus() == mStatus) mNext = rId;
mQueue.releaseRequest(r);
} catch (Exception e) {
@@ -1494,11 +1518,13 @@ class RequestListByStatus implements IRequestList {
protected RequestStatus mStatus;
protected IRequestQueue mQueue;
- protected Enumeration mEnumeration;
+ protected Enumeration mEnumeration;
protected RequestId mNext;
}
-class RequestList implements IRequestList {
+
+class RequestList
+ implements IRequestList {
public boolean hasMoreElements() {
return mEnumeration.hasMoreElements();
}
@@ -1523,9 +1549,10 @@ class RequestList implements IRequestList {
mEnumeration = e;
}
- protected Enumeration mEnumeration;
+ protected Enumeration mEnumeration;
}
+
class RecoverThread extends Thread {
private ARequestQueue mQ = null;