@Override public boolean isAccessGranted(String beanName, UI ui, View view) { Secured viewSecured = view.getClass().getAnnotation(Secured.class); if ( viewSecured == null || !security.hasAccessDecisionManager() ) { return true; // Decision is already done if there is no AccessDecisionManager } else { return security.hasAccessToSecuredObject(view); } } }
@Override public boolean isAccessGranted(String beanName, UI ui) { Secured viewSecured = applicationContext.findAnnotationOnBean(beanName, Secured.class); if ( viewSecured == null ) { return true; } else if ( security.hasAccessDecisionManager() ) { return true; // Leave decision to the second hook } else { return security.hasAnyAuthority(viewSecured.value()); } }
logger.trace("No @PreAuthorize annotation found on view {}. Granting access.", beanName); return true; } else if (security.hasAccessDecisionManager()) { final Class<?> targetClass = AopUtils.getTargetClass(view); final Method method = ClassUtils.getMethod(targetClass, "enter", com.vaadin.navigator.ViewChangeListener.ViewChangeEvent.class);
logger.trace("No @PreAuthorize annotation found on view {}. Granting access.", beanName); return true; } else if (security.hasAccessDecisionManager()) { final Class<?> targetClass = AopUtils.getTargetClass(view); final Method method = ClassUtils.getMethod(targetClass, "enter", com.vaadin.navigator.ViewChangeListener.ViewChangeEvent.class);
@Override public boolean isAccessGranted(String beanName, UI ui) { PreAuthorize viewSecured = applicationContext.findAnnotationOnBean(beanName, PreAuthorize.class); if ( viewSecured == null ) { return true; } else if ( security.hasAccessDecisionManager() ) { final Class<?> targetClass = AopUtils.getTargetClass(applicationContext.getBean(beanName)); final Method method = ClassUtils.getMethod(AopUtils.getTargetClass(applicationContext.getBean(beanName)), "enter", com.vaadin.navigator.ViewChangeListener.ViewChangeEvent.class); final MethodInvocation methodInvocation = MethodInvocationUtils.createFromClass(targetClass, method.getName()); final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); final AccessDecisionManager accessDecisionManager = security.getAccessDecisionManager(); final ExpressionBasedAnnotationAttributeFactory attributeFactory = new ExpressionBasedAnnotationAttributeFactory(new DefaultMethodSecurityExpressionHandler()); Collection<ConfigAttribute> atributi = new ArrayList<ConfigAttribute>(); atributi.add(attributeFactory.createPreInvocationAttribute(null, null, viewSecured.value())); try { accessDecisionManager.decide(authentication, methodInvocation, atributi); return true; } catch (InsufficientAuthenticationException e) { return false; } catch (AccessDeniedException e) { return false; } } else { return true; // Access decision manager required for @PreAuthorize() } }