[Pki-devel] [PATCH] 565 Fixed problem deleting newly created TPS profiles.
Endi Sukma Dewata
edewata at redhat.com
Wed Apr 8 19:18:49 UTC 2015
All TPS services have been fixed to set the default status of a
new record to Disabled if the client does not provide the initial
status. This will ensure a newly created profile to always have a
status so it can be deleted normally.
https://fedorahosted.org/pki/ticket/1273
--
Endi S. Dewata
-------------- next part --------------
From e6bacc223209899ca7a1034013e158cd3c9f473d Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata at redhat.com>
Date: Wed, 8 Apr 2015 08:22:13 -0400
Subject: [PATCH] Fixed problem deleting newly created TPS profiles.
All TPS services have been fixed to set the default status of a
new record to Disabled if the client does not provide the initial
status. This will ensure a newly created profile to always have a
status so it can be deleted normally.
https://fedorahosted.org/pki/ticket/1273
---
.../server/tps/rest/AuthenticatorService.java | 3 +-
.../server/tps/rest/ConnectorService.java | 3 +-
.../server/tps/rest/ProfileMappingService.java | 3 +-
.../dogtagpki/server/tps/rest/ProfileService.java | 35 +++++++++++++---------
4 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/AuthenticatorService.java b/base/tps/src/org/dogtagpki/server/tps/rest/AuthenticatorService.java
index ce240ebe53e3fd23f0853f3606f1634866797866..f02598d62bdf18152de73fa5dfa73b9af81651d0 100644
--- a/base/tps/src/org/dogtagpki/server/tps/rest/AuthenticatorService.java
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/AuthenticatorService.java
@@ -32,6 +32,7 @@ import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.apache.commons.lang.StringUtils;
import org.dogtagpki.server.tps.TPSSubsystem;
import org.dogtagpki.server.tps.config.AuthenticatorDatabase;
import org.dogtagpki.server.tps.config.AuthenticatorRecord;
@@ -184,7 +185,7 @@ public class AuthenticatorService extends PKIService implements AuthenticatorRes
String status = authenticatorData.getStatus();
Principal principal = servletRequest.getUserPrincipal();
- if (status == null || database.requiresApproval() && !database.canApprove(principal)) {
+ if (StringUtils.isEmpty(status) || database.requiresApproval() && !database.canApprove(principal)) {
// if status is unspecified or user doesn't have rights to approve, the entry is disabled
authenticatorData.setStatus(Constants.CFG_DISABLED);
}
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/ConnectorService.java b/base/tps/src/org/dogtagpki/server/tps/rest/ConnectorService.java
index d81b508f2b896245915e82f6ca8927613e80f601..9e558c7d36a15d87437831d9d8c49330e4f5b9c2 100644
--- a/base/tps/src/org/dogtagpki/server/tps/rest/ConnectorService.java
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/ConnectorService.java
@@ -32,6 +32,7 @@ import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.apache.commons.lang.StringUtils;
import org.dogtagpki.server.tps.TPSSubsystem;
import org.dogtagpki.server.tps.config.ConnectorDatabase;
import org.dogtagpki.server.tps.config.ConnectorRecord;
@@ -184,7 +185,7 @@ public class ConnectorService extends PKIService implements ConnectorResource {
String status = connectorData.getStatus();
Principal principal = servletRequest.getUserPrincipal();
- if (status == null || database.requiresApproval() && !database.canApprove(principal)) {
+ if (StringUtils.isEmpty(status) || database.requiresApproval() && !database.canApprove(principal)) {
// if status is unspecified or user doesn't have rights to approve, the entry is disabled
connectorData.setStatus(Constants.CFG_DISABLED);
}
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/ProfileMappingService.java b/base/tps/src/org/dogtagpki/server/tps/rest/ProfileMappingService.java
index 98f5f098684ba41b05d859065a861368f74d5e21..3286043bf96712d00fe988f4f5c750c2efda7271 100644
--- a/base/tps/src/org/dogtagpki/server/tps/rest/ProfileMappingService.java
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/ProfileMappingService.java
@@ -32,6 +32,7 @@ import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.apache.commons.lang.StringUtils;
import org.dogtagpki.server.tps.TPSSubsystem;
import org.dogtagpki.server.tps.config.ProfileMappingDatabase;
import org.dogtagpki.server.tps.config.ProfileMappingRecord;
@@ -180,7 +181,7 @@ public class ProfileMappingService extends PKIService implements ProfileMappingR
String status = profileMappingData.getStatus();
Principal principal = servletRequest.getUserPrincipal();
- if (status == null || database.requiresApproval() && !database.canApprove(principal)) {
+ if (StringUtils.isEmpty(status) || database.requiresApproval() && !database.canApprove(principal)) {
// if status is unspecified or user doesn't have rights to approve, the entry is disabled
profileMappingData.setStatus(Constants.CFG_DISABLED);
}
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/ProfileService.java b/base/tps/src/org/dogtagpki/server/tps/rest/ProfileService.java
index 9505ad208fbd8dbdc7339fb10e7c7ccc5c4e14fb..4a6b8c68c08cb7398b7b4e5b7ca54ec0e5aeb76e 100644
--- a/base/tps/src/org/dogtagpki/server/tps/rest/ProfileService.java
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/ProfileService.java
@@ -32,6 +32,7 @@ import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.apache.commons.lang.StringUtils;
import org.dogtagpki.server.tps.TPSSubsystem;
import org.dogtagpki.server.tps.config.ProfileDatabase;
import org.dogtagpki.server.tps.config.ProfileRecord;
@@ -140,11 +141,12 @@ public class ProfileService extends PKIService implements ProfileResource {
return createOKResponse(response);
} catch (PKIException e) {
+ CMS.debug("ProfileService: " + e);
throw e;
} catch (Exception e) {
- e.printStackTrace();
- throw new PKIException(e.getMessage());
+ CMS.debug(e);
+ throw new PKIException(e);
}
}
@@ -162,11 +164,12 @@ public class ProfileService extends PKIService implements ProfileResource {
return createOKResponse(createProfileData(database.getRecord(profileID)));
} catch (PKIException e) {
+ CMS.debug("ProfileService: " + e);
throw e;
} catch (Exception e) {
- e.printStackTrace();
- throw new PKIException(e.getMessage());
+ CMS.debug(e);
+ throw new PKIException(e);
}
}
@@ -184,7 +187,7 @@ public class ProfileService extends PKIService implements ProfileResource {
String status = profileData.getStatus();
Principal principal = servletRequest.getUserPrincipal();
- if (status == null || database.requiresApproval() && !database.canApprove(principal)) {
+ if (StringUtils.isEmpty(status) || database.requiresApproval() && !database.canApprove(principal)) {
// if status is unspecified or user doesn't have rights to approve, the entry is disabled
profileData.setStatus(Constants.CFG_DISABLED);
}
@@ -196,11 +199,12 @@ public class ProfileService extends PKIService implements ProfileResource {
return createCreatedResponse(profileData, profileData.getLink().getHref());
} catch (PKIException e) {
+ CMS.debug("ProfileService: " + e);
throw e;
} catch (Exception e) {
- e.printStackTrace();
- throw new PKIException(e.getMessage());
+ CMS.debug(e);
+ throw new PKIException(e);
}
}
@@ -253,11 +257,12 @@ public class ProfileService extends PKIService implements ProfileResource {
return createOKResponse(profileData);
} catch (PKIException e) {
+ CMS.debug("ProfileService: " + e);
throw e;
} catch (Exception e) {
- e.printStackTrace();
- throw new PKIException(e.getMessage());
+ CMS.debug(e);
+ throw new PKIException(e);
}
}
@@ -311,11 +316,12 @@ public class ProfileService extends PKIService implements ProfileResource {
return createOKResponse(profileData);
} catch (PKIException e) {
+ CMS.debug("ProfileService: " + e);
throw e;
} catch (Exception e) {
- e.printStackTrace();
- throw new PKIException(e.getMessage());
+ CMS.debug(e);
+ throw new PKIException(e);
}
}
@@ -334,7 +340,7 @@ public class ProfileService extends PKIService implements ProfileResource {
String status = record.getStatus();
if (!Constants.CFG_DISABLED.equals(status)) {
- throw new ForbiddenException("Unable to delete profile " + profileID);
+ throw new ForbiddenException("Profile " + profileID + " is not disabled");
}
database.removeRecord(profileID);
@@ -342,11 +348,12 @@ public class ProfileService extends PKIService implements ProfileResource {
return createNoContentResponse();
} catch (PKIException e) {
+ CMS.debug("ProfileService: " + e);
throw e;
} catch (Exception e) {
- e.printStackTrace();
- throw new PKIException(e.getMessage());
+ CMS.debug(e);
+ throw new PKIException(e);
}
}
}
--
1.9.3
More information about the Pki-devel
mailing list