-1
@Factory("loginContext")
@Begin(join = true)
public LoginContext initLoginContext() {
    if (loginContext == null) {
      loginContext = new LoginContext();
    }
    loginContext.setLanguageCode(LocaleSelector.instance().getLanguage());
    checkEnvironment();
    Map<String,String> requestParams = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
    String prodCode=requestParams.get("prodCode");
    String token=requestParams.get("token");
    //token validation
    if (token.equals("admin")) {
        System.out.println("admin page");
    } else if (token.equals("user")) {
        System.out.println("user page");
    } else {
        return loginContext;
    }
}

here i will be getting user credentials in token(JWE string) and then some validation of on user is done(till here code is fine and i am clear how to do this). later on on the basis of user privilege, i will navigate directly to related page for user(instead of loading the login page related to controller)

I am stuck here, Pls suggest something

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Pratap
  • 1
  • 3
  • Couple of things: 1: narrow down your problem and adapt the question and title accordingly. If you can read query params but not redirect, it is not query param related (using a random pick from a static list would result in the same problem) if you cannot read the query param, it is not 'navigation related. 2: Can you please use better indentation in your code? 3: [mcve], the factory, begin etc are not things we all have so exclude them being part of the problem – Kukeltje Aug 05 '19 at 11:50
  • I have updated the question, hope its fine for you – Pratap Aug 05 '19 at 12:03
  • No, it is not better actually. The java tag is off (see the comment on my edit) and for the rest there is no improvement besides the 'seam2' tag being added (whatever part is seam related (the `@Begin` is?). Most of the parts of my comment are not addressed and hence it is next to impossible to help – Kukeltje Aug 05 '19 at 12:06
  • by mistake java tag was removed. loginContext is for associating user and some other details to get token validation done. I am new to stackoverflow in terms of asking question. – Pratap Aug 05 '19 at 12:16
  • Sorry, No, I on purpose removed the java tag... Someone with only java knowledge cannot answer this question. It is a pure jsf (maybe not even seam related). You cannot download a jdk without anything and recreate the problem.... I gave you several hints in the first comment. Please try them. Cheers! – Kukeltje Aug 05 '19 at 12:19

1 Answers1

0

in the LoginController i added following code which worked for me.:

@Factory("loginContext")
@Begin(join = true)
public LoginContext initLoginContext() {
if (loginContext == null) {
  loginContext = new LoginContext();
}
loginContext.setLanguageCode(LocaleSelector.instance().getLanguage());    
Map<String,String> requestParams = 
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String prodCode=requestParams.get("prodCode");
String token=requestParams.get("token");
//token validation
loginContext.setToken(token);
loginContext.setProductCode(prodCode);
return loginContext; 
 }
@Factory(value = "redirectWelcome", autoCreate = true, scope = ScopeType.EVENT)
  public boolean isRedirectWelcome()
{
boolean welRet=false;
if(loginContext.isLoggedIn()==false)
{

String loginReturn=login();// login is customized method as per my requirement
if(loginReturn.equals("loggedIn"))
{
  FacesContext.getCurrentInstance().getApplication().getNavigationHandler().handleNavigation(FacesContext.getCurrentInstance(),
      null, "/myservice/auth/showWelcome/welcome.jspx?faces-redirect=true");

  loginContext.setLoggedIn(true);
  welRet=true;
}}
return welRet;

}

then In JSP page(login.jspx) i added following in the body.

<h:outputText value="Login  bypass..." rendered="#{loginController.redirectWelcome}" />
Pratap
  • 1
  • 3