@Bean(name = Beans.VAADIN_SECURITY) VaadinSecurity vaadinSecurity() { return new GenericVaadinSecurity(); }
/** * {@inheritDoc} */ @Override public boolean isAuthenticated() { final Authentication authentication = getAuthentication(); return ( authentication != null && authentication.isAuthenticated() ); }
/** * {@inheritDoc} */ @Override public boolean hasAccessToSecuredMethod(Object securedObject, String methodName, Class<?>... methodParameterTypes) { try { final Method method = securedObject.getClass().getMethod(methodName, methodParameterTypes); final Secured secured = AnnotationUtils.findAnnotation(method, Secured.class); Assert.notNull(secured, "securedObject did not have @Secured annotation"); return hasAccessToObject(securedObject, secured.value()); } catch (NoSuchMethodException ex) { throw new IllegalArgumentException("Method " + methodName + " does not exist", ex); } }
final Authentication fullyAuthenticated = getAuthenticationManager().authenticate(authentication); getSessionAuthenticationStrategy().onAuthentication(fullyAuthenticated, request, response); if ( hasAuthenticationSuccessHandlerConfigured() ) { getAuthenticationSuccessHandler().onAuthenticationSuccess(authentication); context = generateNewContext(); if ( hasAuthenticationFailureHandlerConfigured() ) { getAuthenticationFailureHandler().onAuthenticationFailure(e); } else { throw e;
/** * {@inheritDoc} */ @Override public boolean hasAccessToObject(Object securedObject, String... securityConfigurationAttributes) { final Authentication authentication = getAuthentication(); if (getAccessDecisionManager() == null || authentication == null || !authentication.isAuthenticated()) { if (getAccessDecisionManager() == null) { logger.warn("Access was denied to object because there was no AccessDecisionManager set!"); } return false; } final Collection<ConfigAttribute> configAttributes = new ArrayList<ConfigAttribute>(securityConfigurationAttributes.length); for (String securityConfigString : securityConfigurationAttributes) { configAttributes.add(new SecurityConfig(securityConfigString)); } try { getAccessDecisionManager().decide(authentication, securedObject, configAttributes); return true; } catch (AccessDeniedException ex) { return false; } catch (InsufficientAuthenticationException ex) { return false; } }
/** * {@inheritDoc} */ @Override public boolean hasAccessToSecuredObject(Object securedObject) { final Secured secured = AopUtils.getTargetClass(securedObject).getAnnotation(Secured.class); Assert.notNull(secured, "securedObject did not have @Secured annotation"); return hasAccessToObject(securedObject, secured.value()); }
/** * {@inheritDoc} */ @Override public boolean hasAuthority(String authority) { final Authentication authentication = getAuthentication(); if (authentication == null || !authentication.isAuthenticated()) { return false; } for (GrantedAuthority grantedAuthority : authentication.getAuthorities()) { if (authority.equals(grantedAuthority.getAuthority())) { return true; } } return false; }