本文整理汇总了Java中org.springframework.security.oauth2.common.OAuth2RefreshToken.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java OAuth2RefreshToken.getValue方法的具体用法?Java OAuth2RefreshToken.getValue怎么用?Java OAuth2RefreshToken.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.oauth2.common.OAuth2RefreshToken
的用法示例。
在下文中一共展示了OAuth2RefreshToken.getValue方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeAccessTokenUsingRefreshToken
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
@Override
public void removeAccessTokenUsingRefreshToken(OAuth2RefreshToken refreshToken) {
String tokenValue = refreshToken.getValue();
// Lookup RefreshTokenToAccessToken table for locating access token
RefreshTokenToAccessToken refreshTokenToAccessToken = refreshTokenToAccessTokenRepository.findOne(tokenValue);
if (refreshTokenToAccessToken != null) {
String accessTokenKey = refreshTokenToAccessToken.getAccessTokenKey();
AccessToken accessToken = accessTokenRepository.findOne(accessTokenKey);
String jsonOAuth2AccessToken = accessToken.getoAuth2AccessToken();
OAuth2AccessToken oAuth2AccessToken = OAuthUtil.deserializeOAuth2AccessToken(jsonOAuth2AccessToken);
// Delete access token from all related tables
List<RegularStatement> statementList = prepareRemoveAccessTokenStatements(oAuth2AccessToken);
// Delete from RefreshTokenToAccessToken table
Delete refreshTokenToAccessTokenDelete = CassandraTemplate.createDeleteQuery(RefreshTokenToAccessToken.TABLE, refreshTokenToAccessToken, null, cassandraTemplate.getConverter());
statementList.add(refreshTokenToAccessTokenDelete);
Batch batch = QueryBuilder.batch(statementList.toArray(new RegularStatement[statementList.size()]));
cassandraTemplate.execute(batch);
}
}
示例2: createRefreshTokenCookie
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
/**
* Create a cookie out of the given refresh token.
* Refresh token cookies contain the base64 encoded refresh token (a JWT token).
* They also contain a hint whether the refresh token was for remember me or not.
* If not, then the cookie will be prefixed by the timestamp it was created at followed by a pipe '|'.
* This gives us the chance to expire session cookies regardless of the token duration.
*/
private Cookie createRefreshTokenCookie(OAuth2RefreshToken refreshToken, boolean rememberMe) {
int maxAge = -1;
String name = SESSION_TOKEN_COOKIE;
String value = refreshToken.getValue();
if (rememberMe) {
name = REFRESH_TOKEN_COOKIE;
//get expiration in seconds from the token's "exp" claim
Integer exp = getClaim(refreshToken.getValue(), AccessTokenConverter.EXP, Integer.class);
if (exp != null) {
int now = (int) (System.currentTimeMillis() / 1000L);
maxAge = exp - now;
log.debug("refresh token valid for another {} secs", maxAge);
//let cookie expire a bit earlier than the token to avoid race conditions
maxAge -= REFRESH_TOKEN_EXPIRATION_WINDOW_SECS;
}
}
Cookie refreshTokenCookie = new Cookie(name, value);
refreshTokenCookie.setMaxAge(maxAge);
return refreshTokenCookie;
}
示例3: removeRefreshToken
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
@Override
public void removeRefreshToken(OAuth2RefreshToken token) {
String tokenValue = token.getValue();
List<RegularStatement> statementList = new ArrayList<RegularStatement>();
// Delete from RefreshToken table
statementList.add(prepareDeleteByPrimaryKeyRegularStatement(RefreshToken.class, tokenValue));
// Delete from RefreshTokenAuthentication table
statementList.add(prepareDeleteByPrimaryKeyRegularStatement(RefreshTokenAuthentication.class, tokenValue));
// Delete from RefreshTokenToAccessToken table
statementList.add(prepareDeleteByPrimaryKeyRegularStatement(RefreshTokenToAccessToken.class, tokenValue));
Batch batch = QueryBuilder.batch(statementList.toArray(new RegularStatement[statementList.size()]));
cassandraTemplate.execute(batch);
}
示例4: convert
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
private io.gravitee.am.repository.oauth2.model.OAuth2RefreshToken convert(OAuth2RefreshToken _oAuth2RefreshToken) {
io.gravitee.am.repository.oauth2.model.OAuth2RefreshToken oAuth2RefreshToken = new io.gravitee.am.repository.oauth2.model.OAuth2RefreshToken(_oAuth2RefreshToken.getValue());
if (_oAuth2RefreshToken instanceof DefaultExpiringOAuth2RefreshToken) {
oAuth2RefreshToken.setExpiration(((DefaultExpiringOAuth2RefreshToken) _oAuth2RefreshToken).getExpiration());
}
return oAuth2RefreshToken;
}
示例5: revokeRefreshToken
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
@Nullable
public String revokeRefreshToken(String tokenValue, Authentication clientAuth) {
OAuth2RefreshToken refreshToken = tokenStore.readRefreshToken(tokenValue);
if (refreshToken != null) {
OAuth2Authentication authToRevoke = tokenStore.readAuthenticationForRefreshToken(refreshToken);
checkIfTokenIsIssuedToClient(clientAuth, authToRevoke);
tokenStore.removeAccessTokenUsingRefreshToken(refreshToken);
tokenStore.removeRefreshToken(refreshToken);
log.debug("Successfully removed refresh token {} (and any associated access token).", refreshToken);
return refreshToken.getValue();
}
log.debug("No refresh token {} found in the token store.", tokenValue);
return null;
}
示例6: OAuth2AuthenticationRefreshToken
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
/**
* Create the refresh token.
*/
public OAuth2AuthenticationRefreshToken(OAuth2RefreshToken oauth2RefreshToken,
OAuth2Authentication authentication) {
this.id = UUID.randomUUID()
.toString();
this.oauth2RefreshToken = oauth2RefreshToken;
this.authentication = authentication;
this.tokenId = oauth2RefreshToken.getValue();
}
示例7: OAuth2AuthenticationRefreshToken
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
public OAuth2AuthenticationRefreshToken(
OAuth2RefreshToken oAuth2RefreshToken,
OAuth2Authentication authentication) {
this.oAuth2RefreshToken = oAuth2RefreshToken;
this.authentication = authentication;
this.tokenId = oAuth2RefreshToken.getValue();
}
示例8: storeRefreshToken
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
@Override
public void storeRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authentication authentication) {
CouchbaseOAuth2RefreshToken couchBaseRefreshToken = new CouchbaseOAuth2RefreshToken(refreshToken.getValue());
couchBaseRefreshToken.setAuthentication(Base64.encodeBase64String(serializeAuthentication(authentication)));
OAuth2AccessToken accessToken = getAccessToken(authentication);
if (accessToken != null) {
couchBaseRefreshToken.setAccessTokenId(accessToken.getValue());
} else {
if (LOG.isInfoEnabled()) {
LOG.info("Failed to find access token for authentication while storing refresh token " + authentication);
}
}
oAuth2RefreshTokenService.save(couchBaseRefreshToken);
}
示例9: removeRefreshToken
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
@Override
public void removeRefreshToken(OAuth2RefreshToken token) {
if (null != token && null != token.getValue()) {
oAuth2RefreshTokenRepository.delete(token.getValue());
}
}
示例10: OAuth2AuthenticationRefreshToken
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
public OAuth2AuthenticationRefreshToken(OAuth2RefreshToken oAuth2RefreshToken, OAuth2Authentication authentication) {
this.id = UUID.randomUUID().toString();
this.oAuth2RefreshToken = oAuth2RefreshToken;
this.authentication = authentication;
this.tokenId = oAuth2RefreshToken.getValue();
}
示例11: setRefreshTokenAsCokie
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
public static void setRefreshTokenAsCokie(HttpServletResponse response, OAuth2RefreshToken token, int expiry) {
Cookie cookie = new Cookie("refreshToken", token.getValue());
cookie.setMaxAge(expiry);
response.addCookie(cookie);
}
示例12: OAuth2AuthenticationRefreshToken
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
public OAuth2AuthenticationRefreshToken(OAuth2RefreshToken oAuth2RefreshToken, OAuth2Authentication authentication) {
this.oAuth2RefreshToken = oAuth2RefreshToken;
this.authentication = authentication;
this.tokenId = oAuth2RefreshToken.getValue();
}
示例13: AuthenticationRefreshToken
import org.springframework.security.oauth2.common.OAuth2RefreshToken; //导入方法依赖的package包/类
/**
* Create a new OAuth2 Refresh Token holder.
*
* @param refreshToken The Refresh Token.
* @param authentication The authentication.
*/
public AuthenticationRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authentication authentication) {
this.refreshToken = refreshToken;
this.authentication = authentication;
this.tokenId = refreshToken.getValue();
}