示例#1
0
        protected override void InitializeClassInternal(OperationSettings settings, IAuthenticationManager authManager)
        {
            if (!(settings is UserLoginOperationSettings))
            {
                throw new ArgumentException($"Type '{settings.GetType()}' is invalid for this operation.");
            }

            UserLoginOperationSettings internalSettings = (settings as UserLoginOperationSettings);

            UserLoginOperation.Creds = new ConcurrentBag <Credentials>();
            foreach (Credentials creds in internalSettings.Credentials)
            {
                if (!authManager.UserExists(creds.UserId))
                {
                    this.logger?.Log(EventType.OperationClassInitalization, "User '{0}' isn't known.", creds.UserId);
                    continue;
                }

                this.logger?.Log(EventType.OperationClassInitalization, "Adding credentials for user '{0}'.", creds.UserId);

                UserLoginOperation.Creds.Add(creds);
            }

            UserLoginOperation.HttpsOnly = internalSettings.HttpsOnly;
            this.logger?.Log(EventType.OperationClassInitalization, "Use HttpsOnly for UserLogin: '******'.", UserLoginOperation.HttpsOnly);
        }
        protected override void InitializeClassInternal(OperationSettings settings, IAuthenticationManager authManager)
        {
            if (!(settings is ClientLoginOperationSettings))
            {
                throw new ArgumentException($"Type '{settings.GetType()}' is invalid for this operation.");
            }

            ClientLoginOperationSettings internalSettings = (settings as ClientLoginOperationSettings);

            ClientLoginOperation.ClientMappings = new ConcurrentDictionary <string, ClientLoginOperation.Client>();
            foreach (ClientLoginOperation.Client client in internalSettings.Clients)
            {
                this.logger?.Log(EventType.OperationClassInitalization, "Adding user '{0}' to white list.", client.UserId);

                if (!authManager.UserExists(client.UserId))
                {
                    this.logger?.Log(EventType.OperationClassInitalization, "User '{0}' isn't known.", client.UserId);
                    continue;
                }

                foreach (string ip in client.Addresses)
                {
                    if (!ClientLoginOperation.ClientMappings.TryAdd(ip, client))
                    {
                        this.logger?.Log(EventType.OperationClassInitalization, "Failed to whitelist '{0}' for user '{1}'.", ip, client.UserId);
                        continue;
                    }
                }
            }

            ClientLoginOperation.HttpsOnly = internalSettings.HttpsOnly;
            this.logger?.Log(EventType.OperationClassInitalization, "Use HttpsOnly for ClientLogin: '******'.", ClientLoginOperation.HttpsOnly);
        }
示例#3
0
        protected override void InitializeClassInternal(OperationSettings settings, IAuthenticationManager authManager)
        {
            if (!(settings is IdOperationSettings))
            {
                throw new ArgumentException($"Type '{settings.GetType()}' is invalid for this operation.");
            }

            IdOperation.ServerId = (settings as IdOperationSettings).ServerId;
        }
示例#4
0
        protected override void InitializeClassInternal(OperationSettings settings, IAuthenticationManager authManager)
        {
            if (!(settings is DynamicOperationSettings))
            {
                throw new ArgumentException($"Type '{settings.GetType()}' is invalid for this operation.");
            }

            DynamicOperationSettings customSettings = settings as DynamicOperationSettings;

            DynamicOperation.Responses = new ConcurrentDictionary <string, DynamicResponse>();

            if (customSettings.Responses != null)
            {
                foreach (var responseEntry in customSettings.Responses)
                {
                    this.logger?.Log(EventType.OperationInformation, "Create DynamicResponse for id '{0}' using '{1}'.", responseEntry.Id, JsonConvert.SerializeObject(responseEntry.Response, Formatting.Indented));
                    DynamicOperation.Responses[responseEntry.Id] = responseEntry.Response;
                }
            }
        }