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


Java OAuthUtils.writeTextError方法代码示例

本文整理汇总了Java中org.jasig.cas.support.oauth.OAuthUtils.writeTextError方法的典型用法代码示例。如果您正苦于以下问题:Java OAuthUtils.writeTextError方法的具体用法?Java OAuthUtils.writeTextError怎么用?Java OAuthUtils.writeTextError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jasig.cas.support.oauth.OAuthUtils的用法示例。


在下文中一共展示了OAuthUtils.writeTextError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: internalHandleRequest

import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView internalHandleRequest(final String method, final HttpServletRequest request,
        final HttpServletResponse response) throws Exception {

    // authorize
    if (OAuthConstants.AUTHORIZE_URL.equals(method)) {
        return authorizeController.handleRequest(request, response);
    }
    // callback on authorize
    if (OAuthConstants.CALLBACK_AUTHORIZE_URL.equals(method)) {
        return callbackAuthorizeController.handleRequest(request, response);
    }
    //get access token
    if (OAuthConstants.ACCESS_TOKEN_URL.equals(method)) {
        return accessTokenController.handleRequest(request, response);
    }
    // get profile
    if (OAuthConstants.PROFILE_URL.equals(method)) {
        return profileController.handleRequest(request, response);
    }

    // else error
    logger.error("Unknown method : {}", method);
    OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, HttpStatus.SC_OK);
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:OAuth20WrapperController.java

示例2: internalHandleRequest

import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView internalHandleRequest(final String method, final HttpServletRequest request,
        final HttpServletResponse response) throws Exception {

    // authorize
    if (OAuthConstants.AUTHORIZE_URL.equals(method)) {
        return authorizeController.handleRequest(request, response);
    }
    // callback on authorize
    if (OAuthConstants.CALLBACK_AUTHORIZE_URL.equals(method)) {
        return callbackAuthorizeController.handleRequest(request, response);
    }
    //get access token
    if (OAuthConstants.ACCESS_TOKEN_URL.equals(method)) {
        return accessTokenController.handleRequest(request, response);
    }
    // get profile
    if (OAuthConstants.PROFILE_URL.equals(method)) {
        return profileController.handleRequest(request, response);
    }

    // else error
    logger.error("Unknown method : {}", method);
    OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, 200);
    return null;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:27,代码来源:OAuth20WrapperController.java

示例3: handleRequestInternal

import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {

    final String redirectUri = request.getParameter(OAuthConstants.REDIRECT_URI);
    LOGGER.debug("{} : {}", OAuthConstants.REDIRECT_URI, redirectUri);

    final String clientId = request.getParameter(OAuthConstants.CLIENT_ID);
    LOGGER.debug("{} : {}", OAuthConstants.CLIENT_ID, clientId);

    final String clientSecret = request.getParameter(OAuthConstants.CLIENT_SECRET);

    final String code = request.getParameter(OAuthConstants.CODE);
    LOGGER.debug("{} : {}", OAuthConstants.CODE, code);

    final boolean isVerified = verifyAccessTokenRequest(response, redirectUri, clientId, clientSecret, code);
    if (!isVerified) {
        return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, HttpStatus.SC_BAD_REQUEST);
    }

    final ServiceTicket serviceTicket = (ServiceTicket) ticketRegistry.getTicket(code);
    // service ticket should be valid
    if (serviceTicket == null || serviceTicket.isExpired()) {
        LOGGER.error("Code expired : {}", code);
        return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_GRANT, HttpStatus.SC_BAD_REQUEST);
    }
    final TicketGrantingTicket ticketGrantingTicket = serviceTicket.getGrantingTicket();
    // remove service ticket
    ticketRegistry.deleteTicket(serviceTicket.getId());

    response.setContentType("text/plain");
    final int expires = (int) (timeout - TimeUnit.MILLISECONDS
            .toSeconds(System.currentTimeMillis() - ticketGrantingTicket.getCreationTime()));

    final String text = String.format("%s=%s&%s=%s", OAuthConstants.ACCESS_TOKEN, ticketGrantingTicket.getId(),
                                                OAuthConstants.EXPIRES, expires);
    LOGGER.debug("text : {}", text);
    return OAuthUtils.writeText(response, text, HttpStatus.SC_OK);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:40,代码来源:OAuth20AccessTokenController.java

示例4: handleRequestInternal

import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {

    final String redirectUri = request.getParameter(OAuthConstants.REDIRECT_URI);
    LOGGER.debug("{} : {}", OAuthConstants.REDIRECT_URI, redirectUri);

    final String clientId = request.getParameter(OAuthConstants.CLIENT_ID);
    LOGGER.debug("{} : {}", OAuthConstants.CLIENT_ID, clientId);

    final String clientSecret = request.getParameter(OAuthConstants.CLIENT_SECRET);

    final String code = request.getParameter(OAuthConstants.CODE);
    LOGGER.debug("{} : {}", OAuthConstants.CODE, code);

    final boolean isVerified = verifyAccessTokenRequest(response, redirectUri, clientId, clientSecret, code);
    if (!isVerified) {
        return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, 400);
    }

    final ServiceTicket serviceTicket = (ServiceTicket) ticketRegistry.getTicket(code);
    // service ticket should be valid
    if (serviceTicket == null || serviceTicket.isExpired()) {
        LOGGER.error("Code expired : {}", code);
        return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_GRANT, 400);
    }
    final TicketGrantingTicket ticketGrantingTicket = serviceTicket.getGrantingTicket();
    // remove service ticket
    ticketRegistry.deleteTicket(serviceTicket.getId());

    response.setContentType("text/plain");
    final int expires = (int) (timeout - (System.currentTimeMillis()
            - ticketGrantingTicket.getCreationTime()) / 1000);

    final String text = String.format("%s=%s&%s=%s", OAuthConstants.ACCESS_TOKEN, ticketGrantingTicket.getId(),
                                                OAuthConstants.EXPIRES, expires);
    LOGGER.debug("text : {}", text);
    return OAuthUtils.writeText(response, text, 200);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:40,代码来源:OAuth20AccessTokenController.java

示例5: internalHandleRequest

import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView internalHandleRequest(final String method, final HttpServletRequest request,
                                             final HttpServletResponse response) throws Exception {

    final String redirectUri = request.getParameter(OAuthConstants.REDIRECT_URI);
    logger.debug("{} : {}", OAuthConstants.REDIRECT_URI, redirectUri);

    final String clientId = request.getParameter(OAuthConstants.CLIENT_ID);
    logger.debug("{} : {}", OAuthConstants.CLIENT_ID, clientId);

    final String clientSecret = request.getParameter(OAuthConstants.CLIENT_SECRET);

    final String code = request.getParameter(OAuthConstants.CODE);
    logger.debug("{} : {}", OAuthConstants.CODE, code);

    final boolean isVerified = verifyAccessTokenRequest(response, redirectUri, clientId, clientSecret, code);
    if (!isVerified) {
        return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, HttpStatus.SC_BAD_REQUEST);
    }

    final ServiceTicket serviceTicket = (ServiceTicket) ticketRegistry.getTicket(code);
    // service ticket should be valid
    if (serviceTicket == null || serviceTicket.isExpired()) {
        logger.error("Code expired : {}", code);
        return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_GRANT, HttpStatus.SC_BAD_REQUEST);
    }
    final TicketGrantingTicket ticketGrantingTicket = serviceTicket.getGrantingTicket();
    // remove service ticket
    ticketRegistry.deleteTicket(serviceTicket.getId());

    final OAuthRegisteredService registeredService = OAuthUtils.getRegisteredOAuthService(this.servicesManager, clientId);
    final OAuthWebApplicationService service = new OAuthWebApplicationService(registeredService.getId());
    final String accessTokenEncoded = this.accessTokenGenerator.generate(service, ticketGrantingTicket);
    final int expires = (int) (this.timeout - TimeUnit.MILLISECONDS
            .toSeconds(System.currentTimeMillis() - ticketGrantingTicket.getCreationTime()));
    final String text = String.format("%s=%s&%s=%s", OAuthConstants.ACCESS_TOKEN, accessTokenEncoded, OAuthConstants.EXPIRES, expires);
    logger.debug("OAuth access token response: {}", text);
    response.setContentType("text/plain");
    return OAuthUtils.writeText(response, text, HttpStatus.SC_OK);
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:41,代码来源:OAuth20AccessTokenController.java

示例6: internalHandleRequest

import org.jasig.cas.support.oauth.OAuthUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView internalHandleRequest(final String method, final HttpServletRequest request,
                                             final HttpServletResponse response) throws Exception {

    final String redirectUri = request.getParameter(OAuthConstants.REDIRECT_URI);
    logger.debug("{} : {}", OAuthConstants.REDIRECT_URI, redirectUri);

    final String clientId = request.getParameter(OAuthConstants.CLIENT_ID);
    logger.debug("{} : {}", OAuthConstants.CLIENT_ID, clientId);

    final String clientSecret = request.getParameter(OAuthConstants.CLIENT_SECRET);

    final String code = request.getParameter(OAuthConstants.CODE);
    logger.debug("{} : {}", OAuthConstants.CODE, code);

    final boolean isVerified = verifyAccessTokenRequest(response, redirectUri, clientId, clientSecret, code);
    if (!isVerified) {
        return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_REQUEST, HttpStatus.SC_BAD_REQUEST);
    }

    final ServiceTicket serviceTicket = (ServiceTicket) ticketRegistry.getTicket(code);
    // service ticket should be valid
    if (serviceTicket == null || serviceTicket.isExpired()) {
        logger.error("Code expired : {}", code);
        return OAuthUtils.writeTextError(response, OAuthConstants.INVALID_GRANT, HttpStatus.SC_BAD_REQUEST);
    }
    final TicketGrantingTicket ticketGrantingTicket = serviceTicket.getGrantingTicket();
    // remove service ticket
    ticketRegistry.deleteTicket(serviceTicket.getId());

    final OAuthRegisteredService registeredService = OAuthUtils.getRegisteredOAuthService(this.servicesManager, clientId);
    final OAuthWebApplicationService service = new OAuthWebApplicationService(registeredService.getId());
    final String accessTokenEncoded = this.accessTokenGenerator.generate(service, ticketGrantingTicket);
    final int expires = (int) (this.timeout - TimeUnit.MILLISECONDS
            .toSeconds(System.currentTimeMillis() - ticketGrantingTicket.getCreationTime()));
    final String text = String.format("%s=%s&%s=%s", OAuthConstants.ACCESS_TOKEN, 
            accessTokenEncoded, OAuthConstants.EXPIRES_IN, expires);
    logger.debug("OAuth access token response: {}", text);
    response.setContentType("text/plain");
    return OAuthUtils.writeText(response, text, HttpStatus.SC_OK);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:42,代码来源:OAuth20AccessTokenController.java


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