|
66 | 66 | import org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher; |
67 | 67 | import org.springframework.security.web.util.matcher.RequestMatcher; |
68 | 68 | import org.springframework.util.Assert; |
| 69 | +import org.springframework.util.ClassUtils; |
69 | 70 | import org.springframework.web.accept.ContentNegotiationStrategy; |
70 | 71 | import org.springframework.web.accept.HeaderContentNegotiationStrategy; |
71 | 72 |
|
|
149 | 150 | public final class OAuth2ResourceServerConfigurer<H extends HttpSecurityBuilder<H>> |
150 | 151 | extends AbstractHttpConfigurer<OAuth2ResourceServerConfigurer<H>, H> { |
151 | 152 |
|
| 153 | + private static final boolean dPoPAuthenticationAvailable; |
| 154 | + |
| 155 | + static { |
| 156 | + ClassLoader classLoader = OAuth2ResourceServerConfigurer.class.getClassLoader(); |
| 157 | + dPoPAuthenticationAvailable = ClassUtils |
| 158 | + .isPresent("org.springframework.security.oauth2.jwt.DPoPProofJwtDecoderFactory", classLoader); |
| 159 | + } |
| 160 | + |
152 | 161 | private static final RequestHeaderRequestMatcher X_REQUESTED_WITH = new RequestHeaderRequestMatcher( |
153 | 162 | "X-Requested-With", "XMLHttpRequest"); |
154 | 163 |
|
155 | 164 | private final ApplicationContext context; |
156 | 165 |
|
157 | | - private final DPoPAuthenticationConfigurer<H> dPoPAuthenticationConfigurer = new DPoPAuthenticationConfigurer<>(); |
158 | | - |
159 | 166 | private AuthenticationManagerResolver<HttpServletRequest> authenticationManagerResolver; |
160 | 167 |
|
161 | 168 | private AuthenticationConverter authenticationConverter; |
@@ -269,7 +276,10 @@ public void configure(H http) { |
269 | 276 | filter.setSecurityContextHolderStrategy(getSecurityContextHolderStrategy()); |
270 | 277 | filter = postProcess(filter); |
271 | 278 | http.addFilter(filter); |
272 | | - this.dPoPAuthenticationConfigurer.configure(http); |
| 279 | + if (dPoPAuthenticationAvailable) { |
| 280 | + DPoPAuthenticationConfigurer<H> dPoPAuthenticationConfigurer = new DPoPAuthenticationConfigurer<>(); |
| 281 | + dPoPAuthenticationConfigurer.configure(http); |
| 282 | + } |
273 | 283 | } |
274 | 284 |
|
275 | 285 | private void validateConfiguration() { |
|
0 commit comments