[java] createSession(host, tokenString) doesn't work

Hi all,

We are trying to use the:

NotesFactory.createSession(host, stringToken)

method. But this does not seem to work.

I have created a simple test servlet which describes my problem probably best.

The problem is that no matter what I do, I keep getting the error:

Cookie is invalid.

My testing servlet is behind a Lotus Notes login-screen. So I use Notes authentication.

I don’t know what to do. Can somebody please help? Below I have posted the full code listing of my ‘testing-servlet’.

==============================================

package nl.informatiefabriek.tokentest;

import java.io.IOException;

import javax.servlet.ServletConfig;

import javax.servlet.ServletException;

import javax.servlet.http.Cookie;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import lotus.domino.NotesException;

import lotus.domino.NotesFactory;

import lotus.domino.Session;

/**

  • Simple test servlet to test notes login, using the

  • NotesFactory.createSession(host, tokenString) method.

*/

public class TokenTestServlet extends HttpServlet {

private ServletConfig config;



/**

 * Get's called when the servlet is loaded. We just save the

 * intialisation configuration.

 */

public void init(ServletConfig config) throws ServletException {

	this.config = config;

}



/**

 * Get's called by Servlet container when user makes a request.

 */

public void doGet(HttpServletRequest request,

				   HttpServletResponse response)

	throws ServletException, IOException

{

	Cookie[] cookies = request.getCookies();

	String id = null;

	for (int i=0 ; i<cookies.length; i++) {

		String name = cookies[i].getName();

		if (name.equals("DomAuthSessId")) {

			id = cookies[i].getValue();

		}

	}

	

	Session s = null;

	try {

		s = NotesFactory.createSession("aphrodite:60148", id);

		System.out.println("Platform: " + s.getPlatform());

		System.out.println("Username: " + s.getUserName());

	} catch (NotesException e) {

		System.out.println("Exception occured: " + e.text);

	} finally {

		try {

			s.recycle();

		} catch (Exception e) {}

	}

}

}

==============================================

Many Thanks, Cheers,

Harm de Laat

Informatiefabriek

The Netherlands

Subject: need to enable Single Sign-on, and use LtpaToken

NotesFactory.createSession does not handle a DomAuthSessId cookie. But, it can handle the LtpaToken cookie, which means that Multi-Server authentication needs to be enabled.

Also, with ND6 you don’t need to go through the cookies to find the ‘one’, you can use the HttpServletRequest object directly. For example:

public void doGet(HttpServletRequest request,

				   HttpServletResponse response)

	throws ServletException, IOException

{

	Session s = null;

	try {

		s = NotesFactory.createSession("aphrodite:60148", request);

		System.out.println("Platform: " + s.getPlatform());

		System.out.println("Username: " + s.getUserName());

	} catch (NotesException e) {

		System.out.println("Exception occured: " + e.text);

	} finally {

		try {

			s.recycle();

		} catch (Exception e) {}

	}

}

Btw, an article was recently put together that provides more of this information and I understand that it will be posted on LDD soon.

Subject: RE: need to enable Single Sign-on, and use LtpaToken

Thanks Steve for your quick response.

My example was a simple test. But in real life we are using two servers: Domino 6 and Tomcat 4.1.x.

We would like to use the authentication on Domino 6, but redirect the user to our Tomcat server.

In the Tomcat webapp we check if the Domino session is still valid. Therefore we would like to use the Domino Java Api to check if the session is still there.

If the (Domino) session is timed-out then we also have to invalidate the Tomcat session.

(This is because the user could click a link which goes back to the Domino server).

So I think I cannot use the response object directly. And I have to use the LtpaToken instead…

Maybe you guys have any suggestions?