コード例 #1
0
        public static string CreateCredentialA11(this ICredentialService s, out Credential credential, out CredentialState state, bool antipassbackViolated = false)
        {
            var serviceCapabilities = s.GetServiceCapabilities();

            var value = s.GetCredentialIdentifierTypeAndValueA15(serviceCapabilities.SupportedIdentifierType);

            credential = new Credential
            {
                token       = "",
                Description = "Test Description",
                CredentialHolderReference = "TestUser",
                CredentialIdentifier      = new[] { new CredentialIdentifier {
                                                        Type = new CredentialIdentifierType {
                                                            Name = value.TypeName, FormatType = value.FormatType
                                                        }, Value = value.Value, ExemptedFromAuthentication = false
                                                    } },
                CredentialAccessProfile = null,              //new[] { new CredentialAccessProfile { AccessProfileToken = null, ValidFromSpecified = false, ValidToSpecified = false } },
                Extension          = null,
                ValidFromSpecified = false,
                ValidToSpecified   = false
            };

            AntipassbackState antipassbackState = null;

            if (serviceCapabilities.ResetAntipassbackSupported)
            {
                antipassbackState = new AntipassbackState()
                {
                    AntipassbackViolated = antipassbackViolated
                }
            }
            ;

            state = new CredentialState
            {
                Enabled           = true,
                Reason            = "Test Reason",
                AntipassbackState = antipassbackState
            };

            return(s.CreateCredential(credential, state));
        }
コード例 #2
0
        public static string CreateCredentialWithTwoCredentialIdentifierItemsA18(this ICredentialService s, bool antipassbackViolated, CredentialServiceCapabilities serviceCapabilities,
                                                                                 out CredentialIdentifier credentialIdentifierFirst, out CredentialIdentifier credentialIdentifierSecond)
        {
            credentialIdentifierFirst  = null;
            credentialIdentifierSecond = null;

            if (serviceCapabilities == null)
            {
                serviceCapabilities = s.GetServiceCapabilities();
            }

            var valueFirst  = s.GetCredentialIdentifierTypeAndValueA15(serviceCapabilities.SupportedIdentifierType);
            var valueSecond = s.GetCredentialIdentifierTypeAndValueA15(serviceCapabilities.SupportedIdentifierType.Where(e => e != valueFirst.TypeName));

            //7. ONVIF client invokes CreateCredential with parameters by following the procedure mentioned in Annex A.11.
            var credential = new Credential
            {
                token       = "",
                Description = "Test Description",
                CredentialHolderReference = "TestUser",
                CredentialIdentifier      = new[] { credentialIdentifierFirst = new CredentialIdentifier
                                                    {
                                                        Type = new CredentialIdentifierType {
                                                            Name = valueFirst.TypeName, FormatType = valueFirst.FormatType
                                                        },
                                                        Value = valueFirst.Value,
                                                        ExemptedFromAuthentication = false
                                                    },
                                                    credentialIdentifierSecond = new CredentialIdentifier
                                                    {
                                                        Type = new CredentialIdentifierType {
                                                            Name = valueSecond.TypeName, FormatType = valueSecond.FormatType
                                                        },
                                                        Value = valueSecond.Value,
                                                        ExemptedFromAuthentication = false
                                                    } },
                CredentialAccessProfile = null,
                Extension          = null,
                ValidFromSpecified = false,
                ValidToSpecified   = false
            };

            AntipassbackState antipassbackState = null;

            if (serviceCapabilities.ResetAntipassbackSupported)
            {
                antipassbackState = new AntipassbackState()
                {
                    AntipassbackViolated = antipassbackViolated
                }
            }
            ;

            var state = new CredentialState
            {
                Enabled           = true,
                Reason            = "Test Reason",
                AntipassbackState = antipassbackState
            };

            return(s.CreateCredential(credential, state));
        }
    }