use of com.dd.plist.NSDate in project buck by facebook.
the class ProvisioningProfileMetadataTest method testParseProvisioningProfileFile.
@Test
public void testParseProvisioningProfileFile() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
Path testdataDir = TestDataHelper.getTestDataDirectory(this).resolve("provisioning_profiles");
Path testFile = testdataDir.resolve("sample.mobileprovision");
ProvisioningProfileMetadata data = ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ProvisioningProfileStore.DEFAULT_READ_COMMAND, testFile);
assertThat(data.getExpirationDate(), is(equalTo(new NSDate("9999-03-05T01:33:40Z").getDate())));
assertThat(data.getAppID(), is(equalTo(new Pair<>("ABCDE12345", "com.example.TestApp"))));
assertThat(data.getUUID(), is(equalTo("00000000-0000-0000-0000-000000000000")));
assertThat(data.getProfilePath(), is(equalTo(testFile)));
assertThat(data.getDeveloperCertificateFingerprints(), equalTo(ImmutableSet.of(HashCode.fromString("be16fc419bfb6b59a86bc08755ba0f332ec574fb"))));
// Test old-style provisioning profile without "Platforms" field
data = ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir.resolve("sample_without_platforms.mobileprovision"));
assertThat(data.getDeveloperCertificateFingerprints(), equalTo(ImmutableSet.of(HashCode.fromString("be16fc419bfb6b59a86bc08755ba0f332ec574fb"))));
thrown.expect(IOException.class);
ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir.resolve("invalid.mobileprovision"));
}
use of com.dd.plist.NSDate in project robovm by robovm.
the class ProvisioningProfileTest method createProfile.
@SuppressWarnings("unchecked")
private ProvisioningProfile createProfile(String name, String appIdName, String appIdPrefix, String appId, boolean getTaskAllow, String provisionedDevice, String fingerprint) throws Exception {
NSDictionary entitlements = new NSDictionary();
entitlements.put("application-identifier", appId);
entitlements.put("get-task-allow", new NSNumber(getTaskAllow));
NSDictionary dict = new NSDictionary();
dict.put("UUID", UUID.randomUUID().toString());
dict.put("Name", name);
dict.put("AppIDName", appIdName);
dict.put("ApplicationIdentifierPrefix", new NSArray(new NSString(appIdPrefix)));
dict.put("CreationDate", new NSDate(new Date()));
dict.put("ExpirationDate", new NSDate(new Date()));
dict.put("Entitlements", entitlements);
dict.put("DeveloperCertificates", new NSArray());
if (provisionedDevice != null) {
NSArray devices = new NSArray(1);
devices.setValue(0, new NSString(provisionedDevice));
dict.put("ProvisionedDevices", devices);
}
ProvisioningProfile profile = new ProvisioningProfile(new File(""), dict);
Field f = ProvisioningProfile.class.getDeclaredField("certFingerprints");
f.setAccessible(true);
List<String> certFingerprints = (List<String>) f.get(profile);
certFingerprints.add(fingerprint);
return profile;
}
use of com.dd.plist.NSDate in project buck by facebook.
the class AbstractProvisioningProfileMetadata method fromProvisioningProfilePath.
public static ProvisioningProfileMetadata fromProvisioningProfilePath(ProcessExecutor executor, ImmutableList<String> readCommand, Path profilePath) throws IOException, InterruptedException {
Set<ProcessExecutor.Option> options = EnumSet.of(ProcessExecutor.Option.EXPECTING_STD_OUT);
// Extract the XML from its signed message wrapper.
ProcessExecutorParams processExecutorParams = ProcessExecutorParams.builder().addAllCommand(readCommand).addCommand(profilePath.toString()).build();
ProcessExecutor.Result result;
result = executor.launchAndExecute(processExecutorParams, options, /* stdin */
Optional.empty(), /* timeOutMs */
Optional.empty(), /* timeOutHandler */
Optional.empty());
if (result.getExitCode() != 0) {
throw new IOException(result.getMessageForResult("Invalid provisioning profile: " + profilePath));
}
try {
NSDictionary plist = (NSDictionary) PropertyListParser.parse(result.getStdout().get().getBytes());
Date expirationDate = ((NSDate) plist.get("ExpirationDate")).getDate();
String uuid = ((NSString) plist.get("UUID")).getContent();
ImmutableSet.Builder<HashCode> certificateFingerprints = ImmutableSet.builder();
NSArray certificates = (NSArray) plist.get("DeveloperCertificates");
HashFunction hasher = Hashing.sha1();
if (certificates != null) {
for (NSObject item : certificates.getArray()) {
certificateFingerprints.add(hasher.hashBytes(((NSData) item).bytes()));
}
}
ImmutableMap.Builder<String, NSObject> builder = ImmutableMap.builder();
NSDictionary entitlements = ((NSDictionary) plist.get("Entitlements"));
for (String key : entitlements.keySet()) {
builder = builder.put(key, entitlements.objectForKey(key));
}
String appID = entitlements.get("application-identifier").toString();
ProvisioningProfileMetadata.Builder provisioningProfileMetadata = ProvisioningProfileMetadata.builder();
if (plist.get("Platform") != null) {
for (Object platform : (Object[]) plist.get("Platform").toJavaObject()) {
provisioningProfileMetadata.addPlatforms((String) platform);
}
}
return provisioningProfileMetadata.setAppID(ProvisioningProfileMetadata.splitAppID(appID)).setExpirationDate(expirationDate).setUUID(uuid).setProfilePath(profilePath).setEntitlements(builder.build()).setDeveloperCertificateFingerprints(certificateFingerprints.build()).build();
} catch (Exception e) {
throw new IllegalArgumentException("Malformed embedded plist: " + e);
}
}
Aggregations