public static void validateTime ( String timestamp , int duration ) throws Exception { Date date = getTimestampFormatter ( ) . parse ( timestamp ) ; long sign_time = date . getTime ( ) ; long now_time = System . currentTimeMillis ( ) ; long diff = now_time - sign_time ; long min_diff = diff / ( 60 * 1000 ) ; if ( min_diff >= duration ) { throw new GeneralSecurityException ( "Authorization token has expired." ) ; } }
Validates the timestamp and insures that it falls within the specified duration .