All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liveperson.faas.security.JwtExpiryTester Maven / Gradle / Ivy

Go to download

Functions client for invoking lambdas via the eventsource gateway (a.k.a Asgard)

There is a newer version: 1.2.3
Show newest version
package com.liveperson.faas.security;

import com.auth0.jwt.JWT;
import com.auth0.jwt.interfaces.DecodedJWT;

import java.util.Calendar;
import java.util.Date;

public class JwtExpiryTester implements AuthExpiryTester {

    @Override
    public boolean isExpired(String token) {
        return JWT.decode(token).getExpiresAt().before(new Date(System.currentTimeMillis()));
    }

    @Override
    public boolean isAboutToExpire(String token) {
        DecodedJWT jwt = JWT.decode(token);
        Date expiresAt = jwt.getExpiresAt();
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date(System.currentTimeMillis()));
        cal.add(Calendar.MINUTE, 30);
        Date checkDate = cal.getTime();
        return checkDate.after(expiresAt);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy