added samples
[windows-sources.git] / sdk / samples / WCFSamples / TechnologySamples / Scenario / Federation / CS / HomeRealmSTS / ServiceConstants.cs
blob0e45f0b539c2400c9d235542b4f555fabf030fef
1 //-----------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //-----------------------------------------------------------------------------
4 using System;
6 using System.Configuration;
8 using System.Security.Cryptography.X509Certificates;
10 namespace Microsoft.ServiceModel.Samples.Federation
12 class ServiceConstants
14 // Issuer name placed into issued tokens
15 internal const string StsName = "Home Realm STS";
17 // Statics for location of certs
18 internal static StoreName CertStoreName = StoreName.TrustedPeople;
19 internal static StoreLocation CertStoreLocation = StoreLocation.LocalMachine;
21 // Statics initialized from app.config
22 internal static string CertDistinguishedName;
23 internal static string TargetDistinguishedName;
24 internal static double PurchaseLimit;
26 #region Helper functions to load app settings from config
27 /// <summary>
28 /// Helper function to load Application Settings from config
29 /// </summary>
30 public static void LoadAppSettings()
32 CertDistinguishedName = ConfigurationManager.AppSettings["certDistinguishedName"];
33 CheckIfLoaded(CertDistinguishedName);
35 TargetDistinguishedName = ConfigurationManager.AppSettings["targetDistinguishedName"];
36 CheckIfLoaded(TargetDistinguishedName);
38 string purchaseLimitString = ConfigurationManager.AppSettings["purchaseLimit"];
39 CheckIfLoaded(purchaseLimitString);
40 PurchaseLimit = Double.Parse(purchaseLimitString);
43 /// <summary>
44 /// Helper function to check if a required Application Setting has been specified in config.
45 /// Throw if some Application Setting has not been specified.
46 /// </summary>
47 private static void CheckIfLoaded(string s)
49 if (String.IsNullOrEmpty(s))
51 throw new ConfigurationErrorsException("Required Configuration Element(s) missing at HomeRealmSTS. Please check the STS configuration file.");
55 #endregion
57 private ServiceConstants() { }