Changeset 30112

Show
Ignore:
Timestamp:
02/12/08 23:12:11 (9 months ago)
Author:
atchertchian
Message:

NXP-2064: make method saveRequestURLBeforeRedirect public and make it return a boolean if target url is valid, for easier reuse in sso plugin (fwd from r30111)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-ui-web/src/main/java/org/nuxeo/ecm/platform/ui/web/auth/NuxeoAuthenticationFilter.java

    r30021 r30112  
    9191    protected List<String> unAuthenticatedURLPrefix; 
    9292 
    93     protected List<String> validStartURLs; 
    94  
     93    protected static List<String> validStartURLs; 
    9594 
    9695    public void destroy() { 
     
    9897    } 
    9998 
    100     protected static DocumentMessageProducer getMessageProducer() throws Exception { 
     99    protected static DocumentMessageProducer getMessageProducer() 
     100            throws Exception { 
    101101        return Framework.getService(DocumentMessageProducer.class); 
    102102    } 
    103103 
    104     protected static Boolean sendAuthenticationEvent(UserIdentificationInfo userInfo, 
    105             String eventId, String comment) { 
     104    protected static Boolean sendAuthenticationEvent( 
     105            UserIdentificationInfo userInfo, String eventId, String comment) { 
    106106        SystemSession ss = new SystemSession(); 
    107107        // login 
     
    234234    } 
    235235 
    236     private Boolean switchUser(ServletRequest request, ServletResponse response, 
    237             FilterChain chain) throws IOException, ServletException 
    238    
     236    private Boolean switchUser(ServletRequest request, 
     237            ServletResponse response, FilterChain chain) throws IOException, 
     238            ServletException
    239239        HttpServletRequest httpRequest = (HttpServletRequest) request; 
    240240 
     
    249249            cachableUserIdent.getLoginContext().logout(); 
    250250        } catch (LoginException e1) { 
    251             log.error("Error while logout from main identity :" + e1.getMessage()); 
     251            log.error("Error while logout from main identity :" 
     252                    + e1.getMessage()); 
    252253        } 
    253254 
     
    258259        if (session != null) { 
    259260            Manager.instance().endConversation(true); 
    260             Manager.instance().endRequest( ContextAdaptor.getSession(session)  ); 
     261            Manager.instance().endRequest(ContextAdaptor.getSession(session)); 
    261262            Lifecycle.endRequest(session); 
    262263            Lifecycle.setServletRequest(null); 
     
    264265 
    265266            session = httpRequest.getSession(false); 
    266             if (session!=null) 
    267             { 
     267            if (session != null) { 
    268268                session.invalidate(); 
    269269            } 
     
    272272        session = httpRequest.getSession(true); 
    273273 
    274         CachableUserIdentificationInfo newCachableUserIdent = new CachableUserIdentificationInfo(deputy_login,deputy_login); 
     274        CachableUserIdentificationInfo newCachableUserIdent = new CachableUserIdentificationInfo( 
     275                deputyLogin, deputyLogin); 
    275276 
    276277        newCachableUserIdent.getUserInfo().setLoginPluginName("Trusting_LM"); 
    277         newCachableUserIdent.getUserInfo().setAuthPluginName(cachableUserIdent.getUserInfo().getAuthPluginName()); 
     278        newCachableUserIdent.getUserInfo().setAuthPluginName( 
     279                cachableUserIdent.getUserInfo().getAuthPluginName()); 
    278280 
    279281        Principal principal = doAuthenticate(newCachableUserIdent, httpRequest); 
     
    286288 
    287289        // reinit Seam so the afterResponseComplete does not crash 
    288         Lifecycle.beginRequest(session.getServletContext(), session, httpRequest); 
     290        Lifecycle.beginRequest(session.getServletContext(), session, 
     291                httpRequest); 
    289292 
    290293        // flag redirect to not be catched by URLPolicy 
    291         request.setAttribute(URLPolicyService.DISABLE_REDIRECT_REQUEST_KEY,true); 
     294        request.setAttribute(URLPolicyService.DISABLE_REDIRECT_REQUEST_KEY, 
     295                true); 
    292296        String baseURL = BaseURL.getBaseURL(request); 
    293         ((HttpServletResponse) response).sendRedirect(baseURL + DEFAULT_START_PAGE); 
     297        ((HttpServletResponse) response).sendRedirect(baseURL 
     298                + DEFAULT_START_PAGE); 
    294299 
    295300        return true; 
     
    440445        HttpSession session = httpRequest.getSession(false); 
    441446        if (session != null) { 
    442             CachableUserIdentificationInfo cachableUserInfo 
    443                     = (CachableUserIdentificationInfo) session.getAttribute(NXAuthContants.USERIDENT_KEY); 
     447            CachableUserIdentificationInfo cachableUserInfo = (CachableUserIdentificationInfo) session.getAttribute(NXAuthContants.USERIDENT_KEY); 
    444448            if (cachableUserInfo != null) { 
    445449                return cachableUserInfo; 
     
    473477    } 
    474478 
    475     protected void saveRequestedURLBeforeRedirect( 
     479    /** 
     480     * Save requested URL before redirecting to login form. 
     481     * 
     482     * Returns true if target url is a valid startup page. 
     483     */ 
     484    public static boolean saveRequestedURLBeforeRedirect( 
    476485            HttpServletRequest httpRequest, HttpServletResponse httpResponse) { 
    477486 
     
    484493 
    485494        if (session == null) { 
    486             return
     495            return false
    487496        } 
    488497 
     
    501510        // avoid redirect if not usefull 
    502511        if (requestPage.equals(DEFAULT_START_PAGE)) { 
    503             return
     512            return true
    504513        } 
    505514 
    506515        if (isStartPageValid(requestPage)) { 
    507516            session.setAttribute(START_PAGE_SAVE_KEY, requestPage); 
    508         } 
     517            return true; 
     518        } 
     519 
     520        return false; 
    509521    } 
    510522 
     
    525537    } 
    526538 
    527     protected Boolean isStartPageValid(String startPage) { 
     539    protected static Boolean isStartPageValid(String startPage) { 
    528540        for (String prefix : validStartURLs) { 
    529541            if (startPage.startsWith(prefix)) {