Search in sources :

Example 1 with UmaResourceWithId

use of io.jans.as.model.uma.UmaResourceWithId in project jans by JanssenProject.

the class RegisterResourceFlowHttpTest method getOneResource.

/**
 * Get resource
 */
@Test(dependsOnMethods = { "modifyResource" })
public void getOneResource() throws Exception {
    showTitle("getOneResource");
    try {
        UmaResourceWithId resource = getResourceService().getResource("Bearer " + pat.getAccessToken(), this.resourceId);
        assertEquals(resource.getType(), "myType");
        UmaResourceWithId resourceWithExpression = getResourceService().getResource("Bearer " + pat.getAccessToken(), this.resourceIdWithScopeExpression);
        assertEquals(resourceWithExpression.getScopeExpression(), MODIFY_SCOPE_EXPRESSION);
    } catch (ClientErrorException ex) {
        System.err.println(ex.getResponse().readEntity(String.class));
        throw ex;
    }
}
Also used : UmaResourceWithId(io.jans.as.model.uma.UmaResourceWithId) ClientErrorException(javax.ws.rs.ClientErrorException) BaseTest(io.jans.as.client.BaseTest) Test(org.testng.annotations.Test)

Example 2 with UmaResourceWithId

use of io.jans.as.model.uma.UmaResourceWithId in project jans by JanssenProject.

the class RsModifyOperation method getResource.

private UmaResource getResource(UmaResourceService resourceService, RsModifyParams params, String resourceId) {
    String pat = getUmaTokenService().getPat(params.getRpId()).getToken();
    UmaResourceWithId umaResourceWithId = resourceService.getResource("Bearer " + pat, resourceId);
    UmaResource umaResource = new UmaResource();
    umaResource.setDescription(umaResourceWithId.getDescription());
    umaResource.setIat(umaResourceWithId.getIat());
    umaResource.setIconUri(umaResourceWithId.getIconUri());
    umaResource.setName(umaResourceWithId.getName());
    umaResource.setScopes(params.getScopes());
    umaResource.setScopeExpression(null);
    umaResource.setType(umaResourceWithId.getType());
    if (!Strings.isNullOrEmpty(params.getScopeExpression()) && !params.getScopeExpression().equals("null")) {
        umaResource.setScopeExpression(params.getScopeExpression());
        umaResource.setScopes(JsonLogicNodeParser.parseNode(params.getScopeExpression().toString()).getData());
    }
    return umaResource;
}
Also used : UmaResourceWithId(io.jans.as.model.uma.UmaResourceWithId) UmaResource(io.jans.as.model.uma.UmaResource)

Aggregations

UmaResourceWithId (io.jans.as.model.uma.UmaResourceWithId)2 BaseTest (io.jans.as.client.BaseTest)1 UmaResource (io.jans.as.model.uma.UmaResource)1 ClientErrorException (javax.ws.rs.ClientErrorException)1 Test (org.testng.annotations.Test)1