本文整理汇总了Java中org.apache.oltu.oauth2.rs.request.OAuthAccessResourceRequest类的典型用法代码示例。如果您正苦于以下问题:Java OAuthAccessResourceRequest类的具体用法?Java OAuthAccessResourceRequest怎么用?Java OAuthAccessResourceRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OAuthAccessResourceRequest类属于org.apache.oltu.oauth2.rs.request包,在下文中一共展示了OAuthAccessResourceRequest类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: CheckAccessToken
import org.apache.oltu.oauth2.rs.request.OAuthAccessResourceRequest; //导入依赖的package包/类
protected boolean CheckAccessToken(HttpServletRequest request, HttpServletResponse response)
throws IOException, OAuthSystemException {
try {
String accessToken = new OAuthAccessResourceRequest(request).getAccessToken();
if (oAuthService.checkAccessToken(accessToken, request))
return true;
// because OLTU client not process error in response header
// so still send JSON data back, the client need process this error
I18N i18n = new I18N(request.getLocale());
return ResponseUtils.processResponse(response, null,
ResponseUtils.responseInvalidToken(i18n.getString("INVALID_TOKEN")));
} catch (OAuthProblemException ex) {
if (OAuthUtils.isEmpty(ex.getError()))
return ResponseUtils.processResponse(response, null,
ResponseUtils.responseInvalidRequest(ex.getDescription()));
return ResponseUtils.processResponse(response, null,
OAuthRSResponse.errorResponse(HttpServletResponse.SC_UNAUTHORIZED).error(ex));
}
}
开发者ID:hawkxu,项目名称:shiro-oltu,代码行数:20,代码来源:ResourceFilter.java
示例2: doFilter
import org.apache.oltu.oauth2.rs.request.OAuthAccessResourceRequest; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
try {
// Make an OAuth Request out of this servlet request
OAuthAccessResourceRequest oauthRequest = new OAuthAccessResourceRequest(req,
parameterStyles);
// Get the access token
String accessToken = oauthRequest.getAccessToken();
final OAuthDecision decision = provider.validateRequest(realm, accessToken, req);
final Principal principal = decision.getPrincipal();
HttpServletRequest newRequest = new HttpServletRequestWrapper((HttpServletRequest) request) {
@Override
public String getRemoteUser() {
return principal != null ? principal.getName() : null;
}
@Override
public Principal getUserPrincipal() {
return principal;
}
};
newRequest.setAttribute(OAuth.OAUTH_CLIENT_ID, decision.getOAuthClient().getClientId());
chain.doFilter(newRequest, response);
} catch (OAuthSystemException e1) {
throw new ServletException(e1);
} catch (OAuthProblemException e) {
respondWithError(res, e);
}
}
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:44,代码来源:ResourceOAuthFilter.java
注:本文中的org.apache.oltu.oauth2.rs.request.OAuthAccessResourceRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论