diff --git a/model/src/main/java/org/cloudfoundry/identity/uaa/oauth/token/Claims.java b/model/src/main/java/org/cloudfoundry/identity/uaa/oauth/token/Claims.java index 641602220f8..a1d7f5f84f3 100644 --- a/model/src/main/java/org/cloudfoundry/identity/uaa/oauth/token/Claims.java +++ b/model/src/main/java/org/cloudfoundry/identity/uaa/oauth/token/Claims.java @@ -91,6 +91,8 @@ public class Claims { private Long previousLogonTime; @JsonProperty(ClaimConstants.AMR) private String[] amr; + @JsonProperty(ClaimConstants.CLIENT_AUTH_METHOD) + private String clientAuth; public String getUserId() { return userId; @@ -353,4 +355,12 @@ public List getGrantedScopes() { public void setGrantedScopes(List grantedScopes) { this.grantedScopes = grantedScopes; } + + public String getClientAuth() { + return this.clientAuth; + } + + public void setClientAuth(final String clientAuth) { + this.clientAuth = clientAuth; + } } diff --git a/model/src/main/java/org/cloudfoundry/identity/uaa/oauth/token/TokenConstants.java b/model/src/main/java/org/cloudfoundry/identity/uaa/oauth/token/TokenConstants.java index f69a6d2c25e..1c599a0e6e8 100644 --- a/model/src/main/java/org/cloudfoundry/identity/uaa/oauth/token/TokenConstants.java +++ b/model/src/main/java/org/cloudfoundry/identity/uaa/oauth/token/TokenConstants.java @@ -62,6 +62,8 @@ static public List getStringValues() { public static final String GRANT_TYPE_AUTHORIZATION_CODE = "authorization_code"; public static final String GRANT_TYPE_IMPLICIT = "implicit"; + public static final String CLIENT_AUTH_NONE = "none"; + public static final String ID_TOKEN_HINT_PROMPT = "prompt"; public static final String ID_TOKEN_HINT_PROMPT_NONE = "none"; diff --git a/model/src/test/java/org/cloudfoundry/identity/uaa/oauth/token/IntrospectionClaimsTest.java b/model/src/test/java/org/cloudfoundry/identity/uaa/oauth/token/IntrospectionClaimsTest.java new file mode 100644 index 00000000000..43f6284fe23 --- /dev/null +++ b/model/src/test/java/org/cloudfoundry/identity/uaa/oauth/token/IntrospectionClaimsTest.java @@ -0,0 +1,40 @@ +package org.cloudfoundry.identity.uaa.oauth.token; + +import com.nimbusds.jose.util.Base64URL; +import org.cloudfoundry.identity.uaa.util.JsonUtils; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.text.ParseException; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class IntrospectionClaimsTest { + + private final static String TOKEN_PAYLOAD = "eyJqdGkiOiJiODc5MzNkYmQ3MDM0ZTZjODE1MDZmOTljODUwYWUwYSIsImNsaWVudF9hdXRoX21ldGhvZCI6Im5vbmUiLCJzdWIiOiJiZjNkOTJhNC1jNGVjLTQxMDQtOGJmNS0yZTMwMTFmZDQxODUiLCJzY29wZSI6WyJvcGVuaWQiXSwiY2xpZW50X2lkIjoibG9naW4iLCJjaWQiOiJsb2dpbiIsImF6cCI6ImxvZ2luIiwicmV2b2NhYmxlIjp0cnVlLCJncmFudF90eXBlIjoiYXV0aG9yaXphdGlvbl9jb2RlIiwidXNlcl9pZCI6ImJmM2Q5MmE0LWM0ZWMtNDEwNC04YmY1LTJlMzAxMWZkNDE4NSIsIm9yaWdpbiI6Imlhcy5wcm94eSIsInVzZXJfbmFtZSI6IkZpcnN0Lk5hbWVAZW1haWwub3JnIiwiZW1haWwiOiJGaXJzdC5OYW1lQGVtYWlsLm9yZyIsImF1dGhfdGltZSI6MTY4OTE3ODg2MiwicmV2X3NpZyI6IjIzYmRhYmZkIiwiaWF0IjoxNjg5MTc4ODYzLCJleHAiOjE2ODkyMjIwNjMsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC91YWEvb2F1dGgvdG9rZW4iLCJ6aWQiOiJ1YWEiLCJhdWQiOlsib3BlbmlkIiwibG9naW4iXX0"; + private IntrospectionClaims INTROSPECTION_PAYLOAD; + + @BeforeEach + void setup() throws ParseException { + String json = new Base64URL(TOKEN_PAYLOAD).decodeToString(); + INTROSPECTION_PAYLOAD = JsonUtils.readValue(json, IntrospectionClaims.class); + INTROSPECTION_PAYLOAD.setActive(false); + } + + @Test + void setActive() { + INTROSPECTION_PAYLOAD.setActive(true); + assertTrue(INTROSPECTION_PAYLOAD.isActive()); + } + + @Test + void isActive() { + assertFalse(INTROSPECTION_PAYLOAD.isActive()); + } + + @Test + void testSerialize() { + assertTrue(JsonUtils.writeValueAsString(INTROSPECTION_PAYLOAD).contains(TokenConstants.CLIENT_AUTH_NONE)); + } +}