@Test public void parseMobileProvisionToMap() throws FileNotFoundException { URL fileUrl = this.getClass().getClassLoader().getResource("back_test/test_embedded.mobileprovision"); if (fileUrl == null) { return; } String filePath = fileUrl.getPath(); File file = new File(filePath); if (file.exists()) { Map<String, Object> map = IpaUtil.parseMobileProvisionToMap(new FileInputStream(file)); String str = "TeamName"; System.out.println(str + ": " + map.get(str)); } }
@SuppressWarnings("unchecked") public static Map<String, Object> parseMobileProvisionToMap(InputStream in) { if (in == null) { return null; } StringBuilder originContentSBuilder = new StringBuilder(); try (BufferedReader br = new BufferedReader(new InputStreamReader(in))) { String eachLine = br.readLine(); while (eachLine != null) { originContentSBuilder.append(eachLine); eachLine = br.readLine(); } } catch (IOException e) { logger.error("parseMobileProvisionToMap, IOException: [{}]", e); } String startStr = "<plist"; String endStr = "plist>"; int i = originContentSBuilder.indexOf(startStr); int j = originContentSBuilder.indexOf(endStr); if (i == -1 || j == -1) { return null; } NSObject nsObject; try { nsObject = PropertyListParser.parse(originContentSBuilder.substring(i, j + endStr.length()).getBytes()); } catch (IOException | PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) { logger.error("parseMobileProvisionToMap, Exception: [{}]", e); return null; } finally { try { in.close(); } catch (IOException e) { logger.error("parseMobileProvisionToMap, stream close IOException: [{}]", e); } } return (Map<String, Object>) nsObject; }
IpaUtil { @SuppressWarnings("unchecked") public static Map<String, Object> parseMobileProvisionToMap(InputStream in) { if (in == null) { return null; } StringBuilder originContentSBuilder = new StringBuilder(); try (BufferedReader br = new BufferedReader(new InputStreamReader(in))) { String eachLine = br.readLine(); while (eachLine != null) { originContentSBuilder.append(eachLine); eachLine = br.readLine(); } } catch (IOException e) { logger.error("parseMobileProvisionToMap, IOException: [{}]", e); } String startStr = "<plist"; String endStr = "plist>"; int i = originContentSBuilder.indexOf(startStr); int j = originContentSBuilder.indexOf(endStr); if (i == -1 || j == -1) { return null; } NSObject nsObject; try { nsObject = PropertyListParser.parse(originContentSBuilder.substring(i, j + endStr.length()).getBytes()); } catch (IOException | PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) { logger.error("parseMobileProvisionToMap, Exception: [{}]", e); return null; } finally { try { in.close(); } catch (IOException e) { logger.error("parseMobileProvisionToMap, stream close IOException: [{}]", e); } } return (Map<String, Object>) nsObject; } }
IpaUtil { @SuppressWarnings("unchecked") public static Map<String, Object> parseMobileProvisionToMap(InputStream in) { if (in == null) { return null; } StringBuilder originContentSBuilder = new StringBuilder(); try (BufferedReader br = new BufferedReader(new InputStreamReader(in))) { String eachLine = br.readLine(); while (eachLine != null) { originContentSBuilder.append(eachLine); eachLine = br.readLine(); } } catch (IOException e) { logger.error("parseMobileProvisionToMap, IOException: [{}]", e); } String startStr = "<plist"; String endStr = "plist>"; int i = originContentSBuilder.indexOf(startStr); int j = originContentSBuilder.indexOf(endStr); if (i == -1 || j == -1) { return null; } NSObject nsObject; try { nsObject = PropertyListParser.parse(originContentSBuilder.substring(i, j + endStr.length()).getBytes()); } catch (IOException | PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) { logger.error("parseMobileProvisionToMap, Exception: [{}]", e); return null; } finally { try { in.close(); } catch (IOException e) { logger.error("parseMobileProvisionToMap, stream close IOException: [{}]", e); } } return (Map<String, Object>) nsObject; }  }
IpaUtil { @SuppressWarnings("unchecked") public static Map<String, Object> parseMobileProvisionToMap(InputStream in) { if (in == null) { return null; } StringBuilder originContentSBuilder = new StringBuilder(); try (BufferedReader br = new BufferedReader(new InputStreamReader(in))) { String eachLine = br.readLine(); while (eachLine != null) { originContentSBuilder.append(eachLine); eachLine = br.readLine(); } } catch (IOException e) { logger.error("parseMobileProvisionToMap, IOException: [{}]", e); } String startStr = "<plist"; String endStr = "plist>"; int i = originContentSBuilder.indexOf(startStr); int j = originContentSBuilder.indexOf(endStr); if (i == -1 || j == -1) { return null; } NSObject nsObject; try { nsObject = PropertyListParser.parse(originContentSBuilder.substring(i, j + endStr.length()).getBytes()); } catch (IOException | PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) { logger.error("parseMobileProvisionToMap, Exception: [{}]", e); return null; } finally { try { in.close(); } catch (IOException e) { logger.error("parseMobileProvisionToMap, stream close IOException: [{}]", e); } } return (Map<String, Object>) nsObject; }  @SuppressWarnings("unchecked") static Map<String, Object> parsePListToMap(InputStream in); @SuppressWarnings("unchecked") static Map<String, Object> parseMobileProvisionToMap(InputStream in); static String getFileContentByExecuteShell(String fileName); static IpaParseRes parseIpa(File file); static void parseAndStoreFile(File file, List<String> iconList, String path); static synchronized boolean changePlistContent(File originFile, File aimFile, String softwarePackageUrl, String displayImageUrl, String fullSizeImageUrl,
                                                          String bundleIdentifierValue, String bundleVersionValue, String titleValue); static Map<String, Object> generateDirByIpa(File ipaOriginFile, String ipaOriginFileName, String domain, String name); static ByteArrayOutputStream cloneInputStream(InputStream inputStream); }
IpaUtil { @SuppressWarnings("unchecked") public static Map<String, Object> parseMobileProvisionToMap(InputStream in) { if (in == null) { return null; } StringBuilder originContentSBuilder = new StringBuilder(); try (BufferedReader br = new BufferedReader(new InputStreamReader(in))) { String eachLine = br.readLine(); while (eachLine != null) { originContentSBuilder.append(eachLine); eachLine = br.readLine(); } } catch (IOException e) { logger.error("parseMobileProvisionToMap, IOException: [{}]", e); } String startStr = "<plist"; String endStr = "plist>"; int i = originContentSBuilder.indexOf(startStr); int j = originContentSBuilder.indexOf(endStr); if (i == -1 || j == -1) { return null; } NSObject nsObject; try { nsObject = PropertyListParser.parse(originContentSBuilder.substring(i, j + endStr.length()).getBytes()); } catch (IOException | PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) { logger.error("parseMobileProvisionToMap, Exception: [{}]", e); return null; } finally { try { in.close(); } catch (IOException e) { logger.error("parseMobileProvisionToMap, stream close IOException: [{}]", e); } } return (Map<String, Object>) nsObject; }  @SuppressWarnings("unchecked") static Map<String, Object> parsePListToMap(InputStream in); @SuppressWarnings("unchecked") static Map<String, Object> parseMobileProvisionToMap(InputStream in); static String getFileContentByExecuteShell(String fileName); static IpaParseRes parseIpa(File file); static void parseAndStoreFile(File file, List<String> iconList, String path); static synchronized boolean changePlistContent(File originFile, File aimFile, String softwarePackageUrl, String displayImageUrl, String fullSizeImageUrl,
                                                          String bundleIdentifierValue, String bundleVersionValue, String titleValue); static Map<String, Object> generateDirByIpa(File ipaOriginFile, String ipaOriginFileName, String domain, String name); static ByteArrayOutputStream cloneInputStream(InputStream inputStream);  }