private void InitializeConfiguration()
        {
            IPeopleConnectApplicationConfig peopleConnectApplicationConfig = CachedPeopleConnectApplicationConfig.Instance.ReadLinkedIn();

            this.authConfig = LinkedInConfig.CreateForAppAuth(peopleConnectApplicationConfig.AppId, peopleConnectApplicationConfig.AppSecretClearText, peopleConnectApplicationConfig.RequestTokenEndpoint, peopleConnectApplicationConfig.AccessTokenEndpoint, peopleConnectApplicationConfig.WebRequestTimeout, peopleConnectApplicationConfig.WebProxyUri, peopleConnectApplicationConfig.ReadTimeUtc);
            this.appConfig  = new LinkedInAppConfig(peopleConnectApplicationConfig.AppId, peopleConnectApplicationConfig.AppSecretClearText, peopleConnectApplicationConfig.ProfileEndpoint, peopleConnectApplicationConfig.ConnectionsEndpoint, peopleConnectApplicationConfig.RemoveAppEndpoint, peopleConnectApplicationConfig.WebRequestTimeout, peopleConnectApplicationConfig.WebProxyUri);
        }
Beispiel #2
0
 private static void UploadContacts(MailboxSession mailboxSession, string accessToken)
 {
     NewFacebookSubscription.Tracer.TraceFunction(0L, "Entering NewFacebookSubscription.UploadContacts. Mailbox {0}.", new object[]
     {
         mailboxSession.Identity
     });
     try
     {
         IPeopleConnectApplicationConfig peopleConnectApplicationConfig = CachedPeopleConnectApplicationConfig.Instance.ReadFacebook();
         string graphApiEndpoint = peopleConnectApplicationConfig.GraphApiEndpoint;
         using (FacebookClient facebookClient = new FacebookClient(new Uri(graphApiEndpoint)))
         {
             ContactsUploaderPerformanceTracker contactsUploaderPerformanceTracker = new ContactsUploaderPerformanceTracker();
             IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope();
             if (currentActivityScope != null)
             {
                 currentActivityScope.UserState = contactsUploaderPerformanceTracker;
             }
             else
             {
                 NewFacebookSubscription.Tracer.TraceFunction(0L, "Can't add metadata for Contacts upload as there is no current activity scope.");
             }
             FacebookContactsUploader facebookContactsUploader = new FacebookContactsUploader(contactsUploaderPerformanceTracker, facebookClient, peopleConnectApplicationConfig, (PropertyDefinition[] propertiesToLoad) => new RecursiveContactsEnumerator(mailboxSession, new XSOFactory(), DefaultFolderType.Contacts, propertiesToLoad));
             facebookContactsUploader.UploadContacts(accessToken);
         }
     }
     finally
     {
         NewFacebookSubscription.Tracer.TraceFunction(0L, "Leaving NewFacebookSubscription.UploadContacts. Mailbox {0}.", new object[]
         {
             mailboxSession.Identity
         });
     }
 }
Beispiel #3
0
 public IPeopleConnectApplicationConfig OverrideWith(IPeopleConnectApplicationConfig other)
 {
     if (other == null)
     {
         return(this);
     }
     if (this.Equals(other))
     {
         return(this);
     }
     return(new CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig
     {
         AccessTokenEndpoint = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.AccessTokenEndpoint, other.AccessTokenEndpoint),
         AppId = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.AppId, other.AppId),
         AppSecretEncrypted = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith <Func <string, string> >(Tuple.Create <string, Func <string, string> >(this.AppSecretEncrypted, this.DecryptAppSecret), Tuple.Create <string, Func <string, string> >(other.AppSecretEncrypted, other.DecryptAppSecret)).Item1,
         DecryptAppSecret = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith <Func <string, string> >(Tuple.Create <string, Func <string, string> >(this.AppSecretEncrypted, this.DecryptAppSecret), Tuple.Create <string, Func <string, string> >(other.AppSecretEncrypted, other.DecryptAppSecret)).Item2,
         AuthorizationEndpoint = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.AuthorizationEndpoint, other.AuthorizationEndpoint),
         ProfileEndpoint = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.ProfileEndpoint, other.ProfileEndpoint),
         ConnectionsEndpoint = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.ConnectionsEndpoint, other.ConnectionsEndpoint),
         RemoveAppEndpoint = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.RemoveAppEndpoint, other.RemoveAppEndpoint),
         ConsentRedirectEndpoint = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.ConsentRedirectEndpoint, other.ConsentRedirectEndpoint),
         GraphApiEndpoint = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.GraphApiEndpoint, other.GraphApiEndpoint),
         GraphTokenEndpoint = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.GraphTokenEndpoint, other.GraphTokenEndpoint),
         RequestTokenEndpoint = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.RequestTokenEndpoint, other.RequestTokenEndpoint),
         WebProxyUri = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.WebProxyUri, other.WebProxyUri),
         WebRequestTimeout = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.WebRequestTimeout, other.WebRequestTimeout),
         ReadTimeUtc = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith(this.ReadTimeUtc, other.ReadTimeUtc),
         SkipContactUpload = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith <bool>(new bool?(this.SkipContactUpload), new bool?(other.SkipContactUpload)),
         ContinueOnContactUploadFailure = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith <bool>(new bool?(this.ContinueOnContactUploadFailure), new bool?(other.ContinueOnContactUploadFailure)),
         WaitForContactUploadCommit = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith <bool>(new bool?(this.WaitForContactUploadCommit), new bool?(other.WaitForContactUploadCommit)),
         NotifyOnEachContactUpload = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith <bool>(new bool?(this.NotifyOnEachContactUpload), new bool?(other.NotifyOnEachContactUpload)),
         MaximumContactsToUpload = CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig.OverrideWith <int>(new int?(this.MaximumContactsToUpload), new int?(other.MaximumContactsToUpload))
     });
 }
Beispiel #4
0
            public bool TryGetValue(string key, out IPeopleConnectApplicationConfig value)
            {
                CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig peopleConnectApplicationConfig;
                bool result = this.cache.TryGetValue(key, out peopleConnectApplicationConfig);

                value = peopleConnectApplicationConfig;
                return(result);
            }
Beispiel #5
0
 private void ValidateFacebookConfig(IPeopleConnectApplicationConfig config)
 {
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.AppId, Strings.InvalidConfigurationMissingFacebookAppId);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfMatches(config.AppId, CachedPeopleConnectApplicationConfig.KnownInvalidAppIds, StringComparer.OrdinalIgnoreCase, Strings.InvalidConfigurationFacebookAppId);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.AppSecretEncrypted, Strings.InvalidConfigurationMissingFacebookAppSecret);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfMatches(config.AppSecretClearText, CachedPeopleConnectApplicationConfig.KnownInvalidAppSecrets, StringComparer.OrdinalIgnoreCase, Strings.InvalidConfigurationFacebookAppSecret);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.AuthorizationEndpoint, Strings.InvalidConfigurationMissingFacebookAuthorizationEndpoint);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.GraphTokenEndpoint, Strings.InvalidConfigurationMissingFacebookGraphTokenEndpoint);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.GraphApiEndpoint, Strings.InvalidConfigurationMissingFacebookGraphApiEndpoint);
 }
        private Uri GetAuthorizationCallbackUrl()
        {
            IPeopleConnectApplicationConfig peopleConnectApplicationConfig = CachedPeopleConnectApplicationConfig.Instance.ReadLinkedIn();

            if (!string.IsNullOrWhiteSpace(peopleConnectApplicationConfig.ConsentRedirectEndpoint))
            {
                return(new Uri(peopleConnectApplicationConfig.ConsentRedirectEndpoint));
            }
            return(EcpFeature.LinkedInSetup.GetFeatureDescriptor().AbsoluteUrl);
        }
Beispiel #7
0
 private void ValidateLinkedInConfig(IPeopleConnectApplicationConfig config)
 {
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.AccessTokenEndpoint, Strings.InvalidConfigurationMissingLinkedInAccessTokenEndpoint);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.AppId, Strings.InvalidConfigurationMissingLinkedInAppId);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfMatches(config.AppId, CachedPeopleConnectApplicationConfig.KnownInvalidAppIds, StringComparer.OrdinalIgnoreCase, Strings.InvalidConfigurationLinkedInAppId);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.AppSecretEncrypted, Strings.InvalidConfigurationMissingLinkedInAppSecret);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfMatches(config.AppSecretClearText, CachedPeopleConnectApplicationConfig.KnownInvalidAppSecrets, StringComparer.OrdinalIgnoreCase, Strings.InvalidConfigurationLinkedInAppSecret);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.RequestTokenEndpoint, Strings.InvalidConfigurationMissingLinkedInRequestTokenEndpoint);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.ConnectionsEndpoint, Strings.InvalidConfigurationMissingLinkedInConnectionsEndpoint);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.ProfileEndpoint, Strings.InvalidConfigurationMissingLinkedInProfileEndpoint);
     CachedPeopleConnectApplicationConfig.ThrowExchangeConfigurationExceptionIfBlank(config.RemoveAppEndpoint, Strings.InvalidConfigurationMissingLinkedInInvalidateTokenEndpoint);
 }
Beispiel #8
0
        private string GetRedirectUri()
        {
            IPeopleConnectApplicationConfig peopleConnectApplicationConfig = CachedPeopleConnectApplicationConfig.Instance.ReadFacebook();
            string text = string.IsNullOrWhiteSpace(peopleConnectApplicationConfig.ConsentRedirectEndpoint) ? EcpFeature.FacebookSetup.GetFeatureDescriptor().AbsoluteUrl.ToEscapedString() : peopleConnectApplicationConfig.ConsentRedirectEndpoint;

            if (this.IsReconnect())
            {
                UriBuilder uriBuilder = new UriBuilder(text)
                {
                    Query = string.Format("{0}={1}", "Action", "Reconnect")
                };
                text = uriBuilder.Uri.ToEscapedString();
            }
            return(text);
        }
Beispiel #9
0
 public void Add(string key, IPeopleConnectApplicationConfig value)
 {
     this.cache.Add(key, (CachedPeopleConnectApplicationConfig.PeopleConnectApplicationConfig)value);
 }
Beispiel #10
0
 internal FacebookContactsUploader(IContactsUploaderPerformanceTracker performanceTracker, IFacebookClient client, IPeopleConnectApplicationConfig configuration, Func <PropertyDefinition[], IEnumerable <IStorePropertyBag> > contactsEnumeratorBuilder)
 {
     ArgumentValidator.ThrowIfNull("performanceTracker", performanceTracker);
     ArgumentValidator.ThrowIfNull("client", client);
     ArgumentValidator.ThrowIfNull("configuration", configuration);
     ArgumentValidator.ThrowIfNull("contactsEnumerator", contactsEnumeratorBuilder);
     this.performanceTracker = performanceTracker;
     this.client             = client;
     this.configuration      = configuration;
     PropertyDefinition[] arg = PropertyDefinitionCollection.Merge <PropertyDefinition>(FacebookContactsUploader.ContactPropertiesToExport, FacebookContactsUploader.AdditionalContactPropertiesToLoad);
     this.contactsEnumerator = contactsEnumeratorBuilder(arg);
 }
Beispiel #11
0
        private void InitializeConfiguration(string redirectUri)
        {
            IPeopleConnectApplicationConfig peopleConnectApplicationConfig = CachedPeopleConnectApplicationConfig.Instance.ReadFacebook();

            this.config = FacebookAuthenticatorConfig.CreateForAppAuthentication(peopleConnectApplicationConfig.AppId, peopleConnectApplicationConfig.AppSecretClearText, redirectUri, peopleConnectApplicationConfig.GraphTokenEndpoint, new FacebookAuthenticationWebClient(), peopleConnectApplicationConfig.WebRequestTimeout, peopleConnectApplicationConfig.ReadTimeUtc);
        }
Beispiel #12
0
        private LinkedInAppConfig ReadAppConfiguration()
        {
            IPeopleConnectApplicationConfig peopleConnectApplicationConfig = CachedPeopleConnectApplicationConfig.Instance.ReadLinkedIn();

            return(new LinkedInAppConfig(peopleConnectApplicationConfig.AppId, peopleConnectApplicationConfig.AppSecretClearText, peopleConnectApplicationConfig.ProfileEndpoint, peopleConnectApplicationConfig.ConnectionsEndpoint, peopleConnectApplicationConfig.RemoveAppEndpoint, peopleConnectApplicationConfig.WebRequestTimeout, peopleConnectApplicationConfig.WebProxyUri));
        }
Beispiel #13
0
        private LinkedInConfig ReadConfiguration()
        {
            IPeopleConnectApplicationConfig peopleConnectApplicationConfig = CachedPeopleConnectApplicationConfig.Instance.ReadLinkedIn();

            return(LinkedInConfig.CreateForAppAuth(peopleConnectApplicationConfig.AppId, peopleConnectApplicationConfig.AppSecretClearText, peopleConnectApplicationConfig.RequestTokenEndpoint, peopleConnectApplicationConfig.AccessTokenEndpoint, peopleConnectApplicationConfig.WebRequestTimeout, peopleConnectApplicationConfig.WebProxyUri, peopleConnectApplicationConfig.ReadTimeUtc));
        }
Beispiel #14
0
        private FacebookAuthenticatorConfig ReadConfiguration()
        {
            IPeopleConnectApplicationConfig peopleConnectApplicationConfig = CachedPeopleConnectApplicationConfig.Instance.ReadFacebook();

            return(FacebookAuthenticatorConfig.CreateForAppAuthorization(peopleConnectApplicationConfig.AppId, this.GetRedirectUri(), peopleConnectApplicationConfig.AuthorizationEndpoint, Thread.CurrentThread.CurrentUICulture, peopleConnectApplicationConfig.ReadTimeUtc));
        }