summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2016-04-16 10:56:18 -0400
committerAde Lee <alee@redhat.com>2016-04-20 17:29:25 -0400
commit4fddcd370e6f3d47f252eec8077cbca379d4e281 (patch)
tree5c620076fb083795d7f2be9374ffbb55c8e23b9b
parent55b3b745be977b7d1cfc527ffb5f828deacbe26b (diff)
downloadpki-4fddcd370e6f3d47f252eec8077cbca379d4e281.zip
pki-4fddcd370e6f3d47f252eec8077cbca379d4e281.tar.gz
pki-4fddcd370e6f3d47f252eec8077cbca379d4e281.tar.xz
Add realm to the request record
Part of Trac Ticket #2041
-rw-r--r--base/common/src/com/netscape/certsrv/request/CMSRequestInfo.java17
-rw-r--r--base/common/src/com/netscape/certsrv/request/IRequest.java20
-rw-r--r--base/common/src/com/netscape/certsrv/request/IRequestRecord.java2
-rw-r--r--base/server/cmscore/src/com/netscape/cmscore/request/ARequestQueue.java27
-rw-r--r--base/server/cmscore/src/com/netscape/cmscore/request/ARequestRecord.java1
-rw-r--r--base/server/cmscore/src/com/netscape/cmscore/request/RequestRecord.java21
-rw-r--r--base/server/cmscore/src/com/netscape/cmscore/request/Schema.java1
-rw-r--r--base/server/test/com/netscape/cmscore/request/RequestDefaultStub.java21
8 files changed, 90 insertions, 20 deletions
diff --git a/base/common/src/com/netscape/certsrv/request/CMSRequestInfo.java b/base/common/src/com/netscape/certsrv/request/CMSRequestInfo.java
index f7b34f0..bfd1b2f 100644
--- a/base/common/src/com/netscape/certsrv/request/CMSRequestInfo.java
+++ b/base/common/src/com/netscape/certsrv/request/CMSRequestInfo.java
@@ -35,6 +35,9 @@ public class CMSRequestInfo {
@XmlElement
protected String requestURL;
+ @XmlElement
+ protected String realm;
+
/**
* @return the requestType
*/
@@ -85,10 +88,19 @@ public class CMSRequestInfo {
this.requestURL = requestURL;
}
+ public String getRealm() {
+ return realm;
+ }
+
+ public void setRealm(String realm) {
+ this.realm = realm;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
+ result = prime * result + ((realm == null) ? 0 : realm.hashCode());
result = prime * result + ((requestStatus == null) ? 0 : requestStatus.hashCode());
result = prime * result + ((requestType == null) ? 0 : requestType.hashCode());
result = prime * result + ((requestURL == null) ? 0 : requestURL.hashCode());
@@ -104,6 +116,11 @@ public class CMSRequestInfo {
if (getClass() != obj.getClass())
return false;
CMSRequestInfo other = (CMSRequestInfo) obj;
+ if (realm == null) {
+ if (other.realm != null)
+ return false;
+ } else if (!realm.equals(other.realm))
+ return false;
if (requestStatus == null) {
if (other.requestStatus != null)
return false;
diff --git a/base/common/src/com/netscape/certsrv/request/IRequest.java b/base/common/src/com/netscape/certsrv/request/IRequest.java
index 8d4ec98..8a002ab 100644
--- a/base/common/src/com/netscape/certsrv/request/IRequest.java
+++ b/base/common/src/com/netscape/certsrv/request/IRequest.java
@@ -27,15 +27,15 @@ import java.util.Hashtable;
import java.util.Locale;
import java.util.Vector;
+import com.netscape.certsrv.authentication.IAuthToken;
+import com.netscape.certsrv.base.IAttrSet;
+
import netscape.security.x509.CertificateExtensions;
import netscape.security.x509.CertificateSubjectName;
import netscape.security.x509.RevokedCertImpl;
import netscape.security.x509.X509CertImpl;
import netscape.security.x509.X509CertInfo;
-import com.netscape.certsrv.authentication.IAuthToken;
-import com.netscape.certsrv.base.IAttrSet;
-
/**
* An interface that defines abilities of request objects,
*
@@ -305,6 +305,9 @@ public interface IRequest extends Serializable {
// String error messages
public static final String ERROR = "Error";
+ // authentication realm
+ public static final String REALM = "realm";
+
/**
* Copies meta attributes (excluding request Id, etc.) of another request
* to this request.
@@ -771,4 +774,15 @@ public interface IRequest extends Serializable {
*/
public IAttrSet asIAttrSet();
+ /**
+ * Get realm
+ * @return String
+ */
+ public String getRealm();
+
+ /**
+ * Set the realm
+ * @param realm
+ */
+ public void setRealm(String realm);
}
diff --git a/base/common/src/com/netscape/certsrv/request/IRequestRecord.java b/base/common/src/com/netscape/certsrv/request/IRequestRecord.java
index eba6cab..7b041fb 100644
--- a/base/common/src/com/netscape/certsrv/request/IRequestRecord.java
+++ b/base/common/src/com/netscape/certsrv/request/IRequestRecord.java
@@ -61,6 +61,8 @@ public interface IRequestRecord
// and the RequestRecord.
public final static String ATTR_EXT_DATA = "requestExtData";
+ public final static String ATTR_REALM = "realm";
+
/**
* Gets the request id.
*
diff --git a/base/server/cmscore/src/com/netscape/cmscore/request/ARequestQueue.java b/base/server/cmscore/src/com/netscape/cmscore/request/ARequestQueue.java
index 798da3f..fc0a414 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/request/ARequestQueue.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/request/ARequestQueue.java
@@ -33,14 +33,6 @@ import java.util.Locale;
import java.util.Set;
import java.util.Vector;
-import netscape.security.util.DerInputStream;
-import netscape.security.x509.CertificateExtensions;
-import netscape.security.x509.CertificateSubjectName;
-import netscape.security.x509.RevokedCertImpl;
-import netscape.security.x509.X509CertImpl;
-import netscape.security.x509.X509CertInfo;
-import netscape.security.x509.X509ExtensionException;
-
import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.authentication.AuthToken;
import com.netscape.certsrv.authentication.IAuthToken;
@@ -61,6 +53,14 @@ import com.netscape.certsrv.request.PolicyResult;
import com.netscape.certsrv.request.RequestId;
import com.netscape.certsrv.request.RequestStatus;
+import netscape.security.util.DerInputStream;
+import netscape.security.x509.CertificateExtensions;
+import netscape.security.x509.CertificateSubjectName;
+import netscape.security.x509.RevokedCertImpl;
+import netscape.security.x509.X509CertImpl;
+import netscape.security.x509.X509CertInfo;
+import netscape.security.x509.X509ExtensionException;
+
/**
* The ARequestQueue class is an abstract class that implements
* most portions of the IRequestQueue interface. This includes
@@ -1432,10 +1432,21 @@ class Request implements IRequest {
protected String mOwner;
protected String mRequestType;
protected String mContext; // string for now.
+ protected String realm;
protected ExtDataHashtable<Object> mExtData = new ExtDataHashtable<Object>();
Date mCreationTime = CMS.getCurrentDate();
Date mModificationTime = CMS.getCurrentDate();
+
+ @Override
+ public String getRealm() {
+ return realm;
+ }
+
+ @Override
+ public void setRealm(String realm) {
+ this.realm = realm;
+ }
}
class RequestIAttrSetWrapper implements IAttrSet {
diff --git a/base/server/cmscore/src/com/netscape/cmscore/request/ARequestRecord.java b/base/server/cmscore/src/com/netscape/cmscore/request/ARequestRecord.java
index 5f2aa50..418422a 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/request/ARequestRecord.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/request/ARequestRecord.java
@@ -39,4 +39,5 @@ class ARequestRecord {
String mOwner;
String mRequestType;
Hashtable<String, Object> mExtData;
+ String mRealm;
};
diff --git a/base/server/cmscore/src/com/netscape/cmscore/request/RequestRecord.java b/base/server/cmscore/src/com/netscape/cmscore/request/RequestRecord.java
index 023dd94..38060c2 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/request/RequestRecord.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/request/RequestRecord.java
@@ -30,9 +30,6 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
-import netscape.ldap.LDAPAttribute;
-import netscape.ldap.LDAPAttributeSet;
-
import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.dbs.EDBException;
@@ -53,6 +50,9 @@ import com.netscape.cmscore.dbs.DateMapper;
import com.netscape.cmscore.dbs.StringMapper;
import com.netscape.cmscore.util.Debug;
+import netscape.ldap.LDAPAttribute;
+import netscape.ldap.LDAPAttributeSet;
+
//
// A request record is the stored version of a request.
// It has a set of attributes that are mapped into LDAP
@@ -92,6 +92,8 @@ public class RequestRecord
return mOwner;
else if (name.equals(IRequestRecord.ATTR_EXT_DATA))
return mExtData;
+ else if (name.equals(IRequestRecord.ATTR_REALM))
+ return mRealm;
else {
RequestAttr ra = mAttrTable.get(name);
@@ -119,6 +121,8 @@ public class RequestRecord
mSourceId = (String) o;
else if (name.equals(IRequestRecord.ATTR_REQUEST_OWNER))
mOwner = (String) o;
+ else if (name.equals(IRequestRecord.ATTR_REALM))
+ mRealm = (String) o;
else if (name.equals(IRequestRecord.ATTR_EXT_DATA))
mExtData = (Hashtable<String, Object>) o;
else {
@@ -155,6 +159,7 @@ public class RequestRecord
mOwner = r.getRequestOwner();
mCreateTime = r.getCreationTime();
mModifyTime = r.getModificationTime();
+ mRealm = r.getRealm();
mExtData = loadExtDataFromRequest(r);
for (int i = 0; i < mRequestA.length; i++) {
@@ -168,6 +173,7 @@ public class RequestRecord
r.setRequestOwner(mOwner);
a.modModificationTime(r, mModifyTime);
a.modCreationTime(r, mCreateTime);
+ r.setRealm(mRealm);
storeExtDataIntoRequest(r);
for (int i = 0; i < mRequestA.length; i++) {
@@ -192,6 +198,12 @@ public class RequestRecord
mods.add(IRequestRecord.ATTR_EXT_DATA,
Modification.MOD_REPLACE, loadExtDataFromRequest(r));
+ if (r.getRealm() != null) {
+ mods.add(IRequestRecord.ATTR_REALM, Modification.MOD_REPLACE, r.getRealm());
+ } else {
+ mods.add(IRequestRecord.ATTR_REALM, Modification.MOD_DELETE, null);
+ }
+
for (int i = 0; i < mRequestA.length; i++) {
mRequestA[i].mod(mods, r);
}
@@ -213,6 +225,8 @@ public class RequestRecord
new StringMapper(Schema.LDAP_ATTR_SOURCE_ID));
reg.registerAttribute(IRequestRecord.ATTR_REQUEST_OWNER,
new StringMapper(Schema.LDAP_ATTR_REQUEST_OWNER));
+ reg.registerAttribute(IRequestRecord.ATTR_REALM,
+ new StringMapper(Schema.LDAP_ATTR_REALM));
ExtAttrDynMapper extAttrMapper = new ExtAttrDynMapper();
reg.registerAttribute(IRequestRecord.ATTR_EXT_DATA, extAttrMapper);
reg.registerDynamicMapper(extAttrMapper);
@@ -306,6 +320,7 @@ public class RequestRecord
mAttrs.add(IRequestRecord.ATTR_MODIFY_TIME);
mAttrs.add(IRequestRecord.ATTR_SOURCE_ID);
mAttrs.add(IRequestRecord.ATTR_REQUEST_OWNER);
+ mAttrs.add(IRequestRecord.ATTR_REALM);
mAttrs.add(IRequestRecord.ATTR_EXT_DATA);
for (int i = 0; i < mRequestA.length; i++) {
diff --git a/base/server/cmscore/src/com/netscape/cmscore/request/Schema.java b/base/server/cmscore/src/com/netscape/cmscore/request/Schema.java
index 89a7b74..75605d7 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/request/Schema.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/request/Schema.java
@@ -38,6 +38,7 @@ class Schema {
public static final String LDAP_ATTR_AGENT_GROUP = "requestAgentGroup";
public static final String LDAP_ATTR_REQUEST_TYPE = "requestType";
public static final String LDAP_ATTR_REQUEST_ERROR = "requestError";
+ public static final String LDAP_ATTR_REALM = "realm";
// This attribute is a placeholder used by ExtAttrDynMapper
public static final String LDAP_ATTR_EXT_ATTR = "extAttr";
diff --git a/base/server/test/com/netscape/cmscore/request/RequestDefaultStub.java b/base/server/test/com/netscape/cmscore/request/RequestDefaultStub.java
index 7a6bde4..b55238d 100644
--- a/base/server/test/com/netscape/cmscore/request/RequestDefaultStub.java
+++ b/base/server/test/com/netscape/cmscore/request/RequestDefaultStub.java
@@ -7,18 +7,18 @@ import java.util.Hashtable;
import java.util.Locale;
import java.util.Vector;
-import netscape.security.x509.CertificateExtensions;
-import netscape.security.x509.CertificateSubjectName;
-import netscape.security.x509.RevokedCertImpl;
-import netscape.security.x509.X509CertImpl;
-import netscape.security.x509.X509CertInfo;
-
import com.netscape.certsrv.authentication.IAuthToken;
import com.netscape.certsrv.base.IAttrSet;
import com.netscape.certsrv.request.IRequest;
import com.netscape.certsrv.request.RequestId;
import com.netscape.certsrv.request.RequestStatus;
+import netscape.security.x509.CertificateExtensions;
+import netscape.security.x509.CertificateSubjectName;
+import netscape.security.x509.RevokedCertImpl;
+import netscape.security.x509.X509CertImpl;
+import netscape.security.x509.X509CertInfo;
+
/**
* Default testing stub for the IRequest interface.
*/
@@ -268,4 +268,13 @@ public class RequestDefaultStub implements IRequest {
public IAttrSet asIAttrSet() {
return null;
}
+
+ @Override
+ public String getRealm() {
+ return null;
+ }
+
+ @Override
+ public void setRealm(String realm) {
+ }
}