Java Code Examples for org.springframework.security.oauth2.common.util.SerializationUtils#deserialize()

The following examples show how to use org.springframework.security.oauth2.common.util.SerializationUtils#deserialize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TokenServiceImpl.java    From oauth-server with Apache License 2.0 6 votes vote down vote up
@Override
public void deleteOne(String tokenId) {
    //筛选token
    AccessTokenDO accessTokenDO = accessTokenMapper.selectByPrimaryKey(tokenId);
    //token不存在
    if (accessTokenDO == null) {
        throw new CommonException("error.delete.token.not.exist");
    }
    //提取sessionId
    DefaultOAuth2AccessToken deserialize = SerializationUtils.deserialize(accessTokenDO.getToken());
    //删除redis session
    redisTemplate.delete(SESSION_KEY_PREFIX + deserialize.getAdditionalInformation().get("sessionId"));
    //删除db accessToken/refreshToken
    accessTokenMapper.deleteByPrimaryKey(tokenId);
    refreshTokenMapper.deleteByPrimaryKey(accessTokenDO.getRefreshToken());
    LOGGER.info("delete token,tokenId:{},sessionId:{}",tokenId,deserialize.getAdditionalInformation().get("sessionId"));
}
 
Example 2
Source File: AccessParameterClientTokenServices.java    From shimmer with Apache License 2.0 6 votes vote down vote up
@Override
public OAuth2AccessToken getAccessToken(
        OAuth2ProtectedResourceDetails resource,
        Authentication authentication) {

    String username = authentication.getPrincipal().toString();
    String shimKey = authentication.getDetails().toString();

    AccessParameters accessParameters = accessParametersRepo.findByUsernameAndShimKey(
            username, shimKey, new Sort(Sort.Direction.DESC, "dateCreated"));

    if (accessParameters == null || accessParameters.getSerializedToken() == null) {
        return null; //No token was found!
    }

    return SerializationUtils.deserialize(accessParameters.getSerializedToken());
}
 
Example 3
Source File: AccessTokenDO.java    From oauth-server with Apache License 2.0 4 votes vote down vote up
public void setToken(byte[] token) {
    this.token = token;
    this.value = SerializationUtils.deserialize(token);
}
 
Example 4
Source File: AuthorizationCode.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
public OAuth2Authentication authentication() {
    return SerializationUtils.deserialize(authenticationBytes);
}
 
Example 5
Source File: AccessToken.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Tolerate
public OAuth2AccessToken token() {
    return SerializationUtils.deserialize(token);
}
 
Example 6
Source File: AccessToken.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Tolerate
public OAuth2Authentication authentication() {
    return SerializationUtils.deserialize(authentication);
}
 
Example 7
Source File: RefreshToken.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
public OAuth2RefreshToken token() {
    return SerializationUtils.deserialize(token);
}
 
Example 8
Source File: RefreshToken.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
public OAuth2Authentication authentication() {
    return SerializationUtils.deserialize(authentication);
}
 
Example 9
Source File: MongoClientTokenServices.java    From spring-security-mongo with MIT License 4 votes vote down vote up
@Override
public OAuth2AccessToken getAccessToken(final OAuth2ProtectedResourceDetails resource,
                                        final Authentication authentication) {
    final MongoOAuth2ClientToken mongoOAuth2ClientToken = mongoOAuth2ClientTokenRepository.findByAuthenticationId(clientKeyGenerator.extractKey(resource, authentication));
    return SerializationUtils.deserialize(mongoOAuth2ClientToken.getToken());
}