Group Service

From Apache OpenOffice Wiki
Jump to: navigation, search



The service com.sun.star.sdbcx.Group is the first of the two security services, Group and User. The Group service represents the group account that has access permissions to a secured database and it has a Name property to identify it. It supports the interface com.sun.star.sdbcx.XAuthorizable that allows current privilege settings to be obtained, and to grant or revoke privileges. The second interface is the com.sun.star.sdbcx.XUsersSupplier. The word 'Supplier' in the interface name identifies the group object as a container for users. The container returned here is a collection of all users that belong to this group.

Group
  // print all groups and the users with their privileges who belong to this group
  public static void printGroups(XTablesSupplier xTabSup) throws com.sun.star.uno.Exception, SQLException {
      System.out.println("Example printGroups");
      XGroupsSupplier xGroupsSup = (XGroupsSupplier)UnoRuntime.queryInterface(
      XGroupsSupplier.class, xTabSup);
      if (xGroupsSup != null) {
          // the table must be at least support a XColumnsSupplier interface
          System.out.println("--- Groups ---");
          XNameAccess xGroups = xGroupsSup.getGroups();
          String [] aGroupNames = xGroups.getElementNames();
          for (int i =0; i < aGroupNames.length; i++) {
              System.out.println(" " + aGroupNames[i]);
              XUsersSupplier xUsersSup = (XUsersSupplier)UnoRuntime.queryInterface(
                  XUsersSupplier.class, xGroups.getByName(aGroupNames[i]));
              if (xUsersSup != null) {
                  XAuthorizable xAuth = (XAuthorizable)UnoRuntime.queryInterface(
                      XAuthorizable.class, xUsersSup);
                  // the table must be at least support a XColumnsSupplier interface
                  System.out.println("\t--- Users ---");
                  XNameAccess xUsers = xUsersSup.getUsers();
                  String [] aUserNames = xUsers.getElementNames();
                  for (int j = 0; j < aUserNames.length; j++) {
                      System.out.println("\t " + aUserNames[j] + 
                      " Privileges: " + xAuth.getPrivileges(aUserNames[j], PrivilegeObject.TABLE));
                  }
              }
          }
      }
  }
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages