From 5155a9dc8d5b461123a13079252fc5d3fab8f908 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Fri, 18 Nov 2011 14:53:08 -0500 Subject: Typesafety for certsrv.kra --- .../certsrv/kra/IKeyRecoveryAuthority.java | 8 ++-- .../src/com/netscape/certsrv/kra/IKeyService.java | 4 +- .../com/netscape/certsrv/kra/ProofOfArchival.java | 6 +-- .../src/com/netscape/kra/KeyRecoveryAuthority.java | 56 +++++++++++----------- 4 files changed, 38 insertions(+), 36 deletions(-) (limited to 'pki') diff --git a/pki/base/common/src/com/netscape/certsrv/kra/IKeyRecoveryAuthority.java b/pki/base/common/src/com/netscape/certsrv/kra/IKeyRecoveryAuthority.java index b268073e0..7be3f165f 100644 --- a/pki/base/common/src/com/netscape/certsrv/kra/IKeyRecoveryAuthority.java +++ b/pki/base/common/src/com/netscape/certsrv/kra/IKeyRecoveryAuthority.java @@ -164,7 +164,7 @@ public interface IKeyRecoveryAuthority extends ISubsystem { * * @return list of auto recovery identifiers */ - public Enumeration getAutoRecoveryIDs(); + public Enumeration getAutoRecoveryIDs(); /** * Returns the storage key unit that manages the @@ -259,7 +259,7 @@ public interface IKeyRecoveryAuthority extends ISubsystem { * @param id request id * @return volatile requests */ - public Hashtable createVolatileRequest(RequestId id); + public Hashtable createVolatileRequest(RequestId id); /** * Retrieves the request object. @@ -267,7 +267,7 @@ public interface IKeyRecoveryAuthority extends ISubsystem { * @param id request id * @return volatile requests */ - public Hashtable getVolatileRequest(RequestId id); + public Hashtable getVolatileRequest(RequestId id); /** * Destroys the request object. @@ -276,7 +276,7 @@ public interface IKeyRecoveryAuthority extends ISubsystem { */ public void destroyVolatileRequest(RequestId id); - public Vector getAppAgents( + public Vector getAppAgents( String recoveryID) throws EBaseException; /** diff --git a/pki/base/common/src/com/netscape/certsrv/kra/IKeyService.java b/pki/base/common/src/com/netscape/certsrv/kra/IKeyService.java index 5785aeb06..5ed17453c 100644 --- a/pki/base/common/src/com/netscape/certsrv/kra/IKeyService.java +++ b/pki/base/common/src/com/netscape/certsrv/kra/IKeyService.java @@ -133,7 +133,7 @@ public interface IKeyService { * @return recovery parameters * @exception EBaseException failed to create */ - public Hashtable createRecoveryParams(String recoveryID) + public Hashtable createRecoveryParams(String recoveryID) throws EBaseException; /** @@ -152,7 +152,7 @@ public interface IKeyService { * @return recovery parameters * @exception EBaseException failed to retrieve */ - public Hashtable getRecoveryParams(String recoveryID) + public Hashtable getRecoveryParams(String recoveryID) throws EBaseException; /** diff --git a/pki/base/common/src/com/netscape/certsrv/kra/ProofOfArchival.java b/pki/base/common/src/com/netscape/certsrv/kra/ProofOfArchival.java index a2742809e..ca5753967 100644 --- a/pki/base/common/src/com/netscape/certsrv/kra/ProofOfArchival.java +++ b/pki/base/common/src/com/netscape/certsrv/kra/ProofOfArchival.java @@ -94,7 +94,7 @@ public class ProofOfArchival implements IDBObj, IProofOfArchival, Serializable { protected String mIssuer = null; protected Date mDateOfArchival = null; - protected static Vector mNames = new Vector(); + protected static Vector mNames = new Vector(); static { mNames.addElement(ATTR_VERSION); mNames.addElement(ATTR_SERIALNO); @@ -195,7 +195,7 @@ public class ProofOfArchival implements IDBObj, IProofOfArchival, Serializable { * * @return a list of names */ - public Enumeration getElements() { + public Enumeration getElements() { return mNames.elements(); } @@ -204,7 +204,7 @@ public class ProofOfArchival implements IDBObj, IProofOfArchival, Serializable { * * @return a list of serializable attribute names */ - public Enumeration getSerializableAttrNames() { + public Enumeration getSerializableAttrNames() { return mNames.elements(); } diff --git a/pki/base/kra/src/com/netscape/kra/KeyRecoveryAuthority.java b/pki/base/kra/src/com/netscape/kra/KeyRecoveryAuthority.java index 3339d31fb..22a109985 100644 --- a/pki/base/kra/src/com/netscape/kra/KeyRecoveryAuthority.java +++ b/pki/base/kra/src/com/netscape/kra/KeyRecoveryAuthority.java @@ -103,7 +103,6 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove private final static String KEY_RESP_NAME = "keyRepository"; private static final String PROP_REPLICAID_DN = "dbs.replicadn"; - private Hashtable mRequestProcessor = new Hashtable(); protected boolean mInitialized = false; protected IConfigStore mConfig = null; @@ -115,7 +114,7 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove protected IRequestQueue mRequestQueue = null; protected TransportKeyUnit mTransportKeyUnit = null; protected StorageKeyUnit mStorageKeyUnit = null; - protected Hashtable mAutoRecovery = new Hashtable(); + protected Hashtable mAutoRecovery = new Hashtable(); protected boolean mAutoRecoveryOn = false; protected KeyRepository mKeyDB = null; protected ReplicaIDRepository mReplicaRepot = null; @@ -123,7 +122,7 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove protected IRequestNotifier mPNotify = null; protected ISubsystem mOwner = null; protected int mRecoveryIDCounter = 0; - protected Hashtable mRecoveryParams = new Hashtable(); + protected Hashtable> mRecoveryParams = new Hashtable>(); protected org.mozilla.jss.crypto.X509Certificate mJssCert = null; protected CryptoToken mKeygenToken = null; @@ -524,7 +523,7 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove * @return list of user IDs that are accepted in the * auto recovery mode */ - public Enumeration getAutoRecoveryIDs() { + public Enumeration getAutoRecoveryIDs() { return mAutoRecovery.keys(); } @@ -599,11 +598,11 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove return Integer.toString(mRecoveryIDCounter++); } - public Hashtable createRecoveryParams(String recoveryID) + public Hashtable createRecoveryParams(String recoveryID) throws EBaseException { - Hashtable h = new Hashtable(); + Hashtable h = new Hashtable(); - h.put(PARAM_CREDS, new Vector()); + h.put(PARAM_CREDS, new Vector()); h.put(PARAM_LOCK, new Object()); mRecoveryParams.put(recoveryID, h); return h; @@ -614,14 +613,14 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove mRecoveryParams.remove(recoveryID); } - public Hashtable getRecoveryParams(String recoveryID) + public Hashtable getRecoveryParams(String recoveryID) throws EBaseException { - return (Hashtable) mRecoveryParams.get(recoveryID); + return (Hashtable) mRecoveryParams.get(recoveryID); } public void createPk12(String recoveryID, byte[] pk12) throws EBaseException { - Hashtable h = getRecoveryParams(recoveryID); + Hashtable h = getRecoveryParams(recoveryID); h.put(PARAM_PK12, pk12); } @@ -633,7 +632,7 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove public void createError(String recoveryID, String error) throws EBaseException { - Hashtable h = getRecoveryParams(recoveryID); + Hashtable h = getRecoveryParams(recoveryID); h.put(PARAM_ERROR, error); } @@ -646,10 +645,11 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove /** * Retrieve the current approval agents */ - public Vector getAppAgents( + public Vector getAppAgents( String recoveryID) throws EBaseException { - Hashtable h = getRecoveryParams(recoveryID); - Vector dc = (Vector) h.get(PARAM_CREDS); + Hashtable h = getRecoveryParams(recoveryID); + @SuppressWarnings("unchecked") + Vector dc = (Vector) h.get(PARAM_CREDS); return dc; } @@ -662,8 +662,9 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove public Credential[] getDistributedCredentials( String recoveryID) throws EBaseException { - Hashtable h = getRecoveryParams(recoveryID); - Vector dc = (Vector) h.get(PARAM_CREDS); + Hashtable h = getRecoveryParams(recoveryID); + @SuppressWarnings("unchecked") + Vector dc = (Vector) h.get(PARAM_CREDS); Object lock = (Object) h.get(PARAM_LOCK); synchronized (lock) { @@ -684,7 +685,7 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove /** * Verifies credential. */ - private void verifyCredential(Vector creds, String uid, + private void verifyCredential(Vector creds, String uid, String pwd) throws EBaseException { // see if we have the uid already @@ -698,7 +699,7 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove } for (int i = 0; i < creds.size(); i++) { - Credential c = (Credential) creds.elementAt(i); + Credential c = creds.elementAt(i); if (c.getIdentifier().equals(uid)) { // duplicated uid @@ -715,8 +716,9 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove */ public void addDistributedCredential(String recoveryID, String uid, String pwd) throws EBaseException { - Hashtable h = getRecoveryParams(recoveryID); - Vector dc = (Vector) h.get(PARAM_CREDS); + Hashtable h = getRecoveryParams(recoveryID); + @SuppressWarnings("unchecked") + Vector dc = (Vector ) h.get(PARAM_CREDS); Object lock = (Object) h.get(PARAM_LOCK); synchronized (lock) { @@ -1014,7 +1016,7 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove IRequestQueue queue = null; IRequest r = null; - Hashtable params = null; + Hashtable params = null; CMS.debug("KeyRecoveryAuthority: in synchronous doKeyRecovery()"); // ensure that any low-level exceptions are reported @@ -1148,7 +1150,7 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove IRequestQueue queue = null; IRequest r = null; - Hashtable params = null; + Hashtable params = null; CMS.debug("KeyRecoveryAuthority: in asynchronous doKeyRecovery()"); queue = getRequestQueue(); @@ -1492,7 +1494,7 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove } */ - public Hashtable mVolatileRequests = new Hashtable(); + public Hashtable> mVolatileRequests = new Hashtable>(); /** * Creates a request object to store attributes that @@ -1501,15 +1503,15 @@ public class KeyRecoveryAuthority implements IAuthority, IKeyService, IKeyRecove * persistent storage. Things like passwords are not * desirable to be stored. */ - public Hashtable createVolatileRequest(RequestId id) { - Hashtable params = new Hashtable(); + public Hashtable createVolatileRequest(RequestId id) { + Hashtable params = new Hashtable(); mVolatileRequests.put(id.toString(), params); return params; } - public Hashtable getVolatileRequest(RequestId id) { - return (Hashtable) mVolatileRequests.get(id.toString()); + public Hashtable getVolatileRequest(RequestId id) { + return (Hashtable) mVolatileRequests.get(id.toString()); } public void destroyVolatileRequest(RequestId id) { -- cgit