MCPcopy Create free account
hub / github.com/auth0/JWTDecode.Android / isExpired

Method isExpired

lib/src/main/java/com/auth0/android/jwt/JWT.java:161–171  ·  view source on GitHub ↗

Validates that this JWT was issued in the past and hasn't expired yet. @param leeway the time leeway in seconds in which the token should still be considered valid. @return if this JWT has already expired or not.

(long leeway)

Source from the content-addressed store, hash-verified

159 * @return if this JWT has already expired or not.
160 */
161 public boolean isExpired(long leeway) {
162 if (leeway < 0) {
163 throw new IllegalArgumentException("The leeway must be a positive value.");
164 }
165 long todayTime = (long) (Math.floor(new Date().getTime() / 1000) * 1000); //truncate millis
166 Date futureToday = new Date(todayTime + leeway * 1000);
167 Date pastToday = new Date(todayTime - leeway * 1000);
168 boolean expValid = payload.exp == null || !pastToday.after(payload.exp);
169 boolean iatValid = payload.iat == null || !futureToday.before(payload.iat);
170 return !expValid || !iatValid;
171 }
172
173 /**
174 * Returns the String representation of this JWT.

Calls

no outgoing calls