Example #1
0
        protected void SetApiKeyResolver(ServiceRegistry registry, IApiKeyResolver ifNull)
        {
            IApiKeyResolver apiKeyResolver = registry.Get(ifNull);

            Responder.CommonSecureChannel.ApiKeyResolver = apiKeyResolver;
            Responder.AppSecureChannels.Values.Each(sc => sc.ApiKeyResolver = apiKeyResolver);
        }
Example #2
0
        private void AddCommonServices(ServiceProxyResponder responder)
        {
            ServiceTypes.Each(new { Logger, Responder = responder }, (ctx, serviceType) =>
            {
                ctx.Responder.RemoveCommonService(serviceType);
                ctx.Responder.AddCommonService(serviceType, ServiceRegistry.GetServiceLoader(serviceType));
                ctx.Logger.AddEntry("Added service: {0}", serviceType.FullName);
            });
            IApiKeyResolver apiKeyResolver = (IApiKeyResolver)ServiceRegistry.GetServiceLoader(typeof(IApiKeyResolver), new CoreClient())();

            responder.CommonSecureChannel.ApiKeyResolver = apiKeyResolver;
            responder.AppSecureChannels.Values.Each(sc => sc.ApiKeyResolver = apiKeyResolver);
        }
Example #3
0
        private void ValidateApiKeyToken(List <ValidationFailures> failures, List <string> messages)
        {
            ApiKeyRequiredAttribute keyRequired;

            if (_toValidate.TargetType != null &&
                _toValidate.MethodInfo != null &&
                (
                    _toValidate.TargetType.HasCustomAttributeOfType(true, out keyRequired) ||
                    _toValidate.MethodInfo.HasCustomAttributeOfType(true, out keyRequired)
                ))
            {
                IApiKeyResolver resolver = _toValidate.ApiKeyResolver;
                if (!resolver.IsValidRequest(_toValidate))
                {
                    failures.Add(ServiceProxy.ValidationFailures.InvalidApiKeyToken);
                    messages.Add("ApiKeyValidation failed");
                }
            }
        }