I have used the following code and
tested the login sequenz with an externel ejbclient, the jaas settings
are correct
What i have doing wrong, is this constract legal to the JBoss
architektur ?
package MBeanServiceAndJaas;
import org.jboss.system.ServiceMBean;
public interface ServiceAdaptorMBean extends ServiceMBean{
public void setPort(int port);
public int getPort();
}
package MBeanServiceAndJaas;
import javax.naming.InitialContext;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import org.jboss.security.auth.callback.UsernamePasswordHandler;
import org.jboss.system.ServiceMBeanSupport;
import java.net.*;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.BufferedReader;
public class ServiceAdaptor extends ServiceMBeanSupport implements
ServiceAdaptorMBean, Runnable {
private boolean stopped = false;
private int Status = 0;
private int port = 9050;
private ServerSocket ss = null;
private BufferedReader socket_in = null;
private PrintWriter socket_out = null;
public ServiceAdaptor() {
}
public void run() {
try {
System.out.println("open socket at port " + port);
ss = new ServerSocket(port);
while (!stopped) {
Socket client = ss.accept();
System.out.println("client accepted");
this.socket_in = new BufferedReader(new
InputStreamReader(client
.getInputStream()));
String username = socket_in.readLine();
System.out.println(username);
String password = socket_in.readLine();
System.out.println(password);
System.setProperty("java.security.auth.login.config",
"d:/jboss-3.2.4/client/auth.conf");
UsernamePasswordHandler handler = new
UsernamePasswordHandler(username,
password.toCharArray());
// static password
//UsernamePasswordHandler handler = new
UsernamePasswordHandler("username",
// "password".toCharArray());
LoginContext lc = new LoginContext("ServiceSecurity",
handler);
try
{
lc.login();
System.out.println("login successfull");
}
catch(LoginException le)
{
System.out.println("login failed");
le.printStackTrace();
}
// call ejb method
InitialContext ctx = new InitialContext();
Object ref = ctx.lookup("Echo");
EchoHome home = (EchoHome) ref;
Echo echo = home.create();
System.out.println("echo created");
echo.echo();
this.socket_out = new
PrintWriter(client.getOutputStream());
socket_out.println("ok");
socket_out.flush();
socket_in.close();
socket_out.close();
client.close();
System.out.println("client end");
}
ss.close();
} catch (Exception e) {
e.printStackTrace();
stopped = true;
}
}
protected void startService() throws Exception
{
System.out.println("Service started");
Thread thread = new Thread(this);
thread.start();
stopped = false;
}
public void stopService() {
System.out.println("Service stopped");
stopped = true;
}
public void setPort(int port) {
this.port = port;
}
public int getPort() {
return port;
}
}
then i connect to the service via an socket client and transmit the
username and the password i get the following errors
from the service :
12:35:25,806 INFO [STDOUT] client accepted
12:35:25,822 INFO [STDOUT] username
12:35:25,822 INFO [STDOUT] password
12:35:25,822 INFO [STDOUT] login failed
12:35:25,822 INFO [STDOUT] javax.security.auth.login.FailedLoginException: Pass
word Incorrect/Password Required
12:35:25,837 INFO [STDOUT] at org.jboss.security.auth.spi.UsernamePasswordL
oginModule.login(UsernamePasswordLoginModule.java:160)
12:35:25,837 INFO [STDOUT] at org.jboss.security.auth.spi.UsersRolesLoginMo
dule.login(UsersRolesLoginModule.java:116)
12:35:25,837 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(
Native Method)
12:35:25,837 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(N
and from the security interceptor :
12:35:25,806 INFO [STDOUT] client accepted
12:35:25,822 INFO [STDOUT] username
12:35:25,822 INFO [STDOUT] password
12:35:25,822 INFO [STDOUT] login failed
12:35:25,822 INFO [STDOUT] javax.security.auth.login.FailedLoginException: Pass
word Incorrect/Password Required
12:35:25,837 INFO [STDOUT] at org.jboss.security.auth.spi.UsernamePasswordL
oginModule.login(UsernamePasswordLoginModule.java:160)
12:35:25,837 INFO [STDOUT] at org.jboss.security.auth.spi.UsersRolesLoginMo
dule.login(UsersRolesLoginModule.java:116)
12:35:25,837 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(
Native Method)
12:35:25,837 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(N
please contact me if every one have a solution for this problem
cu
Stephan
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3849711#3849711
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3849711
-------------------------------------------------------
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