class DefaultSecurityManager implements SecurityManager {

    @Override
    public boolean authenticate(
            HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {

        boolean result = false;

        if (request.getAuthType() != null) {
            if (request.getAuthType().equals(HttpServletRequest.BASIC_AUTH)) {
                throw new ServletException("Basic auth is not supported");
            }

            if (request.getAuthType().equals(HttpServletRequest.CLIENT_CERT_AUTH)) {
                throw new ServletException("Client cert auth is not supported");
            }

            if (request.getAuthType().equals(HttpServletRequest.DIGEST_AUTH)) {
                throw new ServletException("Digest auth is not supported");
            }

            if (request.getAuthType().equals(HttpServletRequest.FORM_AUTH)) {
                String username = request.getParameter("j_username");
                String password = request.getParameter("j_password");
                login(request, username, password);
                if (request.getUserPrincipal() != null) {
                    result = true;
                }
            }
        }

        return result;
    }

}