Search in sources :

Example 1 with IntrospectionService

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());
}
Also used : IntrospectionResponse(io.jans.as.model.common.IntrospectionResponse) IntrospectionService(io.jans.as.client.service.IntrospectionService) Token(io.jans.as.model.uma.wrapper.Token) Parameters(org.testng.annotations.Parameters) BaseTest(io.jans.as.client.BaseTest) Test(org.testng.annotations.Test)

Example 2 with IntrospectionService

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);
}
Also used : Jwt(io.jans.as.model.jwt.Jwt) IntrospectionService(io.jans.as.client.service.IntrospectionService)

Example 3 with IntrospectionService

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")));
}
Also used : ClientHttpEngine(org.jboss.resteasy.client.jaxrs.ClientHttpEngine) Jwt(io.jans.as.model.jwt.Jwt) IntrospectionService(io.jans.as.client.service.IntrospectionService) Token(io.jans.as.model.uma.wrapper.Token) Parameters(org.testng.annotations.Parameters) BaseTest(io.jans.as.client.BaseTest) Test(org.testng.annotations.Test)

Example 4 with IntrospectionService

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());
}
Also used : IntrospectionResponse(io.jans.as.model.common.IntrospectionResponse) IntrospectionService(io.jans.as.client.service.IntrospectionService) Token(io.jans.as.model.uma.wrapper.Token) Parameters(org.testng.annotations.Parameters) BaseTest(io.jans.as.client.BaseTest) Test(org.testng.annotations.Test)

Example 5 with IntrospectionService

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());
}
Also used : IntrospectionResponse(io.jans.as.model.common.IntrospectionResponse) IntrospectionService(io.jans.as.client.service.IntrospectionService) Token(io.jans.as.model.uma.wrapper.Token) Parameters(org.testng.annotations.Parameters) BaseTest(io.jans.as.client.BaseTest) Test(org.testng.annotations.Test)

Aggregations

IntrospectionService (io.jans.as.client.service.IntrospectionService)6 BaseTest (io.jans.as.client.BaseTest)4 Token (io.jans.as.model.uma.wrapper.Token)4 Parameters (org.testng.annotations.Parameters)4 Test (org.testng.annotations.Test)4 IntrospectionResponse (io.jans.as.model.common.IntrospectionResponse)3 Jwt (io.jans.as.model.jwt.Jwt)2 RestClientBuilder (org.eclipse.microprofile.rest.client.RestClientBuilder)1 ClientHttpEngine (org.jboss.resteasy.client.jaxrs.ClientHttpEngine)1 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)1