Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthRequest"/> class with the
        /// given identity.
        /// </summary>
        /// <param name="identity">The identity of the user to authenticate.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="identity"/> is <see langword="null"/>.</exception>
        /// <exception cref="NotSupportedException">If given <paramref name="identity"/> type is not supported.</exception>
        public AuthRequest(CloudIdentity identity)
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }

            var credentials = new AuthDetails();

            credentials.PasswordCredentials = new Credentials(identity.Username, identity.Password, null);

            CloudIdentityWithProject p = identity as CloudIdentityWithProject;

            if (p is CloudIdentityWithProject)
            {
                if (p != null && !string.IsNullOrEmpty(p.ProjectName))
                {
                    credentials.TenantName = p.ProjectName;
                }

                if (p != null && p.ProjectId != null)
                {
                    credentials.TenantId = p.ProjectId.Value;
                }
            }

            Credentials = credentials;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthRequest"/> class with the
        /// given identity.
        /// </summary>
        /// <param name="identity">The identity of the user to authenticate.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="identity"/> is <see langword="null"/>.</exception>
        /// <exception cref="NotSupportedException">If given <paramref name="identity"/> type is not supported.</exception>
        public AuthRequest(CloudIdentity identity)
        {
            if (identity == null)
                throw new ArgumentNullException("identity");

            var credentials = new AuthDetails();

            credentials.PasswordCredentials = new Credentials(identity.Username, identity.Password, null);

            CloudIdentityWithProject p = identity as CloudIdentityWithProject;
            if (p is CloudIdentityWithProject)
            {
                if (p != null && !string.IsNullOrEmpty(p.ProjectName))
                    credentials.TenantName = p.ProjectName;

                if (p != null && p.ProjectId != null)
                    credentials.TenantId = p.ProjectId.Value;
            }

            Credentials = credentials;
        }