当前位置: 首页>>代码示例>>Java>>正文


Java SerializationUtils.deserialize方法代码示例

本文整理汇总了Java中org.springframework.security.oauth2.common.util.SerializationUtils.deserialize方法的典型用法代码示例。如果您正苦于以下问题:Java SerializationUtils.deserialize方法的具体用法?Java SerializationUtils.deserialize怎么用?Java SerializationUtils.deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.security.oauth2.common.util.SerializationUtils的用法示例。


在下文中一共展示了SerializationUtils.deserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserializeSafely

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
/**
 * Dirty hack to fix <a href="https://github.com/spring-projects/spring-security-oauth/issues/665">Spring Security Issue</a>
 * If there is serialUid mismatch, replaces Uuid and tries de-serialize object again
 * Introduces mismatchCallback function to handle successful recovery of Uuid mismatch
 *
 * @param data             Data to de-serialize
 * @param mismatchCallback Mismatch callback. Executed in case of successful recovery
 * @param <T>              Type of Object
 * @return De-serialized object
 */
@SuppressWarnings("unchecked")
public static <T> T deserializeSafely(byte[] data, @Nullable Consumer<T> mismatchCallback) {
    try {
        return SerializationUtils.deserialize(data);
    } catch (IllegalArgumentException e) {
        boolean serialUidMismatch = java.io.InvalidClassException.class.equals(e.getCause().getClass());
        if (!serialUidMismatch) {
            throw e;
        }

        try {
            ObjectInputStream is = new SerialUidReplacingInputStream(new ByteArrayInputStream(data));
            T t = (T) is.readObject();
            if (null != mismatchCallback) {
                mismatchCallback.accept(t);
            }
            return t;
        } catch (IOException | ClassNotFoundException e1) {
            throw new IllegalArgumentException("Unable to serialize object", e1);
        }
    }
}
 
开发者ID:reportportal,项目名称:service-authorization,代码行数:33,代码来源:AuthUtils.java

示例2: getAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@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());
}
 
开发者ID:openmhealth,项目名称:shimmer,代码行数:18,代码来源:AccessParameterClientTokenServices.java

示例3: readAuthentication

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public OAuth2Authentication readAuthentication(String token) {
  Authentication authentication = authenticationRepository.findOne(token);
  if (authentication != null) {
    ByteBuffer bufferedOAuth2Authentication = authentication.getoAuth2Authentication();
    byte[] serializedOAuth2Authentication = new byte[bufferedOAuth2Authentication.remaining()];
    bufferedOAuth2Authentication.get(serializedOAuth2Authentication);
    OAuth2Authentication oAuth2Authentication = SerializationUtils.deserialize(serializedOAuth2Authentication);
    return oAuth2Authentication;
  } else {
    return null;
  }
}
 
开发者ID:Mert-Z,项目名称:spring-oauth2-cassandra-token-store,代码行数:14,代码来源:CassandraTokenStore.java

示例4: readRefreshToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public OAuth2RefreshToken readRefreshToken(String tokenValue) {
  RefreshToken refreshToken = refreshTokenRepository.findOne(tokenValue);
  if (refreshToken != null) {
    ByteBuffer bufferedRefreshToken = refreshToken.getoAuth2RefreshToken();
    byte[] serializedRefreshToken = new byte[bufferedRefreshToken.remaining()];
    bufferedRefreshToken.get(serializedRefreshToken);
    OAuth2RefreshToken oAuth2RefreshToken = SerializationUtils.deserialize(serializedRefreshToken);
    return oAuth2RefreshToken;
  } else {
    return null;
  }
}
 
开发者ID:Mert-Z,项目名称:spring-oauth2-cassandra-token-store,代码行数:14,代码来源:CassandraTokenStore.java

示例5: readAuthenticationForRefreshToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public OAuth2Authentication readAuthenticationForRefreshToken(OAuth2RefreshToken token) {
  RefreshTokenAuthentication refreshTokenAuthentication = refreshTokenAuthenticationRepository.findOne(token.getValue());
  if (refreshTokenAuthentication != null) {
    ByteBuffer bufferedOAuth2Authentication = refreshTokenAuthentication.getoAuth2Authentication();
    byte[] serializedOAuth2Authentication = new byte[bufferedOAuth2Authentication.remaining()];
    bufferedOAuth2Authentication.get(serializedOAuth2Authentication);
    OAuth2Authentication oAuth2Authentication = SerializationUtils.deserialize(serializedOAuth2Authentication);
    return oAuth2Authentication;
  } else {
    return null;
  }
}
 
开发者ID:Mert-Z,项目名称:spring-oauth2-cassandra-token-store,代码行数:14,代码来源:CassandraTokenStore.java

示例6: readAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public OAuth2AccessToken readAccessToken(String tokenValue) {
    OAuth2AccessTokenEntity token = oAuth2AccessTokenRepository.findByTokenId(tokenValue);
    if (token == null) {
        return null; //let spring security handle the invalid token
    }
    return SerializationUtils.deserialize(token.getToken());
}
 
开发者ID:reportportal,项目名称:service-authorization,代码行数:9,代码来源:OAuth2MongoTokenStore.java

示例7: readAuthentication

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public OAuth2Authentication readAuthentication(OAuth2AccessToken paramOAuth2AccessToken) {
  OAuthAccessToken token = readAuthenticationFromDB(paramOAuth2AccessToken.getValue());

  OAuth2Authentication token2 = SerializationUtils.deserialize(token.getAuthentication());

  if (!token2.isClientOnly()) {
    @SuppressWarnings("unused")
    OAuthUser loggedUser = (OAuthUser) token2.getUserAuthentication().getPrincipal();

  }
  return token2;
}
 
开发者ID:nandhusriram,项目名称:jwt_token_mongo_store,代码行数:14,代码来源:JWTMongoTokenStore.java

示例8: readAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public OAuth2AccessToken readAccessToken(String paramString) {
  JWTCommon common = extractJtiFromRefreshToken(paramString);
  OAuthAccessToken storedObject = accessTokenDao.findByTokenId(common.getJti());
  if (storedObject == null)
    return null;
  Object authentication = SerializationUtils.deserialize(storedObject.getOAuth2AccessToken());

  return (OAuth2AccessToken) authentication;
}
 
开发者ID:nandhusriram,项目名称:jwt_token_mongo_store,代码行数:11,代码来源:JWTMongoTokenStore.java

示例9: readRefreshToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public OAuth2RefreshToken readRefreshToken(String paramString) {
  JWTCommon common = extractJtiFromRefreshToken(paramString);
  OAuthRefreshToken refreshEntity = refreshTokenDao.findByTokenId(common.getJti());
  if (refreshEntity == null)
    return null;
  return SerializationUtils.deserialize(refreshEntity.getOAuth2RefreshToken());
}
 
开发者ID:nandhusriram,项目名称:jwt_token_mongo_store,代码行数:9,代码来源:JWTMongoTokenStore.java

示例10: readAuthenticationForRefreshToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public OAuth2Authentication readAuthenticationForRefreshToken(
    OAuth2RefreshToken paramOAuth2RefreshToken) {
  JWTCommon common = extractJtiFromRefreshToken(paramOAuth2RefreshToken.getValue());
  OAuthRefreshToken storedObject = refreshTokenDao.findByTokenId(common.getJti());
  if (storedObject == null)
    return null;

  return SerializationUtils.deserialize(storedObject.getAuthentication());
}
 
开发者ID:nandhusriram,项目名称:jwt_token_mongo_store,代码行数:11,代码来源:JWTMongoTokenStore.java

示例11: getAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public OAuth2AccessToken getAccessToken(OAuth2Authentication paramOAuth2Authentication) {
  OAuthAccessToken storedObject = accessTokenDao
      .findByAuthenticationId(authenticationKeyGenerator.extractKey(paramOAuth2Authentication));
  if (storedObject == null)
    return null;

  Object authentication = SerializationUtils.deserialize(storedObject.getOAuth2AccessToken());

  return (OAuth2AccessToken) authentication;
}
 
开发者ID:nandhusriram,项目名称:jwt_token_mongo_store,代码行数:12,代码来源:JWTMongoTokenStore.java

示例12: toOAuth2AccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
private Function<MongoOAuth2AccessToken, OAuth2AccessToken> toOAuth2AccessToken() {
	return new Function<MongoOAuth2AccessToken, OAuth2AccessToken>() {
		@Override
		public OAuth2AccessToken apply(MongoOAuth2AccessToken token) {
			return SerializationUtils.deserialize(token.getToken());
		}
	};
}
 
开发者ID:cloudade,项目名称:authorization-server-with-mongodb,代码行数:9,代码来源:MongoTokenStore.java

示例13: remove

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
public OAuth2Authentication remove(String code) {
    OAuth2Authentication authentication = null;

    DBObject query = new BasicDBObject(codeFieldName, code);
    DBObject authCode = getAuthCodeCollection().findOne(query);
    if (authCode != null) {
        authentication = SerializationUtils.deserialize((byte[]) authCode.get(authenticationFieldName));
        if (authentication != null) {
            getAuthCodeCollection().remove(authCode);
        }
    }

    return authentication;
}
 
开发者ID:cedac-software,项目名称:spring-security-mongodb,代码行数:15,代码来源:MongoAuthorizationCodeServices.java

示例14: readAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
  public OAuth2AccessToken readAccessToken(String tokenValue) {
      OAuth2AuthenticationAccessToken token = oAuth2AccessTokenRepository.findByTokenId(tokenValue);
      if(token == null) {
          return null; //let spring security handle the invalid token
      }
      OAuth2AccessToken accessToken = SerializationUtils.deserialize(token.getToken());
return accessToken;
  }
 
开发者ID:xxing1982,项目名称:EDU_SYZT,代码行数:10,代码来源:OAuth2RepositoryTokenStore.java

示例15: getAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication) {
    List<OAuth2AuthenticationAccessToken> tokenList =  oAuth2AccessTokenRepository.findByAuthenticationIdOrderByCreationTimeDesc(authenticationKeyGenerator.extractKey(authentication));
    OAuth2AccessToken token = null;
    if(tokenList.size() != 0) {SerializationUtils.deserialize(tokenList.get(0).getToken());}
    return token;
}
 
开发者ID:xxing1982,项目名称:EDU_SYZT,代码行数:8,代码来源:OAuth2RepositoryTokenStore.java


注:本文中的org.springframework.security.oauth2.common.util.SerializationUtils.deserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。