use of io.jans.as.client.service.IntrospectionService in project jans by JanssenProject.
the class IntrospectionWsHttpTest method introspectWithValidAuthorizationButInvalidTokenShouldReturnActiveFalse.
@Test
@Parameters({ "umaPatClientId", "umaPatClientSecret" })
public void introspectWithValidAuthorizationButInvalidTokenShouldReturnActiveFalse(final String umaPatClientId, final String umaPatClientSecret) throws Exception {
final Token authorization = UmaClient.requestPat(tokenEndpoint, umaPatClientId, umaPatClientSecret, clientEngine(true));
final IntrospectionService introspectionService = ClientFactory.instance().createIntrospectionService(introspectionEndpoint, clientEngine(true));
final IntrospectionResponse introspectionResponse = introspectionService.introspectToken("Bearer " + authorization.getAccessToken(), "invalid_token");
assertNotNull(introspectionResponse);
assertFalse(introspectionResponse.isActive());
}
use of io.jans.as.client.service.IntrospectionService in project jans by JanssenProject.
the class DpopTokenRequestHttpTest method tokenIntrospection.
private void tokenIntrospection(String jwkThumbprint, String accessToken) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException, InvalidJwtException {
IntrospectionService introspectionService = ClientFactory.instance().createIntrospectionService(introspectionEndpoint, clientEngine(true));
String jwtAsString = introspectionService.introspectTokenWithResponseAsJwt("Bearer " + accessToken, accessToken, true);
Jwt jwt = Jwt.parse(jwtAsString);
assertNotNull(jwt.getClaims());
assertTrue(Boolean.parseBoolean(jwt.getClaims().getClaimAsString("active")));
assertTrue(jwt.getClaims().hasClaim(JwtClaimName.SUBJECT_IDENTIFIER));
assertTrue(jwt.getClaims().hasClaim(JwtClaimName.ISSUER));
assertTrue(jwt.getClaims().hasClaim(JwtClaimName.NOT_BEFORE));
assertTrue(jwt.getClaims().hasClaim(JwtClaimName.EXPIRATION_TIME));
assertTrue(jwt.getClaims().hasClaim(JwtClaimName.CNF));
assertTrue(jwt.getClaims().getClaimAsJSON(JwtClaimName.CNF).has(JwtClaimName.JKT));
assertEquals(jwt.getClaims().getClaimAsJSON(JwtClaimName.CNF).get(JwtClaimName.JKT), jwkThumbprint);
}
use of io.jans.as.client.service.IntrospectionService in project jans by JanssenProject.
the class IntrospectionWsHttpTest method bearerWithResponseAsJwt.
@Test
@Parameters({ "umaPatClientId", "umaPatClientSecret" })
public void bearerWithResponseAsJwt(final String umaPatClientId, final String umaPatClientSecret) throws Exception {
final ClientHttpEngine engine = clientEngine(true);
final Token authorization = UmaClient.requestPat(tokenEndpoint, umaPatClientId, umaPatClientSecret, engine);
final Token tokenToIntrospect = UmaClient.requestPat(tokenEndpoint, umaPatClientId, umaPatClientSecret, engine);
final IntrospectionService introspectionService = ClientFactory.instance().createIntrospectionService(introspectionEndpoint, engine);
final String jwtAsString = introspectionService.introspectTokenWithResponseAsJwt("Bearer " + authorization.getAccessToken(), tokenToIntrospect.getAccessToken(), true);
final Jwt jwt = Jwt.parse(jwtAsString);
assertTrue(Boolean.parseBoolean(jwt.getClaims().getClaimAsString("active")));
}
use of io.jans.as.client.service.IntrospectionService in project jans by JanssenProject.
the class IntrospectionWsHttpTest method basicAuthentication.
@Test
@Parameters({ "umaPatClientId", "umaPatClientSecret" })
public void basicAuthentication(final String umaPatClientId, final String umaPatClientSecret) throws Exception {
final Token tokenToIntrospect = UmaClient.requestPat(tokenEndpoint, umaPatClientId, umaPatClientSecret, clientEngine(true));
final IntrospectionService introspectionService = ClientFactory.instance().createIntrospectionService(introspectionEndpoint, clientEngine(true));
final IntrospectionResponse introspectionResponse = introspectionService.introspectToken("Basic " + BaseRequest.getEncodedCredentials(umaPatClientId, umaPatClientSecret), tokenToIntrospect.getAccessToken());
assertTrue(introspectionResponse != null && introspectionResponse.isActive());
}
use of io.jans.as.client.service.IntrospectionService in project jans by JanssenProject.
the class IntrospectionWsHttpTest method bearer.
@Test
@Parameters({ "umaPatClientId", "umaPatClientSecret" })
public void bearer(final String umaPatClientId, final String umaPatClientSecret) throws Exception {
final Token authorization = UmaClient.requestPat(tokenEndpoint, umaPatClientId, umaPatClientSecret);
final Token tokenToIntrospect = UmaClient.requestPat(tokenEndpoint, umaPatClientId, umaPatClientSecret);
final IntrospectionService introspectionService = ClientFactory.instance().createIntrospectionService(introspectionEndpoint);
final IntrospectionResponse introspectionResponse = introspectionService.introspectToken("Bearer " + authorization.getAccessToken(), tokenToIntrospect.getAccessToken());
assertTrue(introspectionResponse != null && introspectionResponse.isActive());
}
Aggregations