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


Java Authentication.NOT_CHECKED属性代码示例

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


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

示例1: validateRequest

@Override
public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory)
    throws ServerAuthException {
  HttpServletRequest httpReq = (HttpServletRequest) request;
  HttpServletResponse httpRes = (HttpServletResponse) response;
  Authentication ret;
  String componentId = getAppComponentId(httpReq);
  if (!mandatory) {
    if (LOG.isDebugEnabled()) {
      LOG.trace("URL '{}' does not require authentication", getRequestInfoForLogging(httpReq, componentId));
    }
    ret = Authentication.NOT_CHECKED;
  } else {
    if (((HttpServletRequest) request).getHeader(SSOConstants.X_REST_CALL) == null) {
      ret = returnUnauthorized(httpReq, httpRes, componentId, "Not a REST call: {}");
    } else {
      String authToken = getAppAuthToken(httpReq);
      if (authToken == null) {
        ret = returnUnauthorized(httpReq, httpRes, componentId, "Missing app authentication token: {}");
      } else if (componentId == null) {
        ret = returnUnauthorized(httpReq, httpRes, null, "Missing component ID: {}");
      } else {
        try {
          SSOPrincipal principal = getSsoService().validateAppToken(authToken, componentId);
          if (principal != null) {
            ret = new SSOAuthenticationUser(principal);
          } else {
            ret = returnUnauthorized(httpReq, httpRes, componentId, "Invalid app authentication token: {}");
          }
        } catch (ForbiddenException fex) {
          ret = returnUnauthorized(httpReq, httpRes, fex.getErrorInfo(), componentId, "Request: {}");
        }
      }
    }
  }
  return ret;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:37,代码来源:SSOAppAuthenticator.java

示例2: validateRequest

@Override
public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory)
    throws ServerAuthException {
  HttpServletRequest httpReq = (HttpServletRequest) request;
  HttpServletResponse httpRes = (HttpServletResponse) response;
  String authToken = getAuthTokenFromRequest(httpReq);

  Authentication ret = null;

  if (LOG.isTraceEnabled()) {
    LOG.trace("Request: {}", getRequestInfoForLogging(httpReq, SSOUtils.tokenForLog(authToken)));
  }

  if (isCORSOptionsRequest(httpReq)) {
    httpRes.setStatus(HttpServletResponse.SC_OK);
    httpRes.setHeader("Access-Control-Allow-Origin", conf.get(CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_ORIGIN,
        CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_ORIGIN_DEFAULT));
    httpRes.setHeader("Access-Control-Allow-Headers", conf.get(CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_HEADERS,
        CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_HEADERS_DEFAULT));
    httpRes.setHeader("Access-Control-Allow-Methods", conf.get(CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_METHODS,
        CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_METHODS_DEFAULT));
    return Authentication.SEND_SUCCESS;
  }

  if (!mandatory) {
    ret = Authentication.NOT_CHECKED;
  } else {
    if (authToken != null) {
      try {
        SSOPrincipal principal = getSsoService().validateUserToken(authToken);
        if (principal != null) {
          SSOAuthenticationUser user = new SSOAuthenticationUser(principal);
          if (isLogoutRequest(httpReq)) {
            if (LOG.isTraceEnabled()) {
              LOG.trace("Principal '{}' Logout", principal.getPrincipalId());
            }
            getSsoService().invalidateUserToken(authToken);
            ret = redirectToLogout(httpRes);
          } else {
            setAuthCookieIfNecessary(httpReq, httpRes, authToken, user.getSSOUserPrincipal().getExpires());
            if (isAuthTokenInQueryString(httpReq)) {
              if (LOG.isTraceEnabled()) {
                LOG.trace(
                    "Redirection to self, principal '{}' request: {}",
                    principal.getPrincipalId(),
                    getRequestInfoForLogging(httpReq, SSOUtils.tokenForLog(authToken))
                );
              }
              ret = redirectToSelf(httpReq, httpRes);
            } else {
              if (LOG.isDebugEnabled()) {
                LOG.debug(
                    "Principal '{}' request: {}",
                    principal.getPrincipalId(),
                    getRequestInfoForLogging(httpReq, SSOUtils.tokenForLog(authToken))
                );
              }
              ret = user;
            }
          }
        }
      } catch (ForbiddenException fex) {
        ret = returnUnauthorized(httpReq, httpRes, fex.getErrorInfo(), null, "Request: {}");
      }
    }
  }
  if (ret == null) {
    ret = returnUnauthorized(httpReq, httpRes, SSOUtils.tokenForLog(authToken), "Could not authenticate: {}");
  }
  return ret;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:71,代码来源:SSOUserAuthenticator.java


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