static void printPermissions(Permission[] ps) { for(int i=0; ps!=null && i< ps.length; i++) { System.out.println("\nEntity:" + ps[i].getEntity().getType() + ":" + ps[i].getEntity().get_value()); System.out.println("IsGroup:" + ps[i].isGroup()); System.out.println("Principal:" + ps[i].getPrincipal()); System.out.println("Propogated:" + ps[i].isPropagate()); System.out.println("RoleId:" + ps[i].getRoleId()); } }
public Permission[] getPermission() { return (Permission[]) getCurrentProperty("permission"); }
public static void main(String[] args) throws Exception { if(args.length != 3) { System.out.println("Usage: java CreateRole <url>" + " <username> <password>"); return; } ServiceInstance si = new ServiceInstance( new URL(args[0]), args[1], args[2], true); AuthorizationManager am = si.getAuthorizationManager(); int roleId = am.addAuthorizationRole("master1", new String[] { "System.View", "System.Read", "System.Anonymous", "Global.LogEvent" } ); //even if you just want to rename the role, you // still need to provide full list of privileges am.updateAuthorizationRole(roleId, "master", new String[] { "System.View", "System.Read", "System.Anonymous", "Global.LogEvent", "Global.Diagnostics", "Folder.Create"} ); System.out.println("The new role ID: " + roleId); Permission perm = new Permission(); perm.setGroup(false); // false for user, true for group perm.setPrincipal("vimaster"); // the vimaster must exist perm.setPropagate(true); // propagate down the hierarchy perm.setRoleId(roleId); am.setEntityPermissions( si.getRootFolder(), new Permission[] {perm} ); Permission[] ps = am.retrieveEntityPermissions( si.getRootFolder(), false); System.out.println("print the permissions on root:"); printPermissions(ps); si.getServerConnection().logout(); }
void resetEntityPermissions(ManagedEntity entity, List<Permission> permission) throws AuthMinimumAdminPermission, NotFound, UserNotFound, RuntimeFault, RemoteException;
List<Permission> retrieveEntityPermissions(ManagedEntity entity, boolean inherited) throws RuntimeFault, RemoteException;
List<Permission> retrieveAllPermissions() throws RuntimeFault, RemoteException;
List<Permission> retrieveRolePermissions(int roleId) throws NotFound, RuntimeFault, RemoteException;
void setEntityPermissions(ManagedEntity entity, List<Permission> permission) throws AuthMinimumAdminPermission, NotFound, UserNotFound, RuntimeFault, RemoteException;