Exemple #1
0
 public IAccessToken GetAccessTokenWithCertificate(
     AdalConfiguration config,
     string clientId,
     string certificate,
     AzureAccount.AccountType credentialType)
 {
     throw new NotImplementedException();
 }
 public IAccessToken GetAccessToken(AdalConfiguration config, ShowDialog promptBehavior, string userId, SecureString password,
                                    AzureAccount.AccountType credentialType)
 {
     if (credentialType == AzureAccount.AccountType.User)
     {
         throw new ArgumentException(string.Format(Resources.InvalidCredentialType, "User"), "credentialType");
     }
     return(new ServicePrincipalAccessToken(config, AcquireToken(config, userId, password), this, userId));
 }
        public void CanConvertValidPSAzureAccounts(string id, AzureAccount.AccountType type)
        {
            var oldAccount = new PSAzureRmAccount
            {
                Id          = id,
                AccountType = type.ToString()
            };
            var account = (AzureAccount)oldAccount;

            Assert.Equal(oldAccount.AccountType, account.Type.ToString());
            Assert.Equal(oldAccount.Id, account.Id);
        }
        public void CanConvertValidAzureAccounts(string id, AzureAccount.AccountType type)
        {
            var oldAccount = new AzureAccount()
            {
                Type = type,
                Id   = id
            };

            var account = (PSAzureRmAccount)oldAccount;

            Assert.Equal(oldAccount.Type.ToString(), account.AccountType);
            Assert.Equal(oldAccount.Id, account.Id);
            Assert.DoesNotThrow(() => account.ToString());
        }
        public IAccessToken GetAccessToken(AdalConfiguration config, ShowDialog promptBehavior, string userId, SecureString password,
                                           AzureAccount.AccountType credentialType)
        {
            switch (credentialType)
            {
            case AzureAccount.AccountType.User:
                return(userTokenProvider.GetAccessToken(config, promptBehavior, userId, password, credentialType));

            case AzureAccount.AccountType.ServicePrincipal:
                return(servicePrincipalTokenProvider.GetAccessToken(config, promptBehavior, userId, password, credentialType));

            default:
                throw new ArgumentException(Resources.UnknownCredentialType, "credentialType");
            }
        }
Exemple #6
0
        public IAccessToken GetAccessTokenWithCertificate(
            AdalConfiguration config,
            string clientId,
            string certificate,
            AzureAccount.AccountType credentialType)
        {
            switch (credentialType)
            {
            case AzureAccount.AccountType.ServicePrincipal:
                return(servicePrincipalTokenProvider.GetAccessTokenWithCertificate(config, clientId, certificate, credentialType));

            default:
                throw new ArgumentException(string.Format(Resources.UnsupportedCredentialType, credentialType), "credentialType");
            }
        }
Exemple #7
0
 public IAccessToken GetAccessTokenWithCertificate(
     AdalConfiguration config,
     string clientId,
     string certificateThumbprint,
     AzureAccount.AccountType credentialType)
 {
     if (credentialType == AzureAccount.AccountType.User)
     {
         throw new ArgumentException(string.Format(Resources.InvalidCredentialType, "User"), "credentialType");
     }
     return(new ServicePrincipalAccessToken(
                config,
                AcquireTokenWithCertificate(config, clientId, certificateThumbprint),
                (adalConfig, appId) => this.RenewWithCertificate(adalConfig, appId, certificateThumbprint), clientId));
 }
 public IAccessToken GetAccessTokenWithCertificate(AdalConfiguration config, string principalId, string certificateThumbprint, AzureAccount.AccountType credentialType)
 {
     return(this.accessToken);
 }
 public IAccessToken GetAccessToken(AdalConfiguration config, ShowDialog promptBehavior, string userId, SecureString password,
                                    AzureAccount.AccountType credentialType)
 {
     return(this.accessToken);
 }
Exemple #10
0
 IAccessToken ITokenProvider.GetAccessTokenWithCertificate(AdalConfiguration config, string principalId, string certificateThumbprint,
                                                           AzureAccount.AccountType credentialType)
 {
     return(GetAccessTokenWithCertificate(config, principalId, certificateThumbprint, credentialType));
 }