Esempio n. 1
0
 /**
  * Anyone can read typeacl.
  *
  * @param typename
  * @return
  */
 @Path("/typeacl/{typename}")
 @GET
 public TypeACL getTypeACL(@PathParam("typename") String typename) {
   TypeACL typeACL = securityEM.find(TypeACL.class, typename);
   if (typeACL == null) {
     typeACL = new TypeACL();
     typeACL.setTypeid(typename);
   }
   for (RolePermission p : typeACL.getRolePermissions()) {
     p.setTypeACL(null);
   }
   for (PropertyPermission p : typeACL.getPropPermissions()) {
     p.setTypeACL(null);
   }
   return typeACL;
 }
Esempio n. 2
0
 @Path("/typeacl")
 @POST
 public void saveTypeACL(TypeACL typeACL) {
   if (permissionChecker.hasPermission(
       ACLHelper.getActionByName(GrantAction.NAME),
       roleContext.getRoles(),
       typeACL.getTypeid(),
       null)) {
     throw new AuthorizedException(InstanceActionType.GRANT, null);
   }
   for (RolePermission p : typeACL.getRolePermissions()) {
     p.setTypeACL(typeACL);
   }
   for (PropertyPermission p : typeACL.getPropPermissions()) {
     p.setTypeACL(typeACL);
   }
   securityEM.getTransaction().begin();
   securityEM.merge(typeACL);
   securityEM.getTransaction().commit();
   ACLHelper.typeacls.put(typeACL.getTypeid(), typeACL);
 }