This content has been marked as final.
Show 2 replies
-
-
2. Re: JAAS in JBoss 7
ybxiang.china Dec 9, 2013 8:41 PM (in response to heldwein)How to login in rich client:
(a) ISecuredRemoteSession is an EJB interface.
private ISecuredRemoteSession securedRemoteSessionProxy; (b) look for the EJB proxy by JNDI:
public void connectToServer(String serverIP, String username, String password) throws Exception{ this.username = username; this.serverIP = serverIP; InitialContext context; try{ Properties p = new Properties(); p.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "true"); p.put("remote.connections", "default"); p.put("remote.connection.default.host", serverIP); p.put("remote.connection.default.port", "4447"); p.put("remote.connection.default.username", username); p.put("remote.connection.default.password", password); p.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false"); p.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER"); p.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false"); p.put("remote.connection.default.connect.options.org.xnio.Options.SSL_STARTTLS", "true"); p.put("remote.connection.default.connect.timeout", "30000");//for xnio EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(p); ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc); EJBClientContext.setSelector(selector); //EJBClientContext.getCurrent().registerInterceptor(0,new ClientSessionTokenInterceptor()); //EJBClientContext.getCurrent().registerInterceptor(1,new ClientExceptionInterceptor()); Properties props = new Properties(); props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); context = new InitialContext(props); securedRemoteSessionProxy = (ISecuredRemoteSession)context.lookup(jndiName); }catch(Exception e){//TCP连接失败的异常不会被抛出! log.error("连接服务器失败:",e); throw ConnectionToServerFailedException.INSTANCE; } }