title: Is there an API in OpenSAML library to check expiration of SAML2 token?
body: <p>I am working with OpenSAML library to generate SAML2 tokens. I was under the impression that validation signature of the token will also check for its expiration which apparently is not the case. Is there an API provided by the library that I can use to check for the expiration?
  Like <code>checkIfExpired()</code> in the following code snippet:</p>
  
  <pre><code>public static boolean validateSignature(String token, Credential credential)
      {
         try {
  
          InputStream in = new ByteArrayInputStream(token.getBytes());
          Document inCommonMDDoc = ppMgr.parse(in);
          AssertionUnmarshaller unmarshaller = new AssertionUnmarshaller();
          Assertion assertion = (Assertion) unmarshaller
                  .unmarshall(inCommonMDDoc.getDocumentElement());
          SignatureValidator validator = new SignatureValidator(credential);
          try {
              validator.validate(assertion.getSignature());
  
               return checkIfExpired(assertion) ; // -- Checks if assertion has expired and return true/false
  
          } catch (ValidationException e) {
              log.error("Invalid Signature", e);
              return false;
          }
      } catch (Exception e) {
          log.error("Unable to perform Signature Validation", e);
  
      }
  }
  </code></pre>
  
  <p>NOTE: I want to avoid doing it manually if OpenSAML already has an API for it.</p>