Ejemplo n.º 1
0
 /// <inheritdoc />
 public void StoreCredentails(Guid subscriptionId, string cluster, JobSubmissionClusterDetails credential)
 {
     Dictionary<string, JobSubmissionClusterDetails> clusterCache;
     if (!this.cache.TryGetValue(subscriptionId, out clusterCache))
     {
         clusterCache = new Dictionary<string, JobSubmissionClusterDetails>();
         this.cache.Add(subscriptionId, clusterCache);
     }
     clusterCache[cluster] = credential;
 }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public void StoreCredentails(Guid subscriptionId, string cluster, JobSubmissionClusterDetails credential)
        {
            Dictionary <string, JobSubmissionClusterDetails> clusterCache;

            if (!this.cache.TryGetValue(subscriptionId, out clusterCache))
            {
                clusterCache = new Dictionary <string, JobSubmissionClusterDetails>();
                this.cache.Add(subscriptionId, clusterCache);
            }
            clusterCache[cluster] = credential;
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public JobSubmissionClusterDetails GetCredentails(Guid subscriptionId, string cluster)
        {
            JobSubmissionClusterDetails retval = null;
            Dictionary <string, JobSubmissionClusterDetails> clusterCache;

            if (this.cache.TryGetValue(subscriptionId, out clusterCache))
            {
                clusterCache.TryGetValue(cluster, out retval);
            }
            return(retval);
        }
Ejemplo n.º 4
0
        internal JobSubmissionClusterDetails GetJobSubmissionClusterDetails(bool ignoreCache = false)
        {
            var    asCertCredentials  = this.subscriptionCredentials as JobSubmissionCertificateCredential;
            var    asTokenCredentials = this.subscriptionCredentials as JobSubmissionAccessTokenCredential;
            string clusterName;

            if (asCertCredentials.IsNotNull())
            {
                clusterName = asCertCredentials.Cluster;
            }
            else if (asTokenCredentials.IsNotNull())
            {
                clusterName = asTokenCredentials.Cluster;
            }
            else
            {
                throw new NotSupportedException("Credential type '" + this.subscriptionCredentials.GetType().FullName + "' is not supported.");
            }

            var credentialCache = ServiceLocator.Instance.Locate <IJobSubmissionCache>();

            var retval = credentialCache.GetCredentails(this.subscriptionCredentials.SubscriptionId, clusterName);

            if (retval.IsNull() || ignoreCache)
            {
                var overrideHandlers = ServiceLocator.Instance.Locate <IHDInsightClusterOverrideManager>().GetHandlers(this.subscriptionCredentials, this.Context, this.IgnoreSslErrors);
                ServiceLocator.Instance.Locate <IHDInsightClientFactory>().Create(this.subscriptionCredentials);
                IHDInsightSubscriptionCredentials actualCredentials = ServiceLocator.Instance.Locate <IHDInsightSubscriptionCredentialsFactory>()
                                                                      .Create(this.subscriptionCredentials);
                var hdinsight = ServiceLocator.Instance.Locate <IHDInsightClientFactory>().Create(actualCredentials);

                hdinsight.IgnoreSslErrors = this.IgnoreSslErrors;

                var cluster             = hdinsight.GetCluster(clusterName);
                var versionFinderClient = overrideHandlers.VersionFinder;
                this.AssertSupportedVersion(cluster.VersionNumber, versionFinderClient);

                var remoteCredentials = new BasicAuthCredential()
                {
                    Server   = GatewayUriResolver.GetGatewayUri(cluster.ConnectionUrl, cluster.VersionNumber),
                    UserName = cluster.HttpUserName,
                    Password = cluster.HttpPassword
                };
                retval = new JobSubmissionClusterDetails()
                {
                    Cluster           = cluster,
                    RemoteCredentials = remoteCredentials
                };
                credentialCache.StoreCredentails(this.subscriptionCredentials.SubscriptionId, clusterName, retval);
            }
            return(retval);
        }