Exemplo n.º 1
0
 public WampSessionManagementService(IWampHostedRealm realm, IWampUriValidator uriValidator = null)
 {
     mRealm                 = realm;
     mUriValidator          = uriValidator ?? new LooseUriValidator();
     mRealm.SessionCreated += OnSessionCreated;
     mRealm.SessionClosed  += OnSessionClosed;
 }
        public static IWampBindingHost CreateHost <TMessage>
            (this IWampBinding <TMessage> binding,
            IWampHostedRealmContainer realmContainer,
            IWampConnectionListener <TMessage> connectionListener,
            IWampUriValidator uriValidator,
            IWampSessionMapper sessionIdMap)
        {
            if (binding is IWampRouterBinding <TMessage> routerBinding)
            {
                return(routerBinding.CreateHost(realmContainer, connectionListener, sessionIdMap));
            }
            else
            {
                IWampRouterBuilder routerBuilder = new WampRouterBuilder(uriValidator);

                WampBindingHost <TMessage> result =
                    new WampBindingHost <TMessage>(realmContainer,
                                                   routerBuilder,
                                                   connectionListener,
                                                   binding,
                                                   sessionIdMap);

                return(result);
            }
        }
 /// <summary>
 /// Initializes a new instance of <see cref="WampMultiAuthenticationHost"/> given the
 /// <see cref="IWampSessionAuthenticatorFactory"/> to use.
 /// </summary>
 /// <param name="defaultAuthenticatorFactory">A default <see cref="IWampSessionAuthenticatorFactory"/> that will be used for the overload <see cref="RegisterTransport(IWampTransport,IEnumerable{WampSharp.V2.Binding.IWampBinding})"/></param>
 /// <param name="realmContainer">The <see cref="IWampRealmContainer"/> associated with this
 /// host.</param>
 /// <param name="uriValidator">The <see cref="IWampUriValidator"/> used to validate uris.</param>
 public WampMultiAuthenticationHost(IWampSessionAuthenticatorFactory defaultAuthenticatorFactory = null,
                                    IWampRealmContainer realmContainer = null,
                                    IWampUriValidator uriValidator     = null)
     : base(realmContainer, uriValidator)
 {
     mDefaultAuthenticatorFactory = defaultAuthenticatorFactory;
 }
        public static IWampBindingHost CreateHost <TMessage>
            (this IWampBinding <TMessage> binding,
            IWampHostedRealmContainer realmContainer,
            IWampConnectionListener <TMessage> connectionListener,
            IWampUriValidator uriValidator)
        {
            IWampRouterBinding <TMessage> routerBinding = binding as IWampRouterBinding <TMessage>;

            if (routerBinding != null)
            {
                return(routerBinding.CreateHost(realmContainer, connectionListener));
            }
            else
            {
                IWampRouterBuilder routerBuilder = new WampRouterBuilder(uriValidator);

                WampBindingHost <TMessage> result =
                    new WampBindingHost <TMessage>(realmContainer,
                                                   routerBuilder,
                                                   connectionListener,
                                                   binding);

                return(result);
            }
        }
Exemplo n.º 5
0
 public WampAuthenticationBinaryBinding(IWampBinaryBinding <TMessage> binding,
                                        IWampSessionAuthenticatorFactory sessionAuthenticationFactory,
                                        IWampUriValidator uriValidator)
     : base(binding, sessionAuthenticationFactory, uriValidator)
 {
     mBinding = binding;
 }
Exemplo n.º 6
0
 public WampPubSubServer(IWampTopicContainer topicContainer, IWampEventSerializer eventSerializer, IWampBinding <TMessage> binding, IWampUriValidator uriValidator)
 {
     mLogger            = LogProvider.GetLogger(this.GetType());
     mBinding           = binding;
     mUriValidator      = uriValidator;
     mEventSerializer   = eventSerializer;
     mRawTopicContainer = new WampRawTopicContainer <TMessage>(topicContainer, mEventSerializer, mBinding);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of <see cref="DefaultWampHost"/> listening at
 /// the given location with the given bindings and the given
 /// <see cref="IWampRealmContainer"/>.
 /// </summary>
 /// <param name="location">The given location.</param>
 /// <param name="realmContainer">The given <see cref="IWampRealmContainer"/>.</param>
 /// <param name="uriValidator">The <see cref="IWampUriValidator"/> to use to validate uris.</param>
 /// <param name="bindings">The given bindings.</param>
 /// <param name="certificate">The <see cref="X509Certificate2"/> certificate to use for secured websockets.</param>
 public DefaultWampHost(string location,
                        IWampRealmContainer realmContainer  = null,
                        IWampUriValidator uriValidator      = null,
                        IEnumerable <IWampBinding> bindings = null,
                        X509Certificate2 certificate        = null)
     : this(location : location, realmContainer : null, uriValidator : null, bindings : bindings, certificate : certificate, getEnabledSslProtocols : null)
 {
 }
        protected WampAuthenticationBinding(IWampBinding <TMessage> binding,
                                            IWampSessionAuthenticatorFactory sessionAuthenticationFactory,
                                            IWampUriValidator uriValidator)
        {
            mBinding      = binding;
            mUriValidator = uriValidator;

            mSessionAuthenticationFactory =
                new RestrictedSessionAuthenticationFactory(sessionAuthenticationFactory);
        }
Exemplo n.º 9
0
        public WampRpcServer(IWampRpcOperationCatalog catalog, IWampBinding <TMessage> binding, IWampUriValidator uriValidator)
        {
            mInvoker      = catalog;
            mUriValidator = uriValidator;
            mLogger       = LogProvider.GetLogger(this.GetType());
            mFormatter    = binding.Formatter;

            mHandler = new WampCalleeInvocationHandler <TMessage>(binding.Formatter);

            mCalleeCatalog = new WampCalleeOperationCatalog <TMessage>
                                 (catalog, mHandler);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of <see cref="DefaultWampHost"/> listening at
        /// the given location with the given bindings and the given
        /// <see cref="IWampRealmContainer"/>.
        /// </summary>
        /// <param name="location">The given location.</param>
        /// <param name="realmContainer">The given <see cref="IWampRealmContainer"/>.</param>
        /// <param name="uriValidator">The <see cref="IWampUriValidator"/> to use to validate uris.</param>
        /// <param name="bindings">The given bindings.</param>
        /// <param name="certificate"></param>
        public DefaultWampHost(string location,
                               IWampRealmContainer realmContainer  = null,
                               IWampUriValidator uriValidator      = null,
                               IEnumerable <IWampBinding> bindings = null,
                               X509Certificate2 certificate        = null)
            : base(realmContainer, uriValidator)
        {
            bindings = bindings ?? new IWampBinding[] { new JTokenJsonBinding(), new JTokenMsgpackBinding() };

            this.RegisterTransport(new FleckWebSocketTransport(location, certificate),
                                   bindings.ToArray());
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of <see cref="InMemoryWampHost"/> given the
        /// <see cref="IWampRealmContainer"/> associated with this host.
        /// </summary>
        /// <param name="realmContainer"></param>
        /// <param name="uriValidator"></param>
        public InMemoryWampHost(IWampRealmContainer realmContainer,
                                IWampUriValidator uriValidator) :
            base(realmContainer, uriValidator)
        {
            mInternalBinding = new InMemoryBinding();

            mInternalTransport = new InMemoryTransport(Scheduler.Immediate);

            this.RegisterTransport
                (mInternalTransport,
                mInternalBinding);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of <see cref="WampAuthenticationHost"/> given the
        /// <see cref="IWampSessionAuthenticatorFactory"/> to use.
        /// </summary>
        /// <param name="sessionAuthenticationFactory">The <see cref="IWampSessionAuthenticatorFactory"/>
        /// used to accept pending clients.</param>
        /// <param name="realmContainer">The <see cref="IWampRealmContainer"/> associated with this
        /// host.</param>
        /// <param name="uriValidator">The <see cref="IWampUriValidator"/> used to validate uris.</param>
        public WampAuthenticationHost(IWampSessionAuthenticatorFactory sessionAuthenticationFactory,
                                      IWampRealmContainer realmContainer = null,
                                      IWampUriValidator uriValidator     = null)
            : base(realmContainer, uriValidator)
        {
            if (sessionAuthenticationFactory == null)
            {
                throw new ArgumentNullException("sessionAuthenticationFactory");
            }

            mSessionAuthenticationFactory = sessionAuthenticationFactory;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of <see cref="WampHost"/> given the
        /// <see cref="IWampRealmContainer"/> associated with this host.
        /// </summary>
        /// <param name="realmContainer"></param>
        /// <param name="uriValidator"></param>
        public WampHost(IWampRealmContainer realmContainer = null, IWampUriValidator uriValidator = null)
        {
            realmContainer = realmContainer ?? new WampRealmContainer();

            mUriValidator = uriValidator ?? new LooseUriValidator();

            mInternalHost = new InMemoryWampHost(realmContainer, UriValidator);
            mInternalHost.Open();

            mExternalHost = new WampHostBase(realmContainer, UriValidator);

            mRealmContainer =
                new ServiceHostedRealmContainer(mExternalHost.RealmContainer,
                                                mInternalHost);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initializes a new instance of <see cref="DefaultWampHost"/> listening at
        /// the given location with the given bindings and the given
        /// <see cref="IWampRealmContainer"/>.
        /// </summary>
        /// <param name="location">The given location.</param>
        /// <param name="sessionAuthenticationFactory">The <see cref="IWampSessionAuthenticatorFactory"/>
        /// used to accept pending clients.</param>
        /// <param name="realmContainer">The <see cref="IWampRealmContainer"/> associated with this
        /// host.</param>
        /// <param name="uriValidator">The <see cref="IWampUriValidator"/> used to validate uris.</param>
        /// <param name="bindings">The given bindings.</param>
        /// <param name="cookieAuthenticatorFactory">The given <see cref="ICookieAuthenticatorFactory"/> used to authenticate
        /// users given their cookies.</param>
        /// <param name="certificate">The <see cref="X509Certificate2"/> certificate to use for secured websockets.</param>
        public DefaultWampAuthenticationHost(string location,
                                             IWampSessionAuthenticatorFactory sessionAuthenticationFactory,
                                             IWampRealmContainer realmContainer  = null,
                                             IWampUriValidator uriValidator      = null,
                                             IEnumerable <IWampBinding> bindings = null,
                                             ICookieAuthenticatorFactory cookieAuthenticatorFactory = null,
                                             X509Certificate2 certificate = null)
            : base(sessionAuthenticationFactory, realmContainer, uriValidator)
        {
            bindings = bindings ?? new IWampBinding[] { new JTokenJsonBinding(), new JTokenMsgpackBinding() };

            this.RegisterTransport(
                new FleckAuthenticatedWebSocketTransport(location, cookieAuthenticatorFactory, certificate),
                bindings.ToArray());
        }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of <see cref="DefaultWampHost"/> listening at
 /// the given location with the given bindings and the given
 /// <see cref="IWampRealmContainer"/>.
 /// </summary>
 /// <param name="location">The given location.</param>
 /// <param name="sessionAuthenticationFactory">The <see cref="IWampSessionAuthenticatorFactory"/>
 /// used to accept pending clients.</param>
 /// <param name="realmContainer">The <see cref="IWampRealmContainer"/> associated with this
 /// host.</param>
 /// <param name="uriValidator">The <see cref="IWampUriValidator"/> used to validate uris.</param>
 /// <param name="bindings">The given bindings.</param>
 /// <param name="cookieAuthenticatorFactory">The given <see cref="ICookieAuthenticatorFactory"/> used to authenticate
 /// users given their cookies.</param>
 /// <param name="certificate">The <see cref="X509Certificate2"/> certificate to use for secured websockets.</param>
 public DefaultWampAuthenticationHost(string location,
                                      IWampSessionAuthenticatorFactory sessionAuthenticationFactory,
                                      IWampRealmContainer realmContainer  = null,
                                      IWampUriValidator uriValidator      = null,
                                      IEnumerable <IWampBinding> bindings = null,
                                      ICookieAuthenticatorFactory cookieAuthenticatorFactory = null,
                                      X509Certificate2 certificate = null)
     : this(location : location,
            sessionAuthenticationFactory : sessionAuthenticationFactory,
            realmContainer : null,
            uriValidator : null,
            bindings : bindings,
            cookieAuthenticatorFactory : cookieAuthenticatorFactory,
            certificate : certificate,
            getEnabledSslProtocols : null)
 {
 }
Exemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of <see cref="WampHostBase"/> given the
 /// <see cref="IWampRealmContainer"/> associated with this host.
 /// </summary>
 /// <param name="realmContainer"></param>
 /// <param name="uriValidator"></param>
 public WampHostBase(IWampRealmContainer realmContainer, IWampUriValidator uriValidator)
 {
     mUriValidator   = uriValidator;
     mRealmContainer = new HostedRealmContainer(realmContainer);
 }
Exemplo n.º 17
0
 public WampRouterBuilder(IWampUriValidator uriValidator)
 {
     mUriValidator = uriValidator;
 }
Exemplo n.º 18
0
 public WampAuthenticationRouterBuilder(IWampSessionAuthenticatorFactory sessionAuthenticationFactory,
                                        IWampUriValidator uriValidator) :
     base(uriValidator)
 {
     mSessionAuthenticationFactory = sessionAuthenticationFactory;
 }
Exemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of <see cref="WampHostBase"/> given the
 /// <see cref="IWampRealmContainer"/> associated with this host.
 /// </summary>
 /// <param name="realmContainer"></param>
 /// <param name="uriValidator"></param>
 /// <param name="sessionIdMap"></param>
 public WampHostBase(IWampRealmContainer realmContainer, IWampUriValidator uriValidator, IWampSessionMapper sessionIdMap)
 {
     mUriValidator  = uriValidator;
     RealmContainer = new HostedRealmContainer(realmContainer);
     mSessionIdMap  = sessionIdMap;
 }
Exemplo n.º 20
0
        /// <summary>
        /// Hosts a WAMP session management service for the given realm.
        /// </summary>
        /// <param name="hostedRealm">The given realm.</param>
        /// <param name="uriValidator">The <see cref="IWampUriValidator"/> to use to verify GOODBYE message reason uri (see also <see cref="GoodbyeMessage.Reason"/>).</param>
        /// <returns>A disposable: disposing it will unregister the hosted session management service.</returns>
        public static IDisposable HostSessionManagementService(this IWampHostedRealm hostedRealm, IWampUriValidator uriValidator = null)
        {
            WampSessionManagementService service = new WampSessionManagementService(hostedRealm, uriValidator);

            RegisterOptions registerOptions = new RegisterOptions {
                DiscloseCaller = true
            };

            CompositeDisposable disposable = HostDisposableService(hostedRealm, service, new CalleeRegistrationInterceptor(registerOptions));

            return(disposable);
        }