Java Code Examples for org.apache.activemq.security.SimpleAuthenticationPlugin#setAnonymousAccessAllowed()

The following examples show how to use org.apache.activemq.security.SimpleAuthenticationPlugin#setAnonymousAccessAllowed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActiveMQJmsPoolTestSupport.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
protected String createBroker() throws Exception {
    brokerService = new BrokerService();
    brokerService.setDeleteAllMessagesOnStartup(true);
    brokerService.setPersistent(false);
    brokerService.setUseJmx(true);
    brokerService.getManagementContext().setCreateConnector(false);
    brokerService.getManagementContext().setCreateMBeanServer(false);
    brokerService.setAdvisorySupport(false);
    brokerService.setSchedulerSupport(false);
    brokerService.addConnector("tcp://localhost:0").setName("test");

    ArrayList<BrokerPlugin> plugins = new ArrayList<BrokerPlugin>();

    List<AuthenticationUser> users = new ArrayList<AuthenticationUser>();
    users.add(new AuthenticationUser(USER, USER_PASSWORD, "users"));
    users.add(new AuthenticationUser(GUEST, USER_PASSWORD, "guests"));
    users.add(new AuthenticationUser(ADMIN, ADMIN, "admins"));

    SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin(users);
    authenticationPlugin.setAnonymousAccessAllowed(true);

    plugins.add(authenticationPlugin);
    plugins.add(configureAuthorization());

    brokerService.setPlugins(plugins.toArray(new BrokerPlugin[2]));

    brokerService.start();
    brokerService.waitUntilStarted();

    return brokerService.getTransportConnectorByName("test").getPublishableConnectString();
}
 
Example 2
Source File: ActiveMQTestBase.java    From vertx-proton with Apache License 2.0 5 votes vote down vote up
protected BrokerPlugin configureAuthentication() throws Exception {
  List<AuthenticationUser> users = new ArrayList<AuthenticationUser>();
  users.add(new AuthenticationUser(USERNAME_ADMIN, PASSWORD_ADMIN, "users,admins"));
  users.add(new AuthenticationUser(USERNAME_USER, PASSWORD_USER, "users"));
  users.add(new AuthenticationUser(USERNAME_GUEST, PASSWORD_GUEST, "guests"));
  SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin(users);
  authenticationPlugin.setAnonymousAccessAllowed(isAnonymousAccessAllowed());

  return authenticationPlugin;
}
 
Example 3
Source File: QpidJmsTestSupport.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
protected BrokerPlugin configureAuthentication() throws Exception {
    List<AuthenticationUser> users = new ArrayList<AuthenticationUser>();
    users.add(new AuthenticationUser("system", "manager", "users,admins"));
    users.add(new AuthenticationUser("user", "password", "users"));
    users.add(new AuthenticationUser("guest", "password", "guests"));
    SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin(users);
    authenticationPlugin.setAnonymousAccessAllowed(true);

    return authenticationPlugin;
}
 
Example 4
Source File: Broker.java    From hazelcast-simulator with Apache License 2.0 5 votes vote down vote up
public Broker start() {
    LOGGER.info("Starting broker using brokerURL: [" + brokerURL + "]");

    try {
        broker = new BrokerService();
        broker.setPersistent(false);
        broker.deleteAllMessages();
        broker.setDeleteAllMessagesOnStartup(true);
        broker.setUseJmx(false);
        broker.getSystemUsage().getTempUsage().setLimit(USAGE_LIMIT);
        broker.getSystemUsage().getStoreUsage().setLimit(USAGE_LIMIT);
        broker.addConnector(brokerURL);

        if (username != null) {
            AuthenticationUser user = new AuthenticationUser(username, password, "producers,consumer");
            SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin();
            authenticationPlugin.setAnonymousAccessAllowed(false);
            authenticationPlugin.setUsers(singletonList(user));
            broker.setPlugins(new BrokerPlugin[]{authenticationPlugin});
        }

        broker.start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    LOGGER.info("Successfully started broker");
    return this;
}