Patch level : 10.0

Files correlati     : xvaga.dll
Ricompilazione Demo : [ ]
Commento            :
Aggiunto supporto per firma digitale.  La ddl in nostro possesso e' pero' un DEMO


git-svn-id: svn://10.65.10.50/trunk@18573 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2009-03-19 15:51:51 +00:00
parent 6f9698a5bf
commit ba7189cc3d
3 changed files with 168 additions and 9 deletions

View File

@ -970,6 +970,8 @@ static wxString MakeFileName(const wxChar* name, const wxChar* ext)
static FL_STATUS xvt_dm_post_file_ask(FILE_SPEC *fsp, const char *msg, int flags)
{
DIRECTORY savedir; xvt_fsys_get_dir(&savedir); // Salvo cartella corrente
wxString path = fsp->dir.path;
wxString name = MakeFileName(fsp->name, fsp->type);
wxString extension = fsp->type;
@ -980,6 +982,8 @@ static FL_STATUS xvt_dm_post_file_ask(FILE_SPEC *fsp, const char *msg, int flags
return FL_CANCEL;
xvt_fsys_convert_str_to_fspec(selectedname, fsp);
xvt_fsys_set_dir(&savedir); // Ripristino cartella corrente
return FL_OK;
}

View File

@ -447,8 +447,10 @@ XVTDLL int xvt_pane_manager_save_perspective(WINDOW win, char* str, int max_
XVTDLL BOOLEAN xvt_pane_set_size_range(WINDOW pane, int min_size, int best_size, int max_size);
XVTDLL BOOLEAN xvt_pane_set_title(WINDOW pane, const char* title);
XVTDLL BOOLEAN xvt_pdf_sign(const char* name);
XVTDLL BOOLEAN xvt_pdf_signed(const char* name);
XVTDLL BOOLEAN xvt_sign_file(const char* input_file, char* output_file);
XVTDLL BOOLEAN xvt_sign_start();
XVTDLL BOOLEAN xvt_sign_stop();
XVTDLL BOOLEAN xvt_sign_test(const char* input_file);
typedef int ODBC_CALLBACK(void*, int, char**, char**);
XVTDLL XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const char* pwd, const char* dir);

View File

@ -131,10 +131,10 @@ wxString TwxPrintOut::PrinterName() const
return wxString(strName);
}
bool TwxPrintOut::HasPage(int pageNum)
bool TwxPrintOut::HasPage(int WXUNUSED(pageNum))
{ return true; }
bool TwxPrintOut::OnPrintPage(int pageNum)
bool TwxPrintOut::OnPrintPage(int WXUNUSED(pageNum))
{ return false; }
void TwxPrintOut::ResetDC()
@ -831,7 +831,7 @@ BOOLEAN xvt_print_restart_thread()
return TRUE;
}
BOOLEAN xvt_print_open_page(PRINT_RCD* precp)
BOOLEAN xvt_print_open_page(PRINT_RCD* WXUNUSED(precp))
{
BOOLEAN ok = m_PrintoutCache.Printing();
if (ok)
@ -1185,12 +1185,165 @@ BOOLEAN xvt_fsys_file_md5(const char* path, char* outstr)
// Gestione firma digitale
///////////////////////////////////////////////////////////
BOOLEAN xvt_pdf_sign(const char* name)
typedef
int (*dllSignMethod) (
char *operation, //operazione : S (firma file),
// S+D (firma directory),
// S+T (firma + marca file),
// S+T+D (firma + marca directory)
char *method, //metodo : F (file cert), P (file PFX), T (token/smartcard)
char *inputFile, //percorso file di input
char *outputFile, //percorso file di output (senza estensione)
char *timestampOutputFile, //percorso file di output TSR (marca temporale separata)
char *extension, //estensione in caso di input PDF
char *certificateFile, //nome file .cer o .crt contenente il certificato
char *kprivFile, //nome file .pem contenente la chiave privata
char *pfxFile, //nome file pfx contenente certificato e chiave privata
char *pkcs11Dll, //nome dll PKCS11
char *pin_passphrase, //passphrase o PIN (per chiave privata, pfx o token)
char *directoryTokenCache, //directory cache certificati estratti da token
char *indexCertificateOnToken, //numero certificato del token
char *tsaURI, //URI della TSA (http:\\....)
char *tsaUsername, //Username TSA
char *tsaPassword, //Password TSA
char *tsaPolicy, //Policy TSA
char *tsaCoding, //Codifica TSA: binary o base64
char *rootCADir) //percorso directory contenente i certificati della rootca
;
typedef int (*dllVerifyMethod) (
char *operation, //operazione : V (verifica file),
// V+D (verifica directory),
char *inputFileName, //percorso file di input
char *responseFileName, //percorso file di esito
char *rootCADir, //percorso directory contenente i certificati della rootca
char *rootTSADir, //percorso directory contenente i certificati delle rootTSA
char *resultDescription //parametro di output contenente l'esito della verifica
);
static dllSignMethod _SignPDF = NULL;
static dllVerifyMethod _VerifyPDF = NULL;
static wxString _strPin;
static BOOLEAN xvt_sign_init(BOOL bLoad)
{
return FALSE;
BOOLEAN ok = FALSE;
#ifdef WIN32
static HMODULE hESigner = NULL;
if (bLoad)
{
if (hESigner == NULL)
{
hESigner = ::LoadLibrary("esigner.dll");
if (hESigner != NULL)
{
_SignPDF = (dllSignMethod)::GetProcAddress(hESigner, "Sign");
_VerifyPDF = (dllVerifyMethod)::GetProcAddress(hESigner, "Verify");
_strPin = "";
}
}
ok = hESigner != NULL && _SignPDF != NULL && _VerifyPDF != NULL;
if (!ok)
xvt_dm_post_error("Can't load ESigner.dll");
}
else
{
if (hESigner != NULL)
{
::FreeLibrary(hESigner);
_SignPDF = NULL;
_VerifyPDF = NULL;
_strPin = "";
}
}
#endif
return ok;
}
BOOLEAN xvt_pdf_signed(const char* name)
BOOLEAN xvt_sign_file(const char* input_name, char* output_name)
{
return FALSE;
wxString strInput = input_name;
if (strInput.IsEmpty())
{
FILE_SPEC fs;
xvt_fsys_convert_str_to_fspec(strInput, &fs);
if (xvt_dm_post_file_open(&fs, "File") != FL_OK)
return FALSE;
}
strInput.MakeLower();
wxString strOutput = output_name;
if (strOutput.IsEmpty())
{
strOutput = strInput + ".p7m";
if (output_name != NULL)
wxStrncpy(output_name, strOutput, _MAX_PATH);
}
if (_strPin.IsEmpty() && !xvt_sign_start())
return FALSE;
const char* ext = strInput.EndsWith(".pdf") ? ".pdf" : "";
int res = _SignPDF("S", "T", // "S"ignature with "T"oken or smartcard
(char*)(const char*)strInput, (char*)(const char*)strOutput,
NULL, (char*)ext, NULL, NULL, NULL, NULL,
(char*)(const char*)_strPin,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
if (res == 0)
{
if (!xvt_fsys_file_exists(strOutput))
{
wxString str = "ESigner.dll can't create " + strOutput;
xvt_dm_post_error(str);
res = -1;
}
}
else
{
wxString str;
str.Printf("ESigner.dll error %d", res);
xvt_dm_post_error(str);
}
return res == 0;
}
BOOLEAN xvt_sign_start()
{
BOOLEAN ok = xvt_sign_init(TRUE);
if (ok)
{
char* pin = _strPin.GetWriteBuf(16); *pin = '\0';
xvt_dm_post_string_prompt("PIN", pin, 15);
_strPin.UngetWriteBuf();
ok = !_strPin.IsEmpty();
}
return ok;
}
BOOLEAN xvt_sign_stop()
{
_strPin = "";
xvt_sign_init(FALSE);
return TRUE;
}
BOOLEAN xvt_sign_test(const char* input_name)
{
if (!xvt_sign_init(input_name != NULL))
return FALSE;
wxString strInput = input_name;
if (strInput.IsEmpty())
{
FILE_SPEC fs;
xvt_fsys_convert_str_to_fspec(strInput, &fs);
if (xvt_dm_post_file_open(&fs, "File") != FL_OK)
return FALSE;
}
strInput.MakeLower();
int res = _VerifyPDF("V", (char*)(const char*)strInput, NULL, NULL, NULL, NULL);
return res == 0;
}