<!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="https://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;">
    Authentication failed using DatabaseServerLoginModule
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/rmarini">Ricardo Marini</a> in <i>PicketBox Development</i> - <a href="https://community.jboss.org/message/784490#784490">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi all.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I'm trying to use the DatabaseServerLoginModule, but isn't working. I found many examples like this.<br/>What is wrong?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've in my standalone.xml:</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ...<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;security-domain name="TestSecurityDomain" cache-type="default"&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;authentication&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;login-module code="Remoting" flag="optional"&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;module-option name="password-stacking" value="useFirstPass"/&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/login-module&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required"&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;module-option name="dsJndiName" value="java:jboss/datasources/MysqlDS"/&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;module-option name="principalsQuery" value="select u_password from users where u_name=?"/&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;module-option name="rolesQuery" value="select u_profile_name, 'Roles' from user_profile where u_name=?"/&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;module-option name="password-stacking" value="useFirstPass"/&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/login-module&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/authentication&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/security-domain&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ...<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;datasource jndi-name="java:jboss/datasources/MysqlDS" pool-name="MysqlDS" enabled="true" use-java-context="true"&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;connection-url&gt;jdbc:mysql://localhost:3306/teste&lt;/connection-url&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;driver&gt;mysql&lt;/driver&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;security&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;user-name&gt;user_db&lt;/user-name&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;password&gt;pass_db&lt;/password&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/security&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;statement&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;prepared-statement-cache-size&gt;100&lt;/prepared-statement-cache-size&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;share-prepared-statements&gt;true&lt;/share-prepared-statements&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/statement&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/datasource&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ...<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;security-realm name="TestApplicationRealm"&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;authentication&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;jaas name="TestSecurityDomain"/&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/authentication&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/security-realm&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ...<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;subsystem xmlns="urn:jboss:domain:remoting:1.1"&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;connector name="remoting-connector" socket-binding="remoting" security-realm="TestApplicationRealm"/&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/subsystem&gt;</p><p>&#160; <br/>In the jboss-app.xml:<br/>&lt;security-domain&gt;TestSecurityDomain&lt;/security-domain&gt;</p><p><br/>In the client side:</p><p>jboss-ejb-client.properties:<br/>endpoint.name=client-endpoint<br/>remote.connections=default<br/>remote.connection.default.host=localhost<br/>remote.connection.default.port=4447<br/>remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=true<br/>remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=JBOSS-LOCAL-USER<br/>remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false<br/>remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false</p><p><br/>lookup class:<br/>&#160;&#160; Hashtable envTable = new Hashtable();<br/>&#160;&#160; envTable.put(Context.URL_PKG_PREFIXES,<br/>&#160;&#160;&#160;&#160; "org.jboss.ejb.client.naming");<br/>&#160;&#160; envTable.put(Context.INITIAL_CONTEXT_FACTORY,<br/>&#160;&#160;&#160;&#160; "org.jboss.naming.remote.client.InitialContextFactory");<br/>&#160;&#160; envTable.put(Context.PROVIDER_URL, "remote://localhost:4447");<br/>&#160;&#160; envTable.put(Context.SECURITY_PRINCIPAL, "rmarini");<br/>&#160;&#160; envTable.put(Context.SECURITY_CREDENTIALS, "rmarini1");<br/>&#160;&#160; envTable.put("jboss.naming.client.ejb.context", true);<br/>&#160;&#160; Context context = new InitialContext(envTable);</p><p>&#160;&#160; <br/>When I run the client, returns this exception:<br/>INFO: JBoss Remoting version 3.2.3.GA<br/>21/12/2012 10:57:57 org.jboss.remoting3.remote.RemoteConnection handleException<br/>ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed<br/>javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed]<br/> at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)<br/> at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)<br/> at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)<br/> at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)<br/> at javax.naming.InitialContext.init(InitialContext.java:223)<br/> at javax.naming.InitialContext.&lt;init&gt;(InitialContext.java:197)<br/>&#160;&#160;&#160; ...<br/>Caused by: java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed<br/> at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:87)<br/> at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:56)<br/> at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)<br/> at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)<br/> at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)<br/> ... 5 more<br/>Caused by: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed<br/> at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:365)<br/> at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:214)<br/> at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)<br/> at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189)<br/> at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103)<br/> at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)<br/> at org.xnio.nio.NioHandle.run(NioHandle.java:90)<br/> at org.xnio.nio.WorkerThread.run(WorkerThread.java:184)<br/> at ...asynchronous invocation...(Unknown Source)<br/> at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:270)<br/> at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:251)<br/> at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:349)<br/> at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:333)<br/> at org.jboss.naming.remote.client.EndpointCache$EndpointWrapper.connect(EndpointCache.java:105)<br/> at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:55)<br/> ... 8 more</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>In the server, no exception is displayed, even set org.jboss.security to TRACE.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I tried with Jboss 7.1 (picketbox-4.0.7.Final) and Jboss 7.2 Alpha (picketbox-4.0.14.Final).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I found AS7-1370 related with this topic. there is a form to work around this?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Ricardo.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/784490#784490">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in PicketBox Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2088">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>