ToastShaman / dropwizard-auth-jwt

A Dropwizard authentication filter using JSON Web Token (JWT)
Apache License 2.0
116 stars 50 forks source link

JwtClaims.setExpirationTimeMinutesInTheFuture() does not work #37

Open a1anw2 opened 6 years ago

a1anw2 commented 6 years ago

There is a bug with this. For some reason, it is looking for a float; well this is causing some problems with casting and long story short, it does not work correctly.

    private NumericDate offsetFromNow(float offsetMinutes)
    {
        NumericDate numericDate = NumericDate.now();
        float secondsOffset = offsetMinutes * 60;
        numericDate.addSeconds((long)secondsOffset);
        return numericDate;
    }

Needs to be rewritten

    private NumericDate offsetFromNow(int offsetMinutes)
    {
        NumericDate nd = NumericDate.now();
    return nd.addSeconds( 60*offsetMinutes );
    }

As a work around you can manually call the method:

NumericDate nd = NumericDate.now();
nd.addSeconds( 60*60*24 );
claims.setExpirationTime( nd );