Try this: | | import org.jboss.security.SecurityAssociation; | import org.jboss.security.SimplePrincipal; | import javax.naming.InitialContext; | import javax.naming.Context; | import java.util.Properties; | | .... | Properties properties = new Properties(); | properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory"); | properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); | properties.put(Context.PROVIDER_URL, "http://192.168.0.17:8080/invoker/JNDIFactory"); | | SecurityAssociation.setCredential(password); | SecurityAssociation.setPrincipal(new SimplePrincipal(user)); | | InitialContext ctx = new InitialContext(properties); |
put jbossall-client.jar in classpath config/login-config.xml | <application-policy name = "http-invoker"> | <authentication> | <login-module code = "org.jboss.security.ClientLoginModule" | flag = "required"> | </login-module> | <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule" | flag = "required"> | <module-option name = "unauthenticatedIdentity">guest</module-option> | <module-option name = "dsJndiName">java:/MySQL-DS</module-option> | <module-option name = "principalsQuery">SELECT passwd FROM jms_users WHERE name=?</module-option> | <module-option name = "rolesQuery">SELECT jms_roles.name, 'Roles' FROM users_roles LEFT JOIN jms_roles, jms_users ON jms_roles.id = users_roles | .id_role AND jms_users.id = users_roles.id_user WHERE jms_users.name=?</module-option> | </login-module> | </authentication> | </application-policy> | deploy/http-invoker.sar/invoker.war/WEB-INF/web.xml | <security-constraint> | <web-resource-collection> | <web-resource-name>HttpInvokers</web-resource-name> | <description>An example security config that only allows users with the | role HttpInvoker to access the HTTP invoker servlets | </description> | <url-pattern>/*</url-pattern> | <http-method>GET</http-method> | <http-method>POST</http-method> | </web-resource-collection> | <auth-constraint> | <role-name>topic-manager</role-name> | </auth-constraint> | </security-constraint> | <login-config> | <auth-method>BASIC</auth-method> | <realm-name>JBoss HTTP Invoker</realm-name> | </login-config> | | <security-role> | <role-name>topic-manager</role-name> | </security-role> | deploy/http-invoker.sar/invoker.war/WEB-INF/jboss-web.xml | <jboss-web> | <security-domain>java:/jaas/http-invoker</security-domain> | </jboss-web> | the thing is that org.jboss.naming.HttpNamingContextFactory uses "org.jboss.invocation.http.interfaces.Util" which sets "java.net.Authenticator.setDefault()" with "org.jboss.invocation.http.interfaces.Util$SetAuthenticator" which uses "org.jboss.security.SecurityAssociationAuthenticator" that needs "org.jboss.security.SecurityAssociation" that holds Credential and Pricipal object But you might have some problems with SSL. p.s. I took me 2 days to come up with thise lines (I guess I have IQ problem :-) View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3848772#3848772 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3848772 ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
