Package com.dbxml.db.common.security

Examples of com.dbxml.db.common.security.AccessManagerClient


   public void process() throws dbXMLException {
      CollectionClient col = (CollectionClient)cl.getProperty(CommandLine.COLLECTION);
      if ( col == null )
         throw new dbXMLException("Collection context required");

      AccessManagerClient manager = new AccessManagerClient(cl.getClient());
      PrintWriter pw = cl.getWriter();

      if ( !cl.hasMoreTokens() )
         throw new dbXMLException("User ID is required");
      String userID = cl.getNextToken();

      if ( !cl.hasMoreTokens() )
         throw new dbXMLException("A User action must be specified");
      String action = cl.getNextToken().toUpperCase();

      if ( action.equals(ACTION_PASSWORD) ) {
         if ( !cl.hasMoreTokens() )
            throw new dbXMLException("A new password must be specified");
         String password = cl.getNextToken();
         manager.setUserPassword(userID, password);
         pw.println("Password set for '"+userID+"'");
      }
      else if ( action.equals(ACTION_ADDROLE) ) {
         if ( !cl.hasMoreTokens() )
            throw new dbXMLException("A Role ID must be specified");
         String roleID = cl.getNextToken();
         manager.addRoleToUser(userID, roleID);
         pw.println("Role '"+roleID+"' added to User '"+userID+"'");
      }
      else if ( action.equals(ACTION_RMROLE) ) {
         if ( !cl.hasMoreTokens() )
            throw new dbXMLException("A Role ID must be specified");
         String roleID = cl.getNextToken();
         manager.removeRoleFromUser(userID, roleID);
         pw.println("Role '"+roleID+"' removed from User '"+userID+"'");
      }
      else if ( action.equals(ACTION_LSROLE) ) {
         String[] list = manager.listRolesForUser(userID);
         int count = 0;
         for ( int i = 0; i < list.length; i++ ) {
            pw.println(list[i]);
            count++;
         }
View Full Code Here


   public void process() throws dbXMLException {
      CollectionClient col = (CollectionClient)cl.getProperty(CommandLine.COLLECTION);
      if ( col == null )
         throw new dbXMLException("Collection context required");

      AccessManagerClient manager = new AccessManagerClient(cl.getClient());
      PrintWriter pw = cl.getWriter();

      String roleID = cl.getNextToken("Role ID");
      String action = cl.getNextToken("Role Action").toUpperCase();

      if ( action.equals(ACTION_ADDUSER) ) {
         String userID = cl.getNextToken("User ID");
         manager.addRoleToUser(userID, roleID);
         pw.println("User '"+userID+"' added to Role '"+roleID+"'");
      }
      else if ( action.equals(ACTION_RMUSER) ) {
         String userID = cl.getNextToken("User ID");
         manager.removeRoleFromUser(userID, roleID);
         pw.println("User '"+userID+"' removed from Role '"+roleID+"'");
      }
      else if ( action.equals(ACTION_LSUSER) ) {
         String[] list = manager.listUsersForRole(roleID);
         int count = 0;
         for ( int i = 0; i < list.length; i++ ) {
            pw.println(list[i]);
            count++;
         }
View Full Code Here

      String roleID = null;

      if ( cl.hasMoreTokens() )
         roleID = cl.getNextToken("Role ID");

      AccessManagerClient manager = new AccessManagerClient(cl.getClient());
      Map map = manager.listAccessControl(path);

      PrintWriter pw = cl.getWriter();

      if ( roleID != null ) {
         Integer i = (Integer)map.get(roleID);
View Full Code Here

               String title = "Remove User";
               String message = "Are you sure you want to remove the\n"
                              + "User '"+id+"'?";
               int res = JOptionPane.showConfirmDialog(Admin.getInstance(), message, title, JOptionPane.YES_NO_OPTION);
               if ( res == JOptionPane.YES_OPTION ) {
                  AccessManagerClient manager = new AccessManagerClient(col.getClient());
                  manager.removeUser(id);
                  return REMOVE_SELF;
               }
            }
            catch ( Exception e ) {
               Admin.getInstance().addMessage(e.getMessage());
View Full Code Here

      return "Role";
   }

   public int menuAction(int action) {
      Admin admin = Admin.getInstance();
      AccessManagerClient manager = new AccessManagerClient(col.getClient());

      switch ( action ) {
         case ACTION_REMOVE_DATABASE:
         case ACTION_REMOVE_USER:
            try {
               String title;
               String message;
               if ( type == USER ) {
                  title = "Remove Role from User";
                  message = "Are you sure you want to remove the\n"
                          + "Role '"+id+"' from User '"+userID+"'?";
               }
               else {
                  title = "Remove Role from Database";
                  message = "Are you sure you want to remove the\n"
                          + "Role '"+id+"' from the Database?";
               }
               int res = JOptionPane.showConfirmDialog(Admin.getInstance(), message, title, JOptionPane.YES_NO_OPTION);
               if ( res == JOptionPane.YES_OPTION ) {
                  switch ( type ) {
                     case DATABASE:
                        manager.removeRole(id);
                        break;
                     case USER:
                        manager.removeRoleFromUser(userID, id);
                        break;
                  }
                  return REMOVE_SELF;
               }
            }
View Full Code Here

      return col;
   }

   public AdminNode[] getChildren() {
      try {
         AccessManagerClient manager = new AccessManagerClient(col.getClient());
         switch ( type ) {
            case RoleNode.DATABASE: {
               String[] roles = manager.listRoles();
               AdminNode[] list = new AdminNode[roles.length];
               for ( int i = 0; i < roles.length; i++ )
                  list[i] = new RoleNode(this, col, roles[i], type);
               return list;
            }

            case RoleNode.COLLECTION: {
               Map acl = manager.listAccessControl(col.getCanonicalName());
               List list = new ArrayList();
               Iterator iter = acl.entrySet().iterator();
               while ( iter.hasNext() ) {
                  Map.Entry entry = (Map.Entry)iter.next();
                  String role = (String)entry.getKey();
                  Integer permissions = (Integer)entry.getValue();
                  list.add(new RoleNode(this, col, role, type, permissions.intValue()));
               }
               return (AdminNode[])list.toArray(EmptyAdminNodes);
            }

            case RoleNode.USER: {
               String[] roles = manager.listRolesForUser(userID);
               AdminNode[] list = new AdminNode[roles.length];
               for ( int i = 0; i < roles.length; i++ )
                  list[i] = new RoleNode(this, col, roles[i], RoleNode.USER, userID);
               return list;
            }
View Full Code Here

      return col;
   }

   public AdminNode[] getChildren() {
      try {
         AccessManagerClient manager = new AccessManagerClient(col.getClient());
         String[] users = manager.listUsers();
         AdminNode[] list = new AdminNode[users.length];
         for ( int i = 0; i < users.length; i++ )
            list[i] = new UserNode(this, col, users[i]);

         return list;
View Full Code Here

TOP

Related Classes of com.dbxml.db.common.security.AccessManagerClient

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.