feat: opt pktype

This commit is contained in:
2023-05-21 16:52:04 +08:00
parent fb04fc6b6a
commit d91266644d
2 changed files with 4 additions and 7 deletions

View File

@@ -13,7 +13,7 @@
"repo": {
"dependencies": [
"info.picocli:picocli:4.6.1",
"me.hatter:commons:3.67",
"me.hatter:commons:3.68",
"me.hatter:crypto:1.12"
],
"testDependencies": [

View File

@@ -17,7 +17,6 @@ import me.hatter.tools.yubikeyca.hatterink.CertificateUtil;
import java.security.KeyPair;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Optional;
public class YubikeyCaMain {
private static final LogTool log;
@@ -178,13 +177,11 @@ public class YubikeyCaMain {
log.error("Keypair type is required.");
return null;
}
final Optional<PKType> pkTypeOpt = Arrays.stream(PKType.values())
.filter(t -> t.name().equalsIgnoreCase(args.keypairType))
.findFirst();
if (!pkTypeOpt.isPresent()) {
final PKType pkType = PKType.from(args.keypairType);
if (pkType == null) {
log.error("Invalid keypair type: " + args.keypairType);
return null;
}
return pkTypeOpt.get();
return pkType;
}
}