< prev index next >

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

Print this page




  23  * questions.
  24  */
  25 
  26 package jdk.incubator.jpackage.internal;
  27 
  28 import java.io.File;
  29 import java.io.IOException;
  30 import java.text.MessageFormat;
  31 import java.util.*;
  32 
  33 import static jdk.incubator.jpackage.internal.StandardBundlerParam.*;
  34 import static jdk.incubator.jpackage.internal.MacAppBundler.*;
  35 import static jdk.incubator.jpackage.internal.OverridableResource.createResource;
  36 
  37 public class MacAppStoreBundler extends MacBaseInstallerBundler {
  38 
  39     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  40             "jdk.incubator.jpackage.internal.resources.MacResources");
  41 
  42     private static final String TEMPLATE_BUNDLE_ICON_HIDPI = "java.icns";
  43     private final static String DEFAULT_ENTITLEMENTS =
  44             "MacAppStore.entitlements";
  45     private final static String DEFAULT_INHERIT_ENTITLEMENTS =
  46             "MacAppStore_Inherit.entitlements";
  47 
  48     public static final BundlerParamInfo<String> MAC_APP_STORE_APP_SIGNING_KEY =
  49             new StandardBundlerParam<>(
  50             "mac.signing-key-app",
  51             String.class,
  52             params -> {
  53                 String result = MacBaseInstallerBundler.findKey(
  54                         "3rd Party Mac Developer Application: " +
  55                         SIGNING_KEY_USER.fetchFrom(params),
  56                         SIGNING_KEYCHAIN.fetchFrom(params),
  57                         VERBOSE.fetchFrom(params));
  58                 if (result != null) {
  59                     MacCertificate certificate = new MacCertificate(result);
  60 
  61                     if (!certificate.isValid()) {
  62                         Log.error(MessageFormat.format(
  63                                 I18N.getString("error.certificate.expired"),
  64                                 result));
  65                     }
  66                 }


  77                 String result = MacBaseInstallerBundler.findKey(
  78                         "3rd Party Mac Developer Installer: " +
  79                         SIGNING_KEY_USER.fetchFrom(params),
  80                         SIGNING_KEYCHAIN.fetchFrom(params),
  81                         VERBOSE.fetchFrom(params));
  82 
  83                 if (result != null) {
  84                     MacCertificate certificate = new MacCertificate(result);
  85 
  86                     if (!certificate.isValid()) {
  87                         Log.error(MessageFormat.format(
  88                                 I18N.getString("error.certificate.expired"),
  89                                 result));
  90                     }
  91                 }
  92 
  93                 return result;
  94             },
  95             (s, p) -> s);
  96 
  97     public static final StandardBundlerParam<File> MAC_APP_STORE_ENTITLEMENTS  =
  98             new StandardBundlerParam<>(
  99             Arguments.CLIOptions.MAC_APP_STORE_ENTITLEMENTS.getId(),
 100             File.class,
 101             params -> null,
 102             (s, p) -> new File(s));
 103 
 104     public static final BundlerParamInfo<String> INSTALLER_SUFFIX =
 105             new StandardBundlerParam<> (
 106             "mac.app-store.installerName.suffix",
 107             String.class,
 108             params -> "-MacAppStore",
 109             (s, p) -> s);
 110 
 111     public File bundle(Map<String, ? super Object> params,
 112             File outdir) throws PackagerException {
 113         Log.verbose(MessageFormat.format(I18N.getString(
 114                 "message.building-bundle"), APP_NAME.fetchFrom(params)));
 115 
 116         IOUtils.writableOutputDir(outdir.toPath());
 117 
 118         // first, load in some overrides
 119         // icns needs @2 versions, so load in the @2 default
 120         params.put(DEFAULT_ICNS_ICON.getID(), TEMPLATE_BUNDLE_ICON_HIDPI);
 121 
 122         // now we create the app
 123         File appImageDir = APP_IMAGE_TEMP_ROOT.fetchFrom(params);


 184             throw pe;
 185         } catch (Exception ex) {
 186             Log.verbose(ex);
 187             throw new PackagerException(ex);
 188         }
 189     }
 190 
 191     private File getConfig_Entitlements(Map<String, ? super Object> params) {
 192         return new File(CONFIG_ROOT.fetchFrom(params),
 193                 APP_NAME.fetchFrom(params) + ".entitlements");
 194     }
 195 
 196     private File getConfig_Inherit_Entitlements(
 197             Map<String, ? super Object> params) {
 198         return new File(CONFIG_ROOT.fetchFrom(params),
 199                 APP_NAME.fetchFrom(params) + "_Inherit.entitlements");
 200     }
 201 
 202     private void prepareEntitlements(Map<String, ? super Object> params)
 203             throws IOException {
 204         createResource(DEFAULT_ENTITLEMENTS, params)
 205                 .setCategory(
 206                         I18N.getString("resource.mac-app-store-entitlements"))
 207                 .setExternal(MAC_APP_STORE_ENTITLEMENTS.fetchFrom(params))
 208                 .saveToFile(getConfig_Entitlements(params));
 209 
 210         createResource(DEFAULT_INHERIT_ENTITLEMENTS, params)
 211                 .setCategory(I18N.getString(
 212                         "resource.mac-app-store-inherit-entitlements"))
 213                 .saveToFile(getConfig_Entitlements(params));
 214     }
 215 
 216     ///////////////////////////////////////////////////////////////////////
 217     // Implement Bundler
 218     ///////////////////////////////////////////////////////////////////////
 219 
 220     @Override
 221     public String getName() {
 222         return I18N.getString("store.bundler.name");
 223     }
 224 
 225     @Override
 226     public String getID() {
 227         return "mac.appStore";
 228     }
 229 
 230     @Override
 231     public boolean validate(Map<String, ? super Object> params)
 232             throws ConfigException {
 233         try {




  23  * questions.
  24  */
  25 
  26 package jdk.incubator.jpackage.internal;
  27 
  28 import java.io.File;
  29 import java.io.IOException;
  30 import java.text.MessageFormat;
  31 import java.util.*;
  32 
  33 import static jdk.incubator.jpackage.internal.StandardBundlerParam.*;
  34 import static jdk.incubator.jpackage.internal.MacAppBundler.*;
  35 import static jdk.incubator.jpackage.internal.OverridableResource.createResource;
  36 
  37 public class MacAppStoreBundler extends MacBaseInstallerBundler {
  38 
  39     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  40             "jdk.incubator.jpackage.internal.resources.MacResources");
  41 
  42     private static final String TEMPLATE_BUNDLE_ICON_HIDPI = "java.icns";




  43 
  44     public static final BundlerParamInfo<String> MAC_APP_STORE_APP_SIGNING_KEY =
  45             new StandardBundlerParam<>(
  46             "mac.signing-key-app",
  47             String.class,
  48             params -> {
  49                 String result = MacBaseInstallerBundler.findKey(
  50                         "3rd Party Mac Developer Application: " +
  51                         SIGNING_KEY_USER.fetchFrom(params),
  52                         SIGNING_KEYCHAIN.fetchFrom(params),
  53                         VERBOSE.fetchFrom(params));
  54                 if (result != null) {
  55                     MacCertificate certificate = new MacCertificate(result);
  56 
  57                     if (!certificate.isValid()) {
  58                         Log.error(MessageFormat.format(
  59                                 I18N.getString("error.certificate.expired"),
  60                                 result));
  61                     }
  62                 }


  73                 String result = MacBaseInstallerBundler.findKey(
  74                         "3rd Party Mac Developer Installer: " +
  75                         SIGNING_KEY_USER.fetchFrom(params),
  76                         SIGNING_KEYCHAIN.fetchFrom(params),
  77                         VERBOSE.fetchFrom(params));
  78 
  79                 if (result != null) {
  80                     MacCertificate certificate = new MacCertificate(result);
  81 
  82                     if (!certificate.isValid()) {
  83                         Log.error(MessageFormat.format(
  84                                 I18N.getString("error.certificate.expired"),
  85                                 result));
  86                     }
  87                 }
  88 
  89                 return result;
  90             },
  91             (s, p) -> s);
  92 







  93     public static final BundlerParamInfo<String> INSTALLER_SUFFIX =
  94             new StandardBundlerParam<> (
  95             "mac.app-store.installerName.suffix",
  96             String.class,
  97             params -> "-MacAppStore",
  98             (s, p) -> s);
  99 
 100     public File bundle(Map<String, ? super Object> params,
 101             File outdir) throws PackagerException {
 102         Log.verbose(MessageFormat.format(I18N.getString(
 103                 "message.building-bundle"), APP_NAME.fetchFrom(params)));
 104 
 105         IOUtils.writableOutputDir(outdir.toPath());
 106 
 107         // first, load in some overrides
 108         // icns needs @2 versions, so load in the @2 default
 109         params.put(DEFAULT_ICNS_ICON.getID(), TEMPLATE_BUNDLE_ICON_HIDPI);
 110 
 111         // now we create the app
 112         File appImageDir = APP_IMAGE_TEMP_ROOT.fetchFrom(params);


 173             throw pe;
 174         } catch (Exception ex) {
 175             Log.verbose(ex);
 176             throw new PackagerException(ex);
 177         }
 178     }
 179 
 180     private File getConfig_Entitlements(Map<String, ? super Object> params) {
 181         return new File(CONFIG_ROOT.fetchFrom(params),
 182                 APP_NAME.fetchFrom(params) + ".entitlements");
 183     }
 184 
 185     private File getConfig_Inherit_Entitlements(
 186             Map<String, ? super Object> params) {
 187         return new File(CONFIG_ROOT.fetchFrom(params),
 188                 APP_NAME.fetchFrom(params) + "_Inherit.entitlements");
 189     }
 190 
 191     private void prepareEntitlements(Map<String, ? super Object> params)
 192             throws IOException {
 193         createResource("Mac.entitlements", params)
 194                 .setCategory( I18N.getString("resource.mac-entitlements"))


 195                 .saveToFile(getConfig_Entitlements(params));
 196 
 197         createResource("Mac_Inherit.entitlements", params)
 198                 .setCategory(I18N.getString(
 199                         "resource.mac-inherit-entitlements"))
 200                 .saveToFile(getConfig_Inherit_Entitlements(params));
 201     }
 202 
 203     ///////////////////////////////////////////////////////////////////////
 204     // Implement Bundler
 205     ///////////////////////////////////////////////////////////////////////
 206 
 207     @Override
 208     public String getName() {
 209         return I18N.getString("store.bundler.name");
 210     }
 211 
 212     @Override
 213     public String getID() {
 214         return "mac.appStore";
 215     }
 216 
 217     @Override
 218     public boolean validate(Map<String, ? super Object> params)
 219             throws ConfigException {
 220         try {


< prev index next >