<!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/apparaonali">apparaonali</a> in <i>JBoss AS 7 Development</i> - <a href="https://community.jboss.org/message/718417#718417">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 for your quick reply.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>When my test sesion bean trying to get the principal from the EJBContext, it is throwing the above error. Please find the detais of my test below.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>TestBean:</p><p>=======</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><div><span style="color: #646464; font-size: 10pt;"><div><div><span style="color: #646464; font-size: 10pt;"><p align="left">@Stateless</p><p align="left">@SecurityDomain<span style="color: #000000; font-size: 10pt;">(value = </span><span style="color: #2a00ff; font-size: 10pt;">"AppuLogin"</span><span style="color: #000000; font-size: 10pt;">)</span><div align="left"><strong style="color: #7f0055; font-size: 10pt;"><p align="left"><div align="left"><strong> </strong></div></p></strong></div></p><strong><span style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong><span style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;"><strong style=": ; color: #7f0055; font-size: 2;"><p align="left">public <span style="color: #000000; font-size: 10pt;"> </span><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">class</strong></strong><span style="color: #000000; font-size: 10pt;"> SessionBean </span><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">implements </strong></strong></p></strong></strong></strong></strong></span><span style="color: #000000; font-size: 10pt;">SessionBeanInterface {</span><span style="font-size: 10pt;"> </span></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></span><p align="left"><span style="color: #646464; font-size: 10pt;">     @Resource </span><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">private</strong></strong><span style="font-size: 10pt;"> EJBContext </span><span style="color: #0000c0; font-size: 10pt;">context</span><span style="font-size: 10pt;">;</span><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"></span></span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><p align="left">          <span style="text-decoration: underline;"><strong>Principal pp =  <span style="color: #0000c0; font-size: 10pt;">context</span><span style="font-size: 10pt;">.getCallerPrincipal();</span></strong></span><div align="left"> </div></p></span></span></span></span></p><span style="color: #646464; font-size: 10pt;"><p align="left"><span style="color: #646464; font-size: 10pt;">     @Override</span></p><p align="left"><strong><span style="color: #7f0055; font-size: 10pt;">     public </span><span style="font-size: 10pt;"> String getPrincipal() {</span><div align="left"> </div></strong></p></span></strong></span></div></div></span><p><span style="color: #646464; font-size: 10pt;"><div><span style="font-size: 10pt;"><p align="left">          System.<em style="color: #0000c0; font-size: 10pt;"><em style="color: #0000c0; font-size: 10pt;">out</em></em><span style="font-size: 10pt;">.println(pp.toString());</span><p><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></span></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></p></span></div></span></p><p><span style="font-size: 10pt;"><p><strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">          return</strong></strong><span style="font-size: 10pt;"> (String) (</span><span style="color: #0000c0; font-size: 10pt;">context</span><span style="font-size: 10pt;">.getCallerPrincipal().getName());</span></p></span></p><p><span style="font-size: 10pt;"><p align="left">     }</p></span><p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><div class="mcePaste" id="_mcePaste" style="position: absolute; top: 0px; left: 0px;"></div><p><a class="jive-link-anchor-small">#</a></p></p><p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></p><p>Standalone Remote Client code:</p><p><p>=========================</p><p><span style="color: #646464; font-size: 10pt;">public class RemoteEJBClient {<br/>    <br/>    private static final String USER_LOGIN_NAME = "admin";<br/>    private static final String USER_PASSWORD = "admin";<br/>    <br/>    static {<br/>        Security.addProvider(new JBossSaslProvider());<br/>    }</span></p><p><span style="color: #646464; font-size: 10pt;">    <br/>    public static final String AUTH_LOGIN_CONFIG = "java.security.auth.login.config";<br/>    <br/>    public static final String AUTH_CONF = "/auth.conf";</span></p><p><span style="color: #646464; font-size: 10pt;">    public static void main(String[] args) throws Exception {<br/>        <br/>        if (System.getProperties().getProperty(RemoteEJBClient.AUTH_LOGIN_CONFIG) == null) {<br/>            URL url = RemoteEJBClient.class.getClass().getResource(RemoteEJBClient.AUTH_CONF);<br/>            if (url != null) {<br/>                System.getProperties().setProperty(RemoteEJBClient.AUTH_LOGIN_CONFIG, url.toString());<br/>            }<br/>        }<br/>        </span></p><p><span style="color: #646464; font-size: 10pt;">        AppCallbackHandler callbackHandler = new AppCallbackHandler(USER_LOGIN_NAME, USER_PASSWORD.toCharArray());<br/>        LoginContext loginContext = new LoginContext("logincontextname", callbackHandler);<br/>        loginContext.login();</span></p><p><span style="color: #646464; font-size: 10pt;">        <br/>        final Hashtable jndiProperties = new Hashtable();<br/>        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");<br/>        final Context context = new InitialContext(jndiProperties);</span></p><span style="color: #646464; font-size: 10pt;"><p><br/>        invokeStatelessBean(context);<br/>    }</p><p>    private static void invokeStatelessBean(Context context) throws NamingException, LoginException {</p><p>        final SessionBeanInterface statelessSessionBeanInterface = lookupRemoteStatelessCalculator(context);<br/>        System.out.println("Obtained a remote stateless SessionBeanInterface for invocation");<br/>        try {<br/>            final String principal = statelessSessionBeanInterface.getPrincipal();<br/>            System.out.println("EJB principal " + statelessSessionBeanInterface.getPrincipal());<br/>        } catch (RuntimeException e) {<br/>            e.printStackTrace();<br/>        }<br/>    }</p><p><br/>    private static SessionBeanInterface lookupRemoteStatelessCalculator(Context context) throws NamingException, LoginException {</p><p>        </p><p>        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>        return (SessionBeanInterface) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName<br/>                + "!" + viewClassName);<br/>    }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Client ejb properties:</p><p>===============</p></span></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="color: #2a00ff; font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></span></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><span style="color: #2a00ff; font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></span></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-size: 10pt;"><p align="left">remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=<span style="color: #2a00ff; font-size: 10pt;">false</span></p></span></p><p><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left">remote.connections=<span style="color: #2a00ff; font-size: 10pt;">default</span></p></span></p><p><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><span style="font-size: 2;"><p align="left">remote.connection.default.host=</p></span><span style="text-decoration: underline;"><span style="color: #2a00ff; font-size: 10pt; text-decoration: underline;"><span style="color: #2a00ff; font-size: 10pt; text-decoration: underline;">localhost</span></span></span><p align="left"><span style="color: #2a00ff; font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></span></p></span></p><p><span style="font-size: 10pt;"><p align="left">remote.connection.default.port = <span style="color: #2a00ff; font-size: 10pt;">4447</span></p></span></p><p><span style="font-size: 10pt;"><p align="left">remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=<span style="color: #2a00ff; font-size: 10pt;">false</span></p></span></p><p><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><span style="font-size: 2;"><p align="left">remote.connection.two.host=</p></span><span style="text-decoration: underline;"><span style="color: #2a00ff; font-size: 10pt; text-decoration: underline;"><span style="color: #2a00ff; font-size: 10pt; text-decoration: underline;">localhost</span></span></span><p align="left"><span style="color: #2a00ff; font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></span></p></span></p><p><span style="font-size: 10pt;"><p align="left">remote.connection.two.port = <span style="color: #2a00ff; font-size: 10pt;">4447</span></p></span></p><p><span style="font-size: 10pt;"><p>remote.connection.two.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=<span style="color: #2a00ff; font-size: 10pt;">false</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="color: #2a00ff;">aut.conf:</span></p><p><span style="color: #2a00ff;">======</span></p><p><span style="font-size: 10pt;"><p align="left"><p><span style="text-decoration: underline;"><span style="font-size: 10pt; text-decoration: underline;"><span style="text-decoration: underline;"><p align="left">logincontextname</p></span></span></span> {</p></p><p align="left">org.jboss.security.ClientLoginModule required</p><p align="left">;</p><p>};</p></span></p></span></p></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/718417#718417">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>