![](/img/trans.png)
[英]How can we provide username and password of the external git repository while importing it in kie workbench 7.4
[英]Can we setup JMS communication without username and password?
我在 jBoss 環境中工作並實現了 JMS 以實現兩個模塊之間的異步通信。 但是為此我需要通過“add-user.sh”腳本添加用戶。 然后用戶信息保存在 application-users.properties 和 application-roles.properties 中。 然后我需要在 MessagePublisher 類中對此用戶名和密碼進行硬編碼,該類將通過以下代碼塊對用戶進行身份驗證 -
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 中可以通過設置<simpleAuthenticationPlugin anonymousAccessAllowed="true">
同樣,我們可以在 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>
在遠程處理子系統下,我們需要刪除 security-realm 條目。 所以刪除線 -
<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();
謝謝尼爾瑪利亞
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.