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

Java SimpleAuthenticationPlugin类代码示例

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

本文整理汇总了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");
}
 
开发者ID:apache,项目名称:beam,代码行数:27,代码来源:JmsIOTest.java


示例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;
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:10,代码来源:PooledConnectionSecurityExceptionTest.java


示例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;
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-bridge,代码行数:11,代码来源:ActiveMQTestBase.java


示例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();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:41,代码来源:TestJmsSource.java


示例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();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:37,代码来源:TestJmsTarget.java


示例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;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:AMQ4889Test.java


示例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();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:11,代码来源:ExceptionListenerTest.java


示例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;
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:11,代码来源:QpidJmsTestSupport.java


示例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();
}
 
开发者ID:sully6768,项目名称:devnation2014,代码行数:29,代码来源:ActiveMQConnectionFactoryServiceTest.java


示例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;
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:30,代码来源:Broker.java


示例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();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:31,代码来源:Broker.java


示例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);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:42,代码来源:TestIntegrationActiveMQ.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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