當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultOAuth2AccessToken.valueOf方法代碼示例

本文整理匯總了Java中org.springframework.security.oauth2.common.DefaultOAuth2AccessToken.valueOf方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultOAuth2AccessToken.valueOf方法的具體用法?Java DefaultOAuth2AccessToken.valueOf怎麽用?Java DefaultOAuth2AccessToken.valueOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.security.oauth2.common.DefaultOAuth2AccessToken的用法示例。


在下文中一共展示了DefaultOAuth2AccessToken.valueOf方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refreshAccessToken

import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
private OAuth2AccessToken refreshAccessToken(String refreshToken) {

		MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>();
		formData.add("grant_type", "refresh_token");
		formData.add("client_id", "my-trusted-client");
		formData.add("refresh_token", refreshToken);

		@SuppressWarnings("rawtypes")
		ResponseEntity<Map> response = serverRunning.postForMap("/sparklr2/oauth/token", formData);
		assertEquals(HttpStatus.OK, response.getStatusCode());
		assertTrue("Wrong cache control: " + response.getHeaders().getFirst("Cache-Control"), response.getHeaders().getFirst("Cache-Control").contains("no-store"));
		@SuppressWarnings("unchecked")
		OAuth2AccessToken newAccessToken = DefaultOAuth2AccessToken.valueOf(response.getBody());
		return newAccessToken;

	}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:17,代碼來源:RefreshTokenSupportTests.java

示例2: read

import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
@Override
public OAuth2AccessToken read(Type type, Class<?> contextClass, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
    Charset charset = getContentTypeCharset(inputMessage.getHeaders().getContentType());
    String tokenResult = StreamUtils.copyToString(inputMessage.getBody(), charset);
    log.info("tokenResult:{}", tokenResult);
    String[] results = tokenResult.split("&");
    if (results.length == 3) {
        Map<String, String> tokenParams = new HashMap<>();
        tokenParams.put(ACCESS_TOKEN, results[0].replace("access_token=", ""));
        tokenParams.put(EXPIRES_IN, results[1].replace("expires_in=", ""));
        tokenParams.put(REFRESH_TOKEN, results[2].replace("refresh_token=", ""));
        return DefaultOAuth2AccessToken.valueOf(tokenParams);
    }
    return null;
}
 
開發者ID:helloworldtang,項目名稱:sns-todo,代碼行數:16,代碼來源:QQTokenHttpMessageConverter.java

示例3: interceptCall

import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
      ServerCall<ReqT, RespT> call,
      final Metadata requestHeaders,
      ServerCallHandler<ReqT, RespT> next) {
    String token = requestHeaders.get(authKey);
    String principal = null;
    if (StringUtils.isEmpty(token))
    {
        logger.warn("Failed to find token");
    }
    else
    {
        Map<String,String> tokenParams = new HashMap<>();
        tokenParams.put(OAuth2AccessToken.ACCESS_TOKEN,token);
        OAuth2AccessToken otoken = DefaultOAuth2AccessToken.valueOf(tokenParams);
        OAuth2Authentication auth = server.getTokenStore().readAuthentication(otoken);
        if (auth != null && auth.isAuthenticated())
        {
            logger.debug("Principal:"+auth.getPrincipal());
            principal = auth.getPrincipal().toString();
        }
        else
        {
            logger.warn("Failed to authenticate token "+token);
        }
    }
    return new MessagePrincipalListener<ReqT>(next.startCall(call, requestHeaders),principal,server);
  }
 
開發者ID:SeldonIO,項目名稱:seldon-core,代碼行數:30,代碼來源:HeaderServerInterceptor.java

示例4: extractData

import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
public OAuth2AccessToken extractData(ClientHttpResponse response) throws IOException {
	// TODO: this should actually be a 401 if the request asked for JSON
	URI location = response.getHeaders().getLocation();
	if (location == null) {
		return null;
	}
	String fragment = location.getFragment();
	OAuth2AccessToken accessToken = DefaultOAuth2AccessToken.valueOf(OAuth2Utils.extractMap(fragment));
	if (accessToken.getValue() == null) {
		throw new UserRedirectRequiredException(location.toString(), Collections.<String, String> emptyMap());
	}

	return accessToken;
}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:15,代碼來源:ImplicitAccessTokenProvider.java

示例5: getAccessToken

import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
private OAuth2AccessToken getAccessToken(String scope, String clientId) throws Exception {
	MultiValueMap<String, String> formData = getTokenFormData(scope, clientId);

	@SuppressWarnings("rawtypes")
	ResponseEntity<Map> response = serverRunning.postForMap("/sparklr2/oauth/token", formData);
	assertEquals(HttpStatus.OK, response.getStatusCode());
	assertTrue("Wrong cache control: " + response.getHeaders().getFirst("Cache-Control"), response.getHeaders().getFirst("Cache-Control").contains("no-store"));

	@SuppressWarnings("unchecked")
	OAuth2AccessToken accessToken = DefaultOAuth2AccessToken.valueOf(response.getBody());
	return accessToken;
}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:13,代碼來源:RefreshTokenSupportTests.java

示例6: readInternal

import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; //導入方法依賴的package包/類
@Override
protected OAuth2AccessToken readInternal(Class<? extends OAuth2AccessToken> clazz, HttpInputMessage inputMessage)
		throws IOException, HttpMessageNotReadableException {
	MultiValueMap<String, String> data = delegateMessageConverter.read(null, inputMessage);
	return DefaultOAuth2AccessToken.valueOf(data.toSingleValueMap());
}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:7,代碼來源:FormOAuth2AccessTokenMessageConverter.java


注:本文中的org.springframework.security.oauth2.common.DefaultOAuth2AccessToken.valueOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。