Handling User Login with JSP

When you integrate ManualWorks with an in-house authentication system, such as a commercial SSO (Single Sign-On) solution, you can handle user login with JSP. The in-house authentication system verifies the login, and then a JSP page logs the user in to ManualWorks.

We do not recommend handling user login this way. If possible, use OAuth. Two-factor authentication does not apply to users who log in this way.

Allowing JSP Requests

To allow requests to the directory where the JSP pages are, set the following in the Setting Startup Script Options.

3rabbitz.bypass_patterns=/jsp

With this setting, JSP pages under the 3RABBITZ_HOME/web/jsp directory can be requested. The value is compared with the beginning of the request path, so it must start with /. Any path that begins with the value is allowed, so /jsp also allows other paths that start with /jsp. You can set multiple paths separated by commas (,).

Implementing and Copying the JSP Called for Login

Specify the JSP to call when login is required in the startup script options as follows.

3rabbitz.custom_authenticator=/jsp/login.jsp

The JSP must be in the directory you allowed above.

Handling the Login

Implement the login in the JSP to fit your environment. If you need external libraries, copy them to the following location.

3RABBITZ_HOME/web/WEB-INF/lib

When the login succeeds, you must call the Users.login method.

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ page import="com.threerabbitz.base.domain.Users" %>

<%
    // Implement the login logic

    if (!Users.isExist("user01")) {
        // Create the user if the user does not exist
    }
    Users.login(request, "user01");
    response.sendRedirect((String) session.getAttribute("path"));
%>

6Implement the login logic.

8Check whether the user exists in ManualWorks with the Users.isExist method.

11The first parameter of the Users.login method is the HttpServletRequest, and the second is the username.

12Redirect to the page after login with the path attribute in the HttpSession.