예제 #1
0
        public static S2SAuthClient CreateWithCertificateByName(long clientSiteId, string clientCertificateName, Uri msaAuthenticationUrl, IWebClient webClient = null)
        {
            if (string.IsNullOrEmpty(clientCertificateName))
            {
                throw new ArgumentException("Client certificate name cannot be null");
            }
            X509Certificate2 certificate = CertificateFinder.FindCertificateByName(clientCertificateName, true, true);

            return(S2SAuthClient.Create(clientSiteId, certificate, msaAuthenticationUrl, webClient));
        }
예제 #2
0
        public static S2SAuthClient Create(long clientSiteId, X509Certificate2 certificate, Uri msaAuthenticationUrl, IWebClient webClient = null)
        {
            string        key           = clientSiteId + "-" + certificate.GetSerialNumberString();
            S2SAuthClient s2SAuthClient = S2SAuthClient.ClientCache.Get(key, null) as S2SAuthClient;

            if (s2SAuthClient != null)
            {
                return(s2SAuthClient);
            }
            S2SAuthClient result;

            lock (S2SAuthClient.ClientCacheLock)
            {
                if (S2SAuthClient.ClientCache.Get(key, null) == null)
                {
                    s2SAuthClient = new S2SAuthClient(clientSiteId, certificate, msaAuthenticationUrl, webClient);
                    S2SAuthClient.ClientCache.Add(key, s2SAuthClient, new CacheItemPolicy(), null);
                }
                result = (S2SAuthClient.ClientCache.Get(key, null) as S2SAuthClient);
            }
            return(result);
        }