diff options
author | Ade Lee <alee@redhat.com> | 2012-01-11 12:57:53 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2012-01-11 13:49:04 -0500 |
commit | 10cfe7756e967ac91c66d33b392aeab9cf3780fb (patch) | |
tree | d5ac9b58442265d2ce5ef60e31f041ddacba1b4f /pki/base/common/src/com/netscape/certsrv/base/Nonces.java | |
parent | edcb24f65cc3700e75d0a1d14dc2483f210b0ee4 (diff) | |
download | pki-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/certsrv/base/Nonces.java')
-rw-r--r-- | pki/base/common/src/com/netscape/certsrv/base/Nonces.java | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/pki/base/common/src/com/netscape/certsrv/base/Nonces.java b/pki/base/common/src/com/netscape/certsrv/base/Nonces.java index fde209332..cc0231ac3 100644 --- a/pki/base/common/src/com/netscape/certsrv/base/Nonces.java +++ b/pki/base/common/src/com/netscape/certsrv/base/Nonces.java @@ -21,14 +21,13 @@ import java.security.cert.X509Certificate; import java.util.Hashtable; import java.util.Vector; - /** * This class manages nonces sometimes used to control request state flow. * <P> - * + * * @version $Revision$, $Date$ */ -public class Nonces { +public class Nonces { private Hashtable<Long, X509Certificate> mNonces = new Hashtable<Long, X509Certificate>(); private Vector<Long> mNonceList = new Vector<Long>(); @@ -49,17 +48,17 @@ public class Nonces { long i; long k = 0; long n = nonce; - long m = (long)((mNonceLimit / 2) + 1); + long m = (long) ((mNonceLimit / 2) + 1); for (i = 0; i < m; i++) { k = n + i; // avoid collisions - if (!mNonceList.contains((Object)k)) { + if (!mNonceList.contains((Object) k)) { break; } k = n - i; // avoid collisions - if (!mNonceList.contains((Object)k)) { + if (!mNonceList.contains((Object) k)) { break; } } @@ -67,9 +66,9 @@ public class Nonces { mNonceList.add(k); mNonces.put(k, cert); if (mNonceList.size() > mNonceLimit) { - n = ((Long)(mNonceList.firstElement())).longValue(); + n = ((Long) (mNonceList.firstElement())).longValue(); mNonceList.remove(0); - mNonces.remove((Object)n); + mNonces.remove((Object) n); } } else { // failed to resolved collision @@ -79,15 +78,15 @@ public class Nonces { } public X509Certificate getCertificate(long nonce) { - X509Certificate cert = (X509Certificate)mNonces.get(nonce); + X509Certificate cert = (X509Certificate) mNonces.get(nonce); return cert; } public X509Certificate getCertificate(int index) { X509Certificate cert = null; if (index >= 0 && index < mNonceList.size()) { - long nonce = ((Long)(mNonceList.elementAt(index))).longValue(); - cert = (X509Certificate)mNonces.get(nonce); + long nonce = ((Long) (mNonceList.elementAt(index))).longValue(); + cert = (X509Certificate) mNonces.get(nonce); } return cert; } @@ -95,17 +94,16 @@ public class Nonces { public long getNonce(int index) { long nonce = 0; if (index >= 0 && index < mNonceList.size()) { - nonce = ((Long)(mNonceList.elementAt(index))).longValue(); + nonce = ((Long) (mNonceList.elementAt(index))).longValue(); } return nonce; } public void removeNonce(long nonce) { - mNonceList.remove((Object)nonce); - mNonces.remove((Object)nonce); + mNonceList.remove((Object) nonce); + mNonces.remove((Object) nonce); } - public int size() { return mNonceList.size(); } |