Package com.adito.core.stringreplacement

Examples of com.adito.core.stringreplacement.VariableReplacement


    LaunchSession launchSession = LaunchSessionFactory.getInstance()
            .getLaunchSession(request.getParameter(LaunchSession.LAUNCH_ID));
    launchSession.checkAccessRights(null, getSessionInfo(request));
    ReplacementProxyWebForward f = (ReplacementProxyWebForward) launchSession.getResource();

    VariableReplacement r = new VariableReplacement();
    r.setServletRequest(request);
    r.setLaunchSession(launchSession);
    String destinationURL = r.replace(f.getDestinationURL());

    CoreEvent evt = new ResourceAccessEvent(this,
                        WebForwardEventConstants.WEB_FORWARD_STARTED,
            f,
            launchSession.getPolicy(),
View Full Code Here


                        CoreEvent.STATE_SUCCESSFUL).addAttribute(WebForwardEventConstants.EVENT_ATTR_WEB_FORWARD_URL,
            wf.getDestinationURL()).addAttribute(WebForwardEventConstants.EVENT_ATTR_WEB_FORWARD_TYPE,
            ((WebForwardTypeItem) WebForwardTypes.WEB_FORWARD_TYPES.get(wf.getType())).getName());
        CoreServlet.getServlet().fireCoreEvent(evt);
       
        VariableReplacement replacer = new VariableReplacement();
        replacer.setLaunchSession(launchSession);
        URL url = new URL(replacer.replace(wf.getDestinationURL()));
        MultiplexedConnection agent = DefaultAgentManager.getInstance().getAgentBySession(getSessionInfo(request));
        int port = DefaultAgentManager.getInstance().openURL((AgentTunnel)agent, url, launchSession);
        if(port == -1) {
          throw new Exception("Agent couldn't open tunnel.");
        }
View Full Code Here

    return client.execute(method);
  }

  URL getTarget(LaunchSession launchSession, RequestHandlerRequest request) throws MalformedURLException {
    ReverseProxyWebForward webForward = (ReverseProxyWebForward) launchSession.getResource();
    VariableReplacement r = new VariableReplacement();
    r.setRequest(request);
    r.setSession(launchSession.getSession());
    r.setPolicy(launchSession.getPolicy());

    URL target = new URL(r.replace(webForward.getDestinationURL()));

    if (log.isDebugEnabled()) {
      log.debug("Reverse proxy target  " + target.toExternalForm());
    }
    return target;
View Full Code Here

  ProxiedHttpMethod getMethod(HttpClient client, LaunchSession launchSession, RequestHandlerRequest request, URL target) {

    ReverseProxyWebForward webForward = (ReverseProxyWebForward) launchSession.getResource();
    ProxiedHttpMethod method;

    VariableReplacement v = new VariableReplacement();
    v.setRequest(request);
    v.setSession(launchSession.getSession());
    v.setPolicy(launchSession.getPolicy());
   
    /**
     * POST parameters are now not being
     */

    if (!webForward.getFormType().equals(WebForwardTypes.FORM_SUBMIT_NONE)
        && !webForward.getFormType().equals(WebForwardTypes.FORM_SUBMIT_NONE)
        && !webForward.getFormType().equals("")
        && !webForward.getFormType().equals(WebForwardTypes.FORM_SUBMIT_JAVASCRIPT)
        && !Boolean.TRUE.equals(launchSession.getAttribute(LAUNCH_ATTR_AUTH_POSTED))) {

      /**
       * This code will automatically submit form parameters. If it is a post,
       * then we ignore the parameters request and use the webforward target.
       */
      method = new ProxiedHttpMethod(webForward.getFormType(),
              target.getFile(),
              webForward.getFormType().equals(WebForwardTypes.FORM_SUBMIT_POST) new MultiMap() : new MultiMap(request.getParameters()),
              launchSession.getSession(),
              webForward.getFormType().equals(WebForwardTypes.FORM_SUBMIT_POST));

      if (webForward.getCharset() != null
          && !webForward.getCharset().equals("")
          && !webForward.getCharset().equals(WebForwardTypes.DEFAULT_ENCODING))
        method.setCharsetEncoding(webForward.getCharset());

      StringTokenizer tokens = new StringTokenizer(webForward.getFormParameters(), "\n");
      int idx;
      String param;
     
      while (tokens.hasMoreTokens()) {
        param = v.replace(tokens.nextToken().trim());
        idx = param.indexOf('=');
        if (idx > -1) {
          method.addParameter(param.substring(0, idx), param.substring(idx + 1));
        } else
          method.addParameter(param, "");
View Full Code Here

          throw new UndefinedParameterException("Parameter " + name
              + " is undefined");
        }
      }

      VariableReplacement r = new VariableReplacement();
      r.setApplicationShortcut(app, null);
      r.setSession(sessionInfo);
      p.setAttribute("value", r.replace(value));
    }

    XMLOutputter output = new XMLOutputter();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    output.output(element, out);

    String xml = new String(out.toByteArray());

    params = element.getChildren("parameter");

    Map parameters = new HashMap();
    for (Iterator it = params.iterator(); it.hasNext();) {
      Element p = (Element) it.next();
      parameters.put(p.getAttributeValue("name"), p
          .getAttributeValue("value"));
    }

    VariableReplacement r = new VariableReplacement();
    r.setApplicationShortcut(app, parameters);
    r.setSession(sessionInfo);
    String processed = r.replace(xml);

    if (log.isDebugEnabled())
      log.debug("Returning '" + processed + "'");
    return processed;
  }
View Full Code Here

        // Build up the parameter map
        requestParameters = new RequestParameterMap(request);
        proxyURIDetails = requestParameters.getProxiedURIDetails();

        VariableReplacement r = new VariableReplacement();
        r.setRequest(request);
        r.setSession(launchSession.getSession());
        r.setPolicy(launchSession.getPolicy());
        String actualURL = r.replace(webForward.getDestinationURL());
       
        if (proxyURIDetails.getProxiedURL() == null) {
            throw new Exception("No sslex_url parameter provided.");
        }
       
View Full Code Here

         
        }
      }
       */
     
      VariableReplacement r = new VariableReplacement();
      r.setServletRequest(request);
      r.setLaunchSession(launchSession);
      url = r.replace(url);

      CoreEvent evt = new ResourceAccessEvent(this,
                            WebForwardEventConstants.WEB_FORWARD_STARTED,
              wf,
              launchSession.getPolicy(),
View Full Code Here

  public static String processAgentParameters(ExtensionDescriptor des, HttpServletRequest request, SessionInfo session,
                        Properties properties) throws UndefinedParameterException, JDOMException,
          IOException, CoreException {
    try {
      Element element = des.createProcessedDescriptorElement(session);
      VariableReplacement r = new VariableReplacement();
      r.setApplicationShortcut(des, null);
      r.setSession(session);
      r.setServletRequest(request);
      Map<String, String> parameterValues = new HashMap<String, String>();
      for(Iterator i = request.getParameterMap().keySet().iterator(); i.hasNext(); ) {
        String key = (String)i.next();
        parameterValues.put(key, request.getParameter(key));
      }
View Full Code Here

   */
  public static String processApplicationParameters(LaunchSession launchSession, Properties properties, Map<String, String> parameterValues,
                            String applicationId) throws Exception {
    ExtensionDescriptor des = ExtensionStore.getInstance().getExtensionDescriptor(applicationId);
    Element element = des.createProcessedDescriptorElement(launchSession.getSession());
    VariableReplacement r = new VariableReplacement();
    r.setApplicationShortcut(des, null);
    r.setLaunchSession(launchSession);
    // TODO different way of getting 'request' parameters when no servlet request is available
    return getXML(element, parameterValues, r, des);
  }
View Full Code Here

          forward = "/showHome.do";
        }
      }
      name = name.substring(0, idx);
           
            VariableReplacement r = new VariableReplacement();
            r.setServletRequest(request);
            forward = r.replace(forward);           
    }

    StringBuffer buf = new StringBuffer(forward);
    if (includeParameters && !"".equals(forward)) {
      // Build up the URL to forard to
View Full Code Here

TOP

Related Classes of com.adito.core.stringreplacement.VariableReplacement

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.