Richiede ad un server di timestamp di eseguire la marcatura temporale di un file.
La funzione può salvare separatamente la query della marca temporale fatta al server, può separare la marca dal file che ha richiesto l'applicazione della marca su di se e può salvare un responso dell'esito in formato XML.
int WINAPI dmtTimeStamp(
HDMTOBJ hDmt, // Handle oggetto Dimatek
CHAR *szHttpServerUrl,
CHAR *SourceFileName,
TIPO_FILE_TIMESTAMP TipoFileTimestamp,
BOOL fSaveTimeStampQuery = FALSE,
BOOL fDetachTS = FALSE,
BOOL fSaveXMLReply = FALSE,
CHAR *szAlgHash = szOID_OIWSEC_sha1, // Algoritmo di Hash
CHAR *szUsername = NULL,
CHAR *szPassword = NULL
);
External_Function dmtTimeStamp "dmtTimeStamp" Dimatec.dll ;
HDMTOBJ hDmt ;
String szHttpServerUrl ;
String szSourceFileName ;
TIPO_FILE_TIMESTAMP TipoFileTimestamp,
Boolean fSaveTimeStampQuery ;
Boolean fDetachTSR ;
Boolean fSaveXMLReply ;
String szAlgHash ;
String szUsername ;
String szPassword ;
return integer
Dichiarazione - Visual Basic
Public Declare Function dmtTimeStamp Lib "Dimatec.dll" _
(ByVal hDmt As Long, _
ByVal szHttpServerUrl As String, _
ByVal szSourceFileName As String, _
TIPO_FILE_TIMESTAMP TipoFileTimestamp,
Optional ByVal fSaveTimeStampQuery As Boolean = False, _
Optional ByVal fDetachTSR As Boolean = False, _
Optional ByVal fSaveXMLReply As Boolean = False, _
Optional ByVal szAlgHash as String = SzOID_OIWSEC_SHA1, _
Optional ByVal szUsername as string = "", _
Optional ByVal szPassword as string = "") _
As Long
Dichiarazione - C Sharp
[DllImport("Dimatec.dll")]
public static extern int dmtTimeStamp (
int hDmt,
string szHttpServerUrl,
string szSourceFileName,
TIPO_FILE_TIMESTAMP TipoFileTimestamp,
bool fSaveTimeStampQuery /*= false */,
bool fDetachTSR /*=false */,
bool fSaveXMLReply /*= false */,
String szAlgHash ,
String szUsername ,
String szPassword )
hDmt - Handle dell'oggetto DiMaTek
szHttpServerUrl - Indirizzo URL del server di timestamp
szSourceFileName - File da marcare temporalmente
iTipoFileTimeStamp - Tipo di marca da generare 0 = M7M 1= TSD
fSaveTimeStampQuery - Se TRUE verrà salvata la query inviata al server di timestamp
fDetachTSR - Se TRUE verrà salvata in modo separato la marca temporale ricevuta
fSaveXMLReply - Se TRUE verrà salvata la risposta del server di timestamp in un file Xml
szAlgHash - Algoritmo di Hash può essere SzOID_OIWSEC_SHA1
szUsername - se il servizio richiede login di accesso
szPassword . Se il servizio richiede una password di access
Ritorna lo status della risposta della TSA, questi valori possono essere:
0 = granted
1 = grantedWithMods
2 = rejection
3 = waiting
4 = revocationWarning
5 = revocationNotification
Note:
Per i test è stato utilizzato il servizio gratuito di marca temporale fornito all'indirizzo:
http://timestamping.edelweb.fr/service/tsp
Non è garantito che il servizio TS su questo server sia sempre attivo e/o che rimanga gratuito anche in futuro.
Integer ret
String sUrlTimeStamp
String sFileDaMarcare
// Check
If (Length(Trim(psFileDaMarcare(oMarcaTemporaleServerFree))) = 0) Begin
Send Stop_Box "Any file selected to timestamp" "EseguiTimeStamp"
Procedure_Return
End
Get Value of oForm_UrlTimeStamp to sUrlTimeStamp
Get psFileDaMarcare of oMarcaTemporaleServerFree to sFileDaMarcare
// ========================================================= '
// Timestamp request
Move (dmtTimeStamp( ;
ghDmt , ;
sUrlTimeStamp , ;
sFileDaMarcare , ;
(Checked_State(oCheckBox_SaveQuery)) , ;
(Checked_State(oCheckBox_Detach)) , ;
(Checked_State(oCheckBox_Xml)))) to ret
Dim res As Long
' Check
If (Len(Trim(txt_FileToTimeStamp.Text)) = 0) Then
MsgBox "Any file selected to timestamp", vbCritical, "ExecSign"
Exit Sub
End If
' ========================================================= '
' Timestamp request
res = dmtTimeStamp(g_hDmt, _
txt_UrlTimeStamp.Text, _
txt_FileToTimeStamp.Text, _
chk_SaveQuery.Value, _
chk_Detach.Value, _
chk_Xml.Value)
if (LabelFileForTimestamp.Text.Length == 0)
{
MessageBox.Show(this, "Any file selected to timestamp", "ExecTimestamp",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
int TimestampResult = CDIMATECLIBRARY.DMT_OK;
TimestampResult = CDIMATECLIBRARY.dmtTimeStamp(
CDIMATECLIBRARY.ghDimatecObj,
TextBoxUseFreeServer.Text,
LabelFileForTimestamp.Text,
CheckBoxSaveQuery.Checked,
CheckBoxSaveTsr.Checked,
CheckBoxSaveXmlResponse.Checked);