Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
18606e23
Commit
18606e23
authored
May 02, 2017
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Content types correct
parent
ed6d070d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
DesktopEditor/xmlsec/test/windows_list_serts/main.cpp
DesktopEditor/xmlsec/test/windows_list_serts/main.cpp
+73
-0
No files found.
DesktopEditor/xmlsec/test/windows_list_serts/main.cpp
View file @
18606e23
...
@@ -1022,6 +1022,77 @@ Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-sign
...
@@ -1022,6 +1022,77 @@ Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-sign
return
rId
;
return
rId
;
}
}
void
CorrectContentTypes
(
int
nCountSigsNeeds
)
{
std
::
wstring
file
=
m_sFolder
+
L"/[Content_Types].xml"
;
XmlUtils
::
CXmlNode
oNode
;
oNode
.
FromXmlFile
(
file
);
XmlUtils
::
CXmlNodes
nodesDefaults
;
oNode
.
GetNodes
(
L"Default"
,
nodesDefaults
);
XmlUtils
::
CXmlNodes
nodesOverrides
;
oNode
.
GetNodes
(
L"Override"
,
nodesOverrides
);
std
::
string
sAddition
=
""
;
bool
bIsSigsExist
=
false
;
int
nCount
=
nodesDefaults
.
GetCount
();
for
(
int
i
=
0
;
i
<
nCount
;
++
i
)
{
XmlUtils
::
CXmlNode
node
;
nodesDefaults
.
GetAt
(
i
,
node
);
if
(
"sigs"
==
node
.
GetAttributeA
(
"Extension"
)
&&
"application/vnd.openxmlformats-package.digital-signature-origin"
==
node
.
GetAttributeA
(
"ContentType"
))
{
bIsSigsExist
=
true
;
break
;
}
}
if
(
!
bIsSigsExist
)
sAddition
+=
"<Default Extension=
\"
sigs
\"
ContentType=
\"
application/vnd.openxmlformats-package.digital-signature-origin
\"
/>"
;
int
nCountSigs
=
0
;
nCount
=
nodesOverrides
.
GetCount
();
for
(
int
i
=
0
;
i
<
nCount
;
++
i
)
{
XmlUtils
::
CXmlNode
node
;
nodesOverrides
.
GetAt
(
i
,
node
);
if
(
"application/vnd.openxmlformats-package.digital-signature-origin"
==
node
.
GetAttributeA
(
"ContentType"
))
{
++
nCountSigs
;
}
}
for
(
int
i
=
nCountSigs
;
i
<
nCountSigsNeeds
;
++
i
)
{
sAddition
+=
"<Override PartName=
\"
/_xmlsignatures/sig"
;
sAddition
+=
std
::
to_string
(
i
+
1
);
sAddition
+=
".xml
\"
ContentType=
\"
application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml
\"
/>"
;
}
std
::
string
sXmlA
;
NSFile
::
CFileBinary
::
ReadAllTextUtf8A
(
file
,
sXmlA
);
std
::
string
::
size_type
pos
=
sXmlA
.
rfind
(
"</Types>"
);
if
(
pos
==
std
::
string
::
npos
)
return
;
std
::
string
sRet
=
sXmlA
.
substr
(
0
,
pos
);
sRet
+=
sAddition
;
sRet
+=
"</Types>"
;
NSFile
::
CFileBinary
::
Remove
(
file
);
NSFile
::
CFileBinary
oFile
;
oFile
.
CreateFileW
(
file
);
oFile
.
WriteFile
((
BYTE
*
)
sRet
.
c_str
(),
(
DWORD
)
sRet
.
length
());
oFile
.
CloseFile
();
}
};
};
bool
SignDocument
(
std
::
wstring
sFolderOOXML
,
PCCERT_CONTEXT
pCertContext
,
std
::
wstring
sign_id
)
bool
SignDocument
(
std
::
wstring
sFolderOOXML
,
PCCERT_CONTEXT
pCertContext
,
std
::
wstring
sign_id
)
...
@@ -1212,6 +1283,8 @@ bool SignDocument(std::wstring sFolderOOXML, PCCERT_CONTEXT pCertContext, std::w
...
@@ -1212,6 +1283,8 @@ bool SignDocument(std::wstring sFolderOOXML, PCCERT_CONTEXT pCertContext, std::w
int
nSignNum
=
oOOXMLSigner
.
GetCountSigns
(
sDirectory
+
L"/_rels/origin.sigs.rels"
);
int
nSignNum
=
oOOXMLSigner
.
GetCountSigns
(
sDirectory
+
L"/_rels/origin.sigs.rels"
);
oOOXMLSigner
.
CorrectContentTypes
(
nSignNum
);
NSFile
::
CFileBinary
::
SaveToFile
(
sDirectory
+
L"/sig"
+
std
::
to_wstring
(
nSignNum
)
+
L".xml"
,
sXmlData
,
false
);
NSFile
::
CFileBinary
::
SaveToFile
(
sDirectory
+
L"/sig"
+
std
::
to_wstring
(
nSignNum
)
+
L".xml"
,
sXmlData
,
false
);
return
true
;
return
true
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment