spring security EnableMethodSecurity 源码

  • 2022-08-13
  • 浏览 (483)

spring security EnableMethodSecurity 代码

文件路径:/config/src/main/java/org/springframework/security/config/annotation/method/configuration/EnableMethodSecurity.java

/*
 * Copyright 2002-2021 the original author or authors.
 *
 * 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.config.annotation.method.configuration;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Import;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PreFilter;

/**
 * Enables Spring Security Method Security.
 * @author Evgeniy Cheban
 * @author Josh Cummings
 * @since 5.6
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@Import(MethodSecuritySelector.class)
public @interface EnableMethodSecurity {

	/**
	 * Determines if Spring Security's {@link PreAuthorize}, {@link PostAuthorize},
	 * {@link PreFilter}, and {@link PostFilter} annotations should be enabled. Default is
	 * true.
	 * @return true if pre/post annotations should be enabled false otherwise
	 */
	boolean prePostEnabled() default true;

	/**
	 * Determines if Spring Security's {@link Secured} annotation should be enabled.
	 * Default is false.
	 * @return true if {@link Secured} annotation should be enabled false otherwise
	 */
	boolean securedEnabled() default false;

	/**
	 * Determines if JSR-250 annotations should be enabled. Default is false.
	 * @return true if JSR-250 should be enabled false otherwise
	 */
	boolean jsr250Enabled() default false;

	/**
	 * Indicate whether subclass-based (CGLIB) proxies are to be created as opposed to
	 * standard Java interface-based proxies. The default is {@code false}. <strong>
	 * Applicable only if {@link #mode()} is set to {@link AdviceMode#PROXY}</strong>.
	 * <p>
	 * Note that setting this attribute to {@code true} will affect <em>all</em>
	 * Spring-managed beans requiring proxying, not just those marked with
	 * {@code @Cacheable}. For example, other beans marked with Spring's
	 * {@code @Transactional} annotation will be upgraded to subclass proxying at the same
	 * time. This approach has no negative impact in practice unless one is explicitly
	 * expecting one type of proxy vs another, e.g. in tests.
	 * @return true if subclass-based (CGLIB) proxies are to be created
	 */
	boolean proxyTargetClass() default false;

	/**
	 * Indicate how security advice should be applied. The default is
	 * {@link AdviceMode#PROXY}.
	 * @see AdviceMode
	 * @return the {@link AdviceMode} to use
	 */
	AdviceMode mode() default AdviceMode.PROXY;

}

相关信息

spring security 源码目录

相关文章

spring security EnableGlobalMethodSecurity 源码

spring security EnableReactiveMethodSecurity 源码

spring security GlobalMethodSecurityAspectJAutoProxyRegistrar 源码

spring security GlobalMethodSecurityConfiguration 源码

spring security GlobalMethodSecuritySelector 源码

spring security Jsr250MetadataSourceConfiguration 源码

spring security Jsr250MethodSecurityConfiguration 源码

spring security MethodSecurityMetadataSourceAdvisorRegistrar 源码

spring security MethodSecuritySelector 源码

spring security PrePostMethodSecurityConfiguration 源码

0  赞