The CryptoUtil.setClientCiphers(String) has been reformatted to
simplify future refactoring.

Pushed to master under trivial rule.

--
Endi S. Dewata
>From 2b9f9b7ef9e936dc5dc7ecc7bcc4c2fd8236dd1f Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edew...@redhat.com>
Date: Sat, 18 Mar 2017 03:33:10 +0100
Subject: [PATCH] Cleaned up CryptoUtil.setClientCiphers(String).

The CryptoUtil.setClientCiphers(String) has been reformatted to
simplify future refactoring.
---
 .../com/netscape/cmsutil/crypto/CryptoUtil.java    | 41 +++++++++-------------
 1 file changed, 17 insertions(+), 24 deletions(-)

diff --git a/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java b/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
index f8b087120f88587084fa32c66bb27a0b3e903d65..fccda69e4789ffbc4285099b2847a8aafdd2a694 100644
--- a/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
+++ b/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
@@ -928,32 +928,25 @@ public class CryptoUtil {
 
     }
 
+    public static void setClientCiphers(String list) throws SocketException {
 
-    // if clientOverrideCiphers is provided in config, use it
-    public static void setClientCiphers(String clientOverrideCiphers)
-            throws SocketException {
-        if (clientOverrideCiphers != null) {
-            String strCiphers[] = clientOverrideCiphers.split(",");
-            if (strCiphers.length != 0) {
-                unsetSSLCiphers();
-                int cipherid;
-                for (int i=0; i< strCiphers.length; i++) {
-                    Object mapValue;
-
-                    mapValue = cipherMap.get(strCiphers[i]);
-                    if (mapValue == null) {
-                        cipherid = 0;
-                    } else {
-                        cipherid = (Integer) mapValue;
-                    }
-                    if (cipherid != 0) {
-                        SSLSocket.setCipherPreferenceDefault(cipherid, true);
-                    }
-                }
-            }
-            return;
-        } else { //use default
+        if (list == null) {
+            // use default
             setClientCiphers();
+            return;
+        }
+
+        String ciphers[] = list.split(",");
+        if (ciphers.length == 0) return;
+
+        unsetSSLCiphers();
+
+        for (String cipher : ciphers) {
+
+            Integer cipherID = cipherMap.get(cipher);
+            if (cipherID == null) continue;
+
+            SSLSocket.setCipherPreferenceDefault(cipherID, true);
         }
     }
 
-- 
2.9.3

_______________________________________________
Pki-devel mailing list
Pki-devel@redhat.com
https://www.redhat.com/mailman/listinfo/pki-devel

Reply via email to