Search in sources :

Example 6 with IntrospectionResponse

use of org.gluu.oxauth.model.common.IntrospectionResponse in project oxTrust by GluuFederation.

the class DefaultTestModeProtectionService method processIntrospectionResponse.

public Response processIntrospectionResponse(IntrospectionResponse iresponse, ResourceInfo resourceInfo) {
    Response response = null;
    if (iresponse == null || !iresponse.isActive()) {
        String msg = "Invalid token";
        log.error(msg);
        // see section 3.12 RFC 7644
        response = IProtectionService.simpleResponse(Response.Status.FORBIDDEN, msg);
    }
    return response;
}
Also used : IntrospectionResponse(org.gluu.oxauth.model.common.IntrospectionResponse) Response(javax.ws.rs.core.Response)

Example 7 with IntrospectionResponse

use of org.gluu.oxauth.model.common.IntrospectionResponse 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 8 with IntrospectionResponse

use of org.gluu.oxauth.model.common.IntrospectionResponse 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

IntrospectionResponse (org.gluu.oxauth.model.common.IntrospectionResponse)8 Response (javax.ws.rs.core.Response)4 BaseTest (org.gluu.oxauth.BaseTest)4 Parameters (org.testng.annotations.Parameters)4 Test (org.testng.annotations.Test)4 IntrospectionService (org.gluu.oxauth.client.service.IntrospectionService)3 Token (org.gluu.oxauth.model.uma.wrapper.Token)3 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Builder (javax.ws.rs.client.Invocation.Builder)1 Form (javax.ws.rs.core.Form)1 AbstractToken (org.gluu.oxauth.model.common.AbstractToken)1 AccessToken (org.gluu.oxauth.model.common.AccessToken)1 AuthorizationGrant (org.gluu.oxauth.model.common.AuthorizationGrant)1 ExternalIntrospectionContext (org.gluu.oxauth.service.external.context.ExternalIntrospectionContext)1 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1