Blame SOURCES/pki-core-problems-with-FIPS-mode.patch

b9ff42
From 78fa2f5955225cd38f3c5b996396453899017b31 Mon Sep 17 00:00:00 2001
b9ff42
From: "Endi S. Dewata" <edewata@redhat.com>
b9ff42
Date: Wed, 12 Oct 2016 03:26:41 +0200
b9ff42
Subject: [PATCH] Fixed CryptoUtil.getTokenName().
b9ff42
b9ff42
The CryptoUtil.getTokenName() has been modified to check both the
b9ff42
short name and full name of the internal token.
b9ff42
b9ff42
The ConfigurationUtils.deleteCert() has also been modified to call
b9ff42
CryptoUtil.getTokenName().
b9ff42
b9ff42
https://fedorahosted.org/pki/ticket/2500
b9ff42
(cherry picked from commit 5be68e38fd77f171331d27ca52a291f06f7c686c)
b9ff42
(cherry picked from commit 42c52b18467212dde0cdebedca55ab22c4629cb5)
b9ff42
---
b9ff42
 .../cms/servlet/csadmin/ConfigurationUtils.java    |  2 +-
b9ff42
 .../com/netscape/cmsutil/crypto/CryptoUtil.java    | 23 +++++++++++++---------
b9ff42
 2 files changed, 15 insertions(+), 10 deletions(-)
b9ff42
b9ff42
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
b9ff42
index ecf8157..afd8d28 100644
b9ff42
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
b9ff42
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
b9ff42
@@ -3419,7 +3419,7 @@ public class ConfigurationUtils {
b9ff42
             NoSuchTokenException, TokenException {
b9ff42
 
b9ff42
         CryptoManager cm = CryptoManager.getInstance();
b9ff42
-        CryptoToken tok = cm.getTokenByName(tokenname);
b9ff42
+        CryptoToken tok = CryptoUtil.getTokenByName(tokenname);
b9ff42
         CryptoStore store = tok.getCryptoStore();
b9ff42
         String fullnickname = nickname;
b9ff42
         if (!tokenname.equals("") &&
b9ff42
diff --git a/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java b/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
b9ff42
index b02c363..b6b5e6a 100644
b9ff42
--- a/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
b9ff42
+++ b/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
b9ff42
@@ -135,6 +135,9 @@ import netscape.security.x509.X509Key;
b9ff42
 @SuppressWarnings("serial")
b9ff42
 public class CryptoUtil {
b9ff42
 
b9ff42
+    public final static String INTERNAL_TOKEN_NAME = "internal";
b9ff42
+    public final static String INTERNAL_TOKEN_FULL_NAME = "Internal Key Storage Token";
b9ff42
+
b9ff42
     public static final String CERTREQ_BEGIN_HEADING = "-----BEGIN CERTIFICATE REQUEST-----";
b9ff42
     public static final String CERTREQ_END_HEADING = "-----END CERTIFICATE REQUEST-----";
b9ff42
     public static final int LINE_COUNT = 76;
b9ff42
@@ -472,21 +475,23 @@ public class CryptoUtil {
b9ff42
         return true;
b9ff42
     }
b9ff42
 
b9ff42
+    public static boolean isInternalToken(String name) {
b9ff42
+        return name.equalsIgnoreCase(INTERNAL_TOKEN_NAME) || name.equalsIgnoreCase(INTERNAL_TOKEN_FULL_NAME);
b9ff42
+    }
b9ff42
+
b9ff42
     /**
b9ff42
      * Retrieves handle to a JSS token.
b9ff42
      */
b9ff42
-    public static CryptoToken getTokenByName(String token)
b9ff42
-            throws CryptoManager.NotInitializedException,
b9ff42
-                NoSuchTokenException {
b9ff42
+    public static CryptoToken getTokenByName(String name)
b9ff42
+            throws NotInitializedException, NoSuchTokenException {
b9ff42
+
b9ff42
         CryptoManager cm = CryptoManager.getInstance();
b9ff42
-        CryptoToken t = null;
b9ff42
 
b9ff42
-        if (token.equals("internal")) {
b9ff42
-            t = cm.getInternalKeyStorageToken();
b9ff42
-        } else {
b9ff42
-            t = cm.getTokenByName(token);
b9ff42
+        if (isInternalToken(name)) {
b9ff42
+            return cm.getInternalKeyStorageToken();
b9ff42
         }
b9ff42
-        return t;
b9ff42
+
b9ff42
+        return cm.getTokenByName(name);
b9ff42
     }
b9ff42
 
b9ff42
     /**
b9ff42
-- 
b9ff42
1.8.3.1
b9ff42