-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9e462c
commit 63b68a5
Showing
1 changed file
with
52 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package jwt_test.jwt_test_1; | ||
|
||
import com.auth0.jwt.JWT; | ||
import com.auth0.jwt.algorithms.Algorithm; | ||
import com.auth0.jwt.exceptions.JWTCreationException; | ||
|
||
public class App | ||
{ | ||
|
||
private static void bad1() { | ||
try { | ||
// ruleid: java-jwt-none-alg | ||
Algorithm algorithm = Algorithm.none(); | ||
String token = JWT.create() | ||
.withIssuer("auth0") | ||
.sign(algorithm); | ||
} catch (JWTCreationException exception){ | ||
//Invalid Signing configuration / Couldn't convert Claims. | ||
} | ||
} | ||
|
||
private static void bad2() { | ||
try { | ||
// ruleid: java-jwt-none-alg | ||
String token = JWT.create() | ||
.withIssuer("auth0") | ||
.sign(Algorithm.none()); | ||
} catch (JWTCreationException exception){ | ||
//Invalid Signing configuration / Couldn't convert Claims. | ||
} | ||
} | ||
|
||
private static void ok1(String secretKey) { | ||
try { | ||
// ok: java-jwt-none-alg | ||
Algorithm algorithm = Algorithm.HMAC256(secretKey); | ||
String token = JWT.create() | ||
.withIssuer("auth0") | ||
.sign(algorithm); | ||
} catch (JWTCreationException exception){ | ||
//Invalid Signing configuration / Couldn't convert Claims. | ||
} | ||
} | ||
|
||
public static void main( String[] args ) | ||
{ | ||
bad1(); | ||
bad2(); | ||
ok1(args[0]); | ||
} | ||
} | ||
|