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


Java AuthStatus.SEND_CONTINUE属性代码示例

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


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

示例1: secureResponse

public void secureResponse(SoapMessage message)
{
   SOAPMessage request = message.getExchange().getInMessage().get(SOAPMessage.class);
   SOAPMessage response = message.getContent(SOAPMessage.class);
   MessageInfo messageInfo = new GenericMessageInfo(request, response);
   AuthStatus authStatus = null;
   try
   {
      authStatus = sctx.secureResponse(messageInfo, null);
   }
   catch (AuthException e)
   {
      if (isSOAP12(message))
      {
         SoapFault soap12Fault = new SoapFault(e.getMessage(), Soap12.getInstance().getReceiver());
         throw soap12Fault;
      }
      else
      {
         throw new SoapFault(e.getMessage(), new QName("", "jaspi AuthException"));
      }
   }
   if (messageInfo.getResponseMessage() != null && !message.getExchange().isOneWay())
   {
      if (AuthStatus.SEND_CONTINUE == authStatus)
      {
         message.put(Message.RESPONSE_CODE, Integer.valueOf(303));
      }
      if (AuthStatus.SEND_FAILURE == authStatus)
      {
         message.put(Message.RESPONSE_CODE, Integer.valueOf(500));
      }
   }

}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:35,代码来源:JaspiServerAuthenticator.java

示例2: validateRequest

/**
 * {@inheritDoc}. Although this really should return AuthStatus.SEND_SUCCESS
 * based on the spec, to make it work with WebSphere Liberty it returns
 * {@link AuthStatus#SEND_CONTINUE}.
 *
 * @return {@link AuthStatus#SEND_CONTINUE}
 */
@Override
public AuthStatus validateRequest(final ValidateContext context) throws IOException,
    GeneralSecurityException {

    context.setContentType(MediaType.APPLICATION_JSON);
    context.getResp()
        .getWriter()
        .print(context.getTokenCookie()
            .getUserInfo());
    return AuthStatus.SEND_CONTINUE;
}
 
开发者ID:trajano,项目名称:openid-connect,代码行数:18,代码来源:UserInfoRequestProcessor.java

示例3: validateRequest

/**
 * {@inheritDoc}. Although this really should return AuthStatus.SEND_SUCCESS
 * based on the spec, to make it work with WebSphere Liberty it returns
 * {@link AuthStatus#SEND_CONTINUE}.
 *
 * @return {@link AuthStatus#SEND_CONTINUE}
 */
@Override
public AuthStatus validateRequest(final ValidateContext context) throws IOException,
    GeneralSecurityException {

    context.setContentType(MediaType.APPLICATION_JSON);
    context.getResp()
        .getOutputStream().print(context.getIdToken().toString());
    return AuthStatus.SEND_CONTINUE;
}
 
开发者ID:trajano,项目名称:openid-connect,代码行数:16,代码来源:IdTokenRequestProcessor.java

示例4: validateRequest

@Override
public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject)
    throws AuthException {
  _logger.debug("Enter validateRequest");

  if (!requiresAuthentication(messageInfo)) {
    _logger.debug("Returning success, auth policy not mandatory");
    return AuthStatus.SUCCESS;
  }

  HttpServletRequest req = (HttpServletRequest) messageInfo.getRequestMessage();
  HttpServletResponse resp = (HttpServletResponse) messageInfo.getResponseMessage();

  try {
    UserAccount account = (UserAccount) req.getSession().getAttribute(USER_ACCOUNT_SESSION_KEY);
    if (account != null) {
      _logger.debug("Returning success, user already logged in");
      addPrincipalsToSubject(clientSubject, account);
      return AuthStatus.SUCCESS;
    }

    if (!req.getRequestURI().endsWith(LOGIN_PAGE)) {
      redirectToLoginPage(req, resp);
      return AuthStatus.SEND_CONTINUE;
    }

    if ("GET".equals(req.getMethod())) {
      forwardToLoginPage(req, resp, "GET request");
      return AuthStatus.SEND_CONTINUE;
    }

    String userName = req.getParameter("j_username");
    String password = req.getParameter("j_password");
    String otp = req.getParameter("j_otp");

    if (userName == null || password == null || otp == null) {
      _logger.debug("Returning failure, missing request parameter(s)");
      forwardToFailedLoginPage(req, resp, null);
      return AuthStatus.SEND_CONTINUE;
    }

    UserAccount userAccount = _accountMap.get(userName);
    if (userAccount != null
        && userAccount.getHashedPassword().equals(
            PasswordEncoder.encodePasswordForUser(userName, userAccount.getSalt(), password))
        && YubicoClient.isValidOTPFormat(otp)) {
      _logger.debug("Verifying Yubikey for {}...", userName);
      VerificationResponse response = _yubicoClient.verify(otp);
      if (response.isOk()) {
        if (response.getPublicId().equals(userAccount.getPublicYubiId())) {
          addPrincipalsToSubject(clientSubject, userAccount);
          req.getSession().setAttribute(USER_ACCOUNT_SESSION_KEY, userAccount);

          String originalUri = (String) req.getSession().getAttribute(ORIGINAL_URI_SESSION_KEY);
          if (originalUri != null) {
            _logger.debug("Login successful for {}, redirecting to {}", userName, originalUri);
            resp.sendRedirect(originalUri);
            return AuthStatus.SEND_CONTINUE;
          } else {
            _logger.debug("Login successful for {}, returning success", userName);
            return AuthStatus.SUCCESS;
          }
        } else {
          _logger.warn("Login attempt for {} with wrong Yubikey {}!", userName, response.getPublicId());
        }
      } else {
        _logger.info("Failed to verify Yubikey for {}, response not OK", userName);
      }
    }

    forwardToFailedLoginPage(req, resp, "authentication failed");
    return AuthStatus.SEND_CONTINUE;
  } catch (Exception e) {
    _logger.error("Authentication failed with exception", e);
    throw new AuthException(e.getMessage());
  }
}
 
开发者ID:erik-wramner,项目名称:YubikeyAuth,代码行数:77,代码来源:YubiAuthModule.java

示例5: validateRequest

@Override
public AuthStatus validateRequest(final ValidateContext context) throws IOException,
    GeneralSecurityException {

    final String idTokenHint = context.getTokenCookie()
        .getIdTokenJwt();
    context.deleteAuthCookies();
    final OpenIdProviderConfiguration oidProviderConfig = context.getOpenIDProviderConfig();

    final String contextPath = UriBuilder.fromUri(context.getReq()
        .getRequestURL()
        .toString())
        .replacePath(context.getReq()
            .getContextPath())
        .build()
        .toASCIIString();
    final String referrer = context.getReq()
        .getHeader("Referer");
    final String state;
    if (referrer.startsWith(contextPath)) {

        final StringBuilder stateBuilder = new StringBuilder(referrer.substring(contextPath.length()));
        if (context.getReq()
            .getQueryString() != null) {
            stateBuilder.append('?');
            stateBuilder.append(context.getReq()
                .getQueryString());
        }
        state = Encoding.base64urlEncode(stateBuilder.toString());
    } else {
        Log.fine("Referrer " + referrer + "does not start with context path " + contextPath + " using root context");
        state = CONTEXT_ROOT_STATE;
    }

    final URI redirectUri = context.getUri("logout_redirection_endpoint");

    if (oidProviderConfig.getEndSessionEndpoint() != null) {
        final UriBuilder b = UriBuilder.fromUri(oidProviderConfig.getEndSessionEndpoint())
            .queryParam("post_logout_redirect_uri", redirectUri)
            .queryParam("id_token_hint", idTokenHint)
            .queryParam("state", state);
        context.getResp()
            .sendRedirect(b.build()
                .toASCIIString());
    } else {
        context.getResp()
            .sendRedirect(context.getReq()
                .getServletContext() + "/");
    }
    if (context.getReq().getSession(false) != null) {
        context.getReq().getSession(false).invalidate();
    }
    try {
        context.getReq().logout();
    } catch (final ServletException e) {
        throw new GeneralSecurityException(e);
    }
    return AuthStatus.SEND_CONTINUE;
}
 
开发者ID:trajano,项目名称:openid-connect,代码行数:59,代码来源:LogoutRequestProcessor.java


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