use of io.jans.as.model.uma.UmaResource in project jans by JanssenProject.
the class RegisterResourceFlowHttpTest method registerResourceWithScopeExpression.
public String registerResourceWithScopeExpression(String scopeExpression) throws Exception {
try {
UmaResource resource = new UmaResource();
resource.setName("Photo Album");
resource.setIconUri("http://www.example.com/icons/flower.png");
resource.setScopeExpression(scopeExpression);
resource.setType("myType");
UmaResourceResponse resourceStatus = getResourceService().addResource("Bearer " + pat.getAccessToken(), resource);
UmaTestUtil.assertIt(resourceStatus);
this.resourceIdWithScopeExpression = resourceStatus.getId();
return this.resourceIdWithScopeExpression;
} catch (ClientErrorException ex) {
System.err.println(ex.getResponse().readEntity(String.class));
throw ex;
}
}
use of io.jans.as.model.uma.UmaResource in project jans by JanssenProject.
the class RegisterResourceFlowHttpTest method registerResource.
public String registerResource(List<String> scopes) throws Exception {
try {
UmaResource resource = new UmaResource();
resource.setName("Photo Album");
resource.setIconUri("http://www.example.com/icons/flower.png");
resource.setScopes(scopes);
resource.setType("myType");
UmaResourceResponse resourceStatus = getResourceService().addResource("Bearer " + pat.getAccessToken(), resource);
UmaTestUtil.assertIt(resourceStatus);
this.resourceId = resourceStatus.getId();
return this.resourceId;
} catch (ClientErrorException ex) {
System.err.println(ex.getResponse().readEntity(String.class));
throw ex;
}
}
use of io.jans.as.model.uma.UmaResource in project jans by JanssenProject.
the class RegisterResourceFlowHttpTest method testModifyResourceWithInvalidPat.
/**
* Test UMA resource description modification with invalid PAT
*/
@Test(dependsOnMethods = { "modifyResource" })
public void testModifyResourceWithInvalidPat() throws Exception {
showTitle("testModifyResourceWithInvalidPat");
UmaResourceResponse resourceStatus = null;
try {
UmaResource resource = new UmaResource();
resource.setName("Photo Album 4");
resource.setIconUri("http://www.example.com/icons/flower.png");
resource.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view", "http://photoz.example.com/dev/scopes/all"));
resourceStatus = getResourceService().updateResource("Bearer " + pat.getAccessToken() + "_invalid", this.resourceId + "_invalid", resource);
} catch (ClientErrorException ex) {
System.err.println(ex.getResponse().readEntity(String.class));
assertEquals(ex.getResponse().getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "Unexpected response status");
}
assertNull(resourceStatus, "Resource status is not null");
}
use of io.jans.as.model.uma.UmaResource in project jans by JanssenProject.
the class UmaRegisterResourceWSTest method testModifyResource.
@Test(dependsOnMethods = { "testRegisterResource" })
public void testModifyResource() throws Exception {
final UmaResource resource = new UmaResource();
resource.setName("Server Photo Album 2");
resource.setIconUri("http://www.example.com/icons/flower.png");
resource.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view", "http://photoz.example.com/dev/scopes/all"));
final UmaResourceResponse status = TUma.modifyResource(url, pat, umaRegisterResourcePath, resourceStatus.getId(), resource);
UmaTestUtil.assertIt(status);
}
use of io.jans.as.model.uma.UmaResource 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;
}
Aggregations