< prev index next >

src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppStoreBundler.java

Print this page




  37 import java.util.Optional;
  38 import java.util.ResourceBundle;
  39 
  40 import static jdk.jpackage.internal.StandardBundlerParam.*;
  41 import static jdk.jpackage.internal.MacAppBundler.*;
  42 
  43 public class MacAppStoreBundler extends MacBaseInstallerBundler {
  44 
  45     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  46             "jdk.jpackage.internal.resources.MacResources");
  47 
  48     private static final String TEMPLATE_BUNDLE_ICON_HIDPI =
  49             "GenericAppHiDPI.icns";
  50     private final static String DEFAULT_ENTITLEMENTS =
  51             "MacAppStore.entitlements";
  52     private final static String DEFAULT_INHERIT_ENTITLEMENTS =
  53             "MacAppStore_Inherit.entitlements";
  54 
  55     public static final BundlerParamInfo<String> MAC_APP_STORE_APP_SIGNING_KEY =
  56             new StandardBundlerParam<>(
  57             I18N.getString("param.signing-key-app.name"),
  58             I18N.getString("param.signing-key-app.description"),
  59             "mac.signing-key-app",
  60             String.class,
  61             params -> {
  62                     String result = MacBaseInstallerBundler.findKey(
  63                             "3rd Party Mac Developer Application: " +
  64                                     SIGNING_KEY_USER.fetchFrom(params),
  65                             SIGNING_KEYCHAIN.fetchFrom(params),
  66                             VERBOSE.fetchFrom(params));
  67                     if (result != null) {
  68                         MacCertificate certificate = new MacCertificate(result,
  69                                 VERBOSE.fetchFrom(params));
  70 
  71                         if (!certificate.isValid()) {
  72                             Log.error(MessageFormat.format(
  73                                     I18N.getString("error.certificate.expired"),
  74                                     result));
  75                         }
  76                     }
  77 
  78                     return result;
  79                 },
  80             (s, p) -> s);
  81 
  82     public static final BundlerParamInfo<String> MAC_APP_STORE_PKG_SIGNING_KEY =
  83             new StandardBundlerParam<>(
  84             I18N.getString("param.signing-key-pkg.name"),
  85             I18N.getString("param.signing-key-pkg.description"),
  86             "mac.signing-key-pkg",
  87             String.class,
  88             params -> {
  89                     String result = MacBaseInstallerBundler.findKey(
  90                             "3rd Party Mac Developer Installer: " +
  91                                     SIGNING_KEY_USER.fetchFrom(params),
  92                             SIGNING_KEYCHAIN.fetchFrom(params),
  93                             VERBOSE.fetchFrom(params));
  94 
  95                     if (result != null) {
  96                         MacCertificate certificate = new MacCertificate(
  97                                 result, VERBOSE.fetchFrom(params));
  98 
  99                         if (!certificate.isValid()) {
 100                             Log.error(MessageFormat.format(
 101                                     I18N.getString("error.certificate.expired"),
 102                                     result));
 103                         }
 104                     }
 105 
 106                     return result;
 107                 },
 108             (s, p) -> s);
 109 
 110     public static final StandardBundlerParam<File> MAC_APP_STORE_ENTITLEMENTS  =
 111             new StandardBundlerParam<>(
 112             I18N.getString("param.mac-app-store-entitlements.name"),
 113             I18N.getString("param.mac-app-store-entitlements.description"),
 114             Arguments.CLIOptions.MAC_APP_STORE_ENTITLEMENTS.getId(),
 115             File.class,
 116             params -> null,
 117             (s, p) -> new File(s));
 118 
 119     public static final BundlerParamInfo<String> INSTALLER_SUFFIX =
 120             new StandardBundlerParam<> (
 121             I18N.getString("param.installer-suffix.name"),
 122             I18N.getString("param.installer-suffix.description"),
 123             "mac.app-store.installerName.suffix",
 124             String.class,
 125             params -> "-MacAppStore",
 126             (s, p) -> s);
 127 
 128     //@Override
 129     public File bundle(Map<String, ? super Object> p,
 130             File outdir) throws PackagerException {
 131         Log.verbose(MessageFormat.format(I18N.getString(
 132                 "message.building-bundle"), APP_NAME.fetchFrom(p)));
 133         if (!outdir.isDirectory() && !outdir.mkdirs()) {
 134             throw new PackagerException(
 135                     "error.cannot-create-output-dir",
 136                      outdir.getAbsolutePath());
 137         }
 138         if (!outdir.canWrite()) {
 139             throw new PackagerException(
 140                     "error.cannot-write-to-output-dir",
 141                     outdir.getAbsolutePath());
 142         }
 143 
 144         // first, load in some overrides
 145         // icns needs @2 versions, so load in the @2 default
 146         p.put(DEFAULT_ICNS_ICON.getID(), TEMPLATE_BUNDLE_ICON_HIDPI);
 147 
 148         // now we create the app
 149         File appImageDir = APP_IMAGE_BUILD_ROOT.fetchFrom(p);
 150         try {
 151             appImageDir.mkdirs();
 152 
 153             try {
 154                 MacAppImageBuilder.addNewKeychain(p);
 155             } catch (InterruptedException e) {
 156                 Log.error(e.getMessage());
 157             }
 158             // first, make sure we don't use the local signing key
 159             p.put(DEVELOPER_ID_APP_SIGNING_KEY.getID(), null);
 160             File appLocation = prepareAppBundle(p, false);
 161 
 162             prepareEntitlements(p);
 163 
 164             String signingIdentity = MAC_APP_STORE_APP_SIGNING_KEY.fetchFrom(p);
 165             String identifierPrefix = BUNDLE_ID_SIGNING_PREFIX.fetchFrom(p);
 166             String entitlementsFile = getConfig_Entitlements(p).toString();
 167             String inheritEntitlements =
 168                     getConfig_Inherit_Entitlements(p).toString();
 169 




  37 import java.util.Optional;
  38 import java.util.ResourceBundle;
  39 
  40 import static jdk.jpackage.internal.StandardBundlerParam.*;
  41 import static jdk.jpackage.internal.MacAppBundler.*;
  42 
  43 public class MacAppStoreBundler extends MacBaseInstallerBundler {
  44 
  45     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  46             "jdk.jpackage.internal.resources.MacResources");
  47 
  48     private static final String TEMPLATE_BUNDLE_ICON_HIDPI =
  49             "GenericAppHiDPI.icns";
  50     private final static String DEFAULT_ENTITLEMENTS =
  51             "MacAppStore.entitlements";
  52     private final static String DEFAULT_INHERIT_ENTITLEMENTS =
  53             "MacAppStore_Inherit.entitlements";
  54 
  55     public static final BundlerParamInfo<String> MAC_APP_STORE_APP_SIGNING_KEY =
  56             new StandardBundlerParam<>(


  57             "mac.signing-key-app",
  58             String.class,
  59             params -> {
  60                     String result = MacBaseInstallerBundler.findKey(
  61                             "3rd Party Mac Developer Application: " +
  62                                     SIGNING_KEY_USER.fetchFrom(params),
  63                             SIGNING_KEYCHAIN.fetchFrom(params),
  64                             VERBOSE.fetchFrom(params));
  65                     if (result != null) {
  66                         MacCertificate certificate = new MacCertificate(result,
  67                                 VERBOSE.fetchFrom(params));
  68 
  69                         if (!certificate.isValid()) {
  70                             Log.error(MessageFormat.format(
  71                                     I18N.getString("error.certificate.expired"),
  72                                     result));
  73                         }
  74                     }
  75 
  76                     return result;
  77                 },
  78             (s, p) -> s);
  79 
  80     public static final BundlerParamInfo<String> MAC_APP_STORE_PKG_SIGNING_KEY =
  81             new StandardBundlerParam<>(


  82             "mac.signing-key-pkg",
  83             String.class,
  84             params -> {
  85                     String result = MacBaseInstallerBundler.findKey(
  86                             "3rd Party Mac Developer Installer: " +
  87                                     SIGNING_KEY_USER.fetchFrom(params),
  88                             SIGNING_KEYCHAIN.fetchFrom(params),
  89                             VERBOSE.fetchFrom(params));
  90 
  91                     if (result != null) {
  92                         MacCertificate certificate = new MacCertificate(
  93                                 result, VERBOSE.fetchFrom(params));
  94 
  95                         if (!certificate.isValid()) {
  96                             Log.error(MessageFormat.format(
  97                                     I18N.getString("error.certificate.expired"),
  98                                     result));
  99                         }
 100                     }
 101 
 102                     return result;
 103                 },
 104             (s, p) -> s);
 105 
 106     public static final StandardBundlerParam<File> MAC_APP_STORE_ENTITLEMENTS  =
 107             new StandardBundlerParam<>(


 108             Arguments.CLIOptions.MAC_APP_STORE_ENTITLEMENTS.getId(),
 109             File.class,
 110             params -> null,
 111             (s, p) -> new File(s));
 112 
 113     public static final BundlerParamInfo<String> INSTALLER_SUFFIX =
 114             new StandardBundlerParam<> (


 115             "mac.app-store.installerName.suffix",
 116             String.class,
 117             params -> "-MacAppStore",
 118             (s, p) -> s);
 119 
 120     //@Override
 121     public File bundle(Map<String, ? super Object> p,
 122             File outdir) throws PackagerException {
 123         Log.verbose(MessageFormat.format(I18N.getString(
 124                 "message.building-bundle"), APP_NAME.fetchFrom(p)));
 125         if (!outdir.isDirectory() && !outdir.mkdirs()) {
 126             throw new PackagerException(
 127                     "error.cannot-create-output-dir",
 128                      outdir.getAbsolutePath());
 129         }
 130         if (!outdir.canWrite()) {
 131             throw new PackagerException(
 132                     "error.cannot-write-to-output-dir",
 133                     outdir.getAbsolutePath());
 134         }
 135 
 136         // first, load in some overrides
 137         // icns needs @2 versions, so load in the @2 default
 138         p.put(DEFAULT_ICNS_ICON.getID(), TEMPLATE_BUNDLE_ICON_HIDPI);
 139 
 140         // now we create the app
 141         File appImageDir = APP_IMAGE_TEMP_ROOT.fetchFrom(p);
 142         try {
 143             appImageDir.mkdirs();
 144 
 145             try {
 146                 MacAppImageBuilder.addNewKeychain(p);
 147             } catch (InterruptedException e) {
 148                 Log.error(e.getMessage());
 149             }
 150             // first, make sure we don't use the local signing key
 151             p.put(DEVELOPER_ID_APP_SIGNING_KEY.getID(), null);
 152             File appLocation = prepareAppBundle(p, false);
 153 
 154             prepareEntitlements(p);
 155 
 156             String signingIdentity = MAC_APP_STORE_APP_SIGNING_KEY.fetchFrom(p);
 157             String identifierPrefix = BUNDLE_ID_SIGNING_PREFIX.fetchFrom(p);
 158             String entitlementsFile = getConfig_Entitlements(p).toString();
 159             String inheritEntitlements =
 160                     getConfig_Inherit_Entitlements(p).toString();
 161 


< prev index next >