Ejemplo n.º 1
0
        private async Task Sign()
        {
            botonFirmar.IsEnabled = false;
            botonBorrar.IsEnabled = false;
            _signaturePanel.Stop();

            BiometricSignatureServiceBasicClient biometricSignatureClient = new BiometricSignatureServiceBasicClient("WSHttpBinding_IBiometricSignatureServiceBasic");

            var biometricResponse = await biometricSignatureClient.BeginSignatureProviderAsync(
                string.Empty,
                string.Empty,
                "demo://documentoDocumento",
                string.Empty,
                null);

            var biometricState = _signaturePanel.GetSignature(biometricResponse.instance, biometricResponse.biometricState);

            var signedBytes = await biometricSignatureClient.EndSignatureProviderAsync(biometricResponse.instance, biometricState, "demo://documentoDocumento", string.Empty, true);

            using (FileStream documentStream = new FileStream(@"d:\test\sample.signed.pdf", FileMode.Create))
            {
                await documentStream.WriteAsync(signedBytes, 0, signedBytes.Length);

                await documentStream.FlushAsync();

                documentStream.Close();
            }

            biometricSignatureClient.Close();

            _signaturePanel.Start();
            botonFirmar.IsEnabled = true;
            botonBorrar.IsEnabled = true;
        }
Ejemplo n.º 2
0
        private async Task Sign()
        {
            botonFirmar.IsEnabled = false;
            botonBorrar.IsEnabled = false;

            _signaturePanel.Stop();

            byte[] documentBytes = null;

            var assembly = Assembly.GetExecutingAssembly();

            using (Stream documentStream = assembly.GetManifestResourceStream("SealSignBSSClientTest.Assets.sample.pdf"))
            {
                documentBytes = new byte[documentStream.Length];
                await documentStream.ReadAsync(documentBytes, 0, (int)documentStream.Length);

                documentStream.Close();
            }

            Guid instance = Guid.Empty;

            var biometricFinalState = _signaturePanel.GetOfflineSignature(documentBytes, "test", out instance);

            BiometricSignatureServiceBasicClient biometricSignatureClient = new BiometricSignatureServiceBasicClient("WSHttpBinding_IBiometricSignatureServiceBasic");

            OfflineBiometricSignature[] offlineSignatures = new OfflineBiometricSignature[1];
            offlineSignatures[0]                       = new OfflineBiometricSignature();
            offlineSignatures[0].id                    = "";
            offlineSignatures[0].account               = "";
            offlineSignatures[0].biometricOptions      = BiometricSignatureFlags.Default;
            offlineSignatures[0].biometricParameters   = null;
            offlineSignatures[0].options               = SignatureFlags.Default;
            offlineSignatures[0].parameters            = null;
            offlineSignatures[0].instance              = instance;
            offlineSignatures[0].offlineBiometricState = biometricFinalState;

            var signedBytes = await biometricSignatureClient.SyncOfflineSignaturesAsync(SignatureProfile.PDF, offlineSignatures, null, documentBytes);

            using (FileStream documentStream = new FileStream(@"d:\test\sample.signed.pdf", FileMode.Create))
            {
                await documentStream.WriteAsync(signedBytes, 0, signedBytes.Length);

                await documentStream.FlushAsync();

                documentStream.Close();
            }

            biometricSignatureClient.Close();

            _signaturePanel.Start();

            botonFirmar.IsEnabled = true;
            botonBorrar.IsEnabled = true;
        }
        private async Task Sign()
        {
            botonFirmar.IsEnabled = false;
            botonBorrar.IsEnabled = false;

            _signaturePanel.Stop();

            byte[] documentBytes = null;

            var assembly = Assembly.GetExecutingAssembly();

            using (Stream documentStream = assembly.GetManifestResourceStream("SealSignBSSClientTest.Assets.sample.pdf"))
            {
                documentBytes = new byte[documentStream.Length];
                await documentStream.ReadAsync(documentBytes, 0, (int)documentStream.Length);

                documentStream.Close();
            }

            BiometricSignatureServiceBasicClient biometricSignatureClient = new BiometricSignatureServiceBasicClient("WSHttpBinding_IBiometricSignatureServiceBasic");

            var biometricResponse = await biometricSignatureClient.BeginSignatureAsync(
                SignatureProfile.PDF,
                BiometricSignatureType.Default,
                string.Empty,
                string.Empty,
                BiometricSignatureFlags.Default,
                null,
                SignatureFlags.Default,
                null,
                null,
                documentBytes);

            var biometricState = _signaturePanel.GetSignature(biometricResponse.instance, biometricResponse.biometricState);

            var signedBytes = await biometricSignatureClient.EndSignatureAsync(biometricResponse.instance, biometricState);

            using (FileStream documentStream = new FileStream(@"d:\test\sample.signed.pdf", FileMode.Create))
            {
                await documentStream.WriteAsync(signedBytes, 0, signedBytes.Length);

                await documentStream.FlushAsync();

                documentStream.Close();
            }

            biometricSignatureClient.Close();
            _signaturePanel.Start();

            botonFirmar.IsEnabled = true;
            botonBorrar.IsEnabled = true;
        }