Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
702fb2af
Kaydet (Commit)
702fb2af
authored
Mar 01, 2011
tarafından
Thomas Arnhold
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove TEST_IMPLEMENTATION_DIRECTLY
üst
a7ae138b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
196 deletions
+0
-196
signaturetest.cxx
xmlsecurity/workben/signaturetest.cxx
+0
-196
No files found.
xmlsecurity/workben/signaturetest.cxx
Dosyayı görüntüle @
702fb2af
...
@@ -83,9 +83,6 @@ void Main();
...
@@ -83,9 +83,6 @@ void Main();
#define LISTBOXHEIGHT 120
#define LISTBOXHEIGHT 120
// #define TEST_IMPLEMENTATION_DIRECTLY
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
SAL_IMPLEMENT_MAIN
()
SAL_IMPLEMENT_MAIN
()
...
@@ -209,11 +206,7 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
...
@@ -209,11 +206,7 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
maCryptoCheckBox
(
this
)
maCryptoCheckBox
(
this
)
{
{
#ifdef TEST_IMPLEMENTATION_DIRECTLY
Size
aOutputSize
(
400
,
600
);
#else
Size
aOutputSize
(
400
,
400
);
Size
aOutputSize
(
400
,
400
);
#endif
SetOutputSizePixel
(
aOutputSize
);
SetOutputSizePixel
(
aOutputSize
);
SetText
(
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"XML Signature Test"
)
)
);
SetText
(
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"XML Signature Test"
)
)
);
...
@@ -244,55 +237,6 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
...
@@ -244,55 +237,6 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
nY
+=
EDITHEIGHT
*
3
;
nY
+=
EDITHEIGHT
*
3
;
#ifdef TEST_IMPLEMENTATION_DIRECTLY
maTest1Line
.
SetPosSizePixel
(
TEXTFIELDSTARTX
,
nY
,
aOutputSize
.
Width
()
-
2
*
TEXTFIELDSTARTX
,
FIXEDLINEHEIGHT
);
maTest1Line
.
SetText
(
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Test simple files"
)
)
);
maTest1Line
.
Show
();
nY
+=
EDITHEIGHT
*
3
/
2
;
maFixedTextXMLFileName
.
SetPosSizePixel
(
TEXTFIELDSTARTX
,
nY
,
TEXTFIELDWIDTH
,
EDITHEIGHT
);
maFixedTextXMLFileName
.
SetText
(
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"XML File:"
)
)
);
maFixedTextXMLFileName
.
Show
();
maEditXMLFileName
.
SetPosSizePixel
(
TEXTFIELDSTARTX
+
TEXTFIELDWIDTH
,
nY
,
EDITWIDTH
,
EDITHEIGHT
);
maEditXMLFileName
.
Show
();
nY
+=
EDITHEIGHT
*
3
/
2
;
maFixedTextBINFileName
.
SetPosSizePixel
(
TEXTFIELDSTARTX
,
nY
,
TEXTFIELDWIDTH
,
EDITHEIGHT
);
maFixedTextBINFileName
.
SetText
(
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Binary File:"
)
)
);
maFixedTextBINFileName
.
Show
();
maEditBINFileName
.
SetPosSizePixel
(
TEXTFIELDSTARTX
+
TEXTFIELDWIDTH
,
nY
,
EDITWIDTH
,
EDITHEIGHT
);
maEditBINFileName
.
Show
();
nY
+=
EDITHEIGHT
*
3
/
2
;
maFixedTextSIGFileName
.
SetPosSizePixel
(
TEXTFIELDSTARTX
,
nY
,
TEXTFIELDWIDTH
,
EDITHEIGHT
);
maFixedTextSIGFileName
.
SetText
(
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Signature File:"
)
)
);
maFixedTextSIGFileName
.
Show
();
maEditSIGFileName
.
SetPosSizePixel
(
TEXTFIELDSTARTX
+
TEXTFIELDWIDTH
,
nY
,
EDITWIDTH
,
EDITHEIGHT
);
maEditSIGFileName
.
Show
();
nY
+=
EDITHEIGHT
*
2
;
maSignButton
.
SetPosSizePixel
(
TEXTFIELDSTARTX
,
nY
,
BUTTONWIDTH
,
BUTTONHEIGHT
);
maSignButton
.
SetText
(
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Sign"
)
)
);
maSignButton
.
SetClickHdl
(
LINK
(
this
,
MyWin
,
SignButtonHdl
)
);
maSignButton
.
Show
();
maVerifyButton
.
SetPosSizePixel
(
TEXTFIELDSTARTX
+
BUTTONWIDTH
+
BUTTONSPACE
,
nY
,
BUTTONWIDTH
,
BUTTONHEIGHT
);
maVerifyButton
.
SetText
(
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Verify"
)
)
);
maVerifyButton
.
SetClickHdl
(
LINK
(
this
,
MyWin
,
VerifyButtonHdl
)
);
maVerifyButton
.
Show
();
nY
+=
EDITHEIGHT
*
3
;
#endif // TEST_IMPLEMENTATION_DIRECTLY
maTest2Line
.
SetPosSizePixel
(
TEXTFIELDSTARTX
,
nY
,
aOutputSize
.
Width
()
-
2
*
TEXTFIELDSTARTX
,
FIXEDLINEHEIGHT
);
maTest2Line
.
SetPosSizePixel
(
TEXTFIELDSTARTX
,
nY
,
aOutputSize
.
Width
()
-
2
*
TEXTFIELDSTARTX
,
FIXEDLINEHEIGHT
);
maTest2Line
.
SetText
(
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Test Office Document"
)
)
);
maTest2Line
.
SetText
(
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Test Office Document"
)
)
);
maTest2Line
.
Show
();
maTest2Line
.
Show
();
...
@@ -411,144 +355,4 @@ IMPL_LINK( MyWin, VerifyDigitalSignaturesHdl, Button*, EMPTYARG )
...
@@ -411,144 +355,4 @@ IMPL_LINK( MyWin, VerifyDigitalSignaturesHdl, Button*, EMPTYARG )
return
0
;
return
0
;
}
}
#ifdef TEST_IMPLEMENTATION_DIRECTLY
IMPL_LINK
(
MyWin
,
DigitalSignaturesWithTokenHdl
,
Button
*
,
EMPTYARG
)
{
String
aDocFileName
=
maEditDOCFileName
.
GetText
();
String
aTokenFileName
=
maEditTokenName
.
GetText
();
DigitalSignaturesDialog
aSignaturesDialog
(
this
,
comphelper
::
getProcessServiceFactory
(),
SignatureModeDocumentContent
,
false
);
bool
bInit
=
aSignaturesDialog
.
Init
(
aTokenFileName
);
if
(
!
bInit
)
{
ErrorBox
(
this
,
WB_OK
,
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Error initializing security context!"
)
)
).
Execute
();
return
0
;
}
uno
::
Reference
<
embed
::
XStorage
>
xStore
=
::
comphelper
::
OStorageHelper
::
GetStorageFromURL
(
aDocFileName
,
embed
::
ElementModes
::
READWRITE
,
comphelper
::
getProcessServiceFactory
()
);
aSignaturesDialog
.
SetStorage
(
xStore
);
aSignaturesDialog
.
Execute
();
return
0
;
}
IMPL_LINK
(
MyWin
,
SignButtonHdl
,
Button
*
,
EMPTYARG
)
{
String
aXMLFileName
=
maEditXMLFileName
.
GetText
();
String
aBINFileName
=
maEditBINFileName
.
GetText
();
String
aSIGFileName
=
maEditSIGFileName
.
GetText
();
String
aTokenFileName
;
if
(
!
maCryptoCheckBox
.
IsChecked
()
)
aTokenFileName
=
maEditTokenName
.
GetText
();
XMLSignatureHelper
aSignatureHelper
(
comphelper
::
getProcessServiceFactory
()
);
bool
bInit
=
aSignatureHelper
.
Init
(
aTokenFileName
);
if
(
!
bInit
)
{
ErrorBox
(
this
,
WB_OK
,
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Error initializing security context!"
)
)
).
Execute
();
return
0
;
}
uno
::
Reference
<
::
com
::
sun
::
star
::
security
::
XCertificate
>
xCertToUse
;
CertificateChooser
aChooser
(
this
,
aSignatureHelper
.
GetSecurityEnvironment
(),
SignatureInformations
()
);
if
(
aChooser
.
Execute
()
)
xCertToUse
=
aChooser
.
GetSelectedCertificate
();
if
(
!
xCertToUse
.
is
()
)
return
0
;
aSignatureHelper
.
StartMission
();
sal_Int32
nSecurityId
=
aSignatureHelper
.
GetNewSecurityId
();
aSignatureHelper
.
SetX509Certificate
(
nSecurityId
,
xCertToUse
->
getIssuerName
(),
bigIntegerToNumericString
(
xCertToUse
->
getSerialNumber
()
)
);
aSignatureHelper
.
AddForSigning
(
nSecurityId
,
aXMLFileName
,
aXMLFileName
,
sal_False
);
aSignatureHelper
.
AddForSigning
(
nSecurityId
,
aBINFileName
,
aBINFileName
,
sal_True
);
SvFileStream
*
pStream
=
new
SvFileStream
(
aSIGFileName
,
STREAM_WRITE
);
SvLockBytesRef
xLockBytes
=
new
SvLockBytes
(
pStream
,
TRUE
);
uno
::
Reference
<
io
::
XOutputStream
>
xOutputStream
=
new
utl
::
OOutputStreamHelper
(
xLockBytes
);
bool
bDone
=
aSignatureHelper
.
CreateAndWriteSignature
(
xOutputStream
);
aSignatureHelper
.
EndMission
();
if
(
!
bDone
)
{
ErrorBox
(
this
,
WB_OK
,
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Error creating Signature!"
)
)
).
Execute
();
}
else
{
rtl
::
OUString
aInfo
(
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Signature successfully created!
\n\n
"
)
)
);
// aInfo += getSignatureInformationmations( aSignatureHelper.getAllSignatureInformation(), aSignatureHelper.GetSecurityEnvironment() );
InfoBox
(
this
,
aInfo
).
Execute
();
}
// Check for more detailed results...
return
0
;
}
IMPL_LINK
(
MyWin
,
VerifyButtonHdl
,
Button
*
,
EMPTYARG
)
{
String
aXMLFileName
=
maEditXMLFileName
.
GetText
();
String
aBINFileName
=
maEditBINFileName
.
GetText
();
String
aSIGFileName
=
maEditSIGFileName
.
GetText
();
String
aTokenFileName
;
if
(
!
maCryptoCheckBox
.
IsChecked
()
)
aTokenFileName
=
maEditTokenName
.
GetText
();
XMLSignatureHelper
aSignatureHelper
(
comphelper
::
getProcessServiceFactory
()
);
bool
bInit
=
aSignatureHelper
.
Init
(
aTokenFileName
);
if
(
!
bInit
)
{
ErrorBox
(
this
,
WB_OK
,
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Error initializing security context!"
)
)
).
Execute
();
return
0
;
}
aSignatureHelper
.
SetStartVerifySignatureHdl
(
LINK
(
this
,
MyWin
,
StartVerifySignatureHdl
)
);
aSignatureHelper
.
StartMission
();
SvFileStream
*
pStream
=
new
SvFileStream
(
aSIGFileName
,
STREAM_READ
);
pStream
->
Seek
(
STREAM_SEEK_TO_END
);
ULONG
nBytes
=
pStream
->
Tell
();
pStream
->
Seek
(
STREAM_SEEK_TO_BEGIN
);
SvLockBytesRef
xLockBytes
=
new
SvLockBytes
(
pStream
,
TRUE
);
uno
::
Reference
<
io
::
XInputStream
>
xInputStream
=
new
utl
::
OInputStreamHelper
(
xLockBytes
,
nBytes
);
bool
bDone
=
aSignatureHelper
.
ReadAndVerifySignature
(
xInputStream
);
xInputStream
->
closeInput
();
aSignatureHelper
.
EndMission
();
if
(
!
bDone
)
ErrorBox
(
this
,
WB_OK
,
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Error in Signature!"
)
)
).
Execute
();
else
InfoBox
(
this
,
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Signatures verified without any problems!"
)
)
).
Execute
();
return
0
;
}
IMPL_LINK
(
MyWin
,
StartVerifySignatureHdl
,
void
*
,
EMPTYARG
)
{
QueryBox
aQueryBox
(
this
,
WB_YES_NO
|
WB_DEF_YES
,
String
(
RTL_CONSTASCII_USTRINGPARAM
(
"Found Signature - Verify?"
)
)
);
return
(
aQueryBox
.
Execute
()
==
RET_YES
)
?
1
:
0
;
}
#endif // #ifdef TEST_IMPLEMENTATION_DIRECTLY
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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