|
| 1 | +/* |
| 2 | + * |
| 3 | + * * |
| 4 | + * * * |
| 5 | + * * * * |
| 6 | + * * * * * Copyright 2019-2022 the original author or authors. |
| 7 | + * * * * * |
| 8 | + * * * * * Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | + * * * * * you may not use this file except in compliance with the License. |
| 10 | + * * * * * You may obtain a copy of the License at |
| 11 | + * * * * * |
| 12 | + * * * * * https://www.apache.org/licenses/LICENSE-2.0 |
| 13 | + * * * * * |
| 14 | + * * * * * Unless required by applicable law or agreed to in writing, software |
| 15 | + * * * * * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | + * * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | + * * * * * See the License for the specific language governing permissions and |
| 18 | + * * * * * limitations under the License. |
| 19 | + * * * * |
| 20 | + * * * |
| 21 | + * * |
| 22 | + * |
| 23 | + */ |
| 24 | + |
| 25 | +package org.springdoc.core.configuration.hints; |
| 26 | + |
| 27 | +import java.util.Arrays; |
| 28 | + |
| 29 | +import org.springframework.aot.hint.MemberCategory; |
| 30 | +import org.springframework.aot.hint.RuntimeHints; |
| 31 | +import org.springframework.aot.hint.RuntimeHintsRegistrar; |
| 32 | + |
| 33 | +/** |
| 34 | + * The type Spring doc DataRest hints. |
| 35 | + * @author bnasslahsen |
| 36 | + */ |
| 37 | +public class SpringDocSecurityHints implements RuntimeHintsRegistrar { |
| 38 | + |
| 39 | + //spring-security |
| 40 | + static String[] springSecurityTypeNames = { "org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter", |
| 41 | + "org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter", |
| 42 | + "org.springframework.security.web.util.matcher.OrRequestMatcher" |
| 43 | + }; |
| 44 | + |
| 45 | + @Override |
| 46 | + public void registerHints(RuntimeHints hints, ClassLoader classLoader) { |
| 47 | + //spring-security |
| 48 | + Arrays.stream(springSecurityTypeNames).forEach(springDataRestTypeName -> |
| 49 | + hints.reflection() |
| 50 | + .registerTypeIfPresent(classLoader, springDataRestTypeName, |
| 51 | + hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS, |
| 52 | + MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, |
| 53 | + MemberCategory.INVOKE_DECLARED_METHODS |
| 54 | + )) |
| 55 | + ); |
| 56 | + } |
| 57 | + |
| 58 | +} |
| 59 | + |
0 commit comments