parent
06c87d0079
commit
1dc49276f8
|
@ -32,10 +32,12 @@ import org.springframework.security.core.parameters.AnnotationParameterNameDisco
|
|||
*
|
||||
* @author Rob Winch
|
||||
* @since 3.2
|
||||
* @deprecated use @{code org.springframework.security.core.parameters.P}
|
||||
*/
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Deprecated
|
||||
public @interface P {
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.springframework.core.DefaultParameterNameDiscoverer;
|
|||
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
|
||||
import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.core.PrioritizedParameterNameDiscoverer;
|
||||
import org.springframework.security.access.method.P;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
@ -83,6 +82,7 @@ public class DefaultSecurityParameterNameDiscoverer extends
|
|||
}
|
||||
|
||||
Set<String> annotationClassesToUse = new HashSet<String>(2);
|
||||
annotationClassesToUse.add("org.springframework.security.access.method.P");
|
||||
annotationClassesToUse.add(P.class.getName());
|
||||
if (DATA_PARAM_PRESENT) {
|
||||
annotationClassesToUse.add(DATA_PARAM_CLASSNAME);
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2002-2017 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
|
||||
*
|
||||
* http://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.core.parameters;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* An annotation that can be used along with {@link AnnotationParameterNameDiscoverer} to
|
||||
* specify parameter names. This is useful for interfaces prior to JDK 8 which cannot
|
||||
* contain the parameter names.
|
||||
*
|
||||
* @see AnnotationParameterNameDiscoverer
|
||||
*
|
||||
* @author Rob Winch
|
||||
* @since 5.0
|
||||
*/
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface P {
|
||||
|
||||
/**
|
||||
* The parameter name
|
||||
* @return
|
||||
*/
|
||||
String value();
|
||||
}
|
|
@ -26,7 +26,6 @@ import org.junit.Test;
|
|||
import org.springframework.core.DefaultParameterNameDiscoverer;
|
||||
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
|
||||
import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.security.access.method.P;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
|
@ -54,7 +53,7 @@ public class DefaultSecurityParameterNameDiscovererTests {
|
|||
assertThat(annotationDisc).isInstanceOf(AnnotationParameterNameDiscoverer.class);
|
||||
Set<String> annotationsToUse = (Set<String>) ReflectionTestUtils.getField(
|
||||
annotationDisc, "annotationClassesToUse");
|
||||
assertThat(annotationsToUse).containsOnly(P.class.getName());
|
||||
assertThat(annotationsToUse).containsOnly("org.springframework.security.access.method.P", P.class.getName());
|
||||
|
||||
assertThat(discoverers.get(1).getClass()).isEqualTo(
|
||||
DefaultParameterNameDiscoverer.class);
|
||||
|
@ -76,9 +75,9 @@ public class DefaultSecurityParameterNameDiscovererTests {
|
|||
assertThat(annotationDisc).isInstanceOf(AnnotationParameterNameDiscoverer.class);
|
||||
Set<String> annotationsToUse = (Set<String>) ReflectionTestUtils.getField(
|
||||
annotationDisc, "annotationClassesToUse");
|
||||
assertThat(annotationsToUse).containsOnly(P.class.getName());
|
||||
assertThat(annotationsToUse).containsOnly("org.springframework.security.access.method.P", P.class.getName());
|
||||
|
||||
assertThat(discoverers.get(2).getClass()).isEqualTo(
|
||||
DefaultParameterNameDiscoverer.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue