|
|
2555cf |
commit d37d1cb1a2d33d17f15cbf9565a4bba99050e59a
|
|
|
2555cf |
Author: Fraser Tweedale <ftweedal@redhat.com>
|
|
|
2555cf |
Date: Mon Jan 23 17:11:26 2017 +1000
|
|
|
2555cf |
|
|
|
2555cf |
Use BigInteger for entryUSN
|
|
|
2555cf |
|
|
|
2555cf |
Currently we try to parse the entryUSN into an Integer, which wraps
|
|
|
2555cf |
the 'int' primitive type. If entryUSN value is too large to fit in
|
|
|
2555cf |
'int', NumberFormatException is raised.
|
|
|
2555cf |
|
|
|
2555cf |
Change LDAPProfileSubsystem and CertificateAuthority to use
|
|
|
2555cf |
BigInteger for entryUSN values.
|
|
|
2555cf |
|
|
|
2555cf |
Fixes: https://fedorahosted.org/pki/ticket/2579
|
|
|
2555cf |
(cherry picked from commit 79c6d70a8434cf52f9bac8bfa0367876baccb054)
|
|
|
2555cf |
(cherry picked from commit 7727940c7f43161d5a7597756cf01f159b2a72d8)
|
|
|
2555cf |
|
|
|
2555cf |
diff --git a/base/ca/src/com/netscape/ca/CertificateAuthority.java b/base/ca/src/com/netscape/ca/CertificateAuthority.java
|
|
|
2555cf |
index ae90d3a..9b2ba03 100644
|
|
|
2555cf |
--- a/base/ca/src/com/netscape/ca/CertificateAuthority.java
|
|
|
2555cf |
+++ b/base/ca/src/com/netscape/ca/CertificateAuthority.java
|
|
|
2555cf |
@@ -333,7 +333,7 @@ public class CertificateAuthority
|
|
|
2555cf |
|
|
|
2555cf |
/* Maps and sets of entryUSNs and nsUniqueIds for avoiding race
|
|
|
2555cf |
* conditions and unnecessary reloads related to replication */
|
|
|
2555cf |
- private static TreeMap<AuthorityID,Integer> entryUSNs = new TreeMap<>();
|
|
|
2555cf |
+ private static TreeMap<AuthorityID,BigInteger> entryUSNs = new TreeMap<>();
|
|
|
2555cf |
private static TreeMap<AuthorityID,String> nsUniqueIds = new TreeMap<>();
|
|
|
2555cf |
private static TreeSet<String> deletedNsUniqueIds = new TreeSet<>();
|
|
|
2555cf |
|
|
|
2555cf |
@@ -2904,7 +2904,7 @@ public class CertificateAuthority
|
|
|
2555cf |
|
|
|
2555cf |
LDAPAttribute attr = entry.getAttribute("entryUSN");
|
|
|
2555cf |
if (attr != null) {
|
|
|
2555cf |
- Integer entryUSN = new Integer(attr.getStringValueArray()[0]);
|
|
|
2555cf |
+ BigInteger entryUSN = new BigInteger(attr.getStringValueArray()[0]);
|
|
|
2555cf |
entryUSNs.put(aid, entryUSN);
|
|
|
2555cf |
CMS.debug("postCommit: new entryUSN = " + entryUSN);
|
|
|
2555cf |
}
|
|
|
2555cf |
@@ -3270,7 +3270,7 @@ public class CertificateAuthority
|
|
|
2555cf |
return;
|
|
|
2555cf |
}
|
|
|
2555cf |
|
|
|
2555cf |
- Integer newEntryUSN = null;
|
|
|
2555cf |
+ BigInteger newEntryUSN = null;
|
|
|
2555cf |
LDAPAttribute entryUSNAttr = entry.getAttribute("entryUSN");
|
|
|
2555cf |
if (entryUSNAttr == null) {
|
|
|
2555cf |
CMS.debug("readAuthority: no entryUSN");
|
|
|
2555cf |
@@ -3287,14 +3287,14 @@ public class CertificateAuthority
|
|
|
2555cf |
// entryUSN attribute being added.
|
|
|
2555cf |
}
|
|
|
2555cf |
} else {
|
|
|
2555cf |
- newEntryUSN = new Integer(entryUSNAttr.getStringValueArray()[0]);
|
|
|
2555cf |
+ newEntryUSN = new BigInteger(entryUSNAttr.getStringValueArray()[0]);
|
|
|
2555cf |
CMS.debug("readAuthority: new entryUSN = " + newEntryUSN);
|
|
|
2555cf |
}
|
|
|
2555cf |
|
|
|
2555cf |
- Integer knownEntryUSN = entryUSNs.get(aid);
|
|
|
2555cf |
+ BigInteger knownEntryUSN = entryUSNs.get(aid);
|
|
|
2555cf |
if (newEntryUSN != null && knownEntryUSN != null) {
|
|
|
2555cf |
CMS.debug("readAuthority: known entryUSN = " + knownEntryUSN);
|
|
|
2555cf |
- if (newEntryUSN <= knownEntryUSN) {
|
|
|
2555cf |
+ if (newEntryUSN.compareTo(knownEntryUSN) <= 0) {
|
|
|
2555cf |
CMS.debug("readAuthority: data is current");
|
|
|
2555cf |
return;
|
|
|
2555cf |
}
|
|
|
2555cf |
diff --git a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java
|
|
|
2555cf |
index 6dea1a0..348a9ab 100644
|
|
|
2555cf |
--- a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java
|
|
|
2555cf |
+++ b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java
|
|
|
2555cf |
@@ -19,6 +19,7 @@ package com.netscape.cmscore.profile;
|
|
|
2555cf |
|
|
|
2555cf |
import java.io.ByteArrayInputStream;
|
|
|
2555cf |
import java.io.InputStream;
|
|
|
2555cf |
+import java.math.BigInteger;
|
|
|
2555cf |
import java.util.Arrays;
|
|
|
2555cf |
import java.util.Hashtable;
|
|
|
2555cf |
import java.util.LinkedHashMap;
|
|
|
2555cf |
@@ -64,7 +65,7 @@ public class LDAPProfileSubsystem
|
|
|
2555cf |
|
|
|
2555cf |
/* Map of profileId -> entryUSN for the most recent view
|
|
|
2555cf |
* of the profile entry that this instance has seen */
|
|
|
2555cf |
- private TreeMap<String,Integer> entryUSNs;
|
|
|
2555cf |
+ private TreeMap<String,BigInteger> entryUSNs;
|
|
|
2555cf |
|
|
|
2555cf |
private TreeMap<String,String> nsUniqueIds;
|
|
|
2555cf |
|
|
|
2555cf |
@@ -149,14 +150,14 @@ public class LDAPProfileSubsystem
|
|
|
2555cf |
}
|
|
|
2555cf |
profileId = LDAPDN.explodeDN(dn, true)[0];
|
|
|
2555cf |
|
|
|
2555cf |
- Integer newEntryUSN = new Integer(
|
|
|
2555cf |
+ BigInteger newEntryUSN = new BigInteger(
|
|
|
2555cf |
ldapProfile.getAttribute("entryUSN").getStringValueArray()[0]);
|
|
|
2555cf |
CMS.debug("readProfile: new entryUSN = " + newEntryUSN);
|
|
|
2555cf |
|
|
|
2555cf |
- Integer knownEntryUSN = entryUSNs.get(profileId);
|
|
|
2555cf |
+ BigInteger knownEntryUSN = entryUSNs.get(profileId);
|
|
|
2555cf |
if (knownEntryUSN != null) {
|
|
|
2555cf |
CMS.debug("readProfile: known entryUSN = " + knownEntryUSN);
|
|
|
2555cf |
- if (newEntryUSN <= knownEntryUSN) {
|
|
|
2555cf |
+ if (newEntryUSN.compareTo(knownEntryUSN) <= 0) {
|
|
|
2555cf |
CMS.debug("readProfile: data is current");
|
|
|
2555cf |
return;
|
|
|
2555cf |
}
|
|
|
2555cf |
@@ -327,10 +328,10 @@ public class LDAPProfileSubsystem
|
|
|
2555cf |
return;
|
|
|
2555cf |
}
|
|
|
2555cf |
|
|
|
2555cf |
- Integer entryUSN = null;
|
|
|
2555cf |
+ BigInteger entryUSN = null;
|
|
|
2555cf |
LDAPAttribute attr = entry.getAttribute("entryUSN");
|
|
|
2555cf |
if (attr != null)
|
|
|
2555cf |
- entryUSN = new Integer(attr.getStringValueArray()[0]);
|
|
|
2555cf |
+ entryUSN = new BigInteger(attr.getStringValueArray()[0]);
|
|
|
2555cf |
entryUSNs.put(id, entryUSN);
|
|
|
2555cf |
CMS.debug("commitProfile: new entryUSN = " + entryUSN);
|
|
|
2555cf |
|