示例#1
0
 public ServletContextImpl(final ServletContainer servletContainer, final Deployment deployment) {
   this.servletContainer = servletContainer;
   this.deployment = deployment;
   this.deploymentInfo = deployment.getDeploymentInfo();
   sessionCookieConfig = new SessionCookieConfigImpl(this);
   ServletSessionConfig sc = deploymentInfo.getServletSessionConfig();
   if (sc != null) {
     sessionCookieConfig.setName(sc.getName());
     sessionCookieConfig.setComment(sc.getComment());
     sessionCookieConfig.setDomain(sc.getDomain());
     sessionCookieConfig.setHttpOnly(sc.isHttpOnly());
     sessionCookieConfig.setMaxAge(sc.getMaxAge());
     sessionCookieConfig.setPath(sc.getPath());
     sessionCookieConfig.setSecure(sc.isSecure());
     if (sc.getSessionTrackingModes() != null) {
       defaultSessionTrackingModes =
           sessionTrackingModes = new HashSet<SessionTrackingMode>(sc.getSessionTrackingModes());
     }
   }
   if (deploymentInfo.getServletContextAttributeBackingMap() == null) {
     this.attributes = new ConcurrentHashMap<String, Object>();
   } else {
     this.attributes = deploymentInfo.getServletContextAttributeBackingMap();
   }
   attributes.putAll(deployment.getDeploymentInfo().getServletContextAttributes());
 }
示例#2
0
  public void initDone() {
    initialized = true;
    Set<SessionTrackingMode> trackingMethods = sessionTrackingModes;
    if (trackingMethods == null || trackingMethods.isEmpty()) {
      sessionConfig = sessionCookieConfig;
    } else {

      if (sessionTrackingModes.contains(SessionTrackingMode.SSL)) {
        sessionConfig = new SslSessionConfig(sessionCookieConfig);
      } else {
        if (sessionTrackingModes.contains(SessionTrackingMode.COOKIE)
            || sessionTrackingModes.contains(SessionTrackingMode.URL)) {
          sessionConfig = sessionCookieConfig;
          sessionCookieConfig.setFallback(
              new PathParameterSessionConfig(sessionCookieConfig.getName().toLowerCase()));
        } else if (sessionTrackingModes.contains(SessionTrackingMode.COOKIE)) {
          sessionConfig = sessionCookieConfig;
        } else if (sessionTrackingModes.contains(SessionTrackingMode.URL)) {
          sessionConfig =
              new PathParameterSessionConfig(sessionCookieConfig.getName().toLowerCase());
        }
      }
    }
  }