Search in sources :

Example 1 with UserSession

use of de.metas.ui.web.session.UserSession in project metasfresh-webui-api by metasfresh.

the class ServletLoggingFilter method extractLoggedUser.

private static final String extractLoggedUser(final HttpServletRequest httpRequest) {
    try {
        final UserSession userSession = UserSession.getCurrentOrNull();
        if (userSession == null) {
            return "_noSession";
        }
        final String userName = userSession.getUserName();
        if (!userSession.isLoggedIn()) {
            if (userName == null || userName.isEmpty()) {
                return "_notLoggedIn";
            } else {
                return "_notLoggedInBut_" + userName;
            }
        } else if (userName == null || userName.isEmpty()) {
            return "_unknown";
        } else {
            return userName;
        }
    } catch (final Exception e) {
        e.printStackTrace();
        return "_error";
    }
}
Also used : UserSession(de.metas.ui.web.session.UserSession) ServletException(javax.servlet.ServletException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Aggregations

UserSession (de.metas.ui.web.session.UserSession)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ServletException (javax.servlet.ServletException)1