コード例 #1
0
        public static Session getSession(Agent agent, HttpCookieCollection cookies)
        {
            if (cookies == null)
            {
                return(null);
            }

            String sid = agent.GetAuthCookieValue(cookies);

            if (String.IsNullOrEmpty(sid))
            {
                return(null);
            }

            Session userSession = getSessionFromCache(sid);

            if (userSession == null)
            {
                lock (sid){
                    userSession = getSessionFromCache(sid);
                    try {
                        session.Response token = (session.Response) new session.Request(sid, cookies).getResponse();
                        if (token != null)
                        {
                            userSession = new Session(token);
                        }
                    } catch (SessionException) {
                        return(null);
                    } catch (Exception) {
                        return(null);
                    }
                }
            }
            return(userSession);
        }
コード例 #2
0
 public Session(string sessionId)
 {
     try{
         token = Get(new session.Request(sessionId));
     }catch (SessionException) {
         //cache session not found 1 min
         _token = null;
         _cache.Set(sessionId, this, 1);
     }
     this.sessionId = sessionId;
 }
コード例 #3
0
        public Session(auth.Response authResponse)
        {
            session.Request request = new session.Request(authResponse.ssoToken);
            request.cookieContainer = authResponse.cookieContainer;
            //remove AMAuthCookie after auth
            CookieCollection cc = request.cookieContainer.GetCookies(request.getUrl());

            foreach (Cookie co in cc)
            {
                if (co.Name.Equals("AMAuthCookie"))
                {
                    co.Expired = true;
                }
            }
            token          = Get(request);
            this.sessionId = token.sid;
        }
コード例 #4
0
        public static Session getSession(Agent agent, Session oldSession)
        {
            if (oldSession == null || oldSession.token == null)
            {
                return(null);
            }
            Session session = getSessionFromCache(oldSession.token.sid);

            if (session != null)
            {
                return(session);
            }
            try {
                session.Response token = (session.Response) new session.Request(oldSession).getResponse();
                if (token == null)
                {
                    return(null);
                }
                return(new Session(token));
            } catch (SessionException) {
                return(null);
            }
        }
コード例 #5
0
 public Session(auth.Response authResponse)
 {
     token = (session.Response) new session.Request(authResponse).getResponse();
 }
コード例 #6
0
 private Session(session.Response token)
 {
     this.token = token;
 }