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


Java OAuthConstants.ERROR_VIEW属性代码示例

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


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

示例1: handleRequestInternal

@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {
    // get CAS ticket
    final String ticket = request.getParameter(OAuthConstants.TICKET);
    logger.debug("{} : {}", OAuthConstants.TICKET, ticket);

    // retrieve callback url from session
    final HttpSession session = request.getSession();
    String callbackUrl = (String) session.getAttribute(OAuthConstants.OAUTH20_CALLBACKURL);
    logger.debug("{} : {}", OAuthConstants.OAUTH20_CALLBACKURL, callbackUrl);
    session.removeAttribute(OAuthConstants.OAUTH20_CALLBACKURL);

    if (StringUtils.isBlank(callbackUrl)) {
        logger.error("{} is missing from the session and can not be retrieved.", OAuthConstants.OAUTH20_CALLBACKURL);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }
    // and state
    final String state = (String) session.getAttribute(OAuthConstants.OAUTH20_STATE);
    logger.debug("{} : {}", OAuthConstants.OAUTH20_STATE, state);
    session.removeAttribute(OAuthConstants.OAUTH20_STATE);

    // return callback url with code & state
    callbackUrl = OAuthUtils.addParameter(callbackUrl, OAuthConstants.CODE, ticket);
    if (state != null) {
        callbackUrl = OAuthUtils.addParameter(callbackUrl, OAuthConstants.STATE, state);
    }
    logger.debug("{} : {}", OAuthConstants.OAUTH20_CALLBACKURL, callbackUrl);

    final Map<String, Object> model = new HashMap<String, Object>();
    model.put("callbackUrl", callbackUrl);

    // retrieve service name from session
    final String serviceName = (String) session.getAttribute(OAuthConstants.OAUTH20_SERVICE_NAME);
    logger.debug("serviceName : {}", serviceName);
    model.put("serviceName", serviceName);
    return new ModelAndView(OAuthConstants.CONFIRM_VIEW, model);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:38,代码来源:OAuth20CallbackAuthorizeController.java

示例2: internalHandleRequest

@Override
protected ModelAndView internalHandleRequest(final String method, final HttpServletRequest request,
                                             final HttpServletResponse response) throws Exception {
    // get CAS ticket
    final String ticket = request.getParameter(OAuthConstants.TICKET);
    logger.debug("{} : {}", OAuthConstants.TICKET, ticket);

    // retrieve callback url from session
    final HttpSession session = request.getSession();
    String callbackUrl = (String) session.getAttribute(OAuthConstants.OAUTH20_CALLBACKURL);
    logger.debug("{} : {}", OAuthConstants.OAUTH20_CALLBACKURL, callbackUrl);
    session.removeAttribute(OAuthConstants.OAUTH20_CALLBACKURL);

    if (StringUtils.isBlank(callbackUrl)) {
        logger.error("{} is missing from the session and can not be retrieved.", OAuthConstants.OAUTH20_CALLBACKURL);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }
    // and state
    final String state = (String) session.getAttribute(OAuthConstants.OAUTH20_STATE);
    logger.debug("{} : {}", OAuthConstants.OAUTH20_STATE, state);
    session.removeAttribute(OAuthConstants.OAUTH20_STATE);

    // return callback url with code & state
    callbackUrl = OAuthUtils.addParameter(callbackUrl, OAuthConstants.CODE, ticket);
    if (state != null) {
        callbackUrl = OAuthUtils.addParameter(callbackUrl, OAuthConstants.STATE, state);
    }
    logger.debug("{} : {}", OAuthConstants.OAUTH20_CALLBACKURL, callbackUrl);

    final Map<String, Object> model = new HashMap<>();
    model.put("callbackUrl", callbackUrl);

    final Boolean bypassApprovalPrompt = (Boolean) session.getAttribute(OAuthConstants.BYPASS_APPROVAL_PROMPT);
    logger.debug("bypassApprovalPrompt : {}", bypassApprovalPrompt);
    session.removeAttribute(OAuthConstants.BYPASS_APPROVAL_PROMPT);

    // Clients that auto-approve do not need authorization.
    if (bypassApprovalPrompt != null && bypassApprovalPrompt) {
        return OAuthUtils.redirectTo(callbackUrl);
    }

    // retrieve service name from session
    final String serviceName = (String) session.getAttribute(OAuthConstants.OAUTH20_SERVICE_NAME);
    logger.debug("serviceName : {}", serviceName);
    model.put("serviceName", serviceName);

    return new ModelAndView(OAuthConstants.CONFIRM_VIEW, model);

}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:49,代码来源:OAuth20CallbackAuthorizeController.java

示例3: internalHandleRequest

@Override
protected ModelAndView internalHandleRequest(final String method, final HttpServletRequest request,
                                             final HttpServletResponse response) throws Exception {

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

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

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

    // clientId is required
    if (StringUtils.isBlank(clientId)) {
        logger.error("Missing {}", OAuthConstants.CLIENT_ID);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }
    // redirectUri is required
    if (StringUtils.isBlank(redirectUri)) {
        logger.error("Missing {}", OAuthConstants.REDIRECT_URI);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }

    final OAuthRegisteredService service = OAuthUtils.getRegisteredOAuthService(this.servicesManager, clientId);
    if (service == null) {
        logger.error("Unknown {} : {}", OAuthConstants.CLIENT_ID, clientId);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }

    final String serviceId = service.getServiceId();
    if (!redirectUri.matches(serviceId)) {
        logger.error("Unsupported {} : {} for serviceId : {}", OAuthConstants.REDIRECT_URI, redirectUri, serviceId);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }

    // keep info in session
    final HttpSession session = request.getSession();
    session.setAttribute(OAuthConstants.OAUTH20_CALLBACKURL, redirectUri);
    session.setAttribute(OAuthConstants.OAUTH20_SERVICE_NAME, service.getName());
    session.setAttribute(OAuthConstants.BYPASS_APPROVAL_PROMPT, service.isBypassApprovalPrompt());
    session.setAttribute(OAuthConstants.OAUTH20_STATE, state);

    final String callbackAuthorizeUrl = request.getRequestURL().toString()
            .replace('/' + OAuthConstants.AUTHORIZE_URL, '/' + OAuthConstants.CALLBACK_AUTHORIZE_URL);
    logger.debug("{} : {}", OAuthConstants.CALLBACK_AUTHORIZE_URL, callbackAuthorizeUrl);

    final String loginUrlWithService = OAuthUtils.addParameter(loginUrl, OAuthConstants.SERVICE,
            callbackAuthorizeUrl);
    logger.debug("loginUrlWithService : {}", loginUrlWithService);
    return OAuthUtils.redirectTo(loginUrlWithService);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:52,代码来源:OAuth20AuthorizeController.java

示例4: handleRequestInternal

@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {
    // get CAS ticket
    final String ticket = request.getParameter(OAuthConstants.TICKET);
    logger.debug("{} : {}", OAuthConstants.TICKET, ticket);

    // retrieve callback url from session
    final HttpSession session = request.getSession();
    String callbackUrl = (String) session.getAttribute(OAuthConstants.OAUTH20_CALLBACKURL);
    logger.debug("{} : {}", OAuthConstants.OAUTH20_CALLBACKURL, callbackUrl);
    session.removeAttribute(OAuthConstants.OAUTH20_CALLBACKURL);

    if (StringUtils.isBlank(callbackUrl)) {
        logger.error("{} is missing from the session and can not be retrieved.", OAuthConstants.OAUTH20_CALLBACKURL);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }
    // and state
    final String state = (String) session.getAttribute(OAuthConstants.OAUTH20_STATE);
    logger.debug("{} : {}", OAuthConstants.OAUTH20_STATE, state);
    session.removeAttribute(OAuthConstants.OAUTH20_STATE);

    // return callback url with code & state
    callbackUrl = OAuthUtils.addParameter(callbackUrl, OAuthConstants.CODE, ticket);
    if (state != null) {
        callbackUrl = OAuthUtils.addParameter(callbackUrl, OAuthConstants.STATE, state);
    }
    logger.debug("{} : {}", OAuthConstants.OAUTH20_CALLBACKURL, callbackUrl);

    final Map<String, Object> model = new HashMap<>();
    model.put("callbackUrl", callbackUrl);

    final Boolean bypassApprovalPrompt = (Boolean) session.getAttribute(OAuthConstants.BYPASS_APPROVAL_PROMPT);
    logger.debug("bypassApprovalPrompt : {}", bypassApprovalPrompt);
    session.removeAttribute(OAuthConstants.BYPASS_APPROVAL_PROMPT);

    // Clients that auto-approve do not need authorization.
    if (bypassApprovalPrompt != null && bypassApprovalPrompt) {
        return OAuthUtils.redirectTo(callbackUrl);
    }

    // retrieve service name from session
    final String serviceName = (String) session.getAttribute(OAuthConstants.OAUTH20_SERVICE_NAME);
    logger.debug("serviceName : {}", serviceName);
    model.put("serviceName", serviceName);

    return new ModelAndView(OAuthConstants.CONFIRM_VIEW, model);

}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:49,代码来源:OAuth20CallbackAuthorizeController.java

示例5: handleRequestInternal

@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {

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

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

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

    // clientId is required
    if (StringUtils.isBlank(clientId)) {
        LOGGER.error("Missing {}", OAuthConstants.CLIENT_ID);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }
    // redirectUri is required
    if (StringUtils.isBlank(redirectUri)) {
        LOGGER.error("Missing {}", OAuthConstants.REDIRECT_URI);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }

    final OAuthRegisteredService service = OAuthUtils.getRegisteredOAuthService(this.servicesManager, clientId);
    if (service == null) {
        LOGGER.error("Unknown {} : {}", OAuthConstants.CLIENT_ID, clientId);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }

    final String serviceId = service.getServiceId();
    if (!redirectUri.matches(serviceId)) {
        LOGGER.error("Unsupported {} : {} for serviceId : {}", OAuthConstants.REDIRECT_URI, redirectUri, serviceId);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }

    // keep info in session
    final HttpSession session = request.getSession();
    session.setAttribute(OAuthConstants.OAUTH20_CALLBACKURL, redirectUri);
    session.setAttribute(OAuthConstants.OAUTH20_SERVICE_NAME, service.getName());
    session.setAttribute(OAuthConstants.BYPASS_APPROVAL_PROMPT, service.isBypassApprovalPrompt());
    session.setAttribute(OAuthConstants.OAUTH20_STATE, state);

    final String callbackAuthorizeUrl = request.getRequestURL().toString()
            .replace("/" + OAuthConstants.AUTHORIZE_URL, "/" + OAuthConstants.CALLBACK_AUTHORIZE_URL);
    LOGGER.debug("{} : {}", OAuthConstants.CALLBACK_AUTHORIZE_URL, callbackAuthorizeUrl);

    final String loginUrlWithService = OAuthUtils.addParameter(loginUrl, OAuthConstants.SERVICE,
            callbackAuthorizeUrl);
    LOGGER.debug("loginUrlWithService : {}", loginUrlWithService);
    return OAuthUtils.redirectTo(loginUrlWithService);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:52,代码来源:OAuth20AuthorizeController.java

示例6: handleRequestInternal

@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {

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

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

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

    // clientId is required
    if (StringUtils.isBlank(clientId)) {
        LOGGER.error("Missing {}", OAuthConstants.CLIENT_ID);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }
    // redirectUri is required
    if (StringUtils.isBlank(redirectUri)) {
        LOGGER.error("Missing {}", OAuthConstants.REDIRECT_URI);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }

    final OAuthRegisteredService service = OAuthUtils.getRegisteredOAuthService(this.servicesManager, clientId);
    if (service == null) {
        LOGGER.error("Unknown {} : {}", OAuthConstants.CLIENT_ID, clientId);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }

    final String serviceId = service.getServiceId();
    if (!redirectUri.matches(serviceId)) {
        LOGGER.error("Unsupported {} : {} for serviceId : {}", OAuthConstants.REDIRECT_URI, redirectUri, serviceId);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }

    // keep info in session
    final HttpSession session = request.getSession();
    session.setAttribute(OAuthConstants.OAUTH20_CALLBACKURL, redirectUri);
    session.setAttribute(OAuthConstants.OAUTH20_SERVICE_NAME, service.getName());
    session.setAttribute(OAuthConstants.OAUTH20_STATE, state);

    final String callbackAuthorizeUrl = request.getRequestURL().toString()
            .replace("/" + OAuthConstants.AUTHORIZE_URL, "/" + OAuthConstants.CALLBACK_AUTHORIZE_URL);
    LOGGER.debug("{} : {}", OAuthConstants.CALLBACK_AUTHORIZE_URL, callbackAuthorizeUrl);

    final String loginUrlWithService = OAuthUtils.addParameter(loginUrl, OAuthConstants.SERVICE,
            callbackAuthorizeUrl);
    LOGGER.debug("loginUrlWithService : {}", loginUrlWithService);
    return OAuthUtils.redirectTo(loginUrlWithService);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:51,代码来源:OAuth20AuthorizeController.java


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