[Pki-devel] [PATCH] 0077..0081 assorted code deletions

Fraser Tweedale ftweedal at redhat.com
Mon Mar 14 00:25:37 UTC 2016


Hi all,

Attached patches implement various drive-by or long-threatened code
deletions.

0077
  Remove unuesd imports cause by me in a recent patch
0078
  Remove unused vars/fields from ProfileService/ProfileSubsystem
0079
  Remove RAEnrollProfile class.  Background:
  https://www.redhat.com/archives/pki-devel/2015-June/msg00038.html
0080
  Drive-by removal of some commented-out code
0081
  Delete some unused methods

Thanks,
Fraser
-------------- next part --------------
From f48c8c684eb7a96a5a1438681a9938be883cab52 Mon Sep 17 00:00:00 2001
From: Fraser Tweedale <ftweedal at redhat.com>
Date: Mon, 14 Mar 2016 09:29:41 +1000
Subject: [PATCH 77/81] Remove unused imports from OCSP authority classes

Commit 04214b3d3405750cbbda228554c0d9f087a59170 left some vestigal
imports behind; remove them.
---
 base/common/src/com/netscape/certsrv/ocsp/IOCSPAuthority.java | 1 -
 base/ocsp/src/com/netscape/ocsp/OCSPAuthority.java            | 1 -
 2 files changed, 2 deletions(-)

diff --git a/base/common/src/com/netscape/certsrv/ocsp/IOCSPAuthority.java b/base/common/src/com/netscape/certsrv/ocsp/IOCSPAuthority.java
index 3264d2ce5f1dbb88172e9ac124168af5acf7930b..e32c11e7b39fccacd3aaab3de8e5ff4af20840b2 100644
--- a/base/common/src/com/netscape/certsrv/ocsp/IOCSPAuthority.java
+++ b/base/common/src/com/netscape/certsrv/ocsp/IOCSPAuthority.java
@@ -20,7 +20,6 @@ package com.netscape.certsrv.ocsp;
 import netscape.security.x509.X500Name;
 
 import org.mozilla.jss.asn1.OBJECT_IDENTIFIER;
-import org.mozilla.jss.pkix.primitive.AlgorithmIdentifier;
 
 import com.netscape.certsrv.base.EBaseException;
 import com.netscape.certsrv.base.ISubsystem;
diff --git a/base/ocsp/src/com/netscape/ocsp/OCSPAuthority.java b/base/ocsp/src/com/netscape/ocsp/OCSPAuthority.java
index e6fd87da0770a2e85958112765464fccbd26cb05..4a40e89fb4608639d3dff57341bfc6a3ee9623fe 100644
--- a/base/ocsp/src/com/netscape/ocsp/OCSPAuthority.java
+++ b/base/ocsp/src/com/netscape/ocsp/OCSPAuthority.java
@@ -41,7 +41,6 @@ import org.mozilla.jss.asn1.InvalidBERException;
 import org.mozilla.jss.asn1.OBJECT_IDENTIFIER;
 import org.mozilla.jss.asn1.OCTET_STRING;
 import org.mozilla.jss.crypto.TokenException;
-import org.mozilla.jss.pkix.primitive.AlgorithmIdentifier;
 import org.mozilla.jss.pkix.primitive.Name;
 
 import com.netscape.certsrv.apps.CMS;
-- 
2.5.0

-------------- next part --------------
From 3442f13082e691e47b475e53df89a0d9fdddafda Mon Sep 17 00:00:00 2001
From: Fraser Tweedale <ftweedal at redhat.com>
Date: Mon, 14 Mar 2016 09:55:16 +1000
Subject: [PATCH 78/81] Remove unused variables from profile classes

Also drive-by refactor 'createProfileData' to use 'getProfile',
reducing code size.
---
 .../ca/src/org/dogtagpki/server/ca/rest/ProfileService.java | 13 +------------
 .../src/com/netscape/cmscore/profile/ProfileSubsystem.java  |  1 -
 2 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java b/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
index 7029ea7fed9dbca281510eb738023b318a538c89..41d009b9d38003f054f45c2dd8070de8f46065f3 100644
--- a/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
@@ -104,7 +104,6 @@ public class ProfileService extends PKIService implements ProfileResource {
 
     private IProfileSubsystem ps = (IProfileSubsystem) CMS.getSubsystem(IProfileSubsystem.ID);
     private IPluginRegistry registry = (IPluginRegistry) CMS.getSubsystem(CMS.SUBSYSTEM_REGISTRY);
-    private IConfigStore cs = CMS.getConfigStore().getSubStore("profile");
 
     private final static String LOGGING_SIGNED_AUDIT_CERT_PROFILE_APPROVAL =
             "LOGGING_SIGNED_AUDIT_CERT_PROFILE_APPROVAL_4";
@@ -215,8 +214,6 @@ public class ProfileService extends PKIService implements ProfileResource {
 
     @Override
     public Response retrieveProfile(String profileId) throws ProfileNotFoundException {
-        IProfile profile = getProfile(profileId);
-
         ProfileData data = null;
         try {
             data = createProfileData(profileId);
@@ -247,15 +244,7 @@ public class ProfileService extends PKIService implements ProfileResource {
 
 
     public ProfileData createProfileData(String profileId) throws EBaseException {
-
-        IProfile profile;
-
-        try {
-            profile = ps.getProfile(profileId);
-        } catch (EProfileException e) {
-            e.printStackTrace();
-            throw new ProfileNotFoundException(profileId);
-        }
+        IProfile profile = getProfile(profileId);
 
         ProfileData data = new ProfileData();
 
diff --git a/base/server/cmscore/src/com/netscape/cmscore/profile/ProfileSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/profile/ProfileSubsystem.java
index 90d7479e44ae5ee60a902d430336e5a192b87600..5ef3f2b81a03250c2e34b2c6aa0589901debce89 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/profile/ProfileSubsystem.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/profile/ProfileSubsystem.java
@@ -80,7 +80,6 @@ public class ProfileSubsystem
             if (info == null) {
                 throw new EBaseException("No plugins for type : profile, with id " + classid);
             }
-            String configPath = subStore.getString(PROP_CONFIG);
 
             CMS.debug("Start Profile Creation - " + id + " " + classid + " " + info.getClassName());
             createProfile(id, classid, info.getClassName(), false);
-- 
2.5.0

-------------- next part --------------
From 8acfe0c119f0360de1efd764a0e4deb513776c37 Mon Sep 17 00:00:00 2001
From: Fraser Tweedale <ftweedal at redhat.com>
Date: Mon, 14 Mar 2016 09:22:53 +1000
Subject: [PATCH 79/81] Remove unused class 'RAEnrollProfile'

---
 .../cms/profile/common/RAEnrollProfile.java        | 128 ---------------------
 1 file changed, 128 deletions(-)
 delete mode 100644 base/server/cms/src/com/netscape/cms/profile/common/RAEnrollProfile.java

diff --git a/base/server/cms/src/com/netscape/cms/profile/common/RAEnrollProfile.java b/base/server/cms/src/com/netscape/cms/profile/common/RAEnrollProfile.java
deleted file mode 100644
index 1fe2fa5147101e6332a74487c7c8cece8663dfe5..0000000000000000000000000000000000000000
--- a/base/server/cms/src/com/netscape/cms/profile/common/RAEnrollProfile.java
+++ /dev/null
@@ -1,128 +0,0 @@
-// --- BEGIN COPYRIGHT BLOCK ---
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; version 2 of the License.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// (C) 2007 Red Hat, Inc.
-// All rights reserved.
-// --- END COPYRIGHT BLOCK ---
-package com.netscape.cms.profile.common;
-
-import java.util.Enumeration;
-
-import netscape.security.x509.X500Name;
-
-import com.netscape.certsrv.apps.CMS;
-import com.netscape.certsrv.authority.IAuthority;
-import com.netscape.certsrv.base.EBaseException;
-import com.netscape.certsrv.connector.IConnector;
-import com.netscape.certsrv.profile.EProfileException;
-import com.netscape.certsrv.profile.ERejectException;
-import com.netscape.certsrv.ra.IRAService;
-import com.netscape.certsrv.ra.IRegistrationAuthority;
-import com.netscape.certsrv.request.IRequest;
-import com.netscape.certsrv.request.IRequestListener;
-import com.netscape.certsrv.request.IRequestQueue;
-import com.netscape.certsrv.request.RequestStatus;
-
-/**
- * This class implements a Registration Manager
- * enrollment profile.
- *
- * @version $Revision$, $Date$
- */
-public class RAEnrollProfile extends EnrollProfile {
-
-    public RAEnrollProfile() {
-        super();
-    }
-
-    public IAuthority getAuthority() {
-        IAuthority authority = (IAuthority)
-                CMS.getSubsystem(CMS.SUBSYSTEM_RA);
-
-        if (authority == null)
-            return null;
-        return authority;
-    }
-
-    public X500Name getIssuerName() {
-        IRegistrationAuthority ra = (IRegistrationAuthority)
-                CMS.getSubsystem(CMS.SUBSYSTEM_RA);
-        X500Name issuerName = ra.getX500Name();
-
-        return issuerName;
-    }
-
-    public void execute(IRequest request)
-            throws EProfileException {
-
-        if (!isEnable()) {
-            CMS.debug("CAEnrollProfile: Profile Not Enabled");
-            throw new EProfileException("Profile Not Enabled");
-        }
-
-        IRegistrationAuthority ra =
-                (IRegistrationAuthority) getAuthority();
-        IRAService raService = ra.getRAService();
-
-        if (raService == null) {
-            throw new EProfileException("No RA Service");
-        }
-
-        IRequestQueue queue = ra.getRequestQueue();
-
-        // send request to CA
-        try {
-            IConnector caConnector = raService.getCAConnector();
-
-            if (caConnector == null) {
-                CMS.debug("RAEnrollProfile: CA connector not configured");
-            } else {
-                caConnector.send(request);
-                // check response
-                if (!request.isSuccess()) {
-                    CMS.debug("RAEnrollProfile error talking to CA setting req status to SVC_PENDING");
-
-                    request.setRequestStatus(RequestStatus.SVC_PENDING);
-
-                    try {
-                        queue.updateRequest(request);
-                    } catch (EBaseException e) {
-                        CMS.debug("RAEnrollProfile: Update request " + e.toString());
-                    }
-                    throw new ERejectException(
-                            request.getError(getLocale(request)));
-                }
-            }
-        } catch (Exception e) {
-            CMS.debug("RAEnrollProfile: " + e.toString());
-            throw new EProfileException(e.toString());
-        }
-
-        // request handling
-        Enumeration<String> names = ra.getRequestListenerNames();
-
-        if (names != null) {
-            while (names.hasMoreElements()) {
-                String name = names.nextElement();
-
-                CMS.debug("CAEnrollProfile: listener " + name);
-                IRequestListener listener = ra.getRequestListener(name);
-
-                if (listener != null) {
-                    listener.accept(request);
-                }
-            }
-        }
-    }
-}
-- 
2.5.0

-------------- next part --------------
From e0efa721071b76c58997c1580a10f85c0c3234fb Mon Sep 17 00:00:00 2001
From: Fraser Tweedale <ftweedal at redhat.com>
Date: Sun, 13 Mar 2016 19:16:07 -0400
Subject: [PATCH 80/81] Remove commented-out code

---
 .../cmscore/src/com/netscape/cmscore/dbs/DBRegistry.java  |  3 ---
 .../cmscore/src/com/netscape/cmscore/dbs/Repository.java  | 15 ---------------
 2 files changed, 18 deletions(-)

diff --git a/base/server/cmscore/src/com/netscape/cmscore/dbs/DBRegistry.java b/base/server/cmscore/src/com/netscape/cmscore/dbs/DBRegistry.java
index db2ce7af468bd6b58930a808138e09b6ae078634..4a2d5e495cad171097b820e5fae70e44aa4e7d50 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/dbs/DBRegistry.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/dbs/DBRegistry.java
@@ -460,9 +460,6 @@ public class DBRegistry implements IDBRegistry, ISubsystem {
             throw new EDBException(CMS.getLogMessage("CMS_DBS_MISSING_OBJECT_CLASS"));
         }
 
-        // this generates way too many messages;
-        //CMS.debug("createObject: attrs " + attrs);
-
         attrs.remove("objectclass");
 
         // sort the object class values
diff --git a/base/server/cmscore/src/com/netscape/cmscore/dbs/Repository.java b/base/server/cmscore/src/com/netscape/cmscore/dbs/Repository.java
index 0d789cc6434a078e7cba4d02b4cbeccb838cd09c..371f8f641ab975eafd5378230cef3a28fd52c81d 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/dbs/Repository.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/dbs/Repository.java
@@ -88,21 +88,6 @@ public abstract class Repository implements IRepository {
         mBaseDN = baseDN;
 
         BI_INCREMENT = new BigInteger(Integer.toString(increment));
-
-        /*
-        // register schema
-        IDBRegistry reg = db.getRegistry();
-        if (!reg.isObjectClassRegistered(RepositoryRecord.class.getName())) {
-            String repRecordOC[] = new String[2];
-            repRecordOC[0] = RepositorySchema.LDAP_OC_TOP;
-            repRecordOC[1] = RepositorySchema.LDAP_OC_REPOSITORY;
-            reg.registerObjectClass(RepositoryRecord.class.getName(), repRecordOC);
-        }
-        if (!reg.isAttributeRegistered(RepositoryRecord.ATTR_SERIALNO)) {
-            reg.registerAttribute(RepositoryRecord.ATTR_SERIALNO,
-                    new BigIntegerMapper(RepositorySchema.LDAP_ATTR_SERIALNO));
-        }
-        */
     }
 
     /**
-- 
2.5.0

-------------- next part --------------
From 381c06ca1fd9ac302baac98b8fd36ab9bfc11dfc Mon Sep 17 00:00:00 2001
From: Fraser Tweedale <ftweedal at redhat.com>
Date: Mon, 14 Mar 2016 09:22:01 +1000
Subject: [PATCH 81/81] Remove unused 'toMIME64' methods

---
 .../cmscore/src/com/netscape/cmscore/cert/CertUtils.java   | 10 ----------
 base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java  | 14 --------------
 2 files changed, 24 deletions(-)

diff --git a/base/server/cmscore/src/com/netscape/cmscore/cert/CertUtils.java b/base/server/cmscore/src/com/netscape/cmscore/cert/CertUtils.java
index 8c5c2ccc10970426bc161c9fcfb3f0e3732ca2b8..d780cba7375280e1b490415173f9aa00f62a557d 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/cert/CertUtils.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/cert/CertUtils.java
@@ -553,16 +553,6 @@ public class CertUtils {
         }
     }
 
-    public static String toMIME64(X509CertImpl cert) {
-        try {
-            return "-----BEGIN CERTIFICATE-----\n" +
-                    Utils.base64encode(cert.getEncoded()) +
-                    "-----END CERTIFICATE-----\n";
-        } catch (CertificateException e) {
-        }
-        return null;
-    }
-
     public static X509Certificate mapCert(String mime64)
             throws IOException {
         mime64 = stripCertBrackets(mime64.trim());
diff --git a/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java b/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
index e98027dcee49c0abf0176b6a932223ac74dbaeb1..06caa0242ab192c5bbc14845dd7abc772601bd58 100644
--- a/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
+++ b/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
@@ -455,20 +455,6 @@ public class CryptoUtil {
             }
         });
     }
-    /*
-     * encodes cert
-     */
-    // private static BASE64Encoder mEncoder = new BASE64Encoder();
-    public static String toMIME64(X509CertImpl cert) {
-        try {
-            return "-----BEGIN CERTIFICATE-----\n"
-                    //  + mEncoder.encodeBuffer(cert.getEncoded())
-                    + Utils.base64encode(cert.getEncoded())
-                    + "-----END CERTIFICATE-----\n";
-        } catch (Exception e) {
-        }
-        return null;
-    }
 
     public static boolean arraysEqual(byte[] bytes, byte[] ints) {
         if (bytes == null || ints == null) {
-- 
2.5.0



More information about the Pki-devel mailing list