Exemplo n.º 1
0
        async Task <IAppAttachManager> ISelfElevationProxyProvider <IAppAttachManager> .GetProxyFor(SelfElevationLevel selfElevationLevel, CancellationToken cancellationToken)
        {
            if (selfElevationLevel == SelfElevationLevel.HighestAvailable)
            {
                selfElevationLevel = await this.GetMaxAvailableElevation(cancellationToken).ConfigureAwait(false);
            }

            switch (selfElevationLevel)
            {
            case SelfElevationLevel.AsInvoker:
                return(new AppAttachManager(this));    // return user

            case SelfElevationLevel.AsAdministrator:
                if (await UserHelper.IsAdministratorAsync(cancellationToken).ConfigureAwait(false))
                {
                    return(new AppAttachManager(this));
                }

                return(new AppAttachManagerElevationProxy(this.client));    // return admin;

            default:
                throw new InvalidOperationException("Elevation API returned wrong results.");
            }
        }
Exemplo n.º 2
0
        async Task <ISigningManager> ISelfElevationProxyProvider <ISigningManager> .GetProxyFor(SelfElevationLevel selfElevationLevel, CancellationToken cancellationToken)
        {
            if (selfElevationLevel == SelfElevationLevel.HighestAvailable)
            {
                selfElevationLevel = await this.GetMaxAvailableElevation(cancellationToken).ConfigureAwait(false);
            }

            switch (selfElevationLevel)
            {
            case SelfElevationLevel.AsInvoker:
                return(new SigningManager(MsixHeroGistTimeStampFeed.CreateCached()));

            case SelfElevationLevel.AsAdministrator:
                if (await UserHelper.IsAdministratorAsync(cancellationToken).ConfigureAwait(false))
                {
                    return(new SigningManager(MsixHeroGistTimeStampFeed.CreateCached()));
                }

                return(new SigningManagerElevationProxy(this.client, this));

            default:
                throw new InvalidOperationException("Elevation API returned wrong results.");
            }
        }