Beispiel #1
0
        /***************************************************************************************/

        #region Utils

        public static AccessProfileInfo ToAccessProfileInfo(AccessProfile accessProifle)
        {
            AccessProfileInfo accessProifleInfo = new AccessProfileInfo();

            accessProifleInfo.token       = accessProifle.token;
            accessProifleInfo.Description = accessProifle.Description;
            accessProifleInfo.Name        = accessProifle.Name;

            return(accessProifleInfo);
        }
Beispiel #2
0
        private Dictionary <string, ServiceAccessRules10.AccessProfile> AccessProfileListInitialization()
        {
            Dictionary <string, ServiceAccessRules10.AccessProfile> res = new Dictionary <string, ServiceAccessRules10.AccessProfile>();

            ServiceAccessRules10.AccessProfile item;

            item = new ServiceAccessRules10.AccessProfile();

            item.token           = "accessprofile1";
            item.Name            = "Access Profile 1";
            item.Description     = "Access Profile Description 1";
            item.AccessPolicy    = new ServiceAccessRules10.AccessPolicy[2];
            item.AccessPolicy[0] = new ServiceAccessRules10.AccessPolicy();
            item.AccessPolicy[0].ScheduleToken = "schedule1";
            item.AccessPolicy[0].Entity        = "tokenAccessPoint1";
            item.AccessPolicy[0].EntityType    = new System.Xml.XmlQualifiedName("AccessPoint", "http://www.onvif.org/ver10/accesscontrol/wsdl");
            item.AccessPolicy[1] = new ServiceAccessRules10.AccessPolicy();
            item.AccessPolicy[1].ScheduleToken = "schedule2";
            item.AccessPolicy[1].Entity        = "tokenAccessPoint2";
            item.AccessPolicy[1].EntityType    = new System.Xml.XmlQualifiedName("AccessPoint", "http://www.onvif.org/ver10/accesscontrol/wsdl");

            res.Add(item.token, item);

            item = new ServiceAccessRules10.AccessProfile();

            item.token           = "accessprofile2";
            item.Name            = "Access Profile 2";
            item.Description     = "Access Profile Description 2";
            item.AccessPolicy    = new ServiceAccessRules10.AccessPolicy[1];
            item.AccessPolicy[0] = new ServiceAccessRules10.AccessPolicy();
            item.AccessPolicy[0].ScheduleToken = "schedule2";
            item.AccessPolicy[0].Entity        = "tokenAccessPoint2";
            item.AccessPolicy[0].EntityType    = null;


            res.Add(item.token, item);

            return(res);
        }
 public abstract void ModifyAccessProfile(AccessProfile AccessProfile);
 public abstract string CreateAccessProfile(AccessProfile AccessProfile);
 public abstract void ModifyAccessProfile(string Token, AccessProfile AccessProfile);
Beispiel #6
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();
        }