diff --git a/integration/adapter-spi/src/main/java/org/keycloak/adapters/spi/HttpFacade.java b/integration/adapter-spi/src/main/java/org/keycloak/adapters/spi/HttpFacade.java index fb3804e299..cf6e0d5a4d 100755 --- a/integration/adapter-spi/src/main/java/org/keycloak/adapters/spi/HttpFacade.java +++ b/integration/adapter-spi/src/main/java/org/keycloak/adapters/spi/HttpFacade.java @@ -56,6 +56,7 @@ public interface HttpFacade { void resetCookie(String name, String path); void setCookie(String name, String value, String path, String domain, int maxAge, boolean secure, boolean httpOnly); OutputStream getOutputStream(); + void sendError(int code); void sendError(int code, String message); /** diff --git a/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsHttpFacade.java b/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsHttpFacade.java index cce85d541d..29f483b43c 100755 --- a/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsHttpFacade.java +++ b/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsHttpFacade.java @@ -132,6 +132,13 @@ public class JaxrsHttpFacade implements OIDCHttpFacade { throw new IllegalStateException("Not supported yet"); } + @Override + public void sendError(int code) { + javax.ws.rs.core.Response response = responseBuilder.status(code).build(); + requestContext.abortWith(response); + responseFinished = true; + } + @Override public void sendError(int code, String message) { javax.ws.rs.core.Response response = responseBuilder.status(code).entity(message).build(); diff --git a/integration/jetty/jetty-adapter-spi/src/main/java/org/keycloak/adapters/jetty/spi/JettyHttpFacade.java b/integration/jetty/jetty-adapter-spi/src/main/java/org/keycloak/adapters/jetty/spi/JettyHttpFacade.java index ea2b3afcbb..c1008fd3f3 100755 --- a/integration/jetty/jetty-adapter-spi/src/main/java/org/keycloak/adapters/jetty/spi/JettyHttpFacade.java +++ b/integration/jetty/jetty-adapter-spi/src/main/java/org/keycloak/adapters/jetty/spi/JettyHttpFacade.java @@ -170,6 +170,15 @@ public class JettyHttpFacade implements HttpFacade { } } + @Override + public void sendError(int code) { + try { + response.sendError(code); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + @Override public void sendError(int code, String message) { try { diff --git a/integration/servlet-adapter-spi/src/main/java/org/keycloak/adapters/servlet/ServletHttpFacade.java b/integration/servlet-adapter-spi/src/main/java/org/keycloak/adapters/servlet/ServletHttpFacade.java index 1550eaa745..eb487f5f9b 100755 --- a/integration/servlet-adapter-spi/src/main/java/org/keycloak/adapters/servlet/ServletHttpFacade.java +++ b/integration/servlet-adapter-spi/src/main/java/org/keycloak/adapters/servlet/ServletHttpFacade.java @@ -156,6 +156,15 @@ public class ServletHttpFacade implements HttpFacade { } } + @Override + public void sendError(int code) { + try { + response.sendError(code); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + @Override public void sendError(int code, String message) { try { diff --git a/integration/spring-security/src/main/java/org/keycloak/adapters/springsecurity/facade/WrappedHttpServletResponse.java b/integration/spring-security/src/main/java/org/keycloak/adapters/springsecurity/facade/WrappedHttpServletResponse.java index c6b352fd42..c356ebd22d 100644 --- a/integration/spring-security/src/main/java/org/keycloak/adapters/springsecurity/facade/WrappedHttpServletResponse.java +++ b/integration/spring-security/src/main/java/org/keycloak/adapters/springsecurity/facade/WrappedHttpServletResponse.java @@ -95,6 +95,15 @@ class WrappedHttpServletResponse implements Response { } } + @Override + public void sendError(int code) { + try { + response.sendError(code); + } catch (IOException e) { + throw new RuntimeException("Unable to set HTTP status", e); + } + } + @Override public void sendError(int code, String message) { try { diff --git a/integration/tomcat/tomcat-adapter-spi/src/main/java/org/keycloak/adapters/tomcat/CatalinaHttpFacade.java b/integration/tomcat/tomcat-adapter-spi/src/main/java/org/keycloak/adapters/tomcat/CatalinaHttpFacade.java index cdac621243..ba0b3764d7 100755 --- a/integration/tomcat/tomcat-adapter-spi/src/main/java/org/keycloak/adapters/tomcat/CatalinaHttpFacade.java +++ b/integration/tomcat/tomcat-adapter-spi/src/main/java/org/keycloak/adapters/tomcat/CatalinaHttpFacade.java @@ -167,6 +167,15 @@ public class CatalinaHttpFacade implements HttpFacade { } } + @Override + public void sendError(int code) { + try { + response.sendError(code); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + @Override public void sendError(int code, String message) { try { @@ -176,6 +185,7 @@ public class CatalinaHttpFacade implements HttpFacade { } } + @Override public void end() { ended = true; diff --git a/integration/undertow-adapter-spi/src/main/java/org/keycloak/adapters/undertow/UndertowHttpFacade.java b/integration/undertow-adapter-spi/src/main/java/org/keycloak/adapters/undertow/UndertowHttpFacade.java index 3d378777f6..f420533449 100755 --- a/integration/undertow-adapter-spi/src/main/java/org/keycloak/adapters/undertow/UndertowHttpFacade.java +++ b/integration/undertow-adapter-spi/src/main/java/org/keycloak/adapters/undertow/UndertowHttpFacade.java @@ -170,6 +170,12 @@ public class UndertowHttpFacade implements HttpFacade { return exchange.getOutputStream(); } + @Override + public void sendError(int code) { + exchange.setResponseCode(code); + exchange.endExchange(); + } + @Override public void sendError(int code, String message) { exchange.setResponseCode(code);