Esempio n. 1
0
        public void Publish(IWampClient client, string topicUri, TMessage @event)
        {
            string resolvedTopicUri = ResolveUri(client, topicUri);
            WampCraAuthenticator <TMessage> wampAuth = GetOrCreateWampAuthenticatorForClient(client);

            if (wampAuth.IsAuthenticated)
            {
                WampPubSubPermissions pubSubPerm = wampAuth.CraPermissionsMapper.LookupPubSubPermissions(resolvedTopicUri);
                if (pubSubPerm != null && pubSubPerm.pub)
                {
                    mPubSubServer.Publish(client, resolvedTopicUri, @event);
                }
            }
        }
Esempio n. 2
0
        public void Call(IWampClient client, string callId, string procUri, params TMessage[] arguments)
        {
            string resolvedUri = ResolveUri(client, procUri);
            WampCraAuthenticator <TMessage> wampAuth = GetOrCreateWampAuthenticatorForClient(client);

            WampRpcPermissions rpcPerm = wampAuth.CraPermissionsMapper.LookupRpcPermissions(resolvedUri);

            if (rpcPerm != null && rpcPerm.call)
            {
                mRpcServer.Call(client, callId, resolvedUri, arguments);
            }
            else
            {
                client.CallError(callId, "http://api.wamp.ws/error#not_authorized", "No permissions");
            }
        }
Esempio n. 3
0
        private WampCraAuthenticator <TMessage> GetOrCreateWampAuthenticatorForClient(IWampClient client)
        {
            WampCraAuthenticator <TMessage> authenticator = client.CraAuthenticator as WampCraAuthenticator <TMessage>;

            if (authenticator == null)
            {
                if (!mAuthFactory.IsValid)
                {
                    throw new InvalidOperationException("WampCraAuthenticaticatorBuilder is not valid.");
                }

                authenticator = mAuthFactory.BuildAuthenticator(client.SessionId);

                // Very important to give the client permissions to the auth APIs...
                foreach (IWampRpcMethod method in mWampCraProceduredMetadata.GetServiceMethods())
                {
                    authenticator.CraPermissionsMapper.AddRpcPermission(new WampRpcPermissions(method.ProcUri, true));
                }

                client.CraAuthenticator = authenticator;
            }

            return(authenticator);
        }