conf.setSecurityEnabled(true);
conf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
HornetQServer server = HornetQServers.newHornetQServer(conf, false);
server.start();
HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
HornetQSecurityManagerImpl securityManager = (HornetQSecurityManagerImpl)server.getSecurityManager();
securityManager.addUser(validAdminUser, validAdminPassword);
securityManager.addUser(invalidAdminUser, invalidAdminPassword);
securityManager.addRole(validAdminUser, "admin");
securityManager.addRole(validAdminUser, "guest");
securityManager.addRole(invalidAdminUser, "guest");
Set<Role> adminRole = securityRepository.getMatch(ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS.toString());
adminRole.add(new Role("admin", true, true, true, true, true, true, true));
securityRepository.addMatch(ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS.toString(), adminRole);
Set<Role> guestRole = securityRepository.getMatch("*");