コード例 #1
0
        /// <summary>The gShell base implementation of the PowerShell BeginProcessing method.</summary>
        /// <remarks>If a service account needs to be identified, it should be in a child class that overrides
        /// and calls this method.</remarks>
        protected override void BeginProcessing()
        {
            var secrets = CheckForClientSecrets();

            if (secrets != null)
            {
                authUserInfo = EnsureScopesExist(GAuthId);
                ServiceWrapperDictionary[mainBaseType].BuildService(Authenticate(authUserInfo, secrets));

                GWriteProgress = new gWriteProgress(WriteProgress);
            }
            else
            {
                WriteError(new ErrorRecord(new Exception(
                                               "Client Secrets must be set before running cmdlets. Run 'Get-Help "
                                               + "Set-gShellClientSecrets -online' for more information."), "", ErrorCategory.AuthenticationError, null));
            }
        }
コード例 #2
0
        protected override void BeginProcessing()
        {
            var secrets = CheckForClientSecrets();

            if (secrets != null)
            {
                //TODO: figure out the correct ordering of these requests, and add the service account email to the build service
                authUserInfo = EnsureScopesExist(GAuthId);
                //need the gauthID first anyways to ensure that they have permissions, and to look up the service account
                ServiceWrapperDictionary[mainBaseType].BuildService(Authenticate(authUserInfo, secrets));

                if (!string.IsNullOrWhiteSpace(TargetUserEmail))
                {
                    if (!OAuth2Base.infoConsumer.ServiceAccountExists(authUserInfo.domain))
                    {
                        WriteWarning("No service account was found for domain " + authUserInfo.domain +
                                     ". Please set a service" +
                                     " account with Set-GShellServiceAccount, or see https://github.com/squid808/gShell/wiki/Service-Accounts" +
                                     " for more information.");
                    }

                    gShellServiceAccount = GetFullEmailAddress(TargetUserEmail, authUserInfo.domain);
                    ServiceWrapperDictionary[mainBaseType].BuildService(Authenticate(authUserInfo, secrets),
                                                                        gShellServiceAccount);
                }
                else
                {
                    gShellServiceAccount = null;
                }

                GWriteProgress = new gWriteProgress(WriteProgress);
            }
            else
            {
                WriteError(new ErrorRecord(null, (new Exception(
                                                      "Client Secrets must be set before running cmdlets. Run 'Get-Help "
                                                      + "Set-gShellClientSecrets -online' for more information."))));
            }
        }