Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.keycloak.adapters.tomcat7;
  
  import java.util.List;
  
 

Author(s):
Bill Burke
Version:
$Revision: 1 $
 
 public class CatalinaHttpFacade implements HttpFacade {
     protected org.apache.catalina.connector.Request request;
     protected HttpServletResponse response;
     protected RequestFacade requestFacade = new RequestFacade();
     protected ResponseFacade responseFacade = new ResponseFacade();
 
     protected class RequestFacade implements Request {
         @Override
         public String getURI() {
             StringBuffer buf = .getRequestURL();
             if (.getQueryString() != null) {
                 buf.append('?').append(.getQueryString());
             }
             return buf.toString();
         }
 
         @Override
         public boolean isSecure() {
             return .isSecure();
         }
 
         @Override
         public String getQueryParamValue(String paramName) {
             return .getParameter(paramName);
         }
 
         @Override
         public Cookie getCookie(String cookieName) {
             if (.getCookies() == nullreturn null;
             javax.servlet.http.Cookie cookie = null;
             for (javax.servlet.http.Cookie c : .getCookies()) {
                 if (c.getName().equals(cookieName)) {
                     cookie = c;
                     break;
                 }
             }
             if (cookie == nullreturn null;
             return new Cookie(cookie.getName(), cookie.getValue(), cookie.getVersion(), cookie.getDomain(), cookie.getPath());
         }
 
         @Override
         public List<StringgetHeaders(String name) {
             Enumeration<Stringheaders = .getHeaders(name);
             if (headers == nullreturn null;
             List<Stringlist = new ArrayList<String>();
             while (headers.hasMoreElements()) {
                 list.add(headers.nextElement());
             }
             return list;
         }
 
         @Override
         public InputStream getInputStream() {
             try {
                 return .getInputStream();
             } catch (IOException e) {
                 throw new RuntimeException(e);
             }
         }
 
         @Override
         public String getMethod() {
             return .getMethod();
         }
 
         @Override
         public String getHeader(String name) {
             return .getHeader(name);
         }
 
         @Override
         public String getRemoteAddr() {
             return .getRemoteAddr();
         }
     }
 
     protected class ResponseFacade implements Response {
         protected boolean ended;
 
         @Override
        public void setStatus(int status) {
            .setStatus(status);
        }
        @Override
        public void addHeader(String nameString value) {
            .addHeader(namevalue);
        }
        @Override
        public void setHeader(String nameString value) {
            .setHeader(namevalue);
        }
        @Override
        public void resetCookie(String nameString path) {
            setCookie(name""nullpath, 0, falsefalse);
        }
        @Override
        public void setCookie(String nameString valueString pathString domainint maxAgeboolean secureboolean httpOnly) {
            javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie(namevalue);
            if (domain != nullcookie.setDomain(domain);
            if (path != nullcookie.setPath(path);
            if (securecookie.setSecure(true);
            if (httpOnlycookie.setHttpOnly(httpOnly);
            cookie.setMaxAge(maxAge);
            .addCookie(cookie);
        }
        @Override
        public OutputStream getOutputStream() {
            try {
                return .getOutputStream();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        @Override
        public void sendError(int codeString message) {
            try {
                .sendError(codemessage);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        @Override
        public void end() {
             = true;
        }
        public boolean isEnded() {
            return ;
        }
    }
        this. = request;
        this. = response;
    }
    @Override
    public Request getRequest() {
        return ;
    }
    @Override
    public Response getResponse() {
        return ;
    }
    @Override
    }
    @Override
    public X509Certificate[] getCertificateChain() {
        throw new IllegalStateException("Not supported yet");
    }
    public boolean isEnded() {
        return .isEnded();
    }
New to GrepCode? Check out our FAQ X