@RequestMapping(value = "/Grants", consumes = "application/json", produces = "application/json", method = POST)
public RestEntity writeEntry(@RequestBody RestGrant grant, HttpServletRequest request) throws RestException {
RequestContext requestContext = getRequestContext(request);
if(requestContext.isSecure()) {
if(StringUtils.stringNotEmpty(grant.getObjectName()) && StringUtils.stringNotEmpty(grant.getUsername())) {
try {
userManager.grantUser(requestContext.getUserSession(), grant.getObjectName(), grant.getUsername(), grant.getMode());
return loadSpecificGrantObject(requestContext, grant.getObjectName());
} catch(JasDBStorageException e) {
throw new RestException("Unable to grant", e);
}
} else {
throw new RestException("Incomplete grant details");
}
} else {
throw new RestException("Unable to create grant, unsecure connection");
}
}