forked from drechema/ensemble-smime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.smime.util.SMIME.xml
executable file
·81 lines (67 loc) · 3.21 KB
/
demo.smime.util.SMIME.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2015.2.1 (Build 705U)" ts="2016-01-25 12:19:06">
<Class name="demo.smime.util.SMIME">
<Super>%RegisteredObject</Super>
<TimeChanged>63902,52869.915174</TimeChanged>
<TimeCreated>63897,44107.85517</TimeCreated>
<Parameter name="opensslDir">
<Default>c:\InterSystems\HSAP\bin\</Default>
</Parameter>
<Property name="platform">
<Type>%String</Type>
</Property>
<Method name="sign">
<FormalSpec><![CDATA[certificatePath:%String,privateKeyPath:%String,inStream:%Stream.Object,&outStream:%Stream.Object]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
set outStream = ##class(%Stream.GlobalCharacter).%New()
set inFileName = $system.Util.CreateGUID()_".in"
set outFileName = $system.Util.CreateGUID()_".out"
set cmd=$SYSTEM.Util.BinaryDirectory()_"openssl smime -sign -nocerts"_
" -signer "_certificatePath_
" -inkey "_privateKeyPath_
" -in "_inFileName_
" -out "_outFileName
set inFileStream = ##class(%Stream.FileCharacter).%New()
set tSC = inFileStream.LinkToFile(inFileName) if $$$ISERR(tSC) quit tSC
set tSC = inFileStream.CopyFrom(inStream) if $$$ISERR(tSC) quit tSC
set tSC = inFileStream.%Save() if $$$ISERR(tSC) quit tSC
set ret = $zf(-1,cmd)
if ret'=0 quit $$$ERROR("Error executing command")
set outFileStream = ##class(%Stream.FileCharacter).%New()
set tSC = outFileStream.LinkToFile(outFileName) if $$$ISERR(tSC) quit tSC
set tSC = outStream.CopyFrom(outFileStream) if $$$ISERR(tSC) quit tSC
set tSC = outStream.%Save() if $$$ISERR(tSC) quit tSC
do ##class(%File).Delete(inFileName)
do ##class(%File).Delete(outFileName)
quit $$$OK
]]></Implementation>
</Method>
<Method name="verify">
<FormalSpec><![CDATA[certificatePath:%String,inStream:%Stream.Object,&outStream:%Stream.Object]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
set outStream = ##class(%Stream.GlobalCharacter).%New()
set inFileName = $system.Util.CreateGUID()_".in"
set outFileName = $system.Util.CreateGUID()_".out"
set cmd=$SYSTEM.Util.BinaryDirectory()_"openssl smime -verify -noverify -nointern"_
" -certfile "_certificatePath_
" -in "_inFileName_
" -out "_outFileName
set inFileStream = ##class(%Stream.FileCharacter).%New()
set tSC = inFileStream.LinkToFile(inFileName) if $$$ISERR(tSC) quit tSC
set tSC = inFileStream.CopyFrom(inStream) if $$$ISERR(tSC) quit tSC
set tSC = inFileStream.%Save() if $$$ISERR(tSC) quit tSC
set ret = $zf(-1,cmd)
if ret'=0 quit $$$ERROR("Error executing command")
set outFileStream = ##class(%Stream.FileCharacter).%New()
set tSC = outFileStream.LinkToFile(outFileName) if $$$ISERR(tSC) quit tSC
set tSC = outStream.CopyFrom(outFileStream) if $$$ISERR(tSC) quit tSC
set tSC = outStream.%Save() if $$$ISERR(tSC) quit tSC
do ##class(%File).Delete(inFileName,.return)
do ##class(%File).Delete(outFileName,.return)
quit $$$OK
]]></Implementation>
</Method>
</Class>
</Export>