Gets the AuthenticationInfo that matches a token.  This method is only called if the info is not already
cached by the realm, so this method does not need to perform any further caching.
438284
@SuppressWarnings("unchecked")
    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token)
            throws AuthenticationException {
        String id;

        if (AnonymousToken.isAnonymous(token)) {
            // Only continue if an anonymous identity has been set
            if (_anonymousId != null) {
                id = _anonymousId;
            } else {
                return null;
            }
        } else {
            id = ((ApiKeyAuthenticationToken) token).getPrincipal();
        }

        return getUncachedAuthenticationInfoForKey(id);
    }
406095
def userinfo_request(self, access_token):
        
        http_method = self._provider_configuration.userinfo_endpoint_method
        if http_method is None or not self._client.userinfo_endpoint:
            return None

        logger.debug('making userinfo request')
        userinfo_response = self._client.do_user_info_request(method=http_method, token=access_token)
        logger.debug('received userinfo response: %s', userinfo_response.to_json())

        return userinfo_response
1333369
public String getLoginNameFromToken(String token) {
        String username = null;
        try {
            final Claims claims = getClaimsFromToken(token);
            username = claims.getSubject();
        } catch (Exception e) {
            log.error("get username from jwt token error : {}", e.getMessage());
        }
        return username;
    }
651854
def _get_authenticated_session(self):
        
        session = requests.Session()
        session.auth = self.auth
        return session
71276
def API_GET(self):  # pylint: disable=arguments-differ
        
        if self.user_manager.session_logged_in():
            return 200, {"authenticated": True, "username": self.user_manager.session_username()}
        else:
            return 200, {"authenticated": False}
765712
public AccountInfo getAccountInfo() {
        OAuthRequest request = new OAuthRequest(Verb.GET, INFO_URL);
        service.signRequest(accessToken, request);
        String content = check(request.send()).getBody();

        return Json.parse(content, AccountInfo.class);
    }
774346
public int getExpiresIn(String tokenGrantType, String scope) {
        int expiresIn = Integer.MAX_VALUE;
        List<Scope> scopes = loadScopes(scope);
        boolean ccGrantType = TokenRequest.CLIENT_CREDENTIALS.equals(tokenGrantType);
        if (TokenRequest.CLIENT_CREDENTIALS.equals(tokenGrantType)) {
            for (Scope s : scopes) {
                if (s.getCcExpiresIn() < expiresIn) {
                    expiresIn = s.getCcExpiresIn();
                }
            }
        } else if (TokenRequest.PASSWORD.equals(tokenGrantType)) {
            for (Scope s : scopes) {
                if (s.getPassExpiresIn() < expiresIn) {
                    expiresIn = s.getPassExpiresIn();
                }
            }
        } else {
            // refresh_token
            for (Scope s : scopes) {
                if (s.getRefreshExpiresIn() < expiresIn) {
                    expiresIn = s.getRefreshExpiresIn();
                }
            }
        }
        if (scopes.size() == 0 || expiresIn == Integer.MAX_VALUE) {
            expiresIn = (ccGrantType) ? OAuthConfig.DEFAULT_CC_EXPIRES_IN : OAuthConfig.DEFAULT_PASSWORD_EXPIRES_IN;
        }
        return expiresIn;
    }
1243146
private boolean hasAuthenticatedMolgenisToken() {
    boolean hasAuthenticatedMolgenisToken = false;
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication instanceof RestAuthenticationToken) {
      hasAuthenticatedMolgenisToken = authentication.isAuthenticated();
    }
    return hasAuthenticatedMolgenisToken;
  }
528392
public static UserGetShakeInfoResult userGetShakeInfo(String accessToken,
                                                          UserGetShakeInfo userGetShakeInfo) {
        return userGetShakeInfo(accessToken,
                JsonUtil.toJSONString(userGetShakeInfo));
    }
1336112
public int auth_getUserId(String authToken)
    throws FacebookException, IOException {
    /*
     * Get the session information if we don't have it; this will populate
	   * the user ID as well.
	   */
    if (null == this._sessionKey)
      auth_getSession(authToken);
    return this._userId;
  }
846182
private boolean loginMissingToken(NextFilter nextFilter,
                                      IoSession session,
                                      HttpRequestMessage httpRequest,
                                      AuthenticationToken authToken,
                                      TypedCallbackHandlerMap additionalCallbacks,
                                      HttpRealmInfo[] realms,
                                      int realmIndex,
                                      LoginContext[] loginContexts) {
        HttpRealmInfo realm = realms[realmIndex];

        // We build a LoginContext here and call login() so that login
        // modules have a chance to any challenge parameters to the initial
        // challenge (KG-2191).
        ResultAwareLoginContext loginContext = null;

        try {


            LoginContextFactory loginContextFactory = realm.getLoginContextFactory();
            TypedCallbackHandlerMap callbackHandlerMap = new TypedCallbackHandlerMap();

            registerCallbacks(session, httpRequest, authToken, callbackHandlerMap);
            callbackHandlerMap.putAll(additionalCallbacks);

            loginContext = (ResultAwareLoginContext) loginContextFactory.createLoginContext(callbackHandlerMap);
            if (loginContext == null) {
                throw new LoginException("Login failed; cannot create a login context for authentication token '" + authToken + "\'.");
            }

            if (loggerEnabled()) {
                log("Login module login required; [%s].", authToken);
            }

            loginContext.login();
        } catch (LoginException le) {
            // Depending on the login modules configured, this could be
            // a very normal condition.
            if (loggerEnabled()) {

                // Ignore the common "all modules ignored case", it just gums
                // up the logs whilst adding no value.
                if (le.getMessage() != null && !le.getMessage().contains("all modules ignored")) {
                    log("Login failed: " + le.getMessage(), le);
                }
            }

            if (loginContext == null) {
                // This can happen if the given authentication token is
                // not one that we support.  And if that is the case, then
                // we will never able to handle the token, so return
                // 403 now.
                writeResponse(HttpStatus.CLIENT_FORBIDDEN, nextFilter, session, httpRequest);
                return false;
            }
        } catch (Exception e) {
            if (loggerEnabled()) {
                log("Login failed.", e);
            }
            writeResponse(HttpStatus.CLIENT_FORBIDDEN, nextFilter, session, httpRequest);
            return false;
        }
        DefaultLoginResult loginResult = loginContext.getLoginResult();
        String challenge = sendChallengeResponse(nextFilter, session, httpRequest, loginResult, realms, realmIndex, loginContexts);
        if (loggerEnabled()) {
            log(String.format("No authentication token was provided.  Issuing an authentication challenge '%s'.", challenge));
        }
        // No matter what happens, we know that the roles currently present
        // are not sufficient for logging in, so return false.
        ResourceAddress localAddress = LOCAL_ADDRESS.get(session);
        String nextProtocol = localAddress.getOption(NEXT_PROTOCOL);
        if ("http/1.1".equals(nextProtocol)) {
            HttpMergeRequestFilter.INITIAL_HTTP_REQUEST_KEY.remove(session);
        }

        return false;
    }
1050105
def get_token(self):
        
        if not self.authenticated:
            raise ValueError("Must authenticate() as a client first.")

        # If token has expired we'll need to refresh and get a new
        # client credential
        if self.is_expired_token(self.client):
            logging.info("client token expired, will need to refresh token")
            self.authenticate(self.client['id'], self.client['secret'],
                    use_cache=False)

        return self.client['access_token']
78064
def verify_token(self, token) -> bool:
        
        try:
            self.data = jwt.decode(Security.decrypt(token), self.app_secret)
            return True
        except (Exception, BaseException) as error:
            self.errors.append(error)
            return False
        return False
25989
private String getBearerToken(HttpConnectionInterceptorContext context) {
        final AtomicReference<String> iamTokenResponse = new AtomicReference<String>();
        boolean result = super.requestCookie(context, iamServerUrl, iamTokenRequestBody,
                "application/x-www-form-urlencoded", "application/json",
                new StoreBearerCallable(iamTokenResponse));
        if (result) {
            return iamTokenResponse.get();
        } else {
            return null;
        }
    }
1239761
public static String getUserToken(Config config, Context context) {
    AuthInfo authInfo = getUserAuthInfo(config, context);
    if (authInfo != null) {
      return authInfo.getToken();
    }
    return null;
  }
1262036
private String getAuthTokenFromRequest(HttpServletRequest httpRequest) {
        String authToken = httpRequest.getHeader(AUTH_TOKEN_HEADER_KEY);

        if (authToken == null) {
            // token can also exist as request parameter
            authToken = httpRequest.getParameter(AUTH_TOKEN_PARAMETER_KEY);
        }

        return authToken;
    }
105361
def is_authenticated(self):
        
        if not self.token:
            return False

        try:
            self.lookup_token()
            return True
        except exceptions.Forbidden:
            return False
        except exceptions.InvalidPath:
            return False
        except exceptions.InvalidRequest:
            return False