gpt4 book ai didi

com.yubico.client.v2.exceptions.YubicoValidationFailure类的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 18:06:31 26 4
gpt4 key购买 nike

本文整理了Java中com.yubico.client.v2.exceptions.YubicoValidationFailure类的一些代码示例,展示了YubicoValidationFailure类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YubicoValidationFailure类的具体详情如下:
包路径:com.yubico.client.v2.exceptions.YubicoValidationFailure
类名称:YubicoValidationFailure

YubicoValidationFailure介绍

[英]This is thrown for validation failures

  • OTP in request and response isn't matching, could mean a man-in-the-middle
  • nonce in request and response isn't matching, could mean a man-in-the-middle
  • response signature verification failed
    [中]这是由于验证失败而引发的
    *请求和响应中的OTP不匹配,可能意味着中间有人
    *请求和响应中的nonce不匹配,可能意味着中间有人
    *响应签名验证失败

代码示例

代码示例来源:origin: Yubico/yubico-java-client

private void verifySignature(VerificationResponse response) throws YubicoValidationFailure, YubicoVerificationException {
  StringBuilder keyValueStr = new StringBuilder();
  for (Entry<String, String> entry : response.getKeyValueMap().entrySet()) {
    if ("h".equals(entry.getKey())) {
      continue;
    }
    if (keyValueStr.length() > 0) {
      keyValueStr.append("&");
    }
    keyValueStr
        .append(entry.getKey())
        .append("=")
        .append(entry.getValue());
  }
  try {
    String signature = Signature.calculate(keyValueStr.toString(), key).trim();
    if (!response.getH().equals(signature) &&
        !response.getStatus().equals(BAD_SIGNATURE)) {
      // don't throw a ValidationFailure if the server said bad signature, in that
      // case we probably have the wrong key/id and want to check it.
      throw new YubicoValidationFailure("Signatures do not match");
    }
  } catch (YubicoSignatureException e) {
    throw new YubicoVerificationException("Failed to calculate the response signature.", e);
  }
}

代码示例来源:origin: Yubico/yubico-java-client

} catch (YubicoValidationFailure e) {
  log.warn("Something went very wrong during authentication: ", e);
  throw new LoginException("Something went very wrong during authentication: " + e.getMessage());

代码示例来源:origin: Yubico/yubico-java-client

throw new YubicoValidationFailure("OTP mismatch in response, is there a man-in-the-middle?");
throw new YubicoValidationFailure("Nonce mismatch in response, is there a man-in-the-middle?");

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com