internal async Task <Microsoft.Azure.Management.Graph.RBAC.Fluent.IServicePrincipal> RefreshCredentialsAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            IEnumerable <KeyCredential> keyCredentials = await manager.Inner.ServicePrincipals.ListKeyCredentialsAsync(Id(), cancellationToken);

            this.cachedCertificateCredentials = new Dictionary <string, ICertificateCredential>();
            if (keyCredentials != null)
            {
                foreach (var cred in keyCredentials)
                {
                    ICertificateCredential cert = new CertificateCredentialImpl <IServicePrincipal>(cred);
                    this.cachedCertificateCredentials.Add(cert.Id, cert);
                }
            }

            IEnumerable <Models.PasswordCredential> passwordCredentials = await manager.Inner.ServicePrincipals.ListPasswordCredentialsAsync(Id(), cancellationToken);

            this.cachedPasswordCredentials = new Dictionary <string, IPasswordCredential>();
            if (passwordCredentials != null)
            {
                foreach (var cred in passwordCredentials)
                {
                    IPasswordCredential cert = new PasswordCredentialImpl <IServicePrincipal>(cred);
                    this.cachedPasswordCredentials.Add(cert.Id, cert);
                }
            }

            return(this);
        }
 public ActiveDirectoryApplicationImpl WithPasswordCredential <T>(PasswordCredentialImpl <T> credential) where T : class
 {
     if (IsInCreateMode())
     {
         if (createParameters.PasswordCredentials == null)
         {
             createParameters.PasswordCredentials = new List <Models.PasswordCredential>();
         }
         createParameters.PasswordCredentials.Add(credential.Inner);
     }
     else
     {
         if (updateParameters.PasswordCredentials == null)
         {
             updateParameters.PasswordCredentials = cachedPasswordCredentials.Values.Select(pc => pc.Inner).ToList();
         }
         updateParameters.PasswordCredentials.Add(credential.Inner);
     }
     return(this);
 }
Example #3
0
        internal async Task <Microsoft.Azure.Management.Graph.RBAC.Fluent.IActiveDirectoryApplication> RefreshCredentialsAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            IEnumerable <KeyCredential> keyCredentials = await manager.Inner.Applications.ListKeyCredentialsAsync(Id(), cancellationToken);

            this.cachedCertificateCredentials = new Dictionary <string, ICertificateCredential>();
            foreach (var cred in keyCredentials)
            {
                ICertificateCredential cert = new CertificateCredentialImpl <IActiveDirectoryApplication>(cred);
                this.cachedCertificateCredentials.Add(cert.Name, cert);
            }

            IEnumerable <Models.PasswordCredential> passwordCredentials = await manager.Inner.Applications.ListPasswordCredentialsAsync(Id(), cancellationToken);

            this.cachedPasswordCredentials = new Dictionary <string, IPasswordCredential>();
            foreach (var cred in passwordCredentials)
            {
                IPasswordCredential cert = new PasswordCredentialImpl <IActiveDirectoryApplication>(cred);
                this.cachedPasswordCredentials.Add(cert.Name, cert);
            }

            return(this);
        }
 public ServicePrincipalImpl WithPasswordCredential <T>(PasswordCredentialImpl <T> credential) where T : class
 {
     this.passwordCredentialsToCreate.Add(credential);
     return(this);
 }
 /// <summary>
 /// Attach a credential to this model.
 /// </summary>
 /// <param name="credential">The credential to attach to.</param>
 /// <return>The interface itself.</return>
 IWithCreate Microsoft.Azure.Management.Graph.RBAC.Fluent.IHasCredential <IWithCreate> .WithPasswordCredential(PasswordCredentialImpl <IWithCreate> credential)
 {
     return(this.WithPasswordCredential(credential) as Microsoft.Azure.Management.Graph.RBAC.Fluent.ServicePrincipalImpl);
 }
 /// <summary>
 /// Attach a credential to this model.
 /// </summary>
 /// <param name="credential">The credential to attach to.</param>
 /// <return>The interface itself.</return>
 IUpdate Microsoft.Azure.Management.Graph.RBAC.Fluent.IHasCredential <IUpdate> .WithPasswordCredential(PasswordCredentialImpl <IUpdate> credential)
 {
     return(this.WithPasswordCredential(credential));
 }
 /// <summary>
 /// Attach a credential to this model.
 /// </summary>
 /// <param name="credential">The credential to attach to.</param>
 /// <return>The interface itself.</return>
 IUpdate Microsoft.Azure.Management.Graph.RBAC.Fluent.IHasCredential <IUpdate> .WithPasswordCredential(PasswordCredentialImpl <IUpdate> credential)
 {
     return(this.WithPasswordCredential(credential) as Microsoft.Azure.Management.Graph.RBAC.Fluent.ActiveDirectoryApplicationImpl);
 }