本文整理汇总了Java中org.apache.oltu.oauth2.client.response.OAuthClientResponse类的典型用法代码示例。如果您正苦于以下问题:Java OAuthClientResponse类的具体用法?Java OAuthClientResponse怎么用?Java OAuthClientResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OAuthClientResponse类属于org.apache.oltu.oauth2.client.response包,在下文中一共展示了OAuthClientResponse类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
String requestMethod, Class<T> responseClass)
throws OAuthSystemException, OAuthProblemException {
MediaType mediaType = MediaType.parse("application/json");
Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());
if(headers != null) {
for (Entry<String, String> entry : headers.entrySet()) {
if (entry.getKey().equalsIgnoreCase("Content-Type")) {
mediaType = MediaType.parse(entry.getValue());
} else {
requestBuilder.addHeader(entry.getKey(), entry.getValue());
}
}
}
RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
requestBuilder.method(requestMethod, body);
try {
Response response = client.newCall(requestBuilder.build()).execute();
return OAuthClientResponseFactory.createCustomResponse(
response.body().string(),
response.body().contentType().toString(),
response.code(),
responseClass);
} catch (IOException e) {
throw new OAuthSystemException(e);
}
}
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:32,代码来源:OAuthOkHttpClient.java
示例2: execute
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
String requestMethod, Class<T> responseClass)
throws OAuthSystemException, OAuthProblemException {
MediaType mediaType = MediaType.parse("application/json");
Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());
if(headers != null) {
for (Entry<String, String> entry : headers.entrySet()) {
if (entry.getKey().equalsIgnoreCase("Content-Type")) {
mediaType = MediaType.parse(entry.getValue());
} else {
requestBuilder.addHeader(entry.getKey(), entry.getValue());
}
}
}
RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
requestBuilder.method(requestMethod, body);
// try {
// Response response = client.newCall(requestBuilder.build()).execute();
// return OAuthClientResponseFactory.createCustomResponse(
// response.body().string(),
// response.body().contentType().toString(),
// response.code(),
// responseClass);
// } catch (IOException e) {
// throw new OAuthSystemException(e);
// }
return null; // FIXME: Oauth should be tested
}
开发者ID:amardeshbd,项目名称:medium-api-android-sample,代码行数:33,代码来源:OAuthOkHttpClient.java
示例3: execute
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
String requestMethod, Class<T> responseClass)
throws OAuthSystemException, OAuthProblemException {
MediaType mediaType = MediaType.parse("application/json");
Builder requestBuilder = new Builder().url(request.getLocationUri());
if(headers != null) {
for (Entry<String, String> entry : headers.entrySet()) {
if (entry.getKey().equalsIgnoreCase("Content-Type")) {
mediaType = MediaType.parse(entry.getValue());
} else {
requestBuilder.addHeader(entry.getKey(), entry.getValue());
}
}
}
RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
requestBuilder.method(requestMethod, body);
try {
Response response = client.newCall(requestBuilder.build()).execute();
return OAuthClientResponseFactory.createCustomResponse(
response.body().string(),
response.body().contentType().toString(),
response.code(),
responseClass);
} catch (IOException e) {
throw new OAuthSystemException(e);
}
}
开发者ID:hardsky,项目名称:lucky-calories,代码行数:32,代码来源:OAuthOkHttpClient.java
示例4: getUserInfoEndpoint
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
/**
* Get the user info endpoint.
*
* @param token OAuth client response.
* @return User info endpoint.
*/
@Override
protected String getUserInfoEndpoint(OAuthClientResponse token, Map<String, String> authenticatorProperties) {
String userGUID = token.getParam(YahooOAuth2AuthenticatorConstants.USER_GUID);
return getUserInfoURL() + userGUID + YahooOAuth2AuthenticatorConstants.YAHOO_USER_DETAILS_JSON;
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:13,代码来源:YahooOAuth2Authenticator.java
示例5: getAuthenticateUser
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
@Override
protected String getAuthenticateUser(AuthenticationContext context, Map<String, Object> jsonObject, OAuthClientResponse token) {
if (jsonObject.get(OIDCAuthenticatorConstants.Claim.EMAIL) == null) {
return (String) jsonObject.get("sub");
} else {
return (String) jsonObject.get(OIDCAuthenticatorConstants.Claim.EMAIL);
}
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:9,代码来源:GoogleOAuth2Authenticator.java
示例6: getUserInfoEndpoint
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
/**
*
* @return userInfoEndpoint
*/
@Override
protected String getUserInfoEndpoint(OAuthClientResponse token, Map<String, String> authenticatorProperties) {
if (StringUtils.isBlank(this.userInfoEndpoint)) {
initUserInfoEndPoint();
}
return this.userInfoEndpoint;
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:14,代码来源:WindowsLiveOAuth2Authenticator.java
示例7: validate
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
@Override
public void validate(OAuthClientResponse response) throws OAuthProblemException {
if (response instanceof OAuthResResponse)
validateResouceResponse((OAuthResResponse) response);
}
开发者ID:hawkxu,项目名称:shiro-oltu,代码行数:6,代码来源:OAuthResValidator.java
示例8: getSubjectAttributes
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
/**
* Get subject attributes.
* @param token OAuthClientResponse
* @param authenticatorProperties Map<String, String> (Authenticator property, Property value)
* @return Map<ClaimMapping, String> Claim mappings.
*/
protected Map<ClaimMapping, String> getSubjectAttributes(OAuthClientResponse token,
Map<String, String> authenticatorProperties) {
Map<ClaimMapping, String> claims = new HashMap<>();
try {
String accessToken = token.getParam(OIDCAuthenticatorConstants.ACCESS_TOKEN);
String url = getUserInfoEndpoint(token, authenticatorProperties);
String json = sendRequest(url, accessToken);
if (StringUtils.isBlank(json)) {
if(log.isDebugEnabled()) {
log.debug("Empty JSON response from user info endpoint. Unable to fetch user claims." +
" Proceeding without user claims");
}
return claims;
}
Map<String, Object> jsonObject = JSONUtils.parseJSON(json);
for (Map.Entry<String, Object> data : jsonObject.entrySet()) {
String key = data.getKey();
Object value = data.getValue();
if (value != null) {
claims.put(ClaimMapping.build(key, key, null, false), value.toString());
}
if (log.isDebugEnabled() &&
IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_CLAIMS)) {
log.debug("Adding claims from end-point data mapping : " + key + " - " +
jsonObject.get(key).toString());
}
}
} catch (IOException e) {
log.error("Communication error occurred while accessing user info endpoint", e);
}
return claims;
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:47,代码来源:OpenIDConnectAuthenticator.java
示例9: getSubjectAttributes
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
/**
* Get subject attributes.
*
* @param token OAuthClientResponse
* @param authenticatorProperties Map<String, String>
* @return Map<ClaimMapping, String> Claim mappings.
*/
protected Map<ClaimMapping, String> getSubjectAttributes(OAuthClientResponse token,
Map<String, String> authenticatorProperties) {
Map<ClaimMapping, String> claims = new HashMap<>();
try {
String accessToken = token.getParam(OIDCAuthenticatorConstants.ACCESS_TOKEN);
String url = getUserInfoEndpoint(token, authenticatorProperties);
String json = sendRequest(url, accessToken);
if (StringUtils.isBlank(json)) {
if (log.isDebugEnabled()) {
log.debug("Unable to fetch user claims. Proceeding without user claims");
}
return claims;
}
Map<String, Object> jsonObject = JSONUtils.parseJSON(json);
Map<String, Object> profile = null;
if (!jsonObject.isEmpty()) {
// Extract the inner profile JSON object.
profile = JSONUtils.parseJSON(jsonObject.entrySet().iterator().next().getValue().toString());
}
if (profile == null) {
if (log.isDebugEnabled()) {
log.debug("Invalid user profile object. Proceeding without user claims");
}
return claims;
}
for (Map.Entry<String, Object> data : profile.entrySet()) {
String key = data.getKey();
claims.put(ClaimMapping.build(key, key, null, false), profile.get(key).toString());
if (log.isDebugEnabled()
&& IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_CLAIMS)) {
log.debug("Adding claims from end-point data mapping : " + key + " - " +
profile.get(key).toString());
}
}
} catch (IOException e) {
log.error("Communication error occurred while accessing user info endpoint", e);
}
return claims;
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:56,代码来源:YahooOAuth2Authenticator.java
示例10: getAuthenticateUser
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
/**
* @param token
* @return
*/
@Override
protected String getAuthenticateUser(AuthenticationContext context, Map<String, Object> jsonObject, OAuthClientResponse token) {
return token.getParam(WindowsLiveOAuth2AuthenticatorConstants.USER_ID);
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:9,代码来源:WindowsLiveOAuth2Authenticator.java
示例11: getAuthenticateUser
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
/**
*
* @param context
* @param jsonObject
* @param token
* @return
*/
protected String getAuthenticateUser(AuthenticationContext context, Map<String, Object> jsonObject,OAuthClientResponse token) {
return (String) jsonObject.get("sub");
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:12,代码来源:OpenIDConnectAuthenticator.java
示例12: getUserInfoEndpoint
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
/**
* Get user info endpoint.
* @param token OAuthClientResponse
* @param authenticatorProperties Map<String, String> (Authenticator property, Property value)
* @return User info endpoint.
*/
protected String getUserInfoEndpoint(OAuthClientResponse token, Map<String, String> authenticatorProperties) {
return authenticatorProperties.get(IdentityApplicationConstants.Authenticator.OIDC.USER_INFO_URL);
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:10,代码来源:OpenIDConnectAuthenticator.java
示例13: getAuthenticateUser
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
/**
* Get Authenticated User
*
* @param token OAuth client response.
* @return GUID of the authenticated user.
*/
@Override
protected String getAuthenticateUser(AuthenticationContext context, Map<String, Object> jsonObject, OAuthClientResponse token) {
return token.getParam(YahooOAuth2AuthenticatorConstants.USER_GUID);
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:12,代码来源:YahooOAuth2Authenticator.java
示例14: getUserInfoEndpoint
import org.apache.oltu.oauth2.client.response.OAuthClientResponse; //导入依赖的package包/类
/**
* Get google user info endpoint.
* @param token OAuth client response.
* @return User info endpoint.
*/
@Override
protected String getUserInfoEndpoint(OAuthClientResponse token, Map<String, String> authenticatorProperties) {
return getUserInfoURL();
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:10,代码来源:GoogleOAuth2Authenticator.java
注:本文中的org.apache.oltu.oauth2.client.response.OAuthClientResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论