Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
In CDI Implementation to redirect the login to the first denied page:
- change Usuario to User
- why use char[] for password? Is that some security measure, to prevent interned Strings of passwords hanging around in memory? If so, that should be noted, otherwise it should be changed to String, it's confusing.
In CDI and PL implementations:
the AdminAccessDecisionVoter should implement AccessDecisionVoter, not extend AbstractAccessDecisionVoter- I think the AdminAccessDecisionVoter should be agnostic of the view layer and therefore shouldn't inject ViewConfigResolver and shouldn't keep the denied page itself.
Maybe the listener could handle the AccessDeniedException instead:
Basic voter:
AdminAccessDecisionVoter.java
@SessionScoped //or @WindowScoped public class AdminAccessDecisionVoter extends AbstractAccessDecisionVoter { @Override protected void checkPermission(AccessDecisionVoterContext context, Set<SecurityViolation> violations) { // voting stuff } }
The listener/holder/handler:
AuthenticationListener.java
@ExceptionHandler public class AuthenticationListener { @Inject ViewNavigationHandler viewNavigationHandler; @Inject ViewConfigResolver viewConfigResolver; private Class<? extends ViewConfig> deniedPage; public void rememberDeniedView(@BeforeHandles ExceptionEvent<ErrorViewAwareAccessDeniedException> evt) { deniedPage = viewConfigResolver.getViewConfigDescriptor(FacesContext.getCurrentInstance().getViewRoot().getViewId()).getConfigClass(); evt.handledAndContinue(); } public void handleLoggedIn(@Observes UserLoggedInEvent event) { if(deniedPage != null) { viewNavigationHandler.navigateTo(deniedPage); deniedPage = null; } viewNavigationHandler.navigateTo(Pages.Home.class); } }