3333import org .springframework .jdbc .datasource .embedded .EmbeddedDatabase ;
3434import org .springframework .jdbc .datasource .embedded .EmbeddedDatabaseBuilder ;
3535import org .springframework .jdbc .datasource .embedded .EmbeddedDatabaseType ;
36+ import org .springframework .security .authentication .TestingAuthenticationToken ;
3637import org .springframework .security .config .annotation .web .configuration .EnableWebSecurity ;
3738import org .springframework .security .config .annotation .web .configuration .OAuth2AuthorizationServerConfiguration ;
3839import org .springframework .security .config .test .SpringTestRule ;
4243import org .springframework .security .oauth2 .server .authorization .client .JdbcRegisteredClientRepository ;
4344import org .springframework .security .oauth2 .server .authorization .client .RegisteredClientRepository ;
4445import org .springframework .security .oauth2 .server .authorization .config .ProviderSettings ;
46+ import org .springframework .security .oauth2 .server .authorization .jackson2 .TestingAuthenticationTokenMixin ;
4547import org .springframework .security .oauth2 .server .authorization .web .NimbusJwkSetEndpointFilter ;
4648import org .springframework .test .web .servlet .MockMvc ;
4749
@@ -125,8 +127,8 @@ static class AuthorizationServerConfiguration {
125127 @ Bean
126128 OAuth2AuthorizationService authorizationService (JdbcOperations jdbcOperations , RegisteredClientRepository registeredClientRepository ) {
127129 JdbcOAuth2AuthorizationService authorizationService = new JdbcOAuth2AuthorizationService (jdbcOperations , registeredClientRepository );
128- authorizationService .setAuthorizationRowMapper (new OAuth2ClientCredentialsGrantTests . AuthorizationServerConfiguration . RowMapper (registeredClientRepository ));
129- authorizationService .setAuthorizationParametersMapper (new OAuth2ClientCredentialsGrantTests . AuthorizationServerConfiguration . ParametersMapper ());
130+ authorizationService .setAuthorizationRowMapper (new RowMapper (registeredClientRepository ));
131+ authorizationService .setAuthorizationParametersMapper (new ParametersMapper ());
130132 return authorizationService ;
131133 }
132134
@@ -144,6 +146,24 @@ JdbcOperations jdbcOperations() {
144146 JWKSource <SecurityContext > jwkSource () {
145147 return jwkSource ;
146148 }
149+
150+ static class RowMapper extends JdbcOAuth2AuthorizationService .OAuth2AuthorizationRowMapper {
151+
152+ RowMapper (RegisteredClientRepository registeredClientRepository ) {
153+ super (registeredClientRepository );
154+ getObjectMapper ().addMixIn (TestingAuthenticationToken .class , TestingAuthenticationTokenMixin .class );
155+ }
156+
157+ }
158+
159+ static class ParametersMapper extends JdbcOAuth2AuthorizationService .OAuth2AuthorizationParametersMapper {
160+
161+ ParametersMapper () {
162+ super ();
163+ getObjectMapper ().addMixIn (TestingAuthenticationToken .class , TestingAuthenticationTokenMixin .class );
164+ }
165+
166+ }
147167 }
148168
149169 @ EnableWebSecurity
0 commit comments