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