use of org.xdi.oxauth.model.uma.UmaPermission in project oxAuth by GluuFederation.
the class RegisterPermissionWSTest method testRegisterPermissionWithInvalidResourceSet.
@Test(dependsOnMethods = { "testRegisterPermission" })
@Parameters({ "umaAmHost", "umaHost" })
public void testRegisterPermissionWithInvalidResourceSet(final String umaAmHost, String umaHost) {
final String path = umaPermissionPath;
try {
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + path).request();
request.header("Accept", UmaConstants.JSON_MEDIA_TYPE);
request.header("Authorization", "Bearer " + pat.getAccessToken());
request.header("Host", umaAmHost);
String json = null;
try {
final UmaPermission r = new UmaPermission();
r.setResourceSetId(resourceSet.getId() + "x");
json = ServerUtil.createJsonMapper().writeValueAsString(r);
} catch (IOException e) {
e.printStackTrace();
fail();
}
Response response = request.post(Entity.json(json));
String entity = response.readEntity(String.class);
BaseTest.showResponse("UMA : RegisterPermissionWSTest.testRegisterPermissionWithInvalidResourceSet() : ", response, entity);
assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(), "Unexpected response code.");
try {
final PermissionTicket t = ServerUtil.createJsonMapper().readValue(entity, PermissionTicket.class);
Assert.assertNull(t);
} catch (Exception e) {
// it's ok if it fails here, we expect ticket as null.
}
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.xdi.oxauth.model.uma.UmaPermission in project oxAuth by GluuFederation.
the class RegisterPermissionWSTest method testRegisterPermission.
@Test(dependsOnMethods = { "init" })
@Parameters({ "umaAmHost", "umaHost" })
public void testRegisterPermission(final String umaAmHost, String umaHost) throws Exception {
final UmaPermission r = new UmaPermission();
r.setResourceSetId(resourceSet.getId());
r.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view"));
final PermissionTicket ticket = TUma.registerPermission(url, pat, umaAmHost, umaHost, r, umaPermissionPath);
UmaTestUtil.assert_(ticket);
}
use of org.xdi.oxauth.model.uma.UmaPermission in project oxAuth by GluuFederation.
the class TrustElevationWSTest method registerPermissionForRpt.
@Test(dependsOnMethods = { "init" })
@Parameters({ "umaAmHost", "umaHost", "umaPermissionPath" })
public void registerPermissionForRpt(final String umaAmHost, String umaHost, String umaPermissionPath) throws Exception {
final UmaPermission r = new UmaPermission();
r.setResourceSetId(resourceSet.getId());
r.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view"));
ticket = TUma.registerPermission(url, pat, umaAmHost, umaHost, r, umaPermissionPath);
UmaTestUtil.assert_(ticket);
}
use of org.xdi.oxauth.model.uma.UmaPermission in project oxTrust by GluuFederation.
the class UmaPermissionService method registerResourcePermission.
public String registerResourcePermission(Token patToken, String resourceId, List<String> scopeIds) {
UmaPermission permission = new UmaPermission();
permission.setResourceId(resourceId);
permission.setScopes(scopeIds);
PermissionTicket ticket = permissionService.registerPermission("Bearer " + patToken.getAccessToken(), UmaPermissionList.instance(permission));
if (ticket == null) {
return null;
}
return ticket.getTicket();
}
Aggregations