Exemple #1
0
        /// <summary>
        /// Required for support SAML logins
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            IOAuthResponse response;

            if (_authenticationHelper.IsComplete(e.Url, out response))
            {
                HandleOAuthResponse(response);
            }
        }
        public void OAuthResponseBase_PropertiesMapped()
        {
            //Arrange
            var oauth2AuthHelper = new OAuth2AuthenticationHelper(GetOAuthCompleteUri());
            var list             = GetNavigationUris(1);

            var dictionary = new Dictionary <string, string>();

            dictionary.Add("appcp", "sharefile.com");
            dictionary.Add("apicp", "sf-api.com");
            dictionary.Add("randomKey", "randomValue");

            list.Add(GetOAuthCompleteUriWithParameters(dictionary));

            //Act
            bool           found    = false;
            IOAuthResponse response = null;

            foreach (var uri in list)
            {
                if (oauth2AuthHelper.IsComplete(uri, out response))
                {
                    found = true;
                    break;
                }
            }

            response.GetType().Should().Be(typeof(OAuthResponseBase));
            response.Properties.Should().NotBeNull();
            var oauthResponseBase = response as OAuthResponseBase;

            oauthResponseBase.ApiControlPlane.Should().Be("sf-api.com");
            oauthResponseBase.ApplicationControlPlane.Should().Be("sharefile.com");
            oauthResponseBase.Properties.Should().ContainKey("randomKey");
        }
        public bool GetOAuthResponse(bool includeCompleteUri, string key1, string key2, Type expectedType)
        {
            //Arrange
            var oauth2AuthHelper = new OAuth2AuthenticationHelper(GetOAuthCompleteUri());
            var list             = GetNavigationUris();

            var dictionary = new Dictionary <string, string>();

            dictionary.Add(key1, key1 + 123);
            dictionary.Add(key2, key2 + 123);

            if (includeCompleteUri)
            {
                list.Add(GetOAuthCompleteUriWithParameters(dictionary));
            }

            //Act
            bool           found    = false;
            IOAuthResponse response = null;

            foreach (var uri in list)
            {
                if (oauth2AuthHelper.IsComplete(uri, out response))
                {
                    found = true;
                    break;
                }
            }

            return(found && (response != null && response.GetType() == expectedType));
        }