@@ -50,20 +50,34 @@ public interface ClaimAccessor {
50
50
*/
51
51
@ SuppressWarnings ("unchecked" )
52
52
default <T > T getClaim (String claim ) {
53
- return !containsClaim (claim ) ? null : (T ) getClaims ().get (claim );
53
+ return !hasClaim (claim ) ? null : (T ) getClaims ().get (claim );
54
54
}
55
55
56
56
/**
57
57
* Returns {@code true} if the claim exists in {@link #getClaims()}, otherwise
58
58
* {@code false}.
59
59
* @param claim the name of the claim
60
60
* @return {@code true} if the claim exists, otherwise {@code false}
61
+ * @since 5.5
61
62
*/
62
- default Boolean containsClaim (String claim ) {
63
+ default boolean hasClaim (String claim ) {
63
64
Assert .notNull (claim , "claim cannot be null" );
64
65
return getClaims ().containsKey (claim );
65
66
}
66
67
68
+ /**
69
+ * Returns {@code true} if the claim exists in {@link #getClaims()}, otherwise
70
+ * {@code false}.
71
+ * @param claim the name of the claim
72
+ * @return {@code true} if the claim exists, otherwise {@code false}
73
+ * @deprecated Use
74
+ * {@link org.springframework.security.oauth2.core.ClaimAccessor#hasClaim} instead.
75
+ */
76
+ @ Deprecated
77
+ default Boolean containsClaim (String claim ) {
78
+ return hasClaim (claim );
79
+ }
80
+
67
81
/**
68
82
* Returns the claim value as a {@code String} or {@code null} if it does not exist or
69
83
* is equal to {@code null}.
@@ -72,7 +86,7 @@ default Boolean containsClaim(String claim) {
72
86
* {@code null}
73
87
*/
74
88
default String getClaimAsString (String claim ) {
75
- return !containsClaim (claim ) ? null
89
+ return !hasClaim (claim ) ? null
76
90
: ClaimConversionService .getSharedInstance ().convert (getClaims ().get (claim ), String .class );
77
91
}
78
92
@@ -82,7 +96,7 @@ default String getClaimAsString(String claim) {
82
96
* @return the claim value or {@code null} if it does not exist
83
97
*/
84
98
default Boolean getClaimAsBoolean (String claim ) {
85
- return !containsClaim (claim ) ? null
99
+ return !hasClaim (claim ) ? null
86
100
: ClaimConversionService .getSharedInstance ().convert (getClaims ().get (claim ), Boolean .class );
87
101
}
88
102
@@ -92,7 +106,7 @@ default Boolean getClaimAsBoolean(String claim) {
92
106
* @return the claim value or {@code null} if it does not exist
93
107
*/
94
108
default Instant getClaimAsInstant (String claim ) {
95
- if (!containsClaim (claim )) {
109
+ if (!hasClaim (claim )) {
96
110
return null ;
97
111
}
98
112
Object claimValue = getClaims ().get (claim );
@@ -108,7 +122,7 @@ default Instant getClaimAsInstant(String claim) {
108
122
* @return the claim value or {@code null} if it does not exist
109
123
*/
110
124
default URL getClaimAsURL (String claim ) {
111
- if (!containsClaim (claim )) {
125
+ if (!hasClaim (claim )) {
112
126
return null ;
113
127
}
114
128
Object claimValue = getClaims ().get (claim );
@@ -127,7 +141,7 @@ default URL getClaimAsURL(String claim) {
127
141
*/
128
142
@ SuppressWarnings ("unchecked" )
129
143
default Map <String , Object > getClaimAsMap (String claim ) {
130
- if (!containsClaim (claim )) {
144
+ if (!hasClaim (claim )) {
131
145
return null ;
132
146
}
133
147
final TypeDescriptor sourceDescriptor = TypeDescriptor .valueOf (Object .class );
@@ -150,7 +164,7 @@ default Map<String, Object> getClaimAsMap(String claim) {
150
164
*/
151
165
@ SuppressWarnings ("unchecked" )
152
166
default List <String > getClaimAsStringList (String claim ) {
153
- if (!containsClaim (claim )) {
167
+ if (!hasClaim (claim )) {
154
168
return null ;
155
169
}
156
170
final TypeDescriptor sourceDescriptor = TypeDescriptor .valueOf (Object .class );
0 commit comments