SecuritySystem securitySystem = this.lookup(SecuritySystem.class);
securitySystem.setRealms(Arrays.asList(XmlAuthenticatingRealm.ROLE, XmlAuthorizingRealm.ROLE));
AuthorizationManager authManager = securitySystem.getAuthorizationManager("default");
// create an empty role
Role emptyRole = this.buildEmptyRole();
// this should work fine
authManager.addRole(emptyRole);
Role normalRole =
new Role("normalRole-" + Math.random(), "NormalRole", "Normal Role", "default", false,
new HashSet<String>(), new HashSet<String>());
normalRole.addPrivilege(this.createTestPriv());
authManager.addRole(normalRole);
// now create a user and add it to the user
DefaultUser user = this.buildTestUser();
user.addRole(new RoleIdentifier(emptyRole.getSource(), emptyRole.getRoleId()));
user.addRole(new RoleIdentifier(normalRole.getSource(), normalRole.getRoleId()));
// create the user, this user only has an empty role
securitySystem.addUser(user, "password");
// now authorize the user