The moose likes EJB and other Java EE Technologies and the fly likes Websphere Programmatic Login Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Websphere Programmatic Login " Watch "Websphere Programmatic Login " New topic

Websphere Programmatic Login

Dermot Bolger

Joined: Oct 23, 2002
Posts: 1
Does anybody know if websphere programattic login using the actually works!
I've secured a jsp and a bean.
I use a nonsecured servlet to access the secured bean
supplying the necessary userid and password to the ServerSideAuthenticator
to gain access to the secured bean.
This works fine, however if I try access a secured servlet in the same manner
ie. check authentication against the ServerSideAuthenticator and forward to the
secured servlet I keep getting the popup login screen on the browser.
Is the ServerSideAuthenticator supposed to be used for accessing secured web pages?
Please see code attached
public void doGet(
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException, {
try {
boolean forceAuthentication = true;
String userid = request.getParameter("userid");
String password = request.getParamete("password");
// Create a new security context to hold
// authentication data.
ServerSideAuthenticator serverAuth = new ServerSideAuthenticator();
// Perform authentication based on supplied data org.omg.SecurityLevel2.Credentials credentials = serverAuth.login(userid, password, forceAuthentication);
// Retrieve the user's name from the credentials
// so we can tell the user that login succeeded.
String username = serverAuth.getUserName(credentials);
System.out.println( "Authentication successful for user: " + username
// Access secure bean
P1BeanHome p1beanHome = null;
P1Bean p1bean = null;
InitialContext initCtx = new InitialContext();
Object objref = initCtx.lookup("ejb/ie/iss/test/P1BeanHome");
p1beanHome = (P1BeanHome) PortableRemoteObject.narrow(objref, P1BeanHome.class);
System.out.println("in nonsecureservlet3 doget method got home");
p1bean = p1beanHome.create();
// works fine up to here
getServletContext().getRequestDispatcher(response.encodeURL("Secure1.jsp")).forward(request, response);
//fails to do forward
} catch (Exception e) {
System.out.println("in nonsecureservlet3 doget method error is " + e);
It is sorta covered in the JavaRanch Style Guide.
subject: Websphere Programmatic Login