@Path("/{principal-type}/{principal-name}/roles/{role-name}") @DELETE public void removeRoleFromPrincipal(HttpRequest httpRequest, HttpResponder httpResponder, @PathParam("principal-type") String principalType, @PathParam("principal-name") String principalName, @PathParam("role-name") String roleName) throws Exception { ensureSecurityEnabled(); Principal principal = new Principal(principalName, Principal.PrincipalType.valueOf(principalType.toUpperCase())); authorizer.removeRoleFromPrincipal(new Role(roleName), principal); httpResponder.sendStatus(HttpResponseStatus.OK); createLogEntry(httpRequest, HttpResponseStatus.OK); }
@Path("/{principal-type}/{principal-name}/roles/{role-name}") @DELETE public void removeRoleFromPrincipal(HttpRequest httpRequest, HttpResponder httpResponder, @PathParam("principal-type") String principalType, @PathParam("principal-name") String principalName, @PathParam("role-name") String roleName) throws Exception { ensureSecurityEnabled(); Principal principal = new Principal(principalName, Principal.PrincipalType.valueOf(principalType.toUpperCase())); authorizer.removeRoleFromPrincipal(new Role(roleName), principal); httpResponder.sendStatus(HttpResponseStatus.OK); createLogEntry(httpRequest, HttpResponseStatus.OK); }
authorizer.removeRoleFromPrincipal(engineers, spiderman); authorizer.removeRoleFromPrincipal(admins, spiderman); Assert.fail(String.format("Removed non-existing role %s from principal %s. Should have failed.", admins, spiderman));