Пример #1
0
        public override Task <RegisterServiceResponseMessage> RegisterService(RegisterServiceMessage request, DataTransferContext context)
        {
            try
            {
                if (string.IsNullOrEmpty(request.ResponderFor))
                {
                    CheckAuth(context, "ActAsService");
                    TemporaryGrants.RegisterService(request.ServiceName, context.Identity.Name);
                }
                else
                {
                    CheckAuth(context, "ConnectAnyService", request.ResponderFor);
                    TemporaryGrants.GrantTemporaryPermission(request.ResponderFor, request.ServiceName);
                }

                return(base.RegisterService(request, context));
            }
            catch (Exception ex)
            {
                LogEnvironment.LogEvent(ex.OutlineException(), LogSeverity.Error);
                return(Task.FromResult(new RegisterServiceResponseMessage {
                    Ok = false, Reason = ex.Message
                }));
            }
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the LocalServiceHubConsumer class
 /// </summary>
 /// <param name="serviceName">the local service name</param>
 /// <param name="localProvider">the local serviceHubProvider instance</param>
 public LocalServiceHubConsumer(string serviceName, IServiceHubProvider localProvider, string consumedService, ICustomServerSecurity serverSecurity)
 {
     this.localProvider   = localProvider;
     ServiceName          = serviceName;
     this.consumedService = consumedService;
     this.serverSecurity  = serverSecurity;
     rnd = new Random();
     if (!string.IsNullOrEmpty(serviceName) && !string.IsNullOrEmpty(consumedService))
     {
         TemporaryGrants.GrantTemporaryPermission(consumedService, serviceName);
     }
 }