com.github.robozonky.cli.ZonkyPasswordFeature类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(106)

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

ZonkyPasswordFeature介绍

暂无

代码示例

代码示例来源:origin: com.github.robozonky/robozonky-installer

private static void primeKeyStore(final char... keystorePassword) throws SetupFailedException, IOException {
  final String username = Variables.ZONKY_USERNAME.getValue(DATA);
  final char[] password = Variables.ZONKY_PASSWORD.getValue(DATA).toCharArray();
  Files.deleteIfExists(KEYSTORE_FILE.toPath()); // re-install into the same directory otherwise fails
  final Feature f = new ZonkyPasswordFeature(KEYSTORE_FILE, keystorePassword, username, password);
  f.setup();
}

代码示例来源:origin: com.github.robozonky/robozonky-cli

@Override
  public void test() throws TestFailedException {
    super.test();
    final SecretProvider s = SecretProvider.keyStoreBased(this.getStorage());
    attemptLogin(api, s.getUsername(), s.getPassword());
  }
}

代码示例来源:origin: RoboZonky/robozonky

@Override
public DataValidator.Status validateDataPossiblyThrowingException(final InstallData installData) {
  final String username = Variables.ZONKY_USERNAME.getValue(installData);
  final String password = Variables.ZONKY_PASSWORD.getValue(installData);
  try {
    ZonkyPasswordFeature.attemptLogin(apiSupplier.get(), username, password.toCharArray());
    return DataValidator.Status.OK;
  } catch (final TestFailedException t) {
    if (t.getCause() instanceof ServerErrorException) {
      logger.error("Failed accessing Zonky.", t);
      return DataValidator.Status.ERROR;
    } else {
      logger.warn("Failed logging in.", t);
      return DataValidator.Status.WARNING;
    }
  }
}

代码示例来源:origin: com.github.robozonky/robozonky-cli

@Override
public void setup() throws SetupFailedException {
  super.setup();
  SecretProvider.keyStoreBased(this.getStorage(), username, password);
}

代码示例来源:origin: com.github.robozonky/robozonky-installer

@Override
public DataValidator.Status validateDataPossiblyThrowingException(final InstallData installData) {
  final String username = Variables.ZONKY_USERNAME.getValue(installData);
  final String password = Variables.ZONKY_PASSWORD.getValue(installData);
  try {
    ZonkyPasswordFeature.attemptLogin(apiSupplier.get(), username, password.toCharArray());
    return DataValidator.Status.OK;
  } catch (final TestFailedException t) {
    if (t.getCause() instanceof ServerErrorException) {
      LOGGER.error("Failed accessing Zonky.", t);
      return DataValidator.Status.ERROR;
    } else {
      LOGGER.warn("Failed logging in.", t);
      return DataValidator.Status.WARNING;
    }
  }
}

代码示例来源:origin: RoboZonky/robozonky

@Override
public void setup() throws SetupFailedException {
  super.setup();
  SecretProvider.keyStoreBased(this.getStorage(), username, password);
}

代码示例来源:origin: RoboZonky/robozonky

private static void primeKeyStore(final char... keystorePassword) throws SetupFailedException, IOException {
  final String username = Variables.ZONKY_USERNAME.getValue(DATA);
  final char[] password = Variables.ZONKY_PASSWORD.getValue(DATA).toCharArray();
  Files.deleteIfExists(KEYSTORE_FILE.toPath()); // re-install into the same directory otherwise fails
  final Feature f = new ZonkyPasswordFeature(KEYSTORE_FILE, keystorePassword, username, password);
  f.setup();
}

代码示例来源:origin: RoboZonky/robozonky

@Override
  public void test() throws TestFailedException {
    super.test();
    final SecretProvider s = SecretProvider.keyStoreBased(this.getStorage());
    attemptLogin(api, s.getUsername(), s.getPassword());
  }
}

代码示例来源:origin: RoboZonky/robozonky

@Test
  void standaloneTestFails() throws IOException {
    final File f = newTempFile();
    final String username = "someone@somewhere.cz";
    final String pwd = UUID.randomUUID().toString();
    final ApiProvider api = mockApi(username, pwd.toCharArray());
    final Feature feature = new ZonkyPasswordFeature(api, f, KEYSTORE_PASSWORD.toCharArray(), username,
                             pwd.toCharArray());
    assertThatThrownBy(feature::test).isInstanceOf(TestFailedException.class); // no keystore exists
  }
}

代码示例来源:origin: RoboZonky/robozonky

@Test
void testFailsRemotely() throws IOException, SetupFailedException {
  final File f = newTempFile();
  final String username = "someone@somewhere.cz";
  final String pwd = UUID.randomUUID().toString();
  final ApiProvider api = mockFailingApi();
  final Feature feature = new ZonkyPasswordFeature(api, f, KEYSTORE_PASSWORD.toCharArray(), username,
                           pwd.toCharArray());
  feature.setup();
  assertThatThrownBy(feature::test).isInstanceOf(TestFailedException.class); // remote failure caught
}

代码示例来源:origin: RoboZonky/robozonky

@SuppressWarnings("unchecked")
@Test
void testWorks() throws IOException, TestFailedException, SetupFailedException {
  final File f = newTempFile();
  final String username = "someone@somewhere.cz";
  final String pwd = UUID.randomUUID().toString();
  final ApiProvider api = mockApi(username, pwd.toCharArray());
  final Feature feature = new ZonkyPasswordFeature(api, f, KEYSTORE_PASSWORD.toCharArray(), username,
                           pwd.toCharArray());
  feature.setup();
  feature.test();
  verify(api).oauth(any());
  verify(api).run(any(Consumer.class), any());
}

代码示例来源:origin: RoboZonky/robozonky

@Test
void createNew() throws IOException, SetupFailedException, KeyStoreException {
  final File f = newTempFile();
  final String username = "someone@somewhere.cz";
  final String pwd = UUID.randomUUID().toString();
  final Feature feature = new ZonkyPasswordFeature(f, KEYSTORE_PASSWORD.toCharArray(), username,
                           pwd.toCharArray());
  feature.setup();
  final SecretProvider s = SecretProvider.keyStoreBased(KeyStoreHandler.open(f, KEYSTORE_PASSWORD.toCharArray()));
  assertSoftly(softly -> {
    softly.assertThat(s.getUsername()).isEqualTo(username);
    softly.assertThat(s.getPassword()).isEqualTo(pwd.toCharArray());
  });
}

相关文章