Exemplo n.º 1
0
 /**
  * Get the default phases at which restrictions should be applied, by looking for
  * a @RestrictAtPhase on a matching @ViewPattern, falling back on global defaults if none are
  * found
  *
  * @param viewId
  * @return default phases for a view
  */
 public PhaseIdType[] getDefaultPhases(String viewId) {
   PhaseIdType[] defaultPhases = null;
   RestrictAtPhase restrictAtPhase =
       viewConfigStore.getAnnotationData(viewId, RestrictAtPhase.class);
   if (restrictAtPhase != null) {
     defaultPhases = restrictAtPhase.value();
   }
   if (defaultPhases == null) {
     defaultPhases = RestrictAtPhaseDefault.DEFAULT_PHASES;
   }
   return defaultPhases;
 }
Exemplo n.º 2
0
 /**
  * Perform the navigation to the @LoginView. If not @LoginView is defined, return a 401 response.
  * The original view id requested by the user is stored in the session map, for use after a
  * successful login.
  *
  * @param context
  * @param viewRoot
  */
 private void redirectToLoginPage(FacesContext context, UIViewRoot viewRoot) {
   Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
   preLoginEvent.fire(new PreLoginEvent(context, sessionMap));
   LoginView loginView = viewConfigStore.getAnnotationData(viewRoot.getViewId(), LoginView.class);
   if (loginView == null || loginView.value() == null || loginView.value().isEmpty()) {
     log.debug("Returning 401 response (login required)");
     context.getExternalContext().setResponseStatus(401);
     context.responseComplete();
     return;
   }
   String loginViewId = loginView.value();
   log.debugf("Redirecting to configured LoginView %s", loginViewId);
   NavigationHandler navHandler = context.getApplication().getNavigationHandler();
   navHandler.handleNavigation(context, "", loginViewId);
   context.renderResponse();
 }
Exemplo n.º 3
0
 /**
  * Perform the navigation to the @AccessDeniedView. If not @AccessDeniedView is defined, return a
  * 401 response
  *
  * @param context
  * @param viewRoot
  */
 private void redirectToAccessDeniedView(FacesContext context, UIViewRoot viewRoot) {
   AccessDeniedView accessDeniedView =
       viewConfigStore.getAnnotationData(viewRoot.getViewId(), AccessDeniedView.class);
   if (accessDeniedView == null
       || accessDeniedView.value() == null
       || accessDeniedView.value().isEmpty()) {
     log.debug("Returning 401 response (access denied)");
     context.getExternalContext().setResponseStatus(401);
     context.responseComplete();
     return;
   }
   String accessDeniedViewId = accessDeniedView.value();
   log.debugf("Redirecting to configured AccessDenied %s", accessDeniedViewId);
   NavigationHandler navHandler = context.getApplication().getNavigationHandler();
   navHandler.handleNavigation(context, "", accessDeniedViewId);
   context.renderResponse();
 }