use of org.apache.activemq.artemis.core.security.Role in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method addSecuritySettings.
@Override
public void addSecuritySettings(final String addressMatch, final String sendRoles, final String consumeRoles, final String createDurableQueueRoles, final String deleteDurableQueueRoles, final String createNonDurableQueueRoles, final String deleteNonDurableQueueRoles, final String manageRoles, final String browseRoles, final String createAddressRoles, final String deleteAddressRoles) throws Exception {
checkStarted();
clearIO();
try {
Set<Role> roles = SecurityFormatter.createSecurity(sendRoles, consumeRoles, createDurableQueueRoles, deleteDurableQueueRoles, createNonDurableQueueRoles, deleteNonDurableQueueRoles, manageRoles, browseRoles, createAddressRoles, deleteAddressRoles);
server.getSecurityRepository().addMatch(addressMatch, roles);
PersistedRoles persistedRoles = new PersistedRoles(addressMatch, sendRoles, consumeRoles, createDurableQueueRoles, deleteDurableQueueRoles, createNonDurableQueueRoles, deleteNonDurableQueueRoles, manageRoles, browseRoles, createAddressRoles, deleteAddressRoles);
storageManager.storeSecurityRoles(persistedRoles);
} finally {
blockOnIO();
}
}
use of org.apache.activemq.artemis.core.security.Role in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method getRoles.
@Override
public Object[] getRoles(final String addressMatch) throws Exception {
checkStarted();
checkStarted();
clearIO();
try {
Set<Role> roles = server.getSecurityRepository().getMatch(addressMatch);
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();
}
}
use of org.apache.activemq.artemis.core.security.Role in project activemq-artemis by apache.
the class AddressControlImpl method getRoles.
@Override
public Object[] getRoles() throws Exception {
clearIO();
try {
Set<Role> roles = securityRepository.getMatch(addressInfo.getName().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();
}
}
use of org.apache.activemq.artemis.core.security.Role in project activemq-artemis by apache.
the class ActiveMQServerImpl method recoverStoredConfigs.
/**
* @throws Exception
*/
private void recoverStoredConfigs() throws Exception {
List<PersistedAddressSetting> adsettings = storageManager.recoverAddressSettings();
for (PersistedAddressSetting set : adsettings) {
addressSettingsRepository.addMatch(set.getAddressMatch().toString(), set.getSetting());
}
List<PersistedRoles> roles = storageManager.recoverPersistedRoles();
for (PersistedRoles roleItem : roles) {
Set<Role> setRoles = SecurityFormatter.createSecurity(roleItem.getSendRoles(), roleItem.getConsumeRoles(), roleItem.getCreateDurableQueueRoles(), roleItem.getDeleteDurableQueueRoles(), roleItem.getCreateNonDurableQueueRoles(), roleItem.getDeleteNonDurableQueueRoles(), roleItem.getManageRoles(), roleItem.getBrowseRoles(), roleItem.getCreateAddressRoles(), roleItem.getDeleteAddressRoles());
securityRepository.addMatch(roleItem.getAddressMatch().toString(), setRoles);
}
}
use of org.apache.activemq.artemis.core.security.Role in project activemq-artemis by apache.
the class AutoCreateJmsDestinationTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addUser("guest", "guest");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().setDefaultUser("guest");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("guest", "allowAll");
Role role = new Role("allowAll", true, true, true, true, true, true, true, true, true, true);
Set<Role> roles = new HashSet<>();
roles.add(role);
server.getSecurityRepository().addMatch("#", roles);
}
Aggregations