Ganesh Saithala [
https://community.jboss.org/people/ganeshment] created the discussion
"Re: remote ejb client username is encrypted at the server(JBOSS7.1 CR1)"
To view the discussion, visit:
https://community.jboss.org/message/719410#719410
--------------------------------------------------------------
Thanks Daren for helping to fix this issue.
Iam posting below working EJB client API based test program.
package demo;
import java.io.IOException;
import java.net.URI;
import java.security.Security;
import java.util.concurrent.TimeUnit;
import javax.naming.NamingException;
import javax.security.auth.login.LoginException;
import org.jboss.ejb.client.ContextSelector;
import org.jboss.ejb.client.EJBClient;
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.ejb.client.EJBClientTransactionContext;
import org.jboss.ejb.client.StatelessEJBLocator;
import org.jboss.ejb.client.remoting.IoFutureHelper;
import org.jboss.remoting3.Connection;
import org.jboss.remoting3.Endpoint;
import org.jboss.remoting3.Remoting;
import org.jboss.remoting3.remote.RemoteConnectionProviderFactory;
import org.jboss.sasl.JBossSaslProvider;
import org.xnio.IoFuture;
import org.xnio.OptionMap;
import org.xnio.Options;
public class RemoteEJBClient {
  Â
   /**
    * User login name
    */
   private static final String USER_LOGIN_NAME = "admin";
   /**
    * User password
    */
   private static final String USER_PASSWORD = "admin";
  Â
   private static Connection connection;
   private static EJBClientContext ejbClientContext;
   private static Endpoint endpoint;
   static {
       Security.addProvider(new JBossSaslProvider());
   }
   public static void main(String[] args) throws Exception {
       endpoint = Remoting.createEndpoint("ejb-remote-client-endpoint",
OptionMap.EMPTY);
       endpoint.addConnectionProvider("remote", new
RemoteConnectionProviderFactory(),
                                      OptionMap.create(Options.SSL_ENABLED,
Boolean.FALSE, Options.SASL_SERVER_AUTH,
                                                       Boolean.FALSE));
      Â
       MyCallbackHandler callbackhndlr = new MyCallbackHandler(USER_LOGIN_NAME,
USER_PASSWORD);
        // open a connection
       final IoFuture<Connection> futureConnection = endpoint.connect(new
URI("remote://localhost:" + "4447"),
                                                                     Â
OptionMap.create(Options.SASL_POLICY_NOPLAINTEXT,
                                                                                      Â
Boolean.FALSE), callbackhndlr);
       connection = IoFutureHelper.get(futureConnection, 5, TimeUnit.SECONDS);
       ejbClientContext = EJBClientContext.create();
       ejbClientContext.registerConnection(connection);
       @SuppressWarnings("unused")
       final ContextSelector<EJBClientContext> previousSelector =
EJBClientContext.setConstantContext(ejbClientContext);
       // setting up something for transactions
       final EJBClientTransactionContext localUserTxContext =
EJBClientTransactionContext.createLocal();
       EJBClientTransactionContext.setGlobalContext(localUserTxContext);
      Â
       invokeStatelessBean();
       if (connection != null) {
           try {
               connection.close();
           } catch (IOException ioe) {
               System.out.println("Failed to close connection" + ioe);
           }
       }
       if (endpoint != null) {
           try {
               endpoint.close();
           } catch (IOException ioe) {
               System.out.println("Failed to close endpoint" + ioe);
           }
       }
   }
   private static void invokeStatelessBean() throws NamingException, LoginException {
       final SessionBeanInterface statelessSessionBeanInterface =
lookupRemoteStatelessCalculator();
       System.out.println("Obtained a remote stateless SessionBeanInterface for
invocation");
       try {
           System.out.println("EJB principal " +
statelessSessionBeanInterface.getPrincipal());
       } catch (RuntimeException e) {
           e.printStackTrace();
       }
   }
   private static SessionBeanInterface lookupRemoteStatelessCalculator() throws
NamingException, LoginException {
       final String appName = "TestEAR";
       final String moduleName = "TestEJB";
       final String distinctName = "";
       final String beanName = "SessionBean";
       final String viewClassName = SessionBeanInterface.class.getName();
       System.out.println("ejb:" + appName + "/" + moduleName +
"/" + distinctName + "/" + beanName + "!" + viewClassName);
       // create a locator depending on the type you are calling: StatelessEJBLocator,
EntityEJBLocator, StatefulEJBLocator &
       // create the proxy given the locator
       final StatelessEJBLocator<SessionBeanInterface> locator = new
StatelessEJBLocator<SessionBeanInterface>(
                                                                                                              Â
SessionBeanInterface.class,
                                                                                                              Â
appName,
                                                                                                              Â
moduleName,
                                                                                                              Â
beanName,
                                                                                                              Â
distinctName);
       SessionBeanInterface bean = EJBClient.createProxy(locator);
       return bean;
   }
}

--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/719410#719410]
Start a new discussion in JBoss AS 7 Development at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]