diff options
author | Endi S. Dewata <edewata@redhat.com> | 2015-04-08 08:22:13 -0400 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2015-04-08 18:08:20 -0400 |
commit | 38dcd9f5797d64f38139aa42c76038b158edc48e (patch) | |
tree | 56dbb528170ab5f5365429cd4ac8915e714207ea | |
parent | 94ab251fd231919db05cf2e928102c15a5f2fc3c (diff) | |
download | pki-38dcd9f5797d64f38139aa42c76038b158edc48e.tar.gz pki-38dcd9f5797d64f38139aa42c76038b158edc48e.tar.xz pki-38dcd9f5797d64f38139aa42c76038b158edc48e.zip |
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
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 ce240ebe5..f02598d62 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 d81b508f2..9e558c7d3 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 98f5f0986..3286043bf 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 9505ad208..4a6b8c68c 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); } } } |