• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java OAuthError类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.oltu.oauth2.common.error.OAuthError的典型用法代码示例。如果您正苦于以下问题:Java OAuthError类的具体用法?Java OAuthError怎么用?Java OAuthError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OAuthError类属于org.apache.oltu.oauth2.common.error包,在下文中一共展示了OAuthError类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onLoginFailure

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
@Override
protected boolean onLoginFailure(AuthenticationToken token, AuthenticationException ae, ServletRequest request,
                                 ServletResponse response) {

    final OAuthResponse oAuthResponse;
    try {
        oAuthResponse = OAuthRSResponse.errorResponse(401)
                .setError(OAuthError.ResourceResponse.INVALID_TOKEN)
                .setErrorDescription(ae.getMessage())
                .buildJSONMessage();

        com.monkeyk.os.web.WebUtils.writeOAuthJsonResponse((HttpServletResponse) response, oAuthResponse);

    } catch (OAuthSystemException e) {
        LOGGER.error("Build JSON message error", e);
        throw new IllegalStateException(e);
    }


    return false;
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:22,代码来源:OAuth2Filter.java


示例2: __parseResponseType

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
private OAuthResponse __parseResponseType(HttpServletRequest request, ResponseType _responseType, IOAuth.IOAuthAuthzHelper _authzHelper, OAuthAuthzRequest _oauthRequest, String _redirectURI, String _scope, String uid, String state) throws Exception {
    OAuthResponse _response;
    switch (_responseType) {
        case CODE:
            _response = OAuthASResponse.authorizationResponse(request, HttpServletResponse.SC_FOUND)
                    .location(_redirectURI)
                    .setCode(_authzHelper.createOrUpdateAuthCode(_redirectURI, _scope).getCode())
                    .setParam(org.apache.oltu.oauth2.common.OAuth.OAUTH_STATE, state)
                    .buildQueryMessage();
            break;
        case TOKEN:
            _response = OAuthResponseUtils.tokenToResponse(OAuth.get().tokenHelper(_oauthRequest.getClientId(), _oauthRequest.getClientSecret(), _oauthRequest.getParam(org.apache.oltu.oauth2.common.OAuth.OAUTH_CODE), uid).createOrUpdateAccessToken(), state);
            break;
        default:
            _response = OAuthResponseUtils.badRequest(OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE);
    }
    return _response;
}
 
开发者ID:suninformation,项目名称:ymate-module-oauth,代码行数:19,代码来源:OAuthSnsController.java


示例3: userinfo

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
/**
 * @param accountToken 网页授权接口调用凭证
 * @param openId       用户的唯一标识
 * @return 返回用户信息 (OAuth2授权需scope=snsapi_userinfo)
 * @throws Exception 可能产生的任何异常
 */
@RequestMapping("/userinfo")
@Before(SnsAccessTokenCheckInterceptor.class)
@ContextParam(@ParamItem(key = IOAuth.Const.SCOPE, value = IOAuth.Scope.SNSAPI_USERINFO))
public IView userinfo(@RequestParam(IOAuth.Const.ACCESS_TOKEN) String accountToken, @RequestParam(IOAuth.Const.OPEN_ID) String openId) throws Exception {
    OAuthResponse _response = null;
    try {
        if (StringUtils.isBlank(openId)) {
            _response = OAuthResponseUtils.badRequest(IOAuth.Const.INVALID_USER);
        }
        IOAuthUserInfoAdapter _adapter = OAuth.get().getModuleCfg().getUserInfoAdapter();
        if (_adapter != null) {
            return View.jsonView(_adapter.getUserInfo(OAuth.get().resourceHelper(accountToken, openId).getOAuthClientUser().getUid()));
        }
        _response = OAuthResponseUtils.unauthorizedClient(OAuthError.ResourceResponse.INVALID_REQUEST);
    } catch (Exception e) {
        _response = OAuthResponseUtils.badRequest(IOAuth.Const.INVALID_USER);
    }
    return new HttpStatusView(_response.getResponseStatus(), false).writeBody(_response.getBody());
}
 
开发者ID:suninformation,项目名称:ymate-module-oauth,代码行数:26,代码来源:OAuthSnsController.java


示例4: responseApprovalDeny

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
protected void responseApprovalDeny() throws IOException, OAuthSystemException {

        final OAuthResponse oAuthResponse = OAuthASResponse.errorResponse(HttpServletResponse.SC_FOUND)
                .setError(OAuthError.CodeResponse.ACCESS_DENIED)
                .setErrorDescription("User denied access")
                .location(clientDetails().getRedirectUri())
                .setState(oauthRequest.getState())
                .buildQueryMessage();
        LOG.debug("'ACCESS_DENIED' response: {}", oAuthResponse);

        WebUtils.writeOAuthQueryResponse(response, oAuthResponse);

        //user logout when deny
        final Subject subject = SecurityUtils.getSubject();
        subject.logout();
        LOG.debug("After 'ACCESS_DENIED' call logout. user: {}", subject.getPrincipal());
    }
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:18,代码来源:AbstractAuthorizeHandler.java


示例5: onLoginFailure

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
@Override
    protected boolean onLoginFailure(AuthenticationToken token, AuthenticationException ae, ServletRequest request,
                                     ServletResponse response) {
//        OAuth2Token oAuth2Token = (OAuth2Token) token;

        final OAuthResponse oAuthResponse;
        try {
            oAuthResponse = OAuthRSResponse.errorResponse(401)
                    .setError(OAuthError.ResourceResponse.INVALID_TOKEN)
                    .setErrorDescription(ae.getMessage())
                    .buildJSONMessage();

            com.monkeyk.os.web.WebUtils.writeOAuthJsonResponse((HttpServletResponse) response, oAuthResponse);

        } catch (OAuthSystemException e) {
            logger.error("Build JSON message error", e);
            throw new IllegalStateException(e);
        }


        return false;
    }
 
开发者ID:monkeyk,项目名称:oauth2-shiro-redis,代码行数:23,代码来源:OAuth2Filter.java


示例6: responseApprovalDeny

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
protected void responseApprovalDeny() throws IOException, OAuthSystemException {

        final OAuthResponse oAuthResponse = OAuthASResponse.errorResponse(HttpServletResponse.SC_FOUND)
                .setError(OAuthError.CodeResponse.ACCESS_DENIED)
                .setErrorDescription("User denied access")
                .location(clientDetails().redirectUri())
                .setState(oauthRequest.getState())
                .buildQueryMessage();
        LOG.debug("'ACCESS_DENIED' response: {}", oAuthResponse);

        WebUtils.writeOAuthQueryResponse(response, oAuthResponse);

        //user logout when deny
        final Subject subject = SecurityUtils.getSubject();
        subject.logout();
        LOG.debug("After 'ACCESS_DENIED' call logout. user: {}", subject.getPrincipal());
    }
 
开发者ID:monkeyk,项目名称:oauth2-shiro-redis,代码行数:18,代码来源:AbstractAuthorizeHandler.java


示例7: oAuthFaileResponse

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
/**
 * oAuth认证失败时的输出
 * @param res
 * @throws OAuthSystemException
 * @throws IOException
 */
private void oAuthFaileResponse(HttpServletResponse res) throws OAuthSystemException, IOException {
    OAuthResponse oauthResponse = OAuthRSResponse
            .errorResponse(HttpServletResponse.SC_UNAUTHORIZED)
            .setRealm(Constants.RESOURCE_SERVER_NAME)
            .setError(OAuthError.ResourceResponse.INVALID_TOKEN)
            .buildHeaderMessage();
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.add("Content-Type", "application/json; charset=utf-8");
    Gson gson = new GsonBuilder().create();
    res.addHeader(OAuth.HeaderType.WWW_AUTHENTICATE, oauthResponse.getHeader(OAuth.HeaderType.WWW_AUTHENTICATE));
    PrintWriter writer = res.getWriter();
    writer.write(gson.toJson(getStatus(HttpStatus.UNAUTHORIZED.value(),Constants.INVALID_ACCESS_TOKEN)));
    writer.flush();
    writer.close();
}
 
开发者ID:xiaomin0322,项目名称:oauth_demo,代码行数:22,代码来源:Oauth2Filter.java


示例8: onAccessDenied

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
@Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response)
    throws Exception {
  String error = request.getParameter(OAuthError.OAUTH_ERROR);
  String description = request.getParameter(OAuthError.OAUTH_ERROR_DESCRIPTION);
  if (!OAuthUtils.isEmpty(error))
    return processAuthorizationError(request, response, error, description);
  if (!OAuthUtils.isEmpty(state) && !state.equals(request.getParameter(OAuth.OAUTH_STATE)))
    return processAuthorizationError(request, response, OAuthError.CodeResponse.SERVER_ERROR,
        "server response state inconsistent with sent state");
  Subject subject = getSubject(request, response);
  if (!subject.isAuthenticated()) {
    if (OAuthUtils.isEmpty(request.getParameter(OAuth.OAUTH_CODE))) {
      saveRequestAndRedirectToLogin(request, response);
      return false;
    }
  }
  return executeLogin(request, response);
}
 
开发者ID:hawkxu,项目名称:shiro-oltu,代码行数:20,代码来源:OAuthAuthenticationFilter.java


示例9: authorize

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
/**
 * authorize by URI, the client must be HTTP session authenticated before
 * OAuth authorization
 * 
 * @param client
 *          HTTP client
 * @return {@link OAuthClientToken} object
 * @throws OAuthSystemException
 *           If an OAuth system exception occurs
 * @throws OAuthProblemException
 *           If an OAuth problem exception occurs
 */
public OAuthClientToken authorize(CloseableHttpClient client)
    throws OAuthSystemException, OAuthProblemException {
  try {
    CloseableHttpResponse response = client.execute(new HttpGet(getQueryURI()));
    try {
      String content = EntityUtils.toString(response.getEntity());
      OAuthAuthzResponse oAuthResponse = new OAuthAuthzResponse();
      oAuthResponse.init(content, null, response.getStatusLine().getStatusCode());
      if (!OAuthUtils.isEmpty(state) && !state.equals(oAuthResponse.getState())) {
        throw OAuthProblemException.error(OAuthError.CodeResponse.SERVER_ERROR,
            "server response state inconsistent with sent state");
      }
      return OAuthClientToken.authCode(oAuthResponse.getCode(), oAuthResponse.getScopes());
    } finally {
      response.close();
    }
  } catch (IOException ex) {
    throw new OAuthSystemException(ex);
  }
}
 
开发者ID:hawkxu,项目名称:shiro-oltu,代码行数:33,代码来源:OAuthAuthzRequester.java


示例10: validateRequest

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
@Override
public String validateRequest(HttpServletRequest request) throws UserInfoEndpointException {

    String schema = request.getParameter("schema");
    String authzHeaders = request.getHeader(HttpHeaders.AUTHORIZATION);

    if (!"openid".equals(schema)) {
        throw new UserInfoEndpointException(UserInfoEndpointException.ERROR_CODE_INVALID_SCHEMA,
                "Schema should be openid");
    }

    if (authzHeaders == null) {
        throw new UserInfoEndpointException(OAuthError.ResourceResponse.INVALID_REQUEST,
                "Authorization header missing");
    }

    String[] authzHeaderInfo = ((String) authzHeaders).trim().split(" ");
    if (!"Bearer".equals(authzHeaderInfo[0])) {
        throw new UserInfoEndpointException(OAuthError.ResourceResponse.INVALID_REQUEST, "Bearer token missing");
    }
    return authzHeaderInfo[1];
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:23,代码来源:UserInforRequestDefaultValidator.java


示例11: handleUnauthorizedException

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
private void handleUnauthorizedException(HttpServletResponse response, Exception ex) {
    OAuthResponse oAuthResponse;
    try {
        oAuthResponse = OAuthRSResponse.errorResponse(403)
                .setError(OAuthError.ResourceResponse.INVALID_TOKEN)
                .setErrorDescription(ex.getMessage())
                .buildJSONMessage();
    } catch (OAuthSystemException e) {
        throw new IllegalStateException(e);
    }

    WebUtils.writeOAuthJsonResponse(response, oAuthResponse);
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:14,代码来源:OAuthShiroHandlerExceptionResolver.java


示例12: respondWithError

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
private void respondWithError(HttpServletResponse resp, OAuthProblemException error)
        throws IOException, ServletException {

    OAuthResponse oauthResponse;

    try {
        if (OAuthUtils.isEmpty(error.getError())) {
            oauthResponse = OAuthRSResponse.errorResponse(HttpServletResponse.SC_UNAUTHORIZED)
                    .setRealm(realm)
                    .buildHeaderMessage();

        } else {

            int responseCode = 401;
            if (error.getError().equals(OAuthError.CodeResponse.INVALID_REQUEST)) {
                responseCode = 400;
            } else if (error.getError().equals(OAuthError.ResourceResponse.INSUFFICIENT_SCOPE)) {
                responseCode = 403;
            }

            oauthResponse = OAuthRSResponse
                    .errorResponse(responseCode)
                    .setRealm(realm)
                    .setError(error.getError())
                    .setErrorDescription(error.getDescription())
                    .setErrorUri(error.getUri())
                    .buildHeaderMessage();
        }
        resp.addHeader(OAuth.HeaderType.WWW_AUTHENTICATE,
                oauthResponse.getHeader(OAuth.HeaderType.WWW_AUTHENTICATE));
        resp.sendError(oauthResponse.getResponseStatus());
    } catch (OAuthSystemException e) {
        throw new ServletException(e);
    }
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:36,代码来源:ResourceOAuthFilter.java


示例13: validateClientDetails

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
private void validateClientDetails(String token, AccessToken accessToken, ClientDetails clientDetails) throws OAuthProblemException {
    if (clientDetails == null || clientDetails.archived()) {
        LOG.debug("Invalid ClientDetails: {} by client_id: {}, it is null or archived", clientDetails, accessToken.clientId());
        throw OAuthProblemException.error(OAuthError.ResourceResponse.INVALID_TOKEN)
                .description("Invalid client by token: " + token);
    }
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:8,代码来源:MkkOAuthRSProvider.java


示例14: validateToken

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
private void validateToken(String token, AccessToken accessToken) throws OAuthProblemException {
    if (accessToken == null) {
        LOG.debug("Invalid access_token: {}, because it is null", token);
        throw OAuthProblemException.error(OAuthError.ResourceResponse.INVALID_TOKEN)
                .description("Invalid access_token: " + token);
    }
    if (accessToken.tokenExpired()) {
        LOG.debug("Invalid access_token: {}, because it is expired", token);
        throw OAuthProblemException.error(OAuthError.ResourceResponse.EXPIRED_TOKEN)
                .description("Expired access_token: " + token);
    }
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:13,代码来源:MkkOAuthRSProvider.java


示例15: unsupportResponseType

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
private void unsupportResponseType(OAuthAuthxRequest oauthRequest, HttpServletResponse response) throws OAuthSystemException {
    final String responseType = oauthRequest.getResponseType();
    LOG.debug("Unsupport response_type '{}' by client_id '{}'", responseType, oauthRequest.getClientId());

    OAuthResponse oAuthResponse = OAuthResponse.errorResponse(HttpServletResponse.SC_BAD_REQUEST)
            .setError(OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE)
            .setErrorDescription("Unsupport response_type '" + responseType + "'")
            .buildJSONMessage();
    WebUtils.writeOAuthJsonResponse(response, oAuthResponse);
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:11,代码来源:OauthAuthorizeController.java


示例16: handleUnauthorizedException

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
private void handleUnauthorizedException(HttpServletResponse response, Exception ex) {
    OAuthResponse oAuthResponse;
    try {
        oAuthResponse = OAuthASResponse.errorResponse(403)
                .setError(OAuthError.ResourceResponse.INVALID_TOKEN)
                .setErrorDescription(ex.getMessage())
                .buildJSONMessage();
    } catch (OAuthSystemException e) {
        throw new IllegalStateException(e);
    }

    WebUtils.writeOAuthJsonResponse(response, oAuthResponse);
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:14,代码来源:OAuthShiroHandlerExceptionResolver.java


示例17: expiredTokenResponse

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
private void expiredTokenResponse(AccessToken accessToken) throws OAuthSystemException {
    final ClientDetails clientDetails = clientDetails();
    LOG.debug("AccessToken {} is expired", accessToken);

    final OAuthResponse oAuthResponse = OAuthASResponse.errorResponse(HttpServletResponse.SC_FOUND)
            .setError(OAuthError.ResourceResponse.EXPIRED_TOKEN)
            .setErrorDescription("access_token '" + accessToken.tokenId() + "' expired")
            .setErrorUri(clientDetails.getRedirectUri())
            .buildJSONMessage();

    WebUtils.writeOAuthJsonResponse(response, oAuthResponse);
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:13,代码来源:TokenAuthorizeHandler.java


示例18: expiredTokenResponse

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
private void expiredTokenResponse(AccessToken accessToken) throws OAuthSystemException {
    final ClientDetails clientDetails = clientDetails();
    LOG.debug("AccessToken {} is expired", accessToken);

    final OAuthResponse oAuthResponse = OAuthASResponse.errorResponse(HttpServletResponse.SC_FOUND)
            .setError(OAuthError.ResourceResponse.EXPIRED_TOKEN)
            .setErrorDescription("access_token '" + accessToken.tokenId() + "' expired")
            .setErrorUri(clientDetails.redirectUri())
            .buildJSONMessage();

    WebUtils.writeOAuthJsonResponse(response, oAuthResponse);
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro-redis,代码行数:13,代码来源:TokenAuthorizeHandler.java


示例19: buildInvalidClientResponse

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
private Response buildInvalidClientResponse() throws OAuthSystemException {
    OAuthResponse response =
            OAuthASResponse.errorResponse(HttpServletResponse.SC_BAD_REQUEST)
                    .setError(OAuthError.TokenResponse.INVALID_CLIENT)
                    .setErrorDescription(INVALID_CLIENT_DESCRIPTION)
                    .buildJSONMessage();
    return Response.status(response.getResponseStatus()).entity(response.getBody()).build();
}
 
开发者ID:SECQME,项目名称:watchoverme-server,代码行数:9,代码来源:OAuthResource.java


示例20: buildUnauthorizedClient

import org.apache.oltu.oauth2.common.error.OAuthError; //导入依赖的package包/类
private Response buildUnauthorizedClient() throws OAuthSystemException {
    OAuthResponse response =
            OAuthASResponse.errorResponse(HttpServletResponse.SC_UNAUTHORIZED)
                    .setError(OAuthError.TokenResponse.UNAUTHORIZED_CLIENT)
                    .setErrorDescription(INVALID_CLIENT_DESCRIPTION)
                    .buildJSONMessage();
    return Response.status(response.getResponseStatus()).entity(response.getBody()).build();
}
 
开发者ID:SECQME,项目名称:watchoverme-server,代码行数:9,代码来源:OAuthResource.java



注:本文中的org.apache.oltu.oauth2.common.error.OAuthError类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TaggedProfile类代码示例发布时间:2022-05-22
下一篇:
Java TaskAttemptDiagnosticsUpdateEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap