78                 ensureOAuthScope(auth, SystemScopeService.UMA_PROTECTION_SCOPE);
    84                         JsonElement el = 
parser.parse(jsonString);
    85                         if (el.isJsonObject()) {
    86                                 JsonObject o = el.getAsJsonObject();
    88                                 Long rsid = getAsLong(o, 
"resource_set_id");
    89                                 Set<String> scopes = getAsStringSet(o, 
"scopes");
    91                                 if (rsid == null || scopes == null || scopes.isEmpty()){
    93                                         m.addAttribute(
"code", HttpStatus.BAD_REQUEST);
    94                                         m.addAttribute(
"errorMessage", 
"Missing required component of permission registration request.");
    95                                         return JsonErrorView.VIEWNAME;
   106                                 if (resourceSet == null) {
   107                                         m.addAttribute(
"code", HttpStatus.NOT_FOUND);
   108                                         m.addAttribute(
"errorMessage", 
"Requested resource set not found: " + rsid);
   109                                         return JsonErrorView.VIEWNAME;
   113                                 if (!resourceSet.getOwner().equals(auth.getName())) {
   114                                         m.addAttribute(
"code", HttpStatus.FORBIDDEN);
   115                                         m.addAttribute(
"errorMessage", 
"Party requesting permission is not owner of resource set, expected " + resourceSet.getOwner() + 
" got " + auth.getName());
   116                                         return JsonErrorView.VIEWNAME;
   122                                 if (permission != null) {
   124                                         JsonObject out = 
new JsonObject();
   125                                         out.addProperty(
"ticket", permission.getTicket());
   126                                         m.addAttribute(
"entity", out);
   128                                         m.addAttribute(
"code", HttpStatus.CREATED);
   130                                         return JsonEntityView.VIEWNAME;
   134                                         m.addAttribute(
"code", HttpStatus.INTERNAL_SERVER_ERROR);
   135                                         m.addAttribute(
"errorMessage", 
"Unable to save permission and generate ticket.");
   137                                         return JsonErrorView.VIEWNAME;
   142                                 m.addAttribute(
"code", HttpStatus.BAD_REQUEST);
   143                                 m.addAttribute(
"errorMessage", 
"Malformed JSON request.");
   144                                 return JsonErrorView.VIEWNAME;
   146                 } 
catch (JsonParseException e) {
   148                         m.addAttribute(
"code", HttpStatus.BAD_REQUEST);
   149                         m.addAttribute(
"errorMessage", 
"Malformed JSON request.");
   150                         return JsonErrorView.VIEWNAME;
 ResourceSetService resourceSetService
Definition: PermissionRegistrationEndpoint.java:68
 
PermissionTicket createTicket(ResourceSet resourceSet, Set< String > scopes)
 
JsonParser parser
Definition: PermissionRegistrationEndpoint.java:73
 
SystemScopeService scopeService
Definition: PermissionRegistrationEndpoint.java:71
 
Set< SystemScope > removeRestrictedAndReservedScopes(Set< SystemScope > scopes)
 
Set< SystemScope > fromStrings(Set< String > scope)
 
PermissionService permissionService
Definition: PermissionRegistrationEndpoint.java:65
 
ResourceSet getById(Long id)
 
Set< String > toStrings(Set< SystemScope > scope)