3
votes

I am attempting to implement the Redirect to XPages Login Snippet by Paul Withers in my XPages application.

https://openntf.org/XSnippets.nsf/snippet.xsp?id=redirect-to-xpages-login-page

His code is making use of the OpenNTF Domino API which I unfortunately cannot use on production servers due to company polices. Therefore I am trying to replace line 89 using lotus.domino API.

Line 89:

if (!Factory.getSession().getEffectiveUserName().equalsIgnoreCase("anonymous")) {

Creating a session using lotus.domino API requires credentials so how would I go about checking if the user is anonymous without using the OpenNTF Domino API?

1

1 Answers

3
votes

Take a look at JSFUtil used in several XPages project. With JSFUtil you can easily find the effective user name like this:

JSFUtil.getSession().getEffectiveUserName();

The following helper methods from JSFUtil are used for this:

public static Session getSession() {
    return (Session) resolveVariable("session");
}

public static Object resolveVariable(String variable) {
    return FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(FacesContext.getCurrentInstance(), variable);
}

Update: As Paul Withers points out, you can use ExtLibUtil from the XPages Extension Library for this too (with no need to use JSFUtil):

ExtLibUtil.getCurrentSession().getEffectiveUserName();