<!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;">
    Re: remote ejb client username is encrypted at the server(JBOSS7.1 CR1)
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/ganeshment">Ganesh Saithala</a> in <i>JBoss AS 7 Development</i> - <a href="https://community.jboss.org/message/719410#719410">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Thanks Daren for helping to fix this issue.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Iam posting below working EJB client API based test program.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>package demo;</p><p><br/>import java.io.IOException;<br/>import java.net.URI;<br/>import java.security.Security;<br/>import java.util.concurrent.TimeUnit;</p><p>import javax.naming.NamingException;<br/>import javax.security.auth.login.LoginException;</p><p>import org.jboss.ejb.client.ContextSelector;<br/>import org.jboss.ejb.client.EJBClient;<br/>import org.jboss.ejb.client.EJBClientContext;<br/>import org.jboss.ejb.client.EJBClientTransactionContext;<br/>import org.jboss.ejb.client.StatelessEJBLocator;<br/>import org.jboss.ejb.client.remoting.IoFutureHelper;<br/>import org.jboss.remoting3.Connection;<br/>import org.jboss.remoting3.Endpoint;<br/>import org.jboss.remoting3.Remoting;<br/>import org.jboss.remoting3.remote.RemoteConnectionProviderFactory;<br/>import org.jboss.sasl.JBossSaslProvider;<br/>import org.xnio.IoFuture;<br/>import org.xnio.OptionMap;<br/>import org.xnio.Options;</p><p><br/>public class RemoteEJBClient {<br/>&#160;&#160;&#160; <br/>&#160;&#160;&#160; /**<br/>&#160;&#160;&#160;&#160; * User login name<br/>&#160;&#160;&#160;&#160; */<br/>&#160;&#160;&#160; private static final String USER_LOGIN_NAME = "admin";</p><p>&#160;&#160;&#160; /**<br/>&#160;&#160;&#160;&#160; * User password<br/>&#160;&#160;&#160;&#160; */<br/>&#160;&#160;&#160; private static final String USER_PASSWORD = "admin";<br/>&#160;&#160;&#160; <br/>&#160;&#160;&#160; private static Connection connection;<br/>&#160;&#160;&#160; private static EJBClientContext ejbClientContext;<br/>&#160;&#160;&#160; private static Endpoint endpoint;</p><p><br/>&#160;&#160;&#160; static {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Security.addProvider(new JBossSaslProvider());<br/>&#160;&#160;&#160; }</p><p><br/>&#160;&#160;&#160; public static void main(String[] args) throws Exception {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; endpoint = Remoting.createEndpoint("ejb-remote-client-endpoint", OptionMap.EMPTY);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; endpoint.addConnectionProvider("remote", new RemoteConnectionProviderFactory(),<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;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE, Options.SASL_SERVER_AUTH,<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;&#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;&#160; Boolean.FALSE));<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; MyCallbackHandler callbackhndlr = new MyCallbackHandler(USER_LOGIN_NAME, USER_PASSWORD);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // open a connection<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final IoFuture&lt;Connection&gt; futureConnection = endpoint.connect(new URI("remote://localhost:" + "4447"),<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;&#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;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; OptionMap.create(Options.SASL_POLICY_NOPLAINTEXT,<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;&#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;&#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;&#160;&#160;&#160;&#160;&#160;&#160; Boolean.FALSE), callbackhndlr);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; connection = IoFutureHelper.get(futureConnection, 5, TimeUnit.SECONDS);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ejbClientContext = EJBClientContext.create();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ejbClientContext.registerConnection(connection);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; @SuppressWarnings("unused")<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final ContextSelector&lt;EJBClientContext&gt; previousSelector = EJBClientContext.setConstantContext(ejbClientContext);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // setting up something for transactions<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final EJBClientTransactionContext localUserTxContext = EJBClientTransactionContext.createLocal();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; EJBClientTransactionContext.setGlobalContext(localUserTxContext);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; invokeStatelessBean();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (connection != null) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; connection.close();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (IOException ioe) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Failed to close connection" + ioe);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (endpoint != null) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; endpoint.close();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (IOException ioe) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Failed to close endpoint" + ioe);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160; }</p><p>&#160;&#160;&#160; private static void invokeStatelessBean() throws NamingException, LoginException {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final SessionBeanInterface statelessSessionBeanInterface = lookupRemoteStatelessCalculator();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Obtained a remote stateless SessionBeanInterface for invocation");<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("EJB principal " + statelessSessionBeanInterface.getPrincipal());<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (RuntimeException e) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160; }</p><p><br/>&#160;&#160;&#160; private static SessionBeanInterface lookupRemoteStatelessCalculator() throws NamingException, LoginException {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String appName = "TestEAR";<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String moduleName = "TestEJB";<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String distinctName = "";<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String beanName = "SessionBean";<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String viewClassName = SessionBeanInterface.class.getName();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // create a locator depending on the type you are calling: StatelessEJBLocator, EntityEJBLocator, StatefulEJBLocator &amp;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // create the proxy given the locator<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final StatelessEJBLocator&lt;SessionBeanInterface&gt; locator = new StatelessEJBLocator&lt;SessionBeanInterface&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;&#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;&#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;&#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;&#160;&#160;&#160; SessionBeanInterface.class,<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;&#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;&#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;&#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;&#160;&#160;&#160; appName,<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;&#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;&#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;&#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;&#160;&#160;&#160; moduleName,<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;&#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;&#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;&#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;&#160;&#160;&#160; beanName,<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;&#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;&#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;&#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;&#160;&#160;&#160; distinctName);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; SessionBeanInterface bean = EJBClient.createProxy(locator);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return bean;<br/>&#160;&#160;&#160; }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><div class="mcePaste" id="_mcePaste" style="position: absolute; top: 0px; left: 0px;"></div></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/719410#719410">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>