org.springframework.security.access.vote.AuthenticatedVoter Maven / Gradle / Ivy
/*
* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.security.access.vote;
import java.util.Collection;
import org.springframework.security.access.AccessDecisionVoter;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.authentication.AuthenticationTrustResolver;
import org.springframework.security.authentication.AuthenticationTrustResolverImpl;
import org.springframework.security.core.Authentication;
import org.springframework.util.Assert;
/**
* Votes if a {@link ConfigAttribute#getAttribute()} of
* IS_AUTHENTICATED_FULLY
or IS_AUTHENTICATED_REMEMBERED
or
* IS_AUTHENTICATED_ANONYMOUSLY
is present. This list is in order of most
* strict checking to least strict checking.
*
* The current Authentication
will be inspected to determine if the principal
* has a particular level of authentication. The "FULLY" authenticated option means the
* user is authenticated fully (i.e.
* {@link org.springframework.security.authentication.AuthenticationTrustResolver#isAnonymous(Authentication)}
* is false and
* {@link org.springframework.security.authentication.AuthenticationTrustResolver#isRememberMe(Authentication)}
* is false). The "REMEMBERED" will grant access if the principal was either authenticated
* via remember-me OR is fully authenticated. The "ANONYMOUSLY" will grant access if the
* principal was authenticated via remember-me, OR anonymously, OR via full
* authentication.
*
* All comparisons and prefixes are case sensitive.
*
* @author Ben Alex
*/
public class AuthenticatedVoter implements AccessDecisionVoter