Ejemplo n.º 1
0
        private WampCraAuthenticator <TMessage> GetOrCreateWampAuthenticatorForClient(IWampClient client)
        {
            if (!(client.CraAuthenticator is WampCraAuthenticator <TMessage> authenticator))
            {
                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);
        }