@@ -466,7 +466,7 @@ private static SqlParameterValue mapToSqlParameter(String columnName, String val
466466 /**
467467 * The default {@link RowMapper} that maps the current row in
468468 * {@code java.sql.ResultSet} to {@link OAuth2Authorization} using Jackson 3's
469- * {@link JsonMapper} to read all {@code Map<String,Object>} within the result .
469+ * {@link JsonMapper}.
470470 *
471471 * @author Rob Winch
472472 * @since 7.0
@@ -482,6 +482,7 @@ public JsonMapperOAuth2AuthorizationRowMapper(RegisteredClientRepository registe
482482 public JsonMapperOAuth2AuthorizationRowMapper (RegisteredClientRepository registeredClientRepository ,
483483 JsonMapper jsonMapper ) {
484484 super (registeredClientRepository );
485+ Assert .notNull (jsonMapper , "jsonMapper cannot be null" );
485486 this .jsonMapper = jsonMapper ;
486487 }
487488
@@ -544,7 +545,7 @@ private abstract static class AbstractOAuth2AuthorizationRowMapper implements Ro
544545
545546 private LobHandler lobHandler = new DefaultLobHandler ();
546547
547- AbstractOAuth2AuthorizationRowMapper (RegisteredClientRepository registeredClientRepository ) {
548+ private AbstractOAuth2AuthorizationRowMapper (RegisteredClientRepository registeredClientRepository ) {
548549 Assert .notNull (registeredClientRepository , "registeredClientRepository cannot be null" );
549550 this .registeredClientRepository = registeredClientRepository ;
550551 }
@@ -713,42 +714,36 @@ private Map<String, Object> parseMap(String data) {
713714 }
714715
715716 /**
716- * Nested class to protect from getting {@link NoClassDefFoundError} when Jackson 2 is
717- * not on the classpath.
718- *
719- * @deprecated This is used to allow transition to Jackson 3. Use {@link Jackson3}
720- * instead.
717+ * The default {@code Function} that maps {@link OAuth2Authorization} to a
718+ * {@code List} of {@link SqlParameterValue} using an instance of Jackson 3's
719+ * {@link JsonMapper}.
721720 */
722- @ Deprecated ( forRemoval = true , since = "7.0" )
723- private static final class Jackson2 {
721+ public static class JsonMapperOAuth2AuthorizationParametersMapper
722+ extends AbstractOAuth2AuthorizationParametersMapper {
724723
725- static ObjectMapper createObjectMapper () {
726- ObjectMapper objectMapper = new ObjectMapper ();
727- ClassLoader classLoader = Jackson2 .class .getClassLoader ();
728- List <Module > securityModules = SecurityJackson2Modules .getModules (classLoader );
729- objectMapper .registerModules (securityModules );
730- objectMapper .registerModule (new OAuth2AuthorizationServerJackson2Module ());
731- return objectMapper ;
732- }
724+ private final JsonMapper jsonMapper ;
733725
734- }
726+ public JsonMapperOAuth2AuthorizationParametersMapper () {
727+ this (Jackson3 .createJsonMapper ());
728+ }
735729
736- /**
737- * Nested class used to get a common default instance of {@link JsonMapper}. It is in
738- * a nested class to protect from getting {@link NoClassDefFoundError} when Jackson 3
739- * is not on the classpath.
740- */
741- private static final class Jackson3 {
730+ public JsonMapperOAuth2AuthorizationParametersMapper (JsonMapper jsonMapper ) {
731+ Assert .notNull (jsonMapper , "jsonMapper cannot be null" );
732+ this .jsonMapper = jsonMapper ;
733+ }
742734
743- static JsonMapper createJsonMapper () {
744- List < JacksonModule > modules = SecurityJacksonModules . getModules ( Jackson3 . class . getClassLoader ());
745- return JsonMapper . builder (). addModules ( modules ). build ( );
735+ @ Override
736+ String writeValueAsString ( Map < String , Object > data ) throws Exception {
737+ return this . jsonMapper . writeValueAsString ( data );
746738 }
747739
748740 }
749741
750742 /**
751- * @deprecated Use {@link JsonMapperOAuth2AuthorizationParametersMapper} to migrate to
743+ * A {@code Function} that maps {@link OAuth2Authorization} to a {@code List} of
744+ * {@link SqlParameterValue} using an instance of Jackson 2's {@link ObjectMapper}.
745+ *
746+ * @deprecated Use {@link JsonMapperOAuth2AuthorizationParametersMapper} to switch to
752747 * Jackson 3.
753748 */
754749 @ Deprecated (forRemoval = true , since = "7.0" )
@@ -772,40 +767,14 @@ public final void setObjectMapper(ObjectMapper objectMapper) {
772767
773768 }
774769
775- /**
776- * The default {@code Function} that maps {@link OAuth2Authorization} to a
777- * {@code List} of {@link SqlParameterValue} using an instance of Jackson 3's
778- * {@link JsonMapper}.
779- */
780- public static final class JsonMapperOAuth2AuthorizationParametersMapper
781- extends AbstractOAuth2AuthorizationParametersMapper {
782-
783- private final JsonMapper mapper ;
784-
785- public JsonMapperOAuth2AuthorizationParametersMapper () {
786- this (Jackson3 .createJsonMapper ());
787- }
788-
789- public JsonMapperOAuth2AuthorizationParametersMapper (JsonMapper mapper ) {
790- Assert .notNull (mapper , "mapper cannot be null" );
791- this .mapper = mapper ;
792- }
793-
794- @ Override
795- String writeValueAsString (Map <String , Object > data ) throws Exception {
796- return this .mapper .writeValueAsString (data );
797- }
798-
799- }
800-
801770 /**
802771 * The base {@code Function} that maps {@link OAuth2Authorization} to a {@code List}
803772 * of {@link SqlParameterValue}.
804773 */
805774 private abstract static class AbstractOAuth2AuthorizationParametersMapper
806775 implements Function <OAuth2Authorization , List <SqlParameterValue >> {
807776
808- protected AbstractOAuth2AuthorizationParametersMapper () {
777+ private AbstractOAuth2AuthorizationParametersMapper () {
809778 }
810779
811780 @ Override
@@ -916,6 +885,41 @@ private String writeMap(Map<String, Object> data) {
916885
917886 }
918887
888+ /**
889+ * Nested class to protect from getting {@link NoClassDefFoundError} when Jackson 2 is
890+ * not on the classpath.
891+ *
892+ * @deprecated This is used to allow transition to Jackson 3. Use {@link Jackson3}
893+ * instead.
894+ */
895+ @ Deprecated (forRemoval = true , since = "7.0" )
896+ private static final class Jackson2 {
897+
898+ private static ObjectMapper createObjectMapper () {
899+ ObjectMapper objectMapper = new ObjectMapper ();
900+ ClassLoader classLoader = Jackson2 .class .getClassLoader ();
901+ List <Module > securityModules = SecurityJackson2Modules .getModules (classLoader );
902+ objectMapper .registerModules (securityModules );
903+ objectMapper .registerModule (new OAuth2AuthorizationServerJackson2Module ());
904+ return objectMapper ;
905+ }
906+
907+ }
908+
909+ /**
910+ * Nested class used to get a common default instance of {@link JsonMapper}. It is in
911+ * a nested class to protect from getting {@link NoClassDefFoundError} when Jackson 3
912+ * is not on the classpath.
913+ */
914+ private static final class Jackson3 {
915+
916+ private static JsonMapper createJsonMapper () {
917+ List <JacksonModule > modules = SecurityJacksonModules .getModules (Jackson3 .class .getClassLoader ());
918+ return JsonMapper .builder ().addModules (modules ).build ();
919+ }
920+
921+ }
922+
919923 private static final class LobCreatorArgumentPreparedStatementSetter extends ArgumentPreparedStatementSetter {
920924
921925 private final LobCreator lobCreator ;
0 commit comments