Package org.ocpsoft.rewrite.servlet.util

Examples of org.ocpsoft.rewrite.servlet.util.QueryStringBuilder$EncodingHandler


      else if (event instanceof HttpOutboundServletRewrite)
      {
         Set<String> parameters = getPathRequestParameters();

         String outboundURL = ((HttpOutboundServletRewrite) event).getOutboundAddress().toString();
         QueryStringBuilder query = QueryStringBuilder.createNew();
         if (outboundURL.contains("?"))
         {
            query.addParameters(outboundURL);
            for (String string : parameters) {
               List<String> values = query.removeParameter(string);
               if (values.size() > 1)
               {
                  query.addParameter(string, values.subList(1, values.size()).toArray(new String[] {}));
               }
            }
         }

         Address outboundAddress = ((HttpOutboundServletRewrite) event).getOutboundAddress();

         Substitute substitute = Substitute.with(requestPattern + query.toQueryString());
         substitute.setParameterStore(store);

         substitute.perform(event, context);

         Address rewrittenAddress = ((HttpOutboundServletRewrite) event).getOutboundAddress();
View Full Code Here


   {
      if ((event instanceof HttpInboundServletRewrite) && DispatchType.isRequest().evaluate(event, context))
      {
         HttpInboundServletRewrite in = (HttpInboundServletRewrite) event;

         QueryStringBuilder query = QueryStringBuilder.createNew();
         query.addParameters(in.getInboundAddress().getQuery());

         String token = query.decode().getParameter(tokenName);
         if (token != null)
         {
            String decoded = encodingStrategy.decode(token);

            if (checksumStrategy.checksumValid(decoded))
            {
               decoded = checksumStrategy.removeChecksum(decoded);
               query.removeParameter(tokenName);
               QueryStringBuilder queryParams = QueryStringBuilder.createFromEncoded(decoded);
               RewriteWrappedRequest request = RewriteWrappedRequest.getCurrentInstance(in.getRequest());
               for (Entry<String, List<String>> param : queryParams.getParameterMap().entrySet()) {
                  for (String value : param.getValue()) {
                     Maps.addArrayValue(request.getModifiableParameters(), param.getKey(), value);
                  }
               }
            }
            else if (onfailure != null)
            {
               onfailure.perform(event, context);
            }
         }
         else if (!query.isEmpty() && inboundCorrection)
         {
            in.redirectTemporary(in.getAddress().getPathAndQuery());
         }
      }

      else if (event instanceof HttpOutboundServletRewrite)
      {
         HttpOutboundServletRewrite out = (HttpOutboundServletRewrite) event;

         String outboundURL = out.getOutboundAddress().toString();
         URLBuilder url = URLBuilder.createFrom(outboundURL);

         url.getQueryStringBuilder().removeParameter(tokenName);

         QueryStringBuilder newQuery = QueryStringBuilder.createNew();
         for (String param : excludedParams) {
            newQuery.addParameter(param, url.getQueryStringBuilder().removeParameter(param).toArray(new String[] {}));
         }

         if (!params.isEmpty())
         {
            for (String param : url.getQueryStringBuilder().getParameterNames())
            {
               if (!params.contains(param))
               {
                  newQuery.addParameter(param,
                           url.getQueryStringBuilder().removeParameter(param).toArray(new String[] {}));
               }
            }
         }

         if (outboundURL.contains("?") && (outboundURL.startsWith(out.getContextPath()) || outboundURL.startsWith("/")))
         {
            if (!url.getQueryStringBuilder().isEmpty())
            {
               String encoded = checksumStrategy.embedChecksum(url.getQueryStringBuilder().toQueryString());
               encoded = encodingStrategy.encode(encoded);

               newQuery.addParameter(tokenName, encoded);
               out.setOutboundAddress(AddressBuilder.create(url.toPath() + newQuery.toQueryString()));
            }
         }
      }
   }
View Full Code Here

         final String parameterName = name;

         @Override
         public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context)
         {
            QueryStringBuilder queryString = QueryStringBuilder.createFromEncoded(event.getAddress().getQuery())
                     .decode();

            for (String name : queryString.getParameterNames()) {
               String[] parameterValues = queryString.getParameterValues(name);
               if (parameterName.equals(name))
               {
                  if (parameterValues == null || (parameterValues.length == 0))
                  {
                     return pattern.parse("").matches();
View Full Code Here

         final ParameterizedPatternParser pattern = new RegexParameterizedPatternParser(valuePattern);

         @Override
         public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context)
         {
            QueryStringBuilder queryString = QueryStringBuilder.createFromEncoded(event.getAddress().getQuery())
                     .decode();

            for (String name : queryString.getParameterNames()) {

               for (String value : queryString.getParameterValues(name)) {
                  if (value != null && pattern.parse(value).submit(event, context))
                  {
                     return true;
                  }
               }
View Full Code Here

TOP

Related Classes of org.ocpsoft.rewrite.servlet.util.QueryStringBuilder$EncodingHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.