本文整理了Java中com.github.robozonky.cli.ZonkyPasswordFeature
类的一些代码示例,展示了ZonkyPasswordFeature
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonkyPasswordFeature
类的具体详情如下:
包路径:com.github.robozonky.cli.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());
});
}
内容来源于网络,如有侵权,请联系作者删除!