• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Role类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.activemq.artemis.core.security.Role的典型用法代码示例。如果您正苦于以下问题:Java Role类的具体用法?Java Role怎么用?Java Role使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Role类属于org.apache.activemq.artemis.core.security包,在下文中一共展示了Role类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addressPermissionsFor

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
/**
 * A setter to specify role permissions for a matched address.
 * @param addressMatcher a string to match an Artemis address.
 * @param perms specifies what a user in that role can do on a
 *              matched address.
 * @return the setter.
 * @throws IllegalArgumentException if the address matcher is {@code null}
 * or empty.
 * @throws NullPointerException if the role is {@code null}.
 */
public static Function<Configuration, Configuration>
addressPermissionsFor(String addressMatcher, Role perms) {
    requireString(addressMatcher, "addressMatcher");
    requireNonNull(perms, "perms");

    return cfg -> {
        if (cfg.getSecurityRoles() == null) {
            cfg.setSecurityRoles(new HashMap<>());
        }
        Set<Role> rs = cfg.getSecurityRoles()
                          .getOrDefault(addressMatcher, new HashSet<>());
        rs.add(perms);
        return cfg.putSecurityRoles(addressMatcher, rs);
    };
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:26,代码来源:SecurityProps.java


示例2: isPermissionSet

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
private static boolean isPermissionSet(Role r, AddressPermission p) {
    switch (p) {
        case Send:
            return r.isSend();
        case Consume:
            return r.isConsume();
        case CreateDurableQueue:
            return r.isCreateDurableQueue();
        case DeleteDurableQueue:
            return r.isDeleteDurableQueue();
        case CreateNonDurableQueue:
            return r.isCreateNonDurableQueue();
        case DeleteNonDurableQueue:
            return r.isDeleteNonDurableQueue();
        case Manage:
            return r.isManage();
        case Browse:
            return r.isBrowse();
        default:
            throw new IllegalArgumentException("unknown constant: " + p);
    }
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:23,代码来源:RolePermissionsBuilderTest.java


示例3: addToExistingRolesForMatchedAddress

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void addToExistingRolesForMatchedAddress() {
    String address = "x";

    Set<Role> existingRoles = new HashSet<>();
    Role existingRole = role("user").can(Send, Browse);
    existingRoles.add(existingRole);

    Role newRole = role("admin").can(Manage);

    Configuration cfg = CoreConfigFactory
            .empty()
            .with(c -> { c.putSecurityRoles(address, existingRoles); })
            .with(addressPermissionsFor(address, newRole))
            .apply(null);

    assertNotNull(cfg.getSecurityRoles());
    Set<Role> actualRoles = cfg.getSecurityRoles().get(address);
    existingRoles.add(newRole);
    assertThat(actualRoles, is(existingRoles));
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:22,代码来源:SecurityPropsAddressPermTest.java


示例4: init

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Override
public SecuritySettingPlugin init(Map<String, String> map) {
    this.name = map.get(NAME);
    if(this.name != null) {
        INSTANCES.put(this.name, this);
    }
    this.useGroupsFromSaslDelegation = "true".equalsIgnoreCase(map.get(USE_GROUPS_FROM_SASL_DELEGATION));
    Set<Role> roles = new HashSet<>();

    // "admin" (console or other internal process) can do anything
    roles.add(new Role(ADMIN_GROUP, true, true, true, true, true, true, true, true, true, true));

    if(!useGroupsFromSaslDelegation) {
        // "all" users can create/delete queues (but not addresses)
        roles.add(new Role(ALL_GROUP, true, true, true, true, true, true, false, true, false, false));
        roles.add(new Role(MANAGE_GROUP, true, true, true, true, true, true, true, true, false, false));
    }

    this.standardRoles = Collections.unmodifiableSet(roles);

    return this;
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:23,代码来源:SaslGroupBasedSecuritySettingsPlugin.java


示例5: setUp

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
   super.setUp();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("testuser", "testpassword");
   securityManager.getConfiguration().addUser("guest", "guest");
   securityManager.getConfiguration().setDefaultUser("guest");
   securityManager.getConfiguration().addRole("testuser", "arole");
   securityManager.getConfiguration().addRole("guest", "arole");
   Role role = new Role("arole", true, true, true, true, true, true, true, true, true, true);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);

   resourceAdapter = new ActiveMQResourceAdapter();
   resourceAdapter.setEntries("[\"java://jmsXA\"]");

   resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
   MyBootstrapContext ctx = new MyBootstrapContext();
   resourceAdapter.start(ctx);
   mcf = new ActiveMQRAManagedConnectionFactory();
   mcf.setResourceAdapter(resourceAdapter);
   qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:OutgoingConnectionTest.java


示例6: setUp

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
   useDummyTransactionManager();
   super.setUp();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("testuser", "testpassword");
   securityManager.getConfiguration().addUser("guest", "guest");
   securityManager.getConfiguration().setDefaultUser("guest");
   securityManager.getConfiguration().addRole("testuser", "arole");
   securityManager.getConfiguration().addRole("guest", "arole");
   Role role = new Role("arole", true, true, true, true, true, true, true, true, true, true);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);
   resourceAdapter = new ActiveMQResourceAdapter();

   resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
   MyBootstrapContext ctx = new MyBootstrapContext();
   resourceAdapter.start(ctx);
   ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory();
   mcf.setResourceAdapter(resourceAdapter);
   qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:JMSContextTest.java


示例7: setUp

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
   useDummyTransactionManager();
   super.setUp();
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addUser("testuser", "testpassword");
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addUser("guest", "guest");
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().setDefaultUser("guest");
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("testuser", "arole");
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("guest", "arole");
   Role role = new Role("arole", true, true, true, true, true, true, true, true, true, true);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);

   resourceAdapter = new ActiveMQResourceAdapter();
   resourceAdapter.setEntries("[\"java://jmsXA\"]");

   resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
   MyBootstrapContext ctx = new MyBootstrapContext();
   resourceAdapter.start(ctx);
   mcf = new ActiveMQRAManagedConnectionFactory();
   mcf.setResourceAdapter(resourceAdapter);
   qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:OutgoingConnectionJTATest.java


示例8: setUp

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
   useDummyTransactionManager();
   super.setUp();
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addUser("testuser", "testpassword");
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addUser("guest", "guest");
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().setDefaultUser("guest");
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("testuser", "arole");
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("guest", "arole");
   Role role = new Role("arole", true, true, true, true, true, true, true, true);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);

   resourceAdapter = new ActiveMQResourceAdapter();
   resourceAdapter.setEntries("[\"java://jmsXA\"]");
   resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
   MyBootstrapContext ctx = new MyBootstrapContext();
   resourceAdapter.start(ctx);
   mcf = new ActiveMQRAManagedConnectionFactory();
   mcf.setAllowLocalTransactions(true);
   mcf.setResourceAdapter(resourceAdapter);
   qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:OutgoingConnectionNoJTATest.java


示例9: testCreateDurableQueueWithRole

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void testCreateDurableQueueWithRole() throws Exception {
   ActiveMQServer server = createServer();
   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("auser", "pass");
   Role role = new Role("arole", false, false, true, false, false, false, false, false, false, false);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   securityRepository.addMatch(SecurityTest.addressA, roles);
   securityManager.getConfiguration().addRole("auser", "arole");
   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
   session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
   session.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:SecurityTest.java


示例10: testCreateDurableQueueWithoutRole

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void testCreateDurableQueueWithoutRole() throws Exception {
   ActiveMQServer server = createServer();

   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("auser", "pass");
   Role role = new Role("arole", false, false, false, false, false, false, false, false, false, false);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   securityRepository.addMatch(SecurityTest.addressA, roles);
   securityManager.getConfiguration().addRole("auser", "arole");
   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
   try {
      session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
      Assert.fail("should throw exception");
   } catch (ActiveMQSecurityException se) {
      //ok
   } catch (ActiveMQException e) {
      fail("Invalid Exception type:" + e.getType());
   }
   session.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:SecurityTest.java


示例11: testDeleteDurableQueueWithRole

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void testDeleteDurableQueueWithRole() throws Exception {
   ActiveMQServer server = createServer();
   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("auser", "pass");
   Role role = new Role("arole", false, false, true, true, false, false, false, false, false, true);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   securityRepository.addMatch(SecurityTest.addressA, roles);
   securityManager.getConfiguration().addRole("auser", "arole");
   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
   session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
   session.deleteQueue(SecurityTest.queueA);
   session.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:19,代码来源:SecurityTest.java


示例12: testDeleteDurableQueueWithoutRole

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void testDeleteDurableQueueWithoutRole() throws Exception {
   ActiveMQServer server = createServer();
   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("auser", "pass");
   Role role = new Role("arole", false, false, true, false, false, false, false, false, false, false);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   securityRepository.addMatch(SecurityTest.addressA, roles);
   securityManager.getConfiguration().addRole("auser", "arole");
   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
   session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
   try {
      session.deleteQueue(SecurityTest.queueA);
      Assert.fail("should throw exception");
   } catch (ActiveMQSecurityException se) {
      //ok
   } catch (ActiveMQException e) {
      fail("Invalid Exception type:" + e.getType());
   }
   session.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:SecurityTest.java


示例13: testCreateTempQueueWithRole

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void testCreateTempQueueWithRole() throws Exception {
   ActiveMQServer server = createServer();

   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("auser", "pass");
   Role role = new Role("arole", false, false, false, false, true, false, false, false, false, false);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   securityRepository.addMatch(SecurityTest.addressA, roles);
   securityManager.getConfiguration().addRole("auser", "arole");
   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
   session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
   session.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:19,代码来源:SecurityTest.java


示例14: testCreateTempQueueWithoutRole

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void testCreateTempQueueWithoutRole() throws Exception {
   ActiveMQServer server = createServer();

   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("auser", "pass");
   Role role = new Role("arole", false, false, false, false, false, false, false, false, false, false);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   securityRepository.addMatch(SecurityTest.addressA, roles);
   securityManager.getConfiguration().addRole("auser", "arole");
   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
   try {
      session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
      Assert.fail("should throw exception");
   } catch (ActiveMQSecurityException se) {
      //ok
   } catch (ActiveMQException e) {
      fail("Invalid Exception type:" + e.getType());
   }
   session.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:SecurityTest.java


示例15: testDeleteTempQueueWithRole

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void testDeleteTempQueueWithRole() throws Exception {
   ActiveMQServer server = createServer();
   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("auser", "pass");
   Role role = new Role("arole", false, false, false, false, true, true, false, false, false, true);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   securityRepository.addMatch(SecurityTest.addressA, roles);
   securityManager.getConfiguration().addRole("auser", "arole");
   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
   session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
   session.deleteQueue(SecurityTest.queueA);
   session.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:19,代码来源:SecurityTest.java


示例16: testDeleteTempQueueWithoutRole

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void testDeleteTempQueueWithoutRole() throws Exception {
   ActiveMQServer server = createServer();
   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("auser", "pass");
   Role role = new Role("arole", false, false, false, false, true, false, false, false, false, false);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   securityRepository.addMatch(SecurityTest.addressA, roles);
   securityManager.getConfiguration().addRole("auser", "arole");
   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
   session.createQueue(SecurityTest.addressA, SecurityTest.queueA, false);
   try {
      session.deleteQueue(SecurityTest.queueA);
      Assert.fail("should throw exception");
   } catch (ActiveMQSecurityException se) {
      //ok
   } catch (ActiveMQException e) {
      fail("Invalid Exception type:" + e.getType());
   }
   session.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:SecurityTest.java


示例17: testNonBlockSendWithoutRole

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void testNonBlockSendWithoutRole() throws Exception {
   ActiveMQServer server = createServer();

   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("auser", "pass");
   Role role = new Role("arole", false, false, true, false, false, false, false, false, false, false);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   securityRepository.addMatch(SecurityTest.addressA, roles);
   securityManager.getConfiguration().addRole("auser", "arole");
   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
   session.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
   ClientProducer cp = session.createProducer(SecurityTest.addressA);
   cp.send(session.createMessage(false));
   session.close();

   Queue binding = (Queue) server.getPostOffice().getBinding(new SimpleString(SecurityTest.queueA)).getBindable();
   Assert.assertEquals(0, getMessageCount(binding));
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:24,代码来源:SecurityTest.java


示例18: testSendManagementWithRole

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void testSendManagementWithRole() throws Exception {
   ActiveMQServer server = createServer();

   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("auser", "pass");
   Role role = new Role("arole", false, false, false, false, false, false, true, false, false, false);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
   securityManager.getConfiguration().addRole("auser", "arole");
   locator.setBlockOnNonDurableSend(true);
   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
   ClientProducer cp = session.createProducer(configuration.getManagementAddress());
   cp.send(session.createMessage(false));
   session.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:21,代码来源:SecurityTest.java


示例19: testNonBlockSendManagementWithoutRole

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Test
public void testNonBlockSendManagementWithoutRole() throws Exception {
   ActiveMQServer server = createServer();

   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser("auser", "pass");
   Role role = new Role("arole", false, false, true, false, false, false, false, false, false, false);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
   securityManager.getConfiguration().addRole("auser", "arole");
   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
   session.createQueue(configuration.getManagementAddress().toString(), SecurityTest.queueA, true);
   ClientProducer cp = session.createProducer(configuration.getManagementAddress());
   cp.send(session.createMessage(false));
   session.close();

   Queue binding = (Queue) server.getPostOffice().getBinding(new SimpleString(SecurityTest.queueA)).getBindable();
   Assert.assertEquals(0, getMessageCount(binding));

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:SecurityTest.java


示例20: setupAndStartActiveMQServer

import org.apache.activemq.artemis.core.security.Role; //导入依赖的package包/类
@Override
protected ActiveMQServer setupAndStartActiveMQServer() throws Exception {
   Configuration config = createDefaultInVMConfig().setSecurityEnabled(true);
   ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
   server.start();
   HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
   ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
   securityManager.getConfiguration().addUser(validAdminUser, validAdminPassword);
   securityManager.getConfiguration().addUser(invalidAdminUser, invalidAdminPassword);

   securityManager.getConfiguration().addRole(validAdminUser, "admin");
   securityManager.getConfiguration().addRole(validAdminUser, "guest");
   securityManager.getConfiguration().addRole(invalidAdminUser, "guest");

   Set<Role> adminRole = securityRepository.getMatch(ActiveMQDefaultConfiguration.getDefaultManagementAddress().toString());
   adminRole.add(new Role("admin", true, true, true, true, true, true, true, true, true, true));
   securityRepository.addMatch(ActiveMQDefaultConfiguration.getDefaultManagementAddress().toString(), adminRole);
   Set<Role> guestRole = securityRepository.getMatch("*");
   guestRole.add(new Role("guest", true, true, true, true, true, true, false, true, true, true));
   securityRepository.addMatch("*", guestRole);

   return server;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:24,代码来源:SecurityManagementWithConfiguredAdminUserTest.java



注:本文中的org.apache.activemq.artemis.core.security.Role类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SnappyOutputStream类代码示例发布时间:2022-05-23
下一篇:
Java FilterDefinition类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap