コード例 #1
0
        public override string GetAccessProfileInfoList(int Limit, [System.Xml.Serialization.XmlIgnoreAttribute()] bool LimitSpecified, string StartReference, [System.Xml.Serialization.XmlElementAttribute("AccessProfileInfo")] out AccessProfileInfo[] AccessProfileInfo)
        {
            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.AccessRulesCapabilities;

            int offset = 0;

            if (!string.IsNullOrEmpty(StartReference))
            {
                if (!Int32.TryParse(StartReference, out offset))
                {
                    FaultLib.ReturnFault("Invalid StartReferense value. ", new[] { "Sender", "InvalidArgVal", "InvalidArgVal" });
                }
            }

            if (!LimitSpecified)
            {
                Limit = capabilities.MaxLimit > int.MaxValue ?
                        int.MaxValue : (int)capabilities.MaxLimit;
            }

            AccessProfileInfo = Array.ConvertAll(GetList <AccessProfile>(offset, true, Limit, true, C => C.AccessProfileList), item => ToAccessProfileInfo(item));
            string newStartReferense = null;

            if (offset + AccessProfileInfo.Length < ConfStorage.AccessProfileList.Count)
            {
                newStartReferense = Convert.ToString(offset + AccessProfileInfo.Length);
            }
            return(newStartReferense);
        }
コード例 #2
0
        public override AccessProfile[] GetAccessProfiles([System.Xml.Serialization.XmlElementAttribute("Token")] string[] Token)
        {
            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.AccessRulesCapabilities;

            if (Token != null && Token.Length > capabilities.MaxLimit)
            {
                FaultLib.ReturnFault("Too many items was requested. ", new[] { "Sender", "InvalidArgs", "TooManyItems" });
            }
            return(GetListByTokenList <AccessProfile>(Token, C => C.AccessProfileList));
        }
コード例 #3
0
        private SystemCapabilities()
        {
            // don't change service capabilities in other places to maintain synchronization of
            // typed properties and XmlElement's

            //Device Management Service
            DeviceServiceCapabilities          = new DeviceServiceCapabilities();
            DeviceServiceCapabilities.Network  = new NetworkCapabilities();
            DeviceServiceCapabilities.Security = new SecurityCapabilities();
            DeviceServiceCapabilities.Security.HttpDigestSpecified = true;
            DeviceServiceCapabilities.Security.HttpDigest          = true;
            DeviceServiceCapabilities.System = new Device10.SystemCapabilities();
            DeviceServiceCapabilities.System.DiscoveryByeSpecified = true;
            DeviceServiceCapabilities.System.DiscoveryBye          = false;


            //Door Control Service
            DoorServiceCapabilities          = new ServiceDoorControl10.ServiceCapabilities();
            DoorServiceCapabilities.MaxLimit = 7;

            //Access Control Service
            AccessControlCapabilities = new ServiceAccessControl10.ServiceCapabilities();
            //AccessControlCapabilities.DisableAccessPointSpecified = true;
            //AccessControlCapabilities.DisableAccessPoint = true;
            AccessControlCapabilities.MaxLimit = 1;

            //Credential Service
            CredentialCapabilities                = new ServiceCredential10.ServiceCapabilities();
            CredentialCapabilities.MaxLimit       = 3;
            CredentialCapabilities.MaxCredentials = 10;
            CredentialCapabilities.CredentialAccessProfileValiditySupported = true;
            CredentialCapabilities.CredentialValiditySupported    = true;
            CredentialCapabilities.MaxAccessProfilesPerCredential = 5;
            CredentialCapabilities.ResetAntipassbackSupported     = true;
            CredentialCapabilities.ValiditySupportsTimeValue      = true;
            CredentialCapabilities.SupportedIdentifierType        = new string[] { "pt:Card", "pt:PIN" };

            //Supported Format Types (probably refactoring requiered to be flexible)
            List <ServiceCredential10.CredentialIdentifierFormatTypeInfo> formatTypes;

            ServiceCredential10.CredentialIdentifierFormatTypeInfo credentialIdentifierFormatTypeInfo;

            SupportedFormatTypes = new Dictionary <string, List <ServiceCredential10.CredentialIdentifierFormatTypeInfo> >();

            formatTypes = new List <ServiceCredential10.CredentialIdentifierFormatTypeInfo>();

            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "WIEGAND26";
            credentialIdentifierFormatTypeInfo.Description = "Standard 26 bit Wiegand format as defined by SIA standard (SIA AC-01).";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);
            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "WIEGAND37";
            credentialIdentifierFormatTypeInfo.Description = "Description";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);

            SupportedFormatTypes.Add("pt:Card", formatTypes);

            formatTypes = new List <ServiceCredential10.CredentialIdentifierFormatTypeInfo>();

            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "WIEGAND37";
            credentialIdentifierFormatTypeInfo.Description = "Description";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);
            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "WIEGAND37_FACILITY";
            credentialIdentifierFormatTypeInfo.Description = "Description";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);
            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "SIMPLE_NUMBER32";
            credentialIdentifierFormatTypeInfo.Description = "Description";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);

            SupportedFormatTypes.Add("pt:PIN", formatTypes);

            //Access Rules Service
            AccessRulesCapabilities          = new ServiceAccessRules10.ServiceCapabilities();
            AccessRulesCapabilities.MaxLimit = 2;
            AccessRulesCapabilities.MaxAccessPoliciesPerAccessProfile = 2;
            AccessRulesCapabilities.MaxAccessProfiles = 5;
            AccessRulesCapabilities.MultipleSchedulesPerAccessPointSupported = true;

            //Schedule Service
            ScheduleCapabilities                             = new ServiceSchedule10.ServiceCapabilities();
            ScheduleCapabilities.MaxLimit                    = 2;
            ScheduleCapabilities.MaxSchedules                = 4;
            ScheduleCapabilities.MaxSpecialDayGroups         = 6;
            ScheduleCapabilities.MaxDaysInSpecialDayGroup    = 2;
            ScheduleCapabilities.MaxSpecialDaysSchedules     = 4;
            ScheduleCapabilities.MaxTimePeriodsPerDay        = 8;
            ScheduleCapabilities.SpecialDaysSupported        = true;
            ScheduleCapabilities.StateReportingSupported     = true;
            ScheduleCapabilities.ExtendedRecurrenceSupported = true;

            //Events Service
            EventsCapabilities = new Events10.Capabilities();
            EventsCapabilities.MaxNotificationProducers      = 3;
            EventsCapabilities.MaxPullPoints                 = 3;
            EventsCapabilities.PersistentNotificationStorage = false;
            EventsCapabilities.WSPullPointSupport            = true;
            EventsCapabilities.WSSubscriptionPolicySupport   = true;
            EventsCapabilities.WSPausableSubscriptionManagerInterfaceSupport = false;

            InitializeXmlElements();
        }
コード例 #4
0
        public override ServiceCapabilities GetServiceCapabilities()
        {
            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.AccessRulesCapabilities;

            return(capabilities);
        }
コード例 #5
0
        public override void ModifyAccessProfile(AccessProfile AccessProfile)
        {
            ConfStorageLoad();
            EventServerLoad();

            ServiceCapabilities capabilities = Simulator.SystemCapabilities.Instance.AccessRulesCapabilities;

            //Check that access profile exists
            if (!ConfStorage.AccessProfileList.ContainsKey(AccessProfile.token))
            {
                string message = string.Format("Access Profile with specified token {0} does not exists.", AccessProfile.token);
                LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal", "NotFound" });
            }


            //Check MaxAccessPoliciesPerAccessProfile capability
            if (AccessProfile.AccessPolicy != null)
            {
                if (AccessProfile.AccessPolicy.Count() > capabilities.MaxAccessPoliciesPerAccessProfile)
                {
                    string message = string.Format("Max Access Polisies per AccessProfile exeeded.");
                    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MaxAccessPoliciesPerAccessProfile" });
                }

                //Check MultipleSchedulesPerAccessPointSupported capability
                if (!capabilities.MultipleSchedulesPerAccessPointSupported)
                {
                    foreach (var group in AccessProfile.AccessPolicy.GroupBy(C => C.Entity))
                    {
                        if (group.Count() > 1)
                        {
                            string message = string.Format("Multiple AccessPoints are not supported for the same schedule, see MultipleSchedulesPerAccessPointSupported capability.");
                            LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                            FaultLib.ReturnFault(message, new string[] { "Sender", "CapabilityViolated", "MultipleSchedulesPerAccessPointSupported" });
                        }
                    }
                }

                //Check that only access points are used
                if (AccessProfile.AccessPolicy.Any(C => (C.EntityType != null) && ((C.EntityType.Namespace != "http://www.onvif.org/ver10/accesscontrol/wsdl") || (C.EntityType.Name != "AccessPoint"))))
                {
                    string message = string.Format("Specified Entity is not supported.");
                    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal" });
                }

                //Check that all Access Pioints exists
                if (AccessProfile.AccessPolicy.Any(C => !(ConfStorage.AccessPointInfoList.Keys.Contains(C.Entity))))
                {
                    string message = string.Format("Access Profile does not exist.");
                    LoggingService.LogMessage(message, DUT.PACS.Simulator.ExternalLogging.MessageType.Error);
                    FaultLib.ReturnFault(message, new string[] { "Sender", "InvalidArgVal" });
                }
            }

            //TODO: Check that all Schedules exists

            ConfStorage.AccessProfileList.Remove(AccessProfile.token);
            ConfStorage.AccessProfileList.Add(AccessProfile.token, AccessProfile);

            EventServer.ConfigurationAccessProfileChangedEvent(this, AccessProfile.token);

            EventServerSave();
            ConfStorageSave();
        }
コード例 #6
0
        private SystemCapabilities()
        {
            // don't change service capabilities in other places to maintain synchronization of
            // typed properties and XmlElement's

            //Device Management Service
            DeviceServiceCapabilities          = new DeviceServiceCapabilities();
            DeviceServiceCapabilities.Network  = new NetworkCapabilities();
            DeviceServiceCapabilities.Security = new SecurityCapabilities();
            DeviceServiceCapabilities.System   = new Device10.SystemCapabilities();

            //Door Control Service
            DoorServiceCapabilities          = new ServiceDoorControl10.ServiceCapabilities();
            DoorServiceCapabilities.MaxLimit = 7;

            //Access Control Service
            AccessControlCapabilities = new ServiceAccessControl10.ServiceCapabilities();
            //AccessControlCapabilities.DisableAccessPointSpecified = true;
            //AccessControlCapabilities.DisableAccessPoint = true;
            AccessControlCapabilities.MaxLimit = 1;

            //Credential Service
            CredentialCapabilities                = new ServiceCredential10.ServiceCapabilities();
            CredentialCapabilities.MaxLimit       = 3;
            CredentialCapabilities.MaxCredentials = 10;
            CredentialCapabilities.CredentialAccessProfileValiditySupported = true;
            CredentialCapabilities.CredentialValiditySupported    = true;
            CredentialCapabilities.MaxAccessProfilesPerCredential = 5;
            CredentialCapabilities.ResetAntipassbackSupported     = true;
            CredentialCapabilities.SupportedIdentifierType        = new string[] { "ONVIFCard", "ONVIFPIN" };

            //Supported Format Types (probably refactoring requiered to be flexible)
            List <ServiceCredential10.CredentialIdentifierFormatTypeInfo> formatTypes;

            ServiceCredential10.CredentialIdentifierFormatTypeInfo credentialIdentifierFormatTypeInfo;

            SupportedFormatTypes = new Dictionary <string, List <ServiceCredential10.CredentialIdentifierFormatTypeInfo> >();

            formatTypes = new List <ServiceCredential10.CredentialIdentifierFormatTypeInfo>();

            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "WIEGAND26";
            credentialIdentifierFormatTypeInfo.Description = "Standard 26 bit Wiegand format as defined by SIA standard (SIA AC-01).";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);
            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "WIEGAND37";
            credentialIdentifierFormatTypeInfo.Description = "Description";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);


            SupportedFormatTypes.Add("ONVIFCard", formatTypes);

            formatTypes = new List <ServiceCredential10.CredentialIdentifierFormatTypeInfo>();

            credentialIdentifierFormatTypeInfo             = new ServiceCredential10.CredentialIdentifierFormatTypeInfo();
            credentialIdentifierFormatTypeInfo.FormatType  = "WIEGAND37";
            credentialIdentifierFormatTypeInfo.Description = "Description";
            formatTypes.Add(credentialIdentifierFormatTypeInfo);
            SupportedFormatTypes.Add("ONVIFPIN", formatTypes);

            //Access Rules Service
            AccessRulesCapabilities          = new ServiceAccessRules10.ServiceCapabilities();
            AccessRulesCapabilities.MaxLimit = 2;
            AccessRulesCapabilities.MaxAccessPoliciesPerAccessProfile = 2;
            AccessRulesCapabilities.MaxAccessProfiles = 4;
            AccessRulesCapabilities.MultipleSchedulesPerAccessPointSupported = true;

            InitializeXmlElements();
        }