Skip to content

Commit

Permalink
Remove Servlet specific auth from JAX-RS
Browse files Browse the repository at this point in the history
This is no longer needed after the changes in how challenges are handled.

Partial fix for quarkusio#5419
  • Loading branch information
stuartwdouglas committed Nov 15, 2019
1 parent 18b4bd1 commit 9c65197
Showing 1 changed file with 0 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.resteasy.runtime;

import java.lang.reflect.Method;
import java.util.concurrent.ExecutionException;

import javax.annotation.Priority;
Expand Down Expand Up @@ -28,40 +27,8 @@ public class UnauthorizedExceptionMapper implements ExceptionMapper<Unauthorized

private static final Logger log = Logger.getLogger(UnauthorizedExceptionMapper.class.getName());

//Servlet API may not be present
private static final Class<?> HTTP_SERVLET_REQUEST;
private static final Class<?> HTTP_SERVLET_RESPONSE;
private static final Method AUTHENTICATE;

static {
Class<?> httpServletReq = null;
Class<?> httpServletResp = null;
Method auth = null;
try {
httpServletReq = Class.forName("javax.servlet.http.HttpServletRequest");
httpServletResp = Class.forName("javax.servlet.http.HttpServletResponse");
auth = httpServletReq.getMethod("authenticate", httpServletResp);
} catch (Exception ignored) {

}
AUTHENTICATE = auth;
HTTP_SERVLET_REQUEST = httpServletReq;
HTTP_SERVLET_RESPONSE = httpServletResp;
}

@Override
public Response toResponse(UnauthorizedException exception) {
if (HTTP_SERVLET_REQUEST != null) {
Object httpServletRequest = ResteasyContext.getContextData(HTTP_SERVLET_REQUEST);
if (httpServletRequest != null) {
Object httpServletResponse = ResteasyContext.getContextData(HTTP_SERVLET_RESPONSE);
try {
AUTHENTICATE.invoke(httpServletRequest, httpServletResponse);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
RoutingContext context = ResteasyContext.getContextData(RoutingContext.class);
if (context != null) {
HttpAuthenticator authenticator = context.get(HttpAuthenticator.class.getName());
Expand Down

0 comments on commit 9c65197

Please sign in to comment.