public static MobileProvisionIndex Load(string fileName)
        {
            var previousCreationDate = DateTime.MaxValue;
            var index  = new MobileProvisionIndex();
            var sorted = true;

            using (var stream = File.OpenRead(fileName)) {
                using (var reader = new BinaryReader(stream)) {
                    index.Version      = reader.ReadInt32();
                    index.LastModified = new DateTime(reader.ReadInt64(), DateTimeKind.Utc);

                    int count = reader.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        var profile = ProvisioningProfile.Load(reader);
                        index.ProvisioningProfiles.Add(profile);

                        if (profile.CreationDate > previousCreationDate)
                        {
                            sorted = false;
                        }

                        previousCreationDate = profile.CreationDate;
                    }

                    if (!sorted)
                    {
                        index.ProvisioningProfiles.Sort(CreationDateComparer);
                    }

                    return(index);
                }
            }
        }
        public static MobileProvisionIndex CreateIndex(string profilesDir, string indexName)
        {
            var index = new MobileProvisionIndex();

            if (Directory.Exists(profilesDir))
            {
                foreach (var fileName in Directory.EnumerateFiles(profilesDir))
                {
                    if (!fileName.EndsWith(".mobileprovision", StringComparison.Ordinal) && !fileName.EndsWith(".provisionprofile", StringComparison.Ordinal))
                    {
                        continue;
                    }

                    try {
                        var profile = ProvisioningProfile.Load(fileName);
                        index.ProvisioningProfiles.Add(profile);
                    } catch (Exception ex) {
                        LoggingService.LogWarning("Error reading provisioning profile '{0}': {1}", fileName, ex);
                    }
                }

                index.ProvisioningProfiles.Sort(CreationDateComparer);
            }
            else
            {
                Directory.CreateDirectory(profilesDir);
            }

            index.Version      = IndexVersion;
            index.LastModified = Directory.GetLastWriteTimeUtc(profilesDir);

            index.Save(indexName);

            return(index);
        }
            internal static ProvisioningProfile Load(BinaryReader reader)
            {
                var profile = new ProvisioningProfile();
                MobileProvisionDistributionType type;
                int count;

                profile.FileName     = reader.ReadString();
                profile.LastModified = new DateTime(reader.ReadInt64(), DateTimeKind.Utc);

                profile.Name = reader.ReadString();
                profile.Uuid = reader.ReadString();
                Enum.TryParse(reader.ReadString(), out type);
                profile.Distribution   = type;
                profile.CreationDate   = new DateTime(reader.ReadInt64(), DateTimeKind.Utc);
                profile.ExpirationDate = new DateTime(reader.ReadInt64(), DateTimeKind.Utc);

                count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    MobileProvisionPlatform platform;

                    Enum.TryParse(reader.ReadString(), out platform);
                    profile.Platforms.Add(platform);
                }

                profile.ApplicationIdentifier = reader.ReadString();

                count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    profile.DeveloperCertificates.Add(DeveloperCertificate.Load(reader));
                }

                return(profile);
            }
Exemple #4
0
        public async Task <ActionResult> GetProvisioningProfilesAsync(CancellationToken cancellationToken)
        {
            var provisioningProfiles = await this.developerProfile.GetProvisioningProfilesAsync(cancellationToken).ConfigureAwait(false);

            var summaries = provisioningProfiles.Select(p => ProvisioningProfile.Read(p)).ToList();

            return(this.Ok(summaries));
        }
Exemple #5
0
        /// <summary>
        /// Asynchronously adds a provisioning profile to the cluster.
        /// </summary>
        /// <param name="profile">
        /// A <see cref="SignedCms"/> object which represents the provisioning profile to add.
        /// </param>
        /// <param name="cancellationToken">
        /// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
        /// </param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public virtual async Task <ProvisioningProfile> AddProvisioningProfileAsync(SignedCms profile, CancellationToken cancellationToken)
        {
            if (profile == null)
            {
                throw new ArgumentNullException(nameof(profile));
            }

            var secret        = profile.AsSecret();
            var signedProfile = ProvisioningProfile.Read(profile);

            secret.Metadata.Name = signedProfile.Uuid.ToString();
            secret.Metadata.Labels[Annotations.DeveloperProfileComponent] = Annotations.ProvisioningProfile;

            await this.secretClient.CreateAsync(secret, cancellationToken).ConfigureAwait(false);

            return(signedProfile);
        }
 ProvisioningProfileBridge(ProvisioningProfile profile)
 {
     internalObject = profile;
 }
        internal static ProvisioningProfileBridge FindLocalProfileByUUID(string UUID, string[] searchPaths = null)
        {
            var profile = ProvisioningProfile.FindLocalProfileByUUID(UUID, searchPaths);

            return(new ProvisioningProfileBridge(profile));
        }
        internal static ProvisioningProfileBridge ParseProvisioningProfileAtPath(string pathToFile)
        {
            var profile = ProvisioningProfile.ParseProvisioningProfileAtPath(pathToFile);

            return(new ProvisioningProfileBridge(profile));
        }
        public static MobileProvisionIndex OpenIndex(string profilesDir, string indexName)
        {
            MobileProvisionIndex index;

            try {
                index = Load(indexName);

                if (Directory.Exists(profilesDir))
                {
                    var mtime = Directory.GetLastWriteTimeUtc(profilesDir);

                    if (index.Version != IndexVersion)
                    {
                        index = CreateIndex(profilesDir, indexName);
                    }
                    else if (index.LastModified < mtime)
                    {
                        var table = new Dictionary <string, ProvisioningProfile> ();

                        foreach (var profile in index.ProvisioningProfiles)
                        {
                            table[profile.FileName] = profile;
                        }

                        foreach (var fileName in Directory.EnumerateFiles(profilesDir))
                        {
                            if (!fileName.EndsWith(".mobileprovision", StringComparison.Ordinal) && !fileName.EndsWith(".provisionprofile", StringComparison.Ordinal))
                            {
                                continue;
                            }

                            ProvisioningProfile profile;
                            bool unknown = false;

                            if (table.TryGetValue(Path.GetFileName(fileName), out profile))
                            {
                                // remove from our lookup table (any leftover key/valie pairs will be used to determine deleted files)
                                table.Remove(Path.GetFileName(fileName));

                                // check if the file has changed since our last resync
                                mtime = File.GetLastWriteTimeUtc(fileName);

                                if (profile.LastModified < mtime)
                                {
                                    // remove the old record
                                    index.ProvisioningProfiles.Remove(profile);

                                    // treat this provisioning profile as if it is unknown
                                    unknown = true;
                                }
                            }
                            else
                            {
                                unknown = true;
                            }

                            if (unknown)
                            {
                                // unknown provisioning profile; add it to our ProvisioningProfiles array
                                try {
                                    profile = ProvisioningProfile.Load(fileName);
                                    index.ProvisioningProfiles.Add(profile);
                                } catch (Exception ex) {
                                    LoggingService.LogWarning("Error reading provisioning profile '{0}': {1}", fileName, ex);
                                }
                            }
                        }

                        // remove provisioning profiles which have been deleted from the file system
                        foreach (var item in table)
                        {
                            index.ProvisioningProfiles.Remove(item.Value);
                        }

                        index.LastModified = Directory.GetLastWriteTimeUtc(profilesDir);
                        index.Version      = IndexVersion;

                        index.ProvisioningProfiles.Sort(CreationDateComparer);

                        index.Save(indexName);
                    }
                }
                else
                {
                    try {
                        File.Delete(indexName);
                    } catch (Exception ex) {
                        LoggingService.LogWarning("Failed to delete stale index '{0}': {1}", indexName, ex);
                    }

                    index.ProvisioningProfiles.Clear();
                }
            } catch {
                index = CreateIndex(profilesDir, indexName);
            }

            return(index);
        }
Exemple #10
0
        public async Task ReadAsync_MobileProvision_Works_Async()
        {
            using (Stream stream = File.OpenRead("DeveloperProfiles/test.mobileprovision"))
            {
                var profile = await ProvisioningProfile.ReadAsync(stream, default).ConfigureAwait(false);

                Assert.Equal("fastlane test app", profile.AppIdName);
                Assert.Equal("439BBM9367", Assert.Single(profile.ApplicationIdentifierPrefix));
                Assert.Equal("iOS", Assert.Single(profile.Platform));
                Assert.Equal(new DateTimeOffset(2015, 11, 8, 21, 9, 3, TimeSpan.Zero), profile.CreationDate);
                Assert.Single(profile.DeveloperCertificates);

                Assert.Null(profile.Entitlements.AddressBook);
                Assert.Null(profile.Entitlements.ApplicationGroups);
                Assert.Equal("439BBM9367.tools.fastlane.app", profile.Entitlements.ApplicationIdentifier);
                Assert.Null(profile.Entitlements.AppSandbox);
                Assert.Null(profile.Entitlements.ApsEnvironment);
                Assert.Null(profile.Entitlements.AssociatedDomains);
                Assert.Null(profile.Entitlements.AudioVideoBridging);
                Assert.True(profile.Entitlements.BetaReportsActive);
                Assert.Null(profile.Entitlements.Bluetooth);
                Assert.Null(profile.Entitlements.BookmarksAppScope);
                Assert.Null(profile.Entitlements.BookmarksDocumentScope);
                Assert.Null(profile.Entitlements.Calendars);
                Assert.Null(profile.Entitlements.Camera);
                Assert.Null(profile.Entitlements.DefaultDataProtection);
                Assert.Null(profile.Entitlements.DownloadsReadWrite);
                Assert.Null(profile.Entitlements.Firewire);
                Assert.False(profile.Entitlements.GetTaskAllow);
                Assert.Null(profile.Entitlements.HealthKit);
                Assert.Null(profile.Entitlements.HomeKit);
                Assert.Null(profile.Entitlements.iCloudDocumentStore);
                Assert.Null(profile.Entitlements.iCloudKeyValueStore);
                Assert.Null(profile.Entitlements.InAppPayments);
                Assert.Null(profile.Entitlements.InheritSecurity);
                Assert.Null(profile.Entitlements.InterAppAudio);
                Assert.Equal("439BBM9367.*", Assert.Single(profile.Entitlements.KeychainAccessGroups));
                Assert.Null(profile.Entitlements.Location);
                Assert.Null(profile.Entitlements.Microphone);
                Assert.Null(profile.Entitlements.MoviesReadOnly);
                Assert.Null(profile.Entitlements.MoviesReadWrite);
                Assert.Null(profile.Entitlements.MusicReadOnly);
                Assert.Null(profile.Entitlements.MusicReadWrite);
                Assert.Null(profile.Entitlements.NetworkClient);
                Assert.Null(profile.Entitlements.NetworkExtensions);
                Assert.Null(profile.Entitlements.NetworkServer);
                Assert.Null(profile.Entitlements.PicturesReadOnly);
                Assert.Null(profile.Entitlements.PicturesReadWrite);
                Assert.Null(profile.Entitlements.Print);
                Assert.Null(profile.Entitlements.ScriptingTargets);
                Assert.Null(profile.Entitlements.Serial);
                Assert.Null(profile.Entitlements.SiriKit);
                Assert.Equal("439BBM9367", profile.Entitlements.TeamIdentifier);
                Assert.Null(profile.Entitlements.Usb);
                Assert.Null(profile.Entitlements.UserSelectedFilesExecutable);
                Assert.Null(profile.Entitlements.UserSelectedFilesReadOnly);
                Assert.Null(profile.Entitlements.UserSelectedFilesReadWrite);
                Assert.Null(profile.Entitlements.VpnApi);

                Assert.Equal(new DateTimeOffset(2016, 11, 7, 20, 58, 52, TimeSpan.Zero), profile.ExpirationDate);
                Assert.Equal("tools.fastlane.app AppStore", profile.Name);
                Assert.Null(profile.ProvisionsAllDevices);
                Assert.Null(profile.ProvisionedDevices);
                Assert.Equal("439BBM9367", Assert.Single(profile.TeamIdentifier));
                Assert.Equal("Felix Krause", profile.TeamName);
                Assert.Equal(364, profile.TimeToLive);
                Assert.Equal(new Guid("98264c6b-5151-4349-8d0f-66691e48ae35"), profile.Uuid);
                Assert.Equal(1, profile.Version);

                Assert.Equal("tools.fastlane.app AppStore", profile.ToString());
            }
        }
Exemple #11
0
 public async Task ReadAsync_ThrowsOnNull_Async()
 {
     await Assert.ThrowsAsync <ArgumentNullException>("stream", () => ProvisioningProfile.ReadAsync(null, default)).ConfigureAwait(false);
 }
Exemple #12
0
 public void Read_ThrowsOnNull()
 {
     Assert.Throws <ArgumentNullException>("signedData", () => ProvisioningProfile.Read(null));
 }