本文整理汇总了Java中org.apache.activemq.security.SimpleAuthenticationPlugin类的典型用法代码示例。如果您正苦于以下问题:Java SimpleAuthenticationPlugin类的具体用法?Java SimpleAuthenticationPlugin怎么用?Java SimpleAuthenticationPlugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleAuthenticationPlugin类属于org.apache.activemq.security包,在下文中一共展示了SimpleAuthenticationPlugin类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startBroker
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
@Before
public void startBroker() throws Exception {
broker = new BrokerService();
broker.setUseJmx(false);
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.addConnector(BROKER_URL);
broker.setBrokerName("localhost");
broker.setPopulateJMSXUserID(true);
broker.setUseAuthenticatedPrincipalForJMSXUserID(true);
// enable authentication
List<AuthenticationUser> users = new ArrayList<>();
// username and password to use to connect to the broker.
// This user has users privilege (able to browse, consume, produce, list destinations)
users.add(new AuthenticationUser(USERNAME, PASSWORD, "users"));
SimpleAuthenticationPlugin plugin = new SimpleAuthenticationPlugin(users);
BrokerPlugin[] plugins = new BrokerPlugin[]{ plugin };
broker.setPlugins(plugins);
broker.start();
// create JMS connection factory
connectionFactory = new ActiveMQConnectionFactory(BROKER_URL);
connectionFactoryWithoutPrefetch =
new ActiveMQConnectionFactory(BROKER_URL + "?jms.prefetchPolicy.all=0");
}
示例2: configureAuthentication
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
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);
return authenticationPlugin;
}
示例3: configureAuthentication
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
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;
}
示例4: setUp
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
baseDir = Files.createTempDir();
tmpDir = new File(baseDir, "tmp");
dataDir = new File(baseDir, "data");
Assert.assertTrue(tmpDir.mkdir());
passwordFile = new File(baseDir, "password");
Files.write(PASSWORD.getBytes(StandardCharsets.UTF_8), passwordFile);
broker = new BrokerService();
broker.addConnector(BROKER_BIND_URL);
broker.setTmpDataDirectory(tmpDir);
broker.setDataDirectoryFile(dataDir);
List<AuthenticationUser> users = Lists.newArrayList();
users.add(new AuthenticationUser(USERNAME, PASSWORD, ""));
SimpleAuthenticationPlugin authentication = new SimpleAuthenticationPlugin(users);
broker.setPlugins(new BrokerPlugin[]{authentication});
broker.start();
basicConfig = new BasicConfig();
credentialsConfig = new CredentialsConfig();
dataFormatConfig = new DataParserFormatConfig();
messageConfig = new MessageConfig();
jmsSourceConfig = new JmsSourceConfig();
credentialsConfig.useCredentials = true;
credentialsConfig.username = () -> USERNAME;
credentialsConfig.password = () -> PASSWORD;
dataFormat = DataFormat.JSON;
dataFormatConfig.removeCtrlChars = true;
jmsSourceConfig.initialContextFactory = INITIAL_CONTEXT_FACTORY;
jmsSourceConfig.connectionFactory = CONNECTION_FACTORY;
jmsSourceConfig.destinationName = JNDI_PREFIX + DESTINATION_NAME;
jmsSourceConfig.providerURL = BROKER_BIND_URL;
// Create a connection and start
ConnectionFactory factory = new ActiveMQConnectionFactory(USERNAME,
PASSWORD, BROKER_BIND_URL);
connection = factory.createConnection();
connection.start();
}
示例5: setUp
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
baseDir = Files.createTempDir();
tmpDir = new File(baseDir, "tmp");
dataDir = new File(baseDir, "data");
Assert.assertTrue(tmpDir.mkdir());
passwordFile = new File(baseDir, "password");
Files.write(PASSWORD.getBytes(StandardCharsets.UTF_8), passwordFile);
broker = new BrokerService();
broker.addConnector(BROKER_BIND_URL);
broker.setTmpDataDirectory(tmpDir);
broker.setDataDirectoryFile(dataDir);
List<AuthenticationUser> users = Lists.newArrayList();
users.add(new AuthenticationUser(USERNAME, PASSWORD, ""));
SimpleAuthenticationPlugin authentication = new SimpleAuthenticationPlugin(users);
broker.setPlugins(new BrokerPlugin[]{authentication});
broker.start();
credentialsConfig = new CredentialsConfig();
dataFormatConfig = new DataGeneratorFormatConfig();
jmsTargetConfig = new JmsTargetConfig();
credentialsConfig.useCredentials = true;
credentialsConfig.username = () -> USERNAME;
credentialsConfig.password = () -> PASSWORD;
jmsTargetConfig.destinationName = JNDI_PREFIX + DESTINATION_NAME;
jmsTargetConfig.initialContextFactory = INITIAL_CONTEXT_FACTORY;
jmsTargetConfig.connectionFactory = CONNECTION_FACTORY;
jmsTargetConfig.providerURL = BROKER_BIND_URL;
// Create a connection and start
ConnectionFactory factory = new ActiveMQConnectionFactory(USERNAME,
PASSWORD, BROKER_BIND_URL);
connection = factory.createConnection();
connection.start();
}
示例6: configureAuthentication
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
protected BrokerPlugin configureAuthentication() throws Exception {
List<AuthenticationUser> users = new ArrayList<>();
users.add(new AuthenticationUser(USER, GOOD_USER_PASSWORD, "users"));
SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin(users);
return authenticationPlugin;
}
示例7: startBroker
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
@Before
public void startBroker() throws Exception {
brokerService = new BrokerService();
brokerService.setAdvisorySupport(false);
brokerService.setUseJmx(false);
brokerService.setPersistent(false);
brokerService.setPlugins(new BrokerPlugin[]{new SimpleAuthenticationPlugin(new ArrayList())});
brokerUri = brokerService.addConnector("tcp://0.0.0.0:0").getConnectUri();
brokerService.start();
}
示例8: configureAuthentication
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
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;
}
示例9: testConnectionFactory
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
@Test
public void testConnectionFactory() throws Exception {
BrokerService broker = new BrokerService();
broker.setTransportConnectorURIs(new String[]{"tcp://127.0.0.1:61616"});
broker.setDataDirectory("./target/activemq-data");
SimpleAuthenticationPlugin sap = new SimpleAuthenticationPlugin();
AuthenticationUser au = new AuthenticationUser("admin", "admin", "admin");
List<AuthenticationUser> users = new ArrayList<AuthenticationUser>();
users.add(au);
sap.setUsers(users);
broker.setPlugins(new BrokerPlugin[]{sap});
broker.start();
ActiveMQConnectionFactoryService acfs = new ActiveMQConnectionFactoryService();
Map<String, String> map = new HashMap<String, String>();
map.put("brokerURL", "tcp://127.0.0.1:61616");
map.put("username", "admin");
map.put("password", "admin");
acfs.start(map, null);
Connection conn = acfs.createConnection();
assertNotNull(conn);
conn.start();
assertNotNull(conn.createSession(false, Session.AUTO_ACKNOWLEDGE));
conn.stop();
broker.stop();
}
示例10: start
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
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;
}
示例11: main
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
public static void main(String... args) throws Exception {
BrokerService broker = new BrokerService();
broker.setBrokerName("myBroker");
broker.setDataDirectory("data/");
SimpleAuthenticationPlugin authentication = new SimpleAuthenticationPlugin();
List<AuthenticationUser> users = new ArrayList<AuthenticationUser>();
users.add(new AuthenticationUser("admin", "password", "admins,publishers,consumers"));
users.add(new AuthenticationUser("publisher", "password", "publishers,consumers"));
users.add(new AuthenticationUser("consumer", "password", "consumers"));
users.add(new AuthenticationUser("guest", "password", "guests"));
authentication.setUsers(users);
broker.setPlugins(new BrokerPlugin[]{authentication});
/*JaasAuthenticationPlugin jaas = new JaasAuthenticationPlugin();
jaas.setConfiguration("src/main/resources/org/apache/activemq/book/ch5/login.config");
broker.setPlugins(new BrokerPlugin[]{jaas});*/
broker.addConnector("tcp://localhost:61616");
broker.start();
System.out.println();
System.out.println("Press any key to stop the broker");
System.out.println();
System.in.read();
}
示例12: setup
import org.apache.activemq.security.SimpleAuthenticationPlugin; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
baseDir = Files.createTempDir();
tmpDir = new File(baseDir, "tmp");
dataDir = new File(baseDir, "data");
Assert.assertTrue(tmpDir.mkdir());
passwordFile = new File(baseDir, "password");
Files.write(PASSWORD.getBytes(Charsets.UTF_8), passwordFile);
broker = new BrokerService();
broker.addConnector(BROKER_BIND_URL);
broker.setTmpDataDirectory(tmpDir);
broker.setDataDirectoryFile(dataDir);
List<AuthenticationUser> users = Lists.newArrayList();
users.add(new AuthenticationUser(USERNAME, PASSWORD, ""));
SimpleAuthenticationPlugin authentication = new SimpleAuthenticationPlugin(users);
broker.setPlugins(new BrokerPlugin[]{authentication});
broker.start();
context = new Context();
context.put(JMSSourceConfiguration.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
context.put(JMSSourceConfiguration.PROVIDER_URL, BROKER_BIND_URL);
context.put(JMSSourceConfiguration.DESTINATION_NAME, DESTINATION_NAME);
context.put(JMSSourceConfiguration.USERNAME, USERNAME);
context.put(JMSSourceConfiguration.PASSWORD_FILE, passwordFile.getAbsolutePath());
events = Lists.newArrayList();
source = new JMSSource();
source.setName("JMSSource-" + UUID.randomUUID());
ChannelProcessor channelProcessor = mock(ChannelProcessor.class);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
events.addAll((List<Event>)invocation.getArguments()[0]);
return null;
}
}).when(channelProcessor).processEventBatch(any(List.class));
source.setChannelProcessor(channelProcessor);
}