Search in sources :

Example 1 with IntrospectionService

use of org.gluu.oxauth.client.service.IntrospectionService in project oxAuth by GluuFederation.

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(org.gluu.oxauth.model.common.IntrospectionResponse) IntrospectionService(org.gluu.oxauth.client.service.IntrospectionService) Token(org.gluu.oxauth.model.uma.wrapper.Token) Parameters(org.testng.annotations.Parameters) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Example 2 with IntrospectionService

use of org.gluu.oxauth.client.service.IntrospectionService in project oxAuth by GluuFederation.

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(org.gluu.oxauth.model.jwt.Jwt) IntrospectionService(org.gluu.oxauth.client.service.IntrospectionService) Token(org.gluu.oxauth.model.uma.wrapper.Token) Parameters(org.testng.annotations.Parameters) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Example 3 with IntrospectionService

use of org.gluu.oxauth.client.service.IntrospectionService in project oxAuth by GluuFederation.

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(org.gluu.oxauth.model.common.IntrospectionResponse) IntrospectionService(org.gluu.oxauth.client.service.IntrospectionService) Token(org.gluu.oxauth.model.uma.wrapper.Token) Parameters(org.testng.annotations.Parameters) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Example 4 with IntrospectionService

use of org.gluu.oxauth.client.service.IntrospectionService in project oxAuth by GluuFederation.

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(org.gluu.oxauth.model.common.IntrospectionResponse) IntrospectionService(org.gluu.oxauth.client.service.IntrospectionService) Token(org.gluu.oxauth.model.uma.wrapper.Token) Parameters(org.testng.annotations.Parameters) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Aggregations

BaseTest (org.gluu.oxauth.BaseTest)4 IntrospectionService (org.gluu.oxauth.client.service.IntrospectionService)4 Token (org.gluu.oxauth.model.uma.wrapper.Token)4 Parameters (org.testng.annotations.Parameters)4 Test (org.testng.annotations.Test)4 IntrospectionResponse (org.gluu.oxauth.model.common.IntrospectionResponse)3 Jwt (org.gluu.oxauth.model.jwt.Jwt)1 ClientHttpEngine (org.jboss.resteasy.client.jaxrs.ClientHttpEngine)1