@Override public Object[] getRoles() throws Exception { clearIO(); try { Set<Role> roles = securityRepository.getMatch(address.toString()); Object[] objRoles = new Object[roles.size()]; int i = 0; for (Role role : roles) { objRoles[i++] = new Object[] { role.getName(), CheckType.SEND.hasRole(role), CheckType.CONSUME.hasRole(role), CheckType.CREATE_DURABLE_QUEUE.hasRole(role), CheckType.DELETE_DURABLE_QUEUE.hasRole(role), CheckType.CREATE_NON_DURABLE_QUEUE.hasRole(role), CheckType.DELETE_NON_DURABLE_QUEUE.hasRole(role), CheckType.MANAGE.hasRole(role) }; } return objRoles; } finally { blockOnIO(); } }
@Test public void testGetRoles() throws Exception { SimpleString address = RandomUtil.randomSimpleString(); SimpleString queue = RandomUtil.randomSimpleString(); Role role = new Role( RandomUtil.randomString(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean()); session.createQueue(address, queue, true); CoreMessagingProxy proxy = createProxy(address); Object[] roles = (Object[]) proxy.retrieveAttributeValue("roles"); for (Object role2 : roles) { System.out.println(((Object[]) role2)[0]); } Assert.assertEquals(0, roles.length); Set<Role> newRoles = new HashSet<>(); newRoles.add(role); server.getSecurityRepository().addMatch(address.toString(), newRoles); roles = (Object[]) proxy.retrieveAttributeValue("roles"); Assert.assertEquals(1, roles.length); Object[] r = (Object[]) roles[0]; Assert.assertEquals(role.getName(), r[0]); Assert.assertEquals(CheckType.SEND.hasRole(role), r[1]); Assert.assertEquals(CheckType.CONSUME.hasRole(role), r[2]); Assert.assertEquals(CheckType.CREATE_DURABLE_QUEUE.hasRole(role), r[3]); Assert.assertEquals(CheckType.DELETE_DURABLE_QUEUE.hasRole(role), r[4]); Assert.assertEquals(CheckType.CREATE_NON_DURABLE_QUEUE.hasRole(role), r[5]); Assert.assertEquals(CheckType.DELETE_NON_DURABLE_QUEUE.hasRole(role), r[6]); Assert.assertEquals(CheckType.MANAGE.hasRole(role), r[7]); session.deleteQueue(queue); }