当前位置: 首页>>代码示例>>Java>>正文


Java OAuthAuthzRequest类代码示例

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


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

示例1: __parseResponseType

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的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

示例2: buildErrorResponse

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
private Response buildErrorResponse(OAuthProblemException e, OAuthAuthzRequest oAuthRequest, String redirectURI)
    throws OAuthSystemException, URISyntaxException {
  boolean canRedirect = !Strings.isNullOrEmpty(redirectURI);
  OAuthASResponse.OAuthErrorResponseBuilder builder = OAuthASResponse
      .errorResponse(canRedirect ? HttpServletResponse.SC_FOUND : HttpServletResponse.SC_BAD_REQUEST).error(e);
  setState(builder, oAuthRequest);
  OAuthResponse response;

  if(canRedirect) {
    builder.location(redirectURI);
    response = builder.buildQueryMessage();
    return Response.status(response.getResponseStatus()).location(new URI(response.getLocationUri())).build();
  } else {
    response = builder.buildJSONMessage();
    return Response.status(response.getResponseStatus()).entity(response.getBody()).build();
  }
}
 
开发者ID:obiba,项目名称:agate,代码行数:18,代码来源:OAuthResource.java

示例3: processOAuthRequest

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
/**
 * process new OAuth request
 * 
 * @param request
 *          HTTP request
 * @param response
 *          HTTP response
 * @return always return false
 * @throws IOException
 *           If an input or output exception occurs
 * @throws OAuthSystemException
 *           If an OAuth system exception occurs
 * @throws OAuthProblemException
 *           If an OAuth problem exception occurs
 */
protected boolean processOAuthRequest(HttpServletRequest request, HttpServletResponse response)
    throws IOException, OAuthProblemException, OAuthSystemException {
  I18N i18n = new I18N(request.getLocale());
  OAuthAuthzRequest oAuthRequest = new OAuthAuthzRequest(request);
  String clientId = oAuthRequest.getClientId();
  String redirectURI = oAuthRequest.getRedirectURI();
  // check client id
  if (!oAuthService.checkClient(clientId))
    return ResponseUtils.processResponse(response, redirectURI,
        ResponseUtils.responseInvalidClient(i18n.getString("INVALID_CLIENT_ID")));
  // check response type
  String responseType = oAuthRequest.getResponseType();
  if (!ResponseType.CODE.toString().equals(responseType))
    return ResponseUtils.processResponse(response, redirectURI,
        ResponseUtils.responseInvalidRequest(i18n.getString("UNSUPPORT_RESP_TYPE")));
  // check scopes
  Set<String> scopes = oAuthRequest.getScopes();
  if (scopes.isEmpty() && oAuthService.scopeRequired(clientId))
    return ResponseUtils.processResponse(response, redirectURI,
        ResponseUtils.responseInvalidScope(i18n.getString("SCOPE_REQUIRED")));
  for (String scope : scopes) {
    if (!oAuthService.checkScope(clientId, scope))
      return ResponseUtils.processResponse(response, redirectURI,
          ResponseUtils.responseInvalidScope(i18n.getString("INVALID_SCOPE") + " " + scope));
  }
  // determine whether need confirmation or not
  String confirmationURI = oAuthService.confirmationURI(clientId, scopes);
  if (!OAuthUtils.isEmpty(confirmationURI))
    return redirectToConfirmation(request, response, oAuthRequest, confirmationURI);
  // generate authorization code and redirect back
  return generateAuthorizationCode(request, response, new SavedOAuthRequest(oAuthRequest));
}
 
开发者ID:hawkxu,项目名称:shiro-oltu,代码行数:48,代码来源:AuthorizeFilter.java

示例4: SavedOAuthRequest

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
public SavedOAuthRequest(OAuthAuthzRequest oAuthRequest) {
  confirmKey = UUID.randomUUID().toString();
  clientId = oAuthRequest.getClientId();
  state = oAuthRequest.getState();
  scopes = oAuthRequest.getScopes();
  redirectURI = oAuthRequest.getRedirectURI();
}
 
开发者ID:hawkxu,项目名称:shiro-oltu,代码行数:8,代码来源:AuthorizeFilter.java

示例5: executeGet

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
@RequestMapping(value = "auth", method = RequestMethod.GET)
@ResponseBody
public String executeGet(HttpServletRequest request, HttpServletResponse response, HttpSession session)
    throws OAuthSystemException, IOException {
    OAuthResponse resp = null;
    try {
        // dynamically recognize an OAuth profile based on request
        // characteristic (params,
        // method, content type etc.), perform validation
        OAuthAuthzRequest oauthRequest = new OAuthAuthzRequest(request);

        if (appService.checkExist(oauthRequest.getClientId())) {
            String username = request.getParameter("username");
            String passwd = request.getParameter("password");
            if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(passwd)) {
                User user = null;
                if ((user = userService.findByEmail(username)) != null && user.getPassword().equals(passwd)) {
                    String code = oauthIssuerImpl.authorizationCode();
                    // build OAuth response
                    resp = OAuthASResponse.authorizationResponse(request, HttpServletResponse.SC_FOUND)
                        .setCode(code).location(oauthRequest.getRedirectURI()).buildJSONMessage();
                    codeMap.put(code, user);
                } else {
                    throw OAuthProblemException.error("username or password is incorrect");
                }
            } else {
                throw OAuthProblemException.error("username or password is blank");
            }

        } else {
            throw OAuthProblemException.error("App key is invalid");
        }
    } catch (OAuthProblemException ex) {
        resp = OAuthASResponse.errorResponse(HttpServletResponse.SC_FOUND).error(ex).buildJSONMessage();

    }
    return resp.getBody();
}
 
开发者ID:mba811,项目名称:loli.io,代码行数:39,代码来源:AuthServer.java

示例6: setState

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
/**
 * Set the state parameter if any was defined in the request into the response.
 *
 * @param builder
 * @param oAuthRequest
 */
private void setState(OAuthResponse.OAuthResponseBuilder builder, OAuthAuthzRequest oAuthRequest) {
  if(oAuthRequest == null) return;
  String state = oAuthRequest.getState();
  if(!Strings.isNullOrEmpty(state)) {
    builder.setParam(OAuth.OAUTH_STATE, state);
  }
}
 
开发者ID:obiba,项目名称:agate,代码行数:14,代码来源:OAuthResource.java

示例7: CodeClientDetailsValidator

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
public CodeClientDetailsValidator(OAuthAuthzRequest oauthRequest) {
    super(oauthRequest);
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:4,代码来源:CodeClientDetailsValidator.java

示例8: getState

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
private String getState() {
    return ((OAuthAuthzRequest) oauthRequest).getState();
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:4,代码来源:CodeClientDetailsValidator.java

示例9: TokenClientDetailsValidator

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
public TokenClientDetailsValidator(OAuthAuthzRequest oauthRequest) {
    this(oauthRequest, true);
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:4,代码来源:TokenClientDetailsValidator.java

示例10: TokenClientDetailsValidator

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
public TokenClientDetailsValidator(OAuthAuthzRequest oauthRequest) {
    super(oauthRequest);
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro-redis,代码行数:4,代码来源:TokenClientDetailsValidator.java

示例11: OAuthRequestData

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
public OAuthRequestData(String clientId, String redirectUri, OAuthAuthzRequest request) {
  this.redirectUri = redirectUri;
  this.clientId = clientId;
  this.request = request;
}
 
开发者ID:obiba,项目名称:agate,代码行数:6,代码来源:OAuthResource.java

示例12: getRequest

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
public OAuthAuthzRequest getRequest() {
  return request;
}
 
开发者ID:obiba,项目名称:agate,代码行数:4,代码来源:OAuthResource.java

示例13: setRequest

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
public void setRequest(OAuthAuthzRequest request) {
  this.request = request;
}
 
开发者ID:obiba,项目名称:agate,代码行数:4,代码来源:OAuthResource.java

示例14: redirectToConfirmation

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
/**
 * redirect to confirmation page
 * 
 * @param request
 *          HTTP request
 * @param response
 *          HTTP response
 * @param oAuthRequest
 *          OAuth request
 * @param confirmURI
 *          confirm URI
 * @return always return false
 * @throws IOException
 *           If an input or output exception occurs
 */
protected boolean redirectToConfirmation(HttpServletRequest request, HttpServletResponse response,
    OAuthAuthzRequest oAuthRequest, String confirmURI) throws IOException {
  saveOAuthRequest(oAuthRequest);
  SavedOAuthRequest savedRequest = readSavedRequest();
  Map<String, String> parameters = new HashMap<String, String>();
  parameters.put(OAuthService.CONFIRM_KEY, savedRequest.confirmKey);
  parameters.put(OAuth.OAUTH_CLIENT_ID, oAuthRequest.getClientId());
  parameters.put(OAuth.OAUTH_SCOPE, oAuthRequest.getParam(OAuth.OAUTH_SCOPE));
  parameters.put(OAuth.OAUTH_REDIRECT_URI, request.getRequestURI());
  WebUtils.issueRedirect(request, response, confirmURI, parameters);
  return false;
}
 
开发者ID:hawkxu,项目名称:shiro-oltu,代码行数:28,代码来源:AuthorizeFilter.java

示例15: saveOAuthRequest

import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest; //导入依赖的package包/类
/**
 * Save OAuth request
 * 
 * @param oAuthRequest
 *          OAuth request
 */
protected void saveOAuthRequest(OAuthAuthzRequest oAuthRequest) {
  Session session = SecurityUtils.getSubject().getSession();
  SavedOAuthRequest saved = new SavedOAuthRequest(oAuthRequest);
  session.setAttribute(SAVED_OAUTH_REQUEST_KEY, saved);
}
 
开发者ID:hawkxu,项目名称:shiro-oltu,代码行数:12,代码来源:AuthorizeFilter.java


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