<!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;">
custom ServerLoginModule Problem: Authentication failed: all available authentication mechanisms failed
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/john_k">john_k</a> in <i>JBoss AS 7 Development</i> - <a href="https://community.jboss.org/message/737021#737021">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, </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>i have some problems to set up a custom serverloginmodule for jboss as7 any help would be appriciated.</p><p>I am still new to jboss and jboss as7 so maybe i try to tackle my problem with the wrong tools or i miss just some things i need to know to do it properly.</p><p>So maybe someone could point me to the correct direction <span> ;) </span> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong>What i want to achieve:</strong></p><ul><li style="text-align: start;">i want to access a secured remote ejb via a "normal" java client </li><li style="text-align: start;">before i access the bean i want to be authenticated via jaas via the jboss with a custom ServerLoginModule <ul><li style="text-align: start;">call org.jboss.security.ClientLoginModule via LoginContext</li></ul></li></ul><p style="text-align: start;">          </p><p>     </p><pre class="jive-pre"><code class="jive-code">jboss{
              org.jboss.security.ClientLoginModule required
               ;
      };
</code></pre><p>     </p><p>   </p><pre class="jive-pre"><code class="jive-code jive-java">String contextName = <font color="red">"jboss"</font>
Subject subject = <font color="navy"><b>new</b></font> Subject(false, <font color="navy"><b>new</b></font> HashSet<Principal>(),
                <font color="navy"><b>new</b></font> HashSet<String>(), <font color="navy"><b>new</b></font> HashSet<String>());
LoginContext loginContext = <font color="navy"><b>new</b></font> LoginContext(contextName,
                        subject);
loginContext.login();
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ul><li style="text-align: start;">if the login succeeds i want to create the initial context and access the bean</li></ul><p style="text-align: start;">code</p><pre class="jive-pre"><code class="jive-code jive-java">Properties jndiProperties = <font color="navy"><b>new</b></font> Properties();
jndiProperties.put(Context.URL_PKG_PREFIXES,
                <font color="red">"org.jboss.ejb.client.naming"</font>);
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY,
                org.jboss.naming.remote.client.InitialContextFactory.class
                        .getName());
jndiProperties.put(Context.PROVIDER_URL, <font color="red">"remote://localhost:4447"</font>);
jndiProperties.put(<font color="red">"jboss.naming.client.ejb.context"</font>, <font color="navy"><b>true</b></font>);
jndiProperties
                .put(<font color="red">"jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT"</font>,
                        <font color="red">"false"</font>);
jndiProperties.put(Context.SECURITY_PRINCIPAL, <font color="red">"user"</font>);
jndiProperties.put(Context.SECURITY_CREDENTIALS, <font color="red">"pass"</font>);<font color="darkgreen">// pass");</font>
Context context =context = <font color="navy"><b>new</b></font> InitialContext(jndiProperties);
 
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>jboss-ejb-client.properties</p><pre class="jive-pre"><code class="jive-code jive-java">endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=<font color="navy"><b>false</b></font>
remote.connections=<font color="navy"><b>default</b></font>
remote.connection.default.host=localhost
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=<font color="navy"><b>false</b></font>
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=<font color="navy"><b>false</b></font>
</code></pre><p>    </p><ul><li style="text-align: start;">on the server side a implementation of AbstractServerLoginModule should be called<ul><li style="text-align: start;">i putted my implementation in a jar and tried to add it to a jboss module. </li><li style="text-align: start;">i tried two ways <ul><li style="text-align: start;">1) put it in a independent module</li><li style="text-align: start;"><span>2) put it in the  org\jboss\as\remoting\main module [after reading this (I added it on the jboss_install_dir/modules/org/jboss/as/remoting/main and modified the module.xml </span><a class="jive-link-external-small" href="https://community.jboss.org/thread/195501?start=15&tstart=0" target="_blank">https://community.jboss.org/thread/195501?start=15&tstart=0</a><span>)</span></li></ul></li><li style="text-align: start;">both with the same result</li></ul></li><li style="text-align: start;">my server config looks like this:</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="text-align: start;">     </p><p>          </p><pre class="jive-pre"><code class="jive-code jive-java"><security-realm name=<font color="red">"ApplicationRealm"</font>>
                <authentication>
                    <properties relative-to=<font color="red">"jboss.server.config.dir"</font> path=<font color="red">"${jboss.server.config.dir}/application-users.properties"</font>/>
                </authentication>
            </security-realm>
           
             <security-realm name=<font color="red">"MyAppRealm"</font>>
                <authentication>
                    <jaas name=<font color="red">"myAppJaas"</font>/>
                </authentication>
            </security-realm>
    
     <security-domains>
            <security-domain name=<font color="red">"myAppJaas"</font> cache-type=<font color="red">"default"</font>>
                <authentication>
                    <login-module code=<font color="red">"sampleApp.jboss.login.AuthLoginModule"</font>
                        flag=<font color="red">"required"</font>>
                        <module-option name=<font color="red">"debug"</font> value=<font color="red">"true"</font> />
                    </login-module>
                </authentication>
            </security-domain>
         </security-domains>
 
      <subsystem xmlns=<font color="red">"urn:jboss:domain:remoting:1.1"</font>>
            <connector name=<font color="red">"remoting-connector"</font> socket-binding=<font color="red">"remoting"</font> security-realm=<font color="red">"MyAppRealm"</font>/>
        </subsystem>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="text-align: start;"><strong>What i get at the moment:</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ul><li style="text-align: start;">i removed the part where i try to login via jaas upfront figured out that it does not make any diffrence in my sample</li><li style="text-align: start;">it seems that my loginmodule(server) doesent get called (sampleApp.jboss.login.AuthLoginModule)</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="text-align: start;">the only output i get on server side:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>14:04:07,946 TRACE [org.jboss.security.auth.login.XMLLoginConfigImpl] (Remoting "client" task-3) Begin getAppConfigurationEntry(myAppJaas), size=1</p><p>14:04:07,952 TRACE [org.jboss.security.auth.login.XMLLoginConfigImpl] (Remoting "client" task-3) End getAppConfigurationEntry(myAppJaas), authInfo=AppConfigurationEntry[]:</p><p>[0]</p><p>LoginModule Class: sampleApp.jboss.login.AuthLoginModule</p><p>ControlFlag: Anmeldemodul-Steuerflag: required</p><p>Options:</p><p>name=debug, value=true</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>client output:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Mai 22, 2012 2:04:07 PM org.xnio.Xnio <clinit></p><p>INFO: XNIO Version 3.0.3.GA</p><p>Mai 22, 2012 2:04:07 PM org.xnio.nio.NioXnio <clinit></p><p>INFO: XNIO NIO Implementation Version 3.0.3.GA</p><p>Mai 22, 2012 2:04:07 PM org.jboss.remoting3.EndpointImpl <clinit></p><p>INFO: JBoss Remoting version 3.2.2.GA</p><p>Mai 22, 2012 2:04:07 PM org.jboss.remoting3.remote.RemoteConnection handleException</p><p>ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed</p><p>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]</p><p>    at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)</p><p>    at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:117)</p><p>    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)</p><p>    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)</p><p>    at javax.naming.InitialContext.init(InitialContext.java:242)</p><p>    at javax.naming.InitialContext.<init>(InitialContext.java:216)</p><p>    at Main.main(Main.java:37)</p><p>Caused by: java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed</p><p>    at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:87)</p><p>    at org.jboss.naming.remote.client.cache.ConnectionCache.get(ConnectionCache.java:42)</p><p>    at org.jboss.naming.remote.client.InitialContextFactory.createConnection(InitialContextFactory.java:153)</p><p>    at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateConnection(InitialContextFactory.java:126)</p><p>    at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:106)</p><p>    ... 5 more</p><p>Caused by: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed</p><p>    at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:315)</p><p>    at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:214)</p><p>    at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)</p><p>    at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189)</p><p>    at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103)</p><p>    at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)</p><p>    at org.xnio.nio.NioHandle.run(NioHandle.java:90)</p><p>    at org.xnio.nio.WorkerThread.run(WorkerThread.java:184)</p><p>    at ...asynchronous invocation...(Unknown Source)</p><p>    at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:270)</p><p>    at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:251)</p><p>    at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:349)</p><p>    at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:333)</p><p>    at org.jboss.naming.remote.client.cache.EndpointCache$EndpointWrapper.connect(EndpointCache.java:110)</p><p>    at org.jboss.naming.remote.client.cache.ConnectionCache.get(ConnectionCache.java:41)</p><p>    ... 8 more</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong>Problems:</strong></p><ul><li style="text-align: start;">the login module doesent get called --> leads to the sasl exception i assume.. (javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed)</li><li style="text-align: start;">how to get more useful debug/trace output from the security module</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="text-align: start;">Thank you for your time ... any help would be appreciated.. and sorry for my bad english <span> ;) </span> i hope you could get my point anyways</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/737021#737021">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AS 7 Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>