Represents a set of credentials used for accessing a cloud account. Individual providers may impose restrictions on the values allowed for individual properties.
コード例 #1
0
ファイル: ConoHaService.cs プロジェクト: krowin24/backuptool
        public bool Authenticate()
        {
            ConoHa.UserName   = Options.UserName;
            ConoHa.TenantId   = Options.TenantId;
            ConoHa.TenantName = Options.TenantName;

            ConoHaNet.Objects.CloudIdentity Identity = null;

            if ((Options.TenantName != null) || (Options.TenantId != null))
            {
                Identity = new ConoHaNet.Objects.Identity.CloudIdentityWithProject()
                {
                    Username = Options.UserName, Password = Options.Password, ProjectId = (new ConoHaNet.Objects.ProjectId(Options.TenantId ?? Options.TenantName)), ProjectName = Options.TenantName
                }
            }
            ;
            else
            {
                Identity = new CloudIdentity()
                {
                    Username = Options.UserName, Password = Options.Password
                }
            };

            ConoHa.Identity      = Identity;
            ConoHa.DefaultRegion = Options.Region;

            ConoHa.IdentityProvider.Authenticate(ConoHa.Identity);

            return(true);
        }
コード例 #2
0
ファイル: ConoHaOperator.cs プロジェクト: krowin24/backuptool
            public bool Authenticate()
            {
                this.m_Core.Logger?.WriteLine("Identity authenticate request.");
                //this.m_Core.Logger?.WriteLine(System.String.Format("[NAME] {0} / [PASS] {1}", this.UserName, this.Password));

                ConoHa.UserName   = this.UserName;
                ConoHa.TenantId   = this.TenantId;
                ConoHa.TenantName = this.TenantName;

                ConoHaNet.Objects.CloudIdentity Identity = null;

                if ((this.TenantName != null) || (this.TenantId != null))
                {
                    Identity = new ConoHaNet.Objects.Identity.CloudIdentityWithProject()
                    {
                        Username = this.UserName, Password = this.Password, ProjectId = (new ConoHaNet.Objects.ProjectId(this.TenantId ?? this.TenantName)), ProjectName = this.TenantName
                    }
                }
                ;
                else
                {
                    Identity = new CloudIdentity()
                    {
                        Username = this.UserName, Password = this.Password
                    }
                };

                ConoHa.Identity      = Identity;
                ConoHa.DefaultRegion = this.DefaultRegion;

                try {
                    ConoHa.IdentityProvider.Authenticate(ConoHa.Identity);
                } catch (System.Exception ex) {
                    this.m_Core.Logger?.WriteLine(ex.Message, eLogLevel.ERROR);
                    return(false);
                }

                return(true);
            }