diff --git a/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScanner.java b/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScanner.java
index ee771aacc7..f9082181ff 100644
--- a/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScanner.java
+++ b/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScanner.java
@@ -59,8 +59,8 @@ import org.springframework.util.PropertyPlaceholderHelper;
* {@code @HasRole} annotation found on a given {@link AnnotatedElement}.
*
*
- * Meta-annotations that use enum values can use {@link ExpressionTemplateValueProvider} to
- * provide custom placeholder values.
+ * Meta-annotations that use enum values can use {@link ExpressionTemplateValueProvider}
+ * to provide custom placeholder values.
*
*
* Since the process of synthesis is expensive, it is recommended to cache the synthesized
@@ -176,8 +176,8 @@ final class ExpressionTemplateSecurityAnnotationScanner
}
@Override
- public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
- return (source != null) ? ((ExpressionTemplateValueProvider)source).getExpressionTemplateValue() : null;
+ public @Nullable Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
+ return (source != null) ? ((ExpressionTemplateValueProvider) source).getExpressionTemplateValue() : null;
}
}
diff --git a/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateValueProvider.java b/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateValueProvider.java
index 58d241e932..f8c7e64ced 100644
--- a/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateValueProvider.java
+++ b/core/src/main/java/org/springframework/security/core/annotation/ExpressionTemplateValueProvider.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2004-present 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.core.annotation;
/**
@@ -20,14 +36,13 @@ package org.springframework.security.core.annotation;
* }
*
*
- * @since 6.5
* @author Mike Heath
+ * @since 7.0
*/
public interface ExpressionTemplateValueProvider {
/**
* Returns the value to be used in an expression template.
- *
* @return the value to be used in an expression template
*/
String getExpressionTemplateValue();
diff --git a/core/src/test/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScannerTests.java b/core/src/test/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScannerTests.java
index 7a47de4df0..684393a65d 100644
--- a/core/src/test/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScannerTests.java
+++ b/core/src/test/java/org/springframework/security/core/annotation/ExpressionTemplateSecurityAnnotationScannerTests.java
@@ -62,8 +62,8 @@ public class ExpressionTemplateSecurityAnnotationScannerTests {
}
enum Permission implements ExpressionTemplateValueProvider {
- READ,
- WRITE;
+
+ READ, WRITE;
@Override
public String getExpressionTemplateValue() {
@@ -72,6 +72,7 @@ public class ExpressionTemplateSecurityAnnotationScannerTests {
case WRITE -> "'user.WRITE'";
};
}
+
}
@Documented
@@ -89,6 +90,7 @@ public class ExpressionTemplateSecurityAnnotationScannerTests {
@Target({ ElementType.TYPE, ElementType.METHOD })
@HasAnyCustomPermissions(permissions = { Permission.READ, Permission.WRITE })
@interface HasAllCustomPermissions {
+
}
@Documented