|
|
bdfa3c |
From 6b5c8073187a69c09000e88394465228f08d64be Mon Sep 17 00:00:00 2001
|
|
|
bdfa3c |
From: Christina Fu <cfu@redhat.com>
|
|
|
bdfa3c |
Date: Wed, 28 Apr 2021 16:26:46 -0700
|
|
|
bdfa3c |
Subject: [PATCH 1/4] Bug1911472 Revoke via REST API not working when Agent
|
|
|
bdfa3c |
certificate not issued by CA
|
|
|
bdfa3c |
|
|
|
bdfa3c |
This patch resolves the issue that when a client cert is issued by an
|
|
|
bdfa3c |
external CA, the revocation check inside the CA REST service handler
|
|
|
bdfa3c |
(ca/src/org/dogtagpki/server/ca/rest/CertService.java)
|
|
|
bdfa3c |
assumes that all client certs are issued by this CA.
|
|
|
bdfa3c |
The fix is to check the issuer, and add an option, allowExtCASignedAgentCerts
|
|
|
bdfa3c |
to allow for external CA signed agent certs.
|
|
|
bdfa3c |
If the issuer is external, and ca.allowExtCASignedAgentCerts is true, then the
|
|
|
bdfa3c |
internal cert status check is bypassed and to rely on OCSP enablement
|
|
|
bdfa3c |
(enableOCSP) in server.xml.
|
|
|
bdfa3c |
The ca.allowExtCASignedAgentCerts config param currently is only used in
|
|
|
bdfa3c |
the rest revocation case. It is not used anywhere else (not even unrevocation).
|
|
|
bdfa3c |
|
|
|
bdfa3c |
fixes https://bugzilla.redhat.com/show_bug.cgi?id=1911472
|
|
|
bdfa3c |
|
|
|
bdfa3c |
(cherry picked from commit 62f680f98e5bf9a3e6d44279fcc735e65c6d8d91)
|
|
|
bdfa3c |
---
|
|
|
bdfa3c |
.../src/com/netscape/ca/CertificateAuthority.java | 6 ++++
|
|
|
bdfa3c |
.../org/dogtagpki/server/ca/rest/CertService.java | 38 +++++++++++++++++++---
|
|
|
bdfa3c |
.../netscape/certsrv/ca/ICertificateAuthority.java | 2 ++
|
|
|
bdfa3c |
3 files changed, 41 insertions(+), 5 deletions(-)
|
|
|
bdfa3c |
|
|
|
bdfa3c |
diff --git a/base/ca/src/com/netscape/ca/CertificateAuthority.java b/base/ca/src/com/netscape/ca/CertificateAuthority.java
|
|
|
bdfa3c |
index bd99344..c519a5a 100644
|
|
|
bdfa3c |
--- a/base/ca/src/com/netscape/ca/CertificateAuthority.java
|
|
|
bdfa3c |
+++ b/base/ca/src/com/netscape/ca/CertificateAuthority.java
|
|
|
bdfa3c |
@@ -333,6 +333,7 @@ public class CertificateAuthority
|
|
|
bdfa3c |
|
|
|
bdfa3c |
private boolean mByName = true;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ private boolean mAllowExtCASignedAgentCerts = false;
|
|
|
bdfa3c |
private boolean mUseNonces = true;
|
|
|
bdfa3c |
private int mMaxNonces = 100;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
@@ -454,6 +455,10 @@ public class CertificateAuthority
|
|
|
bdfa3c |
return mPolicy.getPolicyProcessor();
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ public boolean allowExtCASignedAgentCerts() {
|
|
|
bdfa3c |
+ return mAllowExtCASignedAgentCerts;
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
public boolean noncesEnabled() {
|
|
|
bdfa3c |
return mUseNonces;
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
@@ -574,6 +579,7 @@ public class CertificateAuthority
|
|
|
bdfa3c |
if (initSigUnitSucceeded)
|
|
|
bdfa3c |
checkForNewerCert();
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ mAllowExtCASignedAgentCerts = mConfig.getBoolean("allowExtCASignedAgentCerts", false);
|
|
|
bdfa3c |
mUseNonces = mConfig.getBoolean("enableNonces", true);
|
|
|
bdfa3c |
mMaxNonces = mConfig.getInteger("maxNumberOfNonces", 100);
|
|
|
bdfa3c |
|
|
|
bdfa3c |
diff --git a/base/ca/src/org/dogtagpki/server/ca/rest/CertService.java b/base/ca/src/org/dogtagpki/server/ca/rest/CertService.java
|
|
|
bdfa3c |
index 000ce32..74d3a5d 100644
|
|
|
bdfa3c |
--- a/base/ca/src/org/dogtagpki/server/ca/rest/CertService.java
|
|
|
bdfa3c |
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/CertService.java
|
|
|
bdfa3c |
@@ -44,6 +44,7 @@ import netscape.security.x509.AlgorithmId;
|
|
|
bdfa3c |
import netscape.security.x509.CRLExtensions;
|
|
|
bdfa3c |
import netscape.security.x509.CRLReasonExtension;
|
|
|
bdfa3c |
import netscape.security.x509.RevocationReason;
|
|
|
bdfa3c |
+import netscape.security.x509.X500Name;
|
|
|
bdfa3c |
import netscape.security.x509.X509CertImpl;
|
|
|
bdfa3c |
import netscape.security.x509.X509ExtensionException;
|
|
|
bdfa3c |
import netscape.security.x509.X509Key;
|
|
|
bdfa3c |
@@ -172,6 +173,8 @@ public class CertService extends PKIService implements CertResource {
|
|
|
bdfa3c |
return unrevokeCert(id);
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ String caIssuerDN = null;
|
|
|
bdfa3c |
+ X500Name caX500DN = null;
|
|
|
bdfa3c |
RevocationProcessor processor;
|
|
|
bdfa3c |
try {
|
|
|
bdfa3c |
processor = new RevocationProcessor("caDoRevoke-agent", getLocale(headers));
|
|
|
bdfa3c |
@@ -190,6 +193,8 @@ public class CertService extends PKIService implements CertResource {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
processor.setAuthority(authority);
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ caX500DN = (X500Name) authority.getCACert().getIssuerDN();
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
} catch (EBaseException e) {
|
|
|
bdfa3c |
throw new PKIException(e.getMessage());
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
@@ -209,12 +214,35 @@ public class CertService extends PKIService implements CertResource {
|
|
|
bdfa3c |
if (clientCert != null) {
|
|
|
bdfa3c |
clientSerialNumber = clientCert.getSerialNumber();
|
|
|
bdfa3c |
clientSubjectDN = clientCert.getSubjectDN().toString();
|
|
|
bdfa3c |
- clientRecord = processor.getCertificateRecord(clientSerialNumber);
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- // Verify client cert is not revoked.
|
|
|
bdfa3c |
- // TODO: This should be checked during authentication.
|
|
|
bdfa3c |
- if (clientRecord.getStatus().equals(ICertRecord.STATUS_REVOKED)) {
|
|
|
bdfa3c |
- throw new UnauthorizedException(CMS.getLogMessage("CMSGW_UNAUTHORIZED"));
|
|
|
bdfa3c |
+ X500Name x500issuerDN = (X500Name) clientCert.getIssuerDN();
|
|
|
bdfa3c |
+ /*
|
|
|
bdfa3c |
+ * internal revocation check only to be conducted for certs
|
|
|
bdfa3c |
+ * issued by this CA
|
|
|
bdfa3c |
+ * For client certs issued by external CAs, TLS mutual auth
|
|
|
bdfa3c |
+ * would have completed the authenticaton/verification if
|
|
|
bdfa3c |
+ * OCSP was enabled;
|
|
|
bdfa3c |
+ * Furthermore, prior to the actual revocation, client cert
|
|
|
bdfa3c |
+ * is mapped against the agent group database for proper
|
|
|
bdfa3c |
+ * privilege regardless of the issuer.
|
|
|
bdfa3c |
+ */
|
|
|
bdfa3c |
+ if (x500issuerDN.equals(caX500DN)) {
|
|
|
bdfa3c |
+ CMS.debug("CertService.revokeCert: client cert issued by this CA");
|
|
|
bdfa3c |
+ clientRecord = processor.getCertificateRecord(clientSerialNumber);
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ // Verify client cert is not revoked.
|
|
|
bdfa3c |
+ // TODO: This should be checked during authentication.
|
|
|
bdfa3c |
+ if (clientRecord.getStatus().equals(ICertRecord.STATUS_REVOKED)) {
|
|
|
bdfa3c |
+ throw new UnauthorizedException(CMS.getLogMessage("CMSGW_UNAUTHORIZED"));
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+ } else {
|
|
|
bdfa3c |
+ CMS.debug("CertService.revokeCert: client cert not issued by this CA");
|
|
|
bdfa3c |
+ if (!authority.allowExtCASignedAgentCerts()) {
|
|
|
bdfa3c |
+ CMS.debug("CertService.revokeCert: allowExtCASignedAgentCerts false;");
|
|
|
bdfa3c |
+ throw new UnauthorizedException(CMS.getLogMessage("CMSGW_UNAUTHORIZED"));
|
|
|
bdfa3c |
+ } else {
|
|
|
bdfa3c |
+ CMS.debug("CertService.revokeCert: allowExtCASignedAgentCerts true;");
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
diff --git a/base/common/src/com/netscape/certsrv/ca/ICertificateAuthority.java b/base/common/src/com/netscape/certsrv/ca/ICertificateAuthority.java
|
|
|
bdfa3c |
index d941624..c5604e3 100644
|
|
|
bdfa3c |
--- a/base/common/src/com/netscape/certsrv/ca/ICertificateAuthority.java
|
|
|
bdfa3c |
+++ b/base/common/src/com/netscape/certsrv/ca/ICertificateAuthority.java
|
|
|
bdfa3c |
@@ -136,6 +136,8 @@ public interface ICertificateAuthority extends ISubsystem {
|
|
|
bdfa3c |
*/
|
|
|
bdfa3c |
public IPolicyProcessor getPolicyProcessor();
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ public boolean allowExtCASignedAgentCerts();
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
public boolean noncesEnabled();
|
|
|
bdfa3c |
|
|
|
bdfa3c |
public Map<Object, Long> getNonces(HttpServletRequest request, String name);
|
|
|
bdfa3c |
--
|
|
|
bdfa3c |
1.8.3.1
|
|
|
bdfa3c |
|
|
|
bdfa3c |
|
|
|
bdfa3c |
From a2599f832ed3036f84d507dce36548e0ca1351d0 Mon Sep 17 00:00:00 2001
|
|
|
bdfa3c |
From: Jack Magne <jmagne@test.host.com>
|
|
|
bdfa3c |
Date: Fri, 30 Apr 2021 20:10:58 -0400
|
|
|
bdfa3c |
Subject: [PATCH 2/4] Fix Bug #1955633 - Recovery of Keys migrated to latest
|
|
|
bdfa3c |
version of KRA fail to recover and result in Null Point Exception
|
|
|
bdfa3c |
[rhel-7.9.z]
|
|
|
bdfa3c |
|
|
|
bdfa3c |
This is a very simple fix to prevent the reported null pointer exception.
|
|
|
bdfa3c |
Checking in directly using the trivial checkin policy.
|
|
|
bdfa3c |
|
|
|
bdfa3c |
(cherry picked from commit c792a8545aecdb4ec17b1a18a401fcff288f877e)
|
|
|
bdfa3c |
---
|
|
|
bdfa3c |
base/server/cmscore/src/com/netscape/cmscore/dbs/KeyRecord.java | 4 ++++
|
|
|
bdfa3c |
1 file changed, 4 insertions(+)
|
|
|
bdfa3c |
|
|
|
bdfa3c |
diff --git a/base/server/cmscore/src/com/netscape/cmscore/dbs/KeyRecord.java b/base/server/cmscore/src/com/netscape/cmscore/dbs/KeyRecord.java
|
|
|
bdfa3c |
index 556c4a7..fd8fff9 100644
|
|
|
bdfa3c |
--- a/base/server/cmscore/src/com/netscape/cmscore/dbs/KeyRecord.java
|
|
|
bdfa3c |
+++ b/base/server/cmscore/src/com/netscape/cmscore/dbs/KeyRecord.java
|
|
|
bdfa3c |
@@ -506,6 +506,10 @@ public class KeyRecord implements IDBObj, IKeyRecord {
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
public Boolean isEncrypted() throws EBaseException {
|
|
|
bdfa3c |
+ if(mMetaInfo == null) {
|
|
|
bdfa3c |
+ return null;
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
String encrypted = (String) mMetaInfo.get(KeyRecordParser.OUT_PL_ENCRYPTED);
|
|
|
bdfa3c |
if (encrypted == null)
|
|
|
bdfa3c |
return null;
|
|
|
bdfa3c |
--
|
|
|
bdfa3c |
1.8.3.1
|
|
|
bdfa3c |
|
|
|
bdfa3c |
|
|
|
bdfa3c |
From 201cef17ad2a6fcc84277b9a62c7e986212c0622 Mon Sep 17 00:00:00 2001
|
|
|
bdfa3c |
From: jmagne <jmagne@redhat.com>
|
|
|
bdfa3c |
Date: Thu, 6 May 2021 17:17:37 -0700
|
|
|
bdfa3c |
Subject: [PATCH 3/4] Fix: Bug 1942687 - TPS not populating Token Policy, or
|
|
|
bdfa3c |
switching PIN_RESET=YES to NO . (#3510)
|
|
|
bdfa3c |
|
|
|
bdfa3c |
Now the behavior will be the following:
|
|
|
bdfa3c |
|
|
|
bdfa3c |
When a new token entry gets created in the token db, due to a token operation such
|
|
|
bdfa3c |
as format or enrollment, the db entry will get populated with the contents of the
|
|
|
bdfa3c |
CS.cfg value:
|
|
|
bdfa3c |
ex:
|
|
|
bdfa3c |
tokendb.defaultPolicy=RE_ENROLL=YES;RENEW=NO;FORCE_FORMAT=NO;PIN_RESET=NO;RESET_PIN_RESET_TO_NO=NO
|
|
|
bdfa3c |
|
|
|
bdfa3c |
Now the value of RESET_PIN_RESET_TO_NO is actually observed.
|
|
|
bdfa3c |
If this value is set to YES and pin reset is allowed, after a successful pin reset,
|
|
|
bdfa3c |
the value of PIN_RESET will be set to NO, thus not allowing further pin resets on this
|
|
|
bdfa3c |
token, until the value is manually changed in the token db entry.
|
|
|
bdfa3c |
|
|
|
bdfa3c |
Also, the class itself has been simplified to allow the cuid token number at constructor
|
|
|
bdfa3c |
time. Now if another token is desired , we must instantiate a new TPSTokenPolicy object for
|
|
|
bdfa3c |
that additional token.
|
|
|
bdfa3c |
|
|
|
bdfa3c |
Co-authored-by: Jack Magne <jmagne@test.host.com>
|
|
|
bdfa3c |
(cherry picked from commit 5f25323a9098af496196dbff0e7f0e89ee7621de)
|
|
|
bdfa3c |
---
|
|
|
bdfa3c |
.../org/dogtagpki/server/tps/TPSTokenPolicy.java | 133 ++++++++++++++++++---
|
|
|
bdfa3c |
.../src/org/dogtagpki/server/tps/TPSTokendb.java | 4 +
|
|
|
bdfa3c |
.../server/tps/processor/TPSEnrollProcessor.java | 23 ++--
|
|
|
bdfa3c |
.../server/tps/processor/TPSPinResetProcessor.java | 14 ++-
|
|
|
bdfa3c |
.../server/tps/processor/TPSProcessor.java | 21 ++++
|
|
|
bdfa3c |
5 files changed, 165 insertions(+), 30 deletions(-)
|
|
|
bdfa3c |
|
|
|
bdfa3c |
diff --git a/base/tps/src/org/dogtagpki/server/tps/TPSTokenPolicy.java b/base/tps/src/org/dogtagpki/server/tps/TPSTokenPolicy.java
|
|
|
bdfa3c |
index 4d7af48..685319e 100644
|
|
|
bdfa3c |
--- a/base/tps/src/org/dogtagpki/server/tps/TPSTokenPolicy.java
|
|
|
bdfa3c |
+++ b/base/tps/src/org/dogtagpki/server/tps/TPSTokenPolicy.java
|
|
|
bdfa3c |
@@ -40,18 +40,31 @@ public class TPSTokenPolicy {
|
|
|
bdfa3c |
private boolean force_format = false;
|
|
|
bdfa3c |
private boolean pin_reset = true;
|
|
|
bdfa3c |
private boolean reset_pin_reset_to_no = false;
|
|
|
bdfa3c |
+ private String cuid = null;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- public TPSTokenPolicy (TPSSubsystem tps) throws TPSException {
|
|
|
bdfa3c |
+ //Construct with a single token in mind. Load the token's config from
|
|
|
bdfa3c |
+ //the db after the default. All operations will then be on this token.
|
|
|
bdfa3c |
+ //
|
|
|
bdfa3c |
+ public TPSTokenPolicy (TPSSubsystem tps,String cuid) throws TPSException {
|
|
|
bdfa3c |
if (tps == null) {
|
|
|
bdfa3c |
String msg = "TPSTokenPolicy.TPSTokenPolicy: tps cannnot be null";
|
|
|
bdfa3c |
CMS.debug(msg);
|
|
|
bdfa3c |
throw new TPSException(msg);
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
+ if (cuid == null) {
|
|
|
bdfa3c |
+ String msg = "TPSTokenPolicy.TPSTokenPolicy: cuid cannnot be null";
|
|
|
bdfa3c |
+ CMS.debug(msg);
|
|
|
bdfa3c |
+ throw new TPSException(msg);
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
this.tps = tps;
|
|
|
bdfa3c |
- // init from config first
|
|
|
bdfa3c |
+ // Get the CS.cfg defaults first
|
|
|
bdfa3c |
String policySetString = getDefaultPolicySetString();
|
|
|
bdfa3c |
parsePolicySetString(policySetString);
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ this.cuid = cuid;
|
|
|
bdfa3c |
+ //Read from the token db once and write at the end if needed
|
|
|
bdfa3c |
+ getUpdatedPolicy();
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
public String getDefaultPolicySetString() {
|
|
|
bdfa3c |
@@ -92,6 +105,41 @@ public class TPSTokenPolicy {
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ /* Take the current state of the policyt variables, create a new policy string,
|
|
|
bdfa3c |
+ * and write the new value for the provided token cuid.
|
|
|
bdfa3c |
+ */
|
|
|
bdfa3c |
+ public void updatePolicySet() throws TPSException {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ String method = "TPSTokenPolicy.updatePolicySet: ";
|
|
|
bdfa3c |
+ String msg = method + "Can't update token policy string to database.";
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ TokenRecord tokenRecord = null;
|
|
|
bdfa3c |
+ String policySetString = null;
|
|
|
bdfa3c |
+ try {
|
|
|
bdfa3c |
+ tokenRecord = tps.tdb.tdbGetTokenEntry(this.cuid);
|
|
|
bdfa3c |
+ } catch (Exception e) {
|
|
|
bdfa3c |
+ throw new TPSException(e.toString() + " " + msg);
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ String newPolicy = "";
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ newPolicy += "RE_ENROLL=" + getFromBool(re_enroll);
|
|
|
bdfa3c |
+ newPolicy += ";RENEW=" + getFromBool(renew);
|
|
|
bdfa3c |
+ newPolicy += ";FORCE_FORMAT=" + getFromBool(force_format);
|
|
|
bdfa3c |
+ newPolicy += ";PIN_RESET=" + getFromBool(pin_reset);
|
|
|
bdfa3c |
+ newPolicy += ";RESET_PIN_RESET_TO_NO=" + getFromBool(reset_pin_reset_to_no);
|
|
|
bdfa3c |
+ newPolicy += ";RENEW_KEEP_OLD_ENC_CERTS=" + getFromBool(renew_keep_old_enc_certs);
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ CMS.debug(method + "newPolicy: " + newPolicy);
|
|
|
bdfa3c |
+ tokenRecord.setPolicy(newPolicy);
|
|
|
bdfa3c |
+ try {
|
|
|
bdfa3c |
+ tps.tdb.tdbUpdateTokenEntry(tokenRecord);
|
|
|
bdfa3c |
+ } catch(Exception e) {
|
|
|
bdfa3c |
+ throw new TPSException(e.toString() + " " + msg);
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
/*
|
|
|
bdfa3c |
* getBool translates string to boolean:
|
|
|
bdfa3c |
* true: "YES", "yes", "TRUE", "true"
|
|
|
bdfa3c |
@@ -114,12 +162,19 @@ public class TPSTokenPolicy {
|
|
|
bdfa3c |
return defaultBool;
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- private void getUpdatedPolicy(String cuid) {
|
|
|
bdfa3c |
+ private String getFromBool(boolean value) {
|
|
|
bdfa3c |
+ if(value == true)
|
|
|
bdfa3c |
+ return "YES";
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ return "NO";
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ private void getUpdatedPolicy() {
|
|
|
bdfa3c |
// note: default policy already initialized in the constructor
|
|
|
bdfa3c |
TokenRecord tokenRecord = null;
|
|
|
bdfa3c |
String policySetString = null;
|
|
|
bdfa3c |
try {
|
|
|
bdfa3c |
- tokenRecord = tps.tdb.tdbGetTokenEntry(cuid);
|
|
|
bdfa3c |
+ tokenRecord = tps.tdb.tdbGetTokenEntry(this.cuid);
|
|
|
bdfa3c |
} catch (Exception e) {
|
|
|
bdfa3c |
// just take the default;
|
|
|
bdfa3c |
return;
|
|
|
bdfa3c |
@@ -129,38 +184,82 @@ public class TPSTokenPolicy {
|
|
|
bdfa3c |
parsePolicySetString(policySetString);
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- public boolean isAllowedTokenPinReset(String cuid) {
|
|
|
bdfa3c |
- getUpdatedPolicy(cuid);
|
|
|
bdfa3c |
+ // Note we only want to allow one cuid to be operated upon
|
|
|
bdfa3c |
+ // by this class, since we are going to allow values to be changed
|
|
|
bdfa3c |
+ // as well as written.
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ public boolean isAllowedTokenPinReset() {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ return reset_pin_reset_to_no;
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ // Add better named version to get the value
|
|
|
bdfa3c |
+ // reset_pin_reset_to_no
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ public boolean isAllowedResetPinResetToNo() {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
return reset_pin_reset_to_no;
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- public boolean isAllowedPinReset(String cuid) {
|
|
|
bdfa3c |
- getUpdatedPolicy(cuid);
|
|
|
bdfa3c |
+ public boolean isAllowedPinReset() {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
return pin_reset;
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- public boolean isForceTokenFormat(String cuid) {
|
|
|
bdfa3c |
- getUpdatedPolicy(cuid);
|
|
|
bdfa3c |
+ public boolean isForceTokenFormat() {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
return force_format;
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- public boolean isAllowdTokenReenroll(String cuid) {
|
|
|
bdfa3c |
- getUpdatedPolicy(cuid);
|
|
|
bdfa3c |
+ public boolean isAllowdTokenReenroll() {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
return re_enroll;
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- public boolean isAllowdRenewSaveOldEncCerts(String cuid) {
|
|
|
bdfa3c |
- getUpdatedPolicy(cuid);
|
|
|
bdfa3c |
+ public boolean isAllowdRenewSaveOldEncCerts() {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
return renew_keep_old_enc_certs;
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- public boolean isAllowdTokenRenew(String cuid) {
|
|
|
bdfa3c |
- getUpdatedPolicy(cuid);
|
|
|
bdfa3c |
+ public boolean isAllowdTokenRenew() {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
return renew;
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
-}
|
|
|
bdfa3c |
\ No newline at end of file
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ public void setAllowedTokenPinReset(boolean value) {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ reset_pin_reset_to_no = value;
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ public void setAllowedResetPinResetToNo(boolean value) {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ reset_pin_reset_to_no = value;
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ public void setAllowedPinReset(boolean value) {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ pin_reset = value;
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ public void setForceTokenFormat(boolean value) {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ force_format = value;
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ public void setAllowdTokenReenroll(boolean value) {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ re_enroll = value;
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ public void setAllowdRenewSaveOldEncCerts(boolean value) {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ renew_keep_old_enc_certs = value;
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ public void setAllowdTokenRenew(boolean value) {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ renew = value;
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+}
|
|
|
bdfa3c |
diff --git a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
|
|
|
bdfa3c |
index 7434502..b58c24f 100644
|
|
|
bdfa3c |
--- a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
|
|
|
bdfa3c |
+++ b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
|
|
|
bdfa3c |
@@ -200,9 +200,13 @@ public class TPSTokendb {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
public void tdbAddTokenEntry(TokenRecord tokenRecord, TokenStatus status)
|
|
|
bdfa3c |
throws Exception {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ String method = "TPSTokendb.tdbAddTokenEntry: ";
|
|
|
bdfa3c |
tokenRecord.setTokenStatus(status);
|
|
|
bdfa3c |
|
|
|
bdfa3c |
tps.tokenDatabase.addRecord(tokenRecord.getId(), tokenRecord);
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ CMS.debug(method + "Added tokenRecord.");
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
public void tdbUpdateTokenEntry(TokenRecord tokenRecord)
|
|
|
bdfa3c |
diff --git a/base/tps/src/org/dogtagpki/server/tps/processor/TPSEnrollProcessor.java b/base/tps/src/org/dogtagpki/server/tps/processor/TPSEnrollProcessor.java
|
|
|
bdfa3c |
index 5175344..2d8c89f 100644
|
|
|
bdfa3c |
--- a/base/tps/src/org/dogtagpki/server/tps/processor/TPSEnrollProcessor.java
|
|
|
bdfa3c |
+++ b/base/tps/src/org/dogtagpki/server/tps/processor/TPSEnrollProcessor.java
|
|
|
bdfa3c |
@@ -95,7 +95,7 @@ public class TPSEnrollProcessor extends TPSProcessor {
|
|
|
bdfa3c |
String logMsg = null;
|
|
|
bdfa3c |
String auditInfo = null;
|
|
|
bdfa3c |
TPSSubsystem tps = (TPSSubsystem) CMS.getSubsystem(TPSSubsystem.ID);
|
|
|
bdfa3c |
- TPSTokenPolicy tokenPolicy = new TPSTokenPolicy(tps);
|
|
|
bdfa3c |
+ TPSTokenPolicy tokenPolicy = null;
|
|
|
bdfa3c |
IConfigStore configStore = CMS.getConfigStore();
|
|
|
bdfa3c |
String configName;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
@@ -128,12 +128,13 @@ public class TPSEnrollProcessor extends TPSProcessor {
|
|
|
bdfa3c |
tokenRecord = isTokenRecordPresent(appletInfo);
|
|
|
bdfa3c |
|
|
|
bdfa3c |
if (tokenRecord != null) {
|
|
|
bdfa3c |
- CMS.debug(method + " found token...");
|
|
|
bdfa3c |
+ CMS.debug(method + " found token... policy: " + tokenRecord.getPolicy());
|
|
|
bdfa3c |
isTokenPresent = true;
|
|
|
bdfa3c |
} else {
|
|
|
bdfa3c |
CMS.debug(method + " token does not exist in tokendb... create one in memory");
|
|
|
bdfa3c |
tokenRecord = new TokenRecord();
|
|
|
bdfa3c |
tokenRecord.setId(appletInfo.getCUIDhexStringPlain());
|
|
|
bdfa3c |
+ fillTokenRecordDefaultPolicy(tokenRecord);
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
fillTokenRecord(tokenRecord, appletInfo);
|
|
|
bdfa3c |
@@ -332,13 +333,14 @@ public class TPSEnrollProcessor extends TPSProcessor {
|
|
|
bdfa3c |
" to " + newState);
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- do_force_format = tokenPolicy.isForceTokenFormat(cuid);
|
|
|
bdfa3c |
+ tokenPolicy = new TPSTokenPolicy(tps,cuid);
|
|
|
bdfa3c |
+ do_force_format = tokenPolicy.isForceTokenFormat();
|
|
|
bdfa3c |
if (do_force_format)
|
|
|
bdfa3c |
CMS.debug(method + " Will force format first due to policy.");
|
|
|
bdfa3c |
|
|
|
bdfa3c |
if (!isExternalReg &&
|
|
|
bdfa3c |
- !tokenPolicy.isAllowdTokenReenroll(cuid) &&
|
|
|
bdfa3c |
- !tokenPolicy.isAllowdTokenRenew(cuid)) {
|
|
|
bdfa3c |
+ !tokenPolicy.isAllowdTokenReenroll() &&
|
|
|
bdfa3c |
+ !tokenPolicy.isAllowdTokenRenew()) {
|
|
|
bdfa3c |
CMS.debug(method + " token renewal or reEnroll disallowed ");
|
|
|
bdfa3c |
logMsg = "Operation renewal or reEnroll for CUID " + cuid +
|
|
|
bdfa3c |
" Disabled";
|
|
|
bdfa3c |
@@ -524,7 +526,7 @@ public class TPSEnrollProcessor extends TPSProcessor {
|
|
|
bdfa3c |
// at this point, enrollment, renewal, or recovery have been processed accordingly;
|
|
|
bdfa3c |
if (!isExternalReg &&
|
|
|
bdfa3c |
status == TPSStatus.STATUS_RENEWAL_IS_PROCESSED &&
|
|
|
bdfa3c |
- tokenPolicy.isAllowdTokenRenew(cuid)) {
|
|
|
bdfa3c |
+ tokenPolicy.isAllowdTokenRenew()) {
|
|
|
bdfa3c |
renewed = true;
|
|
|
bdfa3c |
CMS.debug(method + " renewal happened.. ");
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
@@ -1110,7 +1112,7 @@ public class TPSEnrollProcessor extends TPSProcessor {
|
|
|
bdfa3c |
IConfigStore configStore = CMS.getConfigStore();
|
|
|
bdfa3c |
String configName;
|
|
|
bdfa3c |
TPSSubsystem tps = (TPSSubsystem) CMS.getSubsystem(TPSSubsystem.ID);
|
|
|
bdfa3c |
- TPSTokenPolicy tokenPolicy = new TPSTokenPolicy(tps);
|
|
|
bdfa3c |
+ TPSTokenPolicy tokenPolicy = null;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
ArrayList<TokenRecord> tokenRecords = null;
|
|
|
bdfa3c |
try {
|
|
|
bdfa3c |
@@ -1157,7 +1159,8 @@ public class TPSEnrollProcessor extends TPSProcessor {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
} else if (tokenRecord.getTokenStatus() == TokenStatus.ACTIVE) {
|
|
|
bdfa3c |
// current token is already active; renew if allowed
|
|
|
bdfa3c |
- if (tokenPolicy.isAllowdTokenRenew(aInfo.getCUIDhexStringPlain())) {
|
|
|
bdfa3c |
+ tokenPolicy = new TPSTokenPolicy(tps,aInfo.getCUIDhexStringPlain());
|
|
|
bdfa3c |
+ if (tokenPolicy.isAllowdTokenRenew()) {
|
|
|
bdfa3c |
return processRenewal(certsInfo, channel, aInfo, tokenRecord);
|
|
|
bdfa3c |
} else {
|
|
|
bdfa3c |
logMsg = "token is already active; can't renew because renewal is not allowed; will re-enroll if allowed";
|
|
|
bdfa3c |
@@ -1658,9 +1661,9 @@ public class TPSEnrollProcessor extends TPSProcessor {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
//See if policy calls for this feature
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- TPSTokenPolicy tokenPolicy = new TPSTokenPolicy(tps);
|
|
|
bdfa3c |
+ TPSTokenPolicy tokenPolicy = new TPSTokenPolicy(tps,tokenRecord.getId());
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- boolean recoverOldEncCerts = tokenPolicy.isAllowdRenewSaveOldEncCerts(tokenRecord.getId());
|
|
|
bdfa3c |
+ boolean recoverOldEncCerts = tokenPolicy.isAllowdRenewSaveOldEncCerts();
|
|
|
bdfa3c |
CMS.debug(method + " Recover Old Encryption Certs for Renewed Certs: " + recoverOldEncCerts);
|
|
|
bdfa3c |
if (oldEncCertsToRecover.size() > 0 && recoverOldEncCerts == true) {
|
|
|
bdfa3c |
CMS.debug("About to attempt to recover old encryption certs just renewed.");
|
|
|
bdfa3c |
diff --git a/base/tps/src/org/dogtagpki/server/tps/processor/TPSPinResetProcessor.java b/base/tps/src/org/dogtagpki/server/tps/processor/TPSPinResetProcessor.java
|
|
|
bdfa3c |
index 805af20..2ee9186 100644
|
|
|
bdfa3c |
--- a/base/tps/src/org/dogtagpki/server/tps/processor/TPSPinResetProcessor.java
|
|
|
bdfa3c |
+++ b/base/tps/src/org/dogtagpki/server/tps/processor/TPSPinResetProcessor.java
|
|
|
bdfa3c |
@@ -121,14 +121,14 @@ public class TPSPinResetProcessor extends TPSProcessor {
|
|
|
bdfa3c |
TPSStatus.STATUS_ERROR_UNKNOWN_TOKEN);
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- TPSTokenPolicy tokenPolicy = new TPSTokenPolicy(tps);
|
|
|
bdfa3c |
-
|
|
|
bdfa3c |
fillTokenRecord(tokenRecord, appletInfo);
|
|
|
bdfa3c |
session.setTokenRecord(tokenRecord);
|
|
|
bdfa3c |
|
|
|
bdfa3c |
String cuid = appletInfo.getCUIDhexStringPlain();
|
|
|
bdfa3c |
String tokenType = null;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ TPSTokenPolicy tokenPolicy = new TPSTokenPolicy(tps,cuid);
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
if(isExternalReg) {
|
|
|
bdfa3c |
CMS.debug(method + " isExternalReg: ON");
|
|
|
bdfa3c |
|
|
|
bdfa3c |
@@ -309,7 +309,7 @@ public class TPSPinResetProcessor extends TPSProcessor {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- boolean pinResetAllowed = tokenPolicy.isAllowedPinReset(tokenRecord.getId());
|
|
|
bdfa3c |
+ boolean pinResetAllowed = tokenPolicy.isAllowedPinReset();
|
|
|
bdfa3c |
|
|
|
bdfa3c |
CMS.debug(method + ": PinResetPolicy: Pin Reset Allowed: " + pinResetAllowed);
|
|
|
bdfa3c |
logMsg = method + " PinReset Policy forbids pin reset operation.";
|
|
|
bdfa3c |
@@ -362,6 +362,14 @@ public class TPSPinResetProcessor extends TPSProcessor {
|
|
|
bdfa3c |
throw new TPSException(logMsg, TPSStatus.STATUS_ERROR_UPDATE_TOKENDB_FAILED);
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ //If policy tells us to disallow pin reset after
|
|
|
bdfa3c |
+ //a successfull pin reset, do so.
|
|
|
bdfa3c |
+ //
|
|
|
bdfa3c |
+ if(tokenPolicy.isAllowedResetPinResetToNo()) {
|
|
|
bdfa3c |
+ tokenPolicy.setAllowedPinReset(false);
|
|
|
bdfa3c |
+ tokenPolicy.updatePolicySet();
|
|
|
bdfa3c |
+ CMS.debug(method + ": Updating pin reset policy to NO.");
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
CMS.debug(method + ": Token Pin successfully reset!");
|
|
|
bdfa3c |
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
diff --git a/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java b/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java
|
|
|
bdfa3c |
index baf0671..cadab1d 100644
|
|
|
bdfa3c |
--- a/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java
|
|
|
bdfa3c |
+++ b/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java
|
|
|
bdfa3c |
@@ -1531,6 +1531,26 @@ public class TPSProcessor {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ protected void fillTokenRecordDefaultPolicy(TokenRecord tokenRecord) throws TPSException {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ String method = "TPSProcessor.fillTokenRecordDefaultPolicy: ";
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ try {
|
|
|
bdfa3c |
+ IConfigStore configStore = CMS.getConfigStore();
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ String config = "tokendb.defaultPolicy";
|
|
|
bdfa3c |
+ String defaultPolicy = configStore.getString(config);
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ CMS.debug(method + " default token policy: " + defaultPolicy);
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ tokenRecord.setPolicy(defaultPolicy);
|
|
|
bdfa3c |
+ } catch (Exception e) {
|
|
|
bdfa3c |
+ CMS.debug(method + "Problem with adding the default policy to the token.");
|
|
|
bdfa3c |
+ throw new TPSException(e.toString(),TPSStatus.STATUS_ERROR_MISCONFIGURATION);
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
protected TokenRecord isTokenRecordPresent(AppletInfo appletInfo) throws TPSException {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
if (appletInfo == null) {
|
|
|
bdfa3c |
@@ -2353,6 +2373,7 @@ public class TPSProcessor {
|
|
|
bdfa3c |
try {
|
|
|
bdfa3c |
tps.tdb.tdbAddTokenEntry(tokenRecord, TokenStatus.UNFORMATTED);
|
|
|
bdfa3c |
tps.tdb.tdbActivity(ActivityDatabase.OP_ADD, tokenRecord, session.getIpAddress(), logMsg, "success");
|
|
|
bdfa3c |
+ fillTokenRecordDefaultPolicy(tokenRecord);
|
|
|
bdfa3c |
CMS.debug("TPSProcessor.format: token added");
|
|
|
bdfa3c |
} catch (Exception e) {
|
|
|
bdfa3c |
logMsg = logMsg + ":" + e.toString();
|
|
|
bdfa3c |
--
|
|
|
bdfa3c |
1.8.3.1
|
|
|
bdfa3c |
|
|
|
bdfa3c |
From e83bcc4f045bd6ad43798ff38306ab3c4bc4a52d Mon Sep 17 00:00:00 2001
|
|
|
bdfa3c |
From: Chris Kelley <ckelley@redhat.com>
|
|
|
bdfa3c |
Date: Fri, 7 May 2021 14:05:18 +0100
|
|
|
bdfa3c |
Subject: [PATCH 4/4] Prevent debug exception when product version not found
|
|
|
bdfa3c |
|
|
|
bdfa3c |
Resolves: #1914587
|
|
|
bdfa3c |
(cherry picked from commit d86eefb661766342a4473c699dc6687986420161)
|
|
|
bdfa3c |
---
|
|
|
bdfa3c |
base/common/src/com/netscape/certsrv/apps/CMS.java | 18 ++++++++
|
|
|
bdfa3c |
.../netscape/cms/servlet/csadmin/GetStatus.java | 51 +++-------------------
|
|
|
bdfa3c |
2 files changed, 23 insertions(+), 46 deletions(-)
|
|
|
bdfa3c |
|
|
|
bdfa3c |
diff --git a/base/common/src/com/netscape/certsrv/apps/CMS.java b/base/common/src/com/netscape/certsrv/apps/CMS.java
|
|
|
bdfa3c |
index 1dace42..e852043 100644
|
|
|
bdfa3c |
--- a/base/common/src/com/netscape/certsrv/apps/CMS.java
|
|
|
bdfa3c |
+++ b/base/common/src/com/netscape/certsrv/apps/CMS.java
|
|
|
bdfa3c |
@@ -17,7 +17,9 @@
|
|
|
bdfa3c |
// --- END COPYRIGHT BLOCK ---
|
|
|
bdfa3c |
package com.netscape.certsrv.apps;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+import java.io.File;
|
|
|
bdfa3c |
import java.math.BigInteger;
|
|
|
bdfa3c |
+import java.nio.file.Files;
|
|
|
bdfa3c |
import java.security.NoSuchAlgorithmException;
|
|
|
bdfa3c |
import java.security.cert.Certificate;
|
|
|
bdfa3c |
import java.security.cert.CertificateEncodingException;
|
|
|
bdfa3c |
@@ -135,6 +137,7 @@ public final class CMS {
|
|
|
bdfa3c |
public static final String SUBSYSTEM_SELFTESTS = ISelfTestSubsystem.ID;
|
|
|
bdfa3c |
public static final int PRE_OP_MODE = 0;
|
|
|
bdfa3c |
public static final int RUNNING_MODE = 1;
|
|
|
bdfa3c |
+ private static final String PRODUCT_NAME_FILE = "/usr/share/pki/CS_SERVER_VERSION";
|
|
|
bdfa3c |
|
|
|
bdfa3c |
/**
|
|
|
bdfa3c |
* Private constructor.
|
|
|
bdfa3c |
@@ -1519,6 +1522,21 @@ public final class CMS {
|
|
|
bdfa3c |
_engine.sleepOneMinute();
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+ /**
|
|
|
bdfa3c |
+ * Return the product name from /usr/share/pki/CS_SERVER_VERSION
|
|
|
bdfa3c |
+ * which is provided by the server theme package.
|
|
|
bdfa3c |
+ */
|
|
|
bdfa3c |
+ public static String getProductName() throws Exception {
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ File file = new File(PRODUCT_NAME_FILE);
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ if (!file.exists()) {
|
|
|
bdfa3c |
+ return null;
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
+ return new String(Files.readAllBytes(file.toPath())).trim();
|
|
|
bdfa3c |
+ }
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
public static boolean isExcludedLdapAttrsEnabled() {
|
|
|
bdfa3c |
return _engine.isExcludedLdapAttrsEnabled();
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/GetStatus.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/GetStatus.java
|
|
|
bdfa3c |
index 1cb8a4c..8f6d340 100644
|
|
|
bdfa3c |
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/GetStatus.java
|
|
|
bdfa3c |
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/GetStatus.java
|
|
|
bdfa3c |
@@ -18,7 +18,6 @@
|
|
|
bdfa3c |
package com.netscape.cms.servlet.csadmin;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
import java.io.IOException;
|
|
|
bdfa3c |
-import java.io.FileInputStream;
|
|
|
bdfa3c |
import java.util.Locale;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
import javax.servlet.ServletConfig;
|
|
|
bdfa3c |
@@ -26,6 +25,7 @@ import javax.servlet.ServletException;
|
|
|
bdfa3c |
import javax.servlet.http.HttpServletRequest;
|
|
|
bdfa3c |
import javax.servlet.http.HttpServletResponse;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
+import org.apache.commons.lang.StringUtils;
|
|
|
bdfa3c |
import org.w3c.dom.Node;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
import com.netscape.certsrv.apps.CMS;
|
|
|
bdfa3c |
@@ -35,8 +35,6 @@ import com.netscape.cms.servlet.base.CMSServlet;
|
|
|
bdfa3c |
import com.netscape.cms.servlet.base.UserInfo;
|
|
|
bdfa3c |
import com.netscape.cms.servlet.common.CMSRequest;
|
|
|
bdfa3c |
import com.netscape.cmsutil.xml.XMLObject;
|
|
|
bdfa3c |
-import org.apache.commons.io.IOUtils;
|
|
|
bdfa3c |
-import org.apache.commons.lang.StringUtils;
|
|
|
bdfa3c |
|
|
|
bdfa3c |
public class GetStatus extends CMSServlet {
|
|
|
bdfa3c |
|
|
|
bdfa3c |
@@ -44,8 +42,6 @@ public class GetStatus extends CMSServlet {
|
|
|
bdfa3c |
*
|
|
|
bdfa3c |
*/
|
|
|
bdfa3c |
private static final long serialVersionUID = -2852842030221659847L;
|
|
|
bdfa3c |
- // File below will be a member of a pki theme package.
|
|
|
bdfa3c |
- private static final String productVersionFILE = "/usr/share/pki/CS_SERVER_VERSION";
|
|
|
bdfa3c |
|
|
|
bdfa3c |
public GetStatus() {
|
|
|
bdfa3c |
super();
|
|
|
bdfa3c |
@@ -85,13 +81,13 @@ public class GetStatus extends CMSServlet {
|
|
|
bdfa3c |
xmlObj.addItemToContainer(root, "Type", type);
|
|
|
bdfa3c |
xmlObj.addItemToContainer(root, "Status", status);
|
|
|
bdfa3c |
xmlObj.addItemToContainer(root, "Version", version);
|
|
|
bdfa3c |
+
|
|
|
bdfa3c |
// File below will be a member of a pki theme package.
|
|
|
bdfa3c |
- String productVersion = getProductVersion(productVersionFILE);
|
|
|
bdfa3c |
+ String productName = CMS.getProductName();
|
|
|
bdfa3c |
|
|
|
bdfa3c |
- if(!StringUtils.isEmpty(productVersion)) {
|
|
|
bdfa3c |
- xmlObj.addItemToContainer(root,"ProductVersion", productVersion);
|
|
|
bdfa3c |
+ if (!StringUtils.isEmpty(productName)) {
|
|
|
bdfa3c |
+ xmlObj.addItemToContainer(root, "ProductVersion", productName);
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
-
|
|
|
bdfa3c |
byte[] cb = xmlObj.toByteArray();
|
|
|
bdfa3c |
|
|
|
bdfa3c |
outputResult(httpResp, "application/xml", cb);
|
|
|
bdfa3c |
@@ -119,41 +115,4 @@ public class GetStatus extends CMSServlet {
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
return locale;
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
-
|
|
|
bdfa3c |
- /**
|
|
|
bdfa3c |
- * Return the product version if the file: /usr/share/pki/CS_SERVER_VERSION
|
|
|
bdfa3c |
- * exists.
|
|
|
bdfa3c |
- *
|
|
|
bdfa3c |
- * Caller only cares if there is a string or not, exceptions handled here.
|
|
|
bdfa3c |
- */
|
|
|
bdfa3c |
- private String getProductVersion(String versionFilePathName) {
|
|
|
bdfa3c |
- String version = null;
|
|
|
bdfa3c |
- FileInputStream inputStream = null;
|
|
|
bdfa3c |
-
|
|
|
bdfa3c |
- if(StringUtils.isEmpty(versionFilePathName)) {
|
|
|
bdfa3c |
- CMS.debug("Missing product version file path!");
|
|
|
bdfa3c |
- return null;
|
|
|
bdfa3c |
- }
|
|
|
bdfa3c |
-
|
|
|
bdfa3c |
- try {
|
|
|
bdfa3c |
- inputStream = new FileInputStream(versionFilePathName);
|
|
|
bdfa3c |
- String contents = IOUtils.toString(inputStream);
|
|
|
bdfa3c |
-
|
|
|
bdfa3c |
- if(contents != null) {
|
|
|
bdfa3c |
- CMS.debug("Returning product version: " + version);
|
|
|
bdfa3c |
- version = contents.trim();
|
|
|
bdfa3c |
- }
|
|
|
bdfa3c |
- } catch (Exception e) {
|
|
|
bdfa3c |
- CMS.debug("Failed to read product version String. " + e);
|
|
|
bdfa3c |
- }
|
|
|
bdfa3c |
- finally {
|
|
|
bdfa3c |
- if(inputStream != null) {
|
|
|
bdfa3c |
- try {
|
|
|
bdfa3c |
- inputStream.close();
|
|
|
bdfa3c |
- } catch (IOException e) {
|
|
|
bdfa3c |
- }
|
|
|
bdfa3c |
- }
|
|
|
bdfa3c |
- }
|
|
|
bdfa3c |
- return version;
|
|
|
bdfa3c |
- }
|
|
|
bdfa3c |
}
|
|
|
bdfa3c |
--
|
|
|
bdfa3c |
1.8.3.1
|
|
|
bdfa3c |
|