title: Check if user is logged in aws cognito, JAVA
body: <p>I am using Java as back end to communicate with AWS Cognito. I am able to login, logout, create users, sign out and other functions. I am also able to verify an access token by following this <a href="http://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-with-identity-providers.html" rel="nofollow noreferrer">link</a>: </p>
  
  <p>But I want to verify if a user is logged in or not. 
  In JAVA, is there a isLoggedin() function that returns a boolean or is there a way to see if the token is revoked? These functions exist for Android and iOS but what about JAVA.</p>
  
  <p>I thought this verifies if the token is active, but it only verifies if the token is in the right format:</p>
  
  <pre><code>    // This parses token to JWT.
      JWT jwtparser = JWTParser.parse(accessToken);
      String JWTissuer = jwtparser.getJWTClaimsSet().getIssuer(); 
      JWSHeader header = (JWSHeader) jwtparser.getHeader(); 
      Object token_use = jwtparser.getJWTClaimsSet().getClaim("token_use"); 
      Object exp = jwtparser.getJWTClaimsSet().getClaim("iat");
      Date expirationDate = jwtparser.getJWTClaimsSet().getExpirationTime(); 
  
      // Read in JSON Key file saved somewhere safe
      File file = new File("jwks.json");
      String content = FileUtils.readFileToString(file, "utf-8");
      JSONObject JsonObjects = new JSONObject(content);
      JSONArray keysArray = JsonObjects.getJSONArray("keys");
      JSONObject keyString = (JSONObject) keysArray.get(1);
  
      if (header.getKeyID().equals(keyString.get("kid")) &amp;&amp; token_use.toString().equals("access") &amp;&amp; JWTissuer.equals("https://cognito-idp.us-west-2.amazonaws.com/us-west-2_xxxxxxx")) {
          return true;
      } else { return false; }        
  </code></pre>
  
  <p>I want to see if a user is logged in. I have not found an appropriate method to do so.</p>
  
  <p>Mahalo</p>