From 1adfa2a246435bcb328c2acde33ad6c4747cf6d3 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Mon, 10 Mar 2014 10:47:48 -0400 Subject: [PATCH] updated AuthenticationException to extend BaseServerResponseException --- .../java/ca/uhn/fhir/rest/server/RestfulServer.java | 2 +- .../server/exceptions/AuthenticationException.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java index d9ebf418889..eb8cb3c9108 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java @@ -181,7 +181,7 @@ public abstract class RestfulServer extends HttpServlet { // resourceMethod.get } catch (AuthenticationException e) { - response.setStatus(401); + response.setStatus(e.getStatusCode()); response.getWriter().write(e.getMessage()); } catch (BaseServerResponseException e) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java index b24c538653c..bd49917fcf1 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java @@ -5,8 +5,19 @@ import javax.servlet.ServletException; /** * Created by dsotnikov on 3/10/2014. */ -public class AuthenticationException extends ServletException { +public class AuthenticationException extends BaseServerResponseException { private static final long serialVersionUID = 1L; + public AuthenticationException() { + super(401, "Client unauthorized"); + } + + public AuthenticationException(String theMessage) { + super(401, theMessage); + } + + public AuthenticationException(int theStatusCode, String theMessage) { + super(theStatusCode, theMessage); + } } \ No newline at end of file