-
Notifications
You must be signed in to change notification settings - Fork 928
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from auth0/clock-test-accessible
Make Clock customization accessible for verification
- Loading branch information
Showing
9 changed files
with
129 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.auth0.jwt; | ||
|
||
import com.auth0.jwt.interfaces.Clock; | ||
|
||
import java.util.Date; | ||
|
||
final class ClockImpl implements Clock { | ||
|
||
ClockImpl() { | ||
} | ||
|
||
@Override | ||
public Date getToday() { | ||
return new Date(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 3 additions & 8 deletions
11
lib/src/main/java/com/auth0/jwt/Clock.java → .../java/com/auth0/jwt/interfaces/Clock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
package com.auth0.jwt; | ||
package com.auth0.jwt.interfaces; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* The Clock class is used to wrap calls to Date class. | ||
*/ | ||
class Clock { | ||
|
||
Clock() { | ||
} | ||
public interface Clock { | ||
|
||
/** | ||
* Returns a new Date representing Today's time. | ||
* | ||
* @return a new Date representing Today's time. | ||
*/ | ||
Date getToday() { | ||
return new Date(); | ||
} | ||
Date getToday(); | ||
} |
39 changes: 39 additions & 0 deletions
39
lib/src/main/java/com/auth0/jwt/interfaces/Verification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.auth0.jwt.interfaces; | ||
|
||
import com.auth0.jwt.JWTVerifier; | ||
|
||
import java.util.Date; | ||
|
||
public interface Verification { | ||
Verification withIssuer(String issuer); | ||
|
||
Verification withSubject(String subject); | ||
|
||
Verification withAudience(String... audience); | ||
|
||
Verification acceptLeeway(long leeway) throws IllegalArgumentException; | ||
|
||
Verification acceptExpiresAt(long leeway) throws IllegalArgumentException; | ||
|
||
Verification acceptNotBefore(long leeway) throws IllegalArgumentException; | ||
|
||
Verification acceptIssuedAt(long leeway) throws IllegalArgumentException; | ||
|
||
Verification withJWTId(String jwtId); | ||
|
||
Verification withClaim(String name, Boolean value) throws IllegalArgumentException; | ||
|
||
Verification withClaim(String name, Integer value) throws IllegalArgumentException; | ||
|
||
Verification withClaim(String name, Double value) throws IllegalArgumentException; | ||
|
||
Verification withClaim(String name, String value) throws IllegalArgumentException; | ||
|
||
Verification withClaim(String name, Date value) throws IllegalArgumentException; | ||
|
||
Verification withArrayClaim(String name, String... items) throws IllegalArgumentException; | ||
|
||
Verification withArrayClaim(String name, Integer... items) throws IllegalArgumentException; | ||
|
||
JWTVerifier build(); | ||
} |
6 changes: 3 additions & 3 deletions
6
...rc/test/java/com/auth0/jwt/ClockTest.java → ...est/java/com/auth0/jwt/ClockImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.