本文整理汇总了Java中org.apache.oltu.oauth2.common.message.OAuthResponse.getLocationUri方法的典型用法代码示例。如果您正苦于以下问题:Java OAuthResponse.getLocationUri方法的具体用法?Java OAuthResponse.getLocationUri怎么用?Java OAuthResponse.getLocationUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.oltu.oauth2.common.message.OAuthResponse
的用法示例。
在下文中一共展示了OAuthResponse.getLocationUri方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeOAuthQueryResponse
import org.apache.oltu.oauth2.common.message.OAuthResponse; //导入方法依赖的package包/类
public static void writeOAuthQueryResponse(HttpServletResponse response, OAuthResponse oAuthResponse) {
final String locationUri = oAuthResponse.getLocationUri();
try {
final Map<String, String> headers = oAuthResponse.getHeaders();
for (String key : headers.keySet()) {
response.addHeader(key, headers.get(key));
}
response.setStatus(oAuthResponse.getResponseStatus());
response.sendRedirect(locationUri);
} catch (IOException e) {
throw new IllegalStateException("Write OAuthResponse error", e);
}
}
示例2: authorize
import org.apache.oltu.oauth2.common.message.OAuthResponse; //导入方法依赖的package包/类
private String authorize(HttpServletRequest request, String redirectURI, Authentication authentication) throws OAuthSystemException {
User principal = (User) authentication.getPrincipal();
if (hasAuthorized(principal)) {
// 生成code
String code = new OAuthIssuerImpl(new MD5Generator()).authorizationCode();
// 把授权码存入
oAuth2Service.addCode(code, principal.getOpenId());
// 构建oauth2授权返回信息
OAuthResponse oauthResponse = OAuthASResponse
.authorizationResponse(request, HttpServletResponse.SC_FOUND)
.setCode(code)
.location(redirectURI)
.buildQueryMessage();
return "redirect:" + oauthResponse.getLocationUri();
} else {
return "oauth2/authorize";
}
}