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


Java SerializationUtils.serialize方法代码示例

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


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

示例1: shouldStoreAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Test
public void shouldStoreAccessToken() {
    //Given
    final OAuth2AccessToken auth2AccessToken = OAuth2AccessTokenBuilder.oAuth2AccessTokenBuilder().build();
    final byte[] token = SerializationUtils.serialize(auth2AccessToken);

    //And
    final OAuth2Authentication oAuth2Authentication = OAuth2AuthenticationBuilder.oAuth2AuthenticationBuilder().build();

    //And
    given(mongoOAuth2AccessTokenRepository.findByTokenId(any(String.class))).willReturn(MongoOAuth2AccessTokenBuilder.mongoOAuth2AccessTokenBuilder().token(token).build());

    //When
    tokenStore.storeAccessToken(auth2AccessToken, oAuth2Authentication);

    //Then
    verify(mongoOAuth2AccessTokenRepository).deleteByTokenId(any(String.class));
    verify(mongoOAuth2AccessTokenRepository).save(any(MongoOAuth2AccessToken.class));
}
 
开发者ID:caelwinner,项目名称:spring-security-mongo,代码行数:20,代码来源:MongoTokenStoreTest.java

示例2: shouldStoreRefreshToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Test
public void shouldStoreRefreshToken() {
    //Given
    final OAuth2RefreshToken oAuth2RefreshToken = OAuth2RefreshTokenBuilder.oAuth2RefreshToken().build();

    //And
    final OAuth2Authentication oAuth2Authentication = OAuth2AuthenticationBuilder.oAuth2AuthenticationBuilder().build();

    //And
    final ArgumentCaptor<MongoOAuth2RefreshToken> argumentCaptor = ArgumentCaptor.forClass(MongoOAuth2RefreshToken.class);

    //When
    tokenStore.storeRefreshToken(oAuth2RefreshToken, oAuth2Authentication);

    //Then
    verify(mongoOAuth2RefreshTokenRepository).save(argumentCaptor.capture());
    final MongoOAuth2RefreshToken refreshToken = argumentCaptor.getValue();
    final byte[] expectedResult = SerializationUtils.serialize(oAuth2RefreshToken);
    assertThat(refreshToken.getToken()).isEqualTo(expectedResult);

}
 
开发者ID:caelwinner,项目名称:spring-security-mongo,代码行数:22,代码来源:MongoTokenStoreTest.java

示例3: shouldReadRefreshToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Test
public void shouldReadRefreshToken() {
    //Given
    final String tokenValue = string().next();
    final OAuth2RefreshToken oAuth2RefreshToken = OAuth2RefreshTokenBuilder.oAuth2RefreshToken().build();
    final byte[] oAuth2RefreshTokenSer = SerializationUtils.serialize(oAuth2RefreshToken);

    //And
    given(mongoOAuth2RefreshTokenRepository.findByTokenId(any(String.class)))
            .willReturn(MongoOAuth2RefreshTokenBuilder.mongoOAuth2RefreshTokenBuilder().token(oAuth2RefreshTokenSer).build());

    //When
    final OAuth2RefreshToken result = tokenStore.readRefreshToken(tokenValue);

    //Then
    assertThat(result.getValue()).isEqualTo(oAuth2RefreshToken.getValue());
}
 
开发者ID:caelwinner,项目名称:spring-security-mongo,代码行数:18,代码来源:MongoTokenStoreTest.java

示例4: shouldReadAuthenticationForRefreshToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Test
public void shouldReadAuthenticationForRefreshToken() {
    //Given
    final OAuth2RefreshToken oAuth2RefreshToken = OAuth2RefreshTokenBuilder.oAuth2RefreshToken().build();

    //And
    final OAuth2Authentication authentication = OAuth2AuthenticationBuilder.oAuth2AuthenticationBuilder().build();
    final byte[] authenticationSer = SerializationUtils.serialize(authentication);

    //And
    given(mongoOAuth2RefreshTokenRepository.findByTokenId(any(String.class)))
            .willReturn(MongoOAuth2RefreshTokenBuilder.mongoOAuth2RefreshTokenBuilder()
                    .authentication(authenticationSer)
                    .build());
    //When
    final OAuth2Authentication oAuth2Authentication = tokenStore.readAuthenticationForRefreshToken(oAuth2RefreshToken);

    //Then
    assertThat(oAuth2Authentication.getPrincipal()).isEqualTo(authentication.getPrincipal());
    assertThat(oAuth2Authentication.getCredentials()).isEqualTo(authentication.getCredentials());
}
 
开发者ID:caelwinner,项目名称:spring-security-mongo,代码行数:22,代码来源:MongoTokenStoreTest.java

示例5: storeRefreshToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public void storeRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authentication authentication) {
  List<RegularStatement> statementList = new ArrayList<RegularStatement>();

  byte[] serializedRefreshToken = SerializationUtils.serialize(refreshToken);
  ByteBuffer bufferedRefreshToken = ByteBuffer.wrap(serializedRefreshToken);

  byte[] serializedAuthentication = SerializationUtils.serialize(authentication);
  ByteBuffer bufferedAuthentication = ByteBuffer.wrap(serializedAuthentication);

  WriteOptions refreshWriteOptions = new WriteOptions();
  if (refreshToken instanceof ExpiringOAuth2RefreshToken) {
    ExpiringOAuth2RefreshToken expiringRefreshToken = (ExpiringOAuth2RefreshToken) refreshToken;
    Date expiration = expiringRefreshToken.getExpiration();
    if (expiration != null) {
      int seconds = Long.valueOf((expiration.getTime() - System.currentTimeMillis()) / 1000L).intValue();
      refreshWriteOptions.setTtl(seconds);
    }
  }

  // Insert into RefreshToken table
  Insert accessInsert = CassandraTemplate.createInsertQuery(RefreshToken.TABLE, new RefreshToken(refreshToken.getValue(), bufferedRefreshToken), refreshWriteOptions, cassandraTemplate.getConverter());
  statementList.add(accessInsert);

  // Insert into RefreshTokenAuthentication table
  Insert authInsert = CassandraTemplate.createInsertQuery(RefreshTokenAuthentication.TABLE, new RefreshTokenAuthentication(refreshToken.getValue(), bufferedAuthentication), refreshWriteOptions, cassandraTemplate.getConverter());
  statementList.add(authInsert);

  Batch batch = QueryBuilder.batch(statementList.toArray(new RegularStatement[statementList.size()]));
  cassandraTemplate.execute(batch);
}
 
开发者ID:Mert-Z,项目名称:spring-oauth2-cassandra-token-store,代码行数:32,代码来源:CassandraTokenStore.java

示例6: OAuthAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
public OAuthAccessToken(final OAuth2AccessToken oAuth2AccessToken,
    final OAuth2Authentication authentication, final String authenticationId, String jti,
    String refreshJTI) {
  this.tokenId = jti;
  this.oAuth2AccessToken = SerializationUtils.serialize(oAuth2AccessToken);
  this.authenticationId = authenticationId;
  this.userName = authentication.getName();
  this.oauth2Request = SerializationUtils
      .serialize(SerializationUtils.serialize(authentication.getOAuth2Request()));
  this.clientId = authentication.getOAuth2Request().getClientId();
  this.authentication = SerializationUtils.serialize(authentication);
  this.refreshToken = refreshJTI;
  this.user = authentication.getUserAuthentication() != null
      ? (OAuthUser) authentication.getUserAuthentication().getPrincipal() : null;
}
 
开发者ID:nandhusriram,项目名称:jwt_token_mongo_store,代码行数:16,代码来源:OAuthAccessToken.java

示例7: saveAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public void saveAccessToken(final OAuth2ProtectedResourceDetails resource,
                            final Authentication authentication,
                            final OAuth2AccessToken accessToken) {
    removeAccessToken(resource, authentication);
    final MongoOAuth2ClientToken mongoOAuth2ClientToken = new MongoOAuth2ClientToken(UUID.randomUUID().toString(),
            accessToken.getValue(),
            SerializationUtils.serialize(accessToken),
            clientKeyGenerator.extractKey(resource, authentication),
            authentication.getName(),
            resource.getClientId());
    
    mongoOAuth2ClientTokenRepository.save(mongoOAuth2ClientToken);
}
 
开发者ID:cloudade,项目名称:authorization-server-with-mongodb,代码行数:15,代码来源:MongoClientTokenServices.java

示例8: OAuth2AuthenticationAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
public OAuth2AuthenticationAccessToken(final OAuth2AccessToken oAuth2AccessToken, final OAuth2Authentication authentication, final String authenticationId) {
    this.tokenId = oAuth2AccessToken.getValue();
    this.token = SerializationUtils.serialize(oAuth2AccessToken);
    this.authenticationId = authenticationId;
     
    this.userName = ((User)authentication.getPrincipal()).getUserId();
    this.clientId = authentication.getOAuth2Request().getClientId();
    this.authentication = SerializationUtils.serialize(authentication);
    this.refreshToken = oAuth2AccessToken.getRefreshToken().getValue();
}
 
开发者ID:xxing1982,项目名称:EDU_SYZT,代码行数:11,代码来源:OAuth2AuthenticationAccessToken.java

示例9: saveAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Override
public void saveAccessToken(final OAuth2ProtectedResourceDetails resource,
                            final Authentication authentication,
                            final OAuth2AccessToken accessToken) {
    removeAccessToken(resource, authentication);
    final MongoOAuth2ClientToken mongoOAuth2ClientToken = new MongoOAuth2ClientToken(UUID.randomUUID().toString(),
            accessToken.getValue(),
            SerializationUtils.serialize(accessToken),
            clientKeyGenerator.extractKey(resource, authentication),
            authentication.getName(),
            resource.getClientId());

    mongoOAuth2ClientTokenRepository.save(mongoOAuth2ClientToken);
}
 
开发者ID:caelwinner,项目名称:spring-security-mongo,代码行数:15,代码来源:MongoClientTokenServices.java

示例10: shouldGetAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
@Test
public void shouldGetAccessToken() {
    //Given
    final OAuth2Authentication oAuth2Authentication = OAuth2AuthenticationBuilder.oAuth2AuthenticationBuilder().build();

    //And
    final String value = string().next();
    given(authenticationKeyGenerator.extractKey(oAuth2Authentication)).willReturn(value);

    //And
    final OAuth2AccessToken oAuth2AccessToken = OAuth2AccessTokenBuilder.oAuth2AccessTokenBuilder().build();

    final byte[] oAuth2AccessTokenSer = SerializationUtils.serialize(oAuth2AccessToken);
    given(mongoOAuth2AccessTokenRepository.findByAuthenticationId(value))
            .willReturn(MongoOAuth2AccessTokenBuilder.mongoOAuth2AccessTokenBuilder()
                    .token(oAuth2AccessTokenSer)
                    .build());

    //And
    given(authenticationKeyGenerator.extractKey(any(OAuth2Authentication.class))).willReturn(value);

    //And
    given(mongoOAuth2AccessTokenRepository.findByTokenId(anyString())).willReturn(MongoOAuth2AccessTokenBuilder.mongoOAuth2AccessTokenBuilder().build());

    //When
    tokenStore.getAccessToken(oAuth2Authentication);

    //Then
    verify(mongoOAuth2AccessTokenRepository, never()).deleteByTokenId(any(String.class));
    verify(mongoOAuth2AccessTokenRepository, never()).save(any(MongoOAuth2AccessToken.class));
}
 
开发者ID:caelwinner,项目名称:spring-security-mongo,代码行数:32,代码来源:MongoTokenStoreTest.java

示例11: serializeAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
protected byte[] serializeAccessToken(OAuth2AccessToken token) {
	return SerializationUtils.serialize(token);
}
 
开发者ID:xienjiang,项目名称:session-cloud,代码行数:4,代码来源:CustomTokenStore.java

示例12: serializeRefreshToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
protected byte[] serializeRefreshToken(OAuth2RefreshToken token) {
	return SerializationUtils.serialize(token);
}
 
开发者ID:xienjiang,项目名称:session-cloud,代码行数:4,代码来源:CustomTokenStore.java

示例13: serializeAuthentication

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
protected byte[] serializeAuthentication(OAuth2Authentication authentication) {
	return SerializationUtils.serialize(authentication);
}
 
开发者ID:xienjiang,项目名称:session-cloud,代码行数:4,代码来源:CustomTokenStore.java

示例14: OAuthRefreshToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
public OAuthRefreshToken(OAuth2RefreshToken oAuth2RefreshToken,
    OAuth2Authentication authentication, String jti) {
  this.oAuth2RefreshToken = SerializationUtils.serialize((Serializable) oAuth2RefreshToken);
  this.authentication = SerializationUtils.serialize((Serializable) authentication);
  this.tokenId = jti;
}
 
开发者ID:nandhusriram,项目名称:jwt_token_mongo_store,代码行数:7,代码来源:OAuthRefreshToken.java

示例15: serializeAccessToken

import org.springframework.security.oauth2.common.util.SerializationUtils; //导入方法依赖的package包/类
protected byte[] serializeAccessToken(OAuth2AccessToken token) {
    return SerializationUtils.serialize(token);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:4,代码来源:ClientProxyTokenStore.java


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