From 1512d3f1ace9aa48b771f1dc5b3bd06ff93fa782 Mon Sep 17 00:00:00 2001 From: Christina Fu Date: Thu, 16 Nov 2023 10:42:11 -0800 Subject: [PATCH] Bug2246422-(refinement of)ServerSideKeygen static SKID This small patch is to refine the previous patch where the exceptions thrown in CertUtils.java will not depend on EProfileException. related to https://bugzilla.redhat.com/show_bug.cgi?id=2246422 --- .../com/netscape/cmscore/cert/CertUtils.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/base/server/src/main/java/com/netscape/cmscore/cert/CertUtils.java b/base/server/src/main/java/com/netscape/cmscore/cert/CertUtils.java index 63758526002..b5d1a3d0c1a 100644 --- a/base/server/src/main/java/com/netscape/cmscore/cert/CertUtils.java +++ b/base/server/src/main/java/com/netscape/cmscore/cert/CertUtils.java @@ -72,7 +72,6 @@ import com.netscape.certsrv.logging.AuditEvent; import com.netscape.certsrv.logging.ILogger; import com.netscape.certsrv.logging.LogEvent; -import com.netscape.certsrv.profile.EProfileException; import com.netscape.certsrv.request.IRequest; import com.netscape.cms.logging.Logger; import com.netscape.cms.logging.SignedAuditLogger; @@ -194,7 +193,7 @@ public static PKCS10 parsePKCS10(Locale locale, String certreq) throws Exception if (certreq == null) { logger.error("CertUtils: Missing PKCS #10 request"); - throw new EProfileException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST")); + throw new EBaseException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST")); } logger.debug(certreq); @@ -228,7 +227,7 @@ public static PKCS10 parsePKCS10(Locale locale, String certreq) throws Exception } catch (Exception e) { logger.error("Unable to parse PKCS #10 request: " + e.getMessage(), e); - throw new EProfileException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"), e); + throw new EBaseException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"), e); } finally { if (sigver) { @@ -244,7 +243,7 @@ public static CertReqMsg[] parseCRMF(Locale locale, String certreq) throws Excep if (certreq == null) { logger.error("CertUtils: Missing CRMF request"); - throw new EProfileException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST")); + throw new EBaseException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST")); } byte[] data = CertUtil.parseCSR(certreq); @@ -268,7 +267,7 @@ public static CertReqMsg[] parseCRMF(Locale locale, String certreq) throws Excep } catch (Exception e) { logger.error("Unable to parse CRMF request: " + e.getMessage(), e); - throw new EProfileException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"), e); + throw new EBaseException(CMS.getUserMessage(locale, "CMS_PROFILE_INVALID_REQUEST"), e); } } @@ -572,9 +571,9 @@ public static String getCertType(X509CertImpl cert) throws CertificateParsingExc } public static void addExtension(String name, Extension ext, X509CertInfo info) - throws EProfileException { + throws EBaseException { if (ext == null) { - throw new EProfileException("addExtension: extension '" + name + "' is null"); + throw new EBaseException("addExtension: extension '" + name + "' is null"); } CertificateExtensions exts = null; @@ -583,7 +582,7 @@ public static void addExtension(String name, Extension ext, X509CertInfo info) if (alreadyPresentExtension != null) { String eName = ext.toString(); logger.error("Duplicate extension: " + eName); - throw new EProfileException(CMS.getUserMessage("CMS_PROFILE_DUPLICATE_EXTENSION", eName)); + throw new EBaseException(CMS.getUserMessage("CMS_PROFILE_DUPLICATE_EXTENSION", eName)); } try { @@ -593,7 +592,7 @@ public static void addExtension(String name, Extension ext, X509CertInfo info) logger.warn("EnrollDefault: " + e.getMessage(), e); } if (exts == null) { - throw new EProfileException("extensions not found"); + throw new EBaseException("extensions not found"); } try { exts.set(name, ext); @@ -630,11 +629,11 @@ public static void deleteExtension(String extID, X509CertInfo info) throws Excep } public static void replaceExtension(String name, Extension ext, X509CertInfo info) - throws EProfileException { + throws EBaseException { try { deleteExtension(name, info); } catch (Exception e) { - throw new EProfileException(e); + throw new EBaseException(e); } addExtension(name, ext, info);