summaryrefslogtreecommitdiffstats
path: root/base/server/cmscore
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2015-01-20 09:25:32 -0500
committerEndi S. Dewata <edewata@redhat.com>2015-01-21 15:35:37 -0500
commit802f7471d5ee65e3c4d99b528bb6d8526c277185 (patch)
tree02dd03d41e301499b0b28fbd0af948f253bac03d /base/server/cmscore
parentdeb188bffd38f82396c47411381a875020ca748b (diff)
downloadpki-802f7471d5ee65e3c4d99b528bb6d8526c277185.tar.gz
pki-802f7471d5ee65e3c4d99b528bb6d8526c277185.tar.xz
pki-802f7471d5ee65e3c4d99b528bb6d8526c277185.zip
Added support for exception chains in EBaseException.
The EBaseException has been modified to provide constructors that can be used to chain the cause of the exception. This way the root cause of the exception can be traced back to help troubleshooting. Some codes have been modified to utilize the proper exception chaining as examples. https://fedorahosted.org/pki/ticket/915
Diffstat (limited to 'base/server/cmscore')
-rw-r--r--base/server/cmscore/src/com/netscape/cmscore/authentication/AuthSubsystem.java20
-rw-r--r--base/server/cmscore/src/com/netscape/cmscore/authentication/ChallengePhraseAuthentication.java3
2 files changed, 16 insertions, 7 deletions
diff --git a/base/server/cmscore/src/com/netscape/cmscore/authentication/AuthSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/authentication/AuthSubsystem.java
index 549ce01f9..137edb5c5 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/authentication/AuthSubsystem.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/authentication/AuthSubsystem.java
@@ -219,21 +219,26 @@ public class AuthSubsystem implements IAuthSubsystem {
isEnable = true;
log(ILogger.LL_INFO, CMS.getLogMessage("CMSCORE_AUTH_ADD_AUTH_INSTANCE", insName));
+
} catch (ClassNotFoundException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_AUTH_AUTHSUB_ERROR", e.toString()));
- throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className));
+ throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className), e);
+
} catch (IllegalAccessException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_AUTH_AUTHSUB_ERROR", e.toString()));
- throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className));
+ throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className), e);
+
} catch (InstantiationException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_AUTH_AUTHSUB_ERROR", e.toString()));
- throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className));
+ throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className), e);
+
} catch (EBaseException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_AUTH_AUTH_INIT_ERROR", insName, e.toString()));
// Skip the authenticaiton instance if
// it is mis-configurated. This give
// administrator another chance to
// fix the problem via console
+
} catch (Throwable e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_AUTH_AUTH_INIT_ERROR", insName, e.toString()));
// Skip the authenticaiton instance if
@@ -330,15 +335,18 @@ public class AuthSubsystem implements IAuthSubsystem {
authMgrInst = (IAuthManager)
Class.forName(className).newInstance();
return (authMgrInst.getConfigParams());
+
} catch (InstantiationException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_AUTH_INSTANCE_NOT_CREATED", e.toString()));
- throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className));
+
+ throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className), e);
} catch (ClassNotFoundException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_AUTH_INSTANCE_NOT_CREATED", e.toString()));
- throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className));
+ throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className), e);
+
} catch (IllegalAccessException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_AUTH_INSTANCE_NOT_CREATED", e.toString()));
- throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className));
+ throw new EAuthException(CMS.getUserMessage("CMS_ACL_CLASS_LOAD_FAIL", className), e);
}
}
diff --git a/base/server/cmscore/src/com/netscape/cmscore/authentication/ChallengePhraseAuthentication.java b/base/server/cmscore/src/com/netscape/cmscore/authentication/ChallengePhraseAuthentication.java
index f5bde0b54..11b6104bf 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/authentication/ChallengePhraseAuthentication.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/authentication/ChallengePhraseAuthentication.java
@@ -103,8 +103,9 @@ public class ChallengePhraseAuthentication implements IAuthManager {
try {
mSHADigest = MessageDigest.getInstance("SHA1");
+
} catch (NoSuchAlgorithmException e) {
- throw new EAuthException(CMS.getUserMessage("CMS_AUTHENTICATION_INTERNAL_ERROR", e.getMessage()));
+ throw new EAuthException(CMS.getUserMessage("CMS_AUTHENTICATION_INTERNAL_ERROR", e.getMessage()), e);
}
log(ILogger.LL_INFO, CMS.getLogMessage("INIT_DONE", name));