Пример #1
0
        public void StartAuthorizationShouldReturnStatusWithUrl()
        {
            var state             = "state123";
            var nonce             = "nonce123";
            var authorizeUrl      = "http://www.authorize.com/authorize";
            var encryptedMSISDN   = "abcdef123452452";
            var discoveryResponse = new DiscoveryResponse(new RestResponse(System.Net.HttpStatusCode.OK, responseJson));

            discoveryResponse.OperatorUrls.AuthorizationUrl = authorizeUrl;

            var response = _mobileConnect.StartAuthentication(discoveryResponse, encryptedMSISDN, state, nonce, new MobileConnectRequestOptions());

            Assert.IsNotNull(response);
            Assert.That(response.Url.StartsWith(authorizeUrl));
        }
Пример #2
0
        private async Task StartAuthorization(MobileConnectStatus response)
        {
            _state = Guid.NewGuid().ToString("N");
            _nonce = Guid.NewGuid().ToString("N");
            var newResponse = _mobileConnect.StartAuthentication(_discoveryResponse,
                                                                 response.DiscoveryResponse.ResponseData.subscriber_id, _state, _nonce, new MobileConnectRequestOptions());

            await HandleResponse(newResponse);
        }
        private async Task StartAuthentication(MobileConnectStatus response)
        {
            _state             = Utils.Security.GenerateSecureNonce();
            _nonce             = Utils.Security.GenerateSecureNonce();
            _discoveryResponse = response.DiscoveryResponse;
            _authOptions       = new MobileConnectRequestOptions
            {
                Scope          = GetScope(),
                Context        = "demo",
                BindingMessage = "demo auth",
                // Accept valid results and results indicating validation was skipped due to missing support on the provider
                AcceptedValidationResults = TokenValidationResult.Valid | TokenValidationResult.IdTokenValidationSkipped,
            };

            var newResponse = _mobileConnect.StartAuthentication(_discoveryResponse,
                                                                 response.DiscoveryResponse.ResponseData.subscriber_id, _state, _nonce, _authOptions);

            await HandleResponse(newResponse);
        }