use of org.gluu.oxauth.model.uma.UmaPermission in project oxAuth by GluuFederation.
the class RegisterPermissionWSTest method testRegisterPermission.
@Test(dependsOnMethods = { "init" })
public void testRegisterPermission() throws Exception {
final UmaPermission r = new UmaPermission();
r.setResourceId(resource.getId());
r.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view"));
final PermissionTicket ticket = TUma.registerPermission(url, pat, r, umaPermissionPath);
UmaTestUtil.assert_(ticket);
}
use of org.gluu.oxauth.model.uma.UmaPermission in project oxAuth by GluuFederation.
the class UmaRegisterPermissionFlowHttpTest method registerResourcePermission.
public String registerResourcePermission(String resourceId, List<String> scopes) throws Exception {
UmaPermission permission = new UmaPermission();
permission.setResourceId(resourceId);
permission.setScopes(scopes);
PermissionTicket ticket = getPermissionService().registerPermission("Bearer " + this.registerResourceTest.pat.getAccessToken(), UmaPermissionList.instance(permission));
UmaTestUtil.assert_(ticket);
this.ticket = ticket.getTicket();
return ticket.getTicket();
}
use of org.gluu.oxauth.model.uma.UmaPermission in project oxAuth by GluuFederation.
the class AccessProtectedResourceFlowWSTest method _4_registerPermissionForRpt.
/*
* **************************************************************** 4.
* Registers permission for RPT
*/
@Test(dependsOnMethods = { "_3_hostDeterminesRptStatus" })
@Parameters({ "umaPermissionPath" })
public void _4_registerPermissionForRpt(String umaPermissionPath) throws Exception {
final UmaPermission r = new UmaPermission();
r.setResourceId(resource.getId());
r.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view"));
ticket = TUma.registerPermission(url, pat, r, umaPermissionPath);
UmaTestUtil.assert_(ticket);
}
use of org.gluu.oxauth.model.uma.UmaPermission in project oxTrust by GluuFederation.
the class UmaPermissionService method validateRptToken.
public Pair<Boolean, Response> validateRptToken(Token patToken, String authorization, String resourceId, List<String> scopeIds) {
/*
* //caller of this method never pass null patToken if (patToken == null) {
* return authenticationFailure; }
*/
log.trace("Validating RPT, resourceId: {}, scopeIds: {}, authorization: {}", resourceId, scopeIds, authorization);
if (StringHelper.isNotEmpty(authorization) && authorization.startsWith("Bearer ")) {
String rptToken = authorization.substring(7);
RptIntrospectionResponse rptStatusResponse = getStatusResponse(patToken, rptToken);
log.trace("RPT status response: {} ", rptStatusResponse);
if ((rptStatusResponse == null) || !rptStatusResponse.getActive()) {
log.warn("Status response for RPT token: '{}' is invalid, will do a retry", rptToken);
} else {
boolean rptHasPermissions = isRptHasPermissions(rptStatusResponse);
if (rptHasPermissions) {
// Collect all scopes
List<String> returnScopeIds = new LinkedList<String>();
for (UmaPermission umaPermission : rptStatusResponse.getPermissions()) {
if (umaPermission.getScopes() != null) {
returnScopeIds.addAll(umaPermission.getScopes());
}
}
if (returnScopeIds.containsAll(scopeIds)) {
return authenticationSuccess;
}
log.error("Status response for RPT token: '{}' not contains right permissions", rptToken);
}
}
}
Response registerPermissionsResponse = prepareRegisterPermissionsResponse(patToken, resourceId, scopeIds);
if (registerPermissionsResponse == null) {
return authenticationFailure;
}
return new Pair<Boolean, Response>(true, registerPermissionsResponse);
}
use of org.gluu.oxauth.model.uma.UmaPermission in project oxTrust by GluuFederation.
the class UmaPermissionService method registerResourcePermission.
public String registerResourcePermission(Token patToken, String resourceId, List<String> scopes) {
// TODO: Added this if as a hack since init method is not called upon app startup in scim project
if (permissionService == null) {
init(null);
}
// end
UmaPermission permission = new UmaPermission();
permission.setResourceId(resourceId);
permission.setScopes(scopes);
PermissionTicket ticket = permissionService.registerPermission("Bearer " + patToken.getAccessToken(), UmaPermissionList.instance(permission));
if (ticket == null) {
return null;
}
return ticket.getTicket();
}
Aggregations