You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.springframework.security.oauth2.common.OAuth2RefreshToken: abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [Source: {"value":"422bed46-c545-49cb-8b95-754705309952","expiration":1491041632698}; line: 1, column: 1]
Activity
wwpwan commentedon Mar 2, 2017
步骤一、在com.newnil.cas.oauth2.provider.config中的SecurityConfig增加如下代码:
步骤二、在com.newnil.cas.oauth2.provider.config.OAuth2ServerConfig中的OAuth2ServerConfig里面增加如下代码:
执行上面就可以支持grant_type=password了,但是----com.newnil.cas.oauth2.provider.service.DatabaseTokenStoreService中第51行、90行(accessTokenRepository.save(entityToSave);)、111行(refreshTokenRepository.save(entityToSave);)会报:
wwpwan commentedon Mar 2, 2017
出现json转转化错误的原因是org.springframework.security.oauth2.common.DefaultExpiringOAuth2RefreshToken中没有默认构造方法,com.newnil.cas.oauth2.provider.dao.entity.util.JsonPersistenceConverters中使用com.fasterxml.jackson.databind.ObjectMapper进行json转换时就会出错。我的解决方法是定一个MyDefaultExpiringOAuth2RefreshToken继承自DefaultExpiringOAuth2RefreshToken如下:
然后使用该类进行转换转换后再拷贝给DefaultExpiringOAuth2RefreshToken进行中转,我在. com.newnil.cas.oauth2.provider.dao.entity.util直接中转如:
dewafer commentedon Mar 3, 2017
感谢您的issue。
AuthenticationManager
并且在AuthorizationServerEndpointsConfigurer
配置时注入。OAuth2RefreshToken
。Spring为OAuth2AccessToken
提供了Serializer和Deserializer,但没有为OAuth2RefreshToken
提供。在这里我们仿Spring提供的OAuth2AccessTokenJackson2Serializer
和OAuth2AccessTokenJackson2Deserializer
创建了对应的OAuth2RefreshTokenJackson2Serializer
和OAuth2RefreshTokenJackson2Deserializer
,并在ObjectMapper
上注册,修复了无法反序列化的问题。(没有提供Jackson1的Serializer和Deserializer是因为我们的项目默认使用Jackson2,并不会用到Jackson1)