コード例 #1
0
 @Override
 public void doFilter(
     final ServletRequest request, final ServletResponse response, final FilterChain chain)
     throws IOException, ServletException {
   HttpServletRequest httpRequest = ((HttpServletRequest) request);
   StringBuffer sourceUrl = httpRequest.getRequestURL();
   String queryString = httpRequest.getQueryString();
   if (queryString != null) {
     sourceUrl.append("?");
     sourceUrl.append(queryString);
   }
   try {
     request.setAttribute(
         AbstractGatewayFilter.SOURCE_REQUEST_URL_ATTRIBUTE_NAME,
         Parser.parse(sourceUrl.toString()));
   } catch (URISyntaxException e) {
     throw new ServletException(e);
   }
   try {
     Subject.doAs(
         subject,
         new PrivilegedExceptionAction<Void>() {
           @Override
           public Void run() throws Exception {
             chain.doFilter(request, response);
             return null;
           }
         });
   } catch (PrivilegedActionException e) {
     throw new ServletException(e);
   }
 }
コード例 #2
0
 private String rewriteValue(UrlRewriter rewriter, String value, String rule) {
   try {
     Template input = Parser.parse(value);
     Template output = rewriter.rewrite(this, input, UrlRewriter.Direction.IN, rule);
     value = output.toString();
   } catch (URISyntaxException e) {
     LOG.failedToParseValueForUrlRewrite(value);
   }
   return value;
 }
コード例 #3
0
 private Template getSourceUrl() {
   Template urlTemplate = null;
   StringBuffer urlString = super.getRequestURL();
   String queryString = super.getQueryString();
   if (queryString != null) {
     urlString.append('?');
     urlString.append(queryString);
   }
   try {
     urlTemplate = Parser.parse(urlString.toString());
   } catch (URISyntaxException e) {
     LOG.failedToParseValueForUrlRewrite(urlString.toString());
     // Shouldn't be possible given that the URL is constructed from parts of an existing URL.
     urlTemplate = null;
   }
   return urlTemplate;
 }