Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.keycloak.jaxrs;
  
  import java.util.List;
  import java.util.Map;
  
 

Author(s):
Marek Posolda
 
 public class JaxrsHttpFacade implements HttpFacade {
 
     protected final ContainerRequestContext requestContext;
     protected final SecurityContext securityContext;
     protected final RequestFacade requestFacade = new RequestFacade();
     protected final ResponseFacade responseFacade = new ResponseFacade();
     protected boolean responseFinished;
 
     public JaxrsHttpFacade(ContainerRequestContext containerRequestContextSecurityContext securityContext) {
         this. = containerRequestContext;
         this. = securityContext;
     }
 
     protected class RequestFacade implements HttpFacade.Request {
 
         @Override
         public String getMethod() {
             return .getMethod();
         }
 
         @Override
         public String getURI() {
             return .getUriInfo().getRequestUri().toString();
         }
 
         @Override
         public boolean isSecure() {
             return .isSecure();
         }
 
         @Override
         public String getQueryParamValue(String param) {
             MultivaluedMap<StringStringqueryParams = .getUriInfo().getQueryParameters();
             if (queryParams == null)
                 return null;
             return queryParams.getFirst(param);
         }
 
         @Override
         public Cookie getCookie(String cookieName) {
             Map<Stringjavax.ws.rs.core.Cookiecookies = .getCookies();
             if (cookies == null)
                 return null;
             javax.ws.rs.core.Cookie cookie = cookies.get(cookieName);
             if (cookie == null)
                 return null;
             return new Cookie(cookie.getName(), cookie.getValue(), cookie.getVersion(), cookie.getDomain(), cookie.getPath());
         }
 
         @Override
         public String getHeader(String name) {
             return .getHeaderString(name);
         }
 
         @Override
         public List<StringgetHeaders(String name) {
             MultivaluedMap<StringStringheaders = .getHeaders();
             return (headers == null) ? null : headers.get(name);
         }
 
         @Override
         public InputStream getInputStream() {
             return .getEntityStream();
         }
 
         @Override
         public String getRemoteAddr() {
             // TODO: implement properly
             return HostUtils.getIpAddress();
         }
     }
 
     protected class ResponseFacade implements HttpFacade.Response {
 
         private javax.ws.rs.core.Response.ResponseBuilder responseBuilder = javax.ws.rs.core.Response.status(204);
 
         @Override
         public void setStatus(int status) {
             .status(status);
        }
        @Override
        public void addHeader(String nameString value) {
            .header(namevalue);
        }
        @Override
        public void setHeader(String nameString value) {
            .header(namevalue);
        }
        @Override
        public void resetCookie(String nameString path) {
            // For now doesn't need to be supported
            throw new IllegalStateException("Not supported yet");
        }
        @Override
        public void setCookie(String nameString valueString pathString domainint maxAgeboolean secureboolean httpOnly) {
            // For now doesn't need to be supported
            throw new IllegalStateException("Not supported yet");
        }
        @Override
        public OutputStream getOutputStream() {
            // For now doesn't need to be supported
            throw new IllegalStateException("Not supported yet");
        }
        @Override
        public void sendError(int codeString message) {
            javax.ws.rs.core.Response response = .status(code).entity(message).build();
            .abortWith(response);
             = true;
        }
        @Override
        public void end() {
            javax.ws.rs.core.Response response = .build();
            .abortWith(response);
             = true;
        }
    }
    @Override
        return ;
    }
    public void setSecurityContext(KeycloakSecurityContext securityContext) {
        this. = securityContext;
    }
    @Override
    public Request getRequest() {
        return ;
    }
    @Override
    public Response getResponse() {
        return ;
    }
    @Override
    public X509Certificate[] getCertificateChain() {
        throw new IllegalStateException("Not supported yet");
    }
    public boolean isResponseFinished() {
        return ;
    }
New to GrepCode? Check out our FAQ X