Package org.atomojo.auth.service.db

Examples of org.atomojo.auth.service.db.Permission


            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The 'name' attribute must be present.");
         }

         try {
            Permission p = db.createPermission(name,id);
            Representation responseEntity = new DBObjectRepresentation(MediaType.APPLICATION_XML,p);
            responseEntity.setCharacterSet(CharacterSet.UTF_8);
            getResponse().setStatus(Status.SUCCESS_CREATED);
            return responseEntity;
         } catch (SQLException ex) {
View Full Code Here


   }
  
   public Representation get()
   {
      try {
         Permission p = fetch();
         if (p!=null) {
            Representation entity = new DBObjectRepresentation(MediaType.APPLICATION_XML,p);
            entity.setCharacterSet(CharacterSet.UTF_8);
            return entity;
         }
View Full Code Here

   }
  
   protected Permission fetch()
      throws SQLException
   {
      Permission p = null;
      if (name!=null) {
         p = db.getPermission(name);
      }
      if (suuid!=null) {
         UUID id = UUID.fromString(suuid);
View Full Code Here

      return p;
   }
  
   public Representation delete() {
      try {
         Permission p = fetch();
         if (p!=null) {
            p.delete();
            getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
            return null;
         } else {
            getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
            return new StringRepresentation("Permission was not found.");
View Full Code Here

            if (permissionId!=null) {
               getContext().getLogger().info("Getting permission "+permissionId+" for role {"+role.getUUID()+"}"+role.getName());
               // check for permission by id
               try {
                  UUID id = UUID.fromString(permissionId);
                  Permission p = db.getPermission(id);
                  if (p==null) {
                     getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
                     return new StringRepresentation("Permission does not exist.");
                  } else if (!role.hasPermission(p)) {
                     getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
                     return new StringRepresentation("Role does not have the permission.");
                  } else {
                     getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
                     return null;
                  }
               } catch (SQLException ex) {
                  getContext().getLogger().log(Level.SEVERE,"Error retrieving permission "+permissionId,ex);
                  getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
                  return new StringRepresentation("Exception during processing, see logs.");
               } catch (IllegalArgumentException ex) {
                  getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
                  return new StringRepresentation("Bad UUID value "+permissionId);
               }
            } else if (permissionName!=null) {
               // check for permission by name
               try {
                  Permission p = db.getPermission(permissionName);
                  if (p==null) {
                     getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
                     return new StringRepresentation("Permission does not exist.");
                  } else if (!role.hasPermission(p)) {
                     getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
View Full Code Here

      try {
         Role role = fetch();
         Element top = doc.getDocumentElement();
         String sid = top.getAttributeValue("id");
         String name = top.getAttributeValue("name");
         Permission p = null;
         if (sid!=null) {
            p = db.getPermission(UUID.fromString(sid));
         }
         if (name!=null) {
            p = db.getPermission(name);
View Full Code Here

         if (role!=null) {
            if (permissionId!=null) {
               // delete for permission by id
               try {
                  UUID id = UUID.fromString(permissionId);
                  Permission p = db.getPermission(id);
                  if (p==null || !role.hasPermission(p)) {
                     getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
                  } else {
                     role.removePermission(p);
                     getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
                  }
                  return null;
               } catch (SQLException ex) {
                  getContext().getLogger().log(Level.SEVERE,"Error deleting permission "+permissionId,ex);
                  getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
                  return new StringRepresentation("Database error retrieving permission, see logs.");
               } catch (IllegalArgumentException ex) {
                  getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
                  return new StringRepresentation("Bad UUID value "+permissionId);
               }
            } else if (permissionName!=null) {
               // delete for permission by name
               try {
                  Permission p = db.getPermission(permissionName);
                  if (p==null || !role.hasPermission(p)) {
                     getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
                  } else {
                     role.removePermission(p);
                     getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
View Full Code Here

            Representation entity = new DBObjectRepresentation(MediaType.APPLICATION_XML,role);
            entity.setCharacterSet(CharacterSet.UTF_8);
            getResponse().setStatus(Status.SUCCESS_OK);
            return entity;
         } else {
            Permission p = fetchPermission();
            if (p==null || !role.hasPermission(p)) {
               getResponse().setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
            } else {
               getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
            }
View Full Code Here

   }
 
   protected Permission fetchPermission()
      throws SQLException,IllegalArgumentException
   {
      Permission permission = null;
      if (permissionName!=null) {
         permission = db.getPermission(permissionName);
      }
      if (permissionId!=null) {
         UUID id = UUID.fromString(permissionId);
View Full Code Here

            if (user==null) {
               // see if the user is a super user across realms
               user = findUser(db,authid);
               if (user!=null) {
                  // The user must either be a superuser or have the cross-realm permission
                  Permission superuser = db.getPermission(AuthDB.SUPERUSER_PERMISSION);
                  Permission crossrealm = db.getPermission(AuthDB.ACROSS_REALM_PERMISSION);
                  if (!user.hasPermission(superuser) && !user.hasPermission(crossrealm)) {
                     user = null;
                  }
               }
            }
View Full Code Here

TOP

Related Classes of org.atomojo.auth.service.db.Permission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.