本文整理汇总了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);
}
}
}
示例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());
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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());
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}
示例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;
}
示例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());
}
};
}
示例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;
}
示例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;
}
示例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;
}