Clipper On Line • Ver Tópico - Assinatura digital ??

Assinatura digital ??

Projeto Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

 

Assinatura digital ??

Mensagempor JoséQuintas » 19 Abr 2021 11:51

Achei este documento, mas não guardei o link, de uma universidade.
No final tem um fonte em NET pra assinatura.
À primeira vista, usa o Adobe, igual costumamos usar o CreateObject( "Excel.Application" ), mas usando do Adobe.

AssinaturaPDF.pdf
(1.92 MiB) Baixado 62 vezes


Nota: é que fiz outras pesquisas em seguida, e acabei perdendo o link
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18009
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Assinatura digital ??

Mensagempor JoséQuintas » 19 Abr 2021 11:53

José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18009
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Assinatura digital ??

Mensagempor toninhofwi » 19 Abr 2021 12:05

Marcelo, Free não tem mas o pagamento é único, é uma DLL activeX com toneladas de exemplos em foxPro que basicamente a única diferença é que no Fox se usa obj.method e no Harbour obj:method,

Exemplos de como assinar um PDF estão aqui:

https://www.example-code.com/foxpro/pdf_signatures.asp
toninhofwi
Usuário Nível 1

Usuário Nível 1
 
Mensagens: 29
Data de registro: 23 Set 2009 22:35
Cidade/Estado: Catanduva-SP
Curtiu: 7 vezes
Mens.Curtidas: 6 vezes

Assinatura digital ??

Mensagempor malcarli » 19 Abr 2021 14:07

Obrigado, vou testar com o demo de 30 dias, ver ser consigo fazer rodar um exemplo. Se der certo o exemplo, posto o fonte aqui.

toninhofwi escreveu:Marcelo, Free não tem mas o pagamento é único, é uma DLL activeX com toneladas de exemplos em foxPro que basicamente a única diferença é que no Fox se usa obj.method e no Harbour obj:method,

Exemplos de como assinar um PDF estão aqui:

https://www.example-code.com/foxpro/pdf_signatures.asp


Att.

Marcelo A. L. Carli
Marília/SP
Capital Nacional do Alimento ®

https://malc-informatica.ueniweb.com
http://marcelo.lx.com.br
Email / Skype: malcarli@life.com.br
malcarli
Usuário Nível 3

Usuário Nível 3
 
Mensagens: 181
Data de registro: 20 Ago 2015 18:14
Cidade/Estado: marilia/sp
Curtiu: 81 vezes
Mens.Curtidas: 4 vezes

Assinatura digital ??

Mensagempor malcarli » 19 Abr 2021 14:10

O que meus clientes estão fazendo é exatamente isto, mas querem que eu automatize



Quanto a esta rotina, parece uma solução viável, o problema que não entendo nada de .Net, se conseguir uma "tradução" para harbour, daria para testar.

Att.

Marcelo A. L. Carli
Marília/SP
Capital Nacional do Alimento ®

https://malc-informatica.ueniweb.com
http://marcelo.lx.com.br
Email / Skype: malcarli@life.com.br
malcarli
Usuário Nível 3

Usuário Nível 3
 
Mensagens: 181
Data de registro: 20 Ago 2015 18:14
Cidade/Estado: marilia/sp
Curtiu: 81 vezes
Mens.Curtidas: 4 vezes

Assinatura digital ??

Mensagempor toninhofwi » 20 Abr 2021 16:14

Segue um teste simples para ler algumas TAGs da NFe, para ajudar a compreeender o jeito de trabalho da DLL porque tudo nela segue esta regra:

---cut---

static procedure testChilkat()

   local oGlobal := win_OleGetActiveObject( "Chilkat_9_5_0.Global.1" )

   local oXml

   if !hb_IsObject( oGlobal )
      oGlobal = win_OleCreateObject( "Chilkat_9_5_0.Global.1" )
   endif

   if hb_IsObject( oGlobal )

      if oGlobal:UnlockBundle( "Start my 30-day Trial" ) == 1

         oXml = win_OleGetActiveObject( "Chilkat_9_5_0.Xml" )

         if !hb_IsObject( oXml )
            oXml = win_OleCreateObject( "Chilkat_9_5_0.Xml" )
         endif

         if hb_IsObject( oXml )

            oXml:LoadXmlFile( "d:\xml\n1.xml" )

            ? oXml:GetChildContent( "protNFe|infProt|chNFe" )

            ? oXml:GetChildContent( "NFe|infNFe|infAdic|infCpl" )

         endif

      endif

   endif

return


---cut---
toninhofwi
Usuário Nível 1

Usuário Nível 1
 
Mensagens: 29
Data de registro: 23 Set 2009 22:35
Cidade/Estado: Catanduva-SP
Curtiu: 7 vezes
Mens.Curtidas: 6 vezes

Assinatura digital ??

Mensagempor malcarli » 22 Abr 2021 08:46

Bom dia, neste exemplo abaixo onde está oXml = win_OleGetActiveObject( "Chilkat_9_5_0.Xml" ), substituiria pela extensão pdf?

toninhofwi escreveu:Segue um teste simples para ler algumas TAGs da NFe, para ajudar a compreeender o jeito de trabalho da DLL porque tudo nela segue esta regra:

---cut---

static procedure testChilkat()

   local oGlobal := win_OleGetActiveObject( "Chilkat_9_5_0.Global.1" )

   local oXml

   if !hb_IsObject( oGlobal )
      oGlobal = win_OleCreateObject( "Chilkat_9_5_0.Global.1" )
   endif

   if hb_IsObject( oGlobal )

      if oGlobal:UnlockBundle( "Start my 30-day Trial" ) == 1

         oXml = win_OleGetActiveObject( "Chilkat_9_5_0.Xml" )

         if !hb_IsObject( oXml )
            oXml = win_OleCreateObject( "Chilkat_9_5_0.Xml" )
         endif

         if hb_IsObject( oXml )

            oXml:LoadXmlFile( "d:\xml\n1.xml" )

            ? oXml:GetChildContent( "protNFe|infProt|chNFe" )

            ? oXml:GetChildContent( "NFe|infNFe|infAdic|infCpl" )

         endif

      endif

   endif

return


---cut---
malcarli
Usuário Nível 3

Usuário Nível 3
 
Mensagens: 181
Data de registro: 20 Ago 2015 18:14
Cidade/Estado: marilia/sp
Curtiu: 81 vezes
Mens.Curtidas: 4 vezes

Assinatura digital ??

Mensagempor toninhofwi » 22 Abr 2021 13:21

Bom dia, neste exemplo abaixo onde está oXml = win_OleGetActiveObject( "Chilkat_9_5_0.Xml" ), substituiria pela extensão pdf?


Boa tarde,

Não, eu só dei o exemplo de como se utiliza a chilkat, criei um exemplo onde eu leio algumas tags da NFe.

Para assinar PDF você terá que estudar os exemplos em FOX pro que tem no site da chilkat e adaptar o código.

Abraço.
toninhofwi
Usuário Nível 1

Usuário Nível 1
 
Mensagens: 29
Data de registro: 23 Set 2009 22:35
Cidade/Estado: Catanduva-SP
Curtiu: 7 vezes
Mens.Curtidas: 6 vezes

Assinatura digital ??

Mensagempor malcarli » 22 Abr 2021 16:33

Usando os exemplos da página do ChilKat, para fox pro, adaptei para me extended com harbour, mas está dando erro de método não exportado na linha:
lnSuccess:= loPdf:LoadFile([E:\tools\newpcmso\chilkat\teste.pdf])

obs: existe o arquivo nesta pasta

/*****************************************************************************
* SISTEMA  : ROTINA EVENTUAL                                                *
* PROGRAMA : DEMO.PRG                                                       *
* OBJETIVO : Assinar Digitalmente um Pdf                                    *
* AUTOR    : Marcelo Antonio Lázzaro Carli                                  *
* DATA     : 22.04.2021                                                     *
* ULT. ALT.: 22.04.2021                                                     *
*****************************************************************************/
#include <minigui.ch>

Function Main()
   REQUEST HB_LANG_PT
   HB_LangSelect([PT])
   REQUEST HB_CODEPAGE_PT850 &&& PARA INDEXAR CAMPOS ACENTUADOS
   HB_SETCODEPAGE([PT850])   &&& PARA INDEXAR CAMPOS ACENTUADOS

   Set wrap on
   Set talk off
   Set date briti             &&& data no formato dd/mm/aaaa
   Set dele on                &&& ignora registros marcados por deleção
   Set score off
   Set exact on
   Set ToolTip on
   Setcancel(.F.)             &&& evitar cancelar sistema c/ ALT + C
   Set cent on                &&& ano com 4 dígitos
   Set epoch to 2000          &&& ano a partir de 2000
   Set excl off               &&& abre arquivos em modo compartilhado
   Set navigation extended    &&& enter no lugar do tab
   Set language to portuguese &&& mensagens em português
   Set multiple off warning   &&& abrir 1 cópia somente
   Set tooltipstyle balloon   &&& para mensagem dos campos em forma de balão
   Set menustyle extended     &&& padrão é standard, extended estilo office 2007
   Set programmaticchange off &&& introduzida na build 1.9.94

   Define window main at 0, 0 width getDesktopWidth() height getDesktopHeight() ICON "dw.ico" NOTIFYICON "dw.ico" MAIN title [Atualizador] NOSIZE

      @ 030,090 BUTTON btn_P1 caption [&Assinar] action {|| (fAssinar(), main.Release())} WIDTH 120 TOOLTIP [Selecione]

      on key escape action {|| Thiswindow.Release()}
   end window

   main.Center
   main.maximize
   main.Activate
Return (Nil)

Static Procedure fAssinar()
   Local loPdf, lnSuccess, loJson, loCert

   Destravar()

   * This example requires the Chilkat API to have been previously unlocked.
   * See Global Unlock Sample for sample code.

   * loPdf = CreateObject('Chilkat_9_5_0.Pdf')
   loPdf:= win_OleGetActiveObject([Chilkat_9_5_0.Pdf])

   * Load a PDF to be signed.
   * The "hello.pdf" is available at https://chilkatsoft.com/hello.pdf
   lnSuccess:= loPdf:LoadFile([E:\tools\newpcmso\chilkat\teste.pdf])
   If lnSuccess == 0
      MsgInfo(loPdf:LastErrorText, [este])
      RELEASE loPdf
      CANCEL
   Endif

   loJson:= win_OleCreateObject([Chilkat_9_5_0.JsonObject])

   * Put the signature on page 1, top left
   loJson:UpdateInt([page],1)
   loJson:UpdateString([appearance.y],[top])
   loJson:UpdateString([appearance.x],[left])

   * Use a font scale of 10.0
   loJson:UpdateString([appearance.fontScale],[10.0])

   * In this example, the appearance of the digital signature will contain three lines:
   * 1) The signing certificate's common name
   * 2) The current date/time
   * 3) Some arbitrary text.
   * The keyword "cert_cn" is replaced with the Certificate's Subject Common Name.
   * The keyword "current_dt" is replaced with the current date/time.
   * Any number of appearance text lines can be added.
   loJson:UpdateString('appearance.text[0]',[Digitally signed by: cert_cn])
   loJson:UpdateString('appearance.text[1]',[current_dt])
   loJson:UpdateString('appearance.text[2]',[The crazy brown fox jumps over the lazy dog.])

   * Load the signing certificate. (Use your own certificate.)
   loCert:= win_OleCreateObject([Chilkat_9_5_0.Cert])
   lnSuccess:= loCert:LoadPfxFile("qa_data/pfx/myPdfSigningCert.pfx],[secret])
   If lnSuccess == 0
      MsgInfo(loCert:LastErrorText, [este 1])
      RELEASE loPdf
      RELEASE loJson
      RELEASE loCert
      CANCEL
    Endif

   * Tell the pdf object to use the certificate for signing.
   lnSuccess:= loPdf:SetSigningCert(loCert)
   If lnSuccess == 0
      MsgInfo(loPdf:LastErrorText, [este 2])
      RELEASE loPdf
      RELEASE loJson
      RELEASE loCert
      CANCEL
   Endif

   lnSuccess:= loPdf:SignPdf(loJson,[hello_signed.pdf])
   If lnSuccess == 0
      MsgInfo(loPdf:LastErrorText, [este 3])
      RELEASE loPdf
      RELEASE loJson
      RELEASE loCert
      CANCEL
   Endif

    MsgInfo([The PDF has been successfully cryptographically signed.], [Finalmente])
Return (Nil)

Static Function Destravar()
   Local loGlob:= win_OleCreateObject([Chilkat_9_5_0.Global]), lnSuccess, lnStatus

   lnSuccess:= loGlob:UnlockBundle([Start my 30-day Trial])
   If lnSuccess <> 1
       MsgInfo(loGlob:LastErrorText, [aqui])
       RELEASE loGlob
       CANCEL
   Endif

   lnStatus:= loGlob:UnlockStatus
   If lnStatus == 2
      MsgInfo([Desbloqueado. Usando o código de desbloqueio comprado.], [aqui 1])
   Else
      MsgInfo([Desbloqueado no modo de teste.], [aqui 2])
   Endif

   * The LastErrorText can be examined in the success case to see if it was unlocked in trial more, or with a purchased unlock code.
   * MsgInfo(loGlob:LastErrorText, [aqui 3])
   RELEASE loGlob
Return (Nil)

malcarli
Usuário Nível 3

Usuário Nível 3
 
Mensagens: 181
Data de registro: 20 Ago 2015 18:14
Cidade/Estado: marilia/sp
Curtiu: 81 vezes
Mens.Curtidas: 4 vezes

Assinatura digital ??

Mensagempor malcarli » 23 Abr 2021 12:15

Boa tarde, testando a versão 9.5.0.86 da Chilkat, funcionou perfeitamente a assinatura do pdf. Nas versões anteriores não existe o comando loadfile, por isso do erro de método não exportado. Fiz teste usando a chave de versão trial.

Agora convencer clientes a pagar pela biblioteca, ou continuar buscando uma solução free.
malcarli
Usuário Nível 3

Usuário Nível 3
 
Mensagens: 181
Data de registro: 20 Ago 2015 18:14
Cidade/Estado: marilia/sp
Curtiu: 81 vezes
Mens.Curtidas: 4 vezes

Assinatura digital ??

Mensagempor Itamar M. Lins Jr. » 04 Mai 2021 08:09

Olá!
JsignPdf is an excellent tool for Signing PDF documents. In windows , it can be used with WINDOWS-MY key store or other key stores.

1.Create PDF using hbhpdf contrib
2. Sign using JsignPdf in Java JAR (wapi_shellexecute () in silent mode with bundles of JsignPdf parameters)
(can be done from within your Harbour application , JsignPdf is a compact & free java program from Josef Cacek)

Shaji Thomas



Achei pertinente ao assunto.

Saudações,
Itamar M. Lins Jr.
Avatar de usuário

Itamar M. Lins Jr.
Colaborador

Colaborador
 
Mensagens: 6927
Data de registro: 30 Mai 2007 11:31
Cidade/Estado: Ilheus Bahia
Curtiu: 309 vezes
Mens.Curtidas: 503 vezes

Assinatura digital ??

Mensagempor Mario Mesquita » 04 Mai 2021 18:07

Boa noite a todos.

Itamar, dá pra usar com Harbour? Não entendi bem, são rotinas em Java? Se pode embarcar no Harbour, onde se pode obter mais detalhes?

Sds,
Mario.
Avatar de usuário

Mario Mesquita
Usuário Nível 4

Usuário Nível 4
 
Mensagens: 557
Data de registro: 08 Dez 2009 12:47
Cidade/Estado: Rio de Janeiro
Curtiu: 73 vezes
Mens.Curtidas: 13 vezes

Assinatura digital ??

Mensagempor Itamar M. Lins Jr. » 04 Mai 2021 18:29

Olá!
dá pra usar com Harbour?


O autor disse que usa com o Harbour, mas não colocou os comandos.

Pelo que ele escreveu ai, não deve ser complicado.
Com uma rápida procura pelo google, achei isso!
https://arwsd.com.br/download/manuais/Manual%20-%20Assinatura%20pelo%20JSignPDF.pdf

Saudações,
Itamar M. Lins Jr.
Avatar de usuário

Itamar M. Lins Jr.
Colaborador

Colaborador
 
Mensagens: 6927
Data de registro: 30 Mai 2007 11:31
Cidade/Estado: Ilheus Bahia
Curtiu: 309 vezes
Mens.Curtidas: 503 vezes

Assinatura digital ??

Mensagempor Itamar M. Lins Jr. » 04 Mai 2021 18:39

Olá!
Estou no Linux, depois que baixar o aquivo jSignpdf.jar teste ai:

java -jar JSignPdf.jar -kst PKCS12 -ksf my_certificate.pfx -ksp myPrivateKeystorePassword -d C:\output C:\Documents\*.pdf

Used options:
-kst keystore type
-ksf path to a keystore
-ksp password
-d output folder


Saudações,
Itamar M. Lins Jr.
Avatar de usuário

Itamar M. Lins Jr.
Colaborador

Colaborador
 
Mensagens: 6927
Data de registro: 30 Mai 2007 11:31
Cidade/Estado: Ilheus Bahia
Curtiu: 309 vezes
Mens.Curtidas: 503 vezes

Assinatura digital ??

Mensagempor clodoaldomonteiro » 14 Ago 2023 15:44

Boa tarde,

Reacendendo este Post, vcs conseguiram assinar com A3, onde temos que plugar o PenDriver ou Card, e ainda digitar a senha do responsável?

Desde já, agradeço.
At. Clodoaldo Monteiro
Linguagens: Clipper / Harbour
Área de Atuação: Sistemas de gestão para Prefeituras Municipais
Fones: (86)3223-0653, 98859-0236
www.simplesinformatica.com.br
Avatar de usuário

clodoaldomonteiro
Usuário Nível 4

Usuário Nível 4
 
Mensagens: 741
Data de registro: 30 Dez 2006 12:17
Cidade/Estado: Teresina-PI
Curtiu: 110 vezes
Mens.Curtidas: 31 vezes

Anterior Próximo



Retornar para Harbour

Quem está online

Usuários vendo este fórum: Nenhum usuário registrado online e 5 visitantes


Ola Amigo, espero que meu site e forum tem lhe beneficiado, com exemplos e dicas de programacao.
Entao divulgue o link da Doacao abaixo para seus amigos e redes sociais ou faça uma doacao para o site forum...
MUITO OBRIGADO PELA SUA DOACAO!
Faça uma doação para o forum
cron
v
Olá visitante, seja bem-vindo ao Fórum Clipper On Line!
Efetue o seu login ou faça o seu Registro