Package org.serviceconnector.web

Examples of org.serviceconnector.web.WebSession


      this.loadBody(writer, request);
      writer.flush();
      return;

    }
    WebSession webSession = request.getSession(false);
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    XMLStreamWriter writer = factory.createXMLStreamWriter(os);
    writer.writeStartDocument();
    writer.writeStartElement("sc-web");
    writer.writeStartElement("head");
    // write url path
    String url = request.getURL();
    if (url != null) {
      int qPos = url.indexOf("?");
      if (qPos >= 0) {
        url = url.substring(0, qPos);
      }
      // check if ajax content call
      String id = request.getParameter("id");
      if (id != null) {
        url = Constants.SLASH + id;
      }
      writer.writeStartElement("meta");
      writer.writeAttribute("path", url);
      writer.writeEndElement(); // close meta tag
    }
    // write query string
    writer.writeStartElement("meta");
    writer.writeAttribute("creation", DateTimeUtility.getCurrentTimeZoneMillis());
    writer.writeEndElement(); // close meta tag
    // write sc version
    writer.writeStartElement("meta");
    writer.writeAttribute("scversion", SCVersion.CURRENT.toString());
    writer.writeEndElement(); // close meta tag
    WebConfiguration webConfiguration = WebContext.getWebConfiguration();
    // write web color schema
    writer.writeStartElement("meta");
    writer.writeAttribute("colorscheme", webConfiguration.getColorScheme());
    writer.writeEndElement(); // close meta tag
    // write sc header prefix
    writer.writeStartElement("meta");
    writer.writeAttribute("headerprefix", webConfiguration.getPageHeaderPrefix());
    writer.writeEndElement(); // close meta tag
    // write sc status
    writer.writeStartElement("meta");
    writer.writeAttribute("scstatus", "success");
    writer.writeEndElement(); // close meta tag
    // write scconfigfile
    writer.writeStartElement("meta");
    writer.writeAttribute("scconfigfile", SystemInfo.getConfigFileName());
    writer.writeEndElement(); // close meta tag
    // write current ip host
    String hostName = InetAddress.getLocalHost().getHostName();
    writer.writeStartElement("meta");
    writer.writeAttribute("hostname", hostName);
    writer.writeEndElement(); // close meta tag
    if (webSession != null) {
      writer.writeStartElement("meta");
      writer.writeAttribute("jsessionid", webSession.getId());
      writer.writeEndElement(); // close meta tag
      writer.writeStartElement("meta");
      writer.writeAttribute("urlencoded", ";sid=" + webSession.getId());
      writer.writeEndElement(); // close meta tag
    }
    for (Entry<String, String> entry : this.metaMap.entrySet()) {
      writer.writeStartElement("meta");
      writer.writeAttribute(entry.getKey(), entry.getValue());
View Full Code Here


      }
      response.setContentType(getResourceType(url));
      dumpStream(is, responseOutputStream);
      return;
    }
    WebSession webSession = request.getSession(false);
    // load xml model as stream
    ByteArrayOutputStream xmlOS = new ByteArrayOutputStream();
    XMLDocument xmlDocument = new XMLDocument(request);
    if (this.isLoginAction(request)) {
      try {
        webSession = this.login(request, response);
        if (webSession != null) {
          response.redirect("/;sid=" + webSession.getId());
        } else {
          response.redirect("/;");
        }
        return;
      } catch (LoginException e) {
View Full Code Here

      throw new LoginException("not authorized");
    }
    if (password.equals(contextPassword) == false) {
      throw new LoginException("not authorized");
    }
    WebSession webSession = request.getSession(true);
    if (webSession == null) {
      // check if has been created before
      throw new LoginException("internal error, no session");
    }
    webSession.setCredentials(new WebCredentials(contextUserid, contextPassword));
    webSession.setUserAgent(request.getHeader("User-Agent"));
    webSession.setRemoteHost(request.getRemoteHost());
    webSession.setRemotePort(request.getRemotePort());
    webSession.setHost(request.getHost());
    webSession.setPort(request.getPort());
    request.setAttribute("JSESSIONID", webSession.getId());
    return webSession;
  }
View Full Code Here

    request.setAttribute("JSESSIONID", webSession.getId());
    return webSession;
  }

  public void logout(IWebRequest request) throws Exception {
    WebSession webSession = request.getSession(false);
    if (webSession == null) {
      return;
    }
    webSession.getCredentials().clear();
    WebContext.getWebSessionRegistry().removeSession(webSession);
  }
View Full Code Here

      return false;
    }
    if (url.startsWith("/ajax/")) {
      return true;
    }
    WebSession webSession = request.getSession(false);
    if (webSession == null) {
      return false;
    }
    String userid = webSession.getCredentials().getUserId();
    if (userid != null) {
      return true;
    }
    return false;
  }
View Full Code Here

      this.loadBody(writer, request);
      writer.flush();
      return;

    }
    WebSession webSession = request.getSession(false);
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    XMLStreamWriter writer = factory.createXMLStreamWriter(os);
    writer.writeStartDocument();
    writer.writeStartElement("sc-web");
    writer.writeStartElement("head");
    // write url path
    String url = request.getURL();
    if (url != null) {
      int qPos = url.indexOf("?");
      if (qPos >= 0) {
        url = url.substring(0, qPos);
      }
      // check if ajax content call
      String id = request.getParameter("id");
      if (id != null) {
        url = Constants.SLASH + id;
      }
      writer.writeStartElement("meta");
      writer.writeAttribute("path", url);
      writer.writeEndElement(); // close meta tag
    }
    // write query string
    writer.writeStartElement("meta");
    writer.writeAttribute("creation", DateTimeUtility.getCurrentTimeZoneMillis());
    writer.writeEndElement(); // close meta tag
    // write sc version
    writer.writeStartElement("meta");
    writer.writeAttribute("scversion", SCVersion.CURRENT.toString());
    writer.writeEndElement(); // close meta tag
    WebConfiguration webConfiguration = WebContext.getWebConfiguration();
    // write web color schema
    writer.writeStartElement("meta");
    writer.writeAttribute("colorscheme", webConfiguration.getColorScheme());
    writer.writeEndElement(); // close meta tag
    // write sc header prefix
    writer.writeStartElement("meta");
    writer.writeAttribute("headerprefix", webConfiguration.getPageHeaderPrefix());
    writer.writeEndElement(); // close meta tag
    // write sc status
    writer.writeStartElement("meta");
    writer.writeAttribute("scstatus", "success");
    writer.writeEndElement(); // close meta tag
    // write scconfigfile
    writer.writeStartElement("meta");
    writer.writeAttribute("scconfigfile", SystemInfo.getConfigFileName());
    writer.writeEndElement(); // close meta tag
    // write current ip host
    String hostName = InetAddress.getLocalHost().getHostName();
    writer.writeStartElement("meta");
    writer.writeAttribute("hostname", hostName);
    writer.writeEndElement(); // close meta tag
    if (webSession != null) {
      writer.writeStartElement("meta");
      writer.writeAttribute("jsessionid", webSession.getId());
      writer.writeEndElement(); // close meta tag
      writer.writeStartElement("meta");
      writer.writeAttribute("urlencoded", ";sid=" + webSession.getId());
      writer.writeEndElement(); // close meta tag
    }
    for (Entry<String, String> entry : this.metaMap.entrySet()) {
      writer.writeStartElement("meta");
      writer.writeAttribute(entry.getKey(), entry.getValue());
View Full Code Here

TOP

Related Classes of org.serviceconnector.web.WebSession

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.