1 //-----------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //-----------------------------------------------------------------------------
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
28 /// Helper function to load Application Settings from config
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
);
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.
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.");
57 private ServiceConstants() { }