roles.add(new Role(role, send.contains(role), consume.contains(role), createDurableQueue.contains(role), deleteDurableQueue.contains(role), createNonDurableQueue.contains(role), deleteNonDurableQueue.contains(role), manageRoles.contains(role), browse.contains(role), createAddressRoles.contains(role), deleteAddressRoles.contains(role)));
@Override public boolean hasRole(final Role role) { return role.isDeleteNonDurableQueue(); } },
private void securityCheck(SimpleString address, SimpleString queue, CheckType checkType, SecurityAuth auth) throws Exception { if (securityEnabled) { securityStore.check(address, queue, checkType, auth); } }
@Test public void testCreateRole() throws Exception { Role role = new Role("testCreateRole", false, false, true, false, false, false, false, false, false, false); Assert.assertFalse(SEND.hasRole(role)); Assert.assertFalse(CONSUME.hasRole(role)); Assert.assertTrue(CREATE_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(CREATE_NON_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(DELETE_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(DELETE_NON_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(MANAGE.hasRole(role)); Assert.assertFalse(BROWSE.hasRole(role)); Assert.assertFalse(CREATE_ADDRESS.hasRole(role)); }
@Override protected boolean authenticate(String user, String password) { if (securityStore.isSecurityEnabled()) { try { securityStore.authenticate(user, password, null); return true; } catch (Exception e) { return false; } } else { return true; } } }
@Override public boolean hasRole(final Role role) { return role.isSend(); } },
@Override public boolean hasRole(final Role role) { return role.isConsume(); } },
@Override public boolean hasRole(final Role role) { return role.isDeleteDurableQueue(); } },
@Override public boolean hasRole(final Role role) { return role.isCreateNonDurableQueue(); } },
@Override public boolean hasRole(final Role role) { return role.isCreateDurableQueue(); } },
@Override public boolean hasRole(final Role role) { return role.isManage(); } },
public boolean isSupportsAnonymous() { boolean supportsAnonymous = false; try { server.getSecurityStore().authenticate(null, null, null); supportsAnonymous = true; } catch (Exception e) { // authentication failed so no anonymous support } return supportsAnonymous; }
@Override public boolean hasRole(final Role role) { return role.isDeleteAddress(); } },
@Override public boolean hasRole(final Role role) { return role.isBrowse(); } };
@Override public boolean hasRole(final Role role) { return role.isCreateAddress(); } },
@Test public void testManageRole() throws Exception { Role role = new Role("testManageRole", false, false, false, false, false, false, true, false, false, false); Assert.assertFalse(SEND.hasRole(role)); Assert.assertFalse(CONSUME.hasRole(role)); Assert.assertFalse(CREATE_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(CREATE_NON_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(DELETE_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(DELETE_NON_DURABLE_QUEUE.hasRole(role)); Assert.assertTrue(MANAGE.hasRole(role)); Assert.assertFalse(BROWSE.hasRole(role)); Assert.assertFalse(CREATE_ADDRESS.hasRole(role)); }
@Override protected boolean authenticate(String user, String password) { if (securityStore.isSecurityEnabled()) { try { securityStore.authenticate(user, password, null); return true; } catch (Exception e) { return false; } } else { return true; } } }
private void securityCheck(SimpleString address, CheckType checkType, SecurityAuth auth) throws Exception { if (securityEnabled) { securityStore.check(address, checkType, auth); } }
@Test public void testWriteRole() throws Exception { Role role = new Role("testWriteRole", true, false, false, false, false, false, false, false, false, false); Assert.assertTrue(SEND.hasRole(role)); Assert.assertFalse(CONSUME.hasRole(role)); Assert.assertFalse(CREATE_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(CREATE_NON_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(DELETE_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(DELETE_NON_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(MANAGE.hasRole(role)); Assert.assertFalse(BROWSE.hasRole(role)); Assert.assertFalse(CREATE_ADDRESS.hasRole(role)); }
@Test public void testReadRole() throws Exception { Role role = new Role("testReadRole", false, true, false, false, false, false, false, true, false, false); Assert.assertFalse(SEND.hasRole(role)); Assert.assertTrue(CONSUME.hasRole(role)); Assert.assertFalse(CREATE_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(CREATE_NON_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(DELETE_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(DELETE_NON_DURABLE_QUEUE.hasRole(role)); Assert.assertFalse(MANAGE.hasRole(role)); Assert.assertTrue(BROWSE.hasRole(role)); Assert.assertFalse(CREATE_ADDRESS.hasRole(role)); }