Exemplo n.º 1
0
        public IWampSessionAuthenticator GetSessionAuthenticator
            (WampPendingClientDetails details,
            IWampSessionAuthenticator transportAuthenticator)
        {
            IWampSessionAuthenticator result =
                mSessionAuthenticationFactory.GetSessionAuthenticator
                    (details,
                    transportAuthenticator);

            if (result == null)
            {
                return(null);
            }

            return(new RestrictedSessionAuthenticator(result));
        }
        public override void Hello(IWampSessionClient client, string realm, HelloDetails details)
        {
            IWampClientProxy <TMessage> wampClient = GetWampClient(client, realm, details);

            WampPendingClientDetails clientDetails = new WampPendingClientDetails()
            {
                HelloDetails = details,
                Realm        = realm,
                SessionId    = wampClient.Session
            };

            try
            {
                IWampSessionAuthenticator authenticator =
                    mSessionAuthenticatorFactory.GetSessionAuthenticator
                        (clientDetails,
                        wampClient.Authenticator);

                if (authenticator == null)
                {
                    throw new Exception("Get null authenticator.");
                }

                wampClient.Authenticator = authenticator;

                bool authenticated = authenticator.IsAuthenticated;

                if (authenticated)
                {
                    OnClientAuthenticated(wampClient, details);
                }
                else
                {
                    wampClient.Challenge(authenticator.AuthenticationMethod,
                                         authenticator.ChallengeDetails);
                }
            }
            catch (WampAuthenticationException ex)
            {
                SendAbort(client, ex);
            }
        }