public void AuthenticateParametersArePassedToSessionAuthenticator()
        {
            MockSessionAuthenticationFactory mockSessionAuthenticationFactory =
                new MockSessionAuthenticationFactory();

            string receivedSignature = null;
            AuthenticateExtraData receivedExtraData = null;

            mockSessionAuthenticationFactory.SetGetSessionAuthenticator
                ((clientDetails, transportAuthenticator) =>
            {
                MockSessionAuthenticator mockSessionAuthenticator = new MockSessionAuthenticator();
                mockSessionAuthenticator.SetAuthenticationMethod("ticket");
                mockSessionAuthenticator.SetAuthenticate((signature, extra) =>
                {
                    receivedSignature = signature;
                    receivedExtraData = extra;
                });
                return(mockSessionAuthenticator);
            });


            WampAuthenticationPlayground playground =
                new WampAuthenticationPlayground(mockSessionAuthenticationFactory);

            playground.Host.Open();

            string clientAuthMethod = null;

            ChallengeDetails clientChallengeDetails = null;

            Mock <IWampClient <JToken> > clientMock = new Mock <IWampClient <JToken> >();

            IWampServerProxy serverProxy =
                playground.CreateRawConnection(clientMock.Object);

            serverProxy.Hello("realm1", new HelloDetailsHack()
            {
                AuthenticationId      = "joe",
                AuthenticationMethods = new string[] { "wampcra", "ticket" }
            });

            serverProxy.Authenticate("Barack Hussein", new MyAuthenticateExtraData()
            {
                Wife = "Michelle"
            });

            MyAuthenticateExtraData deserializedExtraData =
                receivedExtraData.OriginalValue.Deserialize <MyAuthenticateExtraData>();

            Assert.That(receivedSignature, Is.EqualTo("Barack Hussein"));

            Assert.That(deserializedExtraData.Wife, Is.EqualTo("Michelle"));
        }
Ejemplo n.º 2
0
 public override void Authenticate(string signature, AuthenticateExtraData extra)
 {
     if (signature == _mTicket)
     {
         IsAuthenticated = true;
         Authorizer      = _authorizer;
         WelcomeDetails  = new WelcomeDetails
         {
             AuthenticationProvider = "dynamic",
             AuthenticationRole     = "user"
         };
     }
 }
        public override void Authenticate(string signature, AuthenticateExtraData extra)
        {
            string computedSignature =
                WampCraHelpers.Sign(Secret, AuthenticationChallenge);

            if (computedSignature == signature)
            {
                IsAuthenticated = true;
            }
            else
            {
                throw new WampAuthenticationException("signature is invalid",
                                                      WampErrors.NotAuthorized);
            }
        }
        public override void Authenticate(string signature, AuthenticateExtraData extra)
        {
            if (_apiKeyValidator.ValidateAsync(signature).Result)
            {
                _sessionRepository.AddSessionId(signature, _details.SessionId);

                IsAuthenticated = true;

                WelcomeDetails = new WelcomeDetails
                {
                    AuthenticationRole = "HFT client"
                };

                Authorizer = TokenAuthorizer.Instance;
            }
        }
        public override void Authenticate(string signature, AuthenticateExtraData extra)
        {
            if (_tokenValidator.Validate(signature))
            {
                _sessionCache.AddSessionId(signature, _details.SessionId);

                IsAuthenticated = true;

                WelcomeDetails = new WelcomeDetails
                {
                    AuthenticationRole = "Lykke client"
                };

                Authorizer = TokenAuthorizer.Instance;
            }
        }
Ejemplo n.º 6
0
        public void Challenge(string authMethod, ChallengeDetails extra)
        {
            try
            {
                AuthenticationResponse response = mAuthenticator.Authenticate(authMethod, extra);

                AuthenticateExtraData authenticationExtraData = response.Extra ?? EmptyAuthenticateDetails;

                string authenticationSignature = response.Signature;

                mServerProxy.Authenticate(authenticationSignature, authenticationExtraData);
            }
            catch (WampAuthenticationException ex)
            {
                mServerProxy.Abort(ex.Details, ex.Reason);
                OnConnectionError(ex);
            }
        }
 public override void Authenticate(IWampSessionClient client, string signature, AuthenticateExtraData extra)
 {
     Extra     = extra;
     Signature = signature;
 }
 public override void Authenticate(string signature, AuthenticateExtraData extra)
 {
     mAuthenticate(signature, extra);
 }
 public void Authenticate(string signature, AuthenticateExtraData extra)
 {
     Send(mAuthenticate2, signature, extra);
 }
Ejemplo n.º 10
0
 public override void Authenticate(string signature, AuthenticateExtraData extra)
 {
     throw new WampAuthenticationException("Cookie wasn't present");
 }
Ejemplo n.º 11
0
 /// <summary>
 /// <see cref="IWampSessionAuthenticator.Authenticate"/>
 /// </summary>
 public abstract void Authenticate(string signature, AuthenticateExtraData extra);
Ejemplo n.º 12
0
 public virtual void Authenticate(IWampSessionClient client, string signature, AuthenticateExtraData extra)
 {
     // TODO: disconnect client.
 }
        public override void Authenticate(IWampSessionClient client, string signature, AuthenticateExtraData extra)
        {
            IWampClientProxy <TMessage> wampClient = client as IWampClientProxy <TMessage>;

            IWampSessionAuthenticator authenticator = wampClient.Authenticator;

            try
            {
                authenticator.Authenticate(signature, extra);

                if (authenticator.IsAuthenticated)
                {
                    OnClientAuthenticated(wampClient, wampClient.HelloDetails);
                }
                else
                {
                    SendAbort(client,
                              new WampAuthenticationException(new AbortDetails(),
                                                              WampErrors.AuthorizationFailed));
                }
            }
            catch (WampAuthenticationException ex)
            {
                SendAbort(client, ex);
            }
        }
Ejemplo n.º 14
0
 public void Authenticate(string signature, AuthenticateExtraData extra)
 {
     mAuthenticator.Authenticate(signature, extra);
 }
 public virtual void Authenticate(IWampSessionClient client, string signature, AuthenticateExtraData extra)
 {
 }
Ejemplo n.º 16
0
 public void Authenticate(IWampSessionClient client, string signature, AuthenticateExtraData extra)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 17
0
        public sealed override void Authenticate(string signature, AuthenticateExtraData extra)
        {
            TExtra deserialized = extra.OriginalValue.Deserialize <TExtra>();

            Authenticate(signature, deserialized);
        }