/** * Store the authentication information to the session. * * @param authInfo * @param user */ protected void storeToSession(final AuthInfo authInfo, final User user) { if (logger.isDebugEnabled()) { logger.debug("storing to session: " + authInfo); } ContextUtils.setSessionAttribute(AUTH_INFO_ATTRIBUTE, authInfo); ContextUtils.setSessionAttribute(USER_ATTRIBUTE, user); }
/** @return true if an exception have been detected. */ public boolean isException() { if (isPortletMode()) { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); PortletRequest request = (PortletRequest) externalContext.getRequest(); ContextUtils.bindRequestAndContext(request, (PortletContext) externalContext.getContext()); } return ExceptionUtils.getMarkedExceptionService() != null; }
/** * @param context * @param ex * @throws IOException * @throws ServletException */ public void handleException(final FacesContext context, final Exception ex) { // besoin d'exposer la requête pour y mettre dans la session le ExceptionService PortletRequest request = (PortletRequest) context.getExternalContext().getRequest(); ContextUtils.exposeRequest(request); ExceptionUtils.markExceptionCaught(); ExceptionService e = null; // try { e = ExceptionUtils.catchException(ex); // } catch (Throwable t) { // handleExceptionHandlingException(t); // // never reached, prevent from warnings // return; // } ExceptionUtils.markExceptionCaught(e); ContextUtils.unexposeRequest(request); NavigationHandler navigation = context.getApplication().getNavigationHandler(); // Redirection vers la page des erreurs navigation.handleNavigation(context, "", e.getExceptionView()); }
@Override public Map<String, List<String>> getHTTPHeaders(String url) { Map<String, List<String>> httpHeaders = null; Object httpHeadersObject = ContextUtils.getSessionAttribute(ESUP_HEADER_SHIB_HTTP_HEADERS); if (httpHeadersObject != null) { httpHeaders = (Map<String, List<String>>) httpHeadersObject; log.debug("httpHeaders :" + httpHeaders.toString()); } else { log.warn("httpHeaders will be null : we don't retrieve any userinfos attributes !"); } return httpHeaders; }
/** @see org.esupportail.pstage.services.authentication.Authenticator#getUser() */ public User getUser() { AuthInfo authInfo = (AuthInfo) ContextUtils.getSessionAttribute(AUTH_INFO_ATTRIBUTE); if (authInfo != null) { User user = (User) ContextUtils.getSessionAttribute(USER_ATTRIBUTE); if (logger.isDebugEnabled()) { logger.debug("found auth info in session: " + user); } return user; } if (logger.isDebugEnabled()) { logger.debug("no auth info found in session"); } authInfo = authenticationService.getAuthInfo(); if (authInfo == null) { return null; } if (AuthUtils.CAS.equals(authInfo.getType())) { User user = getDomainService().getUser(authInfo.getId()); storeToSession(authInfo, user); return user; } return null; }