}
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);