Reads session from JWT-token.
Returns <code>null</code> if fails.
491793
static @Nullable LogMonitorSession readSessionFromJWT(String token) {
		try {
			final Jwt jwt = Jwt.decode(token);
			JSONObject payload = jwt.getPayload();

			LogMonitorSession config = new LogMonitorSession();

			// recipients
			JSONArray recipientsJson = payload.optJSONArray("recipients");
			if (recipientsJson != null) {
				String[] recipients = new String[recipientsJson.length()];
				for (int i = 0; i < recipientsJson.length(); ++i) {
					recipients[i] = recipientsJson.optString(i);
				}

				config.emailRecipients = recipients;
			}

			return config;
		} catch (Exception e) {
			ApptentiveLog.e(e, "Exception while parsing access token: '%s'", token);
			logException(e);
			return null;
		}
	}
659214
def get_jwt(self, request):
        
        try:
            authorization = request.authorization
        except ValueError:
            return None
        if authorization is None:
            return None
        authtype, token = authorization
        if authtype.lower() != self.auth_header_prefix.lower():
            return None
        return token
89008
private Session getCurrentSession() {
		//no logging allowed, since this is called by logging process itself
		//this won't work in a remote component
		synchronized (requestsByThreadId) {
			StandardRequest request = (StandardRequest) requestsByThreadId.get(Thread.currentThread().hashCode());
			if (request != null) {
				return request.getSession(false);
			}
		}
		return null;
	}
1008393
public GetSessionTokenResponse getSessionToken(GetSessionTokenRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        checkIsTrue(request.getDurationSeconds() > 0, "the durationSeconds parameter should be greater than zero");

        InternalRequest internalRequest = new InternalRequest(HttpMethodName.POST,
                HttpUtils.appendUri(this.getEndpoint(), URL_PREFIX, GET_SESSION_TOKEN_PATH));
        if (request.getDurationSeconds() != null) {
            internalRequest.addParameter("durationSeconds", String.valueOf(request.getDurationSeconds()));
        }
        internalRequest.setCredentials(request.getRequestCredentials());
        internalRequest.addHeader(Headers.CONTENT_LENGTH,
                String.valueOf(request.getAcl() == null ? 0 : request.getAcl().length()));
        internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json");
        if (request.getAcl() != null) {
            internalRequest.setContent(RestartableInputStream.wrap(request.getAcl().getBytes()));
        }
        return this.invokeHttpClient(internalRequest, GetSessionTokenResponse.class);
    }
416231
public String auth_getSession(String authToken) throws FacebookException,
                                                         IOException {
    if (null != this._sessionKey) {
      return this._sessionKey;
    }
    Document d =
      this.callMethod(FacebookMethod.AUTH_GET_SESSION, 
                      new Pair<String, CharSequence>("auth_token", authToken.toString()));
    this._sessionKey =
        d.getElementsByTagName("session_key").item(0).getFirstChild().getTextContent();
    this._userId = Integer.parseInt(d.getElementsByTagName("uid").item(0).getFirstChild().getTextContent());
    if (this._isDesktop) {
      this._sessionSecret =
          d.getElementsByTagName("secret").item(0).getFirstChild().getTextContent();
    }
    return this._sessionKey;
  }
977161
public Instant getCreatedTimeFromToken(String token) {
        try {
            final Claims claims = getClaimsFromToken(token);
            return Instant.ofEpochMilli((Long) claims.get(CLAIM_KEY_CREATED));
        } catch (Exception e) {
            log.error("get created Time from jwt token error : {}", e.getMessage());
            return null;
        }
    }
828501
@Override
  public void readSessionData() {
    this.dispatcher.execute(this.userService.isCurrentUserLoggedIn(),
        new AbstractSimpleRestCallback<GwtpSpringSession<T>, Boolean, HttpMessages>(this, this) {

          @Override
          public void onSuccess(final Boolean presult) {
            if (BooleanUtils.isTrue(presult)) {
              // we do have a logged in user, read it
              GwtpSpringSession.this.dispatcher.execute(
                  GwtpSpringSession.this.userService.getCurrentUser(),
                  new AbstractSimpleRestCallback<GwtpSpringSession<T>, T, HttpMessages>(
                      GwtpSpringSession.this, GwtpSpringSession.this) {

                    @Override
                    public void onSuccess(final T presult) {
                      GwtpSpringSession.this.setUser(presult);
                    }
                  });
            } else {
              GwtpSpringSession.this.setUser(null);
            }
          }

        });
  }
378470
private Claims getClaimsFromToken(String token) {
        Claims claims;
        try {
            claims = Jwts.parser()
                    .setSigningKey(jwtProperties.getSecret())
                    .parseClaimsJws(token)
                    .getBody();
        } catch (Exception e) {
            log.error("get claims from jwt token error : {}", e.getMessage());
            claims = null;
        }
        return claims;
    }
680335
def get_session_token(self):
        
        # self.logging.info('Getting session token')
        # Rather than testing any previous session tokens to see if they are still valid, simply delete old tokens in
        # preparation of the creation of new ones
        try:
            os.remove(os.path.join(self.file_path, 'session_token'))
        except FileNotFoundError:
            pass
        # Create a new session
        session_request = OAuth1Session(self.consumer_key,
                                        self.consumer_secret,
                                        access_token=self.access_token,
                                        access_token_secret=self.access_secret)
        # Perform a GET request with the appropriate keys and tokens
        r = session_request.get(self.session_token_url)
        # If the status code is '200' (OK), proceed
        if r.status_code == 200:
            # Save the JSON-decoded token secret and token
            self.session_token = r.json()['oauth_token']
            self.session_secret = r.json()['oauth_token_secret']
            # Write the token and secret to file
            self.write_token('session_token', self.session_token, self.session_secret)
        # Any other status than 200 is considered a failure
        else:
            print('Failed:')
            print(r.json()['message'])
991478
function readSession(intentObj, next) {
    let headers = intentObj.client().headers;
    let sessId;
    try {
      let cookies = cookie.parse(headers['cookie']);
      if (typeof cookies[opt.cookieName] === 'string') {
        let tmp = storeObj.verifySignature(cookies[opt.cookieName]);
        if (tmp) {
          sessId = tmp;
        }
      }
    } catch (e) {
    }
    if (!sessId) sessId = storeObj.readCustomSource(intentObj);
    // IF we don't have a session, we don't have what to read.
    if (!sessId) {
      sessId = storeObj.generateId();
      if (opt.authorization && !intentObj.authorization) {
        intentObj._setAuthorization(AUTHORIZATION_TYPE, sessId);
      }
      intentObj.session = new SessionData(sessId);
      intentObj.session.isNew(true);
      return next();
    }
    if (intentObj.session && intentObj.session.id === sessId) {
      return next();
    }
    // otherwise, we have to retrieve it.
    storeObj.readSession(sessId, (err, data, custom) => {
      // if we failed tor ead from store, empty session.
      if (err) {
        if (err.ns !== 'SESSION') {
          logger.warn('Failed to read session data for sid ' + sessId, err);
        }
        intentObj.session = new SessionData(sessId);
        intentObj.session.isNew(true);
      } else {
        // if there is no session data, we have a new session.
        if (typeof data !== 'object' || !data) {
          intentObj.session = new SessionData(sessId);
          intentObj.session.isNew(true);
        } else {
          intentObj.session = new SessionData(sessId, data);
          intentObj.session.isNew(false);
        }
      }
      if (custom && intentObj.session._setFields) {
        intentObj.session._setFields(custom);
      }
      if (opt.authorization && !intentObj.authorization) {
        intentObj._setAuthorization(AUTHORIZATION_TYPE, sessId);
      }
      next();
    }, false);
  }
299496
@Override
	public String getCustomCacheKeyFromJwtSSOToken(String encodedjwt) {
		// TODO Auto-generated method stub
		JwtSsoTokenUtils tokenUtil = getSimpleJwtSsoTokenUtils();
		if (encodedjwt != null) {
			return tokenUtil.getCustomCacheKeyFromToken(encodedjwt);
		}
		return null;
	}
933196
private static function sessionRead()
	{
		// Web
		if ( isset( $_SERVER['SERVER_PROTOCOL'] ) ) {

			if ( isset( $_SESSION['auth'] ) ) return $_SESSION['auth'];

			Session::start();

			return ( isset( $_SESSION['auth'] ) ) ? $_SESSION['auth'] : array();
		}
		// CLI
		else {
			$json = @file_get_contents( '_cli_fake_session' );
			$value = json_decode( $json , true );

			return ( is_array( $value ) ) ? $value : array();
		}
	}
895680
private synchronized Jwt getJwt(ICacheStrategy cacheStrategy, Jwt.Key key) {
        Jwt result = cacheStrategy.getCachedJwt(key);
        if(result == null) {
            //cache an empty JWT first.
            result = new Jwt(key);
            cacheStrategy.cacheJwt(key, result);
        }
        return result;
    }
1091794
private static String readToken(Buffer buffer) {
    try {
      long tokenSize = buffer.indexOfElement(TOKEN_DELIMITERS);
      if (tokenSize == -1L) tokenSize = buffer.size();

      return tokenSize != 0L
          ? buffer.readUtf8(tokenSize)
          : null;
    } catch (EOFException e) {
      throw new AssertionError();
    }
  }
1089109
public Token peek() {
		if (scopes.isEmpty()) {
			return null;
		} else {
			Token token = scopes.get(scopes.size() - 1);
			return token;
		}
	}
52381
public Date getExpirationDateFromToken(String token) {
        Date expiration;
        try {
            final Claims claims = getClaimsFromToken(token);
            return claims.getExpiration();
        } catch (Exception e) {
            log.error("get expiration Time from jwt token error : {}", e.getMessage());
            return null;
        }
    }
1147589
public StandardSession getSessionByToken(String token) {
		StandardSession session;
		synchronized (sessions) {
			session = (StandardSession) sessions.get(token);
			if (session != null) {
				session.updateLastAccessedTime();
			}
		}
		return session;
	}