Skip to content

Commit

Permalink
Make sure --run does not depend on personalized card
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpaljak committed Sep 2, 2020
1 parent 0f0565b commit e98d8bb
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions tool/src/main/java/com/fidesmo/fdsm/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,29 +288,21 @@ public static void main(String[] argv) {
System.out.println("Not a Fidesmo device");
}
}
FidesmoCard fidesmoCard = fidesmoMetadata.orElseThrow(() -> new IllegalStateException("Need a Fidesmo device to continue!"));

if (args.has(OPT_CARD_APPS)) {
List<byte[]> apps = FidesmoCard.listApps(bibo);
if (apps.size() > 0) {
printApps(queryApps(client, apps, verbose), System.out, verbose);
} else {
success("No applications");
}
} else if (args.has(OPT_RUN)) {
if (args.has(OPT_RUN)) {
String service = args.valueOf(OPT_RUN);

if (service.startsWith("ws://") || service.startsWith("wss://")) {
boolean success = WsClient.execute(new URI(service), bibo, auth).join().isSuccess();

if (!success) {
fail("Fail to run a script");
} else {
success();
}

} else {
FormHandler formHandler = getCommandLineFormHandler();
FidesmoCard fidesmoCard = fidesmoMetadata.orElseThrow(() -> new IllegalStateException("Need a Fidesmo device to continue!"));

String appId = null;
if (service.contains("/")) {
String[] bits = service.split("/");
Expand Down Expand Up @@ -338,6 +330,19 @@ public static void main(String[] argv) {
success(); // Explicitly quit to signal successful service. Which implies only one service per invocation
}
}
// --run always exists
}

// All operations require Fidesmo device
FidesmoCard fidesmoCard = fidesmoMetadata.orElseThrow(() -> new IllegalStateException("Need a Fidesmo device to continue!"));

if (args.has(OPT_CARD_APPS)) {
List<byte[]> apps = FidesmoCard.listApps(bibo);
if (apps.size() > 0) {
printApps(queryApps(client, apps, verbose), System.out, verbose);
} else {
success("No applications");
}
} else if (requiresAuthentication()) { // XXX
if (!auth.getUsername().isPresent()) {
throw new IllegalArgumentException("Application ID is required. Use --auth or FIDESMO_AUTH with appId:appKey format");
Expand Down

0 comments on commit e98d8bb

Please sign in to comment.