Beispiel #1
0
        protected AcquireTokenHandlerBase(RequestData requestData)
        {
            this.Authenticator     = requestData.Authenticator;
            this.CallState         = CreateCallState(this.Authenticator.CorrelationId);
            brokerHelper.CallState = this.CallState;

            var msg = string.Format(CultureInfo.CurrentCulture,
                                    "ADAL {0} with assembly version '{1}', file version '{2}' and informational version '{3}' is running...",
                                    platformInformation.GetProductName(), AdalIdHelper.GetAdalVersion(),
                                    AdalIdHelper.GetAssemblyFileVersion(), AdalIdHelper.GetAssemblyInformationalVersion());

            CallState.Logger.Information(null, msg);
            CallState.Logger.InformationPii(null, msg);

            msg = string.Format(CultureInfo.CurrentCulture,
                                "=== Token Acquisition started: \n\tCacheType: {0}\n\tAuthentication Target: {1}\n\t",
                                tokenCache != null
                    ? tokenCache.GetType().FullName +
                                string.Format(CultureInfo.CurrentCulture, " ({0} items)", tokenCache.Count)
                    : "null",
                                requestData.SubjectType);
            if (InstanceDiscovery.IsWhitelisted(requestData.Authenticator.GetAuthorityHost()))
            {
                msg += string.Format(CultureInfo.CurrentCulture,
                                     ", Authority Host: {0}",
                                     requestData.Authenticator.GetAuthorityHost());
            }
            CallState.Logger.Information(CallState, msg);


            var piiMsg = string.Format(CultureInfo.CurrentCulture,
                                       "=== Token Acquisition started:\n\tAuthority: {0}\n\tResource: {1}\n\tClientId: {2}\n\tCacheType: {3}\n\tAuthentication Target: {4}\n\t",
                                       requestData.Authenticator.Authority, requestData.Resource, requestData.ClientKey.ClientId,
                                       (tokenCache != null)
                    ? tokenCache.GetType().FullName +
                                       string.Format(CultureInfo.CurrentCulture, " ({0} items)", tokenCache.Count)
                    : "null",
                                       requestData.SubjectType);

            CallState.Logger.InformationPii(this.CallState, piiMsg);

            this.tokenCache = requestData.TokenCache;

            if (string.IsNullOrWhiteSpace(requestData.Resource))
            {
                throw new ArgumentNullException("resource");
            }

            this.Resource         = (requestData.Resource != NullResource) ? requestData.Resource : null;
            this.ClientKey        = requestData.ClientKey;
            this.TokenSubjectType = requestData.SubjectType;

            this.LoadFromCache = (tokenCache != null);
            this.StoreToCache  = (tokenCache != null);
            this.SupportADFS   = false;

            this.brokerParameters = new Dictionary <string, string>();
            brokerParameters[BrokerParameter.Authority]     = requestData.Authenticator.Authority;
            brokerParameters[BrokerParameter.Resource]      = requestData.Resource;
            brokerParameters[BrokerParameter.ClientId]      = requestData.ClientKey.ClientId;
            brokerParameters[BrokerParameter.CorrelationId] = this.CallState.CorrelationId.ToString();

            var adalVersion = AdalIdHelper.GetAdalVersion();

            if (AdalIdHelper.VersionNotDetermined.Equals(adalVersion))
            {
                adalVersion = AdalIdHelper.GetAssemblyFileVersion();
            }
            brokerParameters[BrokerParameter.ClientVersion] = adalVersion;

            this.ResultEx = null;

            CacheQueryData.ExtendedLifeTimeEnabled = requestData.ExtendedLifeTimeEnabled;
        }