< prev index next >

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

Print this page




  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);


 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 {




  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             "Mac.entitlements";
  45     private final static String DEFAULT_INHERIT_ENTITLEMENTS =
  46             "Mac_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 /*
  98     public static final StandardBundlerParam<File> MAC_ENTITLEMENTS  =
  99             new StandardBundlerParam<>(
 100             Arguments.CLIOptions.MAC_ENTITLEMENTS.getId(),
 101             File.class,
 102             params -> null,
 103             (s, p) -> new File(s));
 104 
 105     public static final StandardBundlerParam<File> MAC_INHERIT_ENTITLEMENTS  =
 106             new StandardBundlerParam<>(
 107             Arguments.CLIOptions.MAC_INHERIT_ENTITLEMENTS.getId(),
 108             File.class,
 109             params -> null,
 110             (s, p) -> new File(s));
 111 */
 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     public File bundle(Map<String, ? super Object> params,
 121             File outdir) throws PackagerException {
 122         Log.verbose(MessageFormat.format(I18N.getString(
 123                 "message.building-bundle"), APP_NAME.fetchFrom(params)));
 124 
 125         IOUtils.writableOutputDir(outdir.toPath());
 126 
 127         // first, load in some overrides
 128         // icns needs @2 versions, so load in the @2 default
 129         params.put(DEFAULT_ICNS_ICON.getID(), TEMPLATE_BUNDLE_ICON_HIDPI);
 130 
 131         // now we create the app
 132         File appImageDir = APP_IMAGE_TEMP_ROOT.fetchFrom(params);


 195             Log.verbose(ex);
 196             throw new PackagerException(ex);
 197         }
 198     }
 199 
 200     private File getConfig_Entitlements(Map<String, ? super Object> params) {
 201         return new File(CONFIG_ROOT.fetchFrom(params),
 202                 APP_NAME.fetchFrom(params) + ".entitlements");
 203     }
 204 
 205     private File getConfig_Inherit_Entitlements(
 206             Map<String, ? super Object> params) {
 207         return new File(CONFIG_ROOT.fetchFrom(params),
 208                 APP_NAME.fetchFrom(params) + "_Inherit.entitlements");
 209     }
 210 
 211     private void prepareEntitlements(Map<String, ? super Object> params)
 212             throws IOException {
 213         createResource(DEFAULT_ENTITLEMENTS, params)
 214                 .setCategory(
 215                         I18N.getString("resource.mac-entitlements"))
 216                 // .setExternal(MAC_ENTITLEMENTS.fetchFrom(params))
 217                 .saveToFile(getConfig_Entitlements(params));
 218 
 219         createResource(DEFAULT_INHERIT_ENTITLEMENTS, params)
 220                 .setCategory(I18N.getString(
 221                         "resource.mac-inherit-entitlements"))
 222                 // .setExternal(MAC_INHERIT_ENTITLEMENTS.fetchFrom(params))
 223                 .saveToFile(getConfig_Inherit_Entitlements(params));
 224     }
 225 
 226     ///////////////////////////////////////////////////////////////////////
 227     // Implement Bundler
 228     ///////////////////////////////////////////////////////////////////////
 229 
 230     @Override
 231     public String getName() {
 232         return I18N.getString("store.bundler.name");
 233     }
 234 
 235     @Override
 236     public String getID() {
 237         return "mac.appStore";
 238     }
 239 
 240     @Override
 241     public boolean validate(Map<String, ? super Object> params)
 242             throws ConfigException {
 243         try {


< prev index next >