Ejemplo n.º 1
0
        private Dictionary <string, ServiceAccessControl10.AccessPointInfo> AccessPointInfoDefaultInitialization()
        {
            Dictionary <string, ServiceAccessControl10.AccessPointInfo> res = new Dictionary <string, ServiceAccessControl10.AccessPointInfo>();

            ServiceAccessControl10.AccessPointInfo item;

            item              = new ServiceAccessControl10.AccessPointInfo();
            item.token        = "tokenAccessPoint1";
            item.Name         = "AccessPoint1 Name";
            item.Description  = "AccessPoint1 Description";
            item.AreaFrom     = "tokenArea1";
            item.AreaTo       = "tokenArea2";
            item.EntityType   = new System.Xml.XmlQualifiedName("Door", "http://www.onvif.org/ver10/doorcontrol/wsdl");
            item.Entity       = "tokenDoor1";
            item.Capabilities = new ServiceAccessControl10.AccessPointCapabilities();
            item.Capabilities.DisableAccessPoint       = true;
            item.Capabilities.AccessTaken              = true;
            item.Capabilities.AccessTakenSpecified     = true;
            item.Capabilities.AnonymousAccess          = true;
            item.Capabilities.AnonymousAccessSpecified = true;
            item.Capabilities.Duress                         = true;
            item.Capabilities.DuressSpecified                = true;
            item.Capabilities.ExternalAuthorization          = true;
            item.Capabilities.ExternalAuthorizationSpecified = true;
            item.Capabilities.Tamper                         = true;
            item.Capabilities.TamperSpecified                = true;

            res.Add(item.token, item);

            item              = new ServiceAccessControl10.AccessPointInfo();
            item.token        = "tokenAccessPoint2";
            item.Name         = "AccessPoint2 Name";
            item.Description  = "AccessPoint2 Description";
            item.EntityType   = new System.Xml.XmlQualifiedName("Door", "http://www.onvif.org/ver10/doorcontrol/wsdl");
            item.Entity       = "tokenDoor1";
            item.Capabilities = new ServiceAccessControl10.AccessPointCapabilities();
            item.Capabilities.DisableAccessPoint       = false;
            item.Capabilities.AccessTaken              = false;
            item.Capabilities.AccessTakenSpecified     = false;
            item.Capabilities.AnonymousAccess          = false;
            item.Capabilities.AnonymousAccessSpecified = false;
            item.Capabilities.Duress                         = false;
            item.Capabilities.DuressSpecified                = false;
            item.Capabilities.ExternalAuthorization          = false;
            item.Capabilities.ExternalAuthorizationSpecified = false;
            item.Capabilities.Tamper                         = false;
            item.Capabilities.TamperSpecified                = false;

            res.Add(item.token, item);

            return(res);
        }
Ejemplo n.º 2
0
        public override void ExternalAuthorization(string AccessPointToken, string CredentialToken, string Reason, Decision Decision)
        {
            Reason = "Other";
            AccessPointInfo accessPointInfo = null;

            try
            {
                accessPointInfo = GetInfo(AccessPointToken, C => C.AccessPointInfoList);
            }
            catch (SoapException ex)
            {
                FaultLib.ReturnFault(string.Format("Access point '{0}' not found. ", AccessPointToken),
                                     new[] { "Sender", "InvalidArgVal", "NotFound" });
            }

            AccessPointState accessPointState = GetInfo(AccessPointToken, C => C.AccessPointState);
            var       capabilities            = accessPointInfo.Capabilities;
            Requester requester = Requester.Anonymous;

            DUT.PACS.Simulator.ServiceCredential10.Credential credentials = new DUT.PACS.Simulator.ServiceCredential10.Credential();

            if (!string.IsNullOrEmpty(CredentialToken))
            {
                requester = Requester.Credential;

                try
                {
                    credentials = GetInfo(CredentialToken, C => C.CredentialList);
                }
                catch (SoapException)
                {
                    Reason = "Invalid credentials";
                    EventServer.AccessControlExternalEvent(this, "Access Response",
                                                           AccessPointToken, CredentialToken, null, Reason,
                                                           Decision.Denied, requester);
                    throw;
                }
            }
            if (!capabilities.AnonymousAccess && requester == Requester.Anonymous)
            {
                Reason = "AnonymousAccess is inaccessible";
                EventServer.AccessControlExternalEvent(this, "Access Response",
                                                       AccessPointToken, CredentialToken, credentials.CredentialHolderReference,
                                                       Reason, Decision.Denied, requester);
                FaultLib.ReturnFault(Reason, new string[] { "Sender", "ActionNotSupported", "NotSupported" });
            }

            if (accessPointState.Enabled)
            {
                if (capabilities.ExternalAuthorizationSpecified && capabilities.ExternalAuthorization)
                {
                    EventServer.AccessControlExternalEvent(this, "Access Response",
                                                           AccessPointToken, CredentialToken,
                                                           credentials.CredentialHolderReference,
                                                           Reason, Decision, requester);
                }
                else
                {
                    Reason = "External authorization is inaccessible";
                    EventServer.AccessControlExternalEvent(this, "Access Response",
                                                           AccessPointToken, CredentialToken, credentials.CredentialHolderReference,
                                                           Reason, Decision.Denied, requester);
                    FaultLib.ReturnFault(Reason, new string[] { "Sender", "ActionNotSupported", "NotSupported" });
                }
            }
            else
            {
                Reason = "Access point is disabled";
                EventServer.AccessControlExternalEvent(this, "Access Response",
                                                       AccessPointToken, CredentialToken, credentials.CredentialHolderReference, Reason,
                                                       Decision.Denied, requester);
                FaultLib.ReturnFault(Reason, new string[] { "Sender" });
            }
        }