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

Java JMSSecurityException类代码示例

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

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



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

示例1: testFailedCreateConsumerConnectionStillWorks

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test
public void testFailedCreateConsumerConnectionStillWorks() throws JMSException {
    Connection connection = pooledConnFact.createConnection("guest", "password");
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = session.createQueue(name.getMethodName());

    try {
        session.createConsumer(queue);
        fail("Should fail to create consumer");
    } catch (JMSSecurityException ex) {
        LOG.info("Caught expected security error");
    }

    queue = session.createQueue("GUESTS." + name.getMethodName());

    MessageProducer producer = session.createProducer(queue);
    producer.close();

    connection.close();
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:23,代码来源:PooledConnectionSecurityExceptionTest.java


示例2: ensureConnected

import javax.jms.JMSSecurityException; //导入依赖的package包/类
private void ensureConnected() throws JMSException {
    if (isConnected() || closed.get()) {
        return;
    }

    synchronized(this.connectionId) {
        if (isConnected() || closed.get()) {
            return;
        }

        if (clientID == null || clientID.trim().isEmpty()) {
            throw new IllegalArgumentException("Client ID cannot be null or empty string");
        }

        if (!user.isValid()) {
            executor.shutdown();

            throw new JMSSecurityException(user.getFailureCause());
        }

        connected.set(true);
    }
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:24,代码来源:MockJMSConnection.java


示例3: createMockConnection

import javax.jms.JMSSecurityException; //导入依赖的package包/类
private MockJMSConnection createMockConnection(String username, String password) throws JMSException {
    MockJMSUser user = validateUser(username, password);

    if (!user.isValid() && !deferAuthenticationToConnection) {
        throw new JMSSecurityException(user.getFailureCause());
    }

    MockJMSConnection connection = new MockJMSConnection(user);

    if (clientID != null && !clientID.isEmpty()) {
        connection.setClientID(clientID, true);
    } else {
        connection.setClientID(UUID.randomUUID().toString(), false);
    }

    try {
        connection.initialize();
    } catch (JMSException e) {
        connection.close();
    }

    return connection;
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:24,代码来源:MockJMSConnectionFactory.java


示例4: testFailedConnectThenSucceeds

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test
public void testFailedConnectThenSucceeds() throws JMSException {
    Connection connection = pooledConnFact.createConnection("invalid", "credentials");

    try {
        connection.start();
        fail("Should fail to connect");
    } catch (JMSSecurityException ex) {
        LOG.info("Caught expected security error");
    }

    connection = pooledConnFact.createConnection("system", "manager");
    connection.start();

    LOG.info("Successfully create new connection.");

    connection.close();
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:19,代码来源:PooledConnectionSecurityExceptionTest.java


示例5: testFailedConnectThenSucceedsWithListener

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test
public void testFailedConnectThenSucceedsWithListener() throws JMSException {
    Connection connection = pooledConnFact.createConnection("invalid", "credentials");
    connection.setExceptionListener(new ExceptionListener() {

        @Override
        public void onException(JMSException exception) {
            LOG.warn("Connection get error: {}", exception.getMessage());
        }
    });

    try {
        connection.start();
        fail("Should fail to connect");
    } catch (JMSSecurityException ex) {
        LOG.info("Caught expected security error");
    }

    connection = pooledConnFact.createConnection("system", "manager");
    connection.start();

    LOG.info("Successfully create new connection.");

    connection.close();
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:26,代码来源:PooledConnectionSecurityExceptionTest.java


示例6: testFailoverWithInvalidCredentialsCanConnect

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test
public void testFailoverWithInvalidCredentialsCanConnect() throws JMSException {

    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(
        "failover:(" + connectionURI + ")");

    pooledConnFact = new JmsPoolConnectionFactory();
    pooledConnFact.setConnectionFactory(cf);
    pooledConnFact.setMaxConnections(1);

    Connection connection = pooledConnFact.createConnection("invalid", "credentials");

    try {
        connection.start();
        fail("Should fail to connect");
    } catch (JMSSecurityException ex) {
        LOG.info("Caught expected security error");
    }

    connection = pooledConnFact.createConnection("system", "manager");
    connection.start();

    LOG.info("Successfully create new connection.");

    connection.close();
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:27,代码来源:PooledConnectionSecurityExceptionTest.java


示例7: testAutoCreateOnSendToQueueSecurity

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test
public void testAutoCreateOnSendToQueueSecurity() throws Exception {
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addUser("guest", "guest");
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().setDefaultUser("guest");
   ((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("guest", "rejectAll");
   Role role = new Role("rejectAll", false, false, false, false, false, false, false, false, false, false);
   Set<Role> roles = new HashSet<>();
   roles.add(role);
   server.getSecurityRepository().addMatch("#", roles);
   Connection connection = cf.createConnection();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

   javax.jms.Queue queue = ActiveMQJMSClient.createQueue(QUEUE_NAME);

   try {
      session.createProducer(queue);
      Assert.fail("Sending a message here should throw a JMSSecurityException");
   } catch (Exception e) {
      Assert.assertTrue(e instanceof JMSSecurityException);
   }

   connection.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:24,代码来源:AutoCreateJmsDestinationTest.java


示例8: testRepeatedWrongPasswordAttempts

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test(timeout = 30000)
public void testRepeatedWrongPasswordAttempts() throws Exception {
   for (int i = 0; i < 25; ++i) {
      Connection connection = null;
      try {
         connection = createConnection(fullUser, "wrongPassword", null, false);
         connection.start();
         fail("Expected JMSException");
      } catch (JMSSecurityException ex) {
         IntegrationTestLogger.LOGGER.debug("Failed to authenticate connection with incorrect password.");
      } finally {
         if (connection != null) {
            connection.close();
         }
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:JMSConnectionWithSecurityTest.java


示例9: testConsumerNotAuthorized

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test(timeout = 30000)
public void testConsumerNotAuthorized() throws Exception {
   Connection connection = createConnection(noprivUser, noprivPass);

   try {
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      javax.jms.Queue queue = session.createQueue(getQueueName());
      try {
         session.createConsumer(queue);
         fail("Should not be able to consume here.");
      } catch (JMSSecurityException jmsSE) {
         IntegrationTestLogger.LOGGER.info("Caught expected exception");
      }
   } finally {
      connection.close();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:JMSConnectionWithSecurityTest.java


示例10: testBrowserNotAuthorized

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test(timeout = 30000)
public void testBrowserNotAuthorized() throws Exception {
   Connection connection = createConnection(noprivUser, noprivPass);

   try {
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      javax.jms.Queue queue = session.createQueue(getQueueName());
      try {
         QueueBrowser browser = session.createBrowser(queue);
         // Browser is not created until an enumeration is requesteda
         browser.getEnumeration();
         fail("Should not be able to consume here.");
      } catch (JMSSecurityException jmsSE) {
         IntegrationTestLogger.LOGGER.info("Caught expected exception");
      }
   } finally {
      connection.close();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:JMSConnectionWithSecurityTest.java


示例11: testConsumerNotAuthorizedToCreateQueues

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test(timeout = 30000)
public void testConsumerNotAuthorizedToCreateQueues() throws Exception {
   Connection connection = createConnection(noprivUser, noprivPass);

   try {
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      javax.jms.Queue queue = session.createQueue(getQueueName(getPrecreatedQueueSize() + 1));
      try {
         session.createConsumer(queue);
         fail("Should not be able to consume here.");
      } catch (JMSSecurityException jmsSE) {
         IntegrationTestLogger.LOGGER.info("Caught expected exception");
      }
   } finally {
      connection.close();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:JMSConnectionWithSecurityTest.java


示例12: testProducerNotAuthorized

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test(timeout = 30000)
public void testProducerNotAuthorized() throws Exception {
   Connection connection = createConnection(guestUser, guestPass);

   try {
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      javax.jms.Queue queue = session.createQueue(getQueueName());
      try {
         session.createProducer(queue);
         fail("Should not be able to produce here.");
      } catch (JMSSecurityException jmsSE) {
         IntegrationTestLogger.LOGGER.info("Caught expected exception");
      }
   } finally {
      connection.close();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:JMSConnectionWithSecurityTest.java


示例13: testAnonymousProducerNotAuthorized

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test(timeout = 30000)
public void testAnonymousProducerNotAuthorized() throws Exception {
   Connection connection = createConnection(guestUser, guestPass);

   try {
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      javax.jms.Queue queue = session.createQueue(getQueueName());
      MessageProducer producer = session.createProducer(null);

      try {
         producer.send(queue, session.createTextMessage());
         fail("Should not be able to produce here.");
      } catch (JMSSecurityException jmsSE) {
         IntegrationTestLogger.LOGGER.info("Caught expected exception");
      }
   } finally {
      connection.close();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:JMSConnectionWithSecurityTest.java


示例14: testCreateTemporaryQueueNotAuthorized

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test(timeout = 30000)
public void testCreateTemporaryQueueNotAuthorized() throws JMSException {
   Connection connection = createConnection(guestUser, guestPass);

   try {
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

      try {
         session.createTemporaryQueue();
      } catch (JMSSecurityException jmsse) {
         IntegrationTestLogger.LOGGER.info("Client should have thrown a JMSSecurityException but only threw JMSException");
      }

      // Should not be fatal
      assertNotNull(connection.createSession(false, Session.AUTO_ACKNOWLEDGE));
   } finally {
      connection.close();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:JMSConnectionWithSecurityTest.java


示例15: testCreateTemporaryTopicNotAuthorized

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test(timeout = 30000)
public void testCreateTemporaryTopicNotAuthorized() throws JMSException {
   Connection connection = createConnection(guestUser, guestPass);

   try {
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

      try {
         session.createTemporaryTopic();
      } catch (JMSSecurityException jmsse) {
         IntegrationTestLogger.LOGGER.info("Client should have thrown a JMSSecurityException but only threw JMSException");
      }

      // Should not be fatal
      assertNotNull(connection.createSession(false, Session.AUTO_ACKNOWLEDGE));
   } finally {
      connection.close();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:JMSConnectionWithSecurityTest.java


示例16: doMechanismSelectedTestImpl

import javax.jms.JMSSecurityException; //导入依赖的package包/类
private void doMechanismSelectedTestImpl(String username, String password, Symbol clientSelectedMech, Symbol[] serverMechs, boolean wait) throws Exception {
    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {

        testPeer.expectFailingSaslAuthentication(serverMechs, clientSelectedMech);

        ConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:" + testPeer.getServerPort() + "?jms.clientID=myclientid");
        try {
            factory.createConnection(username, password);
            fail("Excepted exception to be thrown");
        }catch (JMSSecurityException jmsse) {
            // Expected, we deliberately failed the SASL process,
            // we only wanted to verify the correct mechanism
            // was selected, other tests verify the remainder.

            LOG.info("Caught expected security exception: {}", jmsse.getMessage());
        }

        if (wait) {
            Thread.sleep(200);
        }

        testPeer.waitForAllHandlersToComplete(1000);
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:25,代码来源:SaslIntegrationTest.java


示例17: doMechanismSelectionRestrictedTestImpl

import javax.jms.JMSSecurityException; //导入依赖的package包/类
private void doMechanismSelectionRestrictedTestImpl(String username, String password, Symbol clientSelectedMech, Symbol[] serverMechs, String mechanismsOptionValue) throws Exception {
    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {

        testPeer.expectFailingSaslAuthentication(serverMechs, clientSelectedMech);

        String uriOptions = "?jms.clientID=myclientid";
        if(mechanismsOptionValue != null) {
            uriOptions += "&amqp.saslMechanisms=" + mechanismsOptionValue;
        }

        ConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:" + testPeer.getServerPort() + uriOptions);
        try {
            factory.createConnection(username, password);

            fail("Excepted exception to be thrown");
        }catch (JMSSecurityException jmsse) {
            // Expected, we deliberately failed the SASL process,
            // we only wanted to verify the correct mechanism
            // was selected, other tests verify the remainder.
        }

        testPeer.waitForAllHandlersToComplete(1000);
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:25,代码来源:SaslIntegrationTest.java


示例18: testSaslGssApiKrbConfigError

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test(timeout = 20000)
public void testSaslGssApiKrbConfigError() throws Exception {
    final String loginConfigScope = "KRB5-CLIENT-DOES-NOT-EXIST";

    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
        testPeer.expectSaslGSSAPIFail();

        String uriOptions = "?sasl.options.configScope=" + loginConfigScope + "&amqp.saslMechanisms=" + GSSAPI;
        ConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:" + testPeer.getServerPort() + uriOptions);
        factory.createConnection();

        fail("Expect exception on no login config");
    } catch (JMSSecurityException expected) {
        assertTrue(expected.getMessage().contains(loginConfigScope));
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:17,代码来源:SaslGssApiIntegrationTest.java


示例19: doMechanismSelectedTestImpl

import javax.jms.JMSSecurityException; //导入依赖的package包/类
private void doMechanismSelectedTestImpl(String username, String password, Symbol clientSelectedMech, Symbol[] serverMechs, boolean enableGssapiExplicitly) throws Exception {
    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {

        testPeer.expectFailingSaslAuthentication(serverMechs, clientSelectedMech);

        String uriOptions = "?jms.clientID=myclientid";
        if(enableGssapiExplicitly) {
            uriOptions += "&amqp.saslMechanisms=PLAIN," + GSSAPI;
        }
        ConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:" + testPeer.getServerPort() + uriOptions);

        try {
            factory.createConnection(username, password);
            fail("Excepted exception to be thrown");
        }catch (JMSSecurityException jmsse) {
            // Expected, we deliberately failed the SASL process,
            // we only wanted to verify the correct mechanism
            // was selected, other tests verify the remainder.

            LOG.info("Caught expected security exception: {}", jmsse.getMessage());
        }

        testPeer.waitForAllHandlersToComplete(1000);
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:26,代码来源:SaslGssApiIntegrationTest.java


示例20: testContextClosePreservesSessionCloseException

import javax.jms.JMSSecurityException; //导入依赖的package包/类
@Test
public void testContextClosePreservesSessionCloseException() throws JMSException {
    JmsConnection connection = Mockito.mock(JmsConnection.class);
    JmsSession session = Mockito.mock(JmsSession.class);
    Mockito.when(connection.createSession(Mockito.anyInt())).thenReturn(session);
    JmsContext context = new JmsContext(connection, JMSContext.AUTO_ACKNOWLEDGE);

    Mockito.doThrow(IllegalStateException.class).when(session).close();
    Mockito.doThrow(JMSSecurityException.class).when(connection).close();

    context.createTemporaryTopic();
    Mockito.verify(connection, Mockito.times(1)).createSession(JMSContext.AUTO_ACKNOWLEDGE);

    try {
        context.close();
        fail("Should throw ISRE");
    } catch (IllegalStateRuntimeException isre) {
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:20,代码来源:JmsContextTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java XYLayout类代码示例发布时间:2022-05-21
下一篇:
Java Project类代码示例发布时间: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