Jboss 我们可以在没有用户名和密码的情况下设置JMS通信吗?
我在jBoss环境中工作,实现了JMS以支持两个模块之间的异步通信。但为此,我需要通过“adduser.sh”脚本添加用户。然后用户信息保存在application-users.properties和application-roles.properties中。然后,我需要在MessagePublisher类中硬编码此用户名和密码,该类将通过以下代码块对用户进行身份验证-Jboss 我们可以在没有用户名和密码的情况下设置JMS通信吗?,jboss,jms,activemq,Jboss,Jms,Activemq,我在jBoss环境中工作,实现了JMS以支持两个模块之间的异步通信。但为此,我需要通过“adduser.sh”脚本添加用户。然后用户信息保存在application-users.properties和application-roles.properties中。然后,我需要在MessagePublisher类中硬编码此用户名和密码,该类将通过以下代码块对用户进行身份验证- final static String INITIAL_CONTEXT_FACTORY = "org.jboss.naming
final static String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
Context context=null;
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, PROVIDER_URL));
env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", "abcd"));
env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", "xyz"));
context = new InitialContext(env);
但我只想绕过用户名和密码这一步。我知道在ActiveMQ中,通过设置
可以实现同样的功能,我们可以在JMS中做同样的事情吗
我发现standalone.xml中有一个条目-
<security-settings>
<security-setting match="#">
<permission type="send" roles="guest"/>
<permission type="consume" roles="guest"/>
<permission type="createNonDurableQueue" roles="guest"/>
<permission type="deleteNonDurableQueue" roles="guest"/>
</security-setting>
</security-settings>
我确信我们需要修改此部分,但没有找到任何参考
我们如何允许匿名用户名向JMS队列或主题发送消息
提前谢谢…经过研究,我找到了答案 在消息传递子系统下的standalone.xml文件中- 拆下以下线路-
<security-settings>
<security-setting match="#">
<permission type="send" roles="guest"/>
<permission type="consume" roles="guest"/>
<permission type="createNonDurableQueue" roles="guest"/>
<permission type="deleteNonDurableQueue" roles="guest"/>
</security-setting>
谢谢
尼马里亚
<security-enabled>false</security-enabled>
<connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/>
<connector name="remoting-connector" socket-binding="remoting"/>
// Set up the context for the JNDI lookup
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, PROVIDER_URL));
// username and password are not required
//env.put(Context.SECURITY_PRINCIPAL, "username");
//env.put(Context.SECURITY_CREDENTIALS, "password");
context = new InitialContext(env);
// Create the JMS connection, session, producer, and consumer
// no need to pass the username and password when create connection
//connection = connectionFactory.createConnection("usernme", "password");
connection = connectionFactory.createConnection();