summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cmscore/connector
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2012-01-11 12:57:53 -0500
committerAde Lee <alee@redhat.com>2012-01-11 13:49:04 -0500
commit10cfe7756e967ac91c66d33b392aeab9cf3780fb (patch)
treed5ac9b58442265d2ce5ef60e31f041ddacba1b4f /pki/base/common/src/com/netscape/cmscore/connector
parentedcb24f65cc3700e75d0a1d14dc2483f210b0ee4 (diff)
downloadpki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.tar.gz
pki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.tar.xz
pki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.zip
Formatting (no line wrap in comments or code)
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/connector')
-rw-r--r--pki/base/common/src/com/netscape/cmscore/connector/HttpConnFactory.java152
-rw-r--r--pki/base/common/src/com/netscape/cmscore/connector/HttpConnection.java68
-rw-r--r--pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java49
-rw-r--r--pki/base/common/src/com/netscape/cmscore/connector/HttpPKIMessage.java86
-rw-r--r--pki/base/common/src/com/netscape/cmscore/connector/HttpRequestEncoder.java8
-rw-r--r--pki/base/common/src/com/netscape/cmscore/connector/LocalConnector.java45
-rw-r--r--pki/base/common/src/com/netscape/cmscore/connector/RemoteAuthority.java12
-rw-r--r--pki/base/common/src/com/netscape/cmscore/connector/RequestTransfer.java40
-rw-r--r--pki/base/common/src/com/netscape/cmscore/connector/Resender.java79
9 files changed, 257 insertions, 282 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/connector/HttpConnFactory.java b/pki/base/common/src/com/netscape/cmscore/connector/HttpConnFactory.java
index 5a607ee9d..12f8fe73f 100644
--- a/pki/base/common/src/com/netscape/cmscore/connector/HttpConnFactory.java
+++ b/pki/base/common/src/com/netscape/cmscore/connector/HttpConnFactory.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.connector;
-
import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.authority.IAuthority;
import com.netscape.certsrv.base.EBaseException;
@@ -28,7 +27,6 @@ import com.netscape.certsrv.logging.ILogger;
import com.netscape.cmsutil.http.JssSSLSocketFactory;
import com.netscape.cmsutil.net.ISocketFactory;
-
/**
* Factory for getting HTTP Connections to a HTTPO server
*/
@@ -38,14 +36,14 @@ public class HttpConnFactory {
private ILogger mLogger = CMS.getLogger();
- private int mNumConns = 0; // number of available conns in array
- private int mTotal = 0; // total num conns
+ private int mNumConns = 0; // number of available conns in array
+ private int mTotal = 0; // total num conns
private IHttpConnection mMasterConn = null; // master connection object.
private IHttpConnection mConns[];
private IAuthority mSource = null;
private IRemoteAuthority mDest = null;
private String mNickname = "";
- private int mTimeout = 0;
+ private int mTimeout = 0;
/**
* default value for the above at init time.
@@ -61,12 +59,12 @@ public class HttpConnFactory {
/**
* Constructor for HttpConnFactory
+ *
* @param minConns minimum number of connections to have available
- * @param maxConns max number of connections to have available. This is
+ * @param maxConns max number of connections to have available. This is
* @param serverInfo server connection info - host, port, etc.
*/
- public HttpConnFactory(int minConns, int maxConns, IAuthority source, IRemoteAuthority dest, String nickname, int timeout
- ) throws EBaseException {
+ public HttpConnFactory(int minConns, int maxConns, IAuthority source, IRemoteAuthority dest, String nickname, int timeout) throws EBaseException {
CMS.debug("In HttpConnFactory constructor mTimeout " + timeout);
mSource = source;
@@ -78,21 +76,22 @@ public class HttpConnFactory {
}
/**
- * initialize parameters obtained from either constructor or
+ * initialize parameters obtained from either constructor or
* config store
+ *
* @param minConns minimum number of connection handls to have available.
* @param maxConns maximum total number of connections to ever have.
* @param connInfo ldap connection info.
* @param authInfo ldap authentication info.
- * @exception ELdapException if any error occurs.
+ * @exception ELdapException if any error occurs.
*/
- private void init(int minConns, int maxConns
- )
- throws EBaseException {
+ private void init(int minConns, int maxConns
+ )
+ throws EBaseException {
CMS.debug("min conns " + minConns + " maxConns " + maxConns);
if (minConns <= 0 || maxConns <= 0 || minConns > maxConns) {
- CMS.debug("bad values from CMS.cfg");
+ CMS.debug("bad values from CMS.cfg");
} else {
@@ -109,8 +108,8 @@ public class HttpConnFactory {
CMS.debug("before makeConnection");
CMS.debug(
- "initializing HttpConnFactory with mininum " + mMinConns + " and maximum " + mMaxConns +
- " connections to ");
+ "initializing HttpConnFactory with mininum " + mMinConns + " and maximum " + mMaxConns +
+ " connections to ");
// initalize minimum number of connection handles available.
//makeMinimum();
@@ -126,21 +125,21 @@ public class HttpConnFactory {
try {
ISocketFactory tFactory = new JssSSLSocketFactory(mNickname);
-
+
if (mTimeout == 0) {
retConn = CMS.getHttpConnection(mDest, tFactory);
} else {
retConn = CMS.getHttpConnection(mDest, tFactory, mTimeout);
}
- } catch (Exception e) {
+ } catch (Exception e) {
CMS.debug("can't make new Htpp Connection");
throw new EBaseException(
- "Can't create new Http Connection");
+ "Can't create new Http Connection");
}
-
+
return retConn;
}
@@ -160,7 +159,7 @@ public class HttpConnFactory {
return;
CMS.debug(
- "increasing minimum connections by " + increment);
+ "increasing minimum connections by " + increment);
for (int i = increment - 1; i >= 0; i--) {
mConns[i] = (IHttpConnection) createConnection();
}
@@ -172,27 +171,26 @@ public class HttpConnFactory {
}
/**
- * gets a conenction from this factory.
- * All connections obtained from the factory must be returned by
+ * gets a conenction from this factory.
+ * All connections obtained from the factory must be returned by
* returnConn() method.
* The best thing to do is to put returnConn in a finally clause so it
- * always gets called. For example,
+ * always gets called. For example,
+ *
* <pre>
- * IHttpConnection c = null;
- * try {
- * c = factory.getConn();
- * myclass.do_something_with_c(c);
- * }
- * catch (EBaseException e) {
- * handle_error_here();
- * }
- * finally {
- * factory.returnConn(c);
- * }
+ * IHttpConnection c = null;
+ * try {
+ * c = factory.getConn();
+ * myclass.do_something_with_c(c);
+ * } catch (EBaseException e) {
+ * handle_error_here();
+ * } finally {
+ * factory.returnConn(c);
+ * }
* </pre>
*/
- public IHttpConnection getConn()
- throws EBaseException {
+ public IHttpConnection getConn()
+ throws EBaseException {
return getConn(true);
}
@@ -200,49 +198,47 @@ public class HttpConnFactory {
* Returns a Http connection - a clone of the master connection.
* All connections should be returned to the factory using returnConn()
* to recycle connection objects.
- * If not returned the limited max number is affected but if that
+ * If not returned the limited max number is affected but if that
* number is large not much harm is done.
* Returns null if maximum number of connections reached.
* The best thing to do is to put returnConn in a finally clause so it
- * always gets called. For example,
+ * always gets called. For example,
+ *
* <pre>
- * IHttpConnnection c = null;
- * try {
- * c = factory.getConn();
- * myclass.do_something_with_c(c);
- * }
- * catch (EBaseException e) {
- * handle_error_here();
- * }
- * finally {
- * factory.returnConn(c);
- * }
+ * IHttpConnnection c = null;
+ * try {
+ * c = factory.getConn();
+ * myclass.do_something_with_c(c);
+ * } catch (EBaseException e) {
+ * handle_error_here();
+ * } finally {
+ * factory.returnConn(c);
+ * }
* </pre>
- */
- public synchronized IHttpConnection getConn(boolean waitForConn)
- throws EBaseException {
+ */
+ public synchronized IHttpConnection getConn(boolean waitForConn)
+ throws EBaseException {
boolean waited = false;
CMS.debug("In HttpConnFactory.getConn");
- if (mNumConns == 0)
+ if (mNumConns == 0)
makeMinimum();
if (mNumConns == 0) {
if (!waitForConn)
return null;
try {
CMS.debug("getConn: out of http connections");
- log(ILogger.LL_WARN,
- "Ran out of http connections available "
- );
+ log(ILogger.LL_WARN,
+ "Ran out of http connections available ");
waited = true;
CMS.debug("HttpConn:about to wait for a new http connection");
- while (mNumConns == 0)
+ while (mNumConns == 0)
wait();
CMS.debug("HttpConn:done waiting for new http connection");
} catch (InterruptedException e) {
}
- }
+ }
mNumConns--;
IHttpConnection conn = mConns[mNumConns];
@@ -250,9 +246,8 @@ public class HttpConnFactory {
if (waited) {
CMS.debug("HttpConn:had to wait for an available connection from pool");
- log(ILogger.LL_WARN,
- "Http connections are available again in http connection pool "
- );
+ log(ILogger.LL_WARN,
+ "Http connections are available again in http connection pool ");
}
CMS.debug("HttpgetConn: mNumConns now " + mNumConns);
@@ -260,22 +255,21 @@ public class HttpConnFactory {
}
/**
- * Teturn connection to the factory.
+ * Teturn connection to the factory.
* This is mandatory after a getConn().
* The best thing to do is to put returnConn in a finally clause so it
- * always gets called. For example,
+ * always gets called. For example,
+ *
* <pre>
- * IHttpConnection c = null;
- * try {
- * c = factory.getConn();
- * myclass.do_something_with_c(c);
- * }
- * catch (EBaseException e) {
- * handle_error_here();
- * }
- * finally {
- * factory.returnConn(c);
- * }
+ * IHttpConnection c = null;
+ * try {
+ * c = factory.getConn();
+ * myclass.do_something_with_c(c);
+ * } catch (EBaseException e) {
+ * handle_error_here();
+ * } finally {
+ * factory.returnConn(c);
+ * }
* </pre>
*/
public synchronized void returnConn(IHttpConnection conn) {
@@ -289,7 +283,7 @@ public class HttpConnFactory {
for (int i = 0; i < mNumConns; i++) {
if (mConns[i] == conn) {
CMS.debug(
- "returnConn: previously returned connection. " + conn);
+ "returnConn: previously returned connection. " + conn);
}
}
@@ -303,11 +297,11 @@ public class HttpConnFactory {
*/
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "In Http (bound) connection pool to" +
- msg);
+ "In Http (bound) connection pool to" +
+ msg);
}
protected void finalize()
- throws Exception {
+ throws Exception {
}
}
diff --git a/pki/base/common/src/com/netscape/cmscore/connector/HttpConnection.java b/pki/base/common/src/com/netscape/cmscore/connector/HttpConnection.java
index e8b03542e..5b07f2c65 100644
--- a/pki/base/common/src/com/netscape/cmscore/connector/HttpConnection.java
+++ b/pki/base/common/src/com/netscape/cmscore/connector/HttpConnection.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.connector;
-
import java.io.IOException;
import java.util.StringTokenizer;
@@ -33,34 +32,32 @@ import com.netscape.cmsutil.http.HttpRequest;
import com.netscape.cmsutil.http.HttpResponse;
import com.netscape.cmsutil.net.ISocketFactory;
-
public class HttpConnection implements IHttpConnection {
protected IRemoteAuthority mDest = null;
protected HttpRequest mHttpreq = new HttpRequest();
protected IRequestEncoder mReqEncoder = null;
protected HttpClient mHttpClient = null;
- protected boolean Connect(String host, HttpClient client)
- {
- StringTokenizer st = new StringTokenizer(host, " ");
- while (st.hasMoreTokens()) {
- String hp = st.nextToken(); // host:port
- StringTokenizer st1 = new StringTokenizer(hp, ":");
- try {
- String h = st1.nextToken();
- int p = Integer.parseInt(st1.nextToken());
- client.connect(h, p);
- return true;
- } catch (Exception e) {
- // may want to log the failure
- }
- try {
- Thread.sleep(5000); // 5 seconds
- } catch (Exception e) {
- }
-
- }
- return false;
+ protected boolean Connect(String host, HttpClient client) {
+ StringTokenizer st = new StringTokenizer(host, " ");
+ while (st.hasMoreTokens()) {
+ String hp = st.nextToken(); // host:port
+ StringTokenizer st1 = new StringTokenizer(hp, ":");
+ try {
+ String h = st1.nextToken();
+ int p = Integer.parseInt(st1.nextToken());
+ client.connect(h, p);
+ return true;
+ } catch (Exception e) {
+ // may want to log the failure
+ }
+ try {
+ Thread.sleep(5000); // 5 seconds
+ } catch (Exception e) {
+ }
+
+ }
+ return false;
}
public HttpConnection(IRemoteAuthority dest, ISocketFactory factory) {
@@ -79,13 +76,13 @@ public class HttpConnection implements IHttpConnection {
// the format is, for example,
// "directory.knowledge.com:1050 people.catalog.com 199.254.1.2"
if (host != null && host.indexOf(' ') != -1) {
- // try to do client-side failover
- boolean connected = false;
- do {
- connected = Connect(host, mHttpClient);
- } while (!connected);
+ // try to do client-side failover
+ boolean connected = false;
+ do {
+ connected = Connect(host, mHttpClient);
+ } while (!connected);
} else {
- mHttpClient.connect(host, dest.getPort());
+ mHttpClient.connect(host, dest.getPort());
}
CMS.debug("HttpConnection: connected to " + dest.getHost() + ":" + dest.getPort());
} catch (IOException e) {
@@ -117,12 +114,13 @@ public class HttpConnection implements IHttpConnection {
}
// Insert end
- /**
+ /**
* sends a request to remote RA/CA, returning the result.
- * @throws EBaseException if request could not be encoded
+ *
+ * @throws EBaseException if request could not be encoded
*/
- public IPKIMessage send(IPKIMessage tomsg)
- throws EBaseException {
+ public IPKIMessage send(IPKIMessage tomsg)
+ throws EBaseException {
IPKIMessage replymsg = null;
CMS.debug("in HttpConnection.send " + this);
@@ -143,8 +141,8 @@ public class HttpConnection implements IHttpConnection {
}
boolean reconnect = false;
- mHttpreq.setHeader("Content-Length",
- Integer.toString(content.length()));
+ mHttpreq.setHeader("Content-Length",
+ Integer.toString(content.length()));
if (Debug.ON)
Debug.trace("request encoded length " + content.length());
mHttpreq.setContent(content);
diff --git a/pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java b/pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java
index fefbe0f31..1781e8fd9 100644
--- a/pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java
+++ b/pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.connector;
-
import java.util.Vector;
import com.netscape.certsrv.apps.CMS;
@@ -36,7 +35,6 @@ import com.netscape.certsrv.request.RequestStatus;
import com.netscape.cmsutil.http.JssSSLSocketFactory;
import com.netscape.cmsutil.net.ISocketFactory;
-
public class HttpConnector implements IConnector {
protected IAuthority mSource = null;
protected IRemoteAuthority mDest = null;
@@ -45,13 +43,14 @@ public class HttpConnector implements IConnector {
// XXX todo make this a pool.
// XXX use CMMF in the future.
protected IHttpConnection mConn = null;
- private Thread mResendThread = null;
+ private Thread mResendThread = null;
private IResender mResender = null;
private int mTimeout;
private HttpConnFactory mConnFactory = null;
+
public HttpConnector(IAuthority source, String nickName,
- IRemoteAuthority dest, int resendInterval, IConfigStore config) throws EBaseException {
+ IRemoteAuthority dest, int resendInterval, IConfigStore config) throws EBaseException {
mTimeout = 0;
mSource = source;
@@ -72,20 +71,20 @@ public class HttpConnector implements IConnector {
// mConn = CMS.getHttpConnection(dest, mFactory);
// this will start resending past requests in parallel.
- mResender = CMS.getResender(mSource, nickName, dest, resendInterval);
+ mResender = CMS.getResender(mSource, nickName, dest, resendInterval);
mResendThread = new Thread(mResender, "HttpConnector");
}
-
+
// Inserted by beomsuk
public HttpConnector(IAuthority source, String nickName,
- IRemoteAuthority dest, int resendInterval, IConfigStore config, int timeout) throws EBaseException {
+ IRemoteAuthority dest, int resendInterval, IConfigStore config, int timeout) throws EBaseException {
mSource = source;
mDest = dest;
mTimeout = timeout;
mFactory = new JssSSLSocketFactory(nickName);
int minConns = config.getInteger("minHttpConns", 1);
- int maxConns = config.getInteger("maxHttpConns", 15);
+ int maxConns = config.getInteger("maxHttpConns", 15);
CMS.debug("HttpConn: min " + minConns);
CMS.debug("HttpConn: max " + maxConns);
@@ -97,14 +96,14 @@ public class HttpConnector implements IConnector {
}
// this will start resending past requests in parallel.
- mResender = CMS.getResender(mSource, nickName, dest, resendInterval);
+ mResender = CMS.getResender(mSource, nickName, dest, resendInterval);
mResendThread = new Thread(mResender, "HttpConnector");
}
// Insert end
-
- public boolean send(IRequest r)
- throws EBaseException {
+
+ public boolean send(IRequest r)
+ throws EBaseException {
IHttpConnection curConn = null;
try {
@@ -144,31 +143,31 @@ public class HttpConnector implements IConnector {
// XXX hack: don't resend get revocation info requests since
// resent results are ignored.
if ((!r.getRequestType().equals(
- IRequest.GETREVOCATIONINFO_REQUEST)) &&
- (replyStatus == RequestStatus.BEGIN ||
- replyStatus == RequestStatus.PENDING ||
- replyStatus == RequestStatus.SVC_PENDING ||
+ IRequest.GETREVOCATIONINFO_REQUEST)) &&
+ (replyStatus == RequestStatus.BEGIN ||
+ replyStatus == RequestStatus.PENDING ||
+ replyStatus == RequestStatus.SVC_PENDING ||
replyStatus == RequestStatus.APPROVED)) {
CMS.debug("HttpConn: remote request id still pending " +
- r.getRequestId() + " state " + replyStatus);
+ r.getRequestId() + " state " + replyStatus);
mSource.log(ILogger.LL_INFO, CMS.getLogMessage("CMSCORE_CONNECTOR_REQUEST_NOT_COMPLETED", r.getRequestId().toString()));
mResender.addRequest(r);
return false;
}
// request was completed.
- replymsg.toRequest(r); // this only copies contents.
+ replymsg.toRequest(r); // this only copies contents.
// terminal states other than completed
- if (replyStatus == RequestStatus.REJECTED ||
- replyStatus == RequestStatus.CANCELED) {
+ if (replyStatus == RequestStatus.REJECTED ||
+ replyStatus == RequestStatus.CANCELED) {
CMS.debug(
- "remote request id " + r.getRequestId() +
- " was rejected or cancelled.");
+ "remote request id " + r.getRequestId() +
+ " was rejected or cancelled.");
r.setExtData(IRequest.REMOTE_STATUS, replyStatus.toString());
r.setExtData(IRequest.RESULT, IRequest.RES_ERROR);
r.setExtData(IRequest.ERROR,
- new EBaseException(CMS.getUserMessage("CMS_BASE_REMOTE_AUTHORITY_ERROR")));
+ new EBaseException(CMS.getUserMessage("CMS_BASE_REMOTE_AUTHORITY_ERROR")));
// XXX overload svcerrors for now.
Vector policyErrors = r.getExtDataInStringVector(IRequest.ERRORS);
@@ -178,11 +177,11 @@ public class HttpConnector implements IConnector {
}
CMS.debug(
- "remote request id " + r.getRequestId() + " was completed");
+ "remote request id " + r.getRequestId() + " was completed");
return true;
} catch (EBaseException e) {
CMS.debug("HttpConn: inside EBaseException " + e.toString());
-
+
if (!r.getRequestType().equals(IRequest.GETREVOCATIONINFO_REQUEST))
mResender.addRequest(r);
diff --git a/pki/base/common/src/com/netscape/cmscore/connector/HttpPKIMessage.java b/pki/base/common/src/com/netscape/cmscore/connector/HttpPKIMessage.java
index e236655d8..586f7f650 100644
--- a/pki/base/common/src/com/netscape/cmscore/connector/HttpPKIMessage.java
+++ b/pki/base/common/src/com/netscape/cmscore/connector/HttpPKIMessage.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.connector;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
@@ -32,9 +31,8 @@ import com.netscape.certsrv.connector.IHttpPKIMessage;
import com.netscape.certsrv.request.IRequest;
import com.netscape.cmscore.util.Debug;
-
/**
- * simple name/value pair message.
+ * simple name/value pair message.
*/
public class HttpPKIMessage implements IHttpPKIMessage {
/**
@@ -118,16 +116,16 @@ public class HttpPKIMessage implements IHttpPKIMessage {
r.setExtData(key, (Hashtable) value);
} else {
CMS.debug("HttpPKIMessage.toRequest(): key: " + key +
- " has unexpected type " + value.getClass().toString());
+ " has unexpected type " + value.getClass().toString());
}
} catch (NoSuchElementException e) {
- CMS.debug("Incorrect pairing of name/value for " + key);
+ CMS.debug("Incorrect pairing of name/value for " + key);
}
}
}
private void writeObject(java.io.ObjectOutputStream out)
- throws IOException {
+ throws IOException {
CMS.debug("writeObject");
out.writeObject(reqType);
if (Debug.ON)
@@ -145,34 +143,34 @@ public class HttpPKIMessage implements IHttpPKIMessage {
Object val = null;
key = enum1.nextElement();
try {
- val = enum1.nextElement();
- // test if key and value are serializable
- ObjectOutputStream os =
- new ObjectOutputStream(new ByteArrayOutputStream());
- os.writeObject(key);
- os.writeObject(val);
-
- // ok, if we dont have problem serializing the objects,
- // then write the objects into the real object stream
- out.writeObject(key);
- out.writeObject(val);
+ val = enum1.nextElement();
+ // test if key and value are serializable
+ ObjectOutputStream os =
+ new ObjectOutputStream(new ByteArrayOutputStream());
+ os.writeObject(key);
+ os.writeObject(val);
+
+ // ok, if we dont have problem serializing the objects,
+ // then write the objects into the real object stream
+ out.writeObject(key);
+ out.writeObject(val);
} catch (Exception e) {
- // skip not serialiable attribute in DRM
- // DRM does not need to store the enrollment request anymore
- CMS.debug("HttpPKIMessage:skipped key=" +
- key.getClass().getName());
- if (val == null) {
- CMS.debug("HttpPKIMessage:skipped val= null");
- } else {
- CMS.debug("HttpPKIMessage:skipped val=" +
- val.getClass().getName());
- }
+ // skip not serialiable attribute in DRM
+ // DRM does not need to store the enrollment request anymore
+ CMS.debug("HttpPKIMessage:skipped key=" +
+ key.getClass().getName());
+ if (val == null) {
+ CMS.debug("HttpPKIMessage:skipped val= null");
+ } else {
+ CMS.debug("HttpPKIMessage:skipped val=" +
+ val.getClass().getName());
+ }
}
}
}
private void readObject(java.io.ObjectInputStream in)
- throws IOException, ClassNotFoundException, OptionalDataException {
+ throws IOException, ClassNotFoundException, OptionalDataException {
reqType = (String) in.readObject();
reqId = (String) in.readObject();
reqStatus = (String) in.readObject();
@@ -185,21 +183,21 @@ public class HttpPKIMessage implements IHttpPKIMessage {
while (true) {
boolean skipped = false;
try {
- keyorval = in.readObject();
+ keyorval = in.readObject();
} catch (OptionalDataException e) {
- throw e;
+ throw e;
} catch (IOException e) {
- // just skipped parameter
- CMS.debug("skipped attribute in request e="+e);
- if (!iskey) {
- int s = mNameVals.size();
- if (s > 0) {
- // remove previous key if this is value
- mNameVals.removeElementAt(s - 1);
- skipped = true;
- keyorval = "";
- }
- }
+ // just skipped parameter
+ CMS.debug("skipped attribute in request e=" + e);
+ if (!iskey) {
+ int s = mNameVals.size();
+ if (s > 0) {
+ // remove previous key if this is value
+ mNameVals.removeElementAt(s - 1);
+ skipped = true;
+ keyorval = "";
+ }
+ }
}
if (iskey) {
if (Debug.ON)
@@ -213,9 +211,9 @@ public class HttpPKIMessage implements IHttpPKIMessage {
if (Debug.ON)
Debug.trace("read " + keyorval);
if (!skipped) {
- if (keyorval == null)
- break;
- mNameVals.addElement(keyorval);
+ if (keyorval == null)
+ break;
+ mNameVals.addElement(keyorval);
}
}
} catch (OptionalDataException e) {
diff --git a/pki/base/common/src/com/netscape/cmscore/connector/HttpRequestEncoder.java b/pki/base/common/src/com/netscape/cmscore/connector/HttpRequestEncoder.java
index 4a762dd8b..b76670946 100644
--- a/pki/base/common/src/com/netscape/cmscore/connector/HttpRequestEncoder.java
+++ b/pki/base/common/src/com/netscape/cmscore/connector/HttpRequestEncoder.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.connector;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -28,13 +27,12 @@ import java.io.OptionalDataException;
import com.netscape.certsrv.connector.IRequestEncoder;
import com.netscape.cmscore.util.Debug;
-
/**
- * encodes a request by serializing it.
+ * encodes a request by serializing it.
*/
public class HttpRequestEncoder implements IRequestEncoder {
public String encode(Object r)
- throws IOException {
+ throws IOException {
String s = null;
byte[] serial;
ByteArrayOutputStream ba = new ByteArrayOutputStream();
@@ -47,7 +45,7 @@ public class HttpRequestEncoder implements IRequestEncoder {
}
public Object decode(String s)
- throws IOException {
+ throws IOException {
Object result = null;
byte[] serial = null;
diff --git a/pki/base/common/src/com/netscape/cmscore/connector/LocalConnector.java b/pki/base/common/src/com/netscape/cmscore/connector/LocalConnector.java
index 9272cc93f..da639c0b1 100644
--- a/pki/base/common/src/com/netscape/cmscore/connector/LocalConnector.java
+++ b/pki/base/common/src/com/netscape/cmscore/connector/LocalConnector.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.connector;
-
import java.util.Hashtable;
import com.netscape.certsrv.apps.CMS;
@@ -36,7 +35,6 @@ import com.netscape.certsrv.request.RequestId;
import com.netscape.certsrv.request.RequestStatus;
import com.netscape.cmscore.util.Debug;
-
public class LocalConnector implements IConnector {
ILogger mLogger = CMS.getLogger();
ICertAuthority mSource = null;
@@ -49,7 +47,7 @@ public class LocalConnector implements IConnector {
// mSource.getId());
mDest = dest;
CMS.debug("Local connector setup for dest " +
- mDest.getId());
+ mDest.getId());
// register for events.
mDest.registerRequestListener(new LocalConnListener());
CMS.debug("Connector inited");
@@ -64,27 +62,27 @@ public class LocalConnector implements IConnector {
Debug.print("send request type " + r.getRequestType() + " status=" + r.getRequestStatus() + " to " + mDest.getId() + " id=" + r.getRequestId() + "\n");
}
CMS.debug("send request type " + r.getRequestType() +
- " to " + mDest.getId());
+ " to " + mDest.getId());
IRequestQueue destQ = mDest.getRequestQueue();
IRequest destreq = destQ.newRequest(r.getRequestType());
CMS.debug("local connector dest req " +
- destreq.getRequestId() + " created for source rId " + r.getRequestId());
+ destreq.getRequestId() + " created for source rId " + r.getRequestId());
// mSource.log(ILogger.LL_DEBUG,
// "setting connector dest " + mDest.getId() +
// " source id to " + r.getRequestId());
// XXX set context to the real identity later.
destreq.setSourceId(
- mSource.getX500Name().toString() + ":" + r.getRequestId().toString());
+ mSource.getX500Name().toString() + ":" + r.getRequestId().toString());
//destreq.copyContents(r); // copy meta attributes in request.
transferRequest(r, destreq);
// XXX requestor type is not transferred on return.
destreq.setExtData(IRequest.REQUESTOR_TYPE,
- IRequest.REQUESTOR_RA);
+ IRequest.REQUESTOR_RA);
CMS.debug("connector dest " + mDest.getId() +
- " processing " + destreq.getRequestId());
+ " processing " + destreq.getRequestId());
// set context before calling process request so
// that request subsystem can record the creator
@@ -111,8 +109,8 @@ public class LocalConnector implements IConnector {
}
CMS.debug("connector dest " + mDest.getId() +
- " processed " + destreq.getRequestId() +
- " status " + destreq.getRequestStatus());
+ " processed " + destreq.getRequestId() +
+ " status " + destreq.getRequestStatus());
if (destreq.getRequestStatus() == RequestStatus.COMPLETE) {
// no need to transfer contents if request wasn't complete.
@@ -126,7 +124,7 @@ public class LocalConnector implements IConnector {
public class LocalConnListener implements IRequestListener {
public void init(ISubsystem sys, IConfigStore config)
- throws EBaseException {
+ throws EBaseException {
}
public void set(String name, String val) {
@@ -136,8 +134,8 @@ public class LocalConnector implements IConnector {
if (Debug.ON) {
Debug.print("dest " + mDest.getId() + " done with " + destreq.getRequestId());
}
- CMS.debug(
- "dest " + mDest.getId() + " done with " + destreq.getRequestId());
+ CMS.debug(
+ "dest " + mDest.getId() + " done with " + destreq.getRequestId());
IRequestQueue sourceQ = mSource.getRequestQueue();
// accept requests that only belong to us.
@@ -146,19 +144,19 @@ public class LocalConnector implements IConnector {
String sourceNameAndId = destreq.getSourceId();
String sourceName = mSource.getX500Name().toString();
- if (sourceNameAndId == null ||
- !sourceNameAndId.toString().regionMatches(0,
- sourceName, 0, sourceName.length())) {
+ if (sourceNameAndId == null ||
+ !sourceNameAndId.toString().regionMatches(0,
+ sourceName, 0, sourceName.length())) {
CMS.debug("request " + destreq.getRequestId() +
- " from " + sourceNameAndId + " not ours.");
+ " from " + sourceNameAndId + " not ours.");
return;
}
int index = sourceNameAndId.lastIndexOf(':');
if (index == -1) {
- mSource.log(ILogger.LL_FAILURE,
- "request " + destreq.getRequestId() +
- " for " + sourceNameAndId + " malformed.");
+ mSource.log(ILogger.LL_FAILURE,
+ "request " + destreq.getRequestId() +
+ " for " + sourceNameAndId + " malformed.");
return;
}
String sourceId = sourceNameAndId.substring(index + 1);
@@ -187,9 +185,9 @@ public class LocalConnector implements IConnector {
r = (IRequest) mSourceReqs.get(rId);
if (r != null) {
if (r.getRequestStatus() != RequestStatus.SVC_PENDING) {
- mSource.log(ILogger.LL_FAILURE,
- "request state of " + rId + "not pending " +
- " from dest authority " + mDest.getId());
+ mSource.log(ILogger.LL_FAILURE,
+ "request state of " + rId + "not pending " +
+ " from dest authority " + mDest.getId());
sourceQ.releaseRequest(r);
return;
}
@@ -209,4 +207,3 @@ public class LocalConnector implements IConnector {
RequestTransfer.transfer(src, dest);
}
}
-
diff --git a/pki/base/common/src/com/netscape/cmscore/connector/RemoteAuthority.java b/pki/base/common/src/com/netscape/cmscore/connector/RemoteAuthority.java
index ddd02f82b..71d01579f 100644
--- a/pki/base/common/src/com/netscape/cmscore/connector/RemoteAuthority.java
+++ b/pki/base/common/src/com/netscape/cmscore/connector/RemoteAuthority.java
@@ -17,23 +17,21 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.connector;
-
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.base.IConfigStore;
import com.netscape.certsrv.connector.IRemoteAuthority;
-
public class RemoteAuthority implements IRemoteAuthority {
String mHost = null;
int mPort = -1;
String mURI = null;
int mTimeout = 0;
-
+
/**
* host parameter can be:
- * "directory.knowledge.com"
- * "199.254.1.2"
- * "directory.knowledge.com:1050 people.catalog.com 199.254.1.2"
+ * "directory.knowledge.com"
+ * "199.254.1.2"
+ * "directory.knowledge.com:1050 people.catalog.com 199.254.1.2"
*/
public RemoteAuthority(String host, int port, String uri, int timeout) {
mHost = host;
@@ -46,7 +44,7 @@ public class RemoteAuthority implements IRemoteAuthority {
}
public void init(IConfigStore c)
- throws EBaseException {
+ throws EBaseException {
mHost = c.getString("host");
mPort = c.getInteger("port");
mURI = c.getString("uri");
diff --git a/pki/base/common/src/com/netscape/cmscore/connector/RequestTransfer.java b/pki/base/common/src/com/netscape/cmscore/connector/RequestTransfer.java
index b00950209..c00d5c8b5 100644
--- a/pki/base/common/src/com/netscape/cmscore/connector/RequestTransfer.java
+++ b/pki/base/common/src/com/netscape/cmscore/connector/RequestTransfer.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.connector;
-
import java.util.Enumeration;
import java.util.Vector;
@@ -25,27 +24,26 @@ import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.request.IRequest;
import com.netscape.cmscore.authentication.ChallengePhraseAuthentication;
-
public class RequestTransfer {
private static final String DOT = ".";
- private static String[] transferAttributes = {
+ private static String[] transferAttributes = {
IRequest.HTTP_PARAMS,
- IRequest.AGENT_PARAMS,
- IRequest.CERT_INFO,
- IRequest.ISSUED_CERTS,
- IRequest.OLD_CERTS,
- IRequest.OLD_SERIALS,
- IRequest.REVOKED_CERTS,
- IRequest.CACERTCHAIN,
- IRequest.CRL,
- IRequest.ERRORS,
+ IRequest.AGENT_PARAMS,
+ IRequest.CERT_INFO,
+ IRequest.ISSUED_CERTS,
+ IRequest.OLD_CERTS,
+ IRequest.OLD_SERIALS,
+ IRequest.REVOKED_CERTS,
+ IRequest.CACERTCHAIN,
+ IRequest.CRL,
+ IRequest.ERRORS,
IRequest.RESULT,
IRequest.ERROR,
- IRequest.SVCERRORS,
- IRequest.REMOTE_STATUS,
- IRequest.REMOTE_REQID,
+ IRequest.SVCERRORS,
+ IRequest.REMOTE_STATUS,
+ IRequest.REMOTE_REQID,
IRequest.REVOKED_CERT_RECORDS,
IRequest.CERT_STATUS,
ChallengePhraseAuthentication.CHALLENGE_PHRASE,
@@ -53,11 +51,11 @@ public class RequestTransfer {
ChallengePhraseAuthentication.SERIALNUMBER,
ChallengePhraseAuthentication.SERIALNOARRAY,
IRequest.ISSUERDN,
- IRequest.CERT_FILTER,
+ IRequest.CERT_FILTER,
"keyRecord",
"uid", // UidPwdDirAuthentication.CRED_UID,
"udn", // UdnPwdDirAuthentication.CRED_UDN,
- };
+ };
public static boolean isProfileRequest(IRequest request) {
String profileId = request.getExtDataInString("profileId");
@@ -71,8 +69,8 @@ public class RequestTransfer {
public static String[] getTransferAttributes(IRequest r) {
if (isProfileRequest(r)) {
// copy everything in the request
- CMS.debug("RequestTransfer: profile request " +
- r.getRequestId().toString());
+ CMS.debug("RequestTransfer: profile request " +
+ r.getRequestId().toString());
Enumeration e = r.getExtDataKeys();
Vector v = new Vector();
@@ -108,8 +106,8 @@ public class RequestTransfer {
public static void transfer(IRequest src, IRequest dest) {
CMS.debug("Transfer srcId=" +
- src.getRequestId().toString() +
- " destId=" + dest.getRequestId().toString());
+ src.getRequestId().toString() +
+ " destId=" + dest.getRequestId().toString());
String attrs[] = getTransferAttributes(src);
for (int i = 0; i < attrs.length; i++) {
diff --git a/pki/base/common/src/com/netscape/cmscore/connector/Resender.java b/pki/base/common/src/com/netscape/cmscore/connector/Resender.java
index ad89a34a1..87764b7d8 100644
--- a/pki/base/common/src/com/netscape/cmscore/connector/Resender.java
+++ b/pki/base/common/src/com/netscape/cmscore/connector/Resender.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.connector;
-
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
@@ -36,16 +35,15 @@ import com.netscape.certsrv.request.RequestStatus;
import com.netscape.cmscore.util.Debug;
import com.netscape.cmsutil.http.JssSSLSocketFactory;
-
/**
- * Resend requests at intervals to the server to check if it's been completed.
+ * Resend requests at intervals to the server to check if it's been completed.
* Default interval is 5 minutes.
*/
public class Resender implements IResender {
public static final int SECOND = 1000; //milliseconds
- public static final int MINUTE = 60 * SECOND;
- public static final int HOUR = 60 * MINUTE;
- public static final int DAY = 24 * HOUR;
+ public static final int MINUTE = 60 * SECOND;
+ public static final int HOUR = 60 * MINUTE;
+ public static final int DAY = 24 * HOUR;
protected IAuthority mAuthority = null;
IRequestQueue mQueue = null;
@@ -61,21 +59,21 @@ public class Resender implements IResender {
// default interval.
// XXX todo add another interval for requests unsent because server
// was down (versus being serviced in request queue)
- protected int mInterval = 1 * MINUTE;
+ protected int mInterval = 1 * MINUTE;
public Resender(IAuthority authority, String nickName, IRemoteAuthority dest) {
mAuthority = authority;
mQueue = mAuthority.getRequestQueue();
mDest = dest;
mNickName = nickName;
-
+
//mConn = new HttpConnection(dest,
- // new JssSSLSocketFactory(nickName));
+ // new JssSSLSocketFactory(nickName));
}
public Resender(
- IAuthority authority, String nickName,
- IRemoteAuthority dest, int interval) {
+ IAuthority authority, String nickName,
+ IRemoteAuthority dest, int interval) {
mAuthority = authority;
mQueue = mAuthority.getRequestQueue();
mDest = dest;
@@ -83,21 +81,21 @@ public class Resender implements IResender {
mInterval = interval * SECOND; // interval specified in seconds.
//mConn = new HttpConnection(dest,
- // new JssSSLSocketFactory(nickName));
+ // new JssSSLSocketFactory(nickName));
}
// must be done after a subsystem 'start' so queue is initialized.
private void initRequests() {
mQueue = mAuthority.getRequestQueue();
// get all requests in mAuthority that are still pending.
- IRequestList list =
- mQueue.listRequestsByStatus(RequestStatus.SVC_PENDING);
+ IRequestList list =
+ mQueue.listRequestsByStatus(RequestStatus.SVC_PENDING);
while (list != null && list.hasMoreElements()) {
RequestId rid = list.nextRequestId();
CMS.debug(
- "added request Id " + rid + " in init to resend queue.");
+ "added request Id " + rid + " in init to resend queue.");
// note these are added as strings
mRequestIds.addElement(rid.toString());
}
@@ -109,13 +107,13 @@ public class Resender implements IResender {
mRequestIds.addElement(r.getRequestId().toString());
}
CMS.debug(
- "added " + r.getRequestId() + " to resend queue");
+ "added " + r.getRequestId() + " to resend queue");
}
public void run() {
- CMS.debug("Resender: In resender Thread run:");
- mConn = new HttpConnection(mDest,
+ CMS.debug("Resender: In resender Thread run:");
+ mConn = new HttpConnection(mDest,
new JssSSLSocketFactory(mNickName));
initRequests();
@@ -127,8 +125,7 @@ public class Resender implements IResender {
mAuthority.log(ILogger.LL_INFO, CMS.getLogMessage("CMSCORE_CONNECTOR_RESENDER_INTERRUPTED"));
continue;
}
- }
- while (true);
+ } while (true);
}
private void resend() {
@@ -141,12 +138,12 @@ public class Resender implements IResender {
while (enum1.hasMoreElements()) {
// request ids are added as strings.
- String ridString = (String) enum1.nextElement();
+ String ridString = (String) enum1.nextElement();
RequestId rid = new RequestId(ridString);
IRequest r = null;
CMS.debug(
- "resend processing request id " + rid);
+ "resend processing request id " + rid);
try {
r = mQueue.findRequest(rid);
@@ -160,7 +157,7 @@ public class Resender implements IResender {
// request not pending anymore - aborted or cancelled.
completedRids.addElement(rid);
CMS.debug(
- "request id " + rid + " no longer service pending");
+ "request id " + rid + " no longer service pending");
} else {
boolean completed = send(r);
@@ -175,8 +172,7 @@ public class Resender implements IResender {
// if connection is down, don't send the remaining request
// as it will sure fail.
mAuthority.log(ILogger.LL_WARN, CMS.getLogMessage("CMSCORE_CONNECTOR_DOWN"));
- if (e.toString().indexOf("connection not available")
- >= 0)
+ if (e.toString().indexOf("connection not available") >= 0)
break;
}
}
@@ -189,44 +185,44 @@ public class Resender implements IResender {
RequestId id = (RequestId) en.nextElement();
CMS.debug(
- "Connector: Removed request " + id + " from re-send queue");
+ "Connector: Removed request " + id + " from re-send queue");
mRequestIds.removeElement(id.toString());
CMS.debug(
- "Connector: mRequestIds now has " +
- mRequestIds.size() + " elements.");
+ "Connector: mRequestIds now has " +
+ mRequestIds.size() + " elements.");
}
}
}
// this is almost the same as connector's send.
private boolean send(IRequest r)
- throws IOException, EBaseException {
+ throws IOException, EBaseException {
IRequest reply = null;
-
+
try {
HttpPKIMessage tomsg = new HttpPKIMessage();
HttpPKIMessage replymsg = null;
tomsg.fromRequest(r);
replymsg = (HttpPKIMessage) mConn.send(tomsg);
- if(replymsg==null)
+ if (replymsg == null)
return false;
CMS.debug(
- r.getRequestId() + " resent to CA");
-
- RequestStatus replyStatus =
- RequestStatus.fromString(replymsg.reqStatus);
+ r.getRequestId() + " resent to CA");
+
+ RequestStatus replyStatus =
+ RequestStatus.fromString(replymsg.reqStatus);
int index = replymsg.reqId.lastIndexOf(':');
- RequestId replyRequestId =
- new RequestId(replymsg.reqId.substring(index + 1));
+ RequestId replyRequestId =
+ new RequestId(replymsg.reqId.substring(index + 1));
if (Debug.ON)
Debug.trace("reply request id " + replyRequestId +
- " for request " + r.getRequestId());
+ " for request " + r.getRequestId());
if (replyStatus != RequestStatus.COMPLETE) {
CMS.debug("resend " +
- r.getRequestId() + " still not completed.");
+ r.getRequestId() + " still not completed.");
return false;
}
@@ -237,7 +233,7 @@ public class Resender implements IResender {
mQueue.markAsServiced(r);
mQueue.releaseRequest(r);
CMS.debug(
- "resend released request " + r.getRequestId());
+ "resend released request " + r.getRequestId());
return true;
} catch (EBaseException e) {
// same as not having sent it, so still want to resend.
@@ -248,6 +244,5 @@ public class Resender implements IResender {
return false;
}
-
-}
+}