<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Securing Queues fails when using JmsXA
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/grosueugen">grosueugen</a> in <i>JBoss Messaging</i> - <a href="http://community.jboss.org/message/576154#576154">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hello,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I'm using JBoss 5.1.0.GA, jdk 1.6, on Linux.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I need to use distributed transaction with JBoss Messaging, so I used JmsXA for the connection factory.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I changed the DB for messaging, so I used Oracle DB.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>With the default security, I was able to send/consume messages to a Queue.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I decided to add a user in the Oracle DB, and that user to have rights to send/receive messages from my Queue.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>So, I did the following:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>1. create a new user in the Oracle DB:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   <em>INSERT INTO JBM_USER (USER_ID, PASSWD, CLIENTID) VALUES ('my-user', 'my-user-pwd', null);<br/>   INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('my-role', 'my-user');<br/></em></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>2. in code, when obtaining a connection, I would use the username: "my-user", password: "my-user-pwd":</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <em>Connection connection = connectionFactory.createConnection("my-user", "my-user-pwd");</em></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>3. I created a new file for defining destinations, named, my-jms-service.xml, and put it in xxx/deploy/</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><em>  <?xml version="1.0" encoding="UTF-8"?></em></p><p>  <em><server>         <br/>     <mbean code="org.jboss.jms.server.destination.QueueService"<br/>      name="orvaal.rtra.jms.destination:service=Queue,name=MyQueue"<br/>      xmbean-dd="xmdesc/Queue-xmbean.xml"><br/>      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends><br/>      <depends>jboss.messaging:service=PostOffice</depends></em></p><p><em>      <attribute name="SecurityConfig"><br/>         <security><br/>            <role name="my-role" read="true" write="true"/><br/>         </security><br/>      </attribute></em><br/><em>    </mbean><br/></em></p><p><em></server></em></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>4. In xxx/conf/login-config.xml, I created a new <application-policy>:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    <em><application-policy name="MyJmsXARealm"><br/>    <authentication><br/>         <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required"><br/>        <module-option name="dsJndiName">java:/jdbc/MyXAOracleDSJms</module-option><br/>            <module-option name="principalsQuery">SELECT PASSWD FROM JBM_USER WHERE USER_ID=?</module-option><br/>            <module-option name="rolesQuery">SELECT ROLE_ID, 'Roles' FROM JBM_ROLE WHERE USER_ID=?</module-option><br/>         </login-module><br/>      </authentication><br/>  </application-policy></em></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   <em>java:/jdbc/MyXAOracleDSJms</em> is the JNDI name for the datasource configured for the Oracle DB used by JBoss Messaging</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>5. In xxx/deploy/messaging/jms-ds.xml, I edited the JmsXA to know of the created MyJmsXARealm:</p><p><em><br/></em></p><p><em>    <!-- JMS XA Resource adapter, use this to get transacted JMS in beans --><br/>   <tx-connection-factory><br/>      <jndi-name>JmsXA</jndi-name><br/>      <xa-transaction/><br/>      <rar-name>jms-ra.rar</rar-name><br/>      <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition><br/>      <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property><br/>      <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property><br/>      <max-pool-size>20</max-pool-size><br/>      <!-- COMMENTED THE INITIAL REALM <security-domain-and-application>JmsXARealm</security-domain-and-application> --><br/>      <security-domain-and-application>MyJmsXARealm</security-domain-and-application><br/>      <depends>jboss.messaging:service=ServerPeer</depends><br/>   </tx-connection-factory></em></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The error is:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>2010-12-15 15:27:53,374 ERROR [org.jboss.resource.adapter.jms.JmsSessionFactoryImpl] (http-127.0.0.1-8080-1) could not create session<br/>java.lang.SecurityException: Unauthenticated caller:null<br/>    at org.jboss.security.integration.JBossSecuritySubjectFactory.createSubject(JBossSecuritySubjectFactory.java:92)<br/>    at org.jboss.resource.connectionmanager.BaseConnectionManager2.getSubject(BaseConnectionManager2.java:687)<br/>    at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:495)<br/>    at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)<br/>    at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.allocateConnection(JmsSessionFactoryImpl.java:395)<br/>    at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.createSession(JmsSessionFactoryImpl.java:374)<br/>    at MySLSB.addToMyQueue(MySLSB.java:103)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Have I done something wrong?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thanks.</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/576154#576154">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Messaging at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>