Beispiel #1
0
        internal static HttpProcessorConfiguration LoadHttpProcessorConfiguration(IServiceEntrySink sink, string hostSuffixesConfigParamName, string enableStorageDomainNamesConfigParamName)
        {
            HttpProcessorConfiguration httpProcessorConfiguration = new HttpProcessorConfiguration()
            {
                AllowPathStyleUris         = ConfigurationHelper.GetConfigSetting <bool>(sink, "NephosAllowPathStyleUris", "Allow path-style URIs"),
                ValidHostSuffixes          = ConfigurationHelper.GetHostSuffixes(sink, hostSuffixesConfigParamName),
                MaskClientIPAddressesInLog = ConfigurationHelper.GetIPAddressMaskSetting(sink)
            };

            if (!httpProcessorConfiguration.AllowPathStyleUris)
            {
                NephosAssertionException.Assert(httpProcessorConfiguration.ValidHostSuffixes != null, "Host suffixes can't be null when AllowPathStyleUris is false. Check service model configuaration.");
                NephosAssertionException.Assert((int)httpProcessorConfiguration.ValidHostSuffixes.Length > 0, "Host suffixes can't be empty when AllowPathStyleUris is false. Check service model configuaration.");
            }
            httpProcessorConfiguration.ValidHostSuffixes = httpProcessorConfiguration.ValidHostSuffixes ?? new string[0];
            httpProcessorConfiguration.IncludeInternalDetailsInErrorResponses = ConfigurationHelper.GetConfigSetting <bool>(sink, "NephosIncludeInternalDetailsInErrorResponses", "Include internal details in error responses");
            if (!string.IsNullOrEmpty(enableStorageDomainNamesConfigParamName))
            {
                httpProcessorConfiguration.EnableStorageDomainNames = ConfigurationHelper.GetConfigSetting <bool>(sink, enableStorageDomainNamesConfigParamName, "Enable storage domain names");
            }
            try
            {
                httpProcessorConfiguration.StampName = ConfigurationHelper.GetConfigSetting <string>(sink, "StampName", "Stamp Name");
            }
            catch (Exception exception1)
            {
                Exception exception          = exception1;
                IStringDataEventStream error = Logger <IRestProtocolHeadLogger> .Instance.Error;
                object[] str = new object[] { exception.ToString() };
                error.Log("Hit Exception while reading StampName setting from ACS: {0}", str);
            }
            return(httpProcessorConfiguration);
        }
Beispiel #2
0
        internal static string[] GetHostSuffixes(IServiceEntrySink sink, string hostSuffixesConfigParamName)
        {
            string configurationParameter = sink.GetConfigurationParameter(hostSuffixesConfigParamName);

            if (configurationParameter == null)
            {
                return(null);
            }
            return(configurationParameter.Split(ConfigurationHelper.HostSuffixesSeparator, StringSplitOptions.RemoveEmptyEntries));
        }
Beispiel #3
0
        public void Initialize(IServiceEntrySink sink)
        {
            if (sink == null)
            {
                throw new ArgumentNullException("sink");
            }
            Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug.Log("[Nephos.Table] { Initialize");

            TableProtocolHead.HttpProcessorConfigurationDefaultInstance = HttpProcessorConfiguration.LoadDefaultHttpProcessorConfiguration(sink, "UriHostSuffixes", null);
            TableServiceEntry.SharedStorageManager   = new DbStorageManager();
            this.authenticationManager               = XFETableAuthenticationManager.CreateAuthenticationManager(TableServiceEntry.SharedStorageManager);
            TableServiceEntry.SharedTableDataFactory = new DbTableDataContextFactory();
            this.tableManager = TableManager.CreateTableManager(NephosAuthorizationManager.CreateAuthorizationManager(TableServiceEntry.SharedStorageManager, false), TableServiceEntry.SharedTableDataFactory, TableServiceEntry.SharedStorageManager);
            sink.RegisterRestHandler(this);
        }
Beispiel #4
0
        public static bool GetIPAddressMaskSetting(IServiceEntrySink sink)
        {
            bool configSetting;

            try
            {
                configSetting = ConfigurationHelper.GetConfigSetting <bool>(sink, "Nephos.MaskClientIPAddressesInLogs", "Indicates whether client IP addresses should be masked in logs.");
            }
            catch (Exception exception1)
            {
                Exception exception          = exception1;
                IStringDataEventStream error = Logger <IRestProtocolHeadLogger> .Instance.Error;
                object[] str = new object[] { exception.ToString() };
                error.Log("Hit Exception while reading Nephos.MaskClientIPAddressesInLogs setting from ACS: {0}", str);
                configSetting = false;
            }
            return(configSetting);
        }
Beispiel #5
0
        public static T GetConfigSetting <T>(IServiceEntrySink serviceEntrySink, string configParam, string configDescription)
        {
            string configurationParameter = serviceEntrySink.GetConfigurationParameter(configParam);

            if (configurationParameter == null)
            {
                throw new ArgumentNullException(string.Concat("The value for service model config parameter named ", configParam, " is missing. Check the config files."));
            }
            IStringDataEventStream infoDebug = Logger <IRestProtocolHeadLogger> .Instance.InfoDebug;

            object[] objArray = new object[] { configParam, configDescription, configurationParameter };
            infoDebug.Log("Loading config Param {0} ({1}) read: {2}", objArray);
            if (typeof(T) == typeof(string))
            {
                return((T)configurationParameter);
            }
            Type type = typeof(T);

            Type[]     typeArray = new Type[] { typeof(string), type.MakeByRefType() };
            MethodInfo method    = type.GetMethod("TryParse", typeArray);

            if (method == null)
            {
                throw new ArgumentException("The passed in type parameter doesn't contain TryParse", "T");
            }
            object[] objArray1 = new object[] { configurationParameter, null };
            if (!(bool)method.Invoke(null, objArray1))
            {
                CultureInfo invariantCulture = CultureInfo.InvariantCulture;
                object[]    objArray2        = new object[] { configParam };
                throw new ArgumentException(string.Format(invariantCulture, "Failed to convert {0} configuration option to a proper type", objArray2));
            }
            T t = (T)objArray1[1];
            IStringDataEventStream stringDataEventStream = Logger <IRestProtocolHeadLogger> .Instance.InfoDebug;

            object[] objArray3 = new object[] { configParam, t };
            stringDataEventStream.Log("Successfully loaded {0}: {1}", objArray3);
            return(t);
        }
Beispiel #6
0
        void Microsoft.Cis.Services.Nephos.Common.Protocols.Rest.IServiceEntry.Initialize(IServiceEntrySink sink)
        {
            Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug.Log("[Nephos.Queue] { Initialize");

            QueueServiceEntry.SharedStorageManager = new DbStorageManager();
            QueueProtocolHead.HttpProcessorConfigurationDefaultInstance = HttpProcessorConfiguration.LoadDefaultHttpProcessorConfiguration(sink, "UriHostSuffixes", null);
            this.authenticationManager = XFEQueueAuthenticationManager.CreateAuthenticationManager(QueueServiceEntry.SharedStorageManager);
            this.queueManager          = new DbQueueManager(QueueServiceEntry.SharedStorageManager, XFEQueueAuthorizationManager.CreateAuthorizationManager(QueueServiceEntry.SharedStorageManager, false));
            sink.RegisterRestHandler(this);
            Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug.Log("[DevelopmentStorage.Queue] } Initialize");
        }
Beispiel #7
0
        public static HttpProcessorConfiguration LoadDefaultStampAccountFEHttpProcessorConfiguration(IServiceEntrySink sink, string hostSuffixesConfigParamName)
        {
            HttpProcessorConfiguration httpProcessorConfiguration = new HttpProcessorConfiguration();

            string[] hostSuffixes = ConfigurationHelper.GetHostSuffixes(sink, hostSuffixesConfigParamName);
            httpProcessorConfiguration.ValidHostSuffixes = (hostSuffixes != null ? hostSuffixes : new string[0]);
            string configurationParameter = sink.GetConfigurationParameter("NephosAllowPathStyleUris");
            bool   flag = false;

            if (string.IsNullOrEmpty(configurationParameter))
            {
                Logger <IRestProtocolHeadLogger> .Instance.Critical.Log("{0} setting was not found for role", new object[] { "NephosAllowPathStyleUris" });
            }
            else if (!bool.TryParse(configurationParameter, out flag))
            {
                Logger <IRestProtocolHeadLogger> .Instance.Critical.Log("{0} setting with value {1} is not a boolean", new object[] { "NephosAllowPathStyleUris", configurationParameter });
            }
            httpProcessorConfiguration.AllowPathStyleUris = flag;
            httpProcessorConfiguration.IncludeInternalDetailsInErrorResponses = ConfigurationHelper.GetConfigSetting <bool>(sink, "NephosIncludeInternalDetailsInErrorResponses", "Include internal details in error responses");
            httpProcessorConfiguration.MaskClientIPAddressesInLog             = false;
            HttpProcessorConfiguration.DefaultHttpProcessorConfiguration      = httpProcessorConfiguration;
            return(httpProcessorConfiguration);
        }
Beispiel #8
0
        public static HttpProcessorConfiguration LoadDefaultHttpProcessorConfiguration(IServiceEntrySink sink, string hostSuffixesConfigParamName, string enableStorageDomainNamesConfigParamName)
        {
            HttpProcessorConfiguration httpProcessorConfiguration = ConfigurationHelper.LoadHttpProcessorConfiguration(sink, hostSuffixesConfigParamName, enableStorageDomainNamesConfigParamName);

            HttpProcessorConfiguration.DefaultHttpProcessorConfiguration = httpProcessorConfiguration;
            return(httpProcessorConfiguration);
        }
Beispiel #9
0
        public static HttpProcessorConfiguration LoadDefaultAccountFEHttpProcessorConfiguration(IServiceEntrySink sink)
        {
            HttpProcessorConfiguration httpProcessorConfiguration = new HttpProcessorConfiguration()
            {
                AllowPathStyleUris = true,
                ValidHostSuffixes  = new string[0],
                IncludeInternalDetailsInErrorResponses = ConfigurationHelper.GetConfigSetting <bool>(sink, "NephosIncludeInternalDetailsInErrorResponses", "Include internal details in error responses"),
                MaskClientIPAddressesInLog             = false
            };

            HttpProcessorConfiguration.DefaultHttpProcessorConfiguration = httpProcessorConfiguration;
            return(httpProcessorConfiguration);
        }
Beispiel #10
0
        void Microsoft.Cis.Services.Nephos.Common.Protocols.Rest.IServiceEntry.Initialize(IServiceEntrySink sink)
        {
            Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug.Log("[Nephos.Storage] { Initialize");

            HttpRestProcessor.HttpProcessorConfigurationDefaultInstance = HttpProcessorConfiguration.LoadDefaultHttpProcessorConfiguration(sink, "UriHostSuffixes", null);
            BlobServiceEntry.SharedStorageManager = new DbStorageManager();
            BlobServiceEntry.SharedConfig         = new ServiceManagerConfiguration();
            this.authenticationManager            = XFEBlobAuthenticationManager.CreateAuthenticationManager(BlobServiceEntry.SharedStorageManager, false);
            this.serviceManager             = RealServiceManager.CreateServiceManager(XFEBlobAuthorizationManager.CreateAuthorizationManager(BlobServiceEntry.SharedStorageManager, true), BlobServiceEntry.SharedStorageManager, BlobServiceEntry.SharedConfig);
            StorageStamp.TranslateException = new TranslateExceptionDelegate(SqlExceptionManager.ReThrowException);
            BlockBlobGarbageCollector.Initialize();
            Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug.Log("[Nephos.Storage] } Initialize");

            sink.RegisterRestHandler(this);
        }