I am still vaving big problems with loging in to a remote jboss-server from my client. After debuging as far as I could. I could see the correct username and password was transmitted to jboss.
I am using the org.jboss.security.auth.spi.UsersRolesLoginModule on jboss-side (I set <security-domain>java:/jaas/helloworld</security-domain>) and my login-config.xml contains this part:
<application-policy name="helloworld">
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
<module-option name="unauthenticatedIdentity">guest</module-option>
</login-module>
</authentication>
</application-policy>
I also created roles.properties: testUser=everyone,Administrator guest=everyone
And user.properties: testUser=testPassword
This is the Client-Side Code I am using:
package de.test.client;
import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import javax.security.auth.login.LoginContext; import org.jboss.security.auth.callback.UsernamePasswordHandler; import java.net.MalformedURLException; import java.net.URL;
import de.test.security.ejb.userManagerSes.UserManagerSesHome; import de.test.security.ejb.userManagerSes.UserManagerSesRemote;
public class TestClient {
private static String authConfig = "jaas.conf"; public static void setAuthConfig(String authConfURL)
throws MalformedURLException {
// Set the JAAS login config file if not already set
ClassLoader loader = Thread.currentThread().getContextClassLoader();
URL loginConfig = loader.getResource(authConfURL);
if (loginConfig != null) {
System.setProperty(
"java.security.auth.login.config",
loginConfig.toExternalForm());
} else {
}
}public static void main(String[] args) {
try {
Context ctx = null;
Properties p = new Properties();
setAuthConfig(authConfig);
System.out.println("Auth-Config set ...");
p.put(Context.PROVIDER_URL, "localhost:1099");
p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.security.jndi.LoginInitialContextFactory");
p.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
p.put(Context.SECURITY_PROTOCOL, "remoteClientLogin");
p.put(Context.SECURITY_PRINCIPAL, "testUser");
p.put(Context.SECURITY_CREDENTIALS, "testPassword");
ctx = new InitialContext(p);
System.out.println("InitialContext created ...");
UsernamePasswordHandler handler = new UsernamePasswordHandler("testUser", "testPassword".toCharArray());
LoginContext lc = new LoginContext("remoteClientLogin", handler);
lc.login();
System.out.println("Logged in to JBoss server ...");
Object objRef = ctx.lookup("ejb/security/UserManagerSes");
UserManagerSesHome managerHome = (UserManagerSesHome) javax.rmi.PortableRemoteObject.narrow(objRef, UserManagerSesHome.class);
System.out.println("Retrieved UserManagerSesRemote ...");
UserManagerSesRemote manager = managerHome.create();
System.out.println("New user created ...");
lc.logout();
} catch (Exception e) {
e.printStackTrace();
}
}
}Everything goes fine until the create-method is called ... I don't have any more ideas fo what to check.
Yes, I did read the article from JavaWorld, but it is some kind of out of date on some parts.Especialy the ones of how
everything is configured on jboss side.
Here is the Exception I got:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: EJBException:; nested exception is:
javax.ejb.EJBException: checkSecurityAssociation; CausedByException is:
Authentication exception, principal=testUser
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:536)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy0.create(Unknown Source)
at de.cware.cweb.client.TestClient.main(TestClient.java:68)
Caused by: java.rmi.ServerException: EJBException:; nested exception is:
javax.ejb.EJBException: checkSecurityAssociation; CausedByException is:
Authentication exception, principal=testUser
at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:347)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:124)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
at org.jboss.ejb.StatelessSessionContainer.internalInvokeHome(StatelessSessionContainer.java:311)
at org.jboss.ejb.Container.invoke(Container.java:699)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:359)
at sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:536)
Caused by: javax.ejb.EJBException: checkSecurityAssociation; CausedByException is:
Authentication exception, principal=testUser
at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(SecurityInterceptor.java:163)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:81)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
... 20 more
Plese help me Chris
------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
