Search in sources :

Example 1 with PersistedRoles

use of org.apache.activemq.artemis.core.persistence.config.PersistedRoles in project activemq-artemis by apache.

the class AbstractJournalStorageManager method newSecurityRecord.

/**
 * @param id
 * @param buffer
 * @return
 */
protected static PersistedRoles newSecurityRecord(long id, ActiveMQBuffer buffer) {
    PersistedRoles roles = new PersistedRoles();
    roles.decode(buffer);
    roles.setStoreId(id);
    return roles;
}
Also used : PersistedRoles(org.apache.activemq.artemis.core.persistence.config.PersistedRoles)

Example 2 with PersistedRoles

use of org.apache.activemq.artemis.core.persistence.config.PersistedRoles 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();
    }
}
Also used : Role(org.apache.activemq.artemis.core.security.Role) PersistedRoles(org.apache.activemq.artemis.core.persistence.config.PersistedRoles)

Example 3 with PersistedRoles

use of org.apache.activemq.artemis.core.persistence.config.PersistedRoles 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);
    }
}
Also used : Role(org.apache.activemq.artemis.core.security.Role) PersistedRoles(org.apache.activemq.artemis.core.persistence.config.PersistedRoles) PersistedAddressSetting(org.apache.activemq.artemis.core.persistence.config.PersistedAddressSetting)

Example 4 with PersistedRoles

use of org.apache.activemq.artemis.core.persistence.config.PersistedRoles in project activemq-artemis by apache.

the class RolesConfigurationStorageTest method testStoreSecuritySettings.

@Test
public void testStoreSecuritySettings() throws Exception {
    createStorage();
    addSetting(new PersistedRoles("a#", "a1", "a1", "a1", "a1", "a1", "a1", "a1", "a1", "a1", "a1"));
    addSetting(new PersistedRoles("a2", "a1", null, "a1", "a1", "a1", "a1", "a1", "a1", "a1", "a1"));
    journal.stop();
    checkSettings();
    createStorage();
    checkSettings();
    addSetting(new PersistedRoles("a2", "a1", null, "a1", "a1", "a1", "a1", "a1", "a1", "a1", "a1"));
    addSetting(new PersistedRoles("a3", "a1", null, "a1", "a1", "a1", "a1", "a1", "a1", "a1", "a1"));
    checkSettings();
    journal.stop();
    createStorage();
    checkSettings();
    journal.stop();
    journal = null;
}
Also used : PersistedRoles(org.apache.activemq.artemis.core.persistence.config.PersistedRoles) Test(org.junit.Test)

Example 5 with PersistedRoles

use of org.apache.activemq.artemis.core.persistence.config.PersistedRoles in project activemq-artemis by apache.

the class RolesConfigurationStorageTest method testStoreSecuritySettings2.

@Test
public void testStoreSecuritySettings2() throws Exception {
    createStorage();
    checkSettings();
    journal.stop();
    createStorage();
    checkSettings();
    addSetting(new PersistedRoles("a#", "a1", "a1", "a1", "a1", "a1", "a1", "a1", "a1", "a1", "a1"));
    journal.stop();
    createStorage();
    checkSettings();
    journal.stop();
    createStorage();
    checkSettings();
}
Also used : PersistedRoles(org.apache.activemq.artemis.core.persistence.config.PersistedRoles) Test(org.junit.Test)

Aggregations

PersistedRoles (org.apache.activemq.artemis.core.persistence.config.PersistedRoles)7 PersistedAddressSetting (org.apache.activemq.artemis.core.persistence.config.PersistedAddressSetting)2 Role (org.apache.activemq.artemis.core.security.Role)2 Test (org.junit.Test)2 InvalidParameterException (java.security.InvalidParameterException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)1 JournalLoadInformation (org.apache.activemq.artemis.core.journal.JournalLoadInformation)1 PreparedTransactionInfo (org.apache.activemq.artemis.core.journal.PreparedTransactionInfo)1 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)1 GroupingEncoding (org.apache.activemq.artemis.core.persistence.impl.journal.codec.GroupingEncoding)1 PersistentAddressBindingEncoding (org.apache.activemq.artemis.core.persistence.impl.journal.codec.PersistentAddressBindingEncoding)1 PersistentQueueBindingEncoding (org.apache.activemq.artemis.core.persistence.impl.journal.codec.PersistentQueueBindingEncoding)1 QueueStatusEncoding (org.apache.activemq.artemis.core.persistence.impl.journal.codec.QueueStatusEncoding)1