com.dd.plist.NSNumber Java Examples

The following examples show how to use com.dd.plist.NSNumber. 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 File: EscrowOperationsRecover.java    From InflatableDonkey with MIT License 5 votes vote down vote up
static void validateSrpInitResponse(NSDictionary srpInitResponseBlob) {
    Integer version = PListsLegacy.optionalAs(srpInitResponseBlob, "version", NSNumber.class)
            .map(NSNumber::intValue)
            .orElse(null);
    if (!version.equals(1)) {
        throw new UnsupportedOperationException("unknown SRP_INIT version: " + version);
    }
}
 
Example #2
Source File: ColorParser.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
private static float getAlpha(NSDictionary dictionary) {
	if (dictionary.containsKey("alpha")) {
		return ((NSNumber) dictionary.get("alpha")).floatValue();
	}
	if (dictionary.containsKey("opacity")) {
		return ((NSNumber) dictionary.get("opacity")).floatValue();			
	}
	return 1.0f;
}
 
Example #3
Source File: ColorParser.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
private static float getValue(NSDictionary dictionary) {
	if (dictionary.containsKey("value")) {
		return ((NSNumber) dictionary.get("value")).floatValue();
	}
	if (dictionary.containsKey("brightness")) {
		return ((NSNumber) dictionary.get("brightness")).floatValue();			
	}
	return 1.0f;
}
 
Example #4
Source File: ColorParser.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
private static long getColorFromOXPArray(NSArray colorArray) {
	NSObject[] array = colorArray.getArray();
	float r = array.length > 0 ? ((NSNumber) array[0]).floatValue() : 0;
	float g = array.length > 1 ? ((NSNumber) array[1]).floatValue() : 0;
	float b = array.length > 2 ? ((NSNumber) array[2]).floatValue() : 0;
	float a = array.length > 3 ? ((NSNumber) array[3]).floatValue() : 1;
	
	if (r <= 1.0f && g <= 1.0f && b <= 1.0f && a <= 1.0f) {
		return AliteColors.convertRgba(r, g, b, a);
	} 
	a = array.length > 3 ? ((NSNumber) array[3]).floatValue() : 255.0f;
	return AliteColors.convertRgba(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
}
 
Example #5
Source File: AppleBundle.java    From buck with Apache License 2.0 5 votes vote down vote up
private ImmutableMap<String, NSObject> getInfoPlistOverrideKeys() {
  ImmutableMap.Builder<String, NSObject> keys = ImmutableMap.builder();

  if (platform.getType() == ApplePlatformType.MAC) {
    if (needsLSRequiresIPhoneOSInfoPlistKeyOnMac()) {
      keys.put("LSRequiresIPhoneOS", new NSNumber(false));
    }
  } else if (!platform.getType().isWatch() && !isLegacyWatchApp()) {
    keys.put("LSRequiresIPhoneOS", new NSNumber(true));
  }

  return keys.build();
}
 
Example #6
Source File: AppleInfoPlistParsing.java    From buck with Apache License 2.0 5 votes vote down vote up
/** Extracts the watchOS app flag (WKWatchKitApp) from an Info.plist, returning it if present. */
public static Optional<Boolean> isWatchOSAppFromPlistStream(
    Path plistPath, InputStream inputStream) throws IOException {
  NSNumber isWatchOSApp =
      (NSNumber) getPropertyValueFromPlistStream(plistPath, inputStream, "WKWatchKitApp");
  if (isWatchOSApp == null) {
    return Optional.of(Boolean.FALSE);
  } else {
    return Optional.of(isWatchOSApp.boolValue());
  }
}
 
Example #7
Source File: WorkspaceGeneratorTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void workspaceDisablesSchemeAutoCreation() throws Exception {
  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 autocreate =
      ((NSDictionary) object).get("IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded");
  assertThat(autocreate, instanceOf(NSNumber.class));
  assertThat(autocreate, equalTo(new NSNumber(false)));
}
 
Example #8
Source File: WorkspaceGeneratorTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void workspaceDisablesSchemeAutoCreation() throws Exception {
  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 autocreate =
      ((NSDictionary) object).get("IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded");
  assertThat(autocreate, instanceOf(NSNumber.class));
  assertThat(autocreate, equalTo(new NSNumber(false)));
}
 
Example #9
Source File: Snapshot.java    From InflatableDonkey with MIT License 4 votes vote down vote up
public Optional<Boolean> wasPasscodeSet() {
    return backupProperty("WasPasscodeSet", NSNumber.class).map(NSNumber::boolValue);
}
 
Example #10
Source File: AssetEncryptedAttributesFactory.java    From InflatableDonkey with MIT License 4 votes vote down vote up
public static AssetEncryptedAttributes fromDictionary(NSDictionary data, String domain) {
    logger.trace("<< fromDictionary() - data:{} domain: {}", data.toXMLPropertyList(), domain);
    NSDictionaries.as(data, "domain", NSString.class)
            .map(NSString::getContent)
            .filter(u -> !u.equals(domain))
            .ifPresent(u -> logger.warn("-- fromDictionary() - domain mismatch: {} != {}", u, domain));
    Optional<String> relativePath = NSDictionaries.as(data, "relativePath", NSString.class)
            .map(NSString::getContent);
    Optional<Instant> modified = NSDictionaries.as(data, "modified", NSDate.class)
            .map(NSDate::getDate)
            .map(Date::toInstant);
    Optional<Instant> birth = NSDictionaries.as(data, "birth", NSDate.class)
            .map(NSDate::getDate)
            .map(Date::toInstant);
    Optional<Instant> statusChanged = NSDictionaries.as(data, "statusChanged", NSDate.class)
            .map(NSDate::getDate)
            .map(Date::toInstant);
    Optional<Integer> userID = NSDictionaries.as(data, "userID", NSNumber.class)
            .map(NSNumber::intValue);
    Optional<Integer> groupID = NSDictionaries.as(data, "groupID", NSNumber.class)
            .map(NSNumber::intValue);
    Optional<Integer> mode = NSDictionaries.as(data, "mode", NSNumber.class)
            .map(NSNumber::intValue);
    Optional<Long> size = NSDictionaries.as(data, "size", NSNumber.class)
            .map(NSNumber::longValue);
    Optional<byte[]> encryptionKey = NSDictionaries.as(data, "encryptionKey", NSData.class)
            .map(NSData::bytes);
    Optional<byte[]> checksum = Optional.empty();   // not present
    Optional<Long> sizeBeforeCopy = Optional.empty();   // not present
    Optional<Integer> contentEncodingMethod = Optional.empty();   // not present
    Optional<Integer> contentCompressionMethod = Optional.empty();   // not present

    AssetEncryptedAttributes attributes = new AssetEncryptedAttributes(
            Optional.of(domain),
            relativePath,
            modified,
            birth,
            statusChanged,
            userID,
            groupID,
            mode,
            size,
            encryptionKey,
            checksum,
            sizeBeforeCopy,
            contentEncodingMethod,
            contentCompressionMethod);
    logger.trace(">> fromDictionary() - encrypted attributes: {}", attributes);
    return attributes;
}
 
Example #11
Source File: Authenticator.java    From InflatableDonkey with MIT License 4 votes vote down vote up
public static Auth authenticate(HttpClient httpClient, String id, String password) throws IOException {
    logger.trace("<< authenticate() < id: {} password: {}", id, password);

    AuthenticationRequestFactory authenticationRequestFactory = AuthenticationRequestFactory.instance();
    PropertyListResponseHandler<NSDictionary> nsDictionaryResponseHandler
            = PropertyListResponseHandler.dictionary();

    try {
        HttpUriRequest request = authenticationRequestFactory.apply(id, password);
        NSDictionary authentication = httpClient.execute(request, nsDictionaryResponseHandler);
        logger.debug("-- authenticate() - authentication: {}", authentication.toASCIIPropertyList());

        NSDictionary appleAccountInfo = PListsLegacy.getAs(authentication, "appleAccountInfo", NSDictionary.class);
        String dsPrsID = PListsLegacy.getAs(appleAccountInfo, "dsPrsID", NSNumber.class).toString();

        NSDictionary tokens = PListsLegacy.getAs(authentication, "tokens", NSDictionary.class);
        String mmeAuthToken = PListsLegacy.getAs(tokens, "mmeAuthToken", NSString.class).getContent();

        logger.debug("-- authenticate() -  dsPrsID: {}", dsPrsID);
        logger.debug("-- authenticate() -  mmeAuthToken: {}", mmeAuthToken);

        Auth auth = new Auth(dsPrsID, mmeAuthToken);

        logger.trace(">> authenticate() > auth: {}", auth);
        return auth;

    } catch (HttpResponseException ex) {
        logger.warn("--authenticate() - HttpResponseException: {}", ex.getMessage());
        int statusCode = ex.getStatusCode();

        if (statusCode == 401) {
            throw new HttpResponseException(statusCode, "Bad appleId/ password or not an iCloud account?");
        }

        if (statusCode == 409) {
            throw new HttpResponseException(statusCode, "Two-step enabled or partial iCloud account activation?");
        }

        throw ex;
    }
}
 
Example #12
Source File: PropertyListResponseHandler.java    From InflatableDonkey with MIT License 4 votes vote down vote up
public static PropertyListResponseHandler<NSNumber> number() {
    return NUMBER;
}
 
Example #13
Source File: IPAModifyPlist.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void setUIStatusBarHidden(boolean status) {
	NSNumber nsstatus = new NSNumber(status);
	this.rootDict.put(UIStatusBarHidden, nsstatus);
}
 
Example #14
Source File: AppleBundle.java    From buck with Apache License 2.0 4 votes vote down vote up
private ImmutableMap<String, NSObject> getInfoPlistAdditionalKeys() {
  ImmutableMap.Builder<String, NSObject> keys = ImmutableMap.builder();

  switch (platform.getType()) {
    case MAC:
      if (needsAppInfoPlistKeysOnMac()) {
        keys.put("NSHighResolutionCapable", new NSNumber(true));
        keys.put("NSSupportsAutomaticGraphicsSwitching", new NSNumber(true));
      }
      keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("MacOSX")));
      break;
    case IOS_DEVICE:
      keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("iPhoneOS")));
      break;
    case IOS_SIMULATOR:
      keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("iPhoneSimulator")));
      break;
    case WATCH_DEVICE:
      if (!isLegacyWatchApp()) {
        keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("WatchOS")));
      }
      break;
    case WATCH_SIMULATOR:
      if (!isLegacyWatchApp()) {
        keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("WatchSimulator")));
      }
      break;
    case TV_DEVICE:
    case TV_SIMULATOR:
    case UNKNOWN:
      break;
  }

  keys.put("DTPlatformName", new NSString(platform.getName()));
  keys.put("DTPlatformVersion", new NSString(sdkVersion));
  keys.put("DTSDKName", new NSString(sdkName + sdkVersion));
  keys.put("MinimumOSVersion", new NSString(minOSVersion));
  if (platformBuildVersion.isPresent()) {
    keys.put("DTPlatformBuild", new NSString(platformBuildVersion.get()));
    keys.put("DTSDKBuild", new NSString(platformBuildVersion.get()));
  }

  if (xcodeBuildVersion.isPresent()) {
    keys.put("DTXcodeBuild", new NSString(xcodeBuildVersion.get()));
  }

  if (xcodeVersion.isPresent()) {
    keys.put("DTXcode", new NSString(xcodeVersion.get()));
  }

  return keys.build();
}
 
Example #15
Source File: AppleBundleIntegrationTest.java    From buck with Apache License 2.0 4 votes vote down vote up
@Test
public void simpleApplicationBundleWithDryRunCodeSigning() throws Exception {
  assumeTrue(FakeAppleDeveloperEnvironment.supportsCodeSigning());

  ProjectWorkspace workspace =
      TestDataHelper.createProjectWorkspaceForScenario(
          this, "simple_application_bundle_with_codesigning", tmp);
  workspace.setUp();
  workspace.addBuckConfigLocalOption("apple", "dry_run_code_signing", "true");

  BuildTarget target =
      workspace.newBuildTarget("//:DemoAppWithFramework#iphoneos-arm64,no-debug");
  workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();

  Path appPath =
      workspace.getPath(
          BuildTargetPaths.getGenPath(
                  filesystem,
                  target.withAppendedFlavors(AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR),
                  "%s")
              .resolve(target.getShortName() + ".app"));
  Path codeSignResultsPath = appPath.resolve("BUCK_code_sign_entitlements.plist");
  assertTrue(Files.exists(codeSignResultsPath));

  NSDictionary resultPlist = verifyAndParsePlist(appPath.resolve("BUCK_pp_dry_run.plist"));
  assertEquals(new NSString("com.example.DemoApp"), resultPlist.get("bundle-id"));
  assertEquals(new NSString("12345ABCDE"), resultPlist.get("team-identifier"));
  assertEquals(
      new NSString("00000000-0000-0000-0000-000000000000"),
      resultPlist.get("provisioning-profile-uuid"));

  // Codesigning main bundle
  resultPlist = verifyAndParsePlist(appPath.resolve("BUCK_code_sign_args.plist"));
  assertEquals(new NSNumber(true), resultPlist.get("use-entitlements"));

  // Codesigning embedded framework bundle
  resultPlist =
      verifyAndParsePlist(
          appPath.resolve("Frameworks/DemoFramework.framework/BUCK_code_sign_args.plist"));
  assertEquals(new NSNumber(false), resultPlist.get("use-entitlements"));
}