@Override public boolean isAuthenticated() { final Authentication authentication = getAuthentication(); return authentication != null && authentication.isAuthenticated() && !(authentication instanceof AnonymousAuthenticationToken); }
@Override public boolean isRememberMeAuthenticated() { final Authentication authentication = getAuthentication(); return authentication instanceof RememberMeAuthenticationToken && authentication.isAuthenticated(); }
@Override public boolean isAuthenticatedAnonymously() { final Authentication authentication = getAuthentication(); return authentication instanceof AnonymousAuthenticationToken && authentication.isAuthenticated(); }
@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; }
@Override public boolean isRememberMeAuthenticated() { final Authentication authentication = getAuthentication(); return authentication instanceof RememberMeAuthenticationToken && authentication.isAuthenticated(); }
@Override public boolean isFullyAuthenticated() { final Authentication authentication = getAuthentication(); return authentication != null && !(authentication instanceof AnonymousAuthenticationToken) && !(authentication instanceof RememberMeAuthenticationToken) && authentication.isAuthenticated(); }
@Override public boolean isAuthenticated() { final Authentication authentication = getAuthentication(); return authentication != null && authentication.isAuthenticated() && !(authentication instanceof AnonymousAuthenticationToken); }
@Override public boolean isAuthenticatedAnonymously() { final Authentication authentication = getAuthentication(); return authentication instanceof AnonymousAuthenticationToken && authentication.isAuthenticated(); }
@Override public boolean isFullyAuthenticated() { final Authentication authentication = getAuthentication(); return authentication != null && !(authentication instanceof AnonymousAuthenticationToken) && !(authentication instanceof RememberMeAuthenticationToken) && authentication.isAuthenticated(); }
@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; }
@Override public boolean hasAccessToObject(Object securedObject, String... securityConfigurationAttributes) { final Authentication authentication = getAuthentication(); if (getAccessDecisionManager() == null) { logger.warn("Access was denied to object because there was no AccessDecisionManager set!"); return false; } else if (authentication == null || !authentication.isAuthenticated()) { 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) { logger.trace("Access denied when accessing {}", securedObject); return false; } catch (InsufficientAuthenticationException ex) { logger.trace("Insufficient authentication when accessing {}", securedObject); return false; } }
@Override public boolean hasAccessToObject(Object securedObject, String... securityConfigurationAttributes) { final Authentication authentication = getAuthentication(); if (getAccessDecisionManager() == null) { logger.warn("Access was denied to object because there was no AccessDecisionManager set!"); return false; } else if (authentication == null || !authentication.isAuthenticated()) { 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) { logger.trace("Access denied when accessing {}", securedObject); return false; } catch (InsufficientAuthenticationException ex) { logger.trace("Insufficient authentication when accessing {}", securedObject); return false; } }