简体   繁体   English

wildfly匿名远程jms访问

[英]wildfly anonymous remote jms access

I'm trying to access a remote JMS queue from a unit test. 我正在尝试从单元测试访问远程JMS队列。 As far as I can tell by looking at the config, the Remote factory is there, and security is disabled. 据我所知,通过配置,远程工厂就在那里,并且安全性已禁用。 However, I keep getting Authentication exception. 但是,我不断收到身份验证异常。 Do I have to pass some additional properties to indicate that no Auth is required? 我是否必须传递一些其他属性以指示不需要Auth?

WildFly 10 config WildFly 10配置

<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
    <server name="default" persistence-enabled="false">
        <security enabled="false"/>
        <security-setting name="#">
            <role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true"/>
        </security-setting>
        <address-setting name="#" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" max-delivery-attempts="3" redelivery-delay="5000" expiry-address="jms.queue.ExpiryQueue" dead-letter-
address="jms.queue.DLQ"/>
        <http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http"/>
        <http-connector name="http-connector-throughput" endpoint="http-acceptor-throughput" socket-binding="http">
            <param name="batch-delay" value="50"/>
        </http-connector>
        <in-vm-connector name="in-vm" server-id="0"/>
        <http-acceptor name="http-acceptor" http-listener="default"/>
        <http-acceptor name="http-acceptor-throughput" http-listener="default">
            <param name="batch-delay" value="50"/>
            <param name="direct-deliver" value="false"/>
        </http-acceptor>
        <in-vm-acceptor name="in-vm" server-id="0"/>
        <broadcast-group name="bg-group1" connectors="http-connector" jgroups-channel="activemq-cluster" jgroups-stack=""/>
        <discovery-group name="dg-group1" jgroups-channel="activemq-cluster" jgroups-stack=""/>
        <cluster-connection name="my-cluster" discovery-group="dg-group1" connector-name="http-connector" address="jms"/>

        <jms-queue name="JobsQueue" entries="java:/JobsQueue java:jboss/exported/jms/queue/JobsQueue"/>

        <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
        <connection-factory name="CDSInVmConnectionFactory" entries="java:/CDSConnectionFactory" connectors="in-vm"/>
        <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
        <pooled-connection-factory name="hornetq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/>
    </server>
</subsystem>

Code

@Test
public void testSend(){
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
    props.put(Context.PROVIDER_URL, "http-remoting://192.168.1.115:10090");   

    try {
      Context remoteContext = new InitialContext(props);
      remoteContext.lookup("jms/RemoteConnectionFactory");
    } catch (NamingException e) {
      e.printStackTrace();
    }
}

Logs and Exception 日志和异常

 INFO | XNIO version 3.3.4.Final
 INFO | XNIO NIO Implementation Version 3.3.4.Final
 INFO | JBoss Remoting version 4.0.18.Final
javax.naming.AuthenticationException: Failed to connect to any server. Servers tried: [http-remoting://192.168.1.115:10090 (Authentication failed: all available authentication mechanisms failed:
   JBOSS-LOCAL-USER: javax.security.sasl.SaslException: Failed to read server challenge [Caused by java.io.FileNotFoundException: \docs\root\batch-etl\standalone\tmp\auth\local4222485653487147171.challenge (The system cannot find the path specified)]
   DIGEST-MD5: javax.security.sasl.SaslException: DIGEST-MD5: Cannot perform callback to acquire realm, authentication ID or password [Caused by javax.security.auth.callback.UnsupportedCallbackException])] [Root exception is javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed:
   JBOSS-LOCAL-USER: javax.security.sasl.SaslException: Failed to read server challenge [Caused by java.io.FileNotFoundException: \docs\root\batch-etl\standalone\tmp\auth\local4222485653487147171.challenge (The system cannot find the path specified)]
   DIGEST-MD5: javax.security.sasl.SaslException: DIGEST-MD5: Cannot perform callback to acquire realm, authentication ID or password [Caused by javax.security.auth.callback.UnsupportedCallbackException]]
    at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:238)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)
    at org.jboss.naming.remote.client.RemoteContext.lookupInternal(RemoteContext.java:104)
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:93)
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:146)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)

The error you are seeing is related to the JNDI connection, not the JMS connection. 您看到的错误与JNDI连接有关,而不与JMS连接有关。 JMS and JNDI are 100% independent of each other so while security may be disabled for JMS connections that doesn't mean that security for JNDI connections is also disabled. JMS和JNDI是100%彼此独立的,因此虽然JMS连接的安全性可能被禁用,但这并不意味着JNDI连接的安全性也被禁用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM