gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-14 18:14:49 30 4
gpt4 key购买 nike

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

YubicoClient介绍

[英]Base class for doing YubiKey validations using version 2 of the validation protocol.
[中]用于使用验证协议版本2进行YubiKey验证的基类。

代码示例

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

@Path("register")
@POST
public String register(@FormParam("username") String username, @FormParam("otp") String otp) throws Exception {
  VerificationResponse response = client.verify(otp);
  if (response.isOk()) {
    String yubikeyId = YubicoClient.getPublicId(otp);
    yubikeyIds.put(username, yubikeyId);
    return "Successfully registered YubiKey!" + NAVIGATION;
  }
  return "Invalid OTP: " + response;
}

代码示例来源:origin: net.unicon.cas/cas-addons

/**
 * Prepares the Yubico client with the received clientId and secretKey. By default,
 * all YubiKey accounts are allowed to authenticate.
 * <p/>
 * WARNING: THIS CONSTRUCTOR RESULTS IN AN EXAMPLE YubiKeyAuthenticationHandler
 * CONFIGURATION THAT CONSIDERS ALL Yubikeys VALID FOR ALL USERS.  YOU MUST NOT USE
 * THIS CONSTRUCTOR IN PRODUCTION.
 *
 * @param clientId
 * @param secretKey
 */
public YubiKeyAuthenticationHandler(final Integer clientId, final String secretKey) {
  this.client = YubicoClient.getClient(clientId);
  this.client.setKey(secretKey);
}

代码示例来源:origin: net.unicon.cas/cas-addons

final String otp = usernamePasswordCredentials.getPassword();
if (YubicoClient.isValidOTPFormat(otp)) {
  final String publicId = YubicoClient.getPublicId(otp);
    final YubicoResponse response = client.verify(otp);
    log.debug("YubiKey response status {} at {}", response.getStatus(), response.getTimestamp());
    return (response.getStatus() == YubicoResponseStatus.OK);

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

public static void main (String args []) throws Exception
{
  if (args.length != 3) {
    System.err.println("\n*** Test your Yubikey against Yubico OTP validation server ***");
    System.err.println("\nUsage: java -jar client.jar Client_ID Client_key OTP");
    System.err.println("\nEg. java -jar client.jar 28 vvfucnlcrrnejlbuthlktguhclhvegbungldcrefbnku");
    System.err.println("\nTouch Yubikey to generate the OTP. Visit Yubico.com for more details.");
    return;
  }
  String otp = args[2];
  YubicoClient yc = YubicoClient.getClient(Integer.parseInt(args[0]), args[1]);
  VerificationResponse response = yc.verify(otp);
  if(response!=null && response.getStatus() == ResponseStatus.OK) {
    System.out.println("\n* OTP verified OK");
  } else {
    System.out.println("\n* Failed to verify OTP");
  }
  System.out.println("\n* Last response: " + response);
  System.exit(0);
} // End of main

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

this.yc = YubicoClient.getClient(clientId, clientKey);
  String in = options.get(OPTION_YUBICO_WSAPI_URLS).toString();
  String l[] = in.split("\\|");
  this.yc.setWsapiUrls(l);
  this.yc.setSync(Integer.parseInt(options.get(OPTION_YUBICO_SYNC_POLICY).toString()));

代码示例来源:origin: org.apereo.cas/cas-server-support-yubikey-core

if (!YubicoClient.isValidOTPFormat(otp)) {
  LOGGER.debug("Invalid OTP format [{}]", otp);
  throw new AccountNotFoundException("OTP format is invalid");
  val response = this.client.verify(otp);
  val status = response.getStatus();
  if (status.compareTo(ResponseStatus.OK) == 0) {

代码示例来源:origin: org.apereo.cas/cas-server-support-yubikey-core-mfa

/**
   * Gets token public id.
   *
   * @param token the token
   * @return the token public id
   */
  default String getTokenPublicId(final String token) {
    return YubicoClient.getPublicId(token);
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-support-yubikey

@RefreshScope
@Bean
@ConditionalOnMissingBean(name = "yubicoClient")
public YubicoClient yubicoClient() {
  val yubi = this.casProperties.getAuthn().getMfa().getYubikey();
  if (StringUtils.isBlank(yubi.getSecretKey())) {
    throw new IllegalArgumentException("Yubikey secret key cannot be blank");
  }
  if (yubi.getClientId() <= 0) {
    throw new IllegalArgumentException("Yubikey client id is undefined");
  }
  val client = YubicoClient.getClient(yubi.getClientId(), yubi.getSecretKey());
  if (!yubi.getApiUrls().isEmpty()) {
    val urls = yubi.getApiUrls().toArray(ArrayUtils.EMPTY_STRING_ARRAY);
    client.setWsapiUrls(urls);
  }
  return client;
}

代码示例来源:origin: org.apereo.cas/cas-server-support-yubikey-core

@Override
  public boolean isValid(final String uid, final String token) {
    try {
      val yubikeyPublicId = getTokenPublicId(token);
      if (StringUtils.isNotBlank(yubikeyPublicId)) {
        val response = this.client.verify(token);
        val status = response.getStatus();
        if (status.compareTo(ResponseStatus.OK) == 0) {
          LOGGER.debug("YubiKey response status [{}] at [{}]", status, response.getTimestamp());
          return true;
        }
        LOGGER.error("Failed to verify YubiKey token: [{}]", response);
      } else {
        LOGGER.error("Invalid YubiKey token: [{}]", token);
      }
    } catch (final Exception e) {
      LOGGER.error(e.getMessage(), e);
    }
    return false;
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-support-yubikey-core-mfa

@Override
public boolean isAvailable(final RegisteredService service) {
  try {
    val endpoints = client.getWsapiUrls();
    for (val endpoint : endpoints) {
      LOGGER.debug("Pinging YubiKey API endpoint at [{}]", endpoint);
      val msg = this.httpClient.sendMessageToEndPoint(new URL(endpoint));
      val message = msg != null ? msg.getMessage() : null;
      if (StringUtils.isNotBlank(message)) {
        val response = EncodingUtils.urlDecode(message);
        LOGGER.debug("Received YubiKey ping response [{}]", response);
        return true;
      }
    }
  } catch (final Exception e) {
    LOGGER.warn(e.getMessage(), e);
  }
  return false;
}

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

public String getPublicId() {
    return YubicoClient.getPublicId(otp);
  }
}

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

@Path("login")
  @POST
  public String login(@FormParam("username") String username, @FormParam("otp") String otp) throws Exception {
    VerificationResponse response = client.verify(otp);
    if (response.isOk()) {
      String yubikeyId = YubicoClient.getPublicId(otp);
      if(yubikeyIds.get(username).contains(yubikeyId)) {
        return "Success fully logged in " + username + "!" + NAVIGATION;
      }
      return "No such username and YubiKey combination.";
    }
    return "Invalid OTP: " + response;
  }
}

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

ykr = this.yc.verify(otp);
} catch (YubicoVerificationException e) {
  log.warn("Errors during validation: ", e);
  log.trace("OTP {} verify result : {}", otp, ykr.getStatus().toString());
  if (ykr.getStatus() == ResponseStatus.OK) {
    String publicId = YubicoClient.getPublicId(otp);
    log.info("OTP verified successfully (YubiKey id {})", publicId);
    if (is_right_user(nameCb.getName(), publicId)) {

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