35
35
36
36
#include < memory.h>
37
37
#include < iostream>
38
+ #include < memory>
38
39
#include < stdlib.h>
39
40
40
41
#include < xercesc/util/PlatformUtils.hpp>
69
70
#include < xsec/enc/XSECCryptoSymmetricKey.hpp>
70
71
#include < xsec/framework/XSECError.hpp>
71
72
#include < xsec/framework/XSECProvider.hpp>
73
+ #include < xsec/framework/XSECURIResolverXerces.hpp>
72
74
#include < xsec/xenc/XENCCipher.hpp>
73
75
#include < xsec/xenc/XENCEncryptedData.hpp>
74
76
#include < xsec/xenc/XENCEncryptedKey.hpp>
@@ -433,6 +435,7 @@ void outputDoc(DOMImplementation * impl, DOMDocument * doc) {
433
435
bool reValidateSig (DOMImplementation *impl, DOMDocument * inDoc, XSECCryptoKey *k) {
434
436
435
437
// Take a signature in DOM, serialise and re-validate
438
+ std::unique_ptr<XSECURIResolver> resolver (new XSECURIResolverXerces ());
436
439
437
440
try {
438
441
@@ -486,6 +489,7 @@ bool reValidateSig(DOMImplementation *impl, DOMDocument * inDoc, XSECCryptoKey *
486
489
*/
487
490
488
491
XSECProvider prov;
492
+ prov.setDefaultURIResolver (resolver.get ());
489
493
DSIGSignature * sig = prov.newSignatureFromDOM (doc);
490
494
sig->load ();
491
495
sig->setSigningKey (k);
@@ -525,7 +529,7 @@ void unitTestEnvelopingSignature(DOMImplementation * impl) {
525
529
// This tests an enveloping signature as the root node
526
530
527
531
cerr << " Creating enveloping signature ... " ;
528
-
532
+ std::unique_ptr<XSECURIResolver> resolver ( new XSECURIResolverXerces ());
529
533
try {
530
534
531
535
// Create a document
@@ -538,6 +542,7 @@ void unitTestEnvelopingSignature(DOMImplementation * impl) {
538
542
DSIGSignature *sig;
539
543
DOMElement *sigNode;
540
544
545
+ prov.setDefaultURIResolver (resolver.get ());
541
546
sig = prov.newSignature ();
542
547
sig->setDSIGNSPrefix (MAKE_UNICODE_STRING (" ds" ));
543
548
sig->setPrettyPrint (true );
@@ -634,7 +639,7 @@ void unitTestBase64NodeSignature(DOMImplementation * impl) {
634
639
// This tests a normal signature with a reference to a Base64 element
635
640
636
641
cerr << " Creating a base64 Element reference ... " ;
637
-
642
+ std::unique_ptr<XSECURIResolver> resolver ( new XSECURIResolverXerces ());
638
643
try {
639
644
640
645
// Create a document
@@ -647,6 +652,7 @@ void unitTestBase64NodeSignature(DOMImplementation * impl) {
647
652
DSIGSignature *sig;
648
653
DOMElement *sigNode;
649
654
655
+ prov.setDefaultURIResolver (resolver.get ());
650
656
sig = prov.newSignature ();
651
657
sig->setDSIGNSPrefix (MAKE_UNICODE_STRING (" ds" ));
652
658
sig->setPrettyPrint (true );
@@ -745,7 +751,7 @@ void unitTestLongSHA(DOMImplementation * impl) {
745
751
// This tests an enveloping signature as the root node, using SHA224/256/384/512
746
752
747
753
cerr << " Creating long SHA references using HMAC... " ;
748
-
754
+ std::unique_ptr<XSECURIResolver> resolver ( new XSECURIResolverXerces ());
749
755
try {
750
756
751
757
// Create a document
@@ -759,6 +765,7 @@ void unitTestLongSHA(DOMImplementation * impl) {
759
765
DOMElement *sigNode;
760
766
DSIGReference *ref[4 ];
761
767
768
+ prov.setDefaultURIResolver (resolver.get ());
762
769
sig = prov.newSignature ();
763
770
sig->setDSIGNSPrefix (MAKE_UNICODE_STRING (" ds" ));
764
771
sig->setPrettyPrint (true );
@@ -935,7 +942,7 @@ void unitTestLongSHA(DOMImplementation * impl) {
935
942
void unitTestSig (DOMImplementation * impl, XSECCryptoKey * k, const XMLCh * AlgURI) {
936
943
937
944
// Given a specific RSA/EC key and particular algorithm URI, sign and validate a document
938
-
945
+ std::unique_ptr<XSECURIResolver> resolver ( new XSECURIResolverXerces ());
939
946
try {
940
947
941
948
// Create a document
@@ -948,6 +955,7 @@ void unitTestSig(DOMImplementation * impl, XSECCryptoKey * k, const XMLCh * AlgU
948
955
DSIGSignature *sig;
949
956
DOMElement *sigNode;
950
957
958
+ prov.setDefaultURIResolver (resolver.get ());
951
959
sig = prov.newSignature ();
952
960
sig->setDSIGNSPrefix (MAKE_UNICODE_STRING (" ds" ));
953
961
sig->setPrettyPrint (true );
@@ -1143,12 +1151,14 @@ void testSignature(DOMImplementation *impl) {
1143
1151
DOMElement *sigNode;
1144
1152
int refCount;
1145
1153
1154
+ std::unique_ptr<XSECURIResolver> resolver (new XSECURIResolverXerces ());
1155
+
1146
1156
try {
1147
1157
1148
1158
/*
1149
1159
* Now we have a document, create a signature for it.
1150
1160
*/
1151
-
1161
+ prov. setDefaultURIResolver (resolver. get ());
1152
1162
sig = prov.newSignature ();
1153
1163
sig->setDSIGNSPrefix (MAKE_UNICODE_STRING (" ds" ));
1154
1164
sig->setPrettyPrint (true );
@@ -1608,15 +1618,15 @@ void unitTestElementContentEncrypt(DOMImplementation *impl, XSECCryptoKey * key,
1608
1618
// Create and execute cipher
1609
1619
1610
1620
XSECProvider prov;
1611
- XENCCipher * cipher;
1621
+ std::unique_ptr< XENCCipher> cipher;
1612
1622
1613
1623
try {
1614
1624
1615
1625
/*
1616
1626
* Now we have a document, find the data node.
1617
1627
*/
1618
1628
1619
- cipher = prov.newCipher (doc);
1629
+ cipher. reset ( prov.newCipher (doc) );
1620
1630
cipher->setXENCNSPrefix (MAKE_UNICODE_STRING (" xenc" ));
1621
1631
cipher->setPrettyPrint (true );
1622
1632
@@ -2394,40 +2404,40 @@ int main(int argc, char **argv) {
2394
2404
2395
2405
while (paramCount < argc) {
2396
2406
2397
- if (_stricmp (argv[paramCount], " --help" ) == 0 || _stricmp (argv[paramCount], " -h" ) == 0 ) {
2407
+ if (strcmp (argv[paramCount], " --help" ) == 0 || strcmp (argv[paramCount], " -h" ) == 0 ) {
2398
2408
printUsage ();
2399
2409
exit (0 );
2400
2410
}
2401
- else if (_stricmp (argv[paramCount], " --print-docs" ) == 0 || _stricmp (argv[paramCount], " -p" ) == 0 ) {
2411
+ else if (strcmp (argv[paramCount], " --print-docs" ) == 0 || strcmp (argv[paramCount], " -p" ) == 0 ) {
2402
2412
g_printDocs = true ;
2403
2413
paramCount++;
2404
2414
}
2405
2415
2406
- else if (_stricmp (argv[paramCount], " --signature-only" ) == 0 || _stricmp (argv[paramCount], " -s" ) == 0 ) {
2416
+ else if (strcmp (argv[paramCount], " --signature-only" ) == 0 || strcmp (argv[paramCount], " -s" ) == 0 ) {
2407
2417
doEncryptionTest = false ;
2408
2418
doEncryptionUnitTests = false ;
2409
2419
doSignatureUnitTests = false ;
2410
2420
paramCount++;
2411
2421
}
2412
- else if (_stricmp (argv[paramCount], " --encryption-only" ) == 0 || _stricmp (argv[paramCount], " -e" ) == 0 ) {
2422
+ else if (strcmp (argv[paramCount], " --encryption-only" ) == 0 || strcmp (argv[paramCount], " -e" ) == 0 ) {
2413
2423
doSignatureTest = false ;
2414
2424
doEncryptionUnitTests = false ;
2415
2425
doSignatureUnitTests = false ;
2416
2426
paramCount++;
2417
2427
}
2418
- else if (_stricmp (argv[paramCount], " --encryption-unit-only" ) == 0 || _stricmp (argv[paramCount], " -u" ) == 0 ) {
2428
+ else if (strcmp (argv[paramCount], " --encryption-unit-only" ) == 0 || strcmp (argv[paramCount], " -u" ) == 0 ) {
2419
2429
doEncryptionTest = false ;
2420
2430
doSignatureTest = false ;
2421
2431
doSignatureUnitTests = false ;
2422
2432
paramCount++;
2423
2433
}
2424
- else if (_stricmp (argv[paramCount], " --signature-unit-only" ) == 0 || _stricmp (argv[paramCount], " -t" ) == 0 ) {
2434
+ else if (strcmp (argv[paramCount], " --signature-unit-only" ) == 0 || strcmp (argv[paramCount], " -t" ) == 0 ) {
2425
2435
doEncryptionTest = false ;
2426
2436
doSignatureTest = false ;
2427
2437
doEncryptionUnitTests = false ;
2428
2438
paramCount++;
2429
2439
}
2430
- else if (_stricmp (argv[paramCount], " --no-gcm" ) == 0 ) {
2440
+ else if (strcmp (argv[paramCount], " --no-gcm" ) == 0 ) {
2431
2441
g_testGCM = false ;
2432
2442
paramCount++;
2433
2443
}
0 commit comments