AnsweredAssumed Answered

How to redirect user to our own jsp if he is not authorized?

Question asked by dynamolalit on Jan 23, 2010

I am using alfresco 3.1.1 with JBoss 4.2.3 GA.Our front end is Liferay.We are using CAS(ECAS) for authentication.I am running around one scenario with details below:

On Liferay portal, there is a link to Alfresco WCM explorer.For propagating from liferay to alfresco, user has to be there in ECAS & Liferay & atlast in alfresco and should have role to see the alfresco link on top banner.Now thing is that when there is a user which exists in LIferay & ECAS, but not in alfresco but user has role to get alfresco link on liferay, if he clicks on that link, he should be redirected to a customized error page saying you either do not exist or do not have appropriate permissions for this operation but currently i can see nice error dump from alfresco.I tried these three ways:

1. Extending LoginBean & customizing login() method but i am getting javax.faces.el.PropertyNotFoundException: Base is null :CustomisedLoginBean & something-2.
2. I tried to call authentication service in login.jsp or tried to set it in index.jsp & get it in login.jsp but no success as its saying no secured context exists.
3. I get person & node services in login.jsp but as i can not get user name here before login so its of no use.Just check my code here which i have put in login.jsp:

PersonService personService = (PersonService)ctx.getBean("personService");
      System.out.println("Person Service # 1 "+personService);
      NodeService nodeService = (NodeService)ctx.getBean("nodeService");
      System.out.println("Node Service # 1 "+nodeService);
      LoginBean loginBean = (LoginBean)FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "LoginBean");
      String userName  = loginBean.getUsername() ;
      System.out.println("userName in login.jsp "+userName);
      String userName2 = (String)session.getAttribute("username");
      System.out.println("userName in login.jsp from session  2  "+userName2);
      String userName3 = (String)session.getAttribute("userName");
      System.out.println("userName in login.jsp from session  3  "+userName3);
      boolean existence = personService.personExists(userName) ;
      System.out.println("existence  "+existence);
      if(existence == false){
      System.out.println("userName does not exist so redirecting to error page ");
      response.sendRedirect(request.getContextPath() +"/faces/jsp/extension/ejustice/nousererror.jsp");

Is there any way i can achieve this? :?: