Package anvil.session

Examples of anvil.session.Session


  }


  public Session doCreate(SessionContainer container, String id, int lifetime, int timeout)
  {
    Session session = super.doCreate(container, id, lifetime, timeout);
    if (session != null) {
      return session;
    }
    return new BasicSession(container, id, lifetime, timeout);
  }
View Full Code Here


  {
   
    if (_required) {

      String pathinfo = context.getPathinfo();
      Session session = context.getSession();
     
      if (session != null) {
        return true;
      }
     
      boolean hascookie = false;
     
      if (_use_cookies) {
        Cookie cookies[] = context.getRequest().getCookies();
        if (cookies != null) {
          int n = cookies.length;
          for(int i=0; i<n; i++) {
            Cookie c = cookies[i];
            if (c.getName().equals(_cookie_name)) {
              String s = c.getValue();
              session = context.getSession(s);
              if (session != null) {
                context.setSession(session);
                hascookie = true;
                break;
              }
            }
          }
        }
       
      }
     
      if (session == null) {
        session = context.createSession();
        context.setSession(session);
      }

      if (_use_cookies && !hascookie) {
        Cookie c = new Cookie(_cookie_name, session.getId());
        c.setMaxAge(_cookie_lifetime);
        c.setSecure(_cookie_secured);
        if (_cookie_domain != null) {
          c.setDomain(_cookie_domain);
        }
        if (_cookie_path != null) {
          c.setPath(_cookie_path);
        }
        context.getResponse().addCookie(c);
      }
     
      if (_auto_redirect) {
        throw new RedirectException(session.getId(), context.getOriginalPathinfo());
       
      } else {
        return true;
      }
    }
View Full Code Here

    if (!_prefs.getRequired()) {
      return true;
    }

    Realm realm = getRealm();
    Session session = context.getSession();
   
    if (realm == null) {
      context.log().error("Couldn't get realm named '"+_prefs.getRealm()+"'");
      try {
        String contentType = MimeTypes.guessContentType(context.getRequest());
        Templates.message(context, contentType, 500);
      } catch(IOException e) {
        context.log().error("Error while writing '500 Internal Server Error' response", e);
      }
      return false;
    }
   
    if (session == null) {
      //cannot authorize if there's no session
     
      return false;
    }
   
    String citizenName = session.getCitizen();
    Citizen citizen = null;

    if (citizenName != null) {
      citizen = realm.getCitizen(citizenName);
    }
View Full Code Here

  }


  public Any getAttribute(Context context, String attribute)
  {
    Session session = _container.getSession(attribute.toString());
    return (session != null) ? new AnySession(session) : UNDEFINED;
  }
View Full Code Here


  public boolean deleteAttribute(Context context, String attribute)
  {
    context.checkAccess(CAN_WRITE);
    Session session = _container.getSession(attribute.toString());
    if (session != null) {
      _container.removeSession(session);
      return true;
    }
    return false;   
View Full Code Here

  {
    Session[] sessions = _container.getSessions();
    int n = sessions.length;
    Array array = new Array(n+1);
    for(int i=0; i<n ;i++) {
      Session session = sessions[i];
      array.append(Any.create(session.getId()), new AnySession(session));
    }
    return array;
  }
View Full Code Here

  private String      _selfID   = "";

 
  public AnyContext(anvil.server.Context context)
  {
    Session session = context.getSession();
    Citizen citizen = context.getCitizen();
    _context      = context;
    _any_request  = new AnyRequest(context.getRequest());
    _any_response = new AnyResponse(context.getResponse());
    _any_session  = (session != null) ? new AnySession(session) : Any.UNDEFINED;
View Full Code Here

  ///
  public static final Object[] p_getSession = { null, "id" };
  public Any m_getSession(Context context, String id)
  {
    context.checkAccess(AnySessionContainer.CAN_READ);
    Session session = _context.getSession(id);
    return (session != null) ? new AnySession(session) : UNDEFINED;
  }
View Full Code Here

      lifetime = parseInt(request[2], 3600);
      if (n>2) {
        timeout = parseInt(request[2], 3000);
      }
    }
    Session session = _container.createSession(lifetime, timeout);
    printSession(output, session);
    output.flush();
  }
View Full Code Here

  public void handleTouch(GenericInputStream input, PrintStream output, String[] request) throws IOException
  {
    int n = request.length;
    if (n>1) {
      String id = request[1];
      Session session = _container.getSession(id);
      if (session != null) {
        //session.touch();
        output.println("ok");
        output.flush();
        return;
View Full Code Here

TOP

Related Classes of anvil.session.Session

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.