Skip to content

Commit 29b9dc6

Browse files
committed
Register runtime hints for authorization server
Issue gh-18251
1 parent 7503d80 commit 29b9dc6

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2004-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.oauth2.server.authorization.aot.hint;
18+
19+
import org.springframework.aot.hint.MemberCategory;
20+
import org.springframework.aot.hint.RuntimeHints;
21+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
22+
import org.springframework.aot.hint.TypeReference;
23+
import org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthorizationCodeRequestAuthenticationProvider;
24+
import org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthorizationCodeRequestAuthenticationToken;
25+
import org.springframework.security.oauth2.server.authorization.web.OAuth2AuthorizationEndpointFilter;
26+
27+
/**
28+
* {@link RuntimeHintsRegistrar} that contributes the required {@link RuntimeHints} for
29+
* OAuth 2.1 Authorization Server. Statically registered via
30+
* META-INF/spring/aot.factories.
31+
*
32+
* @author Joe Grandja
33+
* @since 7.0
34+
*/
35+
class OAuth2AuthorizationServerRuntimeHints implements RuntimeHintsRegistrar {
36+
37+
@Override
38+
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
39+
hints.reflection()
40+
.registerType(OAuth2AuthorizationCodeRequestAuthenticationProvider.class,
41+
MemberCategory.INVOKE_DECLARED_METHODS);
42+
hints.reflection()
43+
.registerType(OAuth2AuthorizationEndpointFilter.class, MemberCategory.INVOKE_DECLARED_METHODS);
44+
hints.reflection()
45+
.registerType(TypeReference
46+
.of("org.springframework.security.oauth2.server.authorization.web.OAuth2AuthorizationEndpointFilter$OAuth2AuthorizationCodeRequestValidatingFilter"),
47+
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
48+
hints.reflection()
49+
.registerType(OAuth2AuthorizationCodeRequestAuthenticationToken.class, MemberCategory.DECLARED_FIELDS);
50+
51+
}
52+
53+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
org.springframework.beans.factory.aot.BeanRegistrationAotProcessor=\
22
org.springframework.security.oauth2.server.authorization.aot.hint.OAuth2AuthorizationServerBeanRegistrationAotProcessor
3+
4+
org.springframework.aot.hint.RuntimeHintsRegistrar=\
5+
org.springframework.security.oauth2.server.authorization.aot.hint.OAuth2AuthorizationServerRuntimeHints

0 commit comments

Comments
 (0)