Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@

package org.springframework.session.aot.hint;

import java.net.URL;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.TreeSet;

import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.session.MapSession;

/**
* A {@link RuntimeHintsRegistrar} for common session hints.
Expand All @@ -33,16 +41,19 @@ class CommonSessionRuntimeHints implements RuntimeHintsRegistrar {

@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
Arrays
.asList(TypeReference.of(String.class), TypeReference.of(ArrayList.class), TypeReference.of(TreeSet.class),
TypeReference.of(Number.class), TypeReference.of(Long.class), TypeReference.of(Integer.class),
TypeReference.of(StackTraceElement.class), TypeReference.of(Throwable.class),
TypeReference.of(Exception.class), TypeReference.of(RuntimeException.class),
TypeReference.of("java.util.Collections$UnmodifiableCollection"),
TypeReference.of("java.util.Collections$UnmodifiableList"),
TypeReference.of("java.util.Collections$EmptyList"),
TypeReference.of("java.util.Collections$UnmodifiableRandomAccessList"),
TypeReference.of("java.util.Collections$UnmodifiableSet"))
Arrays.asList(TypeReference.of(String.class), TypeReference.of(Number.class), TypeReference.of(Long.class),
TypeReference.of(Integer.class), TypeReference.of(URL.class), TypeReference.of(Instant.class),
TypeReference.of(Duration.class), TypeReference.of("java.time.Ser"),
TypeReference.of(StackTraceElement.class), TypeReference.of(Throwable.class),
TypeReference.of(Exception.class), TypeReference.of(RuntimeException.class),
TypeReference.of(ArrayList.class), TypeReference.of(TreeSet.class), TypeReference.of(HashMap.class),
TypeReference.of(LinkedHashMap.class), TypeReference.of(HashSet.class),
TypeReference.of(LinkedHashSet.class), TypeReference.of("java.util.Collections$UnmodifiableCollection"),
TypeReference.of("java.util.Collections$UnmodifiableList"),
TypeReference.of("java.util.Collections$EmptyList"),
TypeReference.of("java.util.Collections$UnmodifiableRandomAccessList"),
TypeReference.of("java.util.Collections$UnmodifiableSet"),
TypeReference.of("java.util.Collections$UnmodifiableMap"), TypeReference.of(MapSession.class))
.forEach(hints.serialization()::registerType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,35 @@ private void registerOAuth2ResourceServerHintsIfNeeded(RuntimeHints hints) {

private void registerOAuth2ClientHintsIfNeeded(RuntimeHints hints) {
Arrays.asList(
TypeReference.of("org.springframework.security.oauth2.core.AbstractOAuth2Token"),
TypeReference.of("org.springframework.security.oauth2.core.OAuth2AccessToken"),
TypeReference.of("org.springframework.security.oauth2.core.OAuth2AccessToken$TokenType"),
TypeReference.of("org.springframework.security.oauth2.core.AuthenticationMethod"),
TypeReference.of("org.springframework.security.oauth2.core.ClientAuthenticationMethod"),
TypeReference.of("org.springframework.security.oauth2.core.AuthorizationGrantType"),
TypeReference.of("org.springframework.security.oauth2.core.OAuth2RefreshToken"),
TypeReference.of("org.springframework.security.oauth2.core.OAuth2AuthenticationException"),
TypeReference.of("org.springframework.security.oauth2.core.user.OAuth2UserAuthority"),
TypeReference.of("org.springframework.security.oauth2.core.user.DefaultOAuth2User"),
TypeReference.of("org.springframework.security.oauth2.core.oidc.user.OidcUserAuthority"),
TypeReference.of("org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser"),
TypeReference.of("org.springframework.security.oauth2.core.oidc.OidcIdToken"),
TypeReference.of("org.springframework.security.oauth2.core.oidc.OidcUserInfo"),
TypeReference.of("org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest"),
TypeReference.of("org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationResponseType"),
TypeReference.of("org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken"),
TypeReference.of("org.springframework.security.oauth2.client.OAuth2AuthorizedClient"),
TypeReference
.of("org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationToken"),
TypeReference
.of("org.springframework.security.oauth2.client.authentication.OAuth2AuthorizationCodeAuthenticationToken"),
TypeReference.of("org.springframework.security.oauth2.core.OAuth2AuthenticationException"))
.of("org.springframework.security.oauth2.client.authentication.OAuth2AuthorizationCodeAuthenticationToken"),
TypeReference.of("org.springframework.security.oauth2.client.registration.ClientRegistration"),
TypeReference
.of("org.springframework.security.oauth2.client.registration.ClientRegistration$ProviderDetails"),
TypeReference
.of("org.springframework.security.oauth2.client.registration.ClientRegistration$ProviderDetails$UserInfoEndpoint"),
TypeReference.of("net.minidev.json.JSONObject"),
TypeReference.of("com.nimbusds.oauth2.sdk.util.OrderedJSONObject"))
.forEach((type) -> hints.serialization()
.registerType(type, (hint) -> hint.onReachableType(TypeReference
.of("org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken"))));
Expand Down