<!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 JBoss Messaging and EJB3
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/ejb3workshop">Alexander Hartner</a> in <i>JBoss Messaging</i> - <a href="http://community.jboss.org/message/553934#553934">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>I would like to ensure all access to any JMS destination is authenticated so I disabled the guest account in messaging-service.xml</p><blockquote class="jive-quote"><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><div id="_mcePaste">      <attribute name="DefaultSecurityConfig"></div>
<div id="_mcePaste">        <security></div>
<div id="_mcePaste">            <role name="jmsuser" read="true" write="true" create="true"/></div>
<div id="_mcePaste">        </security></div>
<div id="_mcePaste">      </attribute></div></blockquote><p><span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif;">I then added a new users to messaging-roles.properties and messaging-users.properties. </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif;">Now my problem is how can I get my application to access the queues. I am using EJB3 annotations as well as dependency injection for the connection factory and destinations. I was hoping to link the entire application to an application-policy specified in login-config.xml using something like this, in a similar way passwords are set on datasources:</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><blockquote class="jive-quote"><p><p>    <application-policy name="EncryptJMSPassword"></p><p>        <authentication></p><p>            <login-module code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required"></p><p>                <module-option name="username"> jmsuser </module-option></p><p>                <module-option name="password">XXXXXXXXXXXXXXXXXXXXXXXXX</module-option></p><p>            </login-module></p><p>        </authentication></p><p>    </application-policy></p></p></blockquote></p><p>and then to specify the policyname in either jboss.xml or jboss-app.xml. However I haven't found a way of doing this. I did get the application deployed using :</p><blockquote class="jive-quote"><p><p class="MsoNormal"><strong><span>            <activation-config></span></strong></p>
<p class="MsoNormal"><strong><span>              
<activation-config-property></span></strong></p>
<p class="MsoNormal"><strong><span>                  
<activation-config-property-name>user</activation-config-property-name></span></strong></p>
<p class="MsoNormal"><strong><span>                  
<activation-config-property-value> jmsuser </activation-config-property-value></span></strong></p>
<p class="MsoNormal"><strong><span>              
</activation-config-property></span></strong></p>
<p class="MsoNormal"><strong><span>              
<activation-config-property></span></strong></p>
<p class="MsoNormal"><strong><span>                  
<activation-config-property-name>password</activation-config-property-name></span></strong></p>
<p class="MsoNormal"><strong><span>                  
<activation-config-property-value>jmspassword</activation-config-property-value></span></strong></p>
<p class="MsoNormal"><strong><span>              
</activation-config-property></span></strong></p>
<p class="MsoNormal"><strong><span>          
</activation-config></span></strong></p></p></blockquote><p>in ejb-jar.xml, however this only addresses the reading of messages from a queue, I believe. It also has to be done on each bean which is not ideal and not very flexible as the password is hard coded inside the ear. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Are there any more elegant options of granting one application unrestricted access to any JMS resources. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Without specifying these I am getting the following error message during startup:</p><blockquote class="jive-quote"><p><p>javax.jms.JMSSecurityException: User: null is not authorized to read from destination TransactionJobs</p><p>        at org.jboss.jms.server.container.SecurityAspect.check(SecurityAspect.java:312)</p><p>        at org.jboss.jms.server.container.SecurityAspect.handleCreateConsumerDelegate(SecurityAspect.java:112)</p></p></blockquote><p>as well as:</p><blockquote class="jive-quote"><p><p>20:04:43,097 FATAL [ConfigurationMonitor] Authentication failure</p><p>javax.ejb.EJBAccessException: Authentication failure</p><p>        at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.handleGeneralSecurityException(Ejb3AuthenticationInterceptor.java:68)</p><p>        at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:70)</p><p>        at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)</p></p></blockquote></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/553934#553934">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>