}
@Override
public void observeEvent(final LifecycleEvent<W> event) {
// There is no good way to inject the context within the bootstrapper.
final SecurityContext securityContext = SecurityContextHoldingSingleton.getSecurityContext();
if (!securityContext.isUserCacheValid() || !securityContext.hasCachedUser()
|| !securityContext.getCachedUser().hasAllRoles(roles)) {
event.veto();
final Class<? extends UniquePageRole> destination;
if (!securityContext.hasCachedUser())
destination = LoginPage.class;
else
destination = SecurityError.class;
securityContext.navigateToPage(destination);
}
}