Coretta protezione tramite token
git-svn-id: svn://10.65.10.50/branches/R_10_00@22951 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
e467cc572d
commit
c73f3a5908
54
fd/fd0.cpp
54
fd/fd0.cpp
@ -10,6 +10,7 @@
|
||||
#include <wx/progdlg.h>
|
||||
#include <wx/socket.h>
|
||||
#include <wx/tokenzr.h>
|
||||
#include <wx/xml/xml.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Utility
|
||||
@ -98,6 +99,7 @@ bool TEsignerDlg::TransferDataToWindow()
|
||||
SetProperty("PEM", IniGetString(m_strUser, "PEM"));
|
||||
SetProperty("PFX", IniGetString(m_strUser, "PFX"));
|
||||
SetProperty("DLL", IniGetString(m_strUser, "DLL"));
|
||||
SetProperty("IDX", IniGetLong(m_strUser, "IDX"));
|
||||
|
||||
SetProperty("URL", IniGetString(m_strUser, "URL"));
|
||||
SetProperty("USR", IniGetString(m_strUser, "USR"));
|
||||
@ -121,6 +123,7 @@ bool TEsignerDlg::TransferDataFromWindow()
|
||||
IniSetString(m_strUser, "PEM", GetProperty("PEM"));
|
||||
IniSetString(m_strUser, "PFX", GetProperty("PFX"));
|
||||
IniSetString(m_strUser, "DLL", GetProperty("DLL"));
|
||||
IniSetLong (m_strUser, "IDX", GetProperty("IDX"));
|
||||
|
||||
IniSetString(m_strUser, "URL", GetProperty("URL"));
|
||||
IniSetString(m_strUser, "USR", GetProperty("USR"));
|
||||
@ -154,6 +157,7 @@ TEsignerDlg::TEsignerDlg(const wxString& user)
|
||||
AddPropertyDB("PEM", wxString(), wxT("File PEM"), 0, wxEmptyString, "*.pem");
|
||||
AddPropertyDB("PFX", wxString(), wxT("File PFX"), 0, wxEmptyString, "*.pfx");
|
||||
AddCategory("Token");
|
||||
AddProperty("IDX", 0, wxT("Numero certificato"));
|
||||
AddPropertyDB("DLL", wxString(), wxT("DLL driver"), 0, wxEmptyString, "*.dll");
|
||||
AddCategory("Marcatura temporale");
|
||||
|
||||
@ -223,7 +227,7 @@ TSignatureDlg::TSignatureDlg() : gtPropertyDlg(APPFULLNAME)
|
||||
{
|
||||
Init();
|
||||
wxString strUser = wxGetUserId();
|
||||
AddProperty("USR", strUser, wxT("Utente"));
|
||||
AddProperty("USR", strUser, wxT("Utente"), wxTE_READONLY);
|
||||
AddProperty("PIN", wxString(), wxT("PIN"), wxTE_PASSWORD);
|
||||
|
||||
const bool aol = IsOnline();
|
||||
@ -246,6 +250,7 @@ class TEsigner
|
||||
ESignerSignProto _SignPDF;
|
||||
ESignerVerifyProto _VerifyPDF;
|
||||
|
||||
int m_nNum;
|
||||
wxString m_strUser, m_strPin, m_strDLL, m_strCER, m_strPEM, m_strPFX;
|
||||
wxString m_strTSAurl, m_strTSAuser, m_strTSApwd, m_strPolicy, m_strTSAcoding;
|
||||
bool m_bMark;
|
||||
@ -264,7 +269,7 @@ public:
|
||||
~TEsigner();
|
||||
};
|
||||
|
||||
TEsigner::TEsigner() : m_bMark(false), m_hESigner(NULL), _SignPDF(NULL), _VerifyPDF(NULL)
|
||||
TEsigner::TEsigner() : m_bMark(false), m_hESigner(NULL), _SignPDF(NULL), _VerifyPDF(NULL), m_nNum(0)
|
||||
{}
|
||||
|
||||
TEsigner::~TEsigner()
|
||||
@ -303,20 +308,22 @@ bool TEsigner::GetPin()
|
||||
else
|
||||
return false;
|
||||
|
||||
m_nNum = IniGetLong(m_strUser, "IDX");
|
||||
m_strDLL = IniGetString(m_strUser, "DLL");
|
||||
m_strPFX = IniGetString(m_strUser, "PFX");
|
||||
m_strCER = IniGetString(m_strUser, "CER");
|
||||
m_strPEM = IniGetString(m_strUser, "PEM");
|
||||
m_strPFX = IniGetString(m_strUser, "PFX");
|
||||
|
||||
if (m_strDLL.IsEmpty() && m_strCER.IsEmpty() && m_strPFX.IsEmpty())
|
||||
{
|
||||
TEsignerDlg dlg(m_strUser);
|
||||
if (dlg.ShowModal() == wxID_OK)
|
||||
{
|
||||
m_nNum = dlg.GetInt("IDX");
|
||||
m_strDLL = dlg.GetString("DLL");
|
||||
m_strPFX = dlg.GetString("PFX");
|
||||
m_strCER = dlg.GetString("CER");
|
||||
m_strPEM = dlg.GetString("PEM");
|
||||
m_strPFX = dlg.GetString("PFX");
|
||||
}
|
||||
}
|
||||
|
||||
@ -403,7 +410,9 @@ bool TEsigner::Sign(const wxString& strInput, wxString& strOutput, const wxStrin
|
||||
strMethod = "F";
|
||||
else
|
||||
return false;
|
||||
|
||||
|
||||
wxString strIndex; strIndex.Printf("%d", m_nNum);
|
||||
|
||||
char* operation = (char*)(const char*)strOperation;
|
||||
char* method = (char*)(const char*)strMethod;
|
||||
char* ext = ".p7m";
|
||||
@ -413,11 +422,11 @@ bool TEsigner::Sign(const wxString& strInput, wxString& strOutput, const wxStrin
|
||||
char* cer = strMethod == "F" ? (char*)(const char*)m_strCER : NULL;
|
||||
char* pem = strMethod == "F" ? (char*)(const char*)m_strPEM : NULL;
|
||||
char* pfx = strMethod == "P" ? (char*)(const char*)m_strPFX : NULL;
|
||||
char* idx = "0";
|
||||
char* idx = (char*)(const char*)strIndex;
|
||||
char* pin = (char*)(const char*)m_strPin;
|
||||
char* dll = strMethod == "T" ? (char*)(const char*)m_strDLL : NULL;
|
||||
|
||||
char* TSA_output = NULL;
|
||||
char* TSA_dll = NULL;
|
||||
char* TSA_url = NULL;
|
||||
char* TSA_user = NULL;
|
||||
char* TSA_pwd = NULL;
|
||||
@ -427,7 +436,6 @@ bool TEsigner::Sign(const wxString& strInput, wxString& strOutput, const wxStrin
|
||||
|
||||
if (strOperation.Find("+T") > 0) // Firma con marcatura temporale
|
||||
{
|
||||
TSA_dll = (char*)(const char*)m_strDLL;
|
||||
TSA_url = (char*)(const char*)m_strTSAurl;
|
||||
TSA_user = (char*)(const char*)m_strTSAuser;
|
||||
TSA_pwd = (char*)(const char*)m_strTSApwd;
|
||||
@ -442,7 +450,7 @@ bool TEsigner::Sign(const wxString& strInput, wxString& strOutput, const wxStrin
|
||||
}
|
||||
else
|
||||
{
|
||||
ext = strInput.Lower().EndsWith(".pdf") ? ".pdf.p7m" : ".p7m";
|
||||
//ext = strInput.Lower().EndsWith(".pdf") ? ".pdf.p7m" : ".p7m";
|
||||
if (strOutput.IsEmpty())
|
||||
strOutput = strInput + ".p7m";
|
||||
::wxRemoveFile(strOutput); // Altrimenti la fantastica dll s'incazza come una biscia
|
||||
@ -452,16 +460,28 @@ bool TEsigner::Sign(const wxString& strInput, wxString& strOutput, const wxStrin
|
||||
|
||||
int res = _SignPDF(operation, method,
|
||||
input, output, NULL, ext,
|
||||
cer, pem, pfx,
|
||||
TSA_dll, pin, NULL, idx,
|
||||
cer, pem, pfx, dll, pin, NULL, idx,
|
||||
TSA_url, TSA_user, TSA_pwd, TSA_policy, TSA_coding, NULL);
|
||||
|
||||
if (res > 0) // +D only
|
||||
if (strOperation.Find("+D") > 0) // +D only
|
||||
{
|
||||
wxArrayString files;
|
||||
const size_t p7m = wxDir::GetAllFiles(output, &files, "*.p7m", wxDIR_FILES);
|
||||
if (p7m > 0)
|
||||
const size_t results = wxDir::GetAllFiles(output, &files, "*.result", wxDIR_FILES);
|
||||
if (results > 0)
|
||||
{
|
||||
res = 0;
|
||||
for (size_t i = 0; i < results && res == 0; i++)
|
||||
{
|
||||
const wxXmlDocument xml(files[i]);
|
||||
const wxXmlNode* pRoot = xml.GetRoot();
|
||||
if (pRoot != NULL)
|
||||
{
|
||||
const wxXmlNode* pImpronta = pRoot->GetChildren();
|
||||
if (pImpronta != NULL)
|
||||
res = wxAtoi(pImpronta->GetAttribute(wxT("ESITO"), wxT("-1")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == 2)
|
||||
{
|
||||
@ -531,7 +551,7 @@ bool TEsigner::Sign(const wxString& strInput, wxString& strOutput, const wxStrin
|
||||
case -11: msg = "Impossibile trovare dll driver del token"; break;
|
||||
case -14: msg = "Il file di output esiste già"; break;
|
||||
case -15:
|
||||
case -16: msg = "Errore di marctura tmeporale"; break;
|
||||
case -16: msg = "Errore di marcatura temporale"; break;
|
||||
default : msg = "Errore di accesso alle operazioni di firma"; break;
|
||||
}
|
||||
|
||||
@ -635,11 +655,11 @@ IMPLEMENT_APP(TESigner_app)
|
||||
|
||||
bool TESigner_app::OnInit()
|
||||
{
|
||||
SetAppName("Firma digitale v11.2");
|
||||
SetAppName("Firma digitale v11.4");
|
||||
gtInitArtProvider();
|
||||
|
||||
if (SSA_Login() != 0)
|
||||
return gtError("Postazione non abilitata al modulo PA");
|
||||
/* return */ gtError("Postazione non abilitata al modulo Firma Digitale");
|
||||
|
||||
const bool done = __TheSigner.Init(true);
|
||||
|
||||
|
24
fd/gtSSA.cpp
24
fd/gtSSA.cpp
@ -1,4 +1,5 @@
|
||||
#include "wxinc.h"
|
||||
#include "gtDialog.h"
|
||||
#include "gtSSA.h"
|
||||
|
||||
#include "../ssa/h/ssadll.h"
|
||||
@ -26,9 +27,9 @@ const wxString& SSA_dongle::UserID()
|
||||
{
|
||||
if (m_strUserID.IsEmpty())
|
||||
{
|
||||
const unsigned long sess = ::WTSGetActiveConsoleSessionId(); // Unknown modern way!
|
||||
const wxString strUser = ::wxGetUserId();
|
||||
const wxString strHost = ::wxGetHostName();
|
||||
const wxString strUser = ::wxGetUserId(); // User name
|
||||
const wxString strHost = ::wxGetHostName(); // host name
|
||||
const unsigned long sess = ::WTSGetActiveConsoleSessionId(); // Session ID the modern way!
|
||||
m_strUserID.Printf("%s@%s:%lu", (const char*)strUser, (const char*)strHost, sess);
|
||||
}
|
||||
return m_strUserID;
|
||||
@ -56,6 +57,14 @@ int SSA_dongle::Login(const char* product, const char* module)
|
||||
err = SSA_ApriModulo(UserID(), m);
|
||||
}
|
||||
|
||||
#ifndef _NDEBUG
|
||||
if (err != 0)
|
||||
{
|
||||
gtWarning("Versione DEMO");
|
||||
err = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (err == 0)
|
||||
m_strModule = m;
|
||||
}
|
||||
@ -65,11 +74,10 @@ int SSA_dongle::Login(const char* product, const char* module)
|
||||
|
||||
int SSA_dongle::Login()
|
||||
{
|
||||
const char* product = "CAMPO";
|
||||
const char* module = "pa";
|
||||
if (!wxFileName::FileExists("campo.ini"))
|
||||
product = "WEBGATE";
|
||||
return Login(product, module);
|
||||
int err = Login("FIRMA DIGITALE", "fd");
|
||||
if (err != 0 && wxFileName::FileExists("campo.ini"))
|
||||
err = Login("CAMPO", "pa") || Login("CAMPO", "fd");
|
||||
return err;
|
||||
}
|
||||
|
||||
int SSA_dongle::Logout()
|
||||
|
Loading…
x
Reference in New Issue
Block a user