493 } catch (Exception ignored) {
494 Log.verbose(ignored);
495 return null;
496 }
497 }
498
499 //////////////////////////////////////////////////////////////////////////
500 // Implement Bundler
501 //////////////////////////////////////////////////////////////////////////
502
503 @Override
504 public String getName() {
505 return I18N.getString("pkg.bundler.name");
506 }
507
508 @Override
509 public String getID() {
510 return "pkg";
511 }
512
513 @Override
514 public boolean validate(Map<String, ? super Object> params)
515 throws ConfigException {
516 try {
517 Objects.requireNonNull(params);
518
519 // run basic validation to ensure requirements are met
520 // we are not interested in return code, only possible exception
521 validateAppImageAndBundeler(params);
522
523 if (MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params) == null) {
524 throw new ConfigException(
525 I18N.getString("message.app-image-requires-identifier"),
526 I18N.getString(
527 "message.app-image-requires-identifier.advice"));
528 }
529
530 // reject explicitly set sign to true and no valid signature key
531 if (Optional.ofNullable(MacAppImageBuilder.
532 SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.FALSE)) {
533 String signingIdentity =
534 DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params);
535 if (signingIdentity == null) {
536 throw new ConfigException(
537 I18N.getString("error.explicit-sign-no-cert"),
538 I18N.getString(
539 "error.explicit-sign-no-cert.advice"));
540 }
541 }
542
543 // hdiutil is always available so there's no need
544 // to test for availability.
545
546 return true;
547 } catch (RuntimeException re) {
|
493 } catch (Exception ignored) {
494 Log.verbose(ignored);
495 return null;
496 }
497 }
498
499 //////////////////////////////////////////////////////////////////////////
500 // Implement Bundler
501 //////////////////////////////////////////////////////////////////////////
502
503 @Override
504 public String getName() {
505 return I18N.getString("pkg.bundler.name");
506 }
507
508 @Override
509 public String getID() {
510 return "pkg";
511 }
512
513 public boolean isValidBundleIdentifier(String id) {
514 for (int i = 0; i < id.length(); i++) {
515 char a = id.charAt(i);
516 // We check for ASCII codes first which we accept. If check fails,
517 // check if it is acceptable extended ASCII or unicode character.
518 if ((a >= 'A' && a <= 'Z') || (a >= 'a' && a <= 'z')
519 || (a >= '0' && a <= '9') || (a == '-' || a == '.')) {
520 continue;
521 }
522 return false;
523 }
524 return true;
525 }
526
527 @Override
528 public boolean validate(Map<String, ? super Object> params)
529 throws ConfigException {
530 try {
531 Objects.requireNonNull(params);
532
533 // run basic validation to ensure requirements are met
534 // we are not interested in return code, only possible exception
535 validateAppImageAndBundeler(params);
536
537 String identifier = MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params);
538 if (identifier == null) {
539 throw new ConfigException(
540 I18N.getString("message.app-image-requires-identifier"),
541 I18N.getString(
542 "message.app-image-requires-identifier.advice"));
543 }
544 if (!isValidBundleIdentifier(identifier)) {
545 throw new ConfigException(
546 MessageFormat.format(I18N.getString(
547 "message.invalid-identifier"), identifier),
548 I18N.getString("message.invalid-identifier.advice"));
549 }
550
551 // reject explicitly set sign to true and no valid signature key
552 if (Optional.ofNullable(MacAppImageBuilder.
553 SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.FALSE)) {
554 String signingIdentity =
555 DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params);
556 if (signingIdentity == null) {
557 throw new ConfigException(
558 I18N.getString("error.explicit-sign-no-cert"),
559 I18N.getString(
560 "error.explicit-sign-no-cert.advice"));
561 }
562 }
563
564 // hdiutil is always available so there's no need
565 // to test for availability.
566
567 return true;
568 } catch (RuntimeException re) {
|