Programmatic navigation, reverse path generation

Splash Forums Rewrite Users Programmatic navigation, reverse path generation

This topic contains 2 replies, has 2 voices, and was last updated by  Marcin Kapusta 2 years, 12 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24502

    Marcin Kapusta
    Participant

    I try to implement my own Entry Point for Spring Security Filter. The Rewrite Filter is first and after it there is Spring Security Filter.

    I’m using Rewrite but I have problems with such think.
    I have viewId = /view/public/login.xhtml and in my configuration one of my rules is:

    .addRule(Join.path("/{language}/login").to("/view/public/login.xhtml"))

    Now I want using Rewrite Api to translate viewId to path by giving language parameter value. In spring security I have to extend LoginUrlAuthenticationEntryPoint and override this method:

    protected String determineUrlToUseForThisRequest(
    		HttpServletRequest request,
    		HttpServletResponse response,
    		AuthenticationException exception) {
    		
    	String lang = request.getParameter("language");
    	String loginViewId = "/view/public/login.xhtml";
    	// Here I have to invoke some API from rewrite
            // String path = RewriteAPI.xxx(loginViewId).with("language", lang);
            // if language is pl this shout return "/pl/login"
    	return path;
    }

    Can somebody help me with this API. There is no information in documentation about usage for such screnario.

    #24528

    Hi there! If I understand correctly, you want to build a URL using Rewrite? That is quite simple, actually! You can just use the native Servlet APIs:

    String rewrittenURL = response.encodeRedirectURL(loginViewId + "?language=" + lang);

    Rewrite will intercept this URL encoding request and provide the appropriate translation.

    Let me know if this works! Thanks,
    ~Lincoln

    #24562

    Marcin Kapusta
    Participant

    Works great.

    Thank You very much.


    Regards
    Marcin

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Comments are closed.