Access page in another project

Asked

Viewed 64 times

0

I am one developing a system that is divided into three modules (Distinct projects), using JSF Framework (Java Server Faces).

I have a main module that has a login screen, which in turn has an access control via filter. The idea is that when the user logs in and accesses the home page, then he can call other pages that are in other modules.

I did not succeed when requesting a page in another project, I am having problems mainly with Filter.

I wonder if someone could give me some idea of how to access another page of another project?

Follow my filter code below:

@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) req;
    HttpServletResponse response = (HttpServletResponse) resp;
    HttpSession session = request.getSession();

    String loginURI = request.getContextPath() + "/RESOURCES/paginas/login.xhtml";

    boolean loggedIn = session != null && session.getAttribute("user") != null;
    boolean loginRequest = request.getRequestURI().equals(loginURI);
    boolean resourceRequest = request.getRequestURI()
            .startsWith(request.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER);

    boolean resourceRequestCSS = request.getRequestURI().contains("/RESOURCES/css");
    boolean resourceRequestIcons = request.getRequestURI().contains("/RESOURCES/icons");
    boolean resourceRequestImages = request.getRequestURI().contains("/RESOURCES/images");

    if (loggedIn || loginRequest || resourceRequest || resourceRequestCSS || resourceRequestIcons
            || resourceRequestImages) {
        chain.doFilter(request, response);

    } else {
        response.sendRedirect(loginURI);
    }
}

1 answer

0

You could generate a token (saved in shared database - or other form of intercom) in the application caller and send it (token) on request to the application called, that in turn through the filter will check in the shared bank and authorize or not access to the application called.

I hope I’ve helped...

  • I removed the Filter and I was able to see the pages in the other projects, but it was just a test. I really need the filter, remembering that the filter only sees the project in which it is located. I didn’t rule out your idea, because when I got something I commented here. Thanks for now

Browser other questions tagged

You are not signed in. Login or sign up in order to post.