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