//public string Scope //{ // get { return C_PROFILE_SCOPE; } //} ///// </summary> //public ProfileVersionStatus Status //{ // get { return ProfileVersionStatus.Release; } //} public ProfileStatus Check(out string reason, IEnumerable <Feature> features, IEnumerable <string> scopes, Dictionary <string, object> parameters) { reason = string.Empty; var Name = this.GetProfileName(); var Scope = this.GetProfileScope(); StringBuilder sb = new StringBuilder(); ProfileStatus status = ProfileStatus.NotSupported; sb.AppendLine(string.Format("Check profile support for {0}", Name)); bool scopePresent = scopes.Contains(Scope); sb.AppendLine(string.Format("Scope {0}: \t\t{1}", Scope, scopePresent ? "PRESENT" : "NOT PRESENT")); if (!scopePresent) { sb.AppendFormat("Profile not supported"); } else { bool profileOk = true; bool supported; Action <Feature, string> checkNextMandatory = new Action <Feature, string>( (feature, displayName) => { supported = features.ContainsFeature(feature); LogMandatory(sb, displayName, supported); profileOk = profileOk && supported; }); Action <Feature, string> checkNextOptional = new Action <Feature, string>( (feature, displayName) => { supported = features.Contains(feature); LogOptional(sb, displayName, supported); }); checkNextMandatory(Feature.GetServices, "GetServices"); LogMandatoryFeature(sb, "Discovery"); checkNextMandatory(Feature.DiscoveryTypesTdsDevice, "tds:Device"); LogMandatoryFeature(sb, "Network Configuration"); LogMandatoryFeature(sb, "System"); LogMandatoryFeature(sb, "User Handling"); LogMandatoryFeature(sb, "Event Handling"); checkNextMandatory(Feature.MaxPullPoints, "EventService/GetServiceCapabilities/MaxPullPoints"); if (profileOk) { var v = (int)parameters["MaxPullPoints"]; profileOk = v >= 2; sb.AppendLine(string.Format("EventService/GetServiceCapabilities/MaxPullPoints has value >= 2: {0}", profileOk ? "SUPPORTED" : "NOT SUPPORTED")); } checkNextMandatory(Feature.Digest, "HTTP Digest"); checkNextMandatory(Feature.AccessControlService, "AccessControl Service"); //checkNextMandatory(Feature.AreaChangedEvent, FeaturesHelper.GetDisplayName(Feature.AreaChangedEvent)); //checkNextMandatory(Feature.AccessPointTamperingEvent, FeaturesHelper.GetDisplayName(Feature.AccessPointTamperingEvent)); //if (features.Contains(Feature.ExternalAuthorization)) //{ // checkNextMandatory(Feature.RequestCredentialEvent, FeaturesHelper.GetDisplayName(Feature.RequestCredentialEvent)); // //checkNextMandatory(Feature.AccessGrantedCredentialEvent, FeaturesHelper.GetDisplayName(Feature.AccessGrantedCredentialEvent)); // //checkNextMandatory(Feature.AccessDeniedWithCredentialEvent, FeaturesHelper.GetDisplayName(Feature.AccessDeniedWithCredentialEvent)); // checkNextMandatory(Feature.AccessDeniedCredentialEvent, FeaturesHelper.GetDisplayName(Feature.AccessDeniedCredentialEvent)); //} checkNextMandatory(Feature.DoorControlService, "DoorControl Service"); checkNextMandatory(Feature.AccessDoor, "AccessDoor"); checkNextMandatory(Feature.LockDoor, "LockDoor"); checkNextMandatory(Feature.UnlockDoor, "UnlockDoor"); Action <Feature, Feature> checkPair = new Action <Feature, Feature>( (featureA, featureB) => { if (features.Contains(featureB) && !features.Contains(featureA)) { supported = false; sb.AppendLine(string.Format("{0} feature is NOT SUPPORTED while {1} is SUPPORTED", FeaturesHelper.GetDisplayName(featureA), FeaturesHelper.GetDisplayName(featureB))); } else { if (features.Contains(featureB) && features.Contains(featureA)) { sb.AppendLine(string.Format("Features {0} and {1} are SUPPORTED", FeaturesHelper.GetDisplayName(featureA), FeaturesHelper.GetDisplayName(featureB))); } } }); checkPair(Feature.DoorPhysicalStateEvent, Feature.DoorMonitor); checkPair(Feature.LockPhysicalStateEvent, Feature.LockMonitor); checkPair(Feature.DoubleLockPhysicalStateEvent, Feature.DoubleLockMonitor); checkPair(Feature.DoorAlarmEvent, Feature.DoorAlarm); checkPair(Feature.DoorTamperEvent, Feature.DoorTamper); checkPair(Feature.DoorFaultEvent, Feature.DoorFault); if (profileOk) { status = ProfileStatus.Supported; } else { status = ProfileStatus.Failed; } } reason = sb.ToString(); return(status); }
public ProfileStatus Check(out string reason, IEnumerable <Feature> features, IEnumerable <string> scopes) { reason = string.Empty; StringBuilder sb = new StringBuilder(); ProfileStatus status = ProfileStatus.NotSupported; sb.AppendLine(string.Format("Check profile support for {0}", Name)); bool scopePresent = scopes.Contains(Scope); sb.AppendLine(string.Format("Scope {0}: \t\t{1}", Scope, scopePresent ? "PRESENT" : "NOT PRESENT")); if (!scopePresent) { sb.AppendFormat("Profile not supported"); } else { bool profileOk = true; bool supported; Action <Feature, string> checkNextMandatory = new Action <Feature, string>( (feature, displayName) => { supported = features.Contains(feature); LogMandatory(sb, displayName, supported); profileOk = profileOk && supported; }); Action <Feature, string> checkNextOptional = new Action <Feature, string>( (feature, displayName) => { supported = features.Contains(feature); LogOptional(sb, displayName, supported); }); checkNextMandatory(Feature.GetServices, "GetServices"); checkNextMandatory(Feature.Digest, "HTTP Digest"); checkNextMandatory(Feature.AccessControlService, "AccessControl Service"); checkNextMandatory(Feature.AccessPointEnabledEvent, FeaturesHelper.GetDisplayName(Feature.AccessPointEnabledEvent)); checkNextMandatory(Feature.AccessPointTamperingEvent, FeaturesHelper.GetDisplayName(Feature.AccessPointTamperingEvent)); if (features.Contains(Feature.ExternalAuthorization)) { checkNextMandatory(Feature.RequestCredentialEvent, FeaturesHelper.GetDisplayName(Feature.RequestCredentialEvent)); checkNextMandatory(Feature.AccessGrantedCredentialExternalEvent, FeaturesHelper.GetDisplayName(Feature.AccessGrantedCredentialExternalEvent)); checkNextMandatory(Feature.AccessDeniedCredentialExternalEvent, FeaturesHelper.GetDisplayName(Feature.AccessDeniedCredentialExternalEvent)); } checkNextMandatory(Feature.DoorControlService, "DoorControl Service"); checkNextMandatory(Feature.AccessDoor, "AccessDoor"); checkNextMandatory(Feature.LockDoor, "LockDoor"); checkNextMandatory(Feature.UnlockDoor, "UnlockDoor"); Action <Feature, Feature> checkPair = new Action <Feature, Feature>( (featureA, featureB) => { if (features.Contains(featureB) && !features.Contains(featureA)) { supported = false; sb.AppendLine(string.Format("{0} feature is NOT SUPPORTED while {1} is SUPPORTED", FeaturesHelper.GetDisplayName(featureA), FeaturesHelper.GetDisplayName(featureB))); } else { if (features.Contains(featureB) && features.Contains(featureA)) { sb.AppendLine(string.Format("Features {0} and {1} are SUPPORTED", FeaturesHelper.GetDisplayName(featureA), FeaturesHelper.GetDisplayName(featureB))); } } }); checkPair(Feature.DoorPhysicalStateEvent, Feature.DoorMonitor); checkPair(Feature.LockPhysicalStateEvent, Feature.LockMonitor); checkPair(Feature.DoubleLockPhysicalStateEvent, Feature.DoubleLockMonitor); checkPair(Feature.DoorAlarmEvent, Feature.DoorAlarm); checkPair(Feature.DoorTamperEvent, Feature.DoorTamper); checkPair(Feature.DoorFault, Feature.DoorFault); if (profileOk) { status = ProfileStatus.Supported; } else { status = ProfileStatus.Failed; } } reason = sb.ToString(); return(status); }
public void DisplayProfiles(IEnumerable <IProfileDefinition> profiles) { tvProfiles.Nodes.Clear(); _scopeNodes = new Dictionary <String, List <TreeNode> >(); _discoveryTypesNodes = new Dictionary <Feature, List <TreeNode> >(); _functionalityNodes = new Dictionary <Functionality, List <TreeNode> >(); _profileNodes = new Dictionary <IProfileDefinition, TreeNode>(); _groupNodes = new List <TreeNode>(); _profileFunctionalityNodes = new Dictionary <IProfileDefinition, Dictionary <Functionality, TreeNode> >(); foreach (IProfileDefinition profile in profiles) { TreeNode profileNode = tvProfiles.Nodes.Add(profile.GetProfileName()); //if (profile.Status == ProfileVersionStatus.Release) //{ // SetImageKey(profileNode, PROFILEUNDEFINED); //} //else //{ // SetImageKey(profileNode, PROFILERCUNDEFINED); //} SetImageKey(profileNode, PROFILEUNDEFINED); profileNode.Tag = profile; _profileNodes.Add(profile, profileNode); Dictionary <Functionality, TreeNode> funcNodes = new Dictionary <Functionality, TreeNode>(); _profileFunctionalityNodes.Add(profile, funcNodes); TreeNode featureNode = profileNode.Nodes.Add(profile.GetProfileName() + "Scopes", "Scopes"); foreach (String item in profile.MandatoryScopes) { string scopeName = item; TreeNode node = new TreeNode(scopeName); SetImageKey(node, UNDEFINED); node.Tag = profile.MandatoryScopes.Contains(item); featureNode.Nodes.Add(node); if (!_scopeNodes.ContainsKey(item)) { _scopeNodes.Add(item, new List <TreeNode>()); } _scopeNodes[item].Add(node); } var typesNode = profileNode.Nodes.Add(profile.GetProfileName() + "Discovery Types", "Discovery Types"); SetImageKey(typesNode, GROUP); if (null != profile.MandatoryDiscoveryTypes) { foreach (var dt in profile.MandatoryDiscoveryTypes) { var node = new TreeNode(FeaturesHelper.GetDisplayName(dt)); SetImageKey(node, UNDEFINED); node.Tag = true; typesNode.Nodes.Add(node); if (!_discoveryTypesNodes.ContainsKey(dt)) { _discoveryTypesNodes.Add(dt, new List <TreeNode>()); } _discoveryTypesNodes[dt].Add(node); } } TreeNode funcNode = profileNode.Nodes.Add(profile.GetProfileName() + "Functionality", "Functionality"); SetImageKey(funcNode, GROUP); foreach (FunctionalityItem item in profile.Functionalities) { // Find group node to add this test to. TreeNode groupNode = FindGroupNode(funcNode, item.Path); TreeNode node = new TreeNode(Utils.FunctionalityHelper.GetDisplayName(item.Functionality)); SetImageKey(node, UNDEFINED); groupNode.Nodes.Add(node); if (!_functionalityNodes.ContainsKey(item.Functionality)) { _functionalityNodes.Add(item.Functionality, new List <TreeNode>()); } _functionalityNodes[item.Functionality].Add(node); funcNodes.Add(item.Functionality, node); } } }
public ProfileStatus Check(out string reason, IEnumerable <Feature> features, IEnumerable <string> scopes, Dictionary <string, object> parameters) { reason = string.Empty; var Name = this.GetProfileName(); var Scope = this.GetProfileScope(); StringBuilder sb = new StringBuilder(); ProfileStatus status = ProfileStatus.NotSupported; sb.AppendLine(string.Format("Check profile support for {0}", Name)); bool scopePresent = scopes.Contains(FactoryDefaultScope) || scopes.Contains(OperationalScope); sb.AppendLine(string.Format("Scope {0}: \t\t{1}", FactoryDefaultScope, scopes.Contains(FactoryDefaultScope) ? "PRESENT" : "NOT PRESENT")); sb.AppendLine(string.Format("Scope {0}: \t\t{1}", OperationalScope, scopes.Contains(OperationalScope) ? "PRESENT" : "NOT PRESENT")); if (!scopePresent) { sb.AppendFormat("Profile not supported"); } else { bool profileOk = true; bool supported; Action <Feature> checkNextMandatory = (feature) => { supported = features.ContainsFeature(feature); LogMandatory(sb, FeaturesHelper.GetDisplayName(feature), supported); profileOk = profileOk && supported; }; Action <Feature> logNextMandatory = (feature) => { supported = features.ContainsFeature(feature); LogMandatoryFeature(sb, FeaturesHelper.GetDisplayName(feature)); profileOk = profileOk && supported; }; Action <Feature> checkNextOptional = (feature) => { supported = features.Contains(feature); LogOptional(sb, FeaturesHelper.GetDisplayName(feature), supported); }; checkNextMandatory(Feature.DiscoveryTypesTdsDevice); checkNextMandatory(Feature.GetServices); checkNextMandatory(Feature.MaximumUsernameLength); checkNextMandatory(Feature.MaximumPasswordLength); checkNextMandatory(Feature.ZeroConfiguration); checkNextMandatory(Feature.NTP); checkNextMandatory(Feature.MaxUsers); checkNextMandatory(Feature.MonitoringProcessorUsageEvent); checkNextMandatory(Feature.MonitoringOperatingTimeLastResetEvent); checkNextMandatory(Feature.MonitoringOperatingTimeLastRebootEvent); checkNextMandatory(Feature.MonitoringOperatingTimeLastClockSynchronizationEvent); logNextMandatory(Feature.EventsService); checkNextMandatory(Feature.MaxPullPoints); if (profileOk) { var v = (int)parameters["MaxPullPoints"]; profileOk = v >= 2; sb.AppendLine(string.Format("EventService/GetServiceCapabilities/MaxPullPoints has value >= 2: {0}", profileOk ? "SUPPORTED" : "NOT SUPPORTED")); } if (features.ContainsFeature(Feature.AdvancedSecurity)) { checkNextMandatory(Feature.RSAKeyPairGenerationOrPKCS12CertificateWithRSAPrivateKeyUpload); if (features.ContainsFeature(Feature.RSAKeyPairGeneration)) { checkNextMandatory(Feature.SelfSignedCertificateCreationWithRSAAndPKCS10ExternalCertificationWithRSA); } checkNextMandatory(Feature.MaximumNumberOfKeys); if (profileOk) { var v = (int)parameters["MaximumNumberOfKeys"]; profileOk = v >= 16; sb.AppendLine(string.Format("Advanced Security Service/GetServiceCapabilities/MaximumNumberOfKeys has value >= 16: {0}", profileOk ? "SUPPORTED" : "NOT SUPPORTED")); } checkNextMandatory(Feature.MaximumNumberOfCertificates); if (profileOk) { var v = (int)parameters["MaximumNumberOfCertificates"]; profileOk = v >= 16; sb.AppendLine(string.Format("Advanced Security Service/GetServiceCapabilities/MaximumNumberOfCertificates has value >= 16: {0}", profileOk ? "SUPPORTED" : "NOT SUPPORTED")); } checkNextMandatory(Feature.TLSServerSupport); } if (features.ContainsFeature(Feature.MediaService)) { checkNextMandatory(Feature.GetServices); checkNextMandatory(Feature.RTSS); } checkNextOptional(Feature.DeviceHardwareFailureFanFailureEvent); checkNextOptional(Feature.DeviceHardwareFailurePowerSupplyFailureEvent); checkNextOptional(Feature.DeviceHardwareFailureStorageFailureEvent); checkNextOptional(Feature.DeviceHardwareFailureTemperatureCriticalEvent); checkNextOptional(Feature.MonitoringBackupLastEvent); checkNextMandatory(Feature.DefaultAccessPolicy); checkNextMandatory(Feature.Digest); status = profileOk ? ProfileStatus.Supported : ProfileStatus.Failed; } reason = sb.ToString(); return(status); }