When using org.eclipse.equinox.http.registry.servlets servlet class request.getRemoteUser() (or request.getUserPrincipal().getName()) is correctly set (authentication is handled by Domino).
I set the Domino Session Factory like this:
When using com.ibm.pvc.webcontainer.application (slide 69 onward) servlet class request.getRemoteUser() isn't set unless it's taken care of. Whether I'm authenticated in Domino or not request.getRemoteUser() always returns null. At this point the above code will:
fail with:
Factory.setSessionFactory(new DasCurrentSessionFactory(req), SessionType.CURRENT);
because createSession will execute the else block (request is not null) but request_.getUserPrincipal() won't be set and it will cause a NullPointerException
succeed with:
Factory.setSessionFactory(new DasCurrentSessionFactory(null), SessionType.CURRENT);
because createSession will execute the first block (request is null)
My suggestion would be that of changing the code as follows:
public class DasCurrentSessionFactory extends AbstractXPageSessionFactory {
private static final long serialVersionUID = 1L;
private HttpServletRequest request_;
//this to be restored
public DasCurrentSessionFactory() {
super();
}
public DasCurrentSessionFactory(final HttpServletRequest request) {
super();
request_ = request;
}
/**
* returns the current Das-Session
*
* @throws
*/
@Override
public Session createSession() {
// I inverted the blocks for convenience
if (request_ != null && request_.getRemoteUser() != null) {
Session session = createSession(request_.getRemoteUser());
Factory.setCurrentToSession(session);
return session;
} else {
lotus.domino.Session rawSession = ContextInfo.getUserSession();
try {
lotus.domino.Database rawDb = rawSession.getCurrentDatabase();
if (rawDb != null) {
if (StringUtil.isEmpty(rawDb.getServer())) {
currentApiPath_ = rawDb.getFilePath();
} else {
currentApiPath_ = rawDb.getServer() + "!!" + rawDb.getFilePath();
}
}
} catch (NotesException e) {
DominoUtils.handleException(e);
}
return wrapSession(ContextInfo.getUserSession(), false);
}
}
When using
org.eclipse.equinox.http.registry.servlets
servlet classrequest.getRemoteUser()
(orrequest.getUserPrincipal().getName()
) is correctly set (authentication is handled by Domino). I set the Domino Session Factory like this:Factory.setSessionFactory(new DasCurrentSessionFactory(req), SessionType.CURRENT);
When
DasCurrentSessionFactory.createSession
code in the} else {
block is good and won't fail:When using
com.ibm.pvc.webcontainer.application
(slide 69 onward) servlet classrequest.getRemoteUser()
isn't set unless it's taken care of. Whether I'm authenticated in Domino or notrequest.getRemoteUser()
always returnsnull
. At this point the above code will:fail with:
Factory.setSessionFactory(new DasCurrentSessionFactory(req), SessionType.CURRENT);
because createSession will execute the else block (request is not null) butrequest_.getUserPrincipal()
won't be set and it will cause a NullPointerExceptionsucceed with:
Factory.setSessionFactory(new DasCurrentSessionFactory(null), SessionType.CURRENT);
because createSession will execute the first block (request is null)My suggestion would be that of changing the code as follows: