Skip to content

Commit

Permalink
Make subject configurable in OidcWiremockTestResource
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-strate committed Jan 16, 2024
1 parent 1b7c88e commit 2508e60
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,15 @@ private void defineCodeFlowAuthorizationMockEncryptedTokenStub() {
}

public static String getEncryptedIdToken(String userName, Set<String> groups) {
return getEncryptedIdToken(userName, groups, "123456");
}

public static String getEncryptedIdToken(String userName, Set<String> groups, String sub) {
return Jwt.preferredUserName(userName)
.groups(groups)
.issuer(TOKEN_ISSUER)
.audience(TOKEN_AUDIENCE)
.subject("123456")
.subject(sub)
.jws()
.keyId("1")
.innerSign("privateKey.jwk").encrypt("publicKey.jwk");
Expand Down Expand Up @@ -368,26 +372,23 @@ public static String getIdToken(String userName, Set<String> groups) {
}

public static String generateJwtToken(String userName, Set<String> groups) {
return generateJwtToken(userName, groups, "123456");
}

public static String generateJwtToken(String userName, Set<String> groups, String sub) {
return Jwt.preferredUserName(userName)
.groups(groups)
.issuer(TOKEN_ISSUER)
.audience(TOKEN_AUDIENCE)
.claim("sid", "session-id")
.subject("123456")
.subject(sub)
.jws()
.keyId("1")
.sign("privateKey.jwk");
}

public static String getLogoutToken() {
return Jwt.issuer(TOKEN_ISSUER)
.audience(TOKEN_AUDIENCE)
.subject("123456")
.claim("events", createEventsClaim())
.claim("sid", "session-id")
.jws()
.keyId("1")
.sign("privateKey.jwk");
return getLogoutToken("123456");
}

public static String getLogoutToken(String sub) {
Expand Down

0 comments on commit 2508e60

Please sign in to comment.