protected override void DoParse(string value, WsatConfiguration config) { if (!String.IsNullOrEmpty(value)) { if (Utilities.SafeCompare(value, CommandLineOption.CertMachine)) { config.X509Certificate = CertificateManager.GetMachineIdentityCertificate(); if (config.X509Certificate == null) { throw new WsatAdminException(WsatAdminErrorCode.CANNOT_FIND_MACHINE_CERTIFICATE, SR.GetString(SR.ErrorCannotFindMachineCertificate)); } } else if (value.IndexOf('\\') >= 0) // "Issuer\SubjectName" e.g. "*\This is a distinguished subject" { config.X509Certificate = CertificateManager.GetCertificateFromIssuerAndSubjectName(value); } else // thumbprint { config.X509Certificate = CertificateManager.GetCertificateFromThumbprint(value, string.Empty); } if (config.X509Certificate != null) { return; } } throw new WsatAdminException(WsatAdminErrorCode.INVALID_OR_MISSING_SSL_CERTIFICATE, SR.GetString(SR.ErrorMissingSSLCert)); }
override protected void DoParse(string value, WsatConfiguration config) { if (!String.IsNullOrEmpty(value)) { SourceLevels level; bool parsedCorrectly = Utilities.ParseSourceLevel(value, out level); if (parsedCorrectly) { config.TraceLevel = level; return; } else { // check to see if it's a number uint temp; if (UInt32.TryParse(value, out temp)) { config.TraceLevel = (SourceLevels)temp; return; } } } throw new WsatAdminException(WsatAdminErrorCode.INVALID_TRACELEVEL_ARGUMENT, SR.GetString(SR.ErrorTraceLevelArgument)); }
internal WsatConfiguration(string machineName, string virtualServer, WsatConfiguration previousConfig, bool minimalWrite) { this.MachineName = machineName; this.minimalWrite = minimalWrite; this.firewallWrapper = new FirewallWrapper(); this.previousConfig = previousConfig; this.virtualServer = virtualServer; if (previousConfig == null) { this.allowedCertificates = DefaultX509GlobalAcl; this.kerberosGlobalAcl = DefaultKerberosGlobalAcl; } else { CopyConfigurationData(previousConfig, this); } if (MsdtcClusterUtils.IsClusterServer(MachineName)) { this.hClusterDtcResource = MsdtcClusterUtils.GetTransactionManagerClusterResource(VirtualServer, out clusterNodes); if (hClusterDtcResource == null || hClusterDtcResource.IsInvalid) { if (!string.IsNullOrEmpty(VirtualServer)) { throw new WsatAdminException(WsatAdminErrorCode.CANNOT_FIND_CLUSTER_VIRTUAL_SERVER, SR.GetString(SR.ErrorCanNotFindVirtualServer)); } } } InitializeConfigurationProvider(); }
public WsatSecurityModel(string machineName, WsatConfiguration current) { this.current = current; this.machineName = machineName; this.objectName = SR.GetString(SR.ACLEditorPageTitle); this.pageTitle = SR.GetString(SR.ACLEditorObjectName); // we only want to edit permissions (this is the default value anyway) objectInformation = new ObjectInfo( ObjectInfoFlags.EditPerms | ObjectInfoFlags.Container, this.machineName, this.objectName, this.pageTitle ); if (accessRights == null) { accessRights = new AccessRightsWrapper(); accessRights.access = new Access[1]; // summary page permissions --- AccessFlags.General accessRights.access[0] = new Access(WSAT_ALL, SR.GetString(SR.ACLEditorPermissionName), AccessFlags.General); // this is de default mask when adding a new ACE --- WSAT_ALL accessRights.DefaultIndex = 0; } }
protected override void DoParse(string value, WsatConfiguration config) { // Empty value is allowed and means then users want to remove all accounts config.KerberosGlobalAcl = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <string> acceptedAccounts = new List <string>(config.KerberosGlobalAcl); List <string> validAccounts = new List <string>(); foreach (string account in acceptedAccounts) { string normalizedAccount = account.Trim(); if (!string.IsNullOrEmpty(normalizedAccount)) { if (IsValidAccount(normalizedAccount)) { validAccounts.Add(normalizedAccount); } else { throw new WsatAdminException(WsatAdminErrorCode.INVALID_ACCOUNT, SR.GetString(SR.ErrorAccountArgument, normalizedAccount)); } } } config.KerberosGlobalAcl = validAccounts.ToArray(); }
ConsoleEntryPoint(string[] argv) { List <string> arguments = PrescanArgs(argv); if (this.operation != Operations.Help) { previousConfig = new WsatConfiguration(null, this.virtualServer, null, true); previousConfig.LoadFromRegistry(); newConfig = new WsatConfiguration(null, this.virtualServer, previousConfig, true); ParseArgs(arguments); } }
// -timeout:<sec> override protected void DoParse(string value, WsatConfiguration config) { if (!String.IsNullOrEmpty(value)) { UInt16 parsedValue; if (UInt16.TryParse(value, out parsedValue)) { config.DefaultTimeout = parsedValue; return; } } throw new WsatAdminException(WsatAdminErrorCode.INVALID_DEFTIMEOUT_ARGUMENT, SR.GetString(SR.ErrorDefaultTimeoutRange)); }
// -port:<portNum> protected override void DoParse(string value, WsatConfiguration config) { if (!String.IsNullOrEmpty(value)) { UInt16 parsedValue; if (UInt16.TryParse(value, out parsedValue)) { config.HttpsPort = parsedValue; return; } } throw new WsatAdminException(WsatAdminErrorCode.INVALID_HTTPS_PORT, SR.GetString(SR.ErrorHttpsPortRange)); }
void InitializeConfig() { try { previousConfig = new WsatConfiguration(machineName, virtualServer, null, false); previousConfig.LoadFromRegistry(); config = new WsatConfiguration(machineName, virtualServer, previousConfig, false); msdtc = config.GetMsdtcWrapper(); ConfigurationToUI(); } catch (WsatAdminException e) { HandleException(e); } }
// private switch: -clusterRemoteNode protected override void DoParse(string value, WsatConfiguration config) { if (!String.IsNullOrEmpty(value)) { if (Utilities.SafeCompare(value, CommandLineOption.Enable)) { config.IsClusterRemoteNode = true; return; } else if (Utilities.SafeCompare(value, CommandLineOption.Disable)) { config.IsClusterRemoteNode = false; return; } } throw new WsatAdminException(WsatAdminErrorCode.INVALID_CLUSTER_REMOTE_NODE_ARGUMENT, SR.GetString(SR.ErrorClusterRemoteNodeArgument)); }
// -network:{enable|disable} protected override void DoParse(string value, WsatConfiguration config) { if (!String.IsNullOrEmpty(value)) { if (Utilities.SafeCompare(value, CommandLineOption.Enable)) { QfeChecker.CheckQfe(); config.TransactionBridgeEnabled = true; return; } else if (Utilities.SafeCompare(value, CommandLineOption.Disable)) { config.TransactionBridgeEnabled = false; return; } } throw new WsatAdminException(WsatAdminErrorCode.INVALID_NETWORK_ARGUMENT, SR.GetString(SR.ErrorNetworkArgument)); }
void CopyConfigurationData(WsatConfiguration src, WsatConfiguration dest) { dest.TransactionBridgeEnabled = src.TransactionBridgeEnabled; dest.TransactionBridge30Enabled = src.TransactionBridge30Enabled; dest.HttpsPort = src.HttpsPort; dest.X509Certificate = src.X509Certificate; dest.KerberosGlobalAcl = src.KerberosGlobalAcl; dest.X509GlobalAcl = src.X509GlobalAcl; dest.DefaultTimeout = src.DefaultTimeout; dest.MaxTimeout = src.MaxTimeout; dest.TraceLevel = src.TraceLevel; dest.ActivityPropagation = src.ActivityPropagation; dest.ActivityTracing = src.ActivityTracing; dest.TracePii = src.TracePii; dest.MachineName = src.MachineName; dest.IsClusterRemoteNode = src.IsClusterRemoteNode; dest.VirtualServer = src.VirtualServer; }
// -tracePII:{enable|disable} protected override void DoParse(string value, WsatConfiguration config) { if (!String.IsNullOrEmpty(value)) { if (Utilities.SafeCompare(value, CommandLineOption.Enable)) { config.TracePii = true; return; } else if (Utilities.SafeCompare(value, CommandLineOption.Disable)) { config.TracePii = false; return; } } throw new WsatAdminException(WsatAdminErrorCode.INVALID_TRACE_PII_ARGUMENT, SR.GetString(SR.ErrorTracePiiArgument)); }
// -accountsCerts:<base64hash|"Issuer\SubjectName",> protected override void DoParse(string value, WsatConfiguration config) { // Empty value is allowed and means then users want to remove all accounts certs config.X509GlobalAcl = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); // newConfig.X509GlobalAcl can be empty, but never null int i = 0; foreach (string certString in config.X509GlobalAcl) { if (!string.IsNullOrEmpty(certString)) { X509Certificate2 cert = null; if (certString.IndexOf('\\') >= 0) { // issuer\subject cert = CertificateManager.GetCertificateFromIssuerAndSubjectName(certString); } else { // thumbprint cert = CertificateManager.GetCertificateFromThumbprint(certString, string.Empty); } if (cert != null) { config.X509GlobalAcl[i] = cert.Thumbprint; } else { throw new WsatAdminException(WsatAdminErrorCode.INVALID_OR_MISSING_CLIENT_CERTIFICATE, SR.GetString(SR.ErrorInvalidOrMissingClientCert)); } } i++; } }
internal TraceOptionsForm(WsatConfiguration config) { if (config == null) { throw new ArgumentNullException("config"); } this.config = config; InitializeComponent(); if (config.IsLocalMachine) { bool isRegError = false; try { textLogFileSize.Text = ETWWsatTraceSession.GetMaxTraceFileSizeFromReg().ToString(System.Globalization.CultureInfo.InvariantCulture); } catch (WsatAdminException ex) { isRegError = true; ShowErrorDialog(ex); } bool isSessionExist = ETWWsatTraceSession.IsSessionExist(); buttonNewSession.Enabled = !isSessionExist && !isRegError; buttonStopSession.Enabled = isSessionExist && !isRegError; buttonFlushData.Enabled = isSessionExist && !isRegError; textLogFileSize.Enabled = !isSessionExist && !isRegError; } else { textLogFileSize.Text = ETWWsatTraceSession.DefaultLogFileSize.ToString(System.Globalization.CultureInfo.InvariantCulture); groupBoxLoggingSession.Enabled = false; } }
public ArgumentsParser(WsatConfiguration config) { this.config = config; InitializeParsers(); }
public void Parse(string value, WsatConfiguration config) { Debug.Assert(config != null, "config is null"); DoParse(value, config); }
protected override void DoParse(string value, WsatConfiguration config) { // Empty value is allowed and means then users want to remove all accounts config.KerberosGlobalAcl = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List<string> acceptedAccounts = new List<string>(config.KerberosGlobalAcl); List<string> validAccounts = new List<string>(); foreach (string account in acceptedAccounts) { string normalizedAccount = account.Trim(); if (!string.IsNullOrEmpty(normalizedAccount)) { if (IsValidAccount(normalizedAccount)) { validAccounts.Add(normalizedAccount); } else { throw new WsatAdminException(WsatAdminErrorCode.INVALID_ACCOUNT, SR.GetString(SR.ErrorAccountArgument, normalizedAccount)); } } } config.KerberosGlobalAcl = validAccounts.ToArray(); }
abstract protected void DoParse(string value, WsatConfiguration config);
ConsoleEntryPoint(string[] argv) { List<string> arguments = PrescanArgs(argv); if (this.operation != Operations.Help) { previousConfig = new WsatConfiguration(null, this.virtualServer, null, true); previousConfig.LoadFromRegistry(); newConfig = new WsatConfiguration(null, this.virtualServer, previousConfig, true); ParseArgs(arguments); } }