[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pki-devel] [PATCH] 263 - fix for cloning from dogtag 9 -> 10



When getting a token from the security domain for a Dogtag 9 system, we
first attempt to reach the REST interfaces. When this fails (with 404
exception), we catch the exception and try the old interfaces.

The exception being thrown has been changed from the deprecated
ClientResponseFailure? to being wrapped in a PKIException, so the code
catching the exception needs to be modified accordingly.

This is in response to IPA ticket : ‚Äč
https://fedorahosted.org/freeipa/ticket/5129 

Please review.
Ade
>From 245cd26e617e1c830dc6a4ef2e513fe1eaec69a8 Mon Sep 17 00:00:00 2001
From: Ade Lee <alee redhat com>
Date: Thu, 16 Jul 2015 16:48:51 -0400
Subject: [PATCH] Fix exception when talking to dogtag 9 systems

When getting a token from the security domain for a Dogtag 9
system, we first attempt to reach the REST interfaces.  When this
fails (with 404 exception), we catch the exception and try the
old interfaces.

The exception being thrown has been changed from the deprecated
ClientResponseFailure to being wrapped in a PKIException, so the
code catching the exception needs to be modified accordingly.

Ticket 1495
---
 .../src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

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
index 5566e91e9aaa64acbcea3c5cfa89b9956142483b..c8ab38ce71643ae49e5c14746e7a815cea5b263a 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
@@ -89,7 +89,6 @@ import netscape.security.x509.X509CertImpl;
 import netscape.security.x509.X509Key;
 
 import org.apache.velocity.context.Context;
-import org.jboss.resteasy.client.ClientResponseFailure;
 import org.mozilla.jss.CryptoManager;
 import org.mozilla.jss.CryptoManager.NicknameConflictException;
 import org.mozilla.jss.CryptoManager.NotInitializedException;
@@ -152,6 +151,7 @@ import com.netscape.certsrv.base.EBaseException;
 import com.netscape.certsrv.base.EPropertyNotFound;
 import com.netscape.certsrv.base.IConfigStore;
 import com.netscape.certsrv.base.ISubsystem;
+import com.netscape.certsrv.base.PKIException;
 import com.netscape.certsrv.base.ResourceNotFoundException;
 import com.netscape.certsrv.ca.ICertificateAuthority;
 import com.netscape.certsrv.client.ClientConfig;
@@ -372,17 +372,14 @@ public class ConfigurationUtils {
             InstallToken token = sdClient.getInstallToken(sdhost, csType);
             accountClient.logout();
             return token.getToken();
-
-        } catch (ClientResponseFailure e) {
-
-            if (e.getResponse().getResponseStatus() == Response.Status.NOT_FOUND) {
+        } catch (PKIException e) {
+            if (e.getCode() == Response.Status.NOT_FOUND.getStatusCode()) {
                 // try the old servlet
                 CMS.debug("Getting old cookie");
                 String tokenString = getOldCookie(sdhost, sdport, user, passwd);
                 CMS.debug("Token: " + tokenString);
                 return tokenString;
             }
-
             throw e;
         }
     }
-- 
1.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]