Java Code Examples for com.dd.plist.NSString

The following examples show how to use com.dd.plist.NSString. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: InflatableDonkey   Source File: EscrowOperationsRecover.java    License: MIT License 6 votes vote down vote up
static NSDictionary recover(
        HttpClient httpClient,
        EscrowProxyRequestFactory requests,
        SRPClient srpClient,
        NSDictionary srpInitResponse) throws IOException {

    validateSrpInitResponse(srpInitResponse);

    String dsid = PListsLegacy.getAs(srpInitResponse, "dsid", NSString.class).getContent();
    String respBlob = PListsLegacy.getAs(srpInitResponse, "respBlob", NSString.class).getContent();

    BlobA4 blob = blobA4(respBlob);

    byte[] m1 = calculateM1(srpClient, blob, dsid);
    byte[] uid = blob.uid();
    byte[] tag = blob.tag();

    return recover(httpClient, requests, uid, tag, m1);
}
 
Example 2
Source Project: InflatableDonkey   Source File: InflatableData.java    License: MIT License 6 votes vote down vote up
public static Optional<InflatableData> from(byte[] bs) {
    InflatableData data;
    try {
        NSDictionary parse = (NSDictionary) PropertyListParser.parse(bs);
        byte[] escrowedKeys = ((NSData) parse.get("escrowedKeys")).bytes();
        UUID deviceUuid = UUID.fromString(((NSString) parse.get("deviceUuid")).getContent());
        String deviceHardWareId = ((NSString) parse.get("deviceHardWareId")).getContent();
        data = new InflatableData(escrowedKeys, deviceUuid, deviceHardWareId);

    } catch (ClassCastException | IllegalArgumentException | IOException | NullPointerException
            | PropertyListFormatException | ParseException | ParserConfigurationException | SAXException ex) {
        logger.warn("-- from() - exception: ", ex);
        data = null;
    }
    return Optional.ofNullable(data);
}
 
Example 3
Source Project: thym   Source File: PBXProjectTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testAddPluginFile() throws Exception{
	PBXProject project = new PBXProject(pbxFile);
	String testPath = "my/files/abc.h";
	PBXFile file = new PBXFile(testPath);
	project.addPluginFile(file);
	
	
	NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes());
	NSDictionary objects = (NSDictionary)dict.objectForKey("objects");
	NSDictionary fileRef = (NSDictionary) objects.objectForKey(file.getFileRef());
	assertNotNull(fileRef);
	NSString isa = (NSString)fileRef.get("isa");
	assertEquals("PBXFileReference",isa.getContent());
	NSString path = (NSString)fileRef.get("path");
	assertEquals(testPath, path.getContent());
	NSString lastType = (NSString)fileRef.get("lastKnownFileType");
	assertEquals(HEADER_FILE, lastType.getContent());
	NSString encoding = (NSString)fileRef.get("fileEncoding");
	assertEquals("4", encoding.getContent());
	NSString sourceTree = (NSString)fileRef.get("sourceTree");
	assertEquals(DEFAULT_GROUP, sourceTree.getContent());
	
	assertTrue("No entry found on the Plugins group",isFileEntryFoundOnPluginsGroup(file, objects));
	
}
 
Example 4
Source Project: thym   Source File: PBXProjectTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testAddFrameworkWithWeak() throws Exception{
	PBXProject project = new PBXProject(pbxFile);
	String testPath = "libsqlite3.dylib";
	PBXFile file = new PBXFile(testPath);
	file.setWeak(true);
	project.addFramework(file);

	NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes());
	NSDictionary objects = (NSDictionary)dict.objectForKey("objects");
	
	NSDictionary buildFile = (NSDictionary)objects.objectForKey(file.getUuid());
	assertNotNull(buildFile);
	NSString isa = (NSString) buildFile.get("isa");
	assertEquals("PBXBuildFile",isa.getContent());
	NSString fRef = (NSString) buildFile.get("fileRef");
	assertEquals(file.getFileRef(), fRef.getContent());
	NSDictionary settings = (NSDictionary) buildFile.get("settings");
	NSArray attributes = (NSArray) settings.get("ATTRIBUTES");
	assertTrue(attributes.containsObject(NSObject.wrap("Weak")));
}
 
Example 5
Source Project: thym   Source File: PBXProjectTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testAddToLibrarySearchPaths() throws Exception{
	PBXProject project = new PBXProject(pbxFile);
	String testPath = "my/files/abcd.h";
	PBXFile file = new PBXFile(testPath);
	project.addToLibrarySearchPaths(file);
	
	NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes());
	NSDictionary objects = (NSDictionary)dict.objectForKey("objects");
	HashMap<String, NSObject> hashmap =  objects.getHashMap();	
	Collection<NSObject> values = hashmap.values();
	for (NSObject nsObject : values) {
		NSDictionary obj = (NSDictionary) nsObject;
		NSString isa = (NSString) obj.objectForKey("isa");
		if(isa != null && isa.getContent().equals("XCBuildConfiguration")){
			NSDictionary buildSettings = (NSDictionary) obj.objectForKey("buildSettings");
			assertTrue(buildSettings.containsKey("LIBRARY_SEARCH_PATHS"));
			NSArray searchPaths = (NSArray) buildSettings.get("LIBRARY_SEARCH_PATHS"); 
			assertEquals("$(SRCROOT)/Test_Application/my/files", ((NSString)searchPaths.objectAtIndex(1)).getContent());
		}
	}

}
 
Example 6
Source Project: thym   Source File: PBXProject.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private NSString searchPathForFile(PBXFile pbxfile) throws PBXProjectException {
	String filepath = FilenameUtils.getFullPathNoEndSeparator(pbxfile.getPath());
	if(filepath.equals(".")){
		filepath = "";
	}else{
		filepath = "/"+filepath;
	}
	NSDictionary group = getGroupByName("Plugins");
	
	if(pbxfile.isPlugin() && group.containsKey("path")){
		NSString groupPath = (NSString)group.objectForKey("path");
		return NSObject.wrap("$(SRCROOT)/" + groupPath.getContent().replace('"', ' ').trim());
    }
	else{
		return NSObject.wrap("$(SRCROOT)/"+ getProductName() + filepath );
	}
}
 
Example 7
Source Project: thym   Source File: PBXProject.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public String getProductName() throws PBXProjectException {
	HashMap<String, NSObject> hashmap =  getObjects().getHashMap();	
	Collection<NSObject> values = hashmap.values();
	for (NSObject nsObject : values) {
		NSDictionary obj = (NSDictionary) nsObject;
		NSString isa = (NSString) obj.objectForKey("isa");
		if(isa != null && isa.getContent().equals("XCBuildConfiguration")){
			NSDictionary buildSettings = (NSDictionary) obj.objectForKey("buildSettings");
			if( buildSettings.containsKey("PRODUCT_NAME")){
				NSString name = (NSString) buildSettings.get("PRODUCT_NAME");
				return name.getContent().replace('"', ' ').trim();
			}
		}
	}
	return null;
}
 
Example 8
Source Project: buck   Source File: XcodeNativeTargetProjectWriter.java    License: Apache License 2.0 6 votes vote down vote up
private void addFileReferenceToHeadersBuildPhase(
    PBXFileReference fileReference,
    PBXHeadersBuildPhase headersBuildPhase,
    HeaderVisibility visibility,
    boolean frameworkHeadersEnabled,
    Optional<ProductType> productType) {
  PBXBuildFile buildFile = objectFactory.createBuildFile(fileReference);
  if (visibility != HeaderVisibility.PRIVATE) {
    productType.ifPresent(
        type -> {
          if (frameworkHeadersEnabled
              && (type == ProductTypes.FRAMEWORK || type == ProductTypes.STATIC_FRAMEWORK)) {
            headersBuildPhase.getFiles().add(buildFile);
          }
        });

    NSDictionary settings = new NSDictionary();
    settings.put(
        "ATTRIBUTES",
        new NSArray(new NSString(AppleHeaderVisibilities.toXcodeAttribute(visibility))));
    buildFile.setSettings(Optional.of(settings));
  } else {
    buildFile.setSettings(Optional.empty());
  }
}
 
Example 9
Source Project: buck   Source File: ProvisioningProfileCopyStep.java    License: Apache License 2.0 6 votes vote down vote up
private ImmutableMap<String, NSObject> getInfoPlistAdditionalKeys(
    String bundleID, ProvisioningProfileMetadata bestProfile) throws IOException {
  ImmutableMap.Builder<String, NSObject> keys = ImmutableMap.builder();

  // Get bundle type and restrict additional keys based on it
  String bundleType =
      AppleInfoPlistParsing.getBundleTypeFromPlistStream(
              infoPlist, filesystem.getInputStreamForRelativePath(infoPlist))
          .get();
  if ("APPL".equalsIgnoreCase(bundleType.toString())) {
    // Skip additional keys for watchOS bundles (property keys whitelist)
    Optional<Boolean> isWatchOSApp =
        AppleInfoPlistParsing.isWatchOSAppFromPlistStream(
            infoPlist, filesystem.getInputStreamForRelativePath(infoPlist));
    if (!isWatchOSApp.isPresent() || !isWatchOSApp.get()) {
      // Construct AppID using the Provisioning Profile info (app prefix)
      String appID = bestProfile.getAppID().getFirst() + "." + bundleID;
      keys.put("ApplicationIdentifier", new NSString(appID));
    }
  }

  return keys.build();
}
 
Example 10
Source Project: buck   Source File: WorkspaceGeneratorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void workspaceEnabledForLegacyBuildSystem() throws Exception {
  AppleConfig appleConfig =
      FakeBuckConfig.builder()
          .setSections("[apple]", "use_modern_build_system = false")
          .build()
          .getView(AppleConfig.class);

  WorkspaceGenerator generator =
      new WorkspaceGenerator(projectFilesystem, "ws", Paths.get("."), appleConfig);

  Path workspacePath = generator.writeWorkspace();
  Optional<String> settings =
      projectFilesystem.readFileIfItExists(
          workspacePath.resolve("xcshareddata/WorkspaceSettings.xcsettings"));
  assertThat(settings.isPresent(), equalTo(true));
  NSObject object = PropertyListParser.parse(settings.get().getBytes(Charsets.UTF_8));
  assertThat(object, instanceOf(NSDictionary.class));
  NSObject buildSystemType = ((NSDictionary) object).get("BuildSystemType");
  assertThat(buildSystemType, instanceOf(NSString.class));
  assertThat(buildSystemType, equalTo(new NSString("Original")));
}
 
Example 11
Source Project: buck   Source File: PlistProcessStepTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testHandlesNonDictionaryPlists() throws Exception {
  FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();

  PlistProcessStep plistProcessStep =
      new PlistProcessStep(
          projectFilesystem,
          INPUT_PATH,
          Optional.empty(),
          OUTPUT_PATH,
          ImmutableMap.of(),
          ImmutableMap.of("Key1", new NSString("OverrideValue")),
          PlistProcessStep.OutputFormat.XML);

  NSArray array = new NSArray(new NSString("Value1"), new NSString("Value2"));
  projectFilesystem.writeContentsToPath(array.toXMLPropertyList(), INPUT_PATH);

  ExecutionContext executionContext = TestExecutionContext.newInstance();
  int errorCode = plistProcessStep.execute(executionContext).getExitCode();
  assertThat(errorCode, equalTo(0));

  assertThat(
      projectFilesystem.readFileIfItExists(OUTPUT_PATH),
      equalTo(Optional.of(array.toXMLPropertyList())));
}
 
Example 12
Source Project: buck   Source File: XcodeprojSerializerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testEmptyProject() {
  PBXProject project = new PBXProject("TestProject", AbstractPBXObjectFactory.DefaultFactory());
  XcodeprojSerializer xcodeprojSerializer = new XcodeprojSerializer(new GidGenerator(), project);
  NSDictionary rootObject = xcodeprojSerializer.toPlist();

  assertEquals(project.getGlobalID(), ((NSString) rootObject.get("rootObject")).getContent());

  NSDictionary objects = ((NSDictionary) rootObject.get("objects"));
  NSDictionary projectObject = (NSDictionary) objects.get(project.getGlobalID());

  String[] requiredKeys = {
    "mainGroup", "targets", "buildConfigurationList", "compatibilityVersion", "attributes",
  };

  for (String key : requiredKeys) {
    assertTrue(projectObject.containsKey(key));
  }
}
 
Example 13
Source Project: buck   Source File: ProvisioningProfileCopyStepTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testApplicationIdentifierIsValid() throws Exception {
  assumeTrue(Platform.detect() == Platform.MACOS);
  ProvisioningProfileCopyStep step =
      new ProvisioningProfileCopyStep(
          projectFilesystem,
          testdataDir.resolve("Info.plist"),
          ApplePlatform.IPHONEOS,
          Optional.of("00000000-0000-0000-0000-000000000000"),
          Optional.of(entitlementsFile),
          ProvisioningProfileStoreFactory.fromSearchPath(
              new DefaultProcessExecutor(new TestConsole()), FAKE_READ_COMMAND, testdataDir),
          outputFile,
          xcentFile,
          codeSignIdentitiesSupplier,
          Optional.empty());
  step.execute(executionContext);

  Optional<String> xcentContents = projectFilesystem.readFileIfItExists(xcentFile);
  assertTrue(xcentContents.isPresent());
  NSDictionary xcentPlist =
      (NSDictionary) PropertyListParser.parse(xcentContents.get().getBytes());
  assertEquals(
      xcentPlist.get("application-identifier"), new NSString("ABCDE12345.com.example.TestApp"));
}
 
Example 14
Source Project: buck   Source File: ProvisioningProfileCopyStepTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testApplicationIdentifierIsInInfoPlist() throws Exception {
  assumeTrue(Platform.detect() == Platform.MACOS);
  Path infoPlistPath = testdataDir.resolve("Info.plist");
  ProvisioningProfileCopyStep step =
      new ProvisioningProfileCopyStep(
          projectFilesystem,
          infoPlistPath,
          ApplePlatform.IPHONEOS,
          Optional.empty(),
          Optional.empty(),
          ProvisioningProfileStoreFactory.fromSearchPath(
              new DefaultProcessExecutor(new TestConsole()), FAKE_READ_COMMAND, testdataDir),
          outputFile,
          xcentFile,
          codeSignIdentitiesSupplier,
          Optional.empty());
  step.execute(executionContext);

  byte[] infoPlistContents = projectFilesystem.getFileBytes(infoPlistPath);
  NSDictionary infoPlist = (NSDictionary) PropertyListParser.parse(infoPlistContents);
  assertEquals(
      infoPlist.get("ApplicationIdentifier"), new NSString("ABCDE12345.com.example.TestApp"));
}
 
Example 15
Source Project: unidbg   Source File: IpaLoader.java    License: Apache License 2.0 5 votes vote down vote up
private static String parseExecutable(File ipa, String appDir) throws IOException {
    try {
        byte[] data = loadZip(ipa, appDir + "Info.plist");
        if (data == null) {
            throw new IllegalStateException("Find Info.plist failed");
        }
        NSDictionary info = (NSDictionary) PropertyListParser.parse(data);
        NSString bundleExecutable = (NSString) info.get("CFBundleExecutable");
        return bundleExecutable.getContent();
    } catch (PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) {
        throw new IllegalStateException("load ipa failed", e);
    }
}
 
Example 16
Source Project: unidbg   Source File: IpaLoader.java    License: Apache License 2.0 5 votes vote down vote up
private static String parseVersion(File ipa, String appDir) throws IOException {
    try {
        byte[] data = loadZip(ipa, appDir + "Info.plist");
        if (data == null) {
            throw new IllegalStateException("Find Info.plist failed");
        }
        NSDictionary info = (NSDictionary) PropertyListParser.parse(data);
        NSString bundleVersion = (NSString) info.get("CFBundleVersion");
        return bundleVersion.getContent();
    } catch (PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) {
        throw new IllegalStateException("load ipa failed", e);
    }
}
 
Example 17
Source Project: unidbg   Source File: IpaLoader.java    License: Apache License 2.0 5 votes vote down vote up
private static String parseCFBundleIdentifier(File ipa, String appDir) throws IOException {
    try {
        byte[] data = loadZip(ipa, appDir + "Info.plist");
        if (data == null) {
            throw new IllegalStateException("Find Info.plist failed");
        }
        NSDictionary info = (NSDictionary) PropertyListParser.parse(data);
        NSString bundleIdentifier = (NSString) info.get("CFBundleIdentifier");
        return bundleIdentifier.getContent();
    } catch (PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) {
        throw new IllegalStateException("load ipa failed", e);
    }
}
 
Example 18
Source Project: netbeans   Source File: IOSDebugTransport.java    License: Apache License 2.0 5 votes vote down vote up
private String nsObjectToString(NSObject o, int lvl) {
    String basicIndent = "    ";                                    //NOI18N
    String levelIndent = "";                                        //NOI18N
    for (int i = 0; i < lvl; i++) {
        levelIndent += basicIndent;
    }
    if (o instanceof NSDictionary) {
        String[] allKeys = ((NSDictionary) o).allKeys();
        StringBuilder sb = new StringBuilder(lvl == 0 ? "\n" : ""); //NOI18N
        sb.append("{\n");                                           //NOI18N
        for (String key: allKeys) {
            NSObject objectForKey = ((NSDictionary) o).objectForKey(key);
            sb.append(levelIndent);
            sb.append(basicIndent);
            sb.append("\"");                                        //NOI18N
            sb.append(key);
            sb.append("\": ");                                      //NOI18N
            sb.append(nsObjectToString(objectForKey, lvl + 1));
            sb.append("\n");                                        //NOI18N
        }
        sb.append(levelIndent);
        sb.append("}\n");                                           //NOI18N
        return sb.toString();
    } else if (o instanceof NSString) {
        return "\"" + ((NSString) o).toString() + "\"";             //NOI18N
    } else if (o instanceof NSData) {
        NSData data = (NSData) o;
        String asStr = new String(data.bytes(), Charset.forName("UTF-8"));
        return "Data: " + asStr;
    } else if (o != null) {
        return o.toString();
    } else {
        return "null";                                              //NOI18N
    }
}
 
Example 19
Source Project: netbeans   Source File: IOSDebugTransport.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get string contained in NSObject hierarchy.
 *
 * @param obj Root object.
 * @param path Path to string value.
 *
 * @return String value, or null if not fount or if data type is not string.
 */
static String stringInNSObject(NSObject obj, String... path) {
    NSObject res = findInNSObject(obj, path);
    if (res instanceof NSString) {
        return ((NSString) res).toString();
    } else {
        return null;
    }
}
 
Example 20
Source Project: cyberduck   Source File: PlistDeserializer.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public <T> List<T> listForKey(final String key) {
    final NSObject value = dict.objectForKey(key);
    if(null == value) {
        return null;
    }
    if(value instanceof NSArray) {
        final NSArray array = (NSArray) value;
        final List<T> list = new ArrayList<T>();
        for(int i = 0; i < array.count(); i++) {
            final NSObject next = array.objectAtIndex(i);
            if(next instanceof NSDictionary) {
                list.add((T) next);
            }
            else if(next instanceof NSString) {
                list.add((T) next.toString());
            }
            else {
                log.warn(String.format("Ignore content of type %s", next));
            }

        }
        return list;
    }
    log.warn(String.format("Unexpected value type for serialized key %s", key));
    return null;
}
 
Example 21
Source Project: InflatableDonkey   Source File: AccountInfo.java    License: MIT License 5 votes vote down vote up
public AccountInfo(NSDictionary accountInfo) {
    appleId = PListsLegacy.getAs(accountInfo, "appleId", NSString.class).getContent();
    aDsID = PListsLegacy.getAs(accountInfo, "aDsID", NSString.class).getContent();
    dsPrsID = PListsLegacy.getAs(accountInfo, "dsPrsID", NSString.class).getContent();
    lastName = PListsLegacy.getAs(accountInfo, "lastName", NSString.class).getContent();
    firstName = PListsLegacy.getAs(accountInfo, "firstName", NSString.class).getContent();
}
 
Example 22
Source Project: InflatableDonkey   Source File: Tokens.java    License: MIT License 5 votes vote down vote up
static Map<Token, String> tokens(NSDictionary dictionary) {
    return dictionary.entrySet()
            .stream()
            .filter(e -> Token.token(e.getKey()).isPresent())
            .filter(e -> e.getValue() instanceof NSString)
            .collect(Collectors.toMap(
                    e -> Token.token(e.getKey()).get(),
                    e -> ((NSString) e.getValue()).getContent()));
}
 
Example 23
Source Project: InflatableDonkey   Source File: EscrowedKeys.java    License: MIT License 5 votes vote down vote up
static boolean isPCSRecord(NSObject metadata) {
    return PListsLegacy.cast(metadata, NSDictionary.class)
            .flatMap(d -> PListsLegacy.optionalAs(d, "label", NSString.class))
            .map(NSString::getContent)
            .map(label -> label.equals("com.apple.protectedcloudstorage.record"))
            .orElse(false);
}
 
Example 24
Source Project: InflatableDonkey   Source File: EscrowedKeys.java    License: MIT License 5 votes vote down vote up
static byte[] escrowedKeys(NSDictionary record, ServiceKeySet backupBagPassword) {
    String metadataBase64 = PListsLegacy.getAs(record, "metadata", NSString.class).getContent();
    byte[] metadata = Base64.getDecoder().decode(metadataBase64);

    byte[] data = ProtectedRecord.unlockData(metadata, backupBagPassword::key);
    logger.debug("-- escrowedKeys() - decrypted metadata: {}", Hex.toHexString(data));
    return data;
}
 
Example 25
Source Project: InflatableDonkey   Source File: EscrowOperationsRecover.java    License: MIT License 5 votes vote down vote up
static NSDictionary decrypt(SRPClient srpClient, NSDictionary recoverResponse) {
    String respBlob = PListsLegacy.getAs(recoverResponse, "respBlob", NSString.class).getContent();
    BlobA6 blob = blobA6(respBlob);

    byte[] key = sessionKey(srpClient, blob);

    return decrypt(blob, key);
}
 
Example 26
Source Project: InflatableDonkey   Source File: ProtectedRecord.java    License: MIT License 5 votes vote down vote up
static void diagnostic(byte[] metadata) {
    NSDictionary dictionary = PListsLegacy.parseDictionary(metadata);
    logger.debug("-- diagnostic() - dictionary: {}", dictionary.toXMLPropertyList());

    byte[] backupKeybagDigest = PListsLegacy.getAs(dictionary, "BackupKeybagDigest", NSData.class).bytes();
    logger.debug("-- diagnostic() - BackupKeybagDigest: 0x{}", Hex.toHexString(backupKeybagDigest));

    Optional<NSString> timestamp = PListsLegacy.optionalAs(dictionary, "com.apple.securebackup.timestamp", NSString.class);
    logger.debug("-- diagnostic() - com.apple.securebackup.timestamp: {}",
            timestamp.map(NSString::getContent));

    NSDictionary clientMetadata = PListsLegacy.getAs(dictionary, "ClientMetadata", NSDictionary.class);

    NSDictionary secureBackupiCloudDataProtection
            = PListsLegacy.getAs(clientMetadata, "SecureBackupiCloudDataProtection", NSDictionary.class);

    byte[] secureBackupiCloudIdentityPublicData
            = PListsLegacy.getAs(clientMetadata, "SecureBackupiCloudIdentityPublicData", NSData.class).bytes();

    Optional<PublicKeyInfo> optionalPublicKeyInfo
            = DERUtils.parse(secureBackupiCloudIdentityPublicData, PublicKeyInfo::new);
    logger.debug("-- diagnostic() - publicKeyInfo: {}", optionalPublicKeyInfo);

    byte[] kPCSMetadataEscrowedKeys
            = PListsLegacy.getAs(secureBackupiCloudDataProtection, "kPCSMetadataEscrowedKeys", NSData.class).bytes();
    logger.debug("-- diagnostic() - kPCSMetadataEscrowedKeys: 0x{}", Hex.toHexString(kPCSMetadataEscrowedKeys));
}
 
Example 27
Source Project: InflatableDonkey   Source File: InflatableData.java    License: MIT License 5 votes vote down vote up
public byte[] encoded() {
    try {
        NSDictionary dict = new NSDictionary();
        dict.put("escrowedKeys", new NSData(escrowedKeys));
        dict.put("deviceUuid", new NSString(deviceUuid.toString()));
        dict.put("deviceHardWareId", new NSString(deviceHardWareId));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PropertyListParser.saveAsBinary(dict, baos);
        return baos.toByteArray();
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
 
Example 28
Source Project: Alite   Source File: ColorParser.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static long getColorFromOXP(NSObject colorDef) {
	if (colorDef instanceof NSDictionary) {
		return getColorFromOXPDict((NSDictionary) colorDef);
	} else if (colorDef instanceof NSString) {
		return getColorFromOXPString((NSString) colorDef);
	} else if (colorDef instanceof NSArray) {
		return getColorFromOXPArray((NSArray) colorDef);
	}
	AliteLog.e("Unknown color definition", "ColorDef is unknown: " + colorDef);
	return 0;
}
 
Example 29
Source Project: thym   Source File: PBXProjectTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private boolean isFileEntryFoundOnPluginsGroup(PBXFile file,
		NSDictionary objects) throws PBXProjectException {
	NSDictionary group = getGroupByName(objects, "Plugins");
	NSArray children = (NSArray) group.objectForKey("children");
	boolean groupFound = false;
	NSObject[] childs = children.getArray();
	for (int i = 0; i < childs.length; i++) {
		NSString str = (NSString)childs[i];
		if(str.getContent().equals(file.getFileRef())){
			groupFound = true;
			break;
		}
	}
	return groupFound;
}
 
Example 30
Source Project: thym   Source File: PBXProjectTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testAddResourceWithPlugin() throws Exception{
	PBXProject project = new PBXProject(pbxFile);
	String testPath = "assets.bundle";
	PBXFile file = new PBXFile(testPath);
	file.setPlugin(true);
	project.addResourceFile(file);
	
	NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes());
	NSDictionary objects = (NSDictionary)dict.objectForKey("objects");
	
	//Added the PBXFileReference object correctly?
	NSDictionary fileRef = (NSDictionary) objects.objectForKey(file.getFileRef());
	assertNotNull(fileRef);
	NSString isa = (NSString)fileRef.get("isa");
	assertEquals("PBXFileReference",isa.getContent());
	NSString path = (NSString)fileRef.get("path");
	assertEquals("assets.bundle", path.getContent());
	NSString lastType = (NSString)fileRef.get("lastKnownFileType");
	assertEquals("\"wrapper.plug-in\"", lastType.getContent());
	NSString sourceTree = (NSString)fileRef.get("sourceTree");
	assertEquals(DEFAULT_GROUP, sourceTree.getContent());
	NSString name = (NSString) fileRef.get("name");
	assertEquals("assets.bundle", name.getContent());
	assertFalse(fileRef.containsKey("fileEncoding"));


	//Added to the Plugins PBXGroup group?
	NSDictionary group = getGroupByName(objects, "Plugins");
	NSArray children = (NSArray) group.objectForKey("children");
	assertTrue(children.containsObject(new NSString(file.getFileRef())));
	
	//Added to the PBXSourcesBuildPhase
	NSDictionary phase = getPhase(objects, "PBXResourcesBuildPhase");
	NSArray files = (NSArray) phase.get("files");
	assertTrue(files.containsObject(new NSString(file.getUuid())));


}