The ConfigurationRequest.TOKEN_DEFAULT has been replaced with
CryptoUtil.INTERNAL_TOKEN_FULL_NAME since they are identical.

https://fedorahosted.org/pki/ticket/2556

Pushed to master under trivial rule.

--
Endi S. Dewata
>From 5e39d36196f06ebaa8dcf943ec4c19bcbb9c25b0 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <[email protected]>
Date: Sat, 21 Jan 2017 00:58:28 +0100
Subject: [PATCH] Refactored ConfigurationRequest.TOKEN_DEFAULT.

The ConfigurationRequest.TOKEN_DEFAULT has been replaced with
CryptoUtil.INTERNAL_TOKEN_FULL_NAME since they are identical.

https://fedorahosted.org/pki/ticket/2556
---
 .../netscape/cms/servlet/test/ConfigurationTest.java    | 17 +++++++++--------
 .../netscape/certsrv/system/ConfigurationRequest.java   |  5 +++--
 .../org/dogtagpki/server/rest/SystemConfigService.java  | 10 +++++-----
 .../dogtagpki/server/tps/rest/TPSInstallerService.java  |  3 ++-
 4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java b/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java
index 69994fa389d31f15e314feba6bfbd3d4803622ba..0416853da58666c4067751a711a61f5d2f7db23f 100644
--- a/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java
+++ b/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java
@@ -62,6 +62,7 @@ import com.netscape.certsrv.system.ConfigurationRequest;
 import com.netscape.certsrv.system.ConfigurationResponse;
 import com.netscape.certsrv.system.SystemCertData;
 import com.netscape.certsrv.system.SystemConfigClient;
+import com.netscape.cmsutil.crypto.CryptoUtil;
 import com.netscape.cmsutil.util.Utils;
 
 /**
@@ -251,7 +252,7 @@ public class ConfigurationTest {
         data.setSecurityDomainName("Testca2 security domain");
         data.setClone("false");
         data.setHierarchy("root");
-        data.setToken(ConfigurationRequest.TOKEN_DEFAULT);
+        data.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
         data.setSubsystemName("test ca subsystem");
 
         data.setDsHost(host);
@@ -353,7 +354,7 @@ public class ConfigurationTest {
 
         data.setClone("false");
         data.setHierarchy("join");
-        data.setToken(ConfigurationRequest.TOKEN_DEFAULT);
+        data.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
         data.setSubsystemName("test subca subsystem");
 
         data.setDsHost(host);
@@ -455,7 +456,7 @@ public class ConfigurationTest {
 
         data.setClone("false");
         data.setHierarchy("join");
-        data.setToken(ConfigurationRequest.TOKEN_DEFAULT);
+        data.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
         data.setSubsystemName("test external ca subsystem");
 
         data.setDsHost(host);
@@ -557,7 +558,7 @@ public class ConfigurationTest {
 
         data.setClone("false");
         data.setHierarchy("join");
-        data.setToken(ConfigurationRequest.TOKEN_DEFAULT);
+        data.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
         data.setSubsystemName("test external ca subsystem");
 
         data.setDsHost(host);
@@ -681,7 +682,7 @@ public class ConfigurationTest {
         data.setP12Password("redhat123");
 
         data.setHierarchy("root");
-        data.setToken(ConfigurationRequest.TOKEN_DEFAULT);
+        data.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
         data.setSubsystemName("test clone ca subsystem");
 
         data.setDsHost(host);
@@ -724,7 +725,7 @@ public class ConfigurationTest {
         data.setSecurityDomainPassword("redhat123");
 
         data.setClone("false");
-        data.setToken(ConfigurationRequest.TOKEN_DEFAULT);
+        data.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
         data.setSubsystemName("test kra subsystem");
 
         data.setDsHost(host);
@@ -827,7 +828,7 @@ public class ConfigurationTest {
         data.setSecurityDomainPassword("redhat123");
 
         data.setClone("false");
-        data.setToken(ConfigurationRequest.TOKEN_DEFAULT);
+        data.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
         data.setSubsystemName("test ocsp subsystem");
 
         data.setDsHost(host);
@@ -919,7 +920,7 @@ public class ConfigurationTest {
         data.setSecurityDomainPassword("redhat123");
 
         data.setClone("false");
-        data.setToken(ConfigurationRequest.TOKEN_DEFAULT);
+        data.setToken(CryptoUtil.INTERNAL_TOKEN_FULL_NAME);
         data.setSubsystemName("test tks subsystem");
 
         data.setDsHost(host);
diff --git a/base/common/src/com/netscape/certsrv/system/ConfigurationRequest.java b/base/common/src/com/netscape/certsrv/system/ConfigurationRequest.java
index cd9d3c8baa67627461f3737b67566e1f884b5f90..2ac1f5a1547e10d7351975634c3d853af774c65d 100644
--- a/base/common/src/com/netscape/certsrv/system/ConfigurationRequest.java
+++ b/base/common/src/com/netscape/certsrv/system/ConfigurationRequest.java
@@ -28,6 +28,8 @@ import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
+import com.netscape.cmsutil.crypto.CryptoUtil;
+
 /**
  * @author alee
  *
@@ -37,7 +39,6 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 public class ConfigurationRequest {
 
     //defaults
-    public static final String TOKEN_DEFAULT = "Internal Key Storage Token";
     public static final String NEW_DOMAIN = "newdomain";
     public static final String EXISTING_DOMAIN = "existingdomain";
     public static final String NEW_SUBDOMAIN = "newsubdomain";
@@ -45,7 +46,7 @@ public class ConfigurationRequest {
     @XmlElement
     protected String pin;
 
-    @XmlElement(defaultValue=TOKEN_DEFAULT)
+    @XmlElement(defaultValue=CryptoUtil.INTERNAL_TOKEN_FULL_NAME)
     protected String token;
 
     @XmlElement
diff --git a/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java b/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
index 40f4b5834e14e6b89bc31e3b56f7a530ab0b2fae..963df4d05d6d568036f292361c1048eadf1be8b4 100644
--- a/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
+++ b/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
@@ -151,7 +151,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
         CMS.debug("=== Token Authentication ===");
         String token = data.getToken();
         if (token == null) {
-            token = ConfigurationRequest.TOKEN_DEFAULT;
+            token = CryptoUtil.INTERNAL_TOKEN_FULL_NAME;
         }
         loginToken(data, token);
 
@@ -877,7 +877,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
         CMS.debug("SystemConfigService: get configuration entries from master");
         ConfigurationUtils.getConfigEntriesFromMaster();
 
-        if (token.equals(ConfigurationRequest.TOKEN_DEFAULT)) {
+        if (token.equals(CryptoUtil.INTERNAL_TOKEN_FULL_NAME)) {
             if (!data.getSystemCertsImported()) {
                 CMS.debug("SystemConfigService: restore certificates from P12 file");
                 String p12File = data.getP12File();
@@ -1019,7 +1019,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
     public void loginToken(ConfigurationRequest data, String token) {
         cs.putString("preop.module.token", token);
 
-        if (! token.equals(ConfigurationRequest.TOKEN_DEFAULT)) {
+        if (! token.equals(CryptoUtil.INTERNAL_TOKEN_FULL_NAME)) {
             try {
                 CryptoManager cryptoManager = CryptoManager.getInstance();
                 CryptoToken ctoken = cryptoManager.getTokenByName(token);
@@ -1130,7 +1130,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
                 throw new BadRequestException("Invalid clone URI: " + cloneUri, e);
             }
 
-            if (data.getToken().equals(ConfigurationRequest.TOKEN_DEFAULT)) {
+            if (data.getToken().equals(CryptoUtil.INTERNAL_TOKEN_FULL_NAME)) {
                 if (!data.getSystemCertsImported()) {
                     if (data.getP12File() == null) {
                         throw new BadRequestException("P12 filename not provided");
@@ -1210,7 +1210,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
         }
 
         if ((data.getBackupKeys() != null) && data.getBackupKeys().equals("true")) {
-            if (! data.getToken().equals(ConfigurationRequest.TOKEN_DEFAULT)) {
+            if (! data.getToken().equals(CryptoUtil.INTERNAL_TOKEN_FULL_NAME)) {
                 throw new BadRequestException("HSMs cannot publish private keys to PKCS #12 files");
             }
 
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/TPSInstallerService.java b/base/tps/src/org/dogtagpki/server/tps/rest/TPSInstallerService.java
index 8fd24c8d8607b45651c6a926a56b45209791633d..7a22288793fba1a9214ea0717cd138f2e6ac1a26 100644
--- a/base/tps/src/org/dogtagpki/server/tps/rest/TPSInstallerService.java
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/TPSInstallerService.java
@@ -31,6 +31,7 @@ import com.netscape.certsrv.base.PKIException;
 import com.netscape.certsrv.system.ConfigurationRequest;
 import com.netscape.certsrv.system.SystemCertData;
 import com.netscape.cms.servlet.csadmin.ConfigurationUtils;
+import com.netscape.cmsutil.crypto.CryptoUtil;
 
 /**
  * @author alee
@@ -50,7 +51,7 @@ public class TPSInstallerService extends SystemConfigService  {
 
         // get token prefix, if applicable
         String tokPrefix = "";
-        if (!request.getToken().equals(ConfigurationRequest.TOKEN_DEFAULT) &&
+        if (!request.getToken().equals(CryptoUtil.INTERNAL_TOKEN_FULL_NAME) &&
                 !request.getToken().equals("internal")) {
             tokPrefix = request.getToken() + ":";
         }
-- 
2.5.5

_______________________________________________
Pki-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/pki-devel

Reply via email to