4 Replies Latest reply on Apr 17, 2013 6:01 AM by mofarn

    Using JAASSecurityManager in Hornetq Security

    mofarn

      Hi all;

       

      I want to use JAAS with Ldap (for authentication), in a standalone HornetQ (2.3.0.CR2) server.

      I also want to use com.sun.security.auth.moduleLdapLoginModule (from jdk) for JASS LoginModule. With respect to "jaas example" I used these configs in hornetq-beans.xml (attached too) for HornetQSecurityManager bean:

       




      <bean name="HornetQSecurityManager"


      class="org.hornetq.integration.jboss.security.JAASSecurityManager">


      <start ignored="true" />


      <stop ignored="true" />





      <property name="configurationName">com.sun.security.auth.module.LdapLoginModule</property>


      <property name="configuration">

                   <inject bean="CustomConfiguration"/>

              </property>



      <property name="callbackHandler">

                   <inject bean="CustomCallbackHandler" />

              </property>


      </bean>



      <bean name="CustomConfiguration" class="custom.hornetq.security.jaas.CustomConfiguration">


      <constructor>



      <parameter>com.sun.security.auth.module.LdapLoginModule</parameter>



      <parameter>




      <map class="java.util.HashMap" keyClass="java.lang.String"





      valueClass="java.lang.String">





      <entry>






      <key>userProvider</key>






      <value>ldap://localhost:389/ou=People,dc=example,dc=com</value>





      </entry>




      </map>



      </parameter>


      </constructor>

      </bean>



      <!-- the CallbackHandler does nothing as we don't have any user interaction -->

      <bean name="CustomCallbackHandler" class="custom.hornetq.security.jaas.CustomCallbackHandler" />

       

       

      And i added a jar file (attached) containing my own CallbackHandler and Configuration implementation (custom.hornetq.security.jaas.CustomCallbackHandler and custom.hornetq.security.jaas.CustomConfiguration).

      My problem is when i want start server, I get this exception (attached too) (in Line 38: <property name="configurationName">com.sun.security.auth.module.LdapLoginModule</property>)

       

      11:10:36,570 ERROR [org.hornetq.integration.bootstrap] HQ104001: Failed to start server: java.lang.RuntimeException: Exception during Bootstrap           at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.run(AbstractBootstrap.java:93) [jboss-mc.jar:]           at org.hornetq.integration.bootstrap.HornetQBootstrapServer.run(HornetQBootstrapServer.java:115) [hornetq-bootstrap.jar:]           at org.hornetq.integration.bootstrap.HornetQBootstrapServer.main(HornetQBootstrapServer.java:69) [hornetq-bootstrap.jar:] Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: file:/C:/hornetq/config/hornetq-beans.xml@38,38           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:177) [jboss-mc.jar:]           at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:147) [jboss-mc.jar:]           at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:86) [jboss-mc.jar:]           at org.hornetq.integration.bootstrap.HornetQBootstrapServer.deploy(HornetQBootstrapServer.java:236) [hornetq-bootstrap.jar:]           at org.hornetq.integration.bootstrap.HornetQBootstrapServer.deploy(HornetQBootstrapServer.java:206) [hornetq-bootstrap.jar:]           at org.hornetq.integration.bootstrap.HornetQBootstrapServer.bootstrap(HornetQBootstrapServer.java:154) [hornetq-bootstrap.jar:]           at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.run(AbstractBootstrap.java:83) [jboss-mc.jar:]           ... 2 more Caused by: org.jboss.xb.binding.JBossXBRuntimeException: {urn:jboss:bean-deployer:2.0}property cannot appear in this position. Expected content of {urn:jboss:bean-deployer:2.0}bean is sequence: {urn:jboss:bean-deployer:2.0}alias* {urn:jboss:bean-deployer:2.0}related-class* {urn:jboss:bean-deployer:2.0}annotation* {urn:jboss:bean-deployer:2.0}classloader? {urn:jboss:bean-deployer:2.0}constructor? {urn:jboss:bean-deployer:2.0}property* {urn:jboss:bean-deployer:2.0}create? {urn:jboss:bean-deployer:2.0}start? {urn:jboss:bean-deployer:2.0}stop? {urn:jboss:bean-deployer:2.0}destroy? {urn:jboss:bean-deployer:2.0}depends* {urn:jboss:bean-deployer:2.0}demand* {urn:jboss:bean-deployer:2.0}supply* {urn:jboss:bean-deployer:2.0}install* {urn:jboss:bean-deployer:2.0}uninstall* {urn:jboss:bean-deployer:2.0}incallback* {urn:jboss:bean-deployer:2.0}uncallback*           at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:449) [jboss-mc.jar:]           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:401) [jboss-mc.jar:]           at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) [jboss-mc.jar:]           at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source) [jboss-mc.jar:]           at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) [jboss-mc.jar:]           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) [jboss-mc.jar:]           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) [jboss-mc.jar:]           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) [jboss-mc.jar:]           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) [jboss-mc.jar:]           at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) [jboss-mc.jar:]           at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) [jboss-mc.jar:]           at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) [jboss-mc.jar:]           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:173) [jboss-mc.jar:]           ... 8 more

       

      I think it can't find com.sun.security.auth.module.LdapLoginModule. What should i do to solve this?

       

      Thanks in advance.


        • 1. Re: Using JAAS with Ldap in HornetQ
          ataylor

          this is not really hornetq code, we just leverage the jboss MC to instantiate beans, however by the exception message I think its implying that the properties should come before the start/stop

          1 of 1 people found this helpful
          • 2. Re: Using JAAS with Ldap in HornetQ
            mofarn

            Is com.sun.security.auth.module.LdapLoginModule in classpath?

            • 3. Re: Using JAAS with Ldap in HornetQ
              ataylor

              you will need to add any jars that you need to the lib dir that aren't in the HornetQ lib or the JDK

              • 4. Re: Using JAAS with Ldap in HornetQ
                mofarn

                I Used this, and server started successfully:

                 

                <bean name="HornetQSecurityManager"

                                    class="org.hornetq.spi.core.security.JAASSecurityManager">

                 

                                    <property name="configurationName">com.sun.security.auth.module.LdapLoginModule</property>

                                    <property name="configuration">

                             <inject bean="CustomConfiguration"/>

                        </property>

                                    <property name="callbackHandler">

                             <inject bean="CustomCallbackHandler" />

                        </property>

                       

                        <start ignored="true" />

                                    <stop ignored="true" />

                 

                          </bean>