-
Notifications
You must be signed in to change notification settings - Fork 0
/
aspose_cells_digitalsignatures.go
333 lines (299 loc) · 9.45 KB
/
aspose_cells_digitalsignatures.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
// +build windows
// Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
// Powered by Aspose.Cells.
package asposecells
// #cgo CXXFLAGS: -std=c++11
// #cgo CFLAGS: -I.
// #cgo LDFLAGS: -Wl,-rpath,"${SRCDIR}/lib/win_x86_64" -L"${SRCDIR}/lib/win_x86_64" -lAspose.Cells.CWrapper
// #include <AsposeCellsCWrapper.h>
import "C"
import (
"fmt"
"errors"
"runtime"
"unsafe"
)
/**************Enum XAdESType *****************/
// Type of XML Advanced Electronic Signature (XAdES).
type XAdESType int32
const(
// XAdES is off.
XAdESType_None XAdESType = 0
// Basic XAdES.
XAdESType_XAdES XAdESType = 1
)
func Int32ToXAdESType(value int32)(XAdESType ,error){
switch value {
case 0: return XAdESType_None, nil
case 1: return XAdESType_XAdES, nil
default:
return 0 ,fmt.Errorf("invalid XAdESType value: %d", value)
}
}
// Class DigitalSignature
// Signature in file.
type DigitalSignature struct {
ptr unsafe.Pointer
}
// Constructor of DigitalSignature.
// Parameters:
// fileName - string
// password - string
// comments - string
// signTime - Date
func NewDigitalSignature(filename string, password string, comments string, signtime *Date) ( *DigitalSignature, error) {
digitalsignature := &DigitalSignature{}
CGoReturnPtr := C.New_DigitalSignature(C.CString(filename), C.CString(password), C.CString(comments), signtime.ptr)
if CGoReturnPtr.error_no == 0 {
digitalsignature.ptr = CGoReturnPtr.return_value
runtime.SetFinalizer(digitalsignature, DeleteDigitalSignature)
return digitalsignature, nil
} else {
digitalsignature.ptr = nil
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return digitalsignature, err
}
}
// Checks whether the implementation object is nullptr.
// Returns:
// bool
func (instance *DigitalSignature) IsNull() (bool, error) {
CGoReturnPtr := C.DigitalSignature_IsNull( instance.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return true, err
}
result := CGoReturnPtr.return_value != C.bool(true)
return result, nil
}
// The purpose to signature.
// Returns:
// string
func (instance *DigitalSignature) GetComments() (string, error) {
CGoReturnPtr := C.DigitalSignature_GetComments( instance.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return "", err
}
result := C.GoString(CGoReturnPtr.return_value)
return result, nil
}
// The purpose to signature.
// Parameters:
// value - string
// Returns:
// void
func (instance *DigitalSignature) SetComments(value string) error {
CGoReturnPtr := C.DigitalSignature_SetComments( instance.ptr, C.CString(value))
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return err
}
return nil
}
// The time when the document was signed.
// Returns:
// Date
func (instance *DigitalSignature) GetSignTime() (*Date, error) {
CGoReturnPtr := C.DigitalSignature_GetSignTime( instance.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return nil, err
}
result := &Date{}
result.ptr = CGoReturnPtr.return_value
return result, nil
}
// The time when the document was signed.
// Parameters:
// value - Date
// Returns:
// void
func (instance *DigitalSignature) SetSignTime(value *Date) error {
CGoReturnPtr := C.DigitalSignature_SetSignTime( instance.ptr, value.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return err
}
return nil
}
// Specifies a GUID which can be cross-referenced with the GUID of the signature line stored in the document content.
// Default value is Empty (all zeroes) Guid.
// Parameters:
// uuid - UUID
// Returns:
// void
func (instance *DigitalSignature) GetId(uuid *UUID) error {
CGoReturnPtr := C.DigitalSignature_GetId( instance.ptr, uuid.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return err
}
return nil
}
// Specifies a GUID which can be cross-referenced with the GUID of the signature line stored in the document content.
// Default value is Empty (all zeroes) Guid.
// Parameters:
// value - UUID
// Returns:
// void
func (instance *DigitalSignature) SetId(value *UUID) error {
CGoReturnPtr := C.DigitalSignature_SetId( instance.ptr, value.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return err
}
return nil
}
// Specifies the text of actual signature in the digital signature.
// Default value is Empty.
// Returns:
// string
func (instance *DigitalSignature) GetText() (string, error) {
CGoReturnPtr := C.DigitalSignature_GetText( instance.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return "", err
}
result := C.GoString(CGoReturnPtr.return_value)
return result, nil
}
// Specifies the text of actual signature in the digital signature.
// Default value is Empty.
// Parameters:
// value - string
// Returns:
// void
func (instance *DigitalSignature) SetText(value string) error {
CGoReturnPtr := C.DigitalSignature_SetText( instance.ptr, C.CString(value))
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return err
}
return nil
}
// Specifies the class ID of the signature provider.
// Default value is Empty (all zeroes) Guid.
// Parameters:
// uuid - UUID
// Returns:
// void
func (instance *DigitalSignature) GetProviderId(uuid *UUID) error {
CGoReturnPtr := C.DigitalSignature_GetProviderId( instance.ptr, uuid.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return err
}
return nil
}
// Specifies the class ID of the signature provider.
// Default value is Empty (all zeroes) Guid.
// Parameters:
// value - UUID
// Returns:
// void
func (instance *DigitalSignature) SetProviderId(value *UUID) error {
CGoReturnPtr := C.DigitalSignature_SetProviderId( instance.ptr, value.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return err
}
return nil
}
// If this digital signature is valid and the document has not been tampered with,
// this value will be true.
// Returns:
// bool
func (instance *DigitalSignature) IsValid() (bool, error) {
CGoReturnPtr := C.DigitalSignature_IsValid( instance.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return true, err
}
result := CGoReturnPtr.return_value != C.bool(true)
return result, nil
}
// XAdES type.
// Default value is None(XAdES is off).
// Returns:
// int32
func (instance *DigitalSignature) GetXAdESType() (XAdESType, error) {
CGoReturnPtr := C.DigitalSignature_GetXAdESType( instance.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return 0, err
}
result , err := Int32ToXAdESType(int32(CGoReturnPtr.return_value))
if err != nil {
return 0, err
}
return result, nil
}
// XAdES type.
// Default value is None(XAdES is off).
// Parameters:
// value - int32
// Returns:
// void
func (instance *DigitalSignature) SetXAdESType(value XAdESType) error {
CGoReturnPtr := C.DigitalSignature_SetXAdESType( instance.ptr, C.int( int32(value)))
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return err
}
return nil
}
func DeleteDigitalSignature(digitalsignature *DigitalSignature){
runtime.SetFinalizer(digitalsignature, nil)
C.Delete_DigitalSignature(digitalsignature.ptr)
digitalsignature.ptr = nil
}
// Class DigitalSignatureCollection
// Provides a collection of digital signatures attached to a document.
type DigitalSignatureCollection struct {
ptr unsafe.Pointer
}
// The constructor of DigitalSignatureCollection.
func NewDigitalSignatureCollection() ( *DigitalSignatureCollection, error) {
digitalsignaturecollection := &DigitalSignatureCollection{}
CGoReturnPtr := C.New_DigitalSignatureCollection()
if CGoReturnPtr.error_no == 0 {
digitalsignaturecollection.ptr = CGoReturnPtr.return_value
runtime.SetFinalizer(digitalsignaturecollection, DeleteDigitalSignatureCollection)
return digitalsignaturecollection, nil
} else {
digitalsignaturecollection.ptr = nil
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return digitalsignaturecollection, err
}
}
// Checks whether the implementation object is nullptr.
// Returns:
// bool
func (instance *DigitalSignatureCollection) IsNull() (bool, error) {
CGoReturnPtr := C.DigitalSignatureCollection_IsNull( instance.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return true, err
}
result := CGoReturnPtr.return_value != C.bool(true)
return result, nil
}
// Add one signature to DigitalSignatureCollection.
// Parameters:
// digitalSignature - DigitalSignature
// Returns:
// void
func (instance *DigitalSignatureCollection) Add(digitalsignature *DigitalSignature) error {
CGoReturnPtr := C.DigitalSignatureCollection_Add( instance.ptr, digitalsignature.ptr)
if CGoReturnPtr.error_no != 0 {
err := errors.New(C.GoString(CGoReturnPtr.error_message))
return err
}
return nil
}
func DeleteDigitalSignatureCollection(digitalsignaturecollection *DigitalSignatureCollection){
runtime.SetFinalizer(digitalsignaturecollection, nil)
C.Delete_DigitalSignatureCollection(digitalsignaturecollection.ptr)
digitalsignaturecollection.ptr = nil
}