From b5ba80fa5755d9f858ac84095227bf64f8333323 Mon Sep 17 00:00:00 2001 From: Jinkun Jang Date: Thu, 14 Mar 2013 15:21:42 +0900 Subject: [PATCH] sync --- bin/run_all.sh | 6 - build/ace/CMakeLists.txt | 30 - build/ace/dpl-ace-dao-ro.pc.in | 11 - build/ace/dpl-ace-dao-rw.pc.in | 11 - build/ace/dpl-ace.pc.in | 11 - build/core/dpl-efl.pc | 11 - build/db/dpl-db-efl.pc | 11 - build/dbus/dpl-dbus-efl.pc | 11 - build/event/dpl-event-efl.pc | 11 - build/log/dpl-log-efl.pc | 11 - build/popup/CMakeLists.txt | 68 - build/popup/dpl-popup-efl.pc | 11 - build/rpc/dpl-rpc-efl.pc | 11 - build/socket/dpl-socket-efl.pc | 11 - build/test/dpl-test-efl.pc | 11 - build/utils/dpl-utils-efl.pc | 11 - build/vcore/CMakeLists.txt | 21 - build/vcore/dpl-vcore.pc.in | 11 - debian/wrt-commons-test.install | 13 - etc/certificates/CMakeLists.txt | 30 - etc/certificates/tizen.root.preproduction.cert.pem | 60 - etc/certificates/wac.publisherid.pem | 24 - etc/certificates/wac.root.preproduction.pem | 22 - etc/certificates/wac.root.production.pem | 22 - etc/fingerprint_list.xml | 21 - etc/fingerprint_list.xsd | 21 - etc/schema.xsd | 415 --- etc/wrt_create_clean_db.sh | 31 - etc/wrt_reset_db.sh | 49 - examples/event_delivery_test/CMakeLists.txt | 34 - .../event_delivery_test/event_delivery_test.cpp | 202 -- modules/ace/CMakeLists.txt | 169 - modules/ace/DESCRIPTION | 2 - modules/ace/configuration/UnrestrictedPolicy.xml | 5 - modules/ace/configuration/WACPolicy.xml | 520 --- modules/ace/configuration/bondixml.xsd | 184 - modules/ace/configuration/config.dtd | 10 - modules/ace/configuration/config.xml | 10 - modules/ace/configuration/demo.xml | 15 - modules/ace/dao/AceDAO.cpp | 368 -- modules/ace/dao/AceDAOConversions.cpp | 54 - modules/ace/dao/AceDAOReadOnly.cpp | 338 -- modules/ace/dao/AceDAOUtilities.cpp | 189 - modules/ace/dao/AceDatabase.cpp | 25 - modules/ace/dao/BaseAttribute.cpp | 82 - modules/ace/dao/CMakeLists.txt | 110 - modules/ace/dao/PromptModel.cpp | 178 - modules/ace/dao/common_dao_types.cpp | 164 - modules/ace/engine/Attribute.cpp | 913 ----- modules/ace/engine/CombinerImpl.cpp | 445 --- modules/ace/engine/Condition.cpp | 265 -- modules/ace/engine/ConfigurationManager.cpp | 422 --- modules/ace/engine/NodeFactory.cpp | 49 - modules/ace/engine/Policy.cpp | 100 - modules/ace/engine/PolicyEnforcementPoint.cpp | 133 - modules/ace/engine/PolicyEvaluator.cpp | 447 --- modules/ace/engine/PolicyInformationPoint.cpp | 198 -- modules/ace/engine/Rule.cpp | 90 - modules/ace/engine/Serializer.cpp | 402 --- modules/ace/engine/SettingsLogic.cpp | 172 - modules/ace/engine/Subject.cpp | 84 - modules/ace/engine/TreeNode.cpp | 141 - modules/ace/engine/parser.cpp | 744 ---- .../ace/include/dpl/ace-dao-ro/AceDAOConversions.h | 39 - .../ace/include/dpl/ace-dao-ro/AceDAOReadOnly.h | 106 - .../ace/include/dpl/ace-dao-ro/AceDAOUtilities.h | 55 - modules/ace/include/dpl/ace-dao-ro/AceDatabase.h | 56 - modules/ace/include/dpl/ace-dao-ro/BaseAttribute.h | 149 - .../ace/include/dpl/ace-dao-ro/BasePermission.h | 53 - modules/ace/include/dpl/ace-dao-ro/IRequest.h | 38 - .../ace/include/dpl/ace-dao-ro/PreferenceTypes.h | 48 - modules/ace/include/dpl/ace-dao-ro/PromptModel.h | 93 - modules/ace/include/dpl/ace-dao-ro/TimedVerdict.h | 42 - modules/ace/include/dpl/ace-dao-ro/ValidityTypes.h | 40 - modules/ace/include/dpl/ace-dao-ro/VerdictTypes.h | 45 - .../ace/include/dpl/ace-dao-ro/common_dao_types.h | 487 --- modules/ace/include/dpl/ace-dao-ro/wrt_db_types.h | 38 - modules/ace/include/dpl/ace-dao-rw/AceDAO.h | 111 - .../dpl/ace/AbstractPolicyEnforcementPoint.h | 31 - .../dpl/ace/AbstractPolicyInformationPoint.h | 21 - modules/ace/include/dpl/ace/AbstractTreeElement.h | 46 - .../include/dpl/ace/AsyncVerdictResultListener.h | 33 - modules/ace/include/dpl/ace/Attribute.h | 220 -- modules/ace/include/dpl/ace/Combiner.h | 58 - modules/ace/include/dpl/ace/CombinerImpl.h | 86 - modules/ace/include/dpl/ace/Condition.h | 139 - modules/ace/include/dpl/ace/ConfigurationManager.h | 202 -- modules/ace/include/dpl/ace/Constants.h | 53 - modules/ace/include/dpl/ace/Effect.h | 44 - modules/ace/include/dpl/ace/NodeFactory.h | 39 - modules/ace/include/dpl/ace/PermissionTriple.h | 48 - modules/ace/include/dpl/ace/Policy.h | 91 - modules/ace/include/dpl/ace/PolicyEffect.h | 47 - .../ace/include/dpl/ace/PolicyEnforcementPoint.h | 95 - modules/ace/include/dpl/ace/PolicyEvaluator.h | 145 - .../ace/include/dpl/ace/PolicyEvaluatorFactory.h | 45 - .../ace/include/dpl/ace/PolicyInformationPoint.h | 105 - modules/ace/include/dpl/ace/PolicyResult.h | 250 -- modules/ace/include/dpl/ace/PolicySet.h | 52 - modules/ace/include/dpl/ace/Preference.h | 38 - modules/ace/include/dpl/ace/PromptDecision.h | 41 - modules/ace/include/dpl/ace/Request.h | 87 - modules/ace/include/dpl/ace/Rule.h | 85 - modules/ace/include/dpl/ace/Serializer.h | 129 - modules/ace/include/dpl/ace/SettingsLogic.h | 88 - modules/ace/include/dpl/ace/Subject.h | 77 - modules/ace/include/dpl/ace/TestTimer.h | 41 - modules/ace/include/dpl/ace/TreeNode.h | 135 - modules/ace/include/dpl/ace/UserDecision.h | 37 - modules/ace/include/dpl/ace/Verdict.h | 39 - modules/ace/include/dpl/ace/WRT_INTERFACE.h | 144 - modules/ace/include/dpl/ace/WidgetUsageModel.h | 97 - modules/ace/include/dpl/ace/acf_consts.h | 41 - modules/ace/include/dpl/ace/parser.h | 107 - modules/ace/orm/ace_db | 60 - modules/ace/orm/ace_db_definitions | 6 - modules/ace/orm/ace_db_sql_generator.h | 27 - modules/ace/orm/gen_db_md5.sh | 19 - modules/ace/orm/orm_generator_ace.h | 24 - modules/ace/orm/version_db | 5 - modules/core/include/dpl/file_input_mapping.h | 73 - modules/core/src/file_input_mapping.cpp | 110 - modules/core/src/named_input_pipe.cpp | 121 - modules/event/include/dpl/event/event_delivery.h | 338 -- .../include/dpl/event/event_delivery_detail.h | 306 -- .../include/dpl/event/event_delivery_injector.h | 81 - .../include/dpl/event/event_delivery_messages.h | 923 ----- modules/event/include/dpl/event/nested_loop.h | 111 - modules/event/src/event_delivery.cpp | 50 - modules/event/src/event_delivery_detail.cpp | 568 --- modules/event/src/nested_loop.cpp | 120 - modules/popup/DESCRIPTION | 2 - modules/popup/config.cmake | 42 - modules/popup/include/dpl/popup/evas_object.h | 661 ---- modules/popup/include/dpl/popup/popup.h | 74 - modules/popup/include/dpl/popup/popup_controller.h | 217 -- modules/popup/include/dpl/popup/popup_manager.h | 114 - modules/popup/include/dpl/popup/popup_object.h | 175 - modules/popup/include/dpl/popup/popup_renderer.h | 129 - modules/popup/src/evas_object.cpp | 240 -- modules/popup/src/popup_controller.cpp | 112 - modules/popup/src/popup_manager.cpp | 59 - modules/popup/src/popup_renderer.cpp | 414 --- modules/utils/include/file_utils.h | 54 - modules/utils/include/folder_size.h | 39 - modules/utils/include/mime_type_utils.h | 57 - modules/utils/include/warp_iri.h | 71 - modules/utils/include/widget_version.h | 118 - modules/utils/include/wrt_global_settings.h | 31 - .../utils/include/wrt_global_settings_internal.h | 35 - modules/utils/include/wrt_utility.h | 170 - modules/utils/src/wrt_global_settings_internal.cpp | 44 - modules/vcore/CMakeLists.txt | 30 - modules/vcore/src/CMakeLists.txt | 132 - modules/vcore/src/orm/DESCRIPTION | 1 - modules/vcore/src/orm/gen_db_md5.sh | 5 - modules/vcore/src/orm/orm_generator_vcore.h | 24 - modules/vcore/src/orm/vcore_db | 20 - modules/vcore/src/orm/vcore_db_definitions | 6 - modules/vcore/src/orm/vcore_db_sql_generator.h | 21 - modules/vcore/src/orm/version_db | 5 - modules/vcore/src/vcore/Base64.cpp | 209 -- modules/vcore/src/vcore/Base64.h | 83 - modules/vcore/src/vcore/CRL.cpp | 500 --- modules/vcore/src/vcore/CRL.h | 195 -- modules/vcore/src/vcore/CachedCRL.cpp | 165 - modules/vcore/src/vcore/CachedCRL.h | 69 - modules/vcore/src/vcore/CachedOCSP.cpp | 192 - modules/vcore/src/vcore/CachedOCSP.h | 65 - modules/vcore/src/vcore/CertStoreType.h | 67 - modules/vcore/src/vcore/Certificate.cpp | 493 --- modules/vcore/src/vcore/Certificate.h | 152 - modules/vcore/src/vcore/CertificateCacheDAO.cpp | 275 -- modules/vcore/src/vcore/CertificateCacheDAO.h | 107 - modules/vcore/src/vcore/CertificateCollection.cpp | 266 -- modules/vcore/src/vcore/CertificateCollection.h | 179 - .../vcore/src/vcore/CertificateConfigReader.cpp | 138 - modules/vcore/src/vcore/CertificateConfigReader.h | 71 - modules/vcore/src/vcore/CertificateIdentifier.h | 73 - modules/vcore/src/vcore/CertificateLoader.cpp | 725 ---- modules/vcore/src/vcore/CertificateLoader.h | 110 - modules/vcore/src/vcore/CertificateStorage.h | 26 - modules/vcore/src/vcore/CertificateVerifier.cpp | 132 - modules/vcore/src/vcore/CertificateVerifier.h | 85 - modules/vcore/src/vcore/Config.cpp | 20 - modules/vcore/src/vcore/Config.h | 92 - modules/vcore/src/vcore/Database.cpp | 43 - modules/vcore/src/vcore/Database.h | 66 - modules/vcore/src/vcore/DeveloperModeValidator.cpp | 97 - modules/vcore/src/vcore/DeveloperModeValidator.h | 58 - modules/vcore/src/vcore/IAbstractResponseCache.h | 47 - modules/vcore/src/vcore/OCSP.cpp | 538 --- modules/vcore/src/vcore/OCSP.h | 242 -- modules/vcore/src/vcore/OCSPCertMgrUtil.cpp | 180 - modules/vcore/src/vcore/OCSPCertMgrUtil.h | 43 - modules/vcore/src/vcore/OCSPUtil.c | 92 - modules/vcore/src/vcore/ParserSchema.h | 199 -- modules/vcore/src/vcore/ReferenceValidator.cpp | 119 - modules/vcore/src/vcore/ReferenceValidator.h | 60 - modules/vcore/src/vcore/RevocationCheckerBase.cpp | 68 - modules/vcore/src/vcore/RevocationCheckerBase.h | 44 - modules/vcore/src/vcore/SSLContainers.h | 183 - modules/vcore/src/vcore/SaxReader.cpp | 308 -- modules/vcore/src/vcore/SaxReader.h | 151 - modules/vcore/src/vcore/SignatureData.h | 186 - modules/vcore/src/vcore/SignatureFinder.cpp | 87 - modules/vcore/src/vcore/SignatureFinder.h | 85 - modules/vcore/src/vcore/SignatureReader.cpp | 582 ---- modules/vcore/src/vcore/SignatureReader.h | 122 - modules/vcore/src/vcore/SignatureValidator.cpp | 265 -- modules/vcore/src/vcore/SignatureValidator.h | 73 - modules/vcore/src/vcore/SoupMessageSendAsync.cpp | 15 - modules/vcore/src/vcore/SoupMessageSendAsync.h | 172 - modules/vcore/src/vcore/SoupMessageSendBase.cpp | 108 - modules/vcore/src/vcore/SoupMessageSendBase.h | 117 - modules/vcore/src/vcore/SoupMessageSendSync.cpp | 94 - modules/vcore/src/vcore/SoupMessageSendSync.h | 42 - modules/vcore/src/vcore/VCore.cpp | 71 - modules/vcore/src/vcore/VCore.h | 58 - modules/vcore/src/vcore/VCorePrivate.h | 35 - modules/vcore/src/vcore/ValidatorCommon.h | 102 - modules/vcore/src/vcore/ValidatorFactories.cpp | 49 - modules/vcore/src/vcore/ValidatorFactories.h | 36 - modules/vcore/src/vcore/VerificationStatus.cpp | 51 - modules/vcore/src/vcore/VerificationStatus.h | 111 - modules/vcore/src/vcore/WacOrigin.cpp | 151 - modules/vcore/src/vcore/WacOrigin.h | 56 - modules/vcore/src/vcore/XmlsecAdapter.cpp | 397 --- modules/vcore/src/vcore/XmlsecAdapter.h | 135 - modules/vcore/src/vcore/scoped_gpointer.h | 76 - modules/widget_dao/dao/bind_to_dao.h | 73 - modules/widget_dao/dao/global_config.cpp | 39 - packaging/dpl.spec | 79 - tests/ace/AttributeSetter.cpp | 19 - tests/ace/AttributeSetter.h | 125 - tests/ace/CMakeLists.txt | 75 - tests/ace/Interfaces.cpp | 75 - tests/ace/Interfaces.h | 70 - tests/ace/PEPSingleton.cpp | 26 - tests/ace/PEPSingleton.h | 31 - tests/ace/TestSuite01.cpp | 986 ------ tests/ace/TestSuite02.cpp | 913 ----- tests/ace/TestSuite03.cpp | 533 --- tests/ace/TestSuite04.cpp | 627 ---- tests/ace/TestSuite05.cpp | 620 ---- tests/ace/TestSuite06.cpp | 1610 --------- tests/ace/TestSuite07.cpp | 287 -- tests/ace/ace_tests.cpp | 75 - tests/ace/loop_control.cpp | 75 - tests/ace/loop_control.h | 42 - tests/ace/test-configuration/CMTest/CMakeLists.txt | 26 - .../CMTest/active/CMakeLists.txt | 21 - .../test-configuration/CMTest/active/bondixml.dtd | 199 -- .../CMTest/active/pms_general-test.xml | 2510 ------------- tests/ace/test-configuration/CMTest/pms_config.xml | 10 - .../test-configuration/CMTest/pms_general-test.xml | 2510 ------------- .../ace/test-configuration/CMTest/policyTest1.xml | 2510 ------------- .../ace/test-configuration/CMTest/policyTest2.xml | 2510 ------------- .../ace/test-configuration/CMTest/policyTest3.xml | 2510 ------------- tests/ace/test-configuration/CMakeLists.txt | 40 - .../ace/test-configuration/attr_policy-example.xml | 50 - .../test-configuration/attr_policy-example1.xml | 97 - .../test-configuration/attr_policy-example2.xml | 55 - .../test-configuration/attr_policy-example3.xml | 128 - .../test-configuration/attr_policy-example4.xml | 102 - .../test-configuration/attr_policy-example5.xml | 43 - .../test-configuration/attr_policy-example6.xml | 41 - .../test-configuration/attr_policy-example7.xml | 54 - .../test-configuration/attr_policy-example8.xml | 55 - tests/ace/test-configuration/attre_config.xml | 17 - tests/ace/test-configuration/general-test.xml | 2621 -------------- tests/ace/test-configuration/interceptpolicy.xml | 495 --- .../ace/test-configuration/old_policy-example.xml | 50 - tests/ace/test-configuration/policy-example.xml | 95 - tests/ace/test-configuration/policy-example2.xml | 50 - tests/ace/test-configuration/policy-example3.xml | 50 - .../test-configuration/policy-test-gsettings.xml | 41 - tests/ace/test-configuration/policy-test.xml | 41 - tests/ace/test-configuration/policy-wac-2.0.xml | 103 - tests/ace/test-configuration/policy_example.xml | 2407 ------------- .../test-configuration/reproduce-abort-test.xml | 26 - tests/ace/test-configuration/undefined-test.xml | 1075 ------ tests/core/CMakeLists.txt | 90 - tests/core/DESCRIPTION | 2 - tests/core/data/sample.zip | Bin 174 -> 0 bytes tests/core/main.cpp | 28 - tests/core/test_address.cpp | 50 - tests/core/test_binary_queue.cpp | 357 -- tests/core/test_fast_delegate.cpp | 248 -- tests/core/test_foreach.cpp | 118 - tests/core/test_log_unhandled_exception.cpp | 74 - tests/core/test_once.cpp | 103 - tests/core/test_scoped_array.cpp | 62 - tests/core/test_scoped_close.cpp | 27 - tests/core/test_scoped_fclose.cpp | 70 - tests/core/test_scoped_free.cpp | 53 - tests/core/test_scoped_ptr.cpp | 59 - tests/core/test_semaphore.cpp | 85 - tests/core/test_serialization.cpp | 259 -- tests/core/test_shared_ptr.cpp | 85 - tests/core/test_string.cpp | 384 -- tests/core/test_task.cpp | 93 - tests/core/test_thread.cpp | 100 - tests/core/test_type_list.cpp | 41 - tests/core/test_zip_input.cpp | 98 - tests/db/CMakeLists.txt | 76 - tests/db/main.cpp | 28 - tests/db/orm/CMakeLists.txt | 9 - tests/db/orm/dpl_orm_test.db | Bin 16384 -> 0 bytes tests/db/orm/dpl_orm_test_db | 38 - tests/db/orm/dpl_orm_test_db.sql | 38 - tests/db/orm/dpl_orm_test_db_definitions | 5 - tests/db/orm/dpl_orm_test_db_sql_generator.h | 27 - tests/db/orm/generator_dpl_orm_test.h | 24 - tests/db/test_orm.cpp | 712 ---- tests/db/test_sql_connection.cpp | 154 - tests/dbus/CMakeLists.txt | 98 - tests/dbus/data/org.tizen.DBusTestService.service | 3 - tests/dbus/dbus_test.cpp | 117 - tests/dbus/dbus_test.h | 90 - tests/dbus/loop_control.cpp | 75 - tests/dbus/loop_control.h | 42 - tests/dbus/main.cpp | 35 - tests/dbus/test_cases.cpp | 188 - tests/dbus/test_service.cpp | 93 - tests/event/CMakeLists.txt | 70 - tests/event/main.cpp | 28 - tests/event/test_controller.cpp | 331 -- tests/event/test_event_support.cpp | 122 - tests/event/test_ic_delegate.cpp | 568 --- tests/event/test_property.cpp | 111 - tests/localization/CMakeLists.txt | 76 - tests/localization/files/CMakeLists.txt | 19 - tests/localization/files/one | 0 tests/localization/files/two | 0 .../dpl/wrt-dao-ro/common_dao_types.h | 487 --- .../mockup_include/dpl/wrt-dao-rw/widget_dao.h | 230 -- tests/localization/mockup_src/widget_dao.cpp | 107 - tests/localization/test_localization.cpp | 28 - tests/localization/test_suite01.cpp | 103 - tests/vcore/CMakeLists.txt | 129 - tests/vcore/TestCRL.cpp | 94 - tests/vcore/TestCRL.h | 33 - tests/vcore/TestCases.cpp | 1325 ------- tests/vcore/TestEnv.cpp | 96 - tests/vcore/TestEnv.h | 23 - tests/vcore/certificate-generator/create_certs.sh | 94 - .../certificate-generator/demoCA.init/cacert.pem | 60 - .../certificate-generator/demoCA.init/careq.pem | 11 - .../certificate-generator/demoCA.init/index.txt | 1 - .../demoCA.init/index.txt.attr | 1 - .../demoCA.init/index.txt.old | 0 .../demoCA.init/newcerts/00.pem | 60 - .../demoCA.init/private/cakey.pem | 18 - .../vcore/certificate-generator/demoCA.init/serial | 1 - .../certificate-generator/demoCA.init/serial.old | 1 - .../dpl-tests-vcore-ocsp-server.sh | 19 - tests/vcore/certificate-generator/openssl.cnf | 327 -- tests/vcore/test-cases/keys/CAbundle.crt | 3677 -------------------- tests/vcore/test-cases/keys/README | 2 - tests/vcore/test-cases/keys/filip_rsa_cert.pem | 62 - tests/vcore/test-cases/keys/filip_rsa_key.pem | 18 - tests/vcore/test-cases/keys/magda_dsa_cert.pem | 90 - tests/vcore/test-cases/keys/magda_dsa_key.pem | 12 - .../test-cases/keys/ocsp_level0deprecated.crt | 31 - tests/vcore/test-cases/keys/ocsp_level1.crt | 29 - tests/vcore/test-cases/keys/ocsp_level2.crt | 29 - tests/vcore/test-cases/keys/ocsp_rootca.crt | 18 - tests/vcore/test-cases/keys/operator.root.cert.pem | 66 - .../vcore/test-cases/keys/operator.second.cert.pem | 64 - .../vcore/test-cases/keys/operator.second.key.pem | 18 - tests/vcore/test-cases/keys/operator.second.p12 | Bin 2043 -> 0 bytes tests/vcore/test-cases/keys/root_cacert.pem | 64 - tests/vcore/test-cases/keys/root_cakey.pem | 18 - tests/vcore/test-cases/widget/author-signature.xml | 66 - tests/vcore/test-cases/widget/config.xml | 6 - tests/vcore/test-cases/widget/index.html | 4 - tests/vcore/test-cases/widget/signature1.xml | 62 - tests/vcore/test-cases/widget/signature22.xml | 66 - tests/vcore/vcore_tests.cpp | 37 - 380 files changed, 69306 deletions(-) delete mode 100755 bin/run_all.sh delete mode 100644 build/ace/CMakeLists.txt delete mode 100644 build/ace/dpl-ace-dao-ro.pc.in delete mode 100644 build/ace/dpl-ace-dao-rw.pc.in delete mode 100644 build/ace/dpl-ace.pc.in delete mode 100644 build/core/dpl-efl.pc delete mode 100644 build/db/dpl-db-efl.pc delete mode 100644 build/dbus/dpl-dbus-efl.pc delete mode 100644 build/event/dpl-event-efl.pc delete mode 100644 build/log/dpl-log-efl.pc delete mode 100644 build/popup/CMakeLists.txt delete mode 100644 build/popup/dpl-popup-efl.pc delete mode 100644 build/rpc/dpl-rpc-efl.pc delete mode 100644 build/socket/dpl-socket-efl.pc delete mode 100644 build/test/dpl-test-efl.pc delete mode 100644 build/utils/dpl-utils-efl.pc delete mode 100644 build/vcore/CMakeLists.txt delete mode 100644 build/vcore/dpl-vcore.pc.in delete mode 100644 debian/wrt-commons-test.install delete mode 100644 etc/certificates/CMakeLists.txt delete mode 100644 etc/certificates/tizen.root.preproduction.cert.pem delete mode 100644 etc/certificates/wac.publisherid.pem delete mode 100644 etc/certificates/wac.root.preproduction.pem delete mode 100644 etc/certificates/wac.root.production.pem delete mode 100644 etc/fingerprint_list.xml delete mode 100644 etc/fingerprint_list.xsd delete mode 100644 etc/schema.xsd delete mode 100755 etc/wrt_create_clean_db.sh delete mode 100755 etc/wrt_reset_db.sh delete mode 100644 examples/event_delivery_test/CMakeLists.txt delete mode 100644 examples/event_delivery_test/event_delivery_test.cpp delete mode 100644 modules/ace/CMakeLists.txt delete mode 100644 modules/ace/DESCRIPTION delete mode 100644 modules/ace/configuration/UnrestrictedPolicy.xml delete mode 100644 modules/ace/configuration/WACPolicy.xml delete mode 100644 modules/ace/configuration/bondixml.xsd delete mode 100644 modules/ace/configuration/config.dtd delete mode 100644 modules/ace/configuration/config.xml delete mode 100644 modules/ace/configuration/demo.xml delete mode 100644 modules/ace/dao/AceDAO.cpp delete mode 100644 modules/ace/dao/AceDAOConversions.cpp delete mode 100644 modules/ace/dao/AceDAOReadOnly.cpp delete mode 100644 modules/ace/dao/AceDAOUtilities.cpp delete mode 100644 modules/ace/dao/AceDatabase.cpp delete mode 100644 modules/ace/dao/BaseAttribute.cpp delete mode 100644 modules/ace/dao/CMakeLists.txt delete mode 100644 modules/ace/dao/PromptModel.cpp delete mode 100644 modules/ace/dao/common_dao_types.cpp delete mode 100644 modules/ace/engine/Attribute.cpp delete mode 100644 modules/ace/engine/CombinerImpl.cpp delete mode 100644 modules/ace/engine/Condition.cpp delete mode 100644 modules/ace/engine/ConfigurationManager.cpp delete mode 100644 modules/ace/engine/NodeFactory.cpp delete mode 100644 modules/ace/engine/Policy.cpp delete mode 100644 modules/ace/engine/PolicyEnforcementPoint.cpp delete mode 100644 modules/ace/engine/PolicyEvaluator.cpp delete mode 100644 modules/ace/engine/PolicyInformationPoint.cpp delete mode 100644 modules/ace/engine/Rule.cpp delete mode 100644 modules/ace/engine/Serializer.cpp delete mode 100644 modules/ace/engine/SettingsLogic.cpp delete mode 100644 modules/ace/engine/Subject.cpp delete mode 100644 modules/ace/engine/TreeNode.cpp delete mode 100644 modules/ace/engine/parser.cpp delete mode 100644 modules/ace/include/dpl/ace-dao-ro/AceDAOConversions.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/AceDAOReadOnly.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/AceDAOUtilities.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/AceDatabase.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/BaseAttribute.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/BasePermission.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/IRequest.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/PreferenceTypes.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/PromptModel.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/TimedVerdict.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/ValidityTypes.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/VerdictTypes.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/common_dao_types.h delete mode 100644 modules/ace/include/dpl/ace-dao-ro/wrt_db_types.h delete mode 100644 modules/ace/include/dpl/ace-dao-rw/AceDAO.h delete mode 100644 modules/ace/include/dpl/ace/AbstractPolicyEnforcementPoint.h delete mode 100644 modules/ace/include/dpl/ace/AbstractPolicyInformationPoint.h delete mode 100644 modules/ace/include/dpl/ace/AbstractTreeElement.h delete mode 100644 modules/ace/include/dpl/ace/AsyncVerdictResultListener.h delete mode 100644 modules/ace/include/dpl/ace/Attribute.h delete mode 100644 modules/ace/include/dpl/ace/Combiner.h delete mode 100644 modules/ace/include/dpl/ace/CombinerImpl.h delete mode 100644 modules/ace/include/dpl/ace/Condition.h delete mode 100644 modules/ace/include/dpl/ace/ConfigurationManager.h delete mode 100644 modules/ace/include/dpl/ace/Constants.h delete mode 100644 modules/ace/include/dpl/ace/Effect.h delete mode 100644 modules/ace/include/dpl/ace/NodeFactory.h delete mode 100644 modules/ace/include/dpl/ace/PermissionTriple.h delete mode 100644 modules/ace/include/dpl/ace/Policy.h delete mode 100644 modules/ace/include/dpl/ace/PolicyEffect.h delete mode 100644 modules/ace/include/dpl/ace/PolicyEnforcementPoint.h delete mode 100644 modules/ace/include/dpl/ace/PolicyEvaluator.h delete mode 100644 modules/ace/include/dpl/ace/PolicyEvaluatorFactory.h delete mode 100644 modules/ace/include/dpl/ace/PolicyInformationPoint.h delete mode 100644 modules/ace/include/dpl/ace/PolicyResult.h delete mode 100644 modules/ace/include/dpl/ace/PolicySet.h delete mode 100644 modules/ace/include/dpl/ace/Preference.h delete mode 100644 modules/ace/include/dpl/ace/PromptDecision.h delete mode 100644 modules/ace/include/dpl/ace/Request.h delete mode 100644 modules/ace/include/dpl/ace/Rule.h delete mode 100644 modules/ace/include/dpl/ace/Serializer.h delete mode 100644 modules/ace/include/dpl/ace/SettingsLogic.h delete mode 100644 modules/ace/include/dpl/ace/Subject.h delete mode 100644 modules/ace/include/dpl/ace/TestTimer.h delete mode 100644 modules/ace/include/dpl/ace/TreeNode.h delete mode 100644 modules/ace/include/dpl/ace/UserDecision.h delete mode 100644 modules/ace/include/dpl/ace/Verdict.h delete mode 100644 modules/ace/include/dpl/ace/WRT_INTERFACE.h delete mode 100644 modules/ace/include/dpl/ace/WidgetUsageModel.h delete mode 100644 modules/ace/include/dpl/ace/acf_consts.h delete mode 100644 modules/ace/include/dpl/ace/parser.h delete mode 100644 modules/ace/orm/ace_db delete mode 100644 modules/ace/orm/ace_db_definitions delete mode 100644 modules/ace/orm/ace_db_sql_generator.h delete mode 100755 modules/ace/orm/gen_db_md5.sh delete mode 100644 modules/ace/orm/orm_generator_ace.h delete mode 100644 modules/ace/orm/version_db delete mode 100644 modules/core/include/dpl/file_input_mapping.h delete mode 100644 modules/core/src/file_input_mapping.cpp delete mode 100644 modules/core/src/named_input_pipe.cpp delete mode 100644 modules/event/include/dpl/event/event_delivery.h delete mode 100644 modules/event/include/dpl/event/event_delivery_detail.h delete mode 100644 modules/event/include/dpl/event/event_delivery_injector.h delete mode 100644 modules/event/include/dpl/event/event_delivery_messages.h delete mode 100644 modules/event/include/dpl/event/nested_loop.h delete mode 100644 modules/event/src/event_delivery.cpp delete mode 100644 modules/event/src/event_delivery_detail.cpp delete mode 100644 modules/event/src/nested_loop.cpp delete mode 100644 modules/popup/DESCRIPTION delete mode 100644 modules/popup/config.cmake delete mode 100644 modules/popup/include/dpl/popup/evas_object.h delete mode 100644 modules/popup/include/dpl/popup/popup.h delete mode 100644 modules/popup/include/dpl/popup/popup_controller.h delete mode 100644 modules/popup/include/dpl/popup/popup_manager.h delete mode 100644 modules/popup/include/dpl/popup/popup_object.h delete mode 100644 modules/popup/include/dpl/popup/popup_renderer.h delete mode 100644 modules/popup/src/evas_object.cpp delete mode 100644 modules/popup/src/popup_controller.cpp delete mode 100644 modules/popup/src/popup_manager.cpp delete mode 100644 modules/popup/src/popup_renderer.cpp delete mode 100644 modules/utils/include/file_utils.h delete mode 100644 modules/utils/include/folder_size.h delete mode 100644 modules/utils/include/mime_type_utils.h delete mode 100644 modules/utils/include/warp_iri.h delete mode 100644 modules/utils/include/widget_version.h delete mode 100644 modules/utils/include/wrt_global_settings.h delete mode 100644 modules/utils/include/wrt_global_settings_internal.h delete mode 100644 modules/utils/include/wrt_utility.h delete mode 100644 modules/utils/src/wrt_global_settings_internal.cpp delete mode 100644 modules/vcore/CMakeLists.txt delete mode 100644 modules/vcore/src/CMakeLists.txt delete mode 100644 modules/vcore/src/orm/DESCRIPTION delete mode 100755 modules/vcore/src/orm/gen_db_md5.sh delete mode 100644 modules/vcore/src/orm/orm_generator_vcore.h delete mode 100644 modules/vcore/src/orm/vcore_db delete mode 100644 modules/vcore/src/orm/vcore_db_definitions delete mode 100644 modules/vcore/src/orm/vcore_db_sql_generator.h delete mode 100644 modules/vcore/src/orm/version_db delete mode 100644 modules/vcore/src/vcore/Base64.cpp delete mode 100644 modules/vcore/src/vcore/Base64.h delete mode 100644 modules/vcore/src/vcore/CRL.cpp delete mode 100644 modules/vcore/src/vcore/CRL.h delete mode 100644 modules/vcore/src/vcore/CachedCRL.cpp delete mode 100644 modules/vcore/src/vcore/CachedCRL.h delete mode 100644 modules/vcore/src/vcore/CachedOCSP.cpp delete mode 100644 modules/vcore/src/vcore/CachedOCSP.h delete mode 100644 modules/vcore/src/vcore/CertStoreType.h delete mode 100644 modules/vcore/src/vcore/Certificate.cpp delete mode 100644 modules/vcore/src/vcore/Certificate.h delete mode 100644 modules/vcore/src/vcore/CertificateCacheDAO.cpp delete mode 100644 modules/vcore/src/vcore/CertificateCacheDAO.h delete mode 100644 modules/vcore/src/vcore/CertificateCollection.cpp delete mode 100644 modules/vcore/src/vcore/CertificateCollection.h delete mode 100644 modules/vcore/src/vcore/CertificateConfigReader.cpp delete mode 100644 modules/vcore/src/vcore/CertificateConfigReader.h delete mode 100644 modules/vcore/src/vcore/CertificateIdentifier.h delete mode 100644 modules/vcore/src/vcore/CertificateLoader.cpp delete mode 100644 modules/vcore/src/vcore/CertificateLoader.h delete mode 100644 modules/vcore/src/vcore/CertificateStorage.h delete mode 100644 modules/vcore/src/vcore/CertificateVerifier.cpp delete mode 100644 modules/vcore/src/vcore/CertificateVerifier.h delete mode 100644 modules/vcore/src/vcore/Config.cpp delete mode 100644 modules/vcore/src/vcore/Config.h delete mode 100644 modules/vcore/src/vcore/Database.cpp delete mode 100644 modules/vcore/src/vcore/Database.h delete mode 100644 modules/vcore/src/vcore/DeveloperModeValidator.cpp delete mode 100644 modules/vcore/src/vcore/DeveloperModeValidator.h delete mode 100644 modules/vcore/src/vcore/IAbstractResponseCache.h delete mode 100644 modules/vcore/src/vcore/OCSP.cpp delete mode 100644 modules/vcore/src/vcore/OCSP.h delete mode 100644 modules/vcore/src/vcore/OCSPCertMgrUtil.cpp delete mode 100644 modules/vcore/src/vcore/OCSPCertMgrUtil.h delete mode 100644 modules/vcore/src/vcore/OCSPUtil.c delete mode 100644 modules/vcore/src/vcore/ParserSchema.h delete mode 100644 modules/vcore/src/vcore/ReferenceValidator.cpp delete mode 100644 modules/vcore/src/vcore/ReferenceValidator.h delete mode 100644 modules/vcore/src/vcore/RevocationCheckerBase.cpp delete mode 100644 modules/vcore/src/vcore/RevocationCheckerBase.h delete mode 100644 modules/vcore/src/vcore/SSLContainers.h delete mode 100644 modules/vcore/src/vcore/SaxReader.cpp delete mode 100644 modules/vcore/src/vcore/SaxReader.h delete mode 100644 modules/vcore/src/vcore/SignatureData.h delete mode 100644 modules/vcore/src/vcore/SignatureFinder.cpp delete mode 100644 modules/vcore/src/vcore/SignatureFinder.h delete mode 100644 modules/vcore/src/vcore/SignatureReader.cpp delete mode 100644 modules/vcore/src/vcore/SignatureReader.h delete mode 100644 modules/vcore/src/vcore/SignatureValidator.cpp delete mode 100644 modules/vcore/src/vcore/SignatureValidator.h delete mode 100644 modules/vcore/src/vcore/SoupMessageSendAsync.cpp delete mode 100644 modules/vcore/src/vcore/SoupMessageSendAsync.h delete mode 100644 modules/vcore/src/vcore/SoupMessageSendBase.cpp delete mode 100644 modules/vcore/src/vcore/SoupMessageSendBase.h delete mode 100644 modules/vcore/src/vcore/SoupMessageSendSync.cpp delete mode 100644 modules/vcore/src/vcore/SoupMessageSendSync.h delete mode 100644 modules/vcore/src/vcore/VCore.cpp delete mode 100644 modules/vcore/src/vcore/VCore.h delete mode 100644 modules/vcore/src/vcore/VCorePrivate.h delete mode 100644 modules/vcore/src/vcore/ValidatorCommon.h delete mode 100644 modules/vcore/src/vcore/ValidatorFactories.cpp delete mode 100644 modules/vcore/src/vcore/ValidatorFactories.h delete mode 100644 modules/vcore/src/vcore/VerificationStatus.cpp delete mode 100644 modules/vcore/src/vcore/VerificationStatus.h delete mode 100644 modules/vcore/src/vcore/WacOrigin.cpp delete mode 100644 modules/vcore/src/vcore/WacOrigin.h delete mode 100644 modules/vcore/src/vcore/XmlsecAdapter.cpp delete mode 100644 modules/vcore/src/vcore/XmlsecAdapter.h delete mode 100644 modules/vcore/src/vcore/scoped_gpointer.h delete mode 100644 modules/widget_dao/dao/bind_to_dao.h delete mode 100644 modules/widget_dao/dao/global_config.cpp delete mode 100644 packaging/dpl.spec delete mode 100644 tests/ace/AttributeSetter.cpp delete mode 100644 tests/ace/AttributeSetter.h delete mode 100644 tests/ace/CMakeLists.txt delete mode 100644 tests/ace/Interfaces.cpp delete mode 100644 tests/ace/Interfaces.h delete mode 100644 tests/ace/PEPSingleton.cpp delete mode 100644 tests/ace/PEPSingleton.h delete mode 100644 tests/ace/TestSuite01.cpp delete mode 100644 tests/ace/TestSuite02.cpp delete mode 100644 tests/ace/TestSuite03.cpp delete mode 100644 tests/ace/TestSuite04.cpp delete mode 100644 tests/ace/TestSuite05.cpp delete mode 100644 tests/ace/TestSuite06.cpp delete mode 100644 tests/ace/TestSuite07.cpp delete mode 100644 tests/ace/ace_tests.cpp delete mode 100644 tests/ace/loop_control.cpp delete mode 100644 tests/ace/loop_control.h delete mode 100644 tests/ace/test-configuration/CMTest/CMakeLists.txt delete mode 100644 tests/ace/test-configuration/CMTest/active/CMakeLists.txt delete mode 100644 tests/ace/test-configuration/CMTest/active/bondixml.dtd delete mode 100644 tests/ace/test-configuration/CMTest/active/pms_general-test.xml delete mode 100644 tests/ace/test-configuration/CMTest/pms_config.xml delete mode 100644 tests/ace/test-configuration/CMTest/pms_general-test.xml delete mode 100644 tests/ace/test-configuration/CMTest/policyTest1.xml delete mode 100644 tests/ace/test-configuration/CMTest/policyTest2.xml delete mode 100644 tests/ace/test-configuration/CMTest/policyTest3.xml delete mode 100644 tests/ace/test-configuration/CMakeLists.txt delete mode 100644 tests/ace/test-configuration/attr_policy-example.xml delete mode 100644 tests/ace/test-configuration/attr_policy-example1.xml delete mode 100644 tests/ace/test-configuration/attr_policy-example2.xml delete mode 100644 tests/ace/test-configuration/attr_policy-example3.xml delete mode 100644 tests/ace/test-configuration/attr_policy-example4.xml delete mode 100644 tests/ace/test-configuration/attr_policy-example5.xml delete mode 100644 tests/ace/test-configuration/attr_policy-example6.xml delete mode 100644 tests/ace/test-configuration/attr_policy-example7.xml delete mode 100644 tests/ace/test-configuration/attr_policy-example8.xml delete mode 100644 tests/ace/test-configuration/attre_config.xml delete mode 100644 tests/ace/test-configuration/general-test.xml delete mode 100644 tests/ace/test-configuration/interceptpolicy.xml delete mode 100644 tests/ace/test-configuration/old_policy-example.xml delete mode 100644 tests/ace/test-configuration/policy-example.xml delete mode 100644 tests/ace/test-configuration/policy-example2.xml delete mode 100644 tests/ace/test-configuration/policy-example3.xml delete mode 100644 tests/ace/test-configuration/policy-test-gsettings.xml delete mode 100644 tests/ace/test-configuration/policy-test.xml delete mode 100644 tests/ace/test-configuration/policy-wac-2.0.xml delete mode 100644 tests/ace/test-configuration/policy_example.xml delete mode 100644 tests/ace/test-configuration/reproduce-abort-test.xml delete mode 100644 tests/ace/test-configuration/undefined-test.xml delete mode 100644 tests/core/CMakeLists.txt delete mode 100644 tests/core/DESCRIPTION delete mode 100644 tests/core/data/sample.zip delete mode 100644 tests/core/main.cpp delete mode 100644 tests/core/test_address.cpp delete mode 100644 tests/core/test_binary_queue.cpp delete mode 100644 tests/core/test_fast_delegate.cpp delete mode 100644 tests/core/test_foreach.cpp delete mode 100644 tests/core/test_log_unhandled_exception.cpp delete mode 100644 tests/core/test_once.cpp delete mode 100644 tests/core/test_scoped_array.cpp delete mode 100644 tests/core/test_scoped_close.cpp delete mode 100644 tests/core/test_scoped_fclose.cpp delete mode 100644 tests/core/test_scoped_free.cpp delete mode 100644 tests/core/test_scoped_ptr.cpp delete mode 100644 tests/core/test_semaphore.cpp delete mode 100644 tests/core/test_serialization.cpp delete mode 100644 tests/core/test_shared_ptr.cpp delete mode 100644 tests/core/test_string.cpp delete mode 100644 tests/core/test_task.cpp delete mode 100644 tests/core/test_thread.cpp delete mode 100644 tests/core/test_type_list.cpp delete mode 100644 tests/core/test_zip_input.cpp delete mode 100644 tests/db/CMakeLists.txt delete mode 100644 tests/db/main.cpp delete mode 100644 tests/db/orm/CMakeLists.txt delete mode 100644 tests/db/orm/dpl_orm_test.db delete mode 100644 tests/db/orm/dpl_orm_test_db delete mode 100644 tests/db/orm/dpl_orm_test_db.sql delete mode 100644 tests/db/orm/dpl_orm_test_db_definitions delete mode 100644 tests/db/orm/dpl_orm_test_db_sql_generator.h delete mode 100644 tests/db/orm/generator_dpl_orm_test.h delete mode 100644 tests/db/test_orm.cpp delete mode 100644 tests/db/test_sql_connection.cpp delete mode 100644 tests/dbus/CMakeLists.txt delete mode 100644 tests/dbus/data/org.tizen.DBusTestService.service delete mode 100644 tests/dbus/dbus_test.cpp delete mode 100644 tests/dbus/dbus_test.h delete mode 100644 tests/dbus/loop_control.cpp delete mode 100644 tests/dbus/loop_control.h delete mode 100644 tests/dbus/main.cpp delete mode 100644 tests/dbus/test_cases.cpp delete mode 100644 tests/dbus/test_service.cpp delete mode 100644 tests/event/CMakeLists.txt delete mode 100644 tests/event/main.cpp delete mode 100644 tests/event/test_controller.cpp delete mode 100644 tests/event/test_event_support.cpp delete mode 100644 tests/event/test_ic_delegate.cpp delete mode 100644 tests/event/test_property.cpp delete mode 100644 tests/localization/CMakeLists.txt delete mode 100644 tests/localization/files/CMakeLists.txt delete mode 100644 tests/localization/files/one delete mode 100644 tests/localization/files/two delete mode 100644 tests/localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h delete mode 100644 tests/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h delete mode 100644 tests/localization/mockup_src/widget_dao.cpp delete mode 100644 tests/localization/test_localization.cpp delete mode 100644 tests/localization/test_suite01.cpp delete mode 100644 tests/vcore/CMakeLists.txt delete mode 100644 tests/vcore/TestCRL.cpp delete mode 100644 tests/vcore/TestCRL.h delete mode 100644 tests/vcore/TestCases.cpp delete mode 100644 tests/vcore/TestEnv.cpp delete mode 100644 tests/vcore/TestEnv.h delete mode 100755 tests/vcore/certificate-generator/create_certs.sh delete mode 100644 tests/vcore/certificate-generator/demoCA.init/cacert.pem delete mode 100644 tests/vcore/certificate-generator/demoCA.init/careq.pem delete mode 100644 tests/vcore/certificate-generator/demoCA.init/index.txt delete mode 100644 tests/vcore/certificate-generator/demoCA.init/index.txt.attr delete mode 100644 tests/vcore/certificate-generator/demoCA.init/index.txt.old delete mode 100644 tests/vcore/certificate-generator/demoCA.init/newcerts/00.pem delete mode 100644 tests/vcore/certificate-generator/demoCA.init/private/cakey.pem delete mode 100644 tests/vcore/certificate-generator/demoCA.init/serial delete mode 100644 tests/vcore/certificate-generator/demoCA.init/serial.old delete mode 100644 tests/vcore/certificate-generator/dpl-tests-vcore-ocsp-server.sh delete mode 100644 tests/vcore/certificate-generator/openssl.cnf delete mode 100644 tests/vcore/test-cases/keys/CAbundle.crt delete mode 100644 tests/vcore/test-cases/keys/README delete mode 100644 tests/vcore/test-cases/keys/filip_rsa_cert.pem delete mode 100644 tests/vcore/test-cases/keys/filip_rsa_key.pem delete mode 100644 tests/vcore/test-cases/keys/magda_dsa_cert.pem delete mode 100644 tests/vcore/test-cases/keys/magda_dsa_key.pem delete mode 100644 tests/vcore/test-cases/keys/ocsp_level0deprecated.crt delete mode 100644 tests/vcore/test-cases/keys/ocsp_level1.crt delete mode 100644 tests/vcore/test-cases/keys/ocsp_level2.crt delete mode 100644 tests/vcore/test-cases/keys/ocsp_rootca.crt delete mode 100644 tests/vcore/test-cases/keys/operator.root.cert.pem delete mode 100644 tests/vcore/test-cases/keys/operator.second.cert.pem delete mode 100644 tests/vcore/test-cases/keys/operator.second.key.pem delete mode 100644 tests/vcore/test-cases/keys/operator.second.p12 delete mode 100644 tests/vcore/test-cases/keys/root_cacert.pem delete mode 100644 tests/vcore/test-cases/keys/root_cakey.pem delete mode 100644 tests/vcore/test-cases/widget/author-signature.xml delete mode 100755 tests/vcore/test-cases/widget/config.xml delete mode 100755 tests/vcore/test-cases/widget/index.html delete mode 100644 tests/vcore/test-cases/widget/signature1.xml delete mode 100644 tests/vcore/test-cases/widget/signature22.xml delete mode 100644 tests/vcore/vcore_tests.cpp diff --git a/bin/run_all.sh b/bin/run_all.sh deleted file mode 100755 index a245ea7..0000000 --- a/bin/run_all.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -./dpl-tests-core --output=text -./dpl-tests-dbus --output=text -./dpl-tests-db --output=text -./dpl-tests-event --output=text diff --git a/build/ace/CMakeLists.txt b/build/ace/CMakeLists.txt deleted file mode 100644 index f2ab0b8..0000000 --- a/build/ace/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) -# @brief -# - -CONFIGURE_FILE(dpl-ace-dao-ro.pc.in dpl-ace-dao-ro.pc @ONLY) -CONFIGURE_FILE(dpl-ace-dao-rw.pc.in dpl-ace-dao-rw.pc @ONLY) -CONFIGURE_FILE(dpl-ace.pc.in dpl-ace.pc @ONLY) -INSTALL(FILES - ${CMAKE_BINARY_DIR}/build/ace/dpl-ace-dao-ro.pc - ${CMAKE_BINARY_DIR}/build/ace/dpl-ace-dao-rw.pc - ${CMAKE_BINARY_DIR}/build/ace/dpl-ace.pc - DESTINATION - lib/pkgconfig - ) - diff --git a/build/ace/dpl-ace-dao-ro.pc.in b/build/ace/dpl-ace-dao-ro.pc.in deleted file mode 100644 index 6af8514..0000000 --- a/build/ace/dpl-ace-dao-ro.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include/dpl-efl - -Name: dpl-ace-dao-ro -Description: dpl-ace-dao-ro -Version: @VERSION@ -Requires: dpl-efl openssl -Libs: -ldpl-ace-dao-ro -L${libdir} -Cflags: -I${includedir} diff --git a/build/ace/dpl-ace-dao-rw.pc.in b/build/ace/dpl-ace-dao-rw.pc.in deleted file mode 100644 index fe6f99f..0000000 --- a/build/ace/dpl-ace-dao-rw.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include/dpl-elf - -Name: dpl-aco-dao-rw -Description: dpl-ace-dao-rw -Version: @VERSION@ -Requires: dpl-ace-dao-ro -Libs: -ldpl-ace-dao-rw -L${libdir} -Cflags: -I${includedir} diff --git a/build/ace/dpl-ace.pc.in b/build/ace/dpl-ace.pc.in deleted file mode 100644 index 45d1278..0000000 --- a/build/ace/dpl-ace.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include/dpl-efl - -Name: dpl-ace -Description: dpl-ace -Version: @VERSION@ -Requires: dpl-efl openssl -Libs: -ldpl-ace -L${libdir} -Cflags: -I${includedir} diff --git a/build/core/dpl-efl.pc b/build/core/dpl-efl.pc deleted file mode 100644 index 193fcd4..0000000 --- a/build/core/dpl-efl.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: dpl-efl -Description: DPL - EFL based -Version: 1.0.0 -Requires: ecore appcore-efl openssl dlog vconf -Libs: -L${libdir} -ldpl-efl -Cflags: -I${includedir}/dpl-efl diff --git a/build/db/dpl-db-efl.pc b/build/db/dpl-db-efl.pc deleted file mode 100644 index f0dc43e..0000000 --- a/build/db/dpl-db-efl.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: dpl-db-efl -Description: DPL DB - EFL based -Version: 1.0.0 -Requires: dpl-efl sqlite3 db-util -Libs: -L${libdir} -ldpl-db-efl -Cflags: -I${includedir}/dpl-efl diff --git a/build/dbus/dpl-dbus-efl.pc b/build/dbus/dpl-dbus-efl.pc deleted file mode 100644 index 6fafa42..0000000 --- a/build/dbus/dpl-dbus-efl.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: dpl-dbus-efl -Description: DPL DBus - EFL based -Version: 1.0.0 -Requires: dbus-1 dpl-efl dpl-event-efl -Libs: -L${libdir} -ldpl-dbus-efl -Cflags: -I${includedir}/dpl-efl diff --git a/build/event/dpl-event-efl.pc b/build/event/dpl-event-efl.pc deleted file mode 100644 index 1b9f911..0000000 --- a/build/event/dpl-event-efl.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: dpl-event-efl -Description: DPL Event - EFL based -Version: 1.0.0 -Requires: dpl-efl ecore appcore-efl vconf heynoti -Libs: -L${libdir} -ldpl-event-efl -Cflags: -I${includedir}/dpl-efl diff --git a/build/log/dpl-log-efl.pc b/build/log/dpl-log-efl.pc deleted file mode 100644 index ea4fff9..0000000 --- a/build/log/dpl-log-efl.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: dpl-log-efl -Description: DPL Log Engine - EFL based -Version: 1.0.0 -Requires: dpl-efl dlog -Libs: -L${libdir} -ldpl-log-efl -Cflags: -I${includedir}/dpl-efl diff --git a/build/popup/CMakeLists.txt b/build/popup/CMakeLists.txt deleted file mode 100644 index d55fa47..0000000 --- a/build/popup/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Pawel Sikorski (p.sikorski@samsung.com) -# @version 1.0 -# @brief -# - -# Check required modules -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(SYS_POPUP - elementary - REQUIRED) - -# Add core include directories -INCLUDE_DIRECTORIES( - ${DPL_LOG_INCLUDE_DIR} - ${DPL_CORE_INCLUDE_DIR} - ${DPL_POPUP_INCLUDE_DIR} - ${DPL_EVENT_INCLUDE_DIR} - ${SYS_EFL_INCLUDE_DIRS}) - -LINK_DIRECTORIES( - ${SYS_POPUP_LIBRARY_DIRS} -) - -# Base EFL based DPL library -SET(DPL_POPUP_LIBRARY "${PROJECT_NAME}-popup-efl") - -# Build shared library - -ADD_LIBRARY(${TARGET_DPL_POPUP} SHARED ${DPL_POPUP_SOURCES}) - -TARGET_LINK_LIBRARIES(${TARGET_DPL_POPUP} - ${SYS_POPUP_LIBRARIES} - ${TARGET_DPL_EFL} -) - -# Target library properties -SET_TARGET_PROPERTIES(${TARGET_DPL_POPUP} PROPERTIES - SOVERSION ${VERSION} - CLEAN_DIRECT_OUTPUT 1 - OUTPUT_NAME ${DPL_POPUP_LIBRARY}) - -# Install libraries -INSTALL(TARGETS ${TARGET_DPL_POPUP} - DESTINATION lib - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) - -# Install detail headers -INSTALL(FILES ${DPL_POPUP_HEADERS} - DESTINATION include/dpl-efl/dpl/popup) - -# Install pkgconfig script -INSTALL(FILES dpl-popup-efl.pc - DESTINATION lib/pkgconfig) diff --git a/build/popup/dpl-popup-efl.pc b/build/popup/dpl-popup-efl.pc deleted file mode 100644 index 92053b9..0000000 --- a/build/popup/dpl-popup-efl.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: dpl-popup-efl -Description: DPL Popup functionality - EFL based -Version: 1.0.0 -Requires: dpl-efl -Libs: -L${libdir} -ldpl-popup-efl -Cflags: -I${includedir}/dpl-efl diff --git a/build/rpc/dpl-rpc-efl.pc b/build/rpc/dpl-rpc-efl.pc deleted file mode 100644 index c5e870a..0000000 --- a/build/rpc/dpl-rpc-efl.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: dpl-rpc-efl -Description: DPL RPC - EFL based -Version: 1.0.0 -Requires: dpl-efl dpl-event-efl dpl-socket-efl -Libs: -L${libdir} -ldpl-rpc-efl -Cflags: -I${includedir}/dpl-efl diff --git a/build/socket/dpl-socket-efl.pc b/build/socket/dpl-socket-efl.pc deleted file mode 100644 index 6de04b0..0000000 --- a/build/socket/dpl-socket-efl.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: dpl-socket-efl -Description: DPL Socket - EFL based -Version: 1.0.0 -Requires: dpl-efl dpl-event-efl -Libs: -L${libdir} -ldpl-socket-efl -Cflags: -I${includedir}/dpl-efl diff --git a/build/test/dpl-test-efl.pc b/build/test/dpl-test-efl.pc deleted file mode 100644 index 94e9064..0000000 --- a/build/test/dpl-test-efl.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: dpl-test-efl -Description: DPL Test Engine - EFL based -Version: 1.0.0 -Requires: dpl-efl -Libs: -L${libdir} -ldpl-test-efl -Cflags: -I${includedir}/dpl-efl diff --git a/build/utils/dpl-utils-efl.pc b/build/utils/dpl-utils-efl.pc deleted file mode 100644 index ce770c1..0000000 --- a/build/utils/dpl-utils-efl.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: dpl-utils-efl -Description: DPL UTILS - EFL based -Version: 1.0.0 -Requires: dpl-efl -Libs: -L${libdir} -ldpl-utils-efl -Cflags: -I${includedir}/dpl-efl diff --git a/build/vcore/CMakeLists.txt b/build/vcore/CMakeLists.txt deleted file mode 100644 index 99200d2..0000000 --- a/build/vcore/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) -# @brief -# - -CONFIGURE_FILE(dpl-vcore.pc.in dpl-vcore.pc @ONLY) -INSTALL(FILES ${CMAKE_BINARY_DIR}/build/vcore/dpl-vcore.pc DESTINATION lib/pkgconfig) diff --git a/build/vcore/dpl-vcore.pc.in b/build/vcore/dpl-vcore.pc.in deleted file mode 100644 index 73fb442..0000000 --- a/build/vcore/dpl-vcore.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include/dpl-efl/dpl/vcore - -Name: dpl-vcore -Description: dpl-vcore -Version: @VERSION@ -Requires: libxml-2.0 openssl libsoup-2.4 -Libs: -ldpl-vcore -L${libdir} -Cflags: -I${includedir} diff --git a/debian/wrt-commons-test.install b/debian/wrt-commons-test.install deleted file mode 100644 index 5dec5e8..0000000 --- a/debian/wrt-commons-test.install +++ /dev/null @@ -1,13 +0,0 @@ -/usr/bin/dpl-test* -/usr/bin/dpl-dbus-test-service -/usr/etc/ace/policy* -/usr/etc/ace/attr* -/usr/etc/ace/general* -/usr/etc/ace/undefined* -/usr/etc/ace/CMTest/* -/opt/apps/widget/tests/vcore_widget_uncompressed/* -/opt/apps/widget/tests/vcore_keys/* -/opt/apps/widget/tests/vcore_certs/* -/opt/apps/wrt/wrt-commons/tests/* -/usr/share/dbus-1/services/org.tizen.DBusTestService.service -/opt/apps/widget/tests/localization/* diff --git a/etc/certificates/CMakeLists.txt b/etc/certificates/CMakeLists.txt deleted file mode 100644 index f7f1a94..0000000 --- a/etc/certificates/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) -# @author Yunchan Cho (yunchan.cho@samsung.com) -# @version 1.0 -# @brief -# - -SET(CERT_DIR ${PROJECT_SOURCE_DIR}/etc/certificates) - -INSTALL(FILES - ${CERT_DIR}/wac.root.preproduction.pem - ${CERT_DIR}/wac.root.production.pem - ${CERT_DIR}/wac.publisherid.pem - ${CERT_DIR}/tizen.root.preproduction.cert.pem - DESTINATION /opt/share/cert-svc/certs/code-signing/wac/ - ) diff --git a/etc/certificates/tizen.root.preproduction.cert.pem b/etc/certificates/tizen.root.preproduction.cert.pem deleted file mode 100644 index bbf523b..0000000 --- a/etc/certificates/tizen.root.preproduction.cert.pem +++ /dev/null @@ -1,60 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: - b3:cb:d1:5b:de:6e:66:95 - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=KR, ST=Suwon, O=Samsung Electronics, OU=SLP, CN=SLP WebApp Temporary CA/emailAddress=yunchan.cho@samsung.com - Validity - Not Before: Dec 8 10:27:32 2011 GMT - Not After : Nov 30 10:27:32 2021 GMT - Subject: C=KR, ST=Suwon, O=Samsung Electronics, OU=SLP, CN=SLP WebApp Temporary CA/emailAddress=yunchan.cho@samsung.com - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (1024 bit) - Modulus: - 00:cb:46:b8:94:81:b1:83:d7:29:05:2a:33:01:9e: - 66:15:f8:be:bb:95:17:dd:7a:c4:c2:f5:d9:e4:aa: - fd:c8:8d:a9:48:65:fc:3d:dc:47:d7:2a:2f:5e:c7: - 1f:22:ed:e0:98:e6:43:6d:74:82:ca:7d:22:9c:60: - 44:18:cd:ca:d6:6b:16:ca:ed:63:c9:7a:f1:00:df: - e4:6b:33:47:2f:78:75:61:d7:c9:29:3e:a9:ee:76: - dd:2e:fe:9d:e7:3c:0d:02:f4:e9:2d:46:74:49:52: - ef:a0:d6:9d:4d:08:65:ea:6b:35:72:a5:08:d8:46: - 46:03:99:7c:66:8c:60:c4:91 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - 47:A8:8F:CD:1F:22:BA:69:85:13:55:21:2D:C2:19:2D:5F:FF:DC:03 - X509v3 Authority Key Identifier: - keyid:47:A8:8F:CD:1F:22:BA:69:85:13:55:21:2D:C2:19:2D:5F:FF:DC:03 - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha1WithRSAEncryption - c2:c4:62:f2:ec:6f:2b:05:9c:09:cc:ae:e9:77:a9:1d:66:6b: - 03:7b:01:3a:e6:29:bb:2a:b8:15:d8:a1:7d:9b:05:b4:8c:cb: - ae:c7:eb:68:c0:e3:29:c7:e7:5a:ca:1a:0c:3a:ab:91:80:4f: - 9b:36:d4:45:b4:7b:2c:ef:f3:fd:cb:84:84:85:42:3d:ec:18: - 3f:5f:9e:b1:1f:8d:0a:57:89:51:e4:eb:7e:da:e9:79:82:61: - 38:ad:ca:94:43:71:00:73:13:b9:e9:ef:bc:68:c5:ff:5e:0a: - f6:b9:2a:3d:1d:21:77:22:d0:4e:e7:ad:da:31:0b:51:fa:44: - cd:fa ------BEGIN CERTIFICATE----- -MIIC9jCCAl+gAwIBAgIJALPL0VvebmaVMA0GCSqGSIb3DQEBBQUAMIGTMQswCQYD -VQQGEwJLUjEOMAwGA1UECAwFU3V3b24xHDAaBgNVBAoME1NhbXN1bmcgRWxlY3Ry -b25pY3MxDDAKBgNVBAsMA1NMUDEgMB4GA1UEAwwXU0xQIFdlYkFwcCBUZW1wb3Jh -cnkgQ0ExJjAkBgkqhkiG9w0BCQEWF3l1bmNoYW4uY2hvQHNhbXN1bmcuY29tMB4X -DTExMTIwODEwMjczMloXDTIxMTEzMDEwMjczMlowgZMxCzAJBgNVBAYTAktSMQ4w -DAYDVQQIDAVTdXdvbjEcMBoGA1UECgwTU2Ftc3VuZyBFbGVjdHJvbmljczEMMAoG -A1UECwwDU0xQMSAwHgYDVQQDDBdTTFAgV2ViQXBwIFRlbXBvcmFyeSBDQTEmMCQG -CSqGSIb3DQEJARYXeXVuY2hhbi5jaG9Ac2Ftc3VuZy5jb20wgZ8wDQYJKoZIhvcN -AQEBBQADgY0AMIGJAoGBAMtGuJSBsYPXKQUqMwGeZhX4vruVF916xML12eSq/ciN -qUhl/D3cR9cqL17HHyLt4JjmQ210gsp9IpxgRBjNytZrFsrtY8l68QDf5GszRy94 -dWHXySk+qe523S7+nec8DQL06S1GdElS76DWnU0IZeprNXKlCNhGRgOZfGaMYMSR -AgMBAAGjUDBOMB0GA1UdDgQWBBRHqI/NHyK6aYUTVSEtwhktX//cAzAfBgNVHSME -GDAWgBRHqI/NHyK6aYUTVSEtwhktX//cAzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3 -DQEBBQUAA4GBAMLEYvLsbysFnAnMrul3qR1mawN7ATrmKbsquBXYoX2bBbSMy67H -62jA4ynH51rKGgw6q5GAT5s21EW0eyzv8/3LhISFQj3sGD9fnrEfjQpXiVHk637a -6XmCYTitypRDcQBzE7np77xoxf9eCva5Kj0dIXci0E7nrdoxC1H6RM36 ------END CERTIFICATE----- diff --git a/etc/certificates/wac.publisherid.pem b/etc/certificates/wac.publisherid.pem deleted file mode 100644 index 758fe66..0000000 --- a/etc/certificates/wac.publisherid.pem +++ /dev/null @@ -1,24 +0,0 @@ ------BEGIN CERTIFICATE----- -MIID9DCCAtygAwIBAgIOZscBAQACO65mNg72468wDQYJKoZIhvcNAQEFBQAwgZQx -CzAJBgNVBAYTAkRFMRwwGgYDVQQKExNUQyBUcnVzdENlbnRlciBHbWJIMTEwLwYD -VQQLEyhQcmUtUHJvZHVjdGlvbiBUQyBUcnVzdENlbnRlciBDbGFzcyAyIENBMTQw -MgYDVQQDEytQcmUtUHJvZHVjdGlvbiBUQyBUcnVzdENlbnRlciBDbGFzcyAyIENB -IElJMB4XDTA2MDYwODE0MTYwMVoXDTI1MTIzMTIyNTk1OVowgZQxCzAJBgNVBAYT -AkRFMRwwGgYDVQQKExNUQyBUcnVzdENlbnRlciBHbWJIMTEwLwYDVQQLEyhQcmUt -UHJvZHVjdGlvbiBUQyBUcnVzdENlbnRlciBDbGFzcyAyIENBMTQwMgYDVQQDEytQ -cmUtUHJvZHVjdGlvbiBUQyBUcnVzdENlbnRlciBDbGFzcyAyIENBIElJMIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3Ewnr8E24AqXnf1Lu7w/g79Hht+W -lvWQg7cPC7685oj0htT0SmDy94uQaC3qRzBJktLKCyuniABykhdTr04rGWgzqD8n -EzcFCt5k0gF39l3ND/JL+S2YJK/f/xc884hjcLsHUU7cAd6mDlVkOszFK86DNbu0 -noz0y1y462RIOvPCjkYl/GJ5zL62bdDbgFqrWMPZ54JFG0Rj1v575ygfOd2LwOXe -xjzqfYI4JOx9frKWakPTehW+0UY5UdF0cMvHuLJie9H0vOobR4vtkenbS283b6j7 -0WCoU/BeAr4qskvMs9WwkwDquO4XnzYQDsEVgjBu4H2W0ihNUYJbRo8wtQIDAQAB -o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQU -DTX6+fYyziPR1HZxViaGOj66QOYwDQYJKoZIhvcNAQEFBQADggEBALZ0pfjOfePn -D/6QDCt+cjQ5+U4eKcOlJMXrpEAlnC6oAnN1hqbOQaj44aIAbNap36E/Hl9s0Uga -c4nz73o5uPvdDmbWzNnMz6ey5NU0XXNzHxQWFdb0+Z7Cho5txoZjjynYXmyQc3RJ -rrPI+6Uej6sEv15ZGirjABza6pNJ+2NLojLyUb+8et3OCLS+wJ4qrX/5uwgL50Lt -0M2iPdZv+gjZwNmNWYIflYrSXa3ujclH+EAkkk/G1JxPzhVI3cII3y2DUZQAPCcX -XQDXIX2zJo7bYaUYJhlEeiGX17cdXMXDT1tbXKKg2mRIga1K4lknn9U/vzkjMJXL -GA38dUZRZ2Y= ------END CERTIFICATE----- diff --git a/etc/certificates/wac.root.preproduction.pem b/etc/certificates/wac.root.preproduction.pem deleted file mode 100644 index 7c46a6a..0000000 --- a/etc/certificates/wac.root.preproduction.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDijCCAnKgAwIBAgIOMwoBAQAuBBKsIqIni7QwDQYJKoZIhvcNAQELBQAwYDEL -MAkGA1UEBhMCR0IxJTAjBgNVBAoMHFdBQyBBcHBsaWNhdGlvbiBTZXJ2aWNlcyBM -dGQxKjAoBgNVBAMMIVdBQyBBcHBsaWNhdGlvbiBTZXJ2aWNlcyBMdGQgVEVTVDAe -Fw0xMTAzMDMxNTA3MTlaFw0zNjAzMDMxNTA3MTlaMGAxCzAJBgNVBAYTAkdCMSUw -IwYDVQQKDBxXQUMgQXBwbGljYXRpb24gU2VydmljZXMgTHRkMSowKAYDVQQDDCFX -QUMgQXBwbGljYXRpb24gU2VydmljZXMgTHRkIFRFU1QwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQC1PB3UrpAQgLSVqHRPhHqdDJsjKQe/CT9oS4lA+mI/ -vkhAvam/EvcNrNHcLVvSph+Mj0d2Y2J9wkcNW7fS3qZJXtpMNU36r7XdBk9kiYhc -PwJbckCo9Pp8YFxkuR6xV6Cc4o54mO2mumxDQ1hbwCsc5CT7yQz0FVVhCE01X6JJ -D61DvqmAzCUpehmEXthNV/s/o8fL+I2mD75p8vNDyIZHSJX59czO3PriT3tH2h+0 -tQx7NEWG70fQEU2CzcH9UngPYU7xXqNOhT9GmI/yL3HTeYGNH3i5VHrBjxeTF11t -IWSUDWQX1W0Y7TbN06XcGcuqPgjZ9xMcV7S4OiCBJz5nAgMBAAGjQjBAMA8GA1Ud -EwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBQp5dzy2tJEArpT -qcQWNXG6J7y5WTANBgkqhkiG9w0BAQsFAAOCAQEAoXuyi8AjMx2yKVpss7xpVi5v -aUjcHU3AlptjNCFrXI6Bw+KJGNo8ydYlEASRd5dL/pJ6/V+UuUt9EngjUSdYOZGB -OgCeB2sJI8EZSay2LLhOCmkAxltC94Y/KRzkKqsYvNc6yvF85d+d4gbokf4APjmR -1TSlZLZsVhwfR0k0mer2rHQGE5Ljezdk7ZGeEMLdn6WFScwjo980EI0OqEoJU3on -+1TTBYudZ4o3qMgHiFwJafUJ6i3zuYbi9x86zMqeI4dJTbsTKLM0QV8vIdzI9fkV -t1tO/uBBAsNFUv8PAYwP4AFyGvyJbR4uxwxuQZKrltgjSTkPGYR14JtrGk7Y9g== ------END CERTIFICATE----- - diff --git a/etc/certificates/wac.root.production.pem b/etc/certificates/wac.root.production.pem deleted file mode 100644 index efccefd..0000000 --- a/etc/certificates/wac.root.production.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDgTCCAmmgAwIBAgIPAKTxAAEALtiV8/+rhB6+MA0GCSqGSIb3DQEBCwUAMFsx -CzAJBgNVBAYTAkdCMSUwIwYDVQQKDBxXQUMgQXBwbGljYXRpb24gU2VydmljZXMg -THRkMSUwIwYDVQQDDBxXQUMgQXBwbGljYXRpb24gU2VydmljZXMgTHRkMB4XDTEx -MDMxNDE0MDEwNFoXDTM2MDMxNDE0MDEwNFowWzELMAkGA1UEBhMCR0IxJTAjBgNV -BAoMHFdBQyBBcHBsaWNhdGlvbiBTZXJ2aWNlcyBMdGQxJTAjBgNVBAMMHFdBQyBB -cHBsaWNhdGlvbiBTZXJ2aWNlcyBMdGQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw -ggEKAoIBAQDCf6RHUPVBUY4YXYMdrmt5yO95eRCOG6vJtI9w0UM2w/2fihD5SMYa -3cCVam4j6F8FSspMIx+4CTCwdDSUixBGENwGEhD4qxqqV3KTObmxmYbELa97S1IP -qwoFelzUX6e+qHmYHi+eu/hONeiZaPBLtUtCd6ppCd5ACrD/kf/Ug/tfUtngozjG -sJ1UB10Ezi3fKs3OkkZMuecJvjWmDpRAyvIeeV8xfzeyn+DMpvhnI9RrSY0j4huE -ud6Lzzg0jV8+m54v0j7hv9klyNcGiZ+bmHr0LIyAtT+uktcms/4p3V9j01SI9Tmw -HcHKDXnM6kuThWpr6DR9KFSZ8zD2Nx5nAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMB -Af8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBT5bKdU2+CGE17R+o/rMCZHHMn+ -WzANBgkqhkiG9w0BAQsFAAOCAQEAXmO+J5suIGuzbfYBoTdr8gahFfWEbhm1y6mJ -eZAc+Mf5L+In20p+Oj5uy6LsTmJsE9VE/+gi1eALKl9EhgYhET2ZlAzRFCN5dTWv -NTAFxJfGMkn2U5iW+luJ+lejyYBqEEFRpzwhXZbVDZQLim4CU75H75KzFkUgTulG -5M6U/Plt6S1rKgMkeYiR27W4C2NZMFXYqctt0m+eKEa3ueZE9pYUxqVcvQKSI017 -Nbc1kSkcuSKFV2Bk2T5dh5jQvywykdWLubAe6XiiC5CIT31kcSX6AlVhgNxWRRKP -QFO7lWqxnQMR2Or38ve7oSg1oL5Sx80fcbp3ovaYSKt5jnVWfg== ------END CERTIFICATE----- - diff --git a/etc/fingerprint_list.xml b/etc/fingerprint_list.xml deleted file mode 100644 index 970c718..0000000 --- a/etc/fingerprint_list.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - AF:90:29:D2:B2:E1:6F:D6:7E:7E:EC:8E:BE:74:FA:4C:00:9C:49:FE - A6:00:BC:53:AC:37:5B:6A:03:C3:7A:8A:E0:1B:87:8B:82:94:9B:C2 - C2:C4:B5:72:9A:CF:D9:72:C5:DE:C1:E1:30:FF:74:7F:7A:AF:27:12 - - - AF:90:29:D2:B2:E1:6F:D6:7E:7E:EC:8E:BE:74:FA:4C:00:9C:49:FE - C2:C4:B5:72:9A:CF:D9:72:C5:DE:C1:E1:30:FF:74:7F:7A:AF:27:12 - A0:59:D3:37:E8:C8:2E:7F:38:84:7D:21:A9:9E:19:A9:8E:EC:EB:E1 - 8D:1F:CB:31:68:11:DA:22:59:26:58:13:6C:C6:72:C9:F0:DE:84:2A - - - 4A:9D:7A:4B:3B:29:D4:69:0A:70:B3:80:EC:A9:44:6B:03:7C:9A:38 - - - - - AD:A1:44:89:6A:35:6D:17:01:E9:6F:46:C6:00:7B:78:BE:2E:D9:4E - - diff --git a/etc/fingerprint_list.xsd b/etc/fingerprint_list.xsd deleted file mode 100644 index b0fab23..0000000 --- a/etc/fingerprint_list.xsd +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/etc/schema.xsd b/etc/schema.xsd deleted file mode 100644 index 8028f3e..0000000 --- a/etc/schema.xsd +++ /dev/null @@ -1,415 +0,0 @@ - - - - - - ]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/etc/wrt_create_clean_db.sh b/etc/wrt_create_clean_db.sh deleted file mode 100755 index db450a3..0000000 --- a/etc/wrt_create_clean_db.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -for name in wrt ace vcore -do - rm -f /opt/dbspace/.$name.db - rm -f /opt/dbspace/.$name.db-journal - SQL="PRAGMA journal_mode = PERSIST;" - sqlite3 /opt/dbspace/.$name.db "$SQL" - SQL=".read /usr/share/wrt-engine/"$name"_db.sql" - sqlite3 /opt/dbspace/.$name.db "$SQL" - touch /opt/dbspace/.$name.db-journal - chown root:6026 /opt/dbspace/.$name.db - chown root:6026 /opt/dbspace/.$name.db-journal - chmod 660 /opt/dbspace/.$name.db - chmod 660 /opt/dbspace/.$name.db-journal -done - - diff --git a/etc/wrt_reset_db.sh b/etc/wrt_reset_db.sh deleted file mode 100755 index 42afbe3..0000000 --- a/etc/wrt_reset_db.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -wrt_create_clean_db.sh - -rm -rf /opt/apps/widget/system/* - -# This directories contains test widgets and test keys. It shouldn't be removed. -#rm -rf /opt/apps/widget/user/* -#rm -rf /opt/apps/widget/data/* - -#Removing of widget desktop icons -WIDGET_EXEC_PATH=/opt/apps/widget/exec -WIDGET_DESKTOP_PATH=/opt/share/install-info/application -WIDGET_ICON_PATH=/opt/share/icons/default/small -WIDGET_EXECS="${WIDGET_EXEC_PATH}/*"; - -for file in $WIDGET_EXECS; do - widget_id=${file#${WIDGET_EXEC_PATH}/}; - - widget_desktop_file="${WIDGET_DESKTOP_PATH}/org.tizen.${widget_id}.desktop"; - if [ -f ${widget_desktop_file} ]; then - echo "rm -f $widget_desktop_file"; - rm -f $widget_desktop_file; - fi - - widget_icon_file="${WIDGET_ICON_PATH}/${widget_id}.*" - if [ -f ${widget_icon_file} ]; then - echo "rm -f $widget_icon_file"; - rm -f $widget_icon_file; - fi -done - -rm -rf /opt/apps/widget/exec/* -touch /opt/apps/widget/plugin-installation-required - diff --git a/examples/event_delivery_test/CMakeLists.txt b/examples/event_delivery_test/CMakeLists.txt deleted file mode 100644 index 1734a80..0000000 --- a/examples/event_delivery_test/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Jaroslaw Osmanski j.osmanski@samsung.com -# @version 1.0 -# @brief -# -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(DPL_GTK "dpl-gtk" "gthread-2.0" REQUIRED) - -SET(EVENT_DELIVERY_SOURCES - event_delivery_test.cpp) - -ADD_DEFINITIONS("-D_DEBUG -g") - -INCLUDE_DIRECTORIES(${DPL_GTK_INCLUDE_DIRS}) -LINK_DIRECTORIES(${DPL_GTK_LIBRARY_DIRS}) - -ADD_EXECUTABLE(event_delivery_test ${EVENT_DELIVERY_SOURCES}) -TARGET_LINK_LIBRARIES(event_delivery_test ${DPL_GTK_LIBRARIES}) - - diff --git a/examples/event_delivery_test/event_delivery_test.cpp b/examples/event_delivery_test/event_delivery_test.cpp deleted file mode 100644 index 5f0f104..0000000 --- a/examples/event_delivery_test/event_delivery_test.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file event_delivery_server.h - * @author Jaroslaw Osmanski j.osmanski@samsung.com - * @version 1.0 - * @brief This file is the implementation file of simple event delivery test - */ -#include -#include -#include -#include -#include -#include -#include - -namespace TestEvents -{ -EVENT_DELIVERY_DECLARE_EVENT_MESSAGE_0(EmptyMessage) -EVENT_DELIVERY_DECLARE_EVENT_MESSAGE_2(HelloWorldMessage, std::string, std::string) -EVENT_DELIVERY_DECLARE_EVENT_MESSAGE_2(NumberMessage, int, float) -EVENT_DELIVERY_DECLARE_EVENT_MESSAGE_4(TestMessage, int, int, int, int) - -EVENT_DELIVERY_IMPLEMENT_EVENT_MESSAGE(EmptyMessage) -EVENT_DELIVERY_IMPLEMENT_EVENT_MESSAGE(HelloWorldMessage) -EVENT_DELIVERY_IMPLEMENT_EVENT_MESSAGE(NumberMessage) -EVENT_DELIVERY_IMPLEMENT_EVENT_MESSAGE(TestMessage) -} // namespace TestEvents - -DECLARE_GENERIC_EVENT_0(StartEvent) -DECLARE_GENERIC_EVENT_0(CloseEvent) -DECLARE_GENERIC_EVENT_0(DeleteEvent) - -class MyListener : - public DPL::Application, - private DPL::Controller::Type>, - public DPL::EventListener, - public DPL::EventListener -{ -private: - class OneTimeListener : - public DPL::EventListener - { - public: - OneTimeListener() - { - DPL::EventDeliverySystem::AddListener (this); - } - - ~OneTimeListener() - { - LogError("Deleting OneTimeListener"); - DPL::EventDeliverySystem::RemoveListener (this); - } - - private: - void OnEventReceived(const TestEvents::EmptyMessage &message) - { - (void) message; - std::cout << "OneTimeListener empty message"; - - } - }; - - OneTimeListener * oneTimeListener; - - virtual void OnEventReceived(const CloseEvent &event) - { - (void) event; - Quit(); - } - - virtual void OnEventReceived(const DeleteEvent &event) - { - (void) event; - delete oneTimeListener; - oneTimeListener = NULL; - } - -protected: - - void OnEventReceived(const TestEvents::HelloWorldMessage &message) - { - std::cout << "Got HelloWorldMessage: " << message.GetArg0() << " : " << message.GetArg1() << std::endl; - - if (oneTimeListener != NULL) - { - DPL::ControllerEventHandler::PostTimedEvent(DeleteEvent(), 1); - } - } - - void OnEventReceived(const TestEvents::NumberMessage &message) - { - std::cout << "Got NumberMessage: " << message.GetArg0() << ", " << message.GetArg1() << std::endl; - } - -public: - - MyListener(int argc, char **argv) - : Application(argc, argv, "Listener") - { - Touch(); - - DPL::EventDeliverySystem::AddListener(this); - DPL::EventDeliverySystem::AddListener(this); - - DPL::ControllerEventHandler::PostTimedEvent(CloseEvent(), 8); - oneTimeListener = new OneTimeListener(); - } - - virtual ~MyListener() - { - DPL::EventDeliverySystem::RemoveListener (this); - DPL::EventDeliverySystem::RemoveListener (this); - delete oneTimeListener; - } -}; - -class MyPusher : - public DPL::Application, - private DPL::Controller::Type> -{ -private: - virtual void OnEventReceived(const CloseEvent &event) - { - (void) event; - Quit(); - } - - virtual void OnEventReceived(const StartEvent &event) - { - (void) event; - std::cout << "Publishing HelloWorldMessage..." << std::endl; - TestEvents::HelloWorldMessage hello("Hello cruel world !", "AAA BBB CCC"); - DPL::EventDeliverySystem::Publish(hello); - std::cout << "HelloWorldMessage published." << std::endl; - - std::cout << "Publishing NumberMessage message..." << std::endl; - TestEvents::NumberMessage number(13, 3.14f); - DPL::EventDeliverySystem::Publish(number); - std::cout << "NumberMessage published." << std::endl; - - std::cout << "Publishing EmptyMessage..." << std::endl; - TestEvents::EmptyMessage empty; - DPL::EventDeliverySystem::Publish(empty); - std::cout << "EmptyMessage published." << std::endl; - - } -public: - MyPusher(int argc, char **argv) - : Application(argc, argv, "Pusher") - { - Touch(); - - DPL::ControllerEventHandler::PostTimedEvent(StartEvent(), 2); - DPL::ControllerEventHandler::PostTimedEvent(StartEvent(), 6); - DPL::ControllerEventHandler::PostTimedEvent(CloseEvent(), 8); - } - - virtual ~MyPusher() - { - } -}; - -int main(int argc, char* argv[]) -{ - switch (fork()) - { - case 0: - { - MyPusher myPusher(argc, argv); - myPusher.Exec(); - } - break; - - case -1: - printf("fork() failed!"); - break; - - default: - { - MyListener myListener(argc, argv); - myListener.Exec(); - } - break; - } - - return 0; -} diff --git a/modules/ace/CMakeLists.txt b/modules/ace/CMakeLists.txt deleted file mode 100644 index 358ba76..0000000 --- a/modules/ace/CMakeLists.txt +++ /dev/null @@ -1,169 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Path for all tests binary files - -###################################################################### -#DB ace -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_BINARY_DIR}/modules/ace/database_checksum_ace.h - COMMAND ${CMAKE_SOURCE_DIR}/modules/ace/orm/gen_db_md5.sh - ARGS ${CMAKE_BINARY_DIR}/modules/ace/database_checksum_ace.h - ${CMAKE_SOURCE_DIR}/modules/ace/orm/ace_db - DEPENDS ${CMAKE_SOURCE_DIR}/modules/ace/orm/ace_db - ${CMAKE_SOURCE_DIR}/modules/ace/orm/gen_db_md5.sh - COMMENT "Generating ACE database checksum" - ) -ADD_CUSTOM_COMMAND( OUTPUT .ace.db - COMMAND rm -f ${CMAKE_CURRENT_BINARY_DIR}/.ace.db - COMMAND gcc -Wall -include ${CMAKE_BINARY_DIR}/modules/ace/database_checksum_ace.h -I${PROJECT_SOURCE_DIR}/modules/db/include -I${PROJECT_SOURCE_DIR}/modules/ace/orm -E ${PROJECT_SOURCE_DIR}/modules/ace/orm/ace_db_sql_generator.h | grep --invert-match "^#" > ${CMAKE_CURRENT_BINARY_DIR}/ace_db.sql - COMMAND sqlite3 ${CMAKE_CURRENT_BINARY_DIR}/.ace.db ".read ${CMAKE_CURRENT_BINARY_DIR}/ace_db.sql" || rm -f ${CMAKE_CURRENT_BINARY_DIR}/.ace.db - DEPENDS ${CMAKE_BINARY_DIR}/modules/ace/database_checksum_ace.h ${PROJECT_SOURCE_DIR}/modules/ace/orm/ace_db_sql_generator.h ${PROJECT_SOURCE_DIR}/modules/ace/orm/ace_db - ) - -ADD_CUSTOM_COMMAND( OUTPUT .ace.db-journal - COMMAND touch - ARGS ${CMAKE_CURRENT_BINARY_DIR}/.ace.db-journal - ) - -ADD_CUSTOM_TARGET(Sqlite3DbACE ALL DEPENDS .ace.db .ace.db-journal) - -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ace_db.sql - DESTINATION share/wrt-engine/ - ) - -########################################################### - -INCLUDE(FindPkgConfig) - -SET(ACE_TEST_PATH "/usr/apps/org.tizen.policy") - -INSTALL(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/configuration/config.xml - ${CMAKE_CURRENT_SOURCE_DIR}/configuration/config.dtd - ${CMAKE_CURRENT_SOURCE_DIR}/configuration/bondixml.xsd - ${CMAKE_CURRENT_SOURCE_DIR}/configuration/demo.xml - ${CMAKE_CURRENT_SOURCE_DIR}/configuration/WACPolicy.xml - ${CMAKE_CURRENT_SOURCE_DIR}/configuration/UnrestrictedPolicy.xml - DESTINATION /usr/etc/ace - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE) - -add_subdirectory(dao) - -SET(ACE_LIB_DEPS_BASIC - ecore - appcore-efl - openssl - sqlite3 - heynoti - dlog - vconf - db-util - libpcrecpp - icu-uc - libxml-2.0 - ) - -IF(SMACK_ENABLED) - LIST(APPEND ACE_LIB_DEPS_BASIC libprivilege-control) -ENDIF(SMACK_ENABLED) - -PKG_CHECK_MODULES(ACE_LIB_DEPS ${ACE_LIB_DEPS_BASIC} REQUIRED) - -SET(WRT_ACE_DIR ${PROJECT_SOURCE_DIR}/modules/ace) - -SET(ACE_SOURCES - ${WRT_ACE_DIR}/engine/PolicyEvaluator.cpp - ${WRT_ACE_DIR}/engine/PolicyInformationPoint.cpp - ${WRT_ACE_DIR}/engine/CombinerImpl.cpp - ${WRT_ACE_DIR}/engine/parser.cpp - ${WRT_ACE_DIR}/engine/PolicyEnforcementPoint.cpp - ${WRT_ACE_DIR}/engine/SettingsLogic.cpp - ${WRT_ACE_DIR}/engine/Attribute.cpp - ${WRT_ACE_DIR}/engine/Condition.cpp - ${WRT_ACE_DIR}/engine/NodeFactory.cpp - ${WRT_ACE_DIR}/engine/Policy.cpp - ${WRT_ACE_DIR}/engine/Rule.cpp - ${WRT_ACE_DIR}/engine/Serializer.cpp - ${WRT_ACE_DIR}/engine/Subject.cpp - ${WRT_ACE_DIR}/engine/TreeNode.cpp - ${WRT_ACE_DIR}/engine/ConfigurationManager.cpp -) - -INCLUDE_DIRECTORIES(${ACE_LIB_DEPS_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${WRT_ACE_DIR}/include) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/core/include) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/db/include) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/log/include) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/event/include) - -SET(WITH_ACE_SETTINGS_SERVER_SOURCES - ${WITH_ACE_SETTINGS_SERVER_NONE_SOURCES} - ) - -ADD_LIBRARY(${TARGET_ACE_LIB} SHARED - ${ACE_SOURCES} - ${WITH_ACE_SETTINGS_SERVER_SOURCES} -) - -SET_TARGET_PROPERTIES(${TARGET_ACE_LIB} PROPERTIES - SOVERSION ${VERSION}) - -SET_TARGET_PROPERTIES(${TARGET_ACE_LIB} PROPERTIES - COMPILE_FLAGS -fPIC) - -TARGET_LINK_LIBRARIES(${TARGET_ACE_LIB} -# ${TARGET_WRT_DAO_RW_LIB} #For now WRT has to be RW - Global dao write is needed - ${TARGET_ACE_DAO_RW_LIB} - ${ACE_LIB_DEPS_LIBRARIES} - ${DPL_EFL_LIBRARY} -) - -INSTALL(TARGETS ${TARGET_ACE_LIB} - DESTINATION lib - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE -) - -INSTALL(FILES - include/dpl/ace/AbstractPolicyEnforcementPoint.h - include/dpl/ace/AbstractTreeElement.h - include/dpl/ace/Attribute.h - include/dpl/ace/AsyncVerdictResultListener.h - include/dpl/ace/Combiner.h - include/dpl/ace/CombinerImpl.h - include/dpl/ace/ConfigurationManager.h - include/dpl/ace/Constants.h - include/dpl/ace/Effect.h - include/dpl/ace/PermissionTriple.h - include/dpl/ace/Policy.h - include/dpl/ace/PolicyEffect.h - include/dpl/ace/PolicyEnforcementPoint.h - include/dpl/ace/PolicyEvaluator.h - include/dpl/ace/PolicyEvaluatorFactory.h - include/dpl/ace/PolicyInformationPoint.h - include/dpl/ace/PolicyResult.h - include/dpl/ace/Preference.h - include/dpl/ace/PromptDecision.h - include/dpl/ace/Request.h - include/dpl/ace/SettingsLogic.h - include/dpl/ace/Subject.h - include/dpl/ace/TreeNode.h - include/dpl/ace/UserDecision.h - include/dpl/ace/WRT_INTERFACE.h - include/dpl/ace/Verdict.h - DESTINATION - include/dpl-efl/dpl/ace - ) - diff --git a/modules/ace/DESCRIPTION b/modules/ace/DESCRIPTION deleted file mode 100644 index aac5ef6..0000000 --- a/modules/ace/DESCRIPTION +++ /dev/null @@ -1,2 +0,0 @@ -!!!options!!! stop -ACE - Access Control Engine - security module for Device APIs diff --git a/modules/ace/configuration/UnrestrictedPolicy.xml b/modules/ace/configuration/UnrestrictedPolicy.xml deleted file mode 100644 index 558f2dc..0000000 --- a/modules/ace/configuration/UnrestrictedPolicy.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/ace/configuration/WACPolicy.xml b/modules/ace/configuration/WACPolicy.xml deleted file mode 100644 index f2c9236..0000000 --- a/modules/ace/configuration/WACPolicy.xml +++ /dev/null @@ -1,520 +0,0 @@ - - - - - - - - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - asdfkjlhxvczxnbcvnjahfjhsdfklahfdas - - - -

PValue

QValue Gvalue laj? -
- - - modulus - - - exponent - - -
- - Subject name - SKI - -
-
- - - - - - - - - Identified - - - - - - - - http://jil.org/jil/api/1.1/devicestateinfo.DeviceStateInfo.requestPositionInfo - - - - - - - http://jil.org/jil/api/1.1/widget.Widget.openURL - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.update - - - http://jil.org/jil/api/1.1/device.Device.launchApplication - - - http://jil.org/jil/api/1.1/multimedia.Camera.captureImage - - - http://jil.org/jil/api/1.1/messaging.Messaging.sendMessage - - - http://jil.org/jil/api/1.1.1/pim.PIM.findAddressBookItems - - - http://jil.org/jil/api/1.1.1/pim.PIM.getAddressBookItem - - - http://jil.org/jil/api/1.1.1/pim.PIM.getAddressBookItemsCount - - - - - - - - http://jil.org/jil/api/1.1/device.Device.getAvailableApplications - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.getAttributeValue - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.getAvailableAttributes - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.setAttributeValue - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.open - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.play - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.pause - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.resume - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.stop - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.onStateChange - - - http://jil.org/jil/api/1.1/multimedia.Camera.onCameraCaptured - - - http://jil.org/jil/api/1.1/multimedia.Camera.setWindow - - - http://jil.org/jil/api/1.1/device.Device.PositionInfo - - - http://jil.org/jil/api/1.1/device.Device.DeviceStateInfo - - - http://jil.org/jil/api/1.1/devicestateinfo.DeviceStateInfo.onPositionRetrieved - - - http://jil.org/jil/api/1.1/messaging.Messaging.createMessage - - - http://jil.org/jil/api/1.1/messaging.Messaging.onMessageSendingFailure - - - http://jil.org/jil/api/1.1/multimedia.Multimedia.getVolume - - - http://jil.org/jil/api/1.1/multimedia.Multimedia.stopAll - - - http://jil.org/jil/api/1.1/multimedia.Multimedia.isAudioPlaying - - - http://jil.org/jil/api/1.1.1/pim.PIM.createAddressBookItem - - - http://jil.org/jil/api/1.1.1/pim.PIM.onAddressBookItemFound - - - http://jil.org/jil/api/1.1/accelerometerinfo - - - http://jil.org/jil/api/1.1/addressbookitem - - - http://jil.org/jil/api/1.1.5/applicationtypes - - - http://jil.org/jil/api/1.1.2/camera - - - http://jil.org/jil/api/1.1/device - - - http://jil.org/jil/api/1.1/devicestateinfo - - - http://jil.org/jil/api/1.1.5/exception - - - http://jil.org/jil/api/1.1.5/exceptiontypes - - - http://jil.org/jil/api/1.1/message - - - http://jil.org/jil/api/1.1/messagetypes - - - http://jil.org/jil/api/1.1/messaging - - - http://jil.org/jil/api/1.1/multimedia - - - http://jil.org/jil/api/1.1.1/pim - - - http://jil.org/jil/api/1.1/positioninfo - - - http://jil.org/jil/api/1.1/widget - - - - - - - - - - - - Operator - - - - - - - - - -
diff --git a/modules/ace/configuration/bondixml.xsd b/modules/ace/configuration/bondixml.xsd deleted file mode 100644 index d16a14d..0000000 --- a/modules/ace/configuration/bondixml.xsd +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/ace/configuration/config.dtd b/modules/ace/configuration/config.dtd deleted file mode 100644 index f483631..0000000 --- a/modules/ace/configuration/config.dtd +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/modules/ace/configuration/config.xml b/modules/ace/configuration/config.xml deleted file mode 100644 index 278081a..0000000 --- a/modules/ace/configuration/config.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - /usr/etc/ace/ - - demo.xml - - - - diff --git a/modules/ace/configuration/demo.xml b/modules/ace/configuration/demo.xml deleted file mode 100644 index 4c4f423..0000000 --- a/modules/ace/configuration/demo.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/modules/ace/dao/AceDAO.cpp b/modules/ace/dao/AceDAO.cpp deleted file mode 100644 index 155c979..0000000 --- a/modules/ace/dao/AceDAO.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file AceDAO.cpp - * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) - * @version 0.1 - * @brief - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace DPL::DB::ORM; -using namespace DPL::DB::ORM::ace; -using namespace AceDB::AceDaoUtilities; -using namespace AceDB::AceDaoConversions; - -namespace { -char const * const EMPTY_SESSION = ""; -} // namespace - -namespace AceDB{ - -void AceDAO::setPromptDecision( - const DPL::String &hash, - const DPL::String &userParam, - const DPL::OptionalString &session, - PromptDecision decision) -{ - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - - ACE_DB_DELETE(del, AcePromptDecision, &AceDaoUtilities::m_databaseInterface); - del->Where( - And( - Equals(userParam), - Equals(hash))); - del->Execute(); - - AcePromptDecision::Row row; - row.Set_hash(hash); - row.Set_decision(promptDecisionToInt(decision)); - row.Set_user_param(userParam); - row.Set_session(session); - ACE_DB_INSERT(insert, AcePromptDecision, &AceDaoUtilities::m_databaseInterface); - insert->Values(row); - insert->Execute(); - - transaction.Commit(); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to setUserSetting"); - } -} - -void AceDAO::setPromptDecision( - const BaseAttributeSet &attributes, - const DPL::String &userParam, - const DPL::OptionalString &session, - PromptDecision decision) -{ - DPL::String DPLHash = convertToHash(attributes); - - setPromptDecision( - DPLHash, - userParam, - session, - decision); -} - -void AceDAO::removePolicyResult( - const BaseAttributeSet &attributes) -{ - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - - auto attrHash = convertToHash(attributes); - - ACE_DB_DELETE(del, - AcePolicyResult, - &AceDaoUtilities::m_databaseInterface); - del->Where(Equals(attrHash)); - del->Execute(); - transaction.Commit(); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to removeVerdict"); - } -} - -void AceDAO::clearAllSettings(void) -{ - clearWidgetDevCapSettings(); - clearDevCapSettings(); -} - -void AceDAO::setDevCapSetting(const std::string &resource, - PreferenceTypes preference) -{ - Try { - ACE_DB_UPDATE(update, AceDevCap, &AceDaoUtilities::m_databaseInterface); - AceDevCap::Row row; - row.Set_general_setting(preferenceToInt(preference)); - update->Values(row); - update->Where( - Equals(DPL::FromUTF8String(resource))); - update->Execute(); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to SetResourceSetting"); - } -} - -void AceDAO::removeDevCapSetting(const std::string &resource) -{ - Try { - ACE_DB_UPDATE(update, AceDevCap, &AceDaoUtilities::m_databaseInterface); - AceDevCap::Row row; - row.Set_general_setting(preferenceToInt(PreferenceTypes::PREFERENCE_DEFAULT)); - update->Values(row); - update->Where( - Equals(DPL::FromUTF8String(resource))); - update->Execute(); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to removeResourceSetting"); - } -} - - -void AceDAO::setWidgetDevCapSetting(const std::string &resource, - WidgetHandle handler, - PreferenceTypes preference) -{ - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - // TODO JOIN - AceDevCap::Row rrow; - if (!getResourceByUri(resource, rrow)) { - ThrowMsg(Exception::DatabaseError, "Resource not found"); - } - - ACE_DB_INSERT(insert, - AceWidgetDevCapSetting, - &AceDaoUtilities::m_databaseInterface); - - AceWidgetDevCapSetting::Row row; - row.Set_app_id(handler); - int rid = rrow.Get_resource_id(); - row.Set_resource_id(rid); - row.Set_access_value(preferenceToInt(preference)); - insert->Values(row); - insert->Execute(); - - transaction.Commit(); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to setUserSetting"); - } -} - -void AceDAO::removeWidgetDevCapSetting(const std::string &resource, - WidgetHandle handler) -{ - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - AceDevCap::Row rrow; - if (!getResourceByUri(resource, rrow)) { - ThrowMsg(Exception::DatabaseError, "resource not found"); - } - - ACE_DB_DELETE(del, - AceWidgetDevCapSetting, - &AceDaoUtilities::m_databaseInterface); - - Equals e1(handler); - Equals e2(rrow.Get_resource_id()); - del->Where(And(e1, e2)); - del->Execute(); - transaction.Commit(); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to clearUserSettings"); - } -} - - -void AceDAO::setPolicyResult(const BaseAttributeSet &attributes, - const PolicyResult &policyResult) -{ - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - - // TODO: this call is connected with logic. - // It should be moved to PolicyEvaluator - addAttributes(attributes); - - auto attrHash = convertToHash(attributes); - - ACE_DB_DELETE(del, AcePolicyResult, &AceDaoUtilities::m_databaseInterface) - del->Where(Equals(attrHash)); - del->Execute(); - - ACE_DB_INSERT(insert, AcePolicyResult, &AceDaoUtilities::m_databaseInterface); - AcePolicyResult::Row row; - row.Set_decision(PolicyResult::serialize(policyResult)); - row.Set_hash(attrHash); - insert->Values(row); - insert->Execute(); - - transaction.Commit(); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to addVerdict"); - } -} - -void AceDAO::resetDatabase(void) -{ - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - ACE_DB_DELETE(del1, AcePolicyResult, &AceDaoUtilities::m_databaseInterface); - del1->Execute(); - ACE_DB_DELETE(del2, AceWidgetDevCapSetting, &AceDaoUtilities::m_databaseInterface); - del2->Execute(); - ACE_DB_DELETE(del3, AceDevCap, &AceDaoUtilities::m_databaseInterface); - del3->Execute(); - ACE_DB_DELETE(del4, AceSubject, &AceDaoUtilities::m_databaseInterface); - del4->Execute(); - ACE_DB_DELETE(del5, AceAttribute, &AceDaoUtilities::m_databaseInterface); - del5->Execute(); - ACE_DB_DELETE(del6, AcePromptDecision, &AceDaoUtilities::m_databaseInterface); - del6->Execute(); - - transaction.Commit(); - - // TODO there is no such query yet in ORM. - // GlobalConnection::DataCommandAutoPtr command = - // GlobalConnectionSingleton::Instance().PrepareDataCommand( - // "VACUUM"); - // command->Step(); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to resetDatabase"); - } -} - -void AceDAO::clearDevCapSettings() -{ - Try { - ACE_DB_UPDATE(update, AceDevCap, &AceDaoUtilities::m_databaseInterface); - AceDevCap::Row row; - row.Set_general_setting(-1); - update->Values(row); - update->Execute(); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to clearResourceSettings"); - } -} - -void AceDAO::clearWidgetDevCapSettings() -{ - Try { - ACE_DB_DELETE(del, AceWidgetDevCapSetting, &AceDaoUtilities::m_databaseInterface); - del->Execute(); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to clearUserSettings"); - } -} - -int AceDAO::addResource(const std::string &request) -{ - LogDebug("addResource: " << request); - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - AceDevCap::Row rrow; - if (getResourceByUri(request, rrow)) { - transaction.Commit(); - return rrow.Get_resource_id(); - } - - ACE_DB_INSERT(insert, AceDevCap, &AceDaoUtilities::m_databaseInterface); - AceDevCap::Row row; - row.Set_id_uri(DPL::FromUTF8String(request)); - row.Set_general_setting(-1); - insert->Values(row); - int id = insert->Execute(); - transaction.Commit(); - return id; - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed in addResource"); - } -} - -void AceDAO::addAttributes(const BaseAttributeSet &attributes) -{ - Try { - BaseAttributeSet::const_iterator iter; - - for (iter = attributes.begin(); iter != attributes.end(); ++iter) { - ACE_DB_SELECT(select, AceAttribute, &AceDaoUtilities::m_databaseInterface); - select->Where(Equals(DPL::FromUTF8String( - *(*iter)->getName()))); - std::list rows = select->GetRowList(); - if (!rows.empty()) { - continue; - } - - ACE_DB_INSERT(insert, AceAttribute, &AceDaoUtilities::m_databaseInterface); - AceAttribute::Row row; - row.Set_name(DPL::FromUTF8String(*(*iter)->getName())); - row.Set_type(attributeTypeToInt((*iter)->getType())); - insert->Values(row); - insert->Execute(); - } - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed in addAttributes"); - } -} - -void AceDAO::setStaticDevCapPermissions( - int widgetHandle, - const std::set &permissions) -{ - Try { - FOREACH(it, permissions) { - ACE_DB_INSERT(insert, AceStaticDevCapPermission, - &AceDaoUtilities::m_databaseInterface); - AceStaticDevCapPermission::Row row; - row.Set_app_id(widgetHandle); - row.Set_dev_cap(*it); - insert->Values(row); - insert->Execute(); - } - } Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed in setStaticDevCapPermissions"); - } -} - - -} diff --git a/modules/ace/dao/AceDAOConversions.cpp b/modules/ace/dao/AceDAOConversions.cpp deleted file mode 100644 index 5254112..0000000 --- a/modules/ace/dao/AceDAOConversions.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file AceDaoConversions.h - * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#include -#include - -#include - -namespace AceDB { - -DPL::String AceDaoConversions::convertToHash(const BaseAttributeSet &attributes) -{ - unsigned char attrHash[MD5_DIGEST_LENGTH]; - std::string attrString; - FOREACH(it, attributes) { - // [CR] implementation of it->toString() is not secure, 24.03.2010 - attrString.append((*it)->toString()); - } - - MD5((unsigned char *) attrString.c_str(), attrString.length(), attrHash); - - char attrHashCoded[MD5_DIGEST_LENGTH*2 + 1]; - for (int i = 0; i < MD5_DIGEST_LENGTH; ++i) { - sprintf(&attrHashCoded[i << 1], - "%02X", - static_cast(attrHash[i])); - } - return DPL::FromASCIIString(attrHashCoded); -} - - -} diff --git a/modules/ace/dao/AceDAOReadOnly.cpp b/modules/ace/dao/AceDAOReadOnly.cpp deleted file mode 100644 index 1f1b617..0000000 --- a/modules/ace/dao/AceDAOReadOnly.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file AceDAOReadOnlyReadOnly.cpp - * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#include -#include -#include -#include - -#include - -using namespace DPL::DB::ORM; -using namespace DPL::DB::ORM::ace; -using namespace AceDB::AceDaoUtilities; -using namespace AceDB::AceDaoConversions; - -namespace AceDB { - -static const int DB_ALLOW_ALWAYS = 0; -static const int DB_ALLOW_FOR_SESSION = 1; -static const int DB_ALLOW_THIS_TIME = 2; -static const int DB_DENY_ALWAYS = 3; -static const int DB_DENY_FOR_SESSION = 4; -static const int DB_DENY_THIS_TIME = 5; - -int AceDAOReadOnly::promptDecisionToInt(PromptDecision decision) -{ - if (PromptDecision::ALLOW_ALWAYS == decision) { - return DB_ALLOW_ALWAYS; - } else if (PromptDecision::DENY_ALWAYS == decision) { - return DB_DENY_ALWAYS; - } else if (PromptDecision::ALLOW_THIS_TIME == decision) { - return DB_ALLOW_THIS_TIME; - } else if (PromptDecision::DENY_THIS_TIME == decision) { - return DB_DENY_THIS_TIME; - } else if (PromptDecision::ALLOW_FOR_SESSION == decision) { - return DB_ALLOW_FOR_SESSION; - } - // DENY_FOR_SESSION - return DB_DENY_FOR_SESSION; -} - -PromptDecision AceDAOReadOnly::intToPromptDecision(int dec) { - if (dec == DB_ALLOW_ALWAYS) { - return PromptDecision::ALLOW_ALWAYS; - } else if (dec == DB_DENY_ALWAYS) { - return PromptDecision::DENY_ALWAYS; - } else if (dec == DB_ALLOW_THIS_TIME) { - return PromptDecision::ALLOW_THIS_TIME; - } else if (dec == DB_DENY_THIS_TIME) { - return PromptDecision::DENY_THIS_TIME; - } else if (dec == DB_ALLOW_FOR_SESSION) { - return PromptDecision::ALLOW_FOR_SESSION; - } - // DB_DENY_FOR_SESSION - return PromptDecision::DENY_FOR_SESSION; -} - -void AceDAOReadOnly::attachToThread() -{ - AceDaoUtilities::m_databaseInterface.AttachToThread(); -} - -void AceDAOReadOnly::detachFromThread() -{ - AceDaoUtilities::m_databaseInterface.DetachFromThread(); -} - -OptionalCachedPromptDecision AceDAOReadOnly::getPromptDecision( - const DPL::String &hash, - const std::string &userParam) -{ - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - - // get matching subject verdict - ACE_DB_SELECT(select, AcePromptDecision, &AceDaoUtilities::m_databaseInterface); - DPL::String DPLParam = DPL::FromUTF8String(userParam); - - select->Where( - And( - Equals(hash), - Equals(DPLParam))); - - std::list rows = select->GetRowList(); - if (rows.empty()) { - transaction.Commit(); - return OptionalCachedPromptDecision(); - } - - AcePromptDecision::Row row = rows.front(); - CachedPromptDecision decision; - decision.decision = intToPromptDecision(row.Get_decision()); - decision.session = row.Get_session(); - - return OptionalCachedPromptDecision(decision); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to getPromptDecision"); - } -} - -OptionalCachedPromptDecision AceDAOReadOnly::getPromptDecision( - const BaseAttributeSet &attributes, - const std::string &userParam) -{ - return getPromptDecision(convertToHash(attributes), userParam); -} - -void AceDAOReadOnly::getAttributes(BaseAttributeSet *attributes) -{ - if (NULL == attributes) { - LogError("NULL pointer"); - return; - } - attributes->clear(); - std::string aname; - int type; - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - - ACE_DB_SELECT(select, AceAttribute, &AceDaoUtilities::m_databaseInterface); - typedef std::list RowList; - RowList list = select->GetRowList(); - - FOREACH(i, list) { - BaseAttributePtr attribute(new BaseAttribute()); - DPL::String name = i->Get_name(); - aname = DPL::ToUTF8String(name); - type = i->Get_type(); - - attribute->setName(&aname); - attribute->setType(intToAttributeType(type)); - attributes->insert(attribute); - } - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to getAttributes"); - } -} - -OptionalPolicyResult AceDAOReadOnly::getPolicyResult( - const BaseAttributeSet &attributes) -{ - - auto attrHash = convertToHash(attributes); - return getPolicyResult(attrHash); -} - -OptionalPolicyResult AceDAOReadOnly::getPolicyResult( - const DPL::String &attrHash) -{ - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - - // get matching subject verdict - ACE_DB_SELECT(select, AcePolicyResult, &AceDaoUtilities::m_databaseInterface); - Equals e1(attrHash); - select->Where(e1); - - std::list rows = select->GetRowList(); - if (rows.empty()) { - transaction.Commit(); - return OptionalPolicyResult(); - } - - AcePolicyResult::Row row = rows.front(); - int decision = row.Get_decision(); - PolicyResult res = PolicyResult::deserialize(decision); - transaction.Commit(); - return OptionalPolicyResult(res); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to getVerdict"); - } -} - -PreferenceTypes AceDAOReadOnly::getDevCapSetting(const std::string &resource) -{ - Try { - AceDevCap::Row row; - if (!getResourceByUri(resource, row)) { - return PreferenceTypes::PREFERENCE_DEFAULT; - } - return intToPreference(row.Get_general_setting()); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to getResourceSetting"); - } -} - -void AceDAOReadOnly::getDevCapSettings(PreferenceTypesMap *globalSettingsMap) -{ - if (NULL == globalSettingsMap) { - LogError("Null pointer"); - return; - } - globalSettingsMap->clear(); - Try { - ACE_DB_SELECT(select, AceDevCap, &AceDaoUtilities::m_databaseInterface); - typedef std::list RowList; - RowList list = select->GetRowList(); - - FOREACH(i, list) { - PreferenceTypes p = intToPreference(i->Get_general_setting()); - globalSettingsMap->insert(make_pair(DPL::ToUTF8String( - i->Get_id_uri()), p)); - } - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to getResourceSettings"); - } -} - - - -void AceDAOReadOnly::getWidgetDevCapSettings(BasePermissionList *outputList) -{ - if (NULL == outputList) { - LogError("NULL pointer"); - return; - } - outputList->clear(); - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - - std::string resourceName; - PreferenceTypes allowAccess; - - ACE_DB_SELECT(select, - AceWidgetDevCapSetting, - &AceDaoUtilities::m_databaseInterface); - - typedef std::list RowList; - RowList list = select->GetRowList(); - - // TODO JOIN - FOREACH(i, list) { - int app_id = i->Get_app_id(); - int res_id = i->Get_resource_id(); - - ACE_DB_SELECT(resourceSelect, AceDevCap, &AceDaoUtilities::m_databaseInterface); - resourceSelect->Where(Equals(res_id)); - AceDevCap::Row rrow = resourceSelect->GetSingleRow(); - - resourceName = DPL::ToUTF8String(rrow.Get_id_uri()); - - if (!resourceName.empty()) { - allowAccess = intToPreference(i->Get_access_value()); - outputList->push_back( - BasePermission(app_id, - resourceName, - allowAccess)); - } - } - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to findUserSettings"); - } -} - -PreferenceTypes AceDAOReadOnly::getWidgetDevCapSetting( - const std::string &resource, - WidgetHandle handler) -{ - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - - AceDevCap::Row rrow; - if (!getResourceByUri(resource, rrow)) { - return PreferenceTypes::PREFERENCE_DEFAULT; - } - int resourceId = rrow.Get_resource_id(); - - // get matching user setting - ACE_DB_SELECT(select, AceWidgetDevCapSetting, &AceDaoUtilities::m_databaseInterface); - - select->Where(And(Equals(resourceId), - Equals(handler))); - - std::list values = - select->GetValueList(); - if (values.empty()) { - return PreferenceTypes::PREFERENCE_DEFAULT; - } - return intToPreference(values.front()); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed in getUserSetting"); - } -} - -void AceDAOReadOnly::getStaticDevCapPermissions( - int widgetHandle, - std::set *permissions) -{ - if (NULL == permissions) { - LogError("NULL pointer"); - return; - } - permissions->clear(); - Try { - ScopedTransaction transaction(&AceDaoUtilities::m_databaseInterface); - - ACE_DB_SELECT(select, AceStaticDevCapPermission, - &AceDaoUtilities::m_databaseInterface); - select->Where( - Equals(widgetHandle)); - std::list devCapNames = - select->GetValueList(); - permissions->insert(devCapNames.begin(), devCapNames.end()); - transaction.Commit(); - } Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to getStaticDevCapPermissions"); - } -} -} diff --git a/modules/ace/dao/AceDAOUtilities.cpp b/modules/ace/dao/AceDAOUtilities.cpp deleted file mode 100644 index 1f8c95e..0000000 --- a/modules/ace/dao/AceDAOUtilities.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file AceDaoReadOnly.h - * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#include -#include -#include - -#include -#include -#include - -namespace AceDB { - -namespace { -const char* ACE_DB_DATABASE = "/opt/dbspace/.ace.db"; -DPL::DB::SqlConnection::Flag::Type ACE_DB_FLAGS = - DPL::DB::SqlConnection::Flag::UseLucene; -} - -DPL::DB::ThreadDatabaseSupport AceDaoUtilities::m_databaseInterface( - ACE_DB_DATABASE, ACE_DB_FLAGS); - -BaseAttribute::Type AceDaoUtilities::intToAttributeType(int val) -{ - switch (val) { - case 0: - return BaseAttribute::Type::Subject; - case 1: - return BaseAttribute::Type::Environment; - case 2: - return BaseAttribute::Type::Resource; - case 3: - return BaseAttribute::Type::FunctionParam; - - default: - Assert(0 && "Unknown Attribute type value"); - return BaseAttribute::Type::Subject; //remove compilation warrning - } -} - -int AceDaoUtilities::attributeTypeToInt(BaseAttribute::Type type) -{ - // we cannot cast enum -> int because this cast will be removed from next c++ standard - switch (type) { - case BaseAttribute::Type::Subject: - return 0; - case BaseAttribute::Type::Environment: - return 1; - case BaseAttribute::Type::Resource: - return 2; - case BaseAttribute::Type::FunctionParam: - return 3; - - default: - Assert(0 && "Unknown Attribute type!"); - return 0; //remove compilation warrning - } -} - -int AceDaoUtilities::preferenceToInt(PreferenceTypes p) -{ - switch (p) { - case PreferenceTypes::PREFERENCE_PERMIT: - return 1; - case PreferenceTypes::PREFERENCE_DENY: - return 0; - case PreferenceTypes::PREFERENCE_BLANKET_PROMPT: - return 2; - case PreferenceTypes::PREFERENCE_SESSION_PROMPT: - return 3; - case PreferenceTypes::PREFERENCE_ONE_SHOT_PROMPT: - return 4; - - default: - return -1; - } -} - -PreferenceTypes AceDaoUtilities::intToPreference(int p) -{ - switch (p) { - case 1: - return PreferenceTypes::PREFERENCE_PERMIT; - case 0: - return PreferenceTypes::PREFERENCE_DENY; - case 2: - return PreferenceTypes::PREFERENCE_BLANKET_PROMPT; - case 3: - return PreferenceTypes::PREFERENCE_SESSION_PROMPT; - case 4: - return PreferenceTypes::PREFERENCE_ONE_SHOT_PROMPT; - - default: - return PreferenceTypes::PREFERENCE_DEFAULT; - } -} - -VerdictTypes AceDaoUtilities::intToVerdict(int v) -{ - switch (v) { - case -1: - return VerdictTypes::VERDICT_UNKNOWN; - case 0: - return VerdictTypes::VERDICT_DENY; - case 1: - return VerdictTypes::VERDICT_PERMIT; - case 2: - return VerdictTypes::VERDICT_INAPPLICABLE; - - default: - Assert(0 && "Cannot convert int to verdict"); - return VerdictTypes::VERDICT_UNKNOWN; // remove compile warrning - } -} - -int AceDaoUtilities::verdictToInt(VerdictTypes v) -{ - switch (v) { - case VerdictTypes::VERDICT_UNKNOWN: - return -1; - case VerdictTypes::VERDICT_DENY: - return 0; - case VerdictTypes::VERDICT_PERMIT: - return 1; - case VerdictTypes::VERDICT_INAPPLICABLE: - return 2; - - default: - Assert(0 && "Unknown Verdict value"); - return -1; // remove compile warrning - } -} - -bool AceDaoUtilities::getSubjectByUri(const std::string &uri, - DPL::DB::ORM::ace::AceSubject::Row &row) -{ - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::ace; - ACE_DB_SELECT(select, AceSubject, &m_databaseInterface); - select->Where(Equals(DPL::FromUTF8String(uri))); - std::list rows = select->GetRowList(); - if (rows.empty()) { - return false; - } - - row = rows.front(); - return true; -} - -bool AceDaoUtilities::getResourceByUri(const std::string &uri, - DPL::DB::ORM::ace::AceDevCap::Row &row) -{ - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::ace; - ACE_DB_SELECT(select, AceDevCap, &m_databaseInterface); - select->Where(Equals(DPL::FromUTF8String(uri))); - std::list rows = select->GetRowList(); - if (rows.empty()) { - return false; - } - - row = rows.front(); - return true; -} - - -} diff --git a/modules/ace/dao/AceDatabase.cpp b/modules/ace/dao/AceDatabase.cpp deleted file mode 100644 index 110f791..0000000 --- a/modules/ace/dao/AceDatabase.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file AceDatabase.cpp - * @author Lukasz Marek (l.marek@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of ace database - */ - -#include - -DPL::Mutex g_aceDbQueriesMutex; diff --git a/modules/ace/dao/BaseAttribute.cpp b/modules/ace/dao/BaseAttribute.cpp deleted file mode 100644 index 095e2f5..0000000 --- a/modules/ace/dao/BaseAttribute.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file BaseAttribute.cpp - * @author Lukasz Marek (l.marek@samsung.com) - * @version 0.1 - * @brief - */ - -#include -#include - -#include - -namespace AceDB { - -const char* BaseAttribute::typeToString(Type type) -{ - const char * ret = NULL; - switch (type) { - case Type::Resource: - ret = "resource"; - break; - case Type::Subject: - ret = "subject"; - break; - case Type::Environment: - ret = "environment"; - break; - default: - ret = "unknown type"; - break; - } - - return ret; -} - -std::string BaseAttribute::toString() const -{ - std::string ret; - const char * SEPARATOR = ";"; - - ret.append(m_name); - ret.append(SEPARATOR); - ret.append(typeToString(m_typeId)); - ret.append(SEPARATOR); - if (m_undetermindState) { - ret.append("true"); - } else { - ret.append("false"); - } - ret.append(SEPARATOR); - for (std::list::const_iterator it = value.begin(); - it != value.end(); - ++it) { - std::stringstream num; - num << it->size(); - ret.append(num.str()); - ret.append(SEPARATOR); - ret.append(*it); - ret.append(SEPARATOR); - } - - return ret; -} - -} diff --git a/modules/ace/dao/CMakeLists.txt b/modules/ace/dao/CMakeLists.txt deleted file mode 100644 index a19dcae..0000000 --- a/modules/ace/dao/CMakeLists.txt +++ /dev/null @@ -1,110 +0,0 @@ - -SET(ACE_DAO_DEPS_LIST - ecore - appcore-efl - openssl - vconf - db-util - libpcrecpp - icu-uc - libxml-2.0 - ) - -PKG_CHECK_MODULES(ACE_DAO_DEPS ${ACE_DAO_DEPS_LIST} REQUIRED) - -set(ACE_SRC_DIR ${PROJECT_SOURCE_DIR}/modules/ace/dao) - -set(ACE_DAO_RO_SOURCES - ${ACE_SRC_DIR}/AceDAOReadOnly.cpp - ${ACE_SRC_DIR}/AceDAOUtilities.cpp - ${ACE_SRC_DIR}/AceDAOConversions.cpp - ${ACE_SRC_DIR}/BaseAttribute.cpp - ${ACE_SRC_DIR}/AceDatabase.cpp - ${ACE_SRC_DIR}/PromptModel.cpp -) - -set(ACE_DAO_RW_SOURCES - ${ACE_SRC_DIR}/AceDAO.cpp -) - -INCLUDE_DIRECTORIES(${ACE_SRC_DIR}) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/log/include) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/db/include) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/core/include) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/ace/include) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/ace/orm) -INCLUDE_DIRECTORIES(${ACE_DAO_DEPS_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/ace/orm) - -ADD_LIBRARY(${TARGET_ACE_DAO_RO_LIB} SHARED - ${ACE_DAO_RO_SOURCES} -) - -SET_TARGET_PROPERTIES(${TARGET_ACE_DAO_RO_LIB} PROPERTIES - SOVERSION ${VERSION}) - -SET_TARGET_PROPERTIES(${TARGET_ACE_DAO_RO_LIB} PROPERTIES - COMPILE_FLAGS -fPIC) - -SET_TARGET_PROPERTIES(${TARGET_ACE_DAO_RO_LIB} PROPERTIES - COMPILE_FLAGS "-include ${CMAKE_BINARY_DIR}/modules/ace/database_checksum_ace.h") - -target_link_libraries(${TARGET_ACE_DAO_RO_LIB} - ${TARGET_DPL_EFL} - ${TARGET_DPL_DB_EFL} - ${ACE_DAO_DEPS_LIBRARY} - ${ACE_DAO_DEPS_LDFLAGS} -) - -ADD_LIBRARY(${TARGET_ACE_DAO_RW_LIB} SHARED - ${ACE_DAO_RW_SOURCES} -) - -SET_TARGET_PROPERTIES(${TARGET_ACE_DAO_RW_LIB} PROPERTIES - SOVERSION ${VERSION}) - -SET_TARGET_PROPERTIES(${TARGET_ACE_DAO_RW_LIB} PROPERTIES - COMPILE_FLAGS -fPIC) - -SET_TARGET_PROPERTIES(${TARGET_ACE_DAO_RW_LIB} PROPERTIES - COMPILE_FLAGS "-include ${CMAKE_BINARY_DIR}/modules/ace/database_checksum_ace.h") - -target_link_libraries(${TARGET_ACE_DAO_RW_LIB} - ${TARGET_DPL_EFL} - ${TARGET_DPL_DB_EFL} - ${TARGET_ACE_DAO_RO_LIB} -) - -INSTALL(TARGETS ${TARGET_ACE_DAO_RO_LIB} - DESTINATION lib - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE -) - -INSTALL(TARGETS ${TARGET_ACE_DAO_RW_LIB} - DESTINATION lib - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE -) - -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/PromptModel.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/PreferenceTypes.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/BaseAttribute.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/BasePermission.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/VerdictTypes.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/TimedVerdict.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/IRequest.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/ValidityTypes.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/AceDAOReadOnly.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/AceDatabase.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/wrt_db_types.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/common_dao_types.h - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-ro/AceDAOConversions.h - DESTINATION include/dpl-efl/dpl/ace-dao-ro -) - -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/modules/ace/include/dpl/ace-dao-rw/AceDAO.h - DESTINATION include/dpl-efl/dpl/ace-dao-rw -) diff --git a/modules/ace/dao/PromptModel.cpp b/modules/ace/dao/PromptModel.cpp deleted file mode 100644 index d3c82a0..0000000 --- a/modules/ace/dao/PromptModel.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* @file PromptModel.cpp - * @author Justyna Mejzner (j.kwiatkowsk@samsung.com) - * @author Jaroslaw Osmanski (j.osmanski@samsung.com) - * @version 1.0 - * - */ - -#include - -#include -#include -#include - -namespace { - -const char INFO[] = "Widget requires access to:"; -const char DENY[] = "Deny"; -const char ALLOW[] = "Permit"; - -const char BLANKET_CHECKBOX_LABEL[] = "Keep setting as permanent"; -const char SESSION_CHECKBOX_LABEL[] = "Remember for one run"; - -Prompt::ButtonLabels aceQuestionLabel = {DENY, ALLOW}; - -static Prompt::PromptLabels* getModel( - Prompt::PromptModel::PromptType promptType, - const std::string& resourceId) -{ - std::string strLabel; - strLabel = INFO; - strLabel += "
"; - strLabel += resourceId; - - return new Prompt::PromptLabels(promptType, aceQuestionLabel, strLabel); -} - -Prompt::Validity fromPromptTypeToValidity(int aPromptType, bool checkClicked) -{ - using namespace Prompt; - PromptModel::PromptType promptTypeEnum = - static_cast(aPromptType); - switch (promptTypeEnum) { - case PromptModel::PROMPT_ONESHOT: - return Validity::ONCE; - case PromptModel::PROMPT_SESSION: - if (checkClicked) - { - return Validity::SESSION; - } - else - { - return Validity::ONCE; - } - case PromptModel::PROMPT_BLANKET: - if (checkClicked) - { - return Validity::ALWAYS; - } - else - { - return Validity::ONCE; - } - default: - Assert(0); - return Validity::ONCE; - } -} -} // namespace anonymous - -namespace Prompt { - - -PromptLabels::PromptLabels(int promptType, - const Prompt::ButtonLabels& questionLabel, - const std::string& mainLabel) : - m_promptType(promptType), - m_buttonLabels(questionLabel), - m_mainLabel(mainLabel) -{ - -} - -int PromptLabels::getPromptType() const -{ - return m_promptType; -} -const ButtonLabels& PromptLabels::getButtonLabels() const -{ - return m_buttonLabels; -} -const std::string& PromptLabels::getMainLabel() const -{ - return m_mainLabel; -} - -DPL::OptionalString PromptLabels::getCheckLabel() const -{ - if (PromptModel::PROMPT_BLANKET == m_promptType) - { - return DPL::OptionalString( - DPL::FromUTF8String(BLANKET_CHECKBOX_LABEL)); - } - else if (PromptModel::PROMPT_SESSION == m_promptType) - { - return DPL::OptionalString( - DPL::FromUTF8String(SESSION_CHECKBOX_LABEL)); - } - - return DPL::OptionalString::Null; -} - -bool PromptLabels::isAllowed(const size_t buttonClicked) const -{ - Assert(buttonClicked < aceQuestionLabel.size() && - "Button Clicked number is not in range of questionLabel"); - - return aceQuestionLabel[buttonClicked] == ALLOW; -} - -PromptAnswer::PromptAnswer(bool isAccessAllowed, Validity validity) : - m_isAccessAllowed(isAccessAllowed), - m_validity(validity) -{ - -} - -PromptAnswer::PromptAnswer( - int aPromptType, unsigned int buttonAns, bool checkAns) -{ - Assert(buttonAns < aceQuestionLabel.size() && - "Button Clicked number is not in range of questionLabel"); - - m_isAccessAllowed = aceQuestionLabel[buttonAns] == ALLOW; - m_validity = fromPromptTypeToValidity(aPromptType, checkAns); -} - -bool PromptAnswer::isAccessAllowed() const -{ - return m_isAccessAllowed; -} - -Validity PromptAnswer::getValidity() const -{ - return m_validity; -} - -PromptLabels* PromptModel::getOneShotModel(const std::string& resourceId) -{ - return getModel(PROMPT_ONESHOT, resourceId); -} - -PromptLabels* PromptModel::getSessionModel(const std::string& resourceId) -{ - return getModel(PROMPT_SESSION, resourceId); -} - -PromptLabels* PromptModel::getBlanketModel(const std::string& resourceId) -{ - return getModel(PROMPT_BLANKET, resourceId); -} - - -} // Prompt diff --git a/modules/ace/dao/common_dao_types.cpp b/modules/ace/dao/common_dao_types.cpp deleted file mode 100644 index 94e1222..0000000 --- a/modules/ace/dao/common_dao_types.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * @file common_dao_types.h - * @author Michal Ciepielski (m.ciepielski@samsung.com) - * @version 1.0 - * @brief This file contains the implementation of common data types for wrtdb - */ - -#include - -#include - -namespace WrtDB { -namespace Powder { - -Description::LevelEntry::LevelEntry(LevelEnum level) : - level(level) -{ -} - -bool Description::LevelEntry::isContextValid(LevelEnum level, - const DPL::OptionalString& aContext) const -{ - if (!aContext) { - return level < level; - } else { - Context::const_iterator iter = context.find(*aContext); - if (iter != context.end()) { - return level < level; - } else { - return true; - } - } -} - -bool Description::CategoryEntry::isCategoryValid(LevelEntry& aReason, - LevelEnum aLevel, - const DPL::OptionalString& aContext) const -{ - for (LevelsContainer::const_iterator iter = levels.begin(); - iter != levels.end(); ++iter) { - if (!iter->isContextValid(aLevel, aContext)) { - aReason = *iter; - return false; - } - } - return true; -} -} - -namespace ChildProtection -{ - -PowderRules::CategoryRule::CategoryRule(const DPL::String& aCategory, - Powder::Description::LevelEnum aLevel, - const DPL::OptionalString& aContext) : - category(aCategory), - level(aLevel), - context(aContext) -{ -} - -PowderRules::PowderResult::PowderResult(InvalidReason aReason, - const Powder::Description::LevelEntry& anInvalidDescription, - const CategoryRule& anInvalidRule) : - invalidDescription(anInvalidDescription), - invalidRule(anInvalidRule), - reason(aReason) -{ -} - -//! Function checks if rule is fulfilled by description -//! \param[in] rule checked rule -//! \param[in] description -//! \retval true rule is valid -//! \retval false rule is invalid -PowderRules::ResultPair PowderRules::isRuleValidForDescription( - const CategoryRule& aRule, - const Powder::Description& aDescription) const -{ - Powder::Description::CategoryEntries::const_iterator - iter = aDescription.categories.find(aRule.category); - if (iter != aDescription.categories.end()) { - Powder::Description::LevelEntry invalidDescription; - if (!iter->second.isCategoryValid(invalidDescription, aRule.level, - aRule.context)) { - LogWarning("Widget forbidden for children detected"); - return std::make_pair(false, - PowderResult(PowderResult::InvalidRule, - invalidDescription, - aRule)); - } else { - return std::make_pair(true, PowderResult()); - } - } else { - return std::make_pair(true, PowderResult()); - } -} - -//! Function checks if age limit is fulfilled by description -//! \param[in] description -//! \retval true age is valid -//! \retval false age is invalid -PowderRules::ResultPair PowderRules::isAgeValidForDescription( - const Powder::Description& aDescription) const -{ - if (!ageLimit) { - return std::make_pair(true, PowderResult()); - } else { - if (!!aDescription.ageRating) { - if (*aDescription.ageRating <= *ageLimit) { - return std::make_pair(true, PowderResult()); - } else { - return std::make_pair(false, - PowderResult(PowderResult::InvalidAge)); - } - } else { - if (!isAgeRatingRequired) { - return std::make_pair(true, PowderResult()); - } else { - return std::make_pair( - false, - PowderResult(PowderResult::AgeRatingNotSet)); - } - } - } -} - -//! Function check if Widget description is valid for ChildProtection -//! configuration -//! \param description widget description -//! \retval true widget is valid -//! \retval false widget is invalid -PowderRules::ResultPair PowderRules::isDescriptionValid( - const Powder::Description& aDescription) const -{ - ResultPair powderResult; - for (RulesContainer::const_iterator iter = rules.begin(); - iter != rules.end(); ++iter) { - powderResult = isRuleValidForDescription(*iter, aDescription); - if (!powderResult.first) { - return powderResult; - } - } - return isAgeValidForDescription(aDescription); -} - -} -} // namespace WrtDB diff --git a/modules/ace/engine/Attribute.cpp b/modules/ace/engine/Attribute.cpp deleted file mode 100644 index 45a8221..0000000 --- a/modules/ace/engine/Attribute.cpp +++ /dev/null @@ -1,913 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include - -const bool Attribute::alpha[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 -}; -const bool Attribute::digit[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 -}; - -const bool Attribute::mark[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 -}; - -bool Attribute::searchAndCut(const char *str) -{ - //TODO - size_t pos = m_name.rfind(str); - if (pos == std::string::npos) { - return false; - } - if ((strlen(str) + pos) == m_name.size()) { - m_name.erase(pos, std::string::npos); - return true; - } - return false; -} - -Attribute::Attribute(const std::string *name, - const Match matchFunc, - const Type type_) : - matchFunction(matchFunc) -{ - m_name = *name; - m_typeId = type_; - m_undetermindState = false; - if (matchFunction != Match::Equal - && matchFunction != Match::Glob - && matchFunction != Match::Regexp) - { - //LogDebug("MID: " << matchFunction); - Assert(0 && "Match function problem"); - } - - if (searchAndCut(".scheme")) { - modifierFunction = Modifier::Scheme; - } else if (searchAndCut(".authority")) { - modifierFunction = Modifier::Authority; - } else if (searchAndCut(".scheme-authority")) { - modifierFunction = Modifier::SchemeAuthority; - } else if (searchAndCut(".host")) { - modifierFunction = Modifier::Host; - } else if (searchAndCut(".path")) { - modifierFunction = Modifier::Path; - } else { - modifierFunction = Modifier::Non; - } -} - -static Attribute::MatchResult equal_comparator(const std::string *first, - const std::string *second) -{ - if((*first) == (*second)) { - return Attribute::MatchResult::MRTrue; - } - return Attribute::MatchResult::MRFalse; -} - -static Attribute::MatchResult glob_comparator(const std::string *first, - const std::string *second) -{ - // order is important - if (!fnmatch(first->c_str(), second->c_str(), 0)) { - return Attribute::MatchResult::MRTrue; - } - return Attribute::MatchResult::MRFalse; -} - -static Attribute::MatchResult regexp_comparator(const std::string *first, - const std::string *second) -{ - // order is important - pcrecpp::RE re(first->c_str()); - if (re.FullMatch(second->c_str())) { - return Attribute::MatchResult::MRTrue; - } - return Attribute::MatchResult::MRFalse; -} - -Attribute::MatchResult Attribute::lists_comparator( - const std::list *first, - const std::list *second, - Attribute::MatchResult (*comparator)(const std::string *, - const std::string *)) const -{ - //NOTE: BONDI defines all availabe matching function as: if some string from first input bag - //matches some input string from second input bag, so it's required to find only one matching string - MatchResult result = MatchResult::MRFalse; - - for (std::list::const_iterator second_iter = second->begin(); - (second_iter != second->end()) && (result != MatchResult::MRTrue); - ++second_iter) - { - std::string *modified_value = applyModifierFunction(&(*second_iter)); - //Value was not an URI, it will be removed from the string bag (ignored) - if (modified_value == NULL) { - continue; - } - - for (std::list::const_iterator first_iter = first->begin(); - first_iter != first->end(); - ++first_iter) { - //Compare attributes - if ((*comparator)(&(*first_iter), modified_value) == MatchResult::MRTrue) { - result = MatchResult::MRTrue; - break; //Only one match is enough - } - } - if (modified_value) { - delete modified_value; - modified_value = NULL; - } - } - - if (result == MatchResult::MRTrue) { - LogDebug("Returning TRUE"); - } else if (result == MatchResult::MRFalse) { - LogDebug("Returning FALSE"); - } else if (result == MatchResult::MRUndetermined) { - LogDebug("Returning UNDETERMINED"); - } - return result; -} - -std::string * Attribute::applyModifierFunction(const std::string * val) const -{ - std::string * result = NULL; - switch (modifierFunction) { - case Modifier::Scheme: - result = uriScheme(val); - break; - case Modifier::Authority: - result = uriAuthority(val); - break; - case Modifier::SchemeAuthority: - result = uriSchemeAuthority(val); - break; - case Modifier::Host: - result = uriHost(val); - break; - case Modifier::Path: - result = uriPath(val); - break; - default: - result = new std::string(*val); - } - - return result; -} - -/** - * this - attribute obtained from xmlPolicy tree - * attribute - attribute obtained from PIP - */ -Attribute::MatchResult Attribute::matchAttributes( - const BaseAttribute *attribute) const -{ - std::string tempNam = *(attribute->getName()); - std::string tempVal; - std::string myVal; - - if (!(attribute->getValue()->empty())) { - tempVal = attribute->getValue()->front(); - } - - if (!(this->value.empty())) { - myVal = this->value.front(); - } - - LogDebug("Comparing attribute: " << this->m_name << "(" << - myVal << ") with: " << tempNam << - "(" << tempVal << ")"); - - Assert( - (this->m_name == *(attribute->getName())) && - "Two completely different attributes are being compared!"); - Assert( - (this->m_typeId == attribute->getType()) && - "Two completely different attributes are being compared!"); - - if (attribute->isUndetermind()) { - LogDebug("Attribute match undetermined"); - return MatchResult::MRUndetermined; - } - - //Regardles the algorithm used, if we have empty - //bag the result is always false - if (this->isValueEmpty() || attribute->isValueEmpty()) { - if (this->isValueEmpty()) { - LogDebug("empty bag in condition comparing"); - } - if (attribute->isValueEmpty()) { - LogDebug("empty bag in attribute comparing"); - } - return MatchResult::MRFalse; - } - - if (this->matchFunction == Match::Equal) { - return lists_comparator(&(this->value), - attribute->getValue(), - equal_comparator); - } else if (this->matchFunction == Match::Glob) { - return lists_comparator(&(this->value), - attribute->getValue(), - glob_comparator); - } else if (this->matchFunction == Match::Regexp) { - return lists_comparator(&(this->value), - attribute->getValue(), - regexp_comparator); - } //[CR] Change to Assert - Assert(false && " ** Critical :: no match function selected!"); - return MatchResult::MRFalse; // to remove compilator warning -} - -void Attribute::addValue(const std::string *val) -{ - this->getValue()->push_back(*val); -} - -std::ostream & operator<<(std::ostream & out, - const Attribute & attr) -{ - out << "attr: m_name: " << *(attr.getName()) - << " type: " << Attribute::typeToString(attr.getType()) - << " value: "; - if (attr.m_undetermindState) { - out << "Undetermined"; - } else if (attr.getValue()->empty()) { - out << "Empty string bag"; - } else { - FOREACH (it, *attr.getValue()) { - out << *it; - } - } - return out; -} - -bool -Attribute::parse(const std::string *input, - std::string *val) const -{ - static const char *pattern = - "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?"; - pcrecpp::RE re(pattern); - re.FullMatch(input->c_str(), &val[0], &val[1], - &val[2], &val[3], &val[4], - &val[5], &val[6], &val[7], &val[8]); - -#ifdef ALL_LOGS - for (int i = 0; i < 9; i++) { - LogDebug("val " << i << " :" << val[i]); - } -#endif - - if (find_error(val)) { - LogDebug("Input is not an URI " << *input); - for (int i = 0; i < 9; ++i) { - val[i].clear(); - } - return false; - } - - return true; -} - -Attribute::Attribute(std::istream& is) -{ - Serializer* serializer = Serializer::getInstance(); - - m_name = serializer->deserializeString(is); - m_typeId = serializer->deserializeType(is); - - setValue(serializer->deserializeListStrings(is)); - - matchFunction = serializer->deserializeMatch(is); - modifierFunction = serializer->deserializeModifier(is); -} - -Attribute::~Attribute() -{ -} - -bool Attribute::serialize(std::ostream& os) const -{ - Serializer* serializer = Serializer::getInstance(); - - serializer->serializeString(os, m_name); - serializer->serializeType(os, m_typeId); - serializer->serializeListStrings(os, value); - - serializer->serializeMatch(os, matchFunction); - serializer->serializeModifier(os, modifierFunction); - return 0; -} - -std::string * Attribute::uriScheme(const std::string *input) const -{ - std::string part[9]; - if (!parse(input, part)) { - return NULL; - } - return new string(part[1]); -} - -std::string * -Attribute::uriAuthority(const std::string *input) const -{ - std::string part[9]; - if (!parse(input, part)) { - return NULL; - } - return new string(part[3]); -} - -std::string * -Attribute::uriSchemeAuthority(const std::string *input) const -{ - std::string part[9]; - if (!parse(input, part)) { - return NULL; - } - - if (part[0].size() == 0 || part[2].size() == 0) { - return new std::string(); - } - return new string(part[0] + part[2]); -} - -std::string * -Attribute::uriHost(const std::string *input) const -{ - std::string part[9]; - if (!parse(input, part)) { - return NULL; - } - return getHost(&(part[3])); -} - -std::string * -Attribute::uriPath(const std::string *input) const -{ - //TODO right now uriPath leaves leading '/' in uri, this slash is removed from the string - //it's not clear if leading '/' is a part of path component or only the separator - std::string part[9]; - if (!parse(input, part)) { - return NULL; - } - - std::string * temp = NULL; - - if (part[4].at(0) == '/') { - temp = new string(part[4].substr(1, part[4].length() - 1)); - } else { - temp = new string(part[4]); - } - - return temp; -} - -bool Attribute::find_error(const std::string *tab) const -{ - //We are checking tab[1] which contains scheme without ':' at the end - if (!checkScheme(&(tab[1]))) { - LogDebug("Check scheme failed, URI is invalid"); - return true; //error found - } - if (!checkAuthority(&(tab[3]))) { - LogDebug("Check authority failed, URI is invalid"); - return true; //error found - } - - if (!checkPath(&(tab[4]))) { - LogDebug("Check path failed, URI is invalid"); - return true; //error found - } - - return false; -} - -bool Attribute::checkScheme(const std::string *part) const -{ - Assert(part != NULL && "Checking NULLable string. This should never happen"); - - bool result = true; - - //TODO change part->at to data=part->c_str() - //TODO can scheme be empty? In absolute URI no, in relative URI yes - if (part->empty()) { - //Empty string is a correct schema - result = true; - } else if (alpha[(int) (part->at(0))] == 0) { - result = false; // First scheme character must be alpha - } else { - // rest must be alpha or digit or '+' or '-' or '.' - for (unsigned int i = 1; i < part->size(); ++i) { - int c = static_cast(part->at(i)); - if (!isSchemeAllowedCharacter(c)) { - result = false; - break; - } - } - } - return result; -} - -bool Attribute::checkAuthority(const std::string *part) const -{ - Assert(part != NULL && "Checking NULLable string. This should never happen"); - - //Server is a subset of reg_m_names so here we only check if authority matches reg_m_name - //Additional check if authority is a valid 'server' component is done in getHost - if (part->empty()) { - return true; //empty authority is valid uri - } - bool result = true; - - const char * data = part->c_str(); - for (size_t i = 0; i < part->length(); ++i) { - int c = (int) data[i]; - if (isUnreserved(c)) { - continue; - } - if (c == '$') { - continue; - } - if (c == ',') { - continue; - } - if (c == ';') { - continue; - } - if (c == ':') { - continue; - } - if (c == '@') { - continue; - } - if (c == '&') { - continue; - } - if (c == '=') { - continue; - } - if (c == '+') { - continue; - } - if (c == '%') { - if (isEscaped(data + i)) { - i += 2; //rewind the two escaped characters - continue; - } - } - result = false; - break; - } - - return result; -} - -std::string * Attribute::getHost(const std::string *part) const -{ - if (part->empty()) { - return new std::string(""); - } - - //Check userinfo - size_t userInfoPos = part->find("@"); - if (userInfoPos != std::string::npos) { - std::string data = part->substr(0, userInfoPos); - if (!isUserInfoAllowedString(&data)) { - return new string(""); //the authority is not composed of 'server' part - } - } - - std::string host; - //If we use host modifier then authority is composed of 'server' part so - //the port must contain only digits - size_t portPos = part->find(":"); - if (portPos != std::string::npos) { - for (unsigned int i = portPos + 1; i < part->size(); ++i) { - if (!digit[(int) part->at(i)]) { - return new string(""); //the authority is not composed of 'server' part - } - } - host = part->substr(userInfoPos + 1, portPos - (userInfoPos + 1)); - } else { - host = part->substr(userInfoPos + 1, part->length() - (userInfoPos + 1)); - } - - if (!isHostAllowedString(&host)) { - //Even if the string is not allowed for host this can still be a valid uri - return new string(""); - } - - return new std::string(host); -} - -bool Attribute::checkPath(const std::string *part) const -{ - bool result = true; - - const char * data = part->c_str(); - - for (unsigned int i = 0; i < part->size(); ++i) { - int c = data[i]; - if (c == '/') { - //If we found slash then the next character must be a part of segment - //It cannot be '/' so we have to check it immediately - i++; - c = data[i]; - if (!isSegmentAllowedCharacter(c)) { - result = false; - break; - } - } else if (c == ';') { - //Start param part of segment - i++; //Param can be empty so we don't have to check what's right after semicolon - continue; - } else if (c == '%') { - //We have to handle escaped characters differently than other segment allowed characters - //because we need an array - if (isEscaped(data + i)) { - i += 2; - } else { - result = false; - break; - } - } else { - if (!isSegmentAllowedCharacter(c)) { - result = false; - break; - } - } - } - - return result; -} - -bool Attribute::isSchemeAllowedCharacter(int c) const -{ - bool result = false; - if (isAlphanum(c)) { - result = true; - } else if (c == '+') { - result = true; - } else if (c == '-') { - result = true; - } else if (c == '.') { - result = true; - } - - return result; -} - -bool Attribute::isSegmentAllowedCharacter(int c) const -{ - bool result = true; - - // LogDebug("Checking is segment allowed for char "<<(char)c); - - if (isUnreserved(c)) { //do nothing, result = true - } else if (c == ':') { //do nothing, result = true - } else if (c == '@') { //do nothing, result = true - } else if (c == '&') { //do nothing, result = true - } else if (c == '=') { //do nothing, result = true - } else if (c == '+') { //do nothing, result = true - } else if (c == '$') { //do nothing, result = true - } else if (c == ',') { //do nothing, result = true - } else { - result = false; - } - - return result; -} - -bool Attribute::isUserInfoAllowedString(const std::string * str) const -{ - bool result = false; - - const char * data = str->c_str(); - - for (unsigned int i = 0; i < str->length(); ++i) { - int c = data[i]; - if (isUnreserved(c)) { - result = true; - } else if (c == '%') { - //isEsacped method checks if we don't cross array bounds, so we can - //safely give data[i] here - result = isEscaped((data + i)); - if (result == false) { - break; - } - i += 2; //rewind the next two characters sEsacped method checks if we don't cross array bounds, so we can safely rewind - } else if (c == ',') { - result = true; - } else if (c == '$') { - result = true; - } else if (c == '+') { - result = true; - } else if (c == '=') { - result = true; - } else if (c == '&') { - result = true; - } else if (c == '@') { - result = true; - } else if (c == ':') { - result = true; - } - } - return result; -} - -bool Attribute::isUnreserved(int c) const -{ - return isAlphanum(c) || mark[c]; -} - -bool Attribute::isAlphanum(int c) const -{ - return alpha[c] || digit[c]; -} - -bool Attribute::isHex(int c) const -{ - bool result = false; - - if (digit[c]) { - result = true; - } else if (c == 'A') { - result = true; - } else if (c == 'B') { - result = true; - } else if (c == 'C') { - result = true; - } else if (c == 'D') { - result = true; - } else if (c == 'E') { - result = true; - } else if (c == 'F') { - result = true; - } else if (c == 'a') { - result = true; - } else if (c == 'b') { - result = true; - } else if (c == 'c') { - result = true; - } else if (c == 'd') { - result = true; - } else if (c == 'e') { - result = true; - } else if (c == 'f') { - result = true; - } - - return result; -} - -bool Attribute::isEscaped(const char esc[3]) const -{ - if (esc == NULL) { - return false; - } - - if ((esc[0] == 0) || (esc[1] == 0) || (esc[2] == 0)) { - //We get an array that seems to be out of bounds. - //To be on the safe side return here - LogDebug("HEX NULLS"); - return false; - } - - if (esc[0] != '%') { - LogDebug( - "Error: first character of escaped value must be a precent but is " - << - esc[0]); - return false; - } - -#ifdef ALL_LOGS - for (int i = 0; i < 3; i++) { - LogDebug("HEX " << esc[i]); - } -#endif - return isHex((int) esc[1]) && isHex((int) esc[2]); -} - -bool Attribute::isHostAllowedString(const std::string * str) const -{ - bool result = true; - - if (digit[(int) str->at(0)]) { - //IPv4 address - result = isIPv4AllowedString(str); - } else { - //Hostname - result = isHostNameAllowedString(str); - } - - return result; -} - -bool Attribute::isIPv4AllowedString(const std::string * str) const -{ - LogDebug("Is hostIPv4 allowed String for " << *str); - - const char * data = str->c_str(); - bool result = true; - int digitCounter = 0; - int dotCounter = 0; - - for (unsigned int i = 0; i < str->length(); ++i) { - if (data[i] == '.') { - dotCounter++; - digitCounter = 0; - } else if (digit[(int) data[i]]) { - digitCounter++; - if ((digitCounter > 3) || !digitCounter) { - result = false; - break; - } - } else { - result = false; - break; - } - } - if (dotCounter != 3) { - result = false; - } - return result; -} - -bool Attribute::isHostNameAllowedString(const std::string * str) const -{ - LogDebug("Is hostname allowed String for " << *str); - - int lastPosition = 0; //the position of last dot + 1 - const char * data = str->c_str(); - bool finalDot = false; - size_t end = str->length(); - bool result = false; - - for (size_t i = 0; i < end; ++i) { - if (data[i] == '.') { - if (i == str->length() - 1) { //ending dot - //There can be a leading '.' int the hostm_name - finalDot = true; - break; - } else { - //we found domain label - if (!isDomainLabelAllowedString(data + lastPosition, i - - lastPosition)) { - result = false; - goto end; - } - lastPosition = i + 1; //Set position to position of last dot + 1 - } - } - } - - if (finalDot) { - //we have to rewind one position to check the rightmost string - //but only in case we find final dot - end--; - } - //Compare only the rightmost string aaa.bbbb.rightmostString. - result = isTopLabelAllowedString(data + lastPosition, end - lastPosition); - -end: - - if (result) { - LogInfo("Hostname is allowed"); - } else { - LogInfo("Hostname is NOT allowed"); - } - - return result; -} - -bool Attribute::isDomainLabelAllowedString(const char * data, - int length) const -{ - LogDebug( - "Is domain allowed String for " << data << " taking first " << - length << - " chars"); - - if (!isAlphanum((int) data[0]) || !isAlphanum((int) data[length - 1])) { - return false; - } - - for (int i = 0; i < length; i++) { - if ((!isAlphanum(data[i])) && !(data[i] == '-')) { - return false; - } - } - return true; -} - -bool Attribute::isTopLabelAllowedString(const char * data, - int length) const -{ - if ((!alpha[(int) data[0]]) || (!isAlphanum((int) data[length - 1]))) { - return false; - } - - for (int i = 1; i < length - 1; i++) { - if ((!isAlphanum(data[i])) && !(data[i] == '-')) { - return false; - } - } - return true; -} - -void printAttributes(const AttributeSet& attrs) -{ - if (attrs.empty()) { - LogWarning("Empty attribute set"); - } else { - LogDebug("PRINT ATTRIBUTES:"); - for (AttributeSet::const_iterator it = attrs.begin(); - it != attrs.end(); - ++it) - { - LogDebug("name: " << *(*it)->getName()); - } - } -} - -void printAttributes(const std::list & attrs) -{ - if (attrs.empty()) { - LogWarning("Empty attribute set"); - } else { - LogDebug("PRINT ATTRIBUTES:"); - for (std::list::const_iterator it = attrs.begin(); - it != attrs.end(); - ++it - ) { - LogDebug(*it); - } - } -} - -//KW const char * matchResultToString(Attribute::MatchResult result){ -//KW -//KW const char * ret = NULL; -//KW -//KW switch(result){ -//KW -//KW case Attribute::MRTrue: -//KW ret = "true"; -//KW break; -//KW case Attribute::MRFalse: -//KW ret = "false"; -//KW break; -//KW case Attribute::MRUndetermined: -//KW ret = "undetermined"; -//KW break; -//KW default: -//KW ret = "Wrong match result"; -//KW } -//KW -//KW return ret; -//KW -//KW } diff --git a/modules/ace/engine/CombinerImpl.cpp b/modules/ace/engine/CombinerImpl.cpp deleted file mode 100644 index ccc3c9b..0000000 --- a/modules/ace/engine/CombinerImpl.cpp +++ /dev/null @@ -1,445 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : CombinerImpl.cpp -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#include -#include - -#include -#include -#include - -const int CombinerImpl::DenyInt = 0, //mb jk changed the numbers !!!!!!!!!!!!!!!!! -CombinerImpl::UndeterminedInt = 1, //this one is added -CombinerImpl::PromptOneShotInt = 2, -CombinerImpl::PromptSessionInt = 3, -CombinerImpl::PromptBlanketInt = 4, -CombinerImpl::PermitInt = 5, -CombinerImpl::InapplicableInt = 6, -CombinerImpl::NotMatchingTargetInt = 7, -CombinerImpl::ErrorInt = 8; - -std::list * CombinerImpl::convertEffectsToInts( - const std::list * effects) -{ - std::list * intList = new std::list(); - for ( - std::list::const_iterator it = effects->begin(); - it != effects->end(); - ++it - ) { - switch (*it) { - case Deny: - intList->push_back(CombinerImpl::DenyInt); - break; - case Undetermined: //jk mb added - intList->push_back(CombinerImpl::UndeterminedInt); - break; - case Permit: - intList->push_back(CombinerImpl::PermitInt); - break; - case PromptBlanket: - intList->push_back(CombinerImpl::PromptBlanketInt); - break; - case PromptOneShot: - intList->push_back(CombinerImpl::PromptOneShotInt); - break; - case PromptSession: - intList->push_back(CombinerImpl::PromptSessionInt); - break; - case Inapplicable: - intList->push_back(CombinerImpl::InapplicableInt); - break; - case NotMatchingTarget: - intList->push_back(CombinerImpl::NotMatchingTargetInt); - break; - case Error: - intList->push_back(CombinerImpl::ErrorInt); - break; - default: - Assert(false && "Wrong effect"); - } - } - return intList; -} - -Effect CombinerImpl::convertIntToEffect(int intEffect) -{ - switch (intEffect) { - case DenyInt: - return Deny; - - case UndeterminedInt: //jk mb added - return Undetermined; - - case PermitInt: - return Permit; - - case PromptBlanketInt: - return PromptBlanket; - - case PromptOneShotInt: - return PromptOneShot; - - case PromptSessionInt: - return PromptSession; - - case InapplicableInt: - return Inapplicable; - - case NotMatchingTargetInt: - return NotMatchingTarget; - - case ErrorInt: - return Error; - - default: - Assert(false && "Wrong integer in int to Effect conversion"); - return Error; - } -} - -Effect CombinerImpl::denyOverrides(const std::list & effects) -{ - if (isError(effects)) { - return Error; - } - - std::list * intList = convertEffectsToInts(&effects); - - int result = InapplicableInt; //Deny has value 0, Undetermined value 1, Inapplicable value 6 - - std::list::const_iterator it = intList->begin(); - - while (it != intList->end()) { - int effect = *it; - //Use most restrictive policy always - result = effect < result ? effect : result; - ++it; - } - delete intList; - return convertIntToEffect(result); -} - -Effect CombinerImpl::permitOverrides(const std::list & effects) //mb jk modified -{ if (isError(effects)) { - return Error; - } - - int result = DenyInt; //Deny has value 0, Inapplicable value 5 - std::list * intList = convertEffectsToInts(&effects); - std::list::const_iterator it = intList->begin(); - - //Flag used to indicate that any of Deny,prompt-*,permit options appear - //Consequently if flag is true then result should be return, otherwise inapplicable should be returned - bool flag = false; - bool flagUndetermined = false; - - while (it != intList->end()) { - int effect = *it; - - if (effect == PermitInt) { - result = effect; - delete intList; - return convertIntToEffect(result); - } // no need for further check if "permit" found - if (effect == UndeterminedInt) { flagUndetermined = true; } //check for undetermined - - //Set the flag and the result even if effect is equal to result - //It is done to mark if any "Deny" effect occured - if (effect >= result && effect != InapplicableInt && effect != - UndeterminedInt) { //check for other results - result = effect; - flag = true; - } - - ++it; - } - delete intList; - - if (flagUndetermined) { - return Undetermined; - } - - if (!flag) { - return Inapplicable; - } - return convertIntToEffect(result); -} - -Effect CombinerImpl::firstApplicable(const std::list & effects) //jk mb modified to comply with BONDI 1.0 ("undetermined" handling) -{ std::list::const_iterator it = effects.begin(); - - if (isError(effects)) { - return Error; - } - - for (; it != effects.end(); ++it) { - if (*it != InapplicableInt) { - return *it; - } - } - return Inapplicable; -} - -Effect CombinerImpl::firstMatchingTarget(const std::list & effects) -{ - if (isError(effects)) { - return Error; - } - // effect list constains result of policies which target has been matched. - // - // If target does not match policy result is NotMatchingTarget - // NotMatchingTarget values are not stored on the effects list - // (you can check it in combinePolicies function). - // - // So we are intrested in first value on the list. - return effects.empty() ? Inapplicable : effects.front(); -} - -bool CombinerImpl::isError(const std::list & effects) -{ - FOREACH(it, effects) - { - if (Error == *it) { - return true; - } - } - return false; -} - -Effect CombinerImpl::combineRules(const TreeNode * policy) -{ - const Policy * policyObj = dynamic_cast(policy->getElement()); - if (!policyObj) { - LogError("dynamic_cast failed. PolicyObj is null."); - return Error; - } - - Policy::CombineAlgorithm algorithm = policyObj->getCombineAlgorithm(); - - Assert( - algorithm != Policy::FirstTargetMatching && - "Policy cannot have algorithm first target matching"); - - bool isUndetermined = false; - - if (!checkIfTargetMatches(policyObj->getSubjects(), isUndetermined)) { - if (isUndetermined) { - //TODO Target is undetermined what should we do now ?? - //Right now simply return NotMatchingTarget - } - //Target doesn't match - return NotMatchingTarget; - } - //Get all rules - const ChildrenSet & children = policy->getChildrenSet(); - ChildrenConstIterator it = children.begin(); - std::list effects; - - while (it != children.end()) { - const Rule * rule = dynamic_cast((*it)->getElement()); - - if (!rule) { - LogError("Error in dynamic_cast. rule is null"); - return Error; - } - - Effect effect = rule->evaluateRule(this->getAttributeSet()); - effects.push_back(effect); - if (algorithm == Policy::FirstApplicable && effect != Inapplicable) { - //For first applicable algorithm we may stop after evaluating first policy - //which has effect other than inapplicable - break; - } - ++it; - } //end policy children iteration - - //Use combining algorithm - Effect ef = combine(policyObj->getCombineAlgorithm(), effects); - return ef; -} - -//WARNING this method makes an assumption that Policy target is a policy child -Effect CombinerImpl::combinePolicies(const TreeNode * policy) -{ - const Policy * policySet = dynamic_cast(policy->getElement()); - - if (!policySet) { - LogError("dynamic_cast failed. Policy set is null."); - return Error; - } - - bool isUndetermined = false; - Policy::CombineAlgorithm algorithm = policySet->getCombineAlgorithm(); - - if (!checkIfTargetMatches(policySet->getSubjects(), isUndetermined)) { - /* I can't explain this... - if (isUndetermined) { - if (algorithm == Policy::FirstTargetMatching) { - return Undetermined; - } - } - */ - //Target doesn't match - return NotMatchingTarget; - } - - const ChildrenSet & children = policy->getChildrenSet(); - - ChildrenConstIterator it = children.begin(); - - std::list effects; - - while (it != children.end()) { - Effect effect; - - if ((*it)->getTypeID() == TreeNode::PolicySet) { - effect = combinePolicies(*it); - if (effect != NotMatchingTarget) { - effects.push_back(effect); - } - } else if ((*it)->getTypeID() == TreeNode::Policy) { - effect = combineRules(*it); - if (effect != NotMatchingTarget) { - effects.push_back(effect); - } - } else { - // [CR] fix it - LogError("effect value is not initialized!"); - return Error; - } - - if (algorithm == Policy::FirstTargetMatching && effect != - NotMatchingTarget) { - //In First matching target algorithm we may return when first result is found - break; - } - ++it; - } - - //Use combining algorithm - Effect ef = combine(policySet->getCombineAlgorithm(), effects); - return ef; -} - -Effect CombinerImpl::combine(Policy::CombineAlgorithm algorithm, - std::list & effects) -{ - LogDebug("Effects to be combined with algorithm: " << toString(algorithm)); - showEffectList(effects); - - switch (algorithm) { - case Policy::DenyOverride: - return denyOverrides(effects); - break; - case Policy::PermitOverride: - return permitOverrides(effects); - break; - case Policy::FirstApplicable: - return firstApplicable(effects); - break; - case Policy::FirstTargetMatching: - return firstMatchingTarget(effects); - break; - default: - Assert(false && "Wrong combining algorithm used"); - return Error; - } -} - -/** - * - * @param attrSet set of Subject attributes in policy that identifies target - * @return true if target is determined and matches, false and isUndertmined is set to true if the target is undetermined - * false and isUndetermined set to false if target is determined but doesn't match - */ -bool CombinerImpl::checkIfTargetMatches( - const std::list * subjectsList, - bool &isUndetermined) -{ - if (subjectsList->empty()) { - return true; - } - - std::list::const_iterator it = subjectsList->begin(); - bool match = false; - //According to BONDI 1.0 at least one target must match - while (it != subjectsList->end()) { - match = (*it)->matchSubject(this->getAttributeSet(), isUndetermined); - if (match) { //at least one match - break; - } - ++it; - } - - #ifdef _DEBUG - if (match == Attribute::MRTrue) { - LogDebug("Target matches "); - } else if (match == Attribute::MRUndetermined) { - LogDebug("Target match undetermined "); - } else { - LogDebug("Target doesn't match"); - } - #endif - return match; -} - -const char * toString(Effect effect) -{ - const char * temp = ""; - - switch (effect) { - case Deny: - temp = "Deny"; - break; - case Undetermined: - temp = "Undetermined"; - break; - case PromptOneShot: - temp = "PromptOneShot"; - break; - case PromptSession: - temp = "PromptSession"; - break; - case PromptBlanket: - temp = "PromptBlanket"; - break; - case Permit: - temp = "Permit"; - break; - case Inapplicable: - temp = "Inapplicable"; - break; - case NotMatchingTarget: - temp = "NotMatchingTarget"; - break; - case Error: - temp = "Error"; - break; - default: - Assert(false && "Wrong effect"); - } - return temp; -} diff --git a/modules/ace/engine/Condition.cpp b/modules/ace/engine/Condition.cpp deleted file mode 100644 index 739e58a..0000000 --- a/modules/ace/engine/Condition.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// File: Condition.cpp -// Author: notroot -// -// Created on June 3, 2009, 9:00 AM -// - -#include -#include -#include -#include -#include - -/** - * Check if attribute in condition matches the values obtained from PIP - * attrSet - attributes from PIP - */ - -Attribute::MatchResult Condition::evaluateCondition( - const AttributeSet * attrSet) const -{ - //Condition may include either matches of attributes or other conditions - //in this method all attributes are matched at first and if possible the - //condition is evaluated. If evaluation is not possible based solely on - //attributes then we start recursion into child conditions. - - Attribute::MatchResult match; - bool undeterminedMatchFound = false; - bool isFinalMatch = false; - - LogDebug("Attributes to be matched"); - printAttributes(*attrSet); - LogDebug("Condition attributes values"); - printAttributes(attributes); - - if (this->isEmpty()) { - LogDebug("Condition is empty, returning true"); - //Condition is empty, it means it evaluates to TRUE - return Attribute::MatchResult::MRTrue; - } - - match = evaluateAttributes(attrSet, isFinalMatch, undeterminedMatchFound); - if (isFinalMatch) { - LogDebug("Evaluate attributes returning verdict" ) ; //<< match); - return match; - } - - match = evaluateChildConditions(attrSet, - isFinalMatch, - undeterminedMatchFound); - if (isFinalMatch) { - LogDebug("Evaluate child conditions returning verdict" ); // << match); - return match; - } - - if (undeterminedMatchFound) { - //If any child condition/attribute-match was undetermined and - //so far we couldn't make a decision then we must return undetermined - LogDebug("Evaluate condition returning MRUndetermined"); - return Attribute::MatchResult::MRUndetermined; - } - - if (this->isAndCondition()) { - match = Attribute::MatchResult::MRTrue; - } else if (this->isOrCondition()) { - match = Attribute::MatchResult::MRFalse; - } else { - Assert(false && "Condition has to be either AND or OR"); - } - return match; -} - -// KW Attribute::MatchResult Condition::performORalgorithm(const std::set* attrSet) const{ -// KW -// KW Attribute::MatchResult match; -// KW bool undeterminedMatchFound = false; -// KW bool isFinalMatch = false; -// KW -// KW LogDebug("Performing OR algorithm"); -// KW -// KW match = evaluateAttributes(attrSet, isFinalMatch, undeterminedMatchFound); -// KW if(isFinalMatch){ -// KW LogDebug("OR algorithm evaluate attributes returning verdict" << match); -// KW return match; -// KW } -// KW -// KW match = evaluateChildConditions(attrSet, isFinalMatch, undeterminedMatchFound); -// KW if(isFinalMatch){ -// KW return match; -// KW } -// KW -// KW if(undeterminedMatchFound){ -// KW //If any child condition/attribute-match was undetermined and -// KW //so far we couldn't make a decision then we must return undetermined -// KW LogDebug("OR algorithm returning MRUndetermined"); -// KW return Attribute::MRUndetermined; -// KW } -// KW -// KW LogDebug("OR algorithm returning MRFalse"); -// KW return Attribute::MRFalse; -// KW } - -// KW Attribute::MatchResult Condition::performANDalgorithm(const std::set* attrSet) const{ -// KW -// KW -// KW Attribute::MatchResult match; -// KW bool undeterminedMatchFound = false; -// KW bool isFinalMatch = false; -// KW -// KW LogDebug("Performing AND algorithm"); -// KW match = evaluateAttributes(attrSet, isFinalMatch, undeterminedMatchFound); -// KW if(isFinalMatch){ -// KW LogDebug("AND algorithm evaluate attributes returning verdict" << match); -// KW return match; -// KW } -// KW match = evaluateChildConditions(attrSet, isFinalMatch, undeterminedMatchFound); -// KW if(isFinalMatch){ -// KW LogDebug("AND algorithm evaluate child returning verdict " << match); -// KW return match; -// KW } -// KW if(undeterminedMatchFound){ -// KW //If any child condition/attribute-match was undetermined and -// KW //so far we couldn't make a decision then we must return undetermined -// KW LogDebug("AND algorithm returning Undetermined"); -// KW return Attribute::MRUndetermined; -// KW } -// KW -// KW LogDebug("AND algorithm returning MRTrue"); -// KW return Attribute::MRTrue; -// KW -// KW } - -Attribute::MatchResult Condition::evaluateAttributes( - const AttributeSet * attrSet, - bool& isFinalMatch, - bool & undeterminedMatchFound) const -{ - Attribute::MatchResult match = Attribute::MatchResult::MRUndetermined; - - std::list::const_iterator condIt = this->attributes.begin(); - while (condIt != this->attributes.end()) { - //Find the value of needed attribute, based on attribute name - AttributeSet::const_iterator attr = - std::find_if(attrSet->begin(), - attrSet->end(), - AceDB::BaseAttribute::UnaryPredicate(&(*condIt))); - if (attr == attrSet->end()) { - LogError("Couldn't find required attribute. This should not happen"); - Assert( - false && - "Couldn't find attribute required in condition. This should not happen" - "This means that some attributes has not been obtained from PIP"); - //Return undetermined here because it seems one of the attributes is unknown/undetermined - isFinalMatch = true; - match = Attribute::MatchResult::MRUndetermined; - break; - } - - match = condIt->matchAttributes(&(*(*attr))); - if ((match == Attribute::MatchResult::MRFalse) && isAndCondition()) { - //FALSE match found in AND condition - isFinalMatch = true; - break; - } else if ((match == Attribute::MatchResult::MRTrue) && isOrCondition()) { - //TRUE match found in OR condition - isFinalMatch = true; - break; - } else if (match == Attribute::MatchResult::MRUndetermined) { - //Just mark that there was undetermined value found - undeterminedMatchFound = true; - } - ++condIt; - } - - return match; -} - -Attribute::MatchResult Condition::evaluateChildConditions( - const AttributeSet * attrSet, - bool& isFinalMatch, - bool & undefinedMatchFound) const -{ - Attribute::MatchResult match = Attribute::MatchResult::MRUndetermined; - - std::list::const_iterator it = conditions.begin(); - while (it != conditions.end()) { - match = it->evaluateCondition(attrSet); - - if ((match == Attribute::MatchResult::MRFalse) && isAndCondition()) { - //FALSE match found in AND condition - LogDebug("Child conditions results MRFalse)"); - isFinalMatch = true; - break; - } else if ((match == Attribute::MatchResult::MRTrue) && isOrCondition()) { - //TRUE match found in OR condition - LogDebug("Child conditions result MRTrue"); - isFinalMatch = true; - break; - } else if (match == Attribute::MatchResult::MRUndetermined) { - undefinedMatchFound = true; - } - ++it; - } - - return match; -} - -void Condition::getAttributes(AttributeSet * attrSet) -{ - //Get attributes from current condition - FOREACH (it, attributes) - { - AceDB::BaseAttributePtr attr(new Attribute(it->getName(), it->getMatchFunction(), it->getType())); - attrSet->insert(attr); - } - //Get attributes from any child conditions - FOREACH (it, conditions) - { - it->getAttributes(attrSet); - } -} - -Condition::Condition(std::istream& is, - Condition* parent) -{ - Serializer* serializer = Serializer::getInstance(); - - //Condition is a object in class - if (parent != NULL) { - this->parent = parent; - } else { - this->parent = NULL; - } - - conditions = serializer->deserializeListConditions(is, this); - combineType = serializer->deserializeCombineType(is); - attributes = serializer->deserializeListAttributes(is); -} - -bool Condition::serialize(std::ostream& os) -{ - Serializer* serializer = Serializer::getInstance(); - - serializer->serializeListConditions(os, conditions); - serializer->serializeCombineType(os, combineType); - serializer->serializeListAttributes(os, attributes); - - return 0; -} - diff --git a/modules/ace/engine/ConfigurationManager.cpp b/modules/ace/engine/ConfigurationManager.cpp deleted file mode 100644 index 9cc7cd7..0000000 --- a/modules/ace/engine/ConfigurationManager.cpp +++ /dev/null @@ -1,422 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace { -const string currentXMLSchema("bondixml.xsd"); -} - -ConfigurationManager * ConfigurationManager::instance = NULL; - -string ConfigurationManager::getCurrentPolicyFile(void) const -{ - return currentPolicyFile; -} - -string ConfigurationManager::getFullPathToCurrentPolicyFile(void) const -{ - if (*(storagePath.rbegin()) == '/') { - return storagePath + currentPolicyFile; - } - return storagePath + "/" + currentPolicyFile; -} - -string ConfigurationManager::getStoragePath(void) const -{ - return storagePath; -} - -string ConfigurationManager::getFullPathToCurrentPolicyXMLSchema() const -{ - if (*(storagePath.rbegin()) == '/') - { - return storagePath + currentXMLSchema; - } - return storagePath + "/" + currentXMLSchema; -} - -int ConfigurationManager::parse(const string &configFileName) -{ - configFile = configFileName; - int error = PARSER_SUCCESS; - policyFiles.clear(); - - reader = xmlNewTextReaderFilename(configFile.c_str()); - - if (reader == NULL) { - LogError("Parser does not exist"); - error = PARSER_ERROR; - goto cleanUp; - } - - if (xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1)) { - LogError("Error while setting parser validating."); - error = PARSER_ERROR; - Assert(false && "Cannot make XML parser validating"); - goto cleanUp; - } - - if (xmlTextReaderSetParserProp(reader, XML_PARSER_DEFAULTATTRS, 1)) { - LogError("Error while attribute defaulting."); - error = PARSER_ERROR; - Assert(false && "XML Parser cannot default xml attributes"); - goto cleanUp; - } - - int ret; - while (1 == (ret = xmlTextReaderRead(reader))) { - processNode(); - if (xmlTextReaderIsValid(reader) == 0) { - LogError( - "Parser error while reading file " << configFile << - ". File is not valid."); - error = PARSER_ERROR; - Assert(false && "Configuration Manager error"); - goto cleanUp; - } - } - if (ret != 0) { - LogError("There were some errors while parsing XML file."); - } - -cleanUp: - if (reader != NULL) { - xmlFreeTextReader(reader); - } - return error; -} - -void ConfigurationManager::extractFileAttributes() -{ - xmlChar *active = xmlTextReaderGetAttribute(reader, ATTR_ACTIVE_POLICY); - xmlActive = false; - - if (active && active[0] == 't') { - xmlActive = true; - } - - xmlFree(active); -} - -void ConfigurationManager::startNodeHandler(void) -{ - xmlChar *name = xmlTextReaderName(reader); - switch (*name) { - case 'f': // file - extractFileAttributes(); - break; - default: - break; - } - xmlFree(name); -} - -void ConfigurationManager::endNodeHandler(void) -{ - xmlChar *name = xmlTextReaderName(reader); - switch (*name) { - case 'f': - policyFiles.push_back(currentText); - if (xmlActive) { - currentPolicyFile = currentText; - xmlActive = false; - } - currentText.clear(); - break; - case 's': - storagePath = currentText; - currentText.clear(); - break; - default: - break; - } - xmlFree(name); -} - -void ConfigurationManager::textNodeHandler(void) -{ - xmlChar *text = xmlTextReaderValue(reader); - currentText = reinterpret_cast(text); - xmlFree(text); -} - -void ConfigurationManager::processNode(void) -{ - xmlReaderTypes type = - static_cast(xmlTextReaderNodeType(reader)); - switch (type) { - case XML_READER_TYPE_ELEMENT: startNodeHandler(); - break; - case XML_READER_TYPE_END_ELEMENT: endNodeHandler(); - break; - case XML_READER_TYPE_TEXT: textNodeHandler(); - break; - default: - break; - } -} - -int ConfigurationManager::addPolicyFile(const string & sourcePath) -{ - FILE * sourceFd = NULL, *destFd = NULL; - int flag = CM_OPERATION_SUCCESS; - int sourceLength; - string fileName; - - string newFilePath(getStoragePath()); - newFilePath.append("/"); - - if (sourcePath.empty()) { - LogError("Filename empty"); - flag = CM_GENERAL_ERROR; - goto cleanup; - } - - fileName = extractFilename(sourcePath); - newFilePath.append(fileName); - - LogDebug("Adding new file " << newFilePath); - if (checkIfFileExistst(newFilePath)) { - LogError("Destination file already exists"); - flag = CM_FILE_EXISTS; - goto cleanup; - } - - sourceFd = fopen(sourcePath.c_str(), "r"); - if (sourceFd == NULL) { - LogError("Source file opening failed"); - flag = CM_GENERAL_ERROR; - goto cleanup; - } - - destFd = fopen(newFilePath.c_str(), "w"); - if (destFd == NULL) { - LogError("Destination file creation failed"); - flag = CM_GENERAL_ERROR; - goto cleanup; - } - - if (0 > (sourceLength = getFileSize(sourcePath))) { - LogError("getFileSize error"); - flag = CM_GENERAL_ERROR; - goto cleanup; - } - - if (!copyFile(sourceFd, destFd, sourceLength)) { - //Copying failed, we have to remove corrupted file - flag = CM_GENERAL_ERROR; - if (removePolicyFile(newFilePath) != CM_OPERATION_SUCCESS) { - flag = CM_REMOVE_ERROR; - } - goto cleanup; - } - policyFiles.push_back(fileName); - - if (saveConfig() != CM_OPERATION_SUCCESS) { - LogError("Error while saving policy file"); - //TODO HOW TO ROLLBACK save config? - } - -cleanup: - - if (sourceFd) { - fclose(sourceFd); - } - if (destFd) { - fclose(destFd); - } - - return flag; -} - -int ConfigurationManager::removePolicyFile(const string& file) -{ - LogDebug("Trying to remove policy " << file); - int errorFlag = CM_OPERATION_SUCCESS; - string fileName = extractFilename(file); - string filePath(CONFIGURATION_MGR_TEST_POLICY_STORAGE); - - if (fileName == currentPolicyFile) { - errorFlag = CM_REMOVE_CURRENT; - LogError("Cannot remove current policy"); - goto end; - } - - filePath.append("/").append(fileName); - - if (remove(filePath.c_str()) != 0) { - if (checkIfFileExistst(filePath)) { - errorFlag = CM_REMOVE_ERROR; - LogError("Cannot delete file" << filePath); - goto end; - } - LogError("Cannot delete file" << filePath << " the file doesn't exist"); - errorFlag = CM_REMOVE_NOT_EXISTING; - } else { - errorFlag = CM_OPERATION_SUCCESS; - } - //If remove was successful or unsuccessful but file doesn't exists then it - //should be removed from the list of available policies - policyFiles.remove(fileName); - -end: - return errorFlag; -} - -string ConfigurationManager::extractFilename(const string & sourcePath) const -{ - //begining of filename without path - size_t filenamePos = sourcePath.rfind('/'); - - string tmp; - if (filenamePos == string::npos) { - tmp = sourcePath; - } else { - tmp = sourcePath.substr(filenamePos + 1); - } - LogDebug("Extracted filename " << tmp); - return tmp; -} - -int ConfigurationManager::getFileSize(const string & path) const -{ - //get source file size - struct stat sourceStat; - int sourceLength; - if (stat(path.c_str(), &sourceStat) == -1) { - LogError("Reading file properties failed"); - sourceLength = -1; - } else { - sourceLength = sourceStat.st_size; - } - return sourceLength; -} - -bool ConfigurationManager::copyFile(FILE * sourceDesc, - FILE * destinationDesc, - int lenght) const -{ - int rv; - char *buffer = static_cast(malloc(lenght)); - bool result = true; - - if (!buffer) { - return false; - } - - while ((rv = fread(buffer, sizeof (char), lenght, sourceDesc)) > 0) { - if (rv != lenght) { - if (!feof(sourceDesc)) { - LogError("Error while reading file "); - result = false; - break; - } - } - - rv = fwrite(buffer, sizeof (char), lenght, destinationDesc); - if (rv != lenght) { - LogError("Write file failed "); - result = false; - break; - } - } - free(buffer); - return result; -} - -bool ConfigurationManager::checkIfFileExistst(const string & newFilePath) const -{ - bool exists = false; - struct stat stats; - if (stat(newFilePath.c_str(), &stats) == 0) { - exists = true; - } - return exists; -} - -int ConfigurationManager::changeCurrentPolicyFile(const std::string & fileName) -{ - int result = CM_OPERATION_SUCCESS; - string oldPolicyFile = currentPolicyFile; - - string filePath(getStoragePath() + "/"); - filePath += fileName; - - if (!checkIfFileExistst(filePath)) { - //Policy file doesn't exist - result = CM_GENERAL_ERROR; - LogError("Error: policy file " << filePath << " doesn't exist"); - goto end; - } - if (result == CM_OPERATION_SUCCESS) { - //Adding file to storage succeeded - currentPolicyFile = extractFilename(filePath); - //Try to save the configuration file - result = saveConfig(); - } - if (result != CM_OPERATION_SUCCESS) { - //rollback changes - currentPolicyFile = oldPolicyFile; - LogError("Error while saving policy file"); - //TODO HOW TO ROLLBACK save config? - } - -end: - return result; -} - -int ConfigurationManager::saveConfig() -{ - std::ofstream output(configFile.c_str()); - int errorFlag = CM_OPERATION_SUCCESS; - - output << "" << std::endl; - output << - "" << - std::endl; - output << "" << std::endl; - output << " " << storagePath << "" << - std::endl; - output << " " << std::endl; - for (list::const_iterator it = policyFiles.begin(); - it != policyFiles.end(); - ++it) { - output << "\t" << *it << "" << std::endl; - } - output << " \n"; - output << " "; - output.close(); - - //TODO should we add 'eof' here? - if (output.bad() || output.fail()) { - //There were some errors while writing to file - errorFlag = CM_GENERAL_ERROR; - } - - return errorFlag; -} diff --git a/modules/ace/engine/NodeFactory.cpp b/modules/ace/engine/NodeFactory.cpp deleted file mode 100644 index a0b93f1..0000000 --- a/modules/ace/engine/NodeFactory.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include - -NodeFactory* NodeFactory::pInstance = NULL; - -AbstractTreeElement* NodeFactory::create(std::istream& is, - TreeNode::TypeID id) -{ - AbstractTreeElement* node; - - switch (id) { - case TreeNode::Policy: - node = new Policy(is); - break; - case TreeNode::PolicySet: - node = new PolicySet(is); - break; - case TreeNode::Rule: - node = new Rule(is); - break; - default: - node = NULL; - break; - } - - return node; -} - -NodeFactory* NodeFactory::getInstance() -{ - if (pInstance == NULL) { - pInstance = new NodeFactory; - } - return pInstance; -} diff --git a/modules/ace/engine/Policy.cpp b/modules/ace/engine/Policy.cpp deleted file mode 100644 index 1b47a89..0000000 --- a/modules/ace/engine/Policy.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : Policy.cpp -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#include -#include - -Policy::Policy(std::istream& is) -{ - Serializer* serializer = Serializer::getInstance(); - - std::list* pList; - pList = serializer->deserializeListSubjects(is); - subjects = pList; - - combineAlgorithm = serializer->deserializeCombineAlgorithm(is); -} - -void Policy::serialize(std::ostream& os) -{ - Serializer* serializer = Serializer::getInstance(); - - serializer->serializeListSubjects(os, *subjects); - serializer->serializeCombineAlgorithm(os, combineAlgorithm); -} - -Policy::~Policy() -{ - for (std::list::iterator it = subjects->begin(); - it != subjects->end(); - ++it) { - delete *it; - } - delete subjects; -} - -void Policy::printData() -{ - std::string subject; - if (subjects != NULL && subjects->size()) { - subject = (subjects->front())->getSubjectId(); - } - std::string algorithm = printCombineAlgorithm(this->combineAlgorithm); - - std::cout << "subject: " << subject << " algorithm: " << algorithm << - std::endl; -} - -std::string Policy::printCombineAlgorithm(CombineAlgorithm algorithm) -{ - switch (algorithm) { - case DenyOverride: - return "DenyOverride"; - case PermitOverride: - return "PermitOverride"; - case FirstApplicable: - return "FirstApplicable"; - case FirstTargetMatching: - return "FirstTargetMatching"; - default: - return "ERROR: Wrong Algorithm"; - } -} - -const char * toString(Policy::CombineAlgorithm algorithm) -{ - switch (algorithm) { - case Policy::DenyOverride: - return "DenyOverride"; - case Policy::PermitOverride: - return "PermitOverride"; - case Policy::FirstApplicable: - return "FirstApplicable"; - case Policy::FirstTargetMatching: - return "FirstTargetMatching"; - default: - return "ERROR: Wrong Algorithm"; - } -} diff --git a/modules/ace/engine/PolicyEnforcementPoint.cpp b/modules/ace/engine/PolicyEnforcementPoint.cpp deleted file mode 100644 index d593f02..0000000 --- a/modules/ace/engine/PolicyEnforcementPoint.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file security_logic.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @author Ming Jin(ming79.jin@samsung.com) - * @version 1.0 - * @brief Implementation file for security logic - */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -using namespace WrtDB; - -PolicyEnforcementPoint::PolicyEnforcementPoint() : - m_wrt(0), - m_res(0), - m_sys(0), - m_pdp(0), - m_pip(0) -{} - -void PolicyEnforcementPoint::terminate() -{ - LogInfo("PolicyEnforcementPoint is being deinitialized."); - - delete m_sys; - delete m_res; - delete m_wrt; - delete m_pdp; - delete m_pip; - m_sys = 0; - m_res = 0; - m_wrt = 0; - m_pdp = 0; - m_pip = 0; -} - -PolicyEnforcementPoint::~PolicyEnforcementPoint() -{ - Assert((m_sys == 0) && "You must run " - "PolicyEnforcementPoint::Deinitialize before exit program!"); -} - -void PolicyEnforcementPoint::initialize( - IWebRuntime *wrt, - IResourceInformation *resource, - IOperationSystem *operation) -{ - if (m_wrt) { - ThrowMsg(PEPException::AlreadyInitialized, - "Policy Enforcement Point is already initialzed"); - } - - m_wrt = wrt; - m_res = resource; - m_sys = operation; - - if (this->m_pip != NULL) { - this->m_pip->update(m_wrt, m_res, m_sys); - return; - } - - this->m_pip = new PolicyInformationPoint(wrt, m_res, m_sys); - this->m_pdp = new PolicyEvaluator(m_pip); - - if (!this->m_pdp->initPDP()) { - Assert(0); - } -} - -PolicyResult PolicyEnforcementPoint::check(Request &request) -{ - return m_pdp->getPolicyForRequest(request); -} - -void PolicyEnforcementPoint::updatePolicy(const std::string &policy) -{ - LogDebug("ACE updatePolicy: " << policy); - int errorCode = 0; - - if (m_pdp == NULL) { - LogError("Evaluator not set. Ignoring message."); - Assert(false && "UpdateClient error on receiving event"); - } else { - LogDebug("Emitting update signal."); - errorCode = m_pdp->updatePolicy(policy.c_str()); - } - - LogDebug("Sending reponse: " << errorCode); -} - -OptionalPolicyResult PolicyEnforcementPoint::checkFromCache(Request &request) -{ - return m_pdp->getPolicyForRequestFromCache(request); - // return OptionalPolicyResult(); -} - -OptionalPolicyResult PolicyEnforcementPoint::check(Request &request, - bool fromCacheOnly) -{ - return m_pdp->getPolicyForRequest(request, fromCacheOnly); - // return OptionalPolicyResult(); -} diff --git a/modules/ace/engine/PolicyEvaluator.cpp b/modules/ace/engine/PolicyEvaluator.cpp deleted file mode 100644 index 609d0fc..0000000 --- a/modules/ace/engine/PolicyEvaluator.cpp +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : PolicyEvaluator.cpp -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#include -#include - -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include - -using namespace AceDB; - -PolicyEvaluator::~PolicyEvaluator() -{ - delete m_combiner; -} - -bool PolicyEvaluator::initPDP() -{ - ConfigurationManager * configMgr = ConfigurationManager::getInstance(); - if (configMgr == NULL) { - LogError("ACE fatal error: failed to create configuration manager"); - return false; - } - - Parser parser; - m_root = parser.parse( - configMgr->getFullPathToCurrentPolicyFile(), - configMgr->getFullPathToCurrentPolicyXMLSchema()); - - if (NULL == m_root) { - LogError("ACE fatal error: cannot parse XML file"); - } - - return true; -} - -bool PolicyEvaluator::fillAttributeWithPolicy() -{ - if (m_attributeSet.empty()) { - if (!extractAttributes()) { - LogInfo( - "Warning attribute set cannot be extracted. Returning Deny"); - return false; - } - } else { - LogDebug("Required attribute set found in database"); - } - return true; -} - -PolicyResult PolicyEvaluator::effectToPolicyResult(Effect effect){ - if (Effect::Deny == effect) { - return PolicyEffect::DENY; - } - if (Effect::Undetermined == effect) { - return PolicyResult::Value::UNDETERMINED; - } - if (Effect::PromptOneShot == effect) { - return PolicyEffect::PROMPT_ONESHOT; - } - if (Effect::PromptSession == effect) { - return PolicyEffect::PROMPT_SESSION; - } - if (Effect::PromptBlanket == effect) { - return PolicyEffect::PROMPT_BLANKET; - } - if (Effect::Permit == effect) { - return PolicyEffect::PERMIT; - } - if (Effect::Inapplicable == effect) { - return PolicyDecision::Value::NOT_APPLICABLE; - } - return PolicyEffect::DENY; -} - -OptionalPolicyResult PolicyEvaluator::getPolicyForRequestInternal(bool fromCacheOnly) -{ - //ADD_PROFILING_POINT("Search cached verdict in database", "start"); - - OptionalPolicyResult result = AceDAO::getPolicyResult( - m_attributeSet); - - //ADD_PROFILING_POINT("Search cached verdict in database", "stop"); - - if (fromCacheOnly || !result.IsNull()) { - return result; - } - - //ADD_PROFILING_POINT("EvaluatePolicy", "start"); - - Effect policyEffect = evaluatePolicies(m_root); - - //ADD_PROFILING_POINT("EvaluatePolicy", "stop"); - - LogDebug("Policy effect is: " << toString(policyEffect)); - - result = effectToPolicyResult(policyEffect); - - AceDAO::setPolicyResult(this->m_attributeSet, *result); - return result; -} - -// +----------------+---------+---------+------+--------+ -// |\User setting | PERMIT | PROMPT* | DENY | DEF | -// | \ | | | | | -// |Policy result\ | | | | | -// |----------------+---------+---------+------+--------+ -// |PERMIT | PERMIT | PROMPT* | DENY | PERMIT | -// |----------------+---------+---------+------+--------+ -// |PROMPT* | PROMPT* | PR MIN | DENY | PROMPT*| -// |----------------+---------+---------+------+--------+ -// |DENY | DENY | DENY | DENY | DENY | -// |----------------+---------+---------+------+--------+ -// |UNDETERMIND | UNDET | UNDET | DENY | UNDET | -// |----------------+---------+---------+------+--------+ -// |NOT_AP | PEMIT | PROMPT* | DENY | NOT_AP | -// +----------------+---------+---------+------+--------+ - -static PolicyResult getMostRestrict(PreferenceTypes globalPreference, - const PolicyResult &policyResult) -{ - if (globalPreference == PreferenceTypes::PREFERENCE_PERMIT && - policyResult == PolicyEffect::PERMIT) - { - return PolicyEffect::PERMIT; - } - - if (globalPreference == PreferenceTypes::PREFERENCE_DENY || - policyResult == PolicyEffect::DENY) - { - return PolicyEffect::DENY; - } - - if (policyResult == PolicyResult::UNDETERMINED) { - return PolicyResult::UNDETERMINED; - } - - if (globalPreference == PreferenceTypes::PREFERENCE_DEFAULT) - { - return policyResult; - } - - if (globalPreference == PreferenceTypes::PREFERENCE_ONE_SHOT_PROMPT || - policyResult == PolicyEffect::PROMPT_ONESHOT) - { - return PolicyEffect::PROMPT_ONESHOT; - } - - if (globalPreference == PreferenceTypes::PREFERENCE_SESSION_PROMPT || - policyResult == PolicyEffect::PROMPT_SESSION) - { - return PolicyEffect::PROMPT_SESSION; - } - - if (globalPreference == PreferenceTypes::PREFERENCE_BLANKET_PROMPT || - policyResult == PolicyEffect::PROMPT_BLANKET) - { - return PolicyEffect::PROMPT_BLANKET; - } - - return PolicyEffect::PERMIT; -} - -OptionalPolicyResult PolicyEvaluator::getPolicyForRequestFromCache( - const Request &request) -{ - return getPolicyForRequest(request, true); -} - -PolicyResult PolicyEvaluator::getPolicyForRequest(const Request &request) -{ - auto result = this->getPolicyForRequest(request, false); - Assert(!result.IsNull() && - "Policy always has to be evaluated to valid state"); - return *result; -} - -OptionalPolicyResult PolicyEvaluator::getPolicyForRequest( - const Request &request, - bool fromCacheOnly) -{ - //ADD_PROFILING_POINT("getPolicyForRequest", "start"); - m_attributeSet.clear(); - - try { - // Check which attributes should be used - // memory alocated, free in destructor - //ADD_PROFILING_POINT("getAttributes", "start"); - AceDB::AceDAO::getAttributes(&m_attributeSet); - //ADD_PROFILING_POINT("getAttributes", "stop"); - - // If attributes can't be resolved then check the policy - if (!fillAttributeWithPolicy()) { - //ADD_PROFILING_POINT("getPolicyForRequest", "stop"); - return OptionalPolicyResult(PolicyEffect::DENY); - } - - //ADD_PROFILING_POINT("getAttributesValues", "start"); - m_pip->getAttributesValues(&request, &m_attributeSet); - //ADD_PROFILING_POINT("getAttributesValues", "stop"); - LogDebug("==== Attributes set by PIP ===="); - printAttributes(m_attributeSet); - LogDebug("==== End of attributes set by PIP ===="); - - OptionalPolicyResult policyResult = - getPolicyForRequestInternal(fromCacheOnly); - - LogDebug("==== getPolicyForRequestInternal result (PolicyResult): " - << policyResult << "====="); - - if (policyResult.IsNull()) { - if (fromCacheOnly) { - return OptionalPolicyResult::Null; - } else { - LogError("Policy evaluated to NULL value"); - Assert(false && "Policy evaluated to NULL value"); - return OptionalPolicyResult::Null; - } - } - - PreferenceTypes globalPreference = - SettingsLogic::findGlobalUserSettings(request); - - auto ret = getMostRestrict(globalPreference, *policyResult); - //ADD_PROFILING_POINT("getPolicyForRequest", "stop"); - return OptionalPolicyResult(ret); - - } catch (AceDB::AceDAO::Exception::DatabaseError &e) { - LogError("Database error"); - DPL::Exception::DisplayKnownException(e); - //ADD_PROFILING_POINT("getPolicyForRequest", "stop"); - return OptionalPolicyResult(PolicyEffect::DENY); - } -} - - -bool PolicyEvaluator::extractAttributes() -{ - if (m_root == NULL) { - return false; - } - - //We check if root target matches. In general the root's target should be empty - //Otherwise it would have to have all the subjects available specified - //But just to be on the safe side ( and for tests) add this checking - const Policy * policy = dynamic_cast(m_root->getElement()); - Assert( - policy != NULL && - "Policy element has been null while attribute extracting"); - - extractTargetAttributes(policy); - extractAttributesFromSubtree(m_root); //Enter recursion - - return true; -} - -void PolicyEvaluator::extractTargetAttributes(const Policy *policy) -{ - std::list::const_iterator it = - policy->getSubjects()->begin(); - for (; it != policy->getSubjects()->end(); ++it) - { - const std::list & attrList = (*it)->getTargetAttributes(); - FOREACH(it2, attrList) - { - BaseAttributePtr attr(new Attribute((*it2).getName(), - (*it2).getMatchFunction(), (*it2).getType())); - m_attributeSet.insert(attr); - } - } -} - -/** - * - * @param *root - the root of the original (full) subtree of politics - * @param *newRoot - the pointer to the root of the copy (reduced) subtree of politics - */ -void PolicyEvaluator::extractAttributesFromSubtree(const TreeNode *root) -{ - const ChildrenSet & children = root->getChildrenSet(); - - for ( - std::list::const_iterator it = children.begin(); - it != children.end(); - ++it - ) { - TreeNode * node = *it; - if (node->getTypeID() != TreeNode::Policy && node->getTypeID() != - TreeNode::PolicySet) { - //It is not a policy so we may be sure that we have already checked that SubjectId matches - //Add new node to new tree and extract attributes - - extractAttributesFromRules(node); - } else { //TreeNode is a Policy or PolicySet - const Policy * policy = - dynamic_cast(node->getElement()); - //We will be needing also the attributes from target - if (policy) { - extractTargetAttributes(policy); - } else { - LogError(" extractAttributesFromSubtree policy=NULL"); - } - //Enter recursion - extractAttributesFromSubtree(node); - } - } -} - -bool PolicyEvaluator::extractAttributesFromRules(const TreeNode *root) -{ - Assert( - root->getTypeID() == TreeNode::Rule - && - "Tree structure, extracting attributes from node that is not a rule"); - Rule * rule = dynamic_cast(root->getElement()); - Assert(rule != NULL); - //Get attributes from rule - rule->getAttributes(&m_attributeSet); - - //[CR] consider returned value, because its added only to eliminate errors - return true; -} - -Effect PolicyEvaluator::evaluatePolicies(const TreeNode * root) -{ - if (root == NULL) { - LogInfo("Error: policy tree doesn't exist. " - "Probably xml file is missing"); - return Deny; - } - - if (m_attributeSet.empty()) { - LogInfo("Warning: evaluatePolicies: attribute set was empty"); - } - m_combiner->setAttributeSet(&m_attributeSet); - return m_combiner->combinePolicies(root); -} - -int PolicyEvaluator::updatePolicy(const char* newPolicy) -{ - ConfigurationManager* configMgr = ConfigurationManager::getInstance(); - - if (NULL == configMgr) { - LogError("ACE fatal error: failed to create configuration manager"); - return POLICY_PARSING_ERROR; - } - - int result = POLICY_PARSING_SUCCESS; - if (newPolicy == NULL) { - LogError("Policy Update: incorrect policy name"); - return POLICY_FILE_ERROR; - } - LogDebug("Starting update policy: " << newPolicy); - - Parser parser; - TreeNode *backup = m_root; - - m_root = parser.parse( - newPolicy, - configMgr->getFullPathToCurrentPolicyXMLSchema()); - - if (NULL == m_root) { - m_root = backup; - LogError("Policy Update: corrupted policy file"); - result = POLICY_PARSING_ERROR; - } else { - m_currentPolicyFile = newPolicy; - backup->releaseResources(); - LogInfo("Policy Update: successful."); - try { - AceDAO::resetDatabase(); - } catch (AceDAO::Exception::DatabaseError &e) { - } - } - return result; -} - -std::string PolicyEvaluator::getCurrentPolicy(){ - return m_currentPolicyFile; -} - -const char * toString(Validity validity) -{ - switch (validity) { - case Validity::ONCE: - return "Once"; - break; - case Validity::SESSION: - return "Session"; - case Validity::ALWAYS: - return "Always"; - default: - return "WRONG VALIDITY"; - } -} - -const char * toString(Verdict verdict) -{ - switch (verdict) { - case Verdict::VERDICT_PERMIT: - return "Permit"; - case Verdict::VERDICT_DENY: - return "Deny"; - case Verdict::VERDICT_INAPPLICABLE: - return "Inapplicable"; - case Verdict::VERDICT_UNKNOWN: - return "Unknown"; - case Verdict::VERDICT_UNDETERMINED: - return "Undetermined"; - case Verdict::VERDICT_ERROR: - return "Error"; - case Verdict::VERDICT_ASYNC: - return "Async"; - default: - return "Wrong verdict value"; - } -} diff --git a/modules/ace/engine/PolicyInformationPoint.cpp b/modules/ace/engine/PolicyInformationPoint.cpp deleted file mode 100644 index 8727d30..0000000 --- a/modules/ace/engine/PolicyInformationPoint.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// -// @ Project : Access Control Engine -// @ File Name : PolicyInformationPoint.cpp -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// -#include - -#include -#include - -#include -#include - -#include -#include - -using namespace AceDB; - -PolicyInformationPoint::~PolicyInformationPoint() -{ -} - -/* gather attributes values from adequate interfaces */ -PipResponse PolicyInformationPoint::getAttributesValues(const Request* request, - AttributeSet* attributes) -{ - int subjectReturn = 0; - int resourceReturn = 0; - int operationReturn = 0; - int functionReturn = 0; - /* create query lists */ - createQueries(attributes); - - /* check if subject attributes query has any elements*/ - if (!subjectAttributesQuery.empty()) { - /* get Subject Attributes */ - subjectReturn = wrtInterface->getAttributesValues( - *request, - &subjectAttributesQuery); - } - - AttributeSet::const_iterator iter2; - FOREACH(iter, subjectAttributesQuery) - { - if (iter->second == NULL) { - Attribute attr(*(iter->first)); - attr.setType(Attribute::Type::Subject); - iter2 = std::find_if(attributes->begin(), - attributes->end(), - BaseAttribute::UnaryPredicate(&attr)); - Assert(iter2 != attributes->end() && "This should not happen, " - "the attribute MUST be in attribute set"); - (*iter2)->setUndetermind(true); - } - } - - /* check if resource attributes query has any elements*/ - if (!resourceAttributesQuery.empty()) { - /* get Resource Attributes */ - resourceReturn = resourceInformation->getAttributesValues( - *request, - &resourceAttributesQuery); - /* error analyzys*/ - resourceReturn <<= ERROR_SHIFT_RESOURCE; - } - - FOREACH(iter, resourceAttributesQuery) - { - if (iter->second == NULL) { - LogInfo("Found undetermined attribute"); - Attribute attr(*(iter->first)); - attr.setType(Attribute::Type::Resource); - iter2 = std::find_if(attributes->begin(), - attributes->end(), - BaseAttribute::UnaryPredicate(&attr)); - Assert(iter2 != attributes->end() && "This should not happen, " - "the attribute MUST be in attribute set"); - (*iter2)->setUndetermind(true); - } - } - - /* check if resource attributes query has any elements*/ - if (!environmentAttributesQuery.empty()) { - /* get enviroment attributes */ - operationReturn = operationSystem->getAttributesValues( - *request, - &environmentAttributesQuery); - /* error analyzys*/ - operationReturn <<= ERROR_SHIFT_OS; - } - - FOREACH(iter, environmentAttributesQuery) - { - if (iter->second == NULL) { - //it doesnt change uniqueness of a set element so we can const_cast - Attribute attr(*(iter->first)); - attr.setType(Attribute::Type::Environment); - iter2 = find_if(attributes->begin(), - attributes->end(), - BaseAttribute::UnaryPredicate(&attr)); - Assert(iter2 != attributes->end() && "This should not happen, " - "the attribute MUST be in attribute set"); - (*iter2)->setUndetermind(true); - } - } - - /* check if functionParam attributes query has any elements*/ - if (!functionParamAttributesQuery.empty() && request->getFunctionParam()) { - /* get params attributes */ - functionReturn = request->getFunctionParam()->getAttributesValues( - *request, - &functionParamAttributesQuery); - /* error analyzys*/ - functionReturn <<= ERROR_SHIFT_FP; - } - - FOREACH(iter, functionParamAttributesQuery) - { - if (iter->second == NULL) { - //it doesnt change uniqueness of a set element so we can const_cast - Attribute attr(*(iter->first)); - attr.setType(Attribute::Type::FunctionParam); - iter2 = find_if(attributes->begin(), - attributes->end(), - BaseAttribute::UnaryPredicate(&attr)); - Assert(iter2 != attributes->end() && "This should not happen, " - "the attribute MUST be in attribute set"); - (*iter2)->setUndetermind(true); - } - } - - /** clear query lists*/ - resourceAttributesQuery.clear(); - environmentAttributesQuery.clear(); - subjectAttributesQuery.clear(); - functionParamAttributesQuery.clear(); - - return subjectReturn | resourceReturn | operationReturn | functionReturn; -} - -/** create query lists */ -void PolicyInformationPoint::createQueries(AttributeSet* attributes) -{ - AttributeSet::const_iterator it; - - enum Attribute::Type type; - - /**iterate all attributes and split them into adequate query */ - FOREACH (it, *attributes) { - type = (*it)->getType(); - - switch (type) { - case Attribute::Type::Subject: - subjectAttributesQuery.push_back(ATTRIBUTE((*it)->getName(), - (*it)->getValue())); - break; - - case Attribute::Type::Environment: - environmentAttributesQuery.push_back(ATTRIBUTE((*it)->getName(), - (*it)->getValue())); - break; - - case Attribute::Type::Resource: - resourceAttributesQuery.push_back(ATTRIBUTE((*it)->getName(), - (*it)->getValue())); - break; - - case Attribute::Type::FunctionParam: - functionParamAttributesQuery.push_back(ATTRIBUTE((*it)->getName(), - (*it)->getValue())); - break; - - default: - break; - } - } -} - diff --git a/modules/ace/engine/Rule.cpp b/modules/ace/engine/Rule.cpp deleted file mode 100644 index 3fe4051..0000000 --- a/modules/ace/engine/Rule.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : Rule.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#include -#include - -#include -#include - -void Rule::printData() -{ - std::cout << "Rule: effect: " << printEffect(this->effect) << - " condition: " << this->condition; -} - -std::string Rule::printEffect(const Effect effect) const -{ - switch (effect) { - case Deny: - return "Deny"; - case PromptBlanket: - return "PromptBlanket"; - case PromptOneShot: - return "PromptOneShot"; - case PromptSession: - return "PromptSession"; - case Permit: - return "Permit"; - case Inapplicable: - return "Inapplicable"; - case Error: - return "Error"; - default: - return "ERROR"; - } -} - -Effect Rule::evaluateRule(const AttributeSet * attrSet) const -{ - Attribute::MatchResult result = condition.evaluateCondition(attrSet); - - if (result == Attribute::MatchResult::MRUndetermined) { - // LogInfo("Rule is undetermined"); - return Undetermined; - } else if (result == Attribute::MatchResult::MRTrue) { - // LogInfo("Rule effect "<deserializeCondition(is); - effect = serializer->deserializeEffect(is); -} - -void Rule::serialize(std::ostream& os) -{ - Serializer* serializer = Serializer::getInstance(); - - serializer->serializeCondition(os, condition); - serializer->serializeEffect(os, effect); -} - diff --git a/modules/ace/engine/Serializer.cpp b/modules/ace/engine/Serializer.cpp deleted file mode 100644 index a3141be..0000000 --- a/modules/ace/engine/Serializer.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include - -Serializer* Serializer::pInstance = NULL; - -Serializer* Serializer::getInstance() -{ - if (pInstance == NULL) { - pInstance = new Serializer; - } - return pInstance; -} - -void Serializer::serializeInt(std::ostream& os, - int value) -{ - os.write((char*)(&value), sizeof(value)); - //LogInfo("SerializeInt: " <& inputList) -{ - int dataLength = inputList.size(); - os.write((char*)(&dataLength), sizeof(dataLength)); - - //LogInfo("SerializeListAttributes SIZE: " <serialize(os); - } - - Assert(os.bad() == false && "Error Writing to file failure"); -} - -std::list Serializer::deserializeListAttributes(std::istream& is) -{ - std::list outputList; - - int numElem = 0; - is.read((char*)(&numElem), sizeof(numElem)); - - //LogInfo("DESerializeListAttributes SIZE: " <& inputList) const -{ - int dataLength = inputList.size(); - os.write((char*)(&dataLength), sizeof(dataLength)); - - FOREACH(it, inputList) - { - serializeString(os, *it); - } - - Assert(os.bad() == false && "Error Writing to file failure"); -} - -std::list Serializer::deserializeListStrings(std::istream& is) -{ - std::list outputList; - - int numElem = 0; - is.read((char*)(&numElem), sizeof(numElem)); - - for (int i = 0; i < numElem; i++) { - outputList.push_back(this->deserializeString(is)); - } - - return outputList; -} - -void Serializer::serializeMatch(std::ostream& os, - const Attribute::Match& match) const -{ - os.write((char*)(&match), sizeof(match)); - // LogInfo("SerializeMatch: " << match); - Assert(os.bad() == false && "Error Writing to file failure"); -} - -Attribute::Match Serializer::deserializeMatch(std::istream& is) -{ - Attribute::Match match(Attribute::Match::Error); - is.read((char*)(&match), sizeof(match)); - // LogInfo("DESerializeMatch: " << match); - return match; -} - -bool Serializer::serializeModifier(std::ostream& os, - const Attribute::Modifier& modifier) const -{ - os.write((char*)(&modifier), sizeof(modifier)); - // LogInfo("SerializeModifier: " << modifier); - return 0; -} - -Attribute::Modifier Serializer::deserializeModifier(std::istream& is) -{ - Attribute::Modifier modifier(Attribute::Modifier::Non); - is.read((char*)(&modifier), sizeof(modifier)); - // LogInfo("DESerializeModifer: " << modifier); - return modifier; -} - -//TODO zrobic z tego szablon - z list jezeli sie da -void Serializer::serializeListTreeNode(std::ostream& os, - std::list& inputList) -{ - int dataLength = inputList.size(); - os.write((char*)(&dataLength), sizeof(dataLength)); - - // LogInfo("SerializeListTreeNode SIZE: " <serialize(os); - } - - Assert(os.bad() == false && "Error Writing to file failure"); -} - -std::list Serializer::deserializeListTreeNode(std::istream&is, - TreeNode* parent) -{ - std::list outputList; - - int numElem = 0; - is.read((char*)(&numElem), sizeof(numElem)); - - // LogInfo("DESerializeListTreeNode SIZE: " <serialize(os); - - // LogInfo("Serialize AbstractElem: " << element); - Assert(os.bad() == false && "Error Writing to file failure"); -} - -AbstractTreeElement* Serializer::deserializeAbstractElement(std::istream& is, - TreeNode::TypeID& typeId) -{ - NodeFactory* factory = NodeFactory::getInstance(); - - AbstractTreeElement* element; - - element = factory->create(is, typeId); - - //LogInfo("DESerialize AbstractElem: " << typeId); - return element; -} - -void Serializer::serializeListSubjects(std::ostream& os, - std::list& inputList) -{ - int dataLength = inputList.size(); - os.write((char*)(&dataLength), sizeof(dataLength)); - - //LogInfo("Serialize list Subjects SIZE: " << dataLength); - - FOREACH (it, inputList) - { - //serialize method doesn't change anything in object - const_cast((*it))->serialize(os); - } - - Assert(os.bad() == false && "Error Writing to file failure"); -} - -std::list* Serializer::deserializeListSubjects(std::istream& is) -{ - std::list* outputList = new std::list; - - int numElem = 0; - is.read((char*)(&numElem), sizeof(numElem)); - - //LogInfo("DESerialize list Subjects SIZE: " <push_back(subject); - } - - return outputList; -} - -void Serializer::serializeCombineAlgorithm(std::ostream& os, - const Policy::CombineAlgorithm& combAlg) -{ - os.write((char*)(&combAlg), sizeof(combAlg)); - //LogInfo("Serialize Combine Alg:" << combAlg); - - Assert(os.bad() == false && "Error Writing to file failure"); -} - -Policy::CombineAlgorithm Serializer::deserializeCombineAlgorithm( - std::istream& is) -{ - Policy::CombineAlgorithm combAlg(Policy::DenyOverride); - is.read((char*)(&combAlg), sizeof(combAlg)); - //LogInfo("DESerialize Combine Alg:" << combAlg); - return combAlg; -} - -void Serializer::serializeCombineType(std::ostream& os, - const Condition::CombineType& combType) -{ - os.write((char*)(&combType), sizeof(combType)); - //LogInfo("Serialize CombineType: " <& inputList) -{ - int dataLength = inputList.size(); - os.write((char*)(&dataLength), sizeof(dataLength)); - - //LogInfo("Serialize List Conditions SIZE:" <serialize(os); - } - - Assert(os.bad() == false && "Error Writing to file failure"); -} - -std::list Serializer::deserializeListConditions(std::istream& is, - Condition* parent) -{ - std::list outputList; - - int numElem = 0; - is.read((char*)(&numElem), sizeof(numElem)); - - //LogInfo("DESerialize list Condition SIZE: " < - -#include -#include - -#include - -using namespace AceDB; - -Preference SettingsLogic::findGlobalUserSettings( - const std::string &resource, - WidgetHandle handler) -{ - Preference p = AceDAO::getWidgetDevCapSetting(resource, handler); - if (PreferenceTypes::PREFERENCE_DEFAULT == p) { - return AceDAO::getDevCapSetting(resource); - } else { - return p; - } -} - -Preference SettingsLogic::findGlobalUserSettings( - const Request &request) -{ - Request::DeviceCapabilitySet devset = request.getDeviceCapabilitySet(); - Assert(!devset.empty() && "No device cap set in request"); - return findGlobalUserSettings( - *(devset.begin()), - request.getWidgetHandle()); -} - -Preference SettingsLogic::getDevCapSetting(const std::string &resource) -{ - return AceDAO::getDevCapSetting(resource); -} - -void SettingsLogic::getDevCapSettings(PreferenceMap *globalSettingsMap) -{ - AceDAO::getDevCapSettings(globalSettingsMap); // NULL check inside -} - - -void SettingsLogic::setDevCapSetting(const std::string &resource, - Preference preference) -{ - if (resource.empty()) { - LogInfo("WARNING: setting resource settings for empty resource name"); - } - - AceDAO::addResource(resource); - - if (preference == PreferenceTypes::PREFERENCE_DEFAULT) { - return; - } - - Assert((PreferenceTypes::PREFERENCE_PERMIT == preference || - PreferenceTypes::PREFERENCE_DENY == preference || - PreferenceTypes::PREFERENCE_BLANKET_PROMPT == preference || - PreferenceTypes::PREFERENCE_ONE_SHOT_PROMPT == preference || - PreferenceTypes::PREFERENCE_SESSION_PROMPT == preference)); - - AceDAO::setDevCapSetting(resource,preference); -} - -void SettingsLogic::setAllDevCapSettings( - const std::list < std::pair < const std::string*, - Preference > > &resourcesList) -{ - std::list < std::pair < const std::string*, - Preference > >::const_iterator iter; - for (iter = resourcesList.begin(); iter != resourcesList.end(); ++iter) { - SettingsLogic::setDevCapSetting(*(iter->first), iter->second); - } -} - -void SettingsLogic::removeDevCapSetting(const std::string &resource) -{ - AceDAO::removeDevCapSetting(resource); -} - -void SettingsLogic::updateDevCapSetting(const std::string &resource, - Preference p) -{ - if (PreferenceTypes::PREFERENCE_DEFAULT == p) { - SettingsLogic::removeDevCapSetting(resource); - } else { - SettingsLogic::setDevCapSetting(resource, p); - } -} - -Preference SettingsLogic::getWidgetDevCapSetting( - const std::string &resource, - WidgetHandle handler) -{ - return AceDAO::getWidgetDevCapSetting(resource, handler); -} - -void SettingsLogic::getWidgetDevCapSettings(PermissionList *outputList) -{ - AceDAO::getWidgetDevCapSettings(outputList); // NULL check inside -} - - -void SettingsLogic::setWidgetDevCapSetting( - const std::string &resource, - WidgetHandle handler, - Preference preference) -{ - if (resource.empty()) { - LogError("Empty resource"); - return; - } - - LogDebug("userSetting, resource: " << resource << - " app_id: " << handler); - - AceDAO::addResource(resource); - SettingsLogic::removeWidgetDevCapSetting(resource, handler); - - if (PreferenceTypes::PREFERENCE_DEFAULT == preference) { - return; - } - - Assert((PreferenceTypes::PREFERENCE_PERMIT == preference || - PreferenceTypes::PREFERENCE_DENY == preference || - PreferenceTypes::PREFERENCE_BLANKET_PROMPT == preference || - PreferenceTypes::PREFERENCE_ONE_SHOT_PROMPT == preference || - PreferenceTypes::PREFERENCE_SESSION_PROMPT == preference)); - - AceDAO::setWidgetDevCapSetting(resource, handler, preference); -} - - -void SettingsLogic::setWidgetDevCapSettings(const PermissionList &permissionsList) -{ - FOREACH(i, permissionsList) { - SettingsLogic::setWidgetDevCapSetting(i->devCap, - i->appId, - i->access); - } -} - - -void SettingsLogic::removeWidgetDevCapSetting(const std::string &resource, - WidgetHandle handler) -{ - AceDAO::removeWidgetDevCapSetting(resource, handler); -} diff --git a/modules/ace/engine/Subject.cpp b/modules/ace/engine/Subject.cpp deleted file mode 100644 index 760b93d..0000000 --- a/modules/ace/engine/Subject.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include - -#include -#include -#include - -bool Subject::matchSubject(const AttributeSet *attrSet, - bool &isUndetermined) const -{ - bool result = true; - Attribute::MatchResult match = Attribute::MatchResult::MRUndetermined; - - FOREACH(it, targetAttributes) - { - AttributeSet::const_iterator attr = - std::find_if(attrSet->begin(), - attrSet->end(), - AceDB::BaseAttribute::UnaryPredicate(&(*it))); - if (attr == attrSet->end()) { - LogError("Cannot find attribute value for " << *(it->getName())); - Assert(false && - "Attribute for subject hasn't been found." - "It shoud not happen. This attribute should be undetermined," - "not missing"); - result = false; //According to BONDI 1.0 for signle subject all attributes must match - isUndetermined = true; - break; - } - - match = it->matchAttributes(&(*(*attr))); - - if (match == Attribute::MatchResult::MRUndetermined) { - result = false; - isUndetermined = true; - /// LogError("Subject doesn match and UNDETERMINED"); - break; //According to BONDI 1.0 for signle subject all attributes must match - } else if (match == Attribute::MatchResult::MRFalse) { - result = false; - // LogError("Subject doesn match and DETERMINED"); - break; //According to BONDI 1.0 for signle subject all attributes must match - } - } - - return result; -} - -const std::list& Subject::getTargetAttributes() const -{ - return targetAttributes; -} - -Subject::Subject(std::istream& is) -{ - Serializer* serializer = Serializer::getInstance(); - - subjectId = serializer->deserializeString(is); - targetAttributes = serializer->deserializeListAttributes(is); -} - -bool Subject::serialize (std::ostream& os) -{ - Serializer* serializer = Serializer::getInstance(); - - serializer->serializeString(os, subjectId); - serializer->serializeListAttributes(os, targetAttributes); - - return 0; -} diff --git a/modules/ace/engine/TreeNode.cpp b/modules/ace/engine/TreeNode.cpp deleted file mode 100644 index 5bcc136..0000000 --- a/modules/ace/engine/TreeNode.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include - -//Tree node destructor is a tricky part, only the original tree should remove the elements -//release resources should be called when we want to destroy the whole tree -TreeNode::~TreeNode() -{ -} - -bool TreeNode::serialize(std::ostream& os) -{ - Serializer* serializer = Serializer::getInstance(); - - //does node have any child - anty Inf recursion - if (!children.empty()) { - serializer->serializeInt(os, 1); - serializer->serializeListTreeNode(os, children); - } else { - serializer->serializeInt(os, 0); - } - - serializer->serializeTypeAbstract(os, typeID); - serializer->serializeAbstractElement(os, element); - - //LOG << "TreeNode Serialized" << std::endl; - return 0; -} - -TreeNode::TreeNode(std::istream& is, - TreeNode* parent) -{ - Serializer* serializer = Serializer::getInstance(); - - this->parent = parent; - - //check if this node has any child - int hasChild = 0; - hasChild = serializer->deserializeInt(is); - - if (hasChild) { //[CR] - 0 remove copying list .... - children = serializer->deserializeListTreeNode(is, this); - } - - typeID = serializer->deserializeTypeAbstract(is); - element = serializer->deserializeAbstractElement(is, typeID); - //LOG << "TreeNode DESERIALIZED" << std::endl; -} - -//TODO release resources is releaseTheSubtree and delete the element -void TreeNode::releaseResources() -{ - Assert(this != 0); - delete element; - std::list::iterator it = this->children.begin(); - while (it != children.end()) { - (*it)->releaseResources(); - ++it; - } - delete this; -} - -// KW void TreeNode::releaseTheSubtree(){ -// KW -// KW std::list::iterator it = children.begin(); -// KW -// KW for(; it != children.end();it++){ -// KW (*it)->releaseTheSubtree(); -// KW } -// KW delete this; -// KW } - -int TreeNode::level = 0; - -// KW void TreeNode::printSubtree(){ -// KW -// KW TreeNode::level++; -// KW -// KW for(int i=0;ichildren.begin(); -// KW -// KW for(;it != children.end();++it){ -// KW (*it)->printSubtree(); -// KW } -// KW -// KW TreeNode::level--; -// KW } - -std::ostream & operator<<(std::ostream & out, - const TreeNode * node) -{ - std::string tmp; - - switch (node->getTypeID()) { - case TreeNode::Policy: - tmp = "Policy"; - break; - case TreeNode::PolicySet: - tmp = "PolicySet"; - break; - case TreeNode::Rule: - tmp = "Rule"; - break; - default: - break; - } - - out << "" << tmp << "-> children count: " << node->children.size() << - ": " << std::endl; - AbstractTreeElement * el = node->getElement(); - if (el != NULL) { - el->printData(); - } else { - std::cout << "Empty element!" << std::endl; - } - - return out; -} - diff --git a/modules/ace/engine/parser.cpp b/modules/ace/engine/parser.cpp deleted file mode 100644 index 1b20a6a..0000000 --- a/modules/ace/engine/parser.cpp +++ /dev/null @@ -1,744 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include - -#include -#include - -namespace { - -class ParserWarningLogger -{ - public: - void operator()(const std::string& logMsg) - { - LogWarning(logMsg); - } -}; - -class ParserErrorLogger -{ - public: - void operator()(const std::string& logMsg) - { - LogError(logMsg); - } -}; - -template -void xmlLogFunction(void* /*ctx*/, const char *msg, ...) -{ - const int BUFFER_SIZE = 1024; - char buffer[BUFFER_SIZE]; - buffer[BUFFER_SIZE - 1] = '\0'; - Logger l; - - va_list va; - va_start(va, msg); - vsnprintf(buffer, BUFFER_SIZE - 1, msg, va); - va_end(va); - - std::string logmsg(buffer); - l(logmsg); -} - -} - -const char *Parser::TOKEN_PARAM = "param:"; - -Parser::Parser() : - reader(NULL), - root(NULL), - currentRoot(NULL), - currentSubject(NULL), - currentCondition(NULL), - currentAttribute(NULL), - currentText(NULL), - processingSignature(false), - canonicalizeOnce(false) -{ - processingSignature = true; - canonicalizeOnce = true; -} - -Parser::~Parser() -{ - /* parse function destroys reader */ - // free(this->xmlFilename); -} - -TreeNode* Parser::parse(const std::string& filename, const std::string& schema) -{ - if(root != NULL) { - root->releaseResources(); - root = NULL; - } - - LogDebug("Parser: opening file " << filename); - - xmlDocPtr xmlDocument = xmlParseFile(filename.c_str()); - if (!xmlDocument) { - LogError("Couldn't parse file " << filename); - return root; - } - - std::unique_ptr > - doc(xmlDocument, xmlFreeDoc); - - xmlSchemaParserCtxtPtr xmlSchemaParserContext = - xmlSchemaNewParserCtxt(schema.c_str()); - - if (!xmlSchemaParserContext) { - LogError("Couldn't load xml schema: " << schema); - return root; - } - - std::unique_ptr < - xmlSchemaParserCtxt, - std::function > - schemaContext( - xmlSchemaParserContext, - xmlSchemaFreeParserCtxt); - - LogDebug("Setting callbacks"); - - xmlSchemaSetParserErrors( - schemaContext.get(), - static_cast - (&xmlLogFunction), - static_cast - (&xmlLogFunction), - NULL); - - xmlSchemaPtr xmlSchema = xmlSchemaParse(schemaContext.get()); - - if (!xmlSchema) { - LogError("Couldn't parse xml schema: " << xmlSchema); - return root; - } - - xmlSchemaValidCtxtPtr xmlValidContext = xmlSchemaNewValidCtxt(xmlSchema); - - if (!xmlValidContext) { - LogError("Couldn't create validation context!"); - return root; - } - - std::unique_ptr < - xmlSchemaValidCtxt, - std::function > - schemaValidContext( - xmlValidContext, - xmlSchemaFreeValidCtxt); - - xmlSchemaSetValidErrors( - schemaValidContext.get(), - static_cast - (&xmlLogFunction), - static_cast - (&xmlLogFunction), - NULL); - - xmlSchemaSetValidOptions( - schemaValidContext.get(), - XML_SCHEMA_VAL_VC_I_CREATE); - - bool result = - (xmlSchemaValidateDoc( - schemaValidContext.get(), - xmlDocument) == 0 ? true : false); - - if (!result) { - LogError("Couldn't validate policy file: " << filename << - " against xml schema: " << schema); - - return root; - } - - LogInfo("Policy file: " << filename << " validated!"); - - xmlTextReaderPtr xmlReader = xmlReaderWalker(xmlDocument); - - //[CR] consider using ASSERT/DASSERT - if (NULL == xmlReader) { - LogError("Error, xml reader cannot be created. Probably xml file is missing (opening file " << filename << ")"); - return root; - } - - std::unique_ptr > - reader(xmlReader, xmlFreeTextReader); - - int ret; - ret = xmlTextReaderRead(reader.get()); - while (ret == 1) { - std::unique_ptr > - name(xmlTextReaderName(reader.get()), xmlFree); - - if (!strcmp("policy-set", (const char *)name.get())) { - processingSignature = false; - } else if (!strcmp("SignedInfo", - (const char *)name.get()) && canonicalizeOnce) { - #if 0 //TODO I think we don't need canonicalization in ACE only in PM, - //we have to verify it tough - extractNodeToFile(reader, "output.xml"); - //TODO we should be able to handle more than one canonicalization algorithm - canonicalize("output.xml", "canon.xml", Canonicalization::C14N); - canonicalizeOnce = false; - #endif - } - //Do not process signature of xml file - if(!processingSignature) { - processNode(reader.get()); - } - ret = xmlTextReaderRead(reader.get()); - } - - if (ret != 0) { - LogError("Error while parsing XML file"); - if (root) { - root->releaseResources(); - root = NULL; - } - } - - return root; -} - -void Parser::processNode(xmlTextReaderPtr reader) -{ - //TODO this is interesting, xmlTextReaderNodeType returns int but I am pretty sure - //those integers coresponds to xmlReaderTypes - xmlReaderTypes type = - static_cast(xmlTextReaderNodeType(reader)); - - switch (type) { - //Start element - case XML_READER_TYPE_ELEMENT: - startNodeHandler(reader); - break; - //End element - case XML_READER_TYPE_END_ELEMENT: - endNodeHandler(reader); - break; - //Text element - case XML_READER_TYPE_TEXT: - textNodeHandler(reader); - break; - default: - //Do not handle other xml tags - break; - } -} - -void Parser::startNodeHandler(xmlTextReaderPtr reader) -{ - xmlChar *name = xmlTextReaderName(reader); - - switch (*name) { - case 'p': //policy and policy-set - if (*(name + 6) == 0) { - handlePolicy(reader, TreeNode::Policy); - } else { - handlePolicy(reader, TreeNode::PolicySet); - } - break; - case 'r': //rule and resource-match - if (*(name + 1) == 'u') { - handleRule(reader); - } else if (*(name + 9) == 'm') { - handleMatch(reader, Attribute::Type::Resource); - } else { - handleAttr(reader); - } - break; - case 's': //subject and subject-match - if (*(name + 7) == 0) { - handleSubject(); - } else if (*(name + 8) == 'm') { //subject match - handleSubjectMatch(reader); - } else { //subject attr - handleAttr(reader); - } - break; - case 'c': //condition - handleCondition(reader); - break; - case 'e': //environment-match - if (*(name + 12) == 'm') { - handleMatch(reader, Attribute::Type::Environment); - } else { //env-attr - handleAttr(reader); - } - break; - } - xmlFree(name); -} - -void Parser::endNodeHandler(xmlTextReaderPtr reader) -{ - xmlChar *name = xmlTextReaderName(reader); - - switch (*name) { - case 'p': //policy and policy-set - //Restore old root - currentRoot = currentRoot->getParent(); - break; - case 'r': //Rule and resource match - if (*(name + 1) == 'u') { //Rule - currentRoot = currentRoot->getParent(); - } else { //Resource-match - consumeCurrentText(); //consume text if any available - consumeCurrentAttribute(); //consume attribute - } - break; - case 's': //subject and subject-match - if (*(name + 7) == 0) { //handle subject - consumeCurrentSubject(); - } else if (*(name + 8) == 'm') { //handle subject match - consumeCurrentText(); - consumeSubjectMatch(); - } - //Subject-match end doesn't require handling - break; - case 'c': //condition - consumeCurrentCondition(); - break; - case 'e': //environment-match - consumeCurrentText(); //consume text if any available - consumeCurrentAttribute(); //consume attribute - break; - } - xmlFree(name); -} - -void Parser::textNodeHandler(xmlTextReaderPtr reader) -{ - delete currentText; - xmlChar * text = xmlTextReaderValue(reader); - Assert(text != NULL && "Parser couldn't parse PCDATA"); - - currentText = new std::string(reinterpret_cast(text)); - trim(currentText); - xmlFree(text); -} - -void Parser::handlePolicy(xmlTextReaderPtr reader, - TreeNode::TypeID type) -{ - Policy::CombineAlgorithm algorithm; - - //Get first attribute - xmlChar * combAlg = xmlTextReaderGetAttribute(reader, BAD_CAST("combine")); - - Assert(combAlg != NULL && "Parser error while getting attributes"); - algorithm = convertToCombineAlgorithm(combAlg); - - //Create TreeNode element - Policy * policy = NULL; - if (type == TreeNode::Policy) { - policy = new Policy(); - } else { - policy = new PolicySet(); - } - policy->setCombineAlgorithm(algorithm); - TreeNode * node = new TreeNode(currentRoot, type, policy); - //Add new tree node to current's root children set - if (currentRoot != NULL) { - currentRoot->addChild(node); - } - - //Switch the current root to the new node - if (!xmlTextReaderIsEmptyElement(reader)) { - //Current root switching is necessary only if tag is not empty - currentRoot = node; - } - if (root == NULL) { - root = currentRoot; - } - - if (NULL == currentRoot) { - node->releaseResources(); - } - - xmlFree(combAlg); -} - -void Parser::handleRule(xmlTextReaderPtr reader) -{ - Effect effect = Inapplicable; - - //[CR] create macros for attribute names - xmlChar * eff = xmlTextReaderGetAttribute(reader, BAD_CAST("effect")); //get the rule attribute - - Assert(eff != NULL && "Parser error while getting attributes"); - effect = convertToEffect(eff); - - Rule * rule = NULL; - rule = new Rule(); - rule->setEffect(effect); - - TreeNode * node = new TreeNode(currentRoot, TreeNode::Rule, rule); - //Add new tree node to current's root children set - if (currentRoot != NULL) { // - currentRoot->addChild(node); - } - - if (!xmlTextReaderIsEmptyElement(reader)) { - currentRoot = node; - } - - if (NULL == currentRoot) { - node->releaseResources(); - } - - xmlFree(eff); -} - -void Parser::handleSubject() -{ - currentSubject = new Subject(); - //TODO what about empty subject tag -} - -void Parser::handleCondition(xmlTextReaderPtr reader) -{ - Condition::CombineType combineType = Condition::AND; - - xmlChar * combine = xmlTextReaderGetAttribute(reader, BAD_CAST("combine")); //get the rule attribute - - Assert(combine != NULL && "Parser error while getting attributes"); - - combineType = *combine == 'a' ? Condition::AND : Condition::OR; - - Condition * condition = new Condition(); - condition->setCombineType(combineType); - condition->setParent(currentCondition); - - currentCondition = condition; - //TODO what about empty condition tag? -} - -//Subject match is handled differently than resource or environment match -//Because it cannot have any children tags and can only include PCDATA -void Parser::handleSubjectMatch(xmlTextReaderPtr reader) -{ - //processing Subject - int attributes = xmlTextReaderAttributeCount(reader); - - xmlChar * func = NULL; - xmlChar * value = NULL; - xmlChar * attrName = xmlTextReaderGetAttribute(reader, BAD_CAST("attr")); //get the first attribute - - if (attributes == 2) { - //match attribute ommited, text value will be used - func = xmlTextReaderGetAttribute(reader, BAD_CAST("func")); - } else if (attributes == 3) { - value = xmlTextReaderGetAttribute(reader, BAD_CAST("match")); - func = xmlTextReaderGetAttribute(reader, BAD_CAST("func")); - } else { - Assert(false && "Wrong XML file format"); - } - - // creating temporiary object is not good idea - // but we have no choice untill Attribute have constructor taking std::string* - std::string temp(reinterpret_cast(attrName)); - Attribute * attr = new Attribute(&temp, convertToMatchFunction( - func), Attribute::Type::Subject); - if (value != NULL) { //add value of the attribute if possible - //[CR] consider create Attribute::addValue(char *) function - std::string temp(reinterpret_cast(value)); - attr->addValue(&temp); - } - currentAttribute = attr; - - if (xmlTextReaderIsEmptyElement(reader)) { - Assert(value != NULL && "XML file format is wrong"); - //Attribute value is required to obtain the match value easier - consumeSubjectMatch(value); - } - - if (attributes == 2 || attributes == 3) { - xmlFree(func); - } - xmlFree(value); - xmlFree(attrName); -} - -void Parser::handleMatch(xmlTextReaderPtr reader, - Attribute::Type type) -{ - int attributes = xmlTextReaderAttributeCount(reader); - - xmlChar * func = NULL; - xmlChar * value = NULL; - xmlChar * attrName = xmlTextReaderGetAttribute(reader, BAD_CAST("attr")); //get the first attribute - - if (attributes == 2) { - //match attribute ommited, text value will be used - func = xmlTextReaderGetAttribute(reader, BAD_CAST("func")); - //the content may be resource-attr or PCDATA - } else if (attributes == 3) { - value = xmlTextReaderGetAttribute(reader, BAD_CAST("match")); - func = xmlTextReaderGetAttribute(reader, BAD_CAST("func")); - } else { - Assert(false && "Wrong XML file format"); - } - - // FunctionParam type is sybtype of Resource. - // FunctionParam is used to storage attriburess of call functions. - if (0 == - xmlStrncmp(attrName, BAD_CAST(TOKEN_PARAM), - xmlStrlen(BAD_CAST(TOKEN_PARAM))) && type == - Attribute::Type::Resource) { - type = Attribute::Type::FunctionParam; - } - - std::string temp(reinterpret_cast(attrName)); - Attribute * attr = new Attribute(&temp, convertToMatchFunction(func), type); - currentAttribute = attr; - - if (xmlTextReaderIsEmptyElement(reader)) { - Assert(value != NULL && "XML is currupted"); - std::string tempVal(reinterpret_cast(value)); - currentAttribute->addValue(&tempVal); - consumeCurrentAttribute(); - } - - if (attributes == 2 || attributes == 3) { - xmlFree(func); - } - xmlFree(value); - xmlFree(attrName); -} - -Policy::CombineAlgorithm Parser::convertToCombineAlgorithm(xmlChar* algorithm) -{ - switch (*algorithm) { - case 'f': - if (*(algorithm + 6) == 'a') { //first applicable - return Policy::FirstApplicable; - } - return Policy::FirstTargetMatching; - case 'd': - return Policy::DenyOverride; - case 'p': - return Policy::PermitOverride; - default: - Assert(false && "Wrong combine algorithm name"); - return Policy::DenyOverride; - } -} - -Effect Parser::convertToEffect(xmlChar *effect) -{ - switch (*effect) { - case 'd': //deny - return Deny; - break; - case 'p': - //permit, prompt-blanket, prompt-session, prompt-oneshot - if (*(effect + 1) == 'e') { - return Permit; - } - switch (*(effect + 7)) { - case 'b': - return PromptBlanket; - case 's': - return PromptSession; - case 'o': - return PromptOneShot; - default: - Assert(false && "Effect is Error"); - return Error; - } - break; - default: - Assert(false && "Effect is Error"); - return Error; - } - return Inapplicable; -} - -Attribute::Match Parser::convertToMatchFunction(xmlChar * func) -{ - if (func == NULL) { - LogError("[ERROR] match function value is NULL"); - return Attribute::Match::Error; - } - - if (*func == 'g') { - return Attribute::Match::Glob; - } else if (*func == 'e') { - return Attribute::Match::Equal; - } else if (*func == 'r') { - return Attribute::Match::Regexp; - } else { - LogError("[ERROR] match function value is NULL"); - return Attribute::Match::Error; - } - Assert(false); -} - -void Parser::handleAttr(xmlTextReaderPtr reader) -{ - xmlChar * attrValue = xmlTextReaderGetAttribute(reader, BAD_CAST("attr")); //get the first attribute - Assert(attrValue != NULL && "Error while obtaining attribute"); - - std::string temp(reinterpret_cast(attrValue)); - currentAttribute->addValue(&temp); - - xmlFree(attrValue); -} - -void Parser::consumeCurrentText() -{ - Assert(currentText != NULL); - currentAttribute->addValue(currentText); - delete currentText; - - currentText = NULL; -} - -void Parser::consumeCurrentAttribute() -{ - Assert(currentAttribute != NULL); - - currentCondition->addAttribute(*currentAttribute); - delete currentAttribute; - - currentAttribute = NULL; -} - -void Parser::consumeCurrentSubject() -{ - Policy * policy = dynamic_cast(currentRoot->getElement()); - Assert(policy != NULL); - policy->addSubject(currentSubject); - //TODO maybe keep subjects not subject pointers in Policies and consume subjects here - currentSubject = NULL; -} - -void Parser::consumeCurrentCondition() -{ - Condition * temp = NULL; - if (currentCondition != NULL) { - if (currentCondition->getParent() != NULL) { //Condition is a child of another condition - currentCondition->getParent()->addCondition(*currentCondition); - } else { //Condition parent is a Rule - Rule * rule = dynamic_cast(currentRoot->getElement()); - Assert(rule != NULL); - rule->setCondition(*currentCondition); - } - temp = currentCondition->getParent(); - delete currentCondition; - } - currentCondition = temp; //switch current condition ( it may be switched to NULL if condition's parent was rule -} - -void Parser::consumeSubjectMatch(xmlChar * value) -{ - Assert( - currentAttribute != NULL && - "consuming subject match without attribute set"); - - if (currentSubject != NULL) { - currentSubject->addNewAttribute(*currentAttribute); - //[CR] matching/modyfing functions transform uri.host to uri ( etc. ) so strncmp is not needed, string equality will do - if (!strncmp(currentAttribute->getName()->c_str(), "uri", - 3) || - !strncmp(currentAttribute->getName()->c_str(), "id", 2)) { - if (value != NULL) { - currentSubject->setSubjectId(reinterpret_cast( - value)); - } else if (currentAttribute->getValue()->size()) { - currentSubject->setSubjectId( - currentAttribute->getValue()->front()); - } else { - Assert(false); - } - } - } else if (currentCondition != NULL) { - currentCondition->addAttribute(*currentAttribute); - } - - delete currentAttribute; - currentAttribute = NULL; -} - -void Parser::trim(std::string * str) -{ - std::string::size_type pos = str->find_last_not_of(whitespaces); - if (pos != std::string::npos) { - str->erase(pos + 1); - pos = str->find_first_not_of(whitespaces); - if (pos != std::string::npos) { - str->erase(0, pos); - } - } else { - str->erase(str->begin(), str->end()); - LogInfo("Warning, empty string as attribute value"); - } -} - -// KW void Parser::canonicalize(const char * input, const char * output, CanonicalizationAlgorithm canonicalizationAlgorithm){ -// KW -// KW xmlDocPtr doc = xmlParseFile(input); -// KW //xmlDocDump(stdout, doc); -// KW -// KW if(doc == NULL) -// KW { -// KW LogError("Canonicalization error, cannot parser xml file"); -// KW } -// KW -// KW -// KW int mode = -1; -// KW if(canonicalizationAlgorithm == C14N) -// KW { -// KW mode = 0; -// KW } -// KW else if(canonicalizationAlgorithm == C14NEXCLUSIVE) -// KW { -// KW mode = 1; -// KW } -// KW -// KW -// KW xmlC14NDocSave(doc, NULL, mode, NULL, 0, output, 0); -// KW -// KW xmlFreeDoc(doc); -// KW -// KW } - -// KW int Parser::extractNodeToFile(xmlTextReaderPtr reader, const char * filename){ -// KW -// KW xmlNodePtr node = xmlTextReaderExpand(reader); -// KW xmlBufferPtr buff = xmlBufferCreate(); -// KW xmlNodeDump(buff, node->doc, node, 0, 0); -// KW FILE * file = fopen(filename, "w"); -// KW if(file == NULL){ -// KW LogError("Error while trying to open file "< -#include - -namespace AceDB { -namespace AceDaoConversions { - -DPL::String convertToHash(const BaseAttributeSet &attributes); - -} -} - -#endif diff --git a/modules/ace/include/dpl/ace-dao-ro/AceDAOReadOnly.h b/modules/ace/include/dpl/ace-dao-ro/AceDAOReadOnly.h deleted file mode 100644 index da94943..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/AceDAOReadOnly.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file AceDAOReadOnly.h - * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef ACE_DAO_READ_ONLY_H_ -#define ACE_DAO_READ_ONLY_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AceDB { - -class AceDAOReadOnly -{ - public: - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, DatabaseError) - }; - - AceDAOReadOnly() {} - - static void attachToThread(); - static void detachFromThread(); - - // policy effect/decision - static OptionalPolicyResult getPolicyResult( - const BaseAttributeSet &attributes); - - static OptionalPolicyResult getPolicyResult( - const DPL::String &attrHash); - - // prompt decision - static OptionalCachedPromptDecision getPromptDecision( - const DPL::String &hash, - const std::string &userParam); - static OptionalCachedPromptDecision getPromptDecision( - const BaseAttributeSet &attribites, - const std::string &userParam); - - // resource settings - static PreferenceTypes getDevCapSetting(const std::string &resource); - static void getDevCapSettings(PreferenceTypesMap *preferences); - - // user settings - static void getWidgetDevCapSettings(BasePermissionList *permissions); - static PreferenceTypes getWidgetDevCapSetting( - const std::string &resource, - WidgetHandle handler); - - static void getAttributes(BaseAttributeSet *attributes); - - // static dev cap permissions - // - // (For a given widget handle, a set of device caps is - // granted "statically", i.e. it is determined at installation - // time that the widget will always get (at launch) the SMACK - // permissions needed to use those device caps). - // - // 'permissions' is an output parameter - it must point to - // an existing set and the function will clear it and fill - // with the device cap names as described. - static void getStaticDevCapPermissions( - int widgetHandle, - std::set *permissions); - - protected: - static int promptDecisionToInt(PromptDecision decision); - static PromptDecision intToPromptDecision(int decision); -}; - -} - -#endif diff --git a/modules/ace/include/dpl/ace-dao-ro/AceDAOUtilities.h b/modules/ace/include/dpl/ace-dao-ro/AceDAOUtilities.h deleted file mode 100644 index 0e0ec00..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/AceDAOUtilities.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file AceDAOUtil.h - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef WRT_ACE_DAO_UTILITIES_H_ -#define WRT_ACE_DAO_UTILITIES_H_ - -#include -#include -#include -#include -#include - -namespace AceDB { - -namespace AceDaoUtilities { - -BaseAttribute::Type intToAttributeType(int val); -int attributeTypeToInt(BaseAttribute::Type type); -int preferenceToInt(PreferenceTypes p); -PreferenceTypes intToPreference(int p); -VerdictTypes intToVerdict(int v); -int verdictToInt(VerdictTypes v); -bool getSubjectByUri(const std::string &uri, - DPL::DB::ORM::ace::AceSubject::Row &row); -bool getResourceByUri(const std::string &uri, - DPL::DB::ORM::ace::AceDevCap::Row &row); - -extern DPL::DB::ThreadDatabaseSupport m_databaseInterface; - -} - -} - -#endif diff --git a/modules/ace/include/dpl/ace-dao-ro/AceDatabase.h b/modules/ace/include/dpl/ace-dao-ro/AceDatabase.h deleted file mode 100644 index d5b2838..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/AceDatabase.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file AceDatabase.h - * @author Lukasz Marek (l.marek@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of ace database - */ - -#ifndef WRT_ENGINE_SRC_ACCESS_CONTROL_ACE_DATABASE_H -#define WRT_ENGINE_SRC_ACCESS_CONTROL_ACE_DATABASE_H - -#include -#include - -extern DPL::Mutex g_aceDbQueriesMutex; - -#define ACE_DB_INTERNAL(tlsCommand, InternalType, interface) \ - static DPL::ThreadLocalVariable *tlsCommand ## Ptr = NULL; \ - { \ - DPL::Mutex::ScopedLock lock(&g_aceDbQueriesMutex); \ - if (!tlsCommand ## Ptr) { \ - static DPL::ThreadLocalVariable tmp; \ - tlsCommand ## Ptr = &tmp; \ - } \ - } \ - DPL::ThreadLocalVariable &tlsCommand = *tlsCommand ## Ptr; \ - if (tlsCommand.IsNull()) { tlsCommand = InternalType(interface); } - -#define ACE_DB_SELECT(name, type, interface) \ - ACE_DB_INTERNAL(name, type::Select, interface) - -#define ACE_DB_INSERT(name, type, interface) \ - ACE_DB_INTERNAL(name, type::Insert, interface) - -#define ACE_DB_UPDATE(name, type, interface) \ - ACE_DB_INTERNAL(name, type::Update, interface) - -#define ACE_DB_DELETE(name, type, interface) \ - ACE_DB_INTERNAL(name, type::Delete, interface) - - -#endif // WRT_ENGINE_SRC_ACCESS_CONTROL_ACE_DATABASE_H diff --git a/modules/ace/include/dpl/ace-dao-ro/BaseAttribute.h b/modules/ace/include/dpl/ace-dao-ro/BaseAttribute.h deleted file mode 100644 index 1956af5..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/BaseAttribute.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file IAttribute.h - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef ACCESS_CONTROL_DAO_BASEATTRIBUTE_H_ -#define ACCESS_CONTROL_DAO_BASEATTRIBUTE_H_ - -#include -#include -#include -#include -#include - -namespace AceDB { - -class BaseAttribute; -typedef DPL::SharedPtr BaseAttributePtr; - -class BaseAttribute -{ - - public: - /** - * Types of attributes - */ - enum class Type { Subject, Environment, Resource, FunctionParam, Undefined }; - - struct UnaryPredicate - { - public: - UnaryPredicate(const AceDB::BaseAttribute *comp = NULL) : - m_priv(comp) - { - } - - bool operator()(const AceDB::BaseAttributePtr &comp) - { - Assert(m_priv != NULL); - if (m_priv->getName()->compare(*comp->getName()) != 0) { - return false; - } - return m_priv->getType() == comp->getType(); - } - - bool operator()(const AceDB::BaseAttributePtr &comp1, - const AceDB::BaseAttributePtr &comp2) - { - if (comp1->getType() != comp2->getType()) { - return comp1->getType() < comp2->getType(); - } - return comp1->getName()->compare(*comp2->getName()) < 0; - } - - private: - const AceDB::BaseAttribute *m_priv; - }; - - public: - BaseAttribute() : - m_typeId(Type::Undefined), - m_undetermindState(false) - {} - - virtual void setName(const std::string& name) - { - m_name = name; - } - virtual void setName(const std::string* name) - { - m_name = *name; - } - - virtual void setType(const Type& type) - { - m_typeId = type; - } - virtual Type getType() const - { - return m_typeId; - } - - virtual const std::string* getName() const - { - return &m_name; - } - - //TODO think - virtual void setUndetermind(bool tmp) - { - m_undetermindState = tmp; - } - virtual bool isUndetermind() const - { - return m_undetermindState; - } - virtual std::list * getValue() const - { - return const_cast* >(&value); - } - virtual bool isValueEmpty() const - { - return value.empty(); - } - - virtual void setValue(const std::list& arg) - { - value = arg; - } - - virtual ~BaseAttribute() - { - } - - static const char * typeToString(Type type); - - virtual std::string toString() const; - - protected: - std::string m_name; - Type m_typeId; - bool m_undetermindState; - std::list value; //string bag list -}; - -typedef std::set BaseAttributeSet; - -} - -#endif diff --git a/modules/ace/include/dpl/ace-dao-ro/BasePermission.h b/modules/ace/include/dpl/ace-dao-ro/BasePermission.h deleted file mode 100644 index 8305f42..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/BasePermission.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file IPermission.h - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef ACCESS_CONTROL_DAO_BASEPERMISSION_H_ -#define ACCESS_CONTROL_DAO_BASEPERMISSION_H_ - -#include -#include - -namespace AceDB{ - -struct BasePermission -{ - BasePermission(WidgetHandle handler, - const std::string& devCap, - PreferenceTypes accessAllowed) : - appId(handler), - devCap(devCap), - access(accessAllowed) - { - } - - WidgetHandle appId; - std::string devCap; - PreferenceTypes access; -}; - -typedef std::list BasePermissionList; - -} - -#endif diff --git a/modules/ace/include/dpl/ace-dao-ro/IRequest.h b/modules/ace/include/dpl/ace-dao-ro/IRequest.h deleted file mode 100644 index 2975b8b..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/IRequest.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file IRequest.h - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef ACCESS_CONTROL_DAO_IREQUEST_H_ -#define ACCESS_CONTROL_DAO_IREQUEST_H_ - -namespace AceDB{ - -class IRequest -{ -public: - virtual ~IRequest(){} -}; - -} - -#endif diff --git a/modules/ace/include/dpl/ace-dao-ro/PreferenceTypes.h b/modules/ace/include/dpl/ace-dao-ro/PreferenceTypes.h deleted file mode 100644 index 0f96dc5..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/PreferenceTypes.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file PreferenceTypes.h - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef ACCESS_CONTROL_DAO_PREFERENCETYPES_H_ -#define ACCESS_CONTROL_DAO_PREFERENCETYPES_H_ - -#include -#include - -namespace AceDB{ - -enum class PreferenceTypes -{ - PREFERENCE_PERMIT, - PREFERENCE_DENY, - PREFERENCE_DEFAULT, - PREFERENCE_BLANKET_PROMPT, - PREFERENCE_SESSION_PROMPT, - PREFERENCE_ONE_SHOT_PROMPT -}; - - -typedef std::map PreferenceTypesMap; - -} - -#endif diff --git a/modules/ace/include/dpl/ace-dao-ro/PromptModel.h b/modules/ace/include/dpl/ace-dao-ro/PromptModel.h deleted file mode 100644 index e610e12..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/PromptModel.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* @file PromptModel.h - * @author Justyna Mejzner (j.kwiatkowsk@samsung.com) - * @author Jaroslaw Osmanski (j.osmanski@samsung.com) - * @version 1.0 - * - */ - -#ifndef WRT_SRC_ACCESSCONTROL_ENGINE_PROMPT_MODEL_H_ -#define WRT_SRC_ACCESSCONTROL_ENGINE_PROMPT_MODEL_H_ - -#include -#include -#include - -#include -#include - -namespace Prompt { -typedef std::vector ButtonLabels; - -class PromptLabels -{ -public: - PromptLabels(int promptType, - const Prompt::ButtonLabels& questionLabel, - const std::string& mainLabel); - DPL::OptionalString getCheckLabel() const; - bool isAllowed(const size_t buttonNumber) const; - int getPromptType() const; - const ButtonLabels& getButtonLabels() const; - const std::string& getMainLabel() const; - -private: - int m_promptType; - ButtonLabels m_buttonLabels; - std::string m_mainLabel; -}; - -typedef std::unique_ptr PromptLabelsPtr; - -enum Validity -{ - ONCE, - SESSION, - ALWAYS -}; - -class PromptAnswer -{ -public: - PromptAnswer(bool isAccessAllowed, Validity validity); - PromptAnswer(int aPromptType, unsigned int buttonAns, bool checkAns); - bool isAccessAllowed() const; - Validity getValidity() const; - -private: - bool m_isAccessAllowed; - Validity m_validity; -}; - -class PromptModel -{ - public: - static PromptLabels* getOneShotModel(const std::string& resourceId); - static PromptLabels* getSessionModel(const std::string& resourceId); - static PromptLabels* getBlanketModel(const std::string& resourceId); - - enum PromptType - { - PROMPT_ONESHOT, - PROMPT_SESSION, - PROMPT_BLANKET - }; -}; - -} // Prompt - -#endif /* WRT_SRC_ACCESSCONTROL_ENGINE_PROMPT_MODEL_H_ */ diff --git a/modules/ace/include/dpl/ace-dao-ro/TimedVerdict.h b/modules/ace/include/dpl/ace-dao-ro/TimedVerdict.h deleted file mode 100644 index 1fbac52..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/TimedVerdict.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file TimedVerdict.h - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef ACCESS_CONTROL_DAO_TIMEDVERDICT_H_ -#define ACCESS_CONTROL_DAO_TIMEDVERDICT_H_ - -#include - -namespace AceDB{ - -struct TimedVerdict -{ - VerdictTypes decision; - /*Below values are optional,its filled only when verdict depend on session*/ - std::string session; - int subjectVerdictId; -}; - -} - -#endif diff --git a/modules/ace/include/dpl/ace-dao-ro/ValidityTypes.h b/modules/ace/include/dpl/ace-dao-ro/ValidityTypes.h deleted file mode 100644 index 1283cf1..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/ValidityTypes.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file ValidityTypes.h - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef ACCESS_CONTROL_DAO_VALIDITYTYPES_H_ -#define ACCESS_CONTROL_DAO_VALIDITYTYPES_H_ - -namespace AceDB{ - -enum class ValidityTypes -{ - ONCE, - SESSION, - ALWAYS, - UNWRITEABLE -}; - -} - -#endif diff --git a/modules/ace/include/dpl/ace-dao-ro/VerdictTypes.h b/modules/ace/include/dpl/ace-dao-ro/VerdictTypes.h deleted file mode 100644 index 8a312b5..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/VerdictTypes.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file VerdictTypes.h - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef ACCESS_CONTROL_DAO_VERDICTTYPES_H_ -#define ACCESS_CONTROL_DAO_VERDICTTYPES_H_ - -namespace AceDB{ - -enum class VerdictTypes -{ - VERDICT_PERMIT, - VERDICT_DENY, - //Verdict is innapplicable if policy evaluate to INAPPLICABLE, - //in this case WRT should decide what to do - VERDICT_INAPPLICABLE, - VERDICT_UNDETERMINED, - VERDICT_UNKNOWN, //Verdict is unknown if Verdicts manager cannot find it - VERDICT_ASYNC, - VERDICT_ERROR -}; - -} - -#endif diff --git a/modules/ace/include/dpl/ace-dao-ro/common_dao_types.h b/modules/ace/include/dpl/ace-dao-ro/common_dao_types.h deleted file mode 100644 index 6913766..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/common_dao_types.h +++ /dev/null @@ -1,487 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * @file common_dao_types.h - * @author Michal Ciepielski (m.ciepielski@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of common data types for wrtdb - */ - -#ifndef WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ -#define WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ - -#include -#include -#include -#include -#include -#include -#include - -namespace WrtDB { -namespace Powder { - -typedef std::set StringSet; -//! Widget description -struct Description -{ - //!Content level - typedef enum - { - Level0 = 0, - Level1, - Level2, - Level3, - Level4, - Level5, - LevelUnknown - } LevelEnum; - struct LevelEntry - { - LevelEnum level; //!< content level - - typedef StringSet Context; - - //! POWDER context - //! xa This material appears in an artistic context - //! xb This material appears in an educational context - //! xc This material appears in a medical context - //! xd This material appears in a sports context - //! xe This material appears in a violent context - Context context; - explicit LevelEntry(LevelEnum level = LevelUnknown); - //! Function checks if context is valid - //! \param[in] level POWDER content level - //! \param[in] context POWDER context - bool isContextValid(LevelEnum level, - const DPL::OptionalString& context) const; - }; - - struct CategoryEntry - { - //! Levels entries for POWDER description - typedef std::vector LevelsContainer; - LevelsContainer levels; - //! Function checks if context is valid - //! \param[out] reason set if context invalid - //! \param[in] level POWDER content level - //! \param[in] context POWDER context - bool isCategoryValid(LevelEntry& reason, - LevelEnum level, - const DPL::OptionalString& context) const; - }; - - //! POWDER Category -> Category entry map for Widget - //! - //! nu Nudity - //! se Sex - //! vi Violence - //! la Potentially offensive language - //! dr Drug use - //! ga Gambling - //! ha Hate or harmful activities - //! ug Use of user-generated content - typedef std::map CategoryEntries; - - CategoryEntries categories; - - //! Age rating for widget - //! If Null not set - DPL::OptionalInt ageRating; -}; -} // namespace Powder - -namespace ChildProtection { - -//! Blacklist with forbidden URLs -//! It should be stored in WidgetDAO -typedef std::vector BlackList; - -//! Widget Child protection record -//! Record should be stored in WingetDAO -struct Record -{ - //! Child protection enabled - bool enabled; - explicit Record(bool enabled) : - enabled(enabled) - { - } -}; - -//! Powder processing -struct PowderRules -{ - //! Rule set by parent about forbidden category - //! Powder category - //! nu Nudity - //! se Sex - //! vi Violence - //! la Potentially offensive language - //! dr Drug use - //! ga Gambling - //! ha Hate or harmful activities - //! ug Use of user-generated content - //! Powder context - //! xa This material appears in an artistic conteaxt - //! xb This material appears in an educational context - //! xc This material appears in a medical context - //! xd This material appears in a sports context - //! xe This material appears in a violent context - struct CategoryRule - { - DPL::String category; - Powder::Description::LevelEnum level; - DPL::OptionalString context; - explicit CategoryRule(const DPL::String& category = DPL::String(), - Powder::Description::LevelEnum level = - Powder::Description::LevelUnknown, - const DPL::OptionalString& context = DPL::OptionalString()); - }; - - struct PowderResult - { - //! Reasoning outcome: part of POWDER description used to invalidate - Powder::Description::LevelEntry invalidDescription; - //! Reasoning outcome: rule set by parent not full filed by description - CategoryRule invalidRule; - - //! Reasoning outcome: type of invalidity - enum InvalidReason - { - InvalidRule, //!< One of rules was not fulfilled - InvalidAge, //!< Age is invalid - AgeRatingNotSet, //!< Age rating for widget is not set - Valid //!< Description valid - }; - InvalidReason reason; - explicit PowderResult(InvalidReason reason = Valid, - const Powder::Description::LevelEntry& invalidDescription = - Powder::Description::LevelEntry(), - const CategoryRule& invalidRule = CategoryRule()); - }; - - typedef std::pair ResultPair; - - //! Function checks if rule is fulfilled by description - //! \param[in] rule checked rule - //! \param[in] description - //! \retval true rule is valid - //! \retval false rule is invalid - ResultPair isRuleValidForDescription(const CategoryRule& rule, - const Powder::Description& description) const; - //! Function checks if age limit is fulfilled by description - //! \param[in] description - //! \retval true age is valid - //! \retval false age is invalid - ResultPair isAgeValidForDescription( - const Powder::Description& description) const; - - //! It is the maximum age rating valid for child - //! Uniform age is stored in WidgetDAO - DPL::OptionalInt ageLimit; - - //! Set to true if age rating is required - //! If ageLimit is not set value is ignored - bool isAgeRatingRequired; - - //! Set of rules configured by parent - //! Rules are stored in WidgetDAO and are uniform for all widgets - typedef std::vector RulesContainer; - RulesContainer rules; - - //! Function check if Widget description is valid for ChildProtection - //! configuration - //! \param description widget description - //! \retval true widget is valid - //! \retval false widget is invalid - ResultPair isDescriptionValid(const Powder::Description& description) - const; - - PowderRules() : - isAgeRatingRequired(false) - { - } -}; -} // namespace ChildProtection - -class PluginMetafileData -{ - public: - struct Feature - { - std::string m_name; - std::set m_deviceCapabilities; - - bool operator< (const Feature& obj) const - { - return m_name < obj.m_name; - } - }; - typedef std::set FeatureContainer; - - public: - - PluginMetafileData() - { - } - - std::string m_libraryName; - std::string m_featuresInstallURI; - std::string m_featuresKeyCN; - std::string m_featuresRootCN; - std::string m_featuresRootFingerprint; - - FeatureContainer m_featureContainer; -}; - -class PluginObjectsDAO -{ - public: - typedef std::set Objects; - typedef DPL::SharedPtr ObjectsPtr; - - public: - explicit PluginObjectsDAO() {} - - protected: - ObjectsPtr m_implemented; - ObjectsPtr m_dependent; -}; - -/** - * @brief Widget id describes web-runtime global widget identifier. - * - * Notice that only up to one widget can exist at the same time. - * DbWidgetHandle can be translated into corresponding WidgetModel by invoking - * FindWidgetModel routine. - */ -typedef int DbWidgetHandle; - -/** - * @brief Structure to hold the information of widget's size - */ -struct DbWidgetSize -{ - DPL::OptionalInt width; - DPL::OptionalInt height; - - DbWidgetSize(DPL::OptionalInt w = DPL::OptionalInt::Null, - DPL::OptionalInt h = DPL::OptionalInt::Null) : - width(w), - height(h) - { - } -}; - -inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB) -{ - if (!objA.height || !objA.width || !objB.width || !objB.height) { - return false; - } else { - return *objA.height == *objB.height && *objA.width == *objB.width; - } -} - -/** - * Widget [G]lobal [U]nique [ID]entifier - * Orginated from appstore ID - */ -typedef DPL::OptionalString WidgetGUID; - -struct WidgetAccessInfo -{ - DPL::String strIRI; /* origin iri */ - bool bSubDomains; /* do we want access to subdomains ? */ - - bool operator ==(const WidgetAccessInfo& info) const - { - return info.strIRI == strIRI && - info.bSubDomains == bSubDomains; - } -}; - -typedef std::list WidgetAccessInfoList; - -typedef std::list WindowModeList; - -/** - * @brief Widget configuration parameter key - */ -typedef DPL::String WidgetParamKey; - -/** - * @brief Widget configuration parameter value - */ -typedef DPL::String WidgetParamValue; - -/** - * @brief A map of widget configuration parameters. - * - * Widget configuration parameters are read from database and are stored - * along with feature that they describe. - */ -typedef std::multimap WidgetParamMap; - -/** - * @brief Widget feature host information about possible javascript extensions - * that widget may use - * - * Widget features are declared in configuration file in widget installation - * package. Each declared special feature is contained in some wrt-plugin that - * declares to implement it. After widget launch wrt searches for proper plugin - * libraries and load needed features. - * - * Widget features can be required or optional. It is possible to start widget - * without missing feature. When required feature cannot be loaded widget will - * not start. - */ - -enum { - INVALID_PLUGIN_HANDLE = -1 -}; -typedef int DbPluginHandle; - -struct DbWidgetFeature -{ - DPL::String name; /// Feature name - bool required; /// Whether feature is required - DbPluginHandle pluginId; /// Plugin id that implement this feature - WidgetParamMap params; /// Widget's params - - DbWidgetFeature() : - required(false), - pluginId(INVALID_PLUGIN_HANDLE) - { - } -}; - -inline bool operator < (const DbWidgetFeature &objA, - const DbWidgetFeature &objB) -{ - return objA.name.compare(objB.name) < 0; -} - -inline bool operator==(const DbWidgetFeature &featureA, - const DbWidgetFeature &featureB) -{ - return featureA.name == featureB.name && - featureA.required == featureB.required && - featureA.pluginId == featureB.pluginId; -} - -/** - * @brief Default container for features list - */ -typedef std::multiset DbWidgetFeatureSet; - -/** - * @brief Default container with DbWidgetHandle's - */ -typedef std::list DbWidgetHandleList; - -/** - * @brief Widget specific type - * - * Widget type describes belowed in WAC, TIZEN WebApp - */ -enum AppType -{ - APP_TYPE_UNKNOWN = 0, // unknown - APP_TYPE_WAC10, // WAC 1.0 - APP_TYPE_WAC20, // WAC 2.0 - APP_TYPE_TIZENWEBAPP, // Tizen webapp -}; - -class WidgetType -{ - public: - WidgetType() - :appType(APP_TYPE_UNKNOWN) - { - } - WidgetType(const AppType type) - :appType(type) - { - } - bool operator== (const AppType& other) const - { - return appType == other; - } - std::string getApptypeToString() - { - switch (appType) { -#define X(x) case x: return #x; - X(APP_TYPE_UNKNOWN) - X(APP_TYPE_WAC10) - X(APP_TYPE_WAC20) - X(APP_TYPE_TIZENWEBAPP) -#undef X - default: - return "UNKNOWN"; - } - } - - AppType appType; -}; - -} // namespace WrtDB - -struct WidgetSetting -{ - DPL::String settingName; - DPL::String settingValue; - - bool operator ==(const WidgetSetting& info) const - { - return (info.settingName == settingName && - info.settingValue == settingValue); - } - bool operator !=(const WidgetSetting& info) const - { - return (info.settingName != settingName || - info.settingValue != settingValue); - } -}; - -typedef std::list WidgetSettings; - -/** - * @brief Widget Application Service - * - * Application sercvice describes details of behaviour - * when widget receives aul bundle data. - */ -struct WidgetApplicationService -{ - public: - DPL::String src; /* start uri */ - DPL::String operation; /* service name */ - DPL::String scheme; /* scheme type*/ - DPL::String mime; /* mime type */ - - bool operator== (const WidgetApplicationService& other) const - { - return src == other.src && - operation == other.operation && - scheme == other.scheme && - mime == other.mime; - } -}; - -typedef std::list WidgetApplicationServiceList; -#endif /* WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ */ diff --git a/modules/ace/include/dpl/ace-dao-ro/wrt_db_types.h b/modules/ace/include/dpl/ace-dao-ro/wrt_db_types.h deleted file mode 100644 index a0dc08b..0000000 --- a/modules/ace/include/dpl/ace-dao-ro/wrt_db_types.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * wrt_db_types.h - * - * Created on: Nov 21, 2011 - * Author: Krzysztof Jackiewicz(k.jackiewicz@samsung.com) - */ - -#ifndef WRT_DB_TYPES_H_ -#define WRT_DB_TYPES_H_ - -#include - -typedef WrtDB::DbWidgetHandle WidgetHandle; -typedef WrtDB::DbWidgetHandleList WidgetHandleList; - -typedef WrtDB::DbWidgetFeature WidgetFeature; -typedef WrtDB::DbWidgetFeatureSet WidgetFeatureSet; - -typedef WrtDB::DbWidgetSize WidgetSize; - -typedef WrtDB::DbPluginHandle PluginHandle; - -#endif /* WRT_DB_TYPES_H_ */ diff --git a/modules/ace/include/dpl/ace-dao-rw/AceDAO.h b/modules/ace/include/dpl/ace-dao-rw/AceDAO.h deleted file mode 100644 index 82b86f6..0000000 --- a/modules/ace/include/dpl/ace-dao-rw/AceDAO.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file AceDAO.h - * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef ACEDAO_H_ -#define ACEDAO_H_ - -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace AceDB { -/* - * - */ -class AceDAO : public AceDAOReadOnly -{ - public: - - AceDAO() {} - - // Policy Decisions - static void setPolicyResult( - const BaseAttributeSet &attributes, - const PolicyResult &policyResult); - - static void removePolicyResult( - const BaseAttributeSet &attributes); - - // PromptDecision - static void setPromptDecision( - const DPL::String &hash, - const DPL::String &userParam, - const DPL::OptionalString &session, - PromptDecision decision); - static void setPromptDecision( - const BaseAttributeSet &attributes, - const DPL::String &userParam, - const DPL::OptionalString &session, - PromptDecision decision); - - static void clearPromptDecisions(void); - - // reseting database - static void clearWidgetDevCapSettings(void); - static void clearDevCapSettings(void); - static void clearAllSettings(void); - static void resetDatabase(void); - - // resource settings - static void setDevCapSetting(const std::string &resource, - PreferenceTypes preference); - static void removeDevCapSetting(const std::string &resource); - - // user settings - static void setWidgetDevCapSetting( - const std::string &resource, - WidgetHandle handler, - PreferenceTypes); - static void removeWidgetDevCapSetting( - const std::string &resource, - WidgetHandle handler); - - // resource and subject management - static int addResource(const std::string &request); - - // utilities - static void addAttributes(const BaseAttributeSet &attributes); - - // set static dev cap permissions - // - // (For a given widget handle, a set of device caps is - // granted "statically", i.e. it is determined at installation - // time that the widget will always get (at launch) the SMACK - // permissions needed to use those device caps). - // - // 'permissions' is the set of device cap names to be assigned - // as "statically permitted" to the given widget handle - static void setStaticDevCapPermissions( - int widgetHandle, - const std::set &permissions); - -}; -} -#endif /* ACEDAO_H_ */ diff --git a/modules/ace/include/dpl/ace/AbstractPolicyEnforcementPoint.h b/modules/ace/include/dpl/ace/AbstractPolicyEnforcementPoint.h deleted file mode 100644 index b808a76..0000000 --- a/modules/ace/include/dpl/ace/AbstractPolicyEnforcementPoint.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WRT_SRC_ACCESS_CONTROL_LOGIC_ABSTRACT_POLICY_ENFORCEMENT_POINTS_H -#define WRT_SRC_ACCESS_CONTROL_LOGIC_ABSTRACT_POLICY_ENFORCEMENT_POINTS_H - -#include -#include -#include - -class AbstractPolicyEnforcementPoint -{ - public: - typedef DPL::Event::ICDelegate ResponseReceiver; - virtual PolicyResult check(Request &request) = 0; -}; - -#endif /* WRT_SRC_ACCESS_CONTROL_LOGIC_ABSTRACT_POLICY_ENFORCEMENT_POINTS_H */ diff --git a/modules/ace/include/dpl/ace/AbstractPolicyInformationPoint.h b/modules/ace/include/dpl/ace/AbstractPolicyInformationPoint.h deleted file mode 100644 index e8d95ed..0000000 --- a/modules/ace/include/dpl/ace/AbstractPolicyInformationPoint.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -class AbstractPolicyInformationPoint -{ - public: - virtual ~AbstractPolicyInformationPoint() {} -}; diff --git a/modules/ace/include/dpl/ace/AbstractTreeElement.h b/modules/ace/include/dpl/ace/AbstractTreeElement.h deleted file mode 100644 index 634eea0..0000000 --- a/modules/ace/include/dpl/ace/AbstractTreeElement.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : AbstractTreeElement.h -// @ Date : 2009-05-25 -// @ Author : Samsung -// -// -#if !defined(_ABSTRACTTREEELEMENT_H) -#define _ABSTRACTTREEELEMENT_H - -#include -#include "Effect.h" -#include - -class AbstractTreeElement -{ - public: - - virtual ~AbstractTreeElement() - { - } - - virtual void printData() = 0; - - virtual void serialize(std::ostream& os) = 0; - protected: -}; - -#endif //_ABSTRACTTREEELEMENT_H diff --git a/modules/ace/include/dpl/ace/AsyncVerdictResultListener.h b/modules/ace/include/dpl/ace/AsyncVerdictResultListener.h deleted file mode 100644 index 9b0d4f6..0000000 --- a/modules/ace/include/dpl/ace/AsyncVerdictResultListener.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _ASYNCVERDICT_H -#define _ASYNCVERDICT_H - -#include -#include -#include - -class AsyncVerdictResultListener -{ - public: - virtual void onVerdict(const Verdict &verdict, - const Request *request) = 0; - virtual ~AsyncVerdictResultListener() - { - } -}; - -#endif diff --git a/modules/ace/include/dpl/ace/Attribute.h b/modules/ace/include/dpl/ace/Attribute.h deleted file mode 100644 index ddf100b..0000000 --- a/modules/ace/include/dpl/ace/Attribute.h +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : Attribute.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#if !defined(_ATTRIBUTE_H) -#define _ATTRIBUTE_H - -#include -#include -#include -#include - -#include - -class Attribute : public AceDB::BaseAttribute -{ - public: - /** - * Types of match functions - */ - enum class Match { Equal, Glob, Regexp, Error }; - /** - * Types of attribute value modifiers - */ - enum class Modifier { Non, Scheme, Authority, SchemeAuthority, Host, Path }; - /** - * Possible match results - */ - enum class MatchResult { MRUndetermined = -1, MRFalse = 0, MRTrue = 1}; - - public: - - /** - * New attribute constructor - * @param name name of the new attribute - * @param matchFunction match function used in the attribute - * @param type attribute type - */ - Attribute(const std::string *name, - const Match matchFunction, - const Type type); - - /** - * Constructor used by ACE serializer - * @param is Input stream to which the object will be serialized - * @deprecated - */ - Attribute(std::istream& is); - - /** - * Constructor used to create default attribute ( used for unit tests ) - * @param nm name of the default attribute - */ - Attribute(const std::string& nm) : - matchFunction(Match::Error), - modifierFunction(Modifier::Non) - { - m_name = nm; - m_typeId = Type::Subject; - m_undetermindState = false; - } - - /** - * Destructor - */ - virtual ~Attribute(); - - bool serialize(std::ostream& os) const; - - std::list * getValue() const - { - return AceDB::BaseAttribute::getValue(); - } - Match getMatchFunction() const - { - return matchFunction; - } - - /* --- Setters --- */ - void addValue (const std::string *value); - - MatchResult matchAttributes(const BaseAttribute *) const; - - /** - * Operator used in for attribute set,used to distinguished only attribute names - * It cannot take attribute type into consideration - */ - bool operator< (const Attribute & obj) const - { - int result = this->m_name.compare(*obj.getName()); - if (result == 0) { //If names are equal check attribute types - if (this->m_typeId < obj.getType()) { - result = -1; - } else if (this->m_typeId > obj.getType()) { - result = 1; - } - } - //If result is negative that means that 'this' was '<' than obj - return result < 0; - } - - /** Checks if object type is equal to argument */ - bool instanceOf(Type type_) - { - return type_ == m_typeId; - } - - friend std::ostream & operator<<(std::ostream & out, - const Attribute & attr); - - protected: - - bool searchAndCut(const char *); - - /* - * URI definition from rfc2396 - * - * ://? - * Each of the components may be absent, apart from the scheme. - * Host is a part of authority as in definition below: - * - * authority = server | reg_name - * server = [ [ userinfo "@" ] hostport ] - * @: - * - * Extract from rfc2396 - * The authority component is preceded by a double slash "//" and is - * terminated by the next slash "/", question-mark "?", or by the end of - * the URI. Within the authority component, the characters ";", ":", - * "@", "?", and "/" are reserved. - * - * Modifiers should return pointer to empty string if given part of string was empty. - * Modifiers should return NULL if the string to be modified was not an URI. - */ - std::string * uriScheme(const std::string *) const; - std::string * uriAuthority(const std::string *) const; - std::string * uriSchemeAuthority(const std::string *) const; - std::string * uriHost(const std::string *) const; - std::string * uriPath(const std::string *) const; - std::string * applyModifierFunction(const std::string * val) const; - - bool parse(const std::string *input, - std::string *part) const; - bool find_error(const std::string *part) const; - - bool checkScheme(const std::string *scheme) const; - bool checkAuthority(const std::string *scheme) const; - std::string * getHost(const std::string *scheme) const; - bool checkPath(const std::string *scheme) const; - - bool isSchemeAllowedCharacter(int c) const; - bool isSegmentAllowedCharacter(int c) const; - bool isUserInfoAllowedString(const std::string *str) const; - bool isHostAllowedString(const std::string *str) const; - bool isHostNameAllowedString(const std::string * str) const; - bool isIPv4AllowedString(const std::string * str) const; - bool isDomainLabelAllowedString(const char * data, - int lenght) const; - bool isTopLabelAllowedString(const char* data, - int lenght) const; - - bool isUnreserved(int c) const; - bool isAlphanum(int c) const; - bool isEscaped(const char esc[3]) const; - bool isHex(int c) const; - - MatchResult lists_comparator( - const std::list *first, - const std::list *second, - MatchResult (*comparator)(const std::string *, - const std::string *)) const; - - /** - * Map used to check if character is a 'mark' - */ - static const bool mark[256]; - /** - * Map used to check if character is a 'digit' - * - */ - static const bool digit[256]; - /** - * Map used to check if character is an 'alphanumeric' value - * - */ - static const bool alpha[256]; - - protected: - Match matchFunction; - Modifier modifierFunction; -}; - -typedef AceDB::BaseAttributeSet AttributeSet; - -//TODO remove later or ifdef debug methods -void printAttributes(const AttributeSet& attrs); -void printAttributes(const std::list & attrs); - -#endif //_ATTRIBUTE_H diff --git a/modules/ace/include/dpl/ace/Combiner.h b/modules/ace/include/dpl/ace/Combiner.h deleted file mode 100644 index 62a044f..0000000 --- a/modules/ace/include/dpl/ace/Combiner.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : Combiner.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#if !defined(_COMBINER_H) -#define _COMBINER_H - -#include - -#include -#include - -class Combiner -{ - protected: - - const AttributeSet * attrSet; - - public: - - virtual Effect combineRules(const TreeNode * rule) = 0; - virtual Effect combinePolicies(const TreeNode * policy) = 0; - - const AttributeSet * getAttributeSet() const - { - return this->attrSet; - } - void setAttributeSet(const AttributeSet * attrSet) - { - this->attrSet = attrSet; - } - virtual ~Combiner() - { - } //attrSet is deleted elsewhere -}; - -#endif //_COMBINER_H diff --git a/modules/ace/include/dpl/ace/CombinerImpl.h b/modules/ace/include/dpl/ace/CombinerImpl.h deleted file mode 100644 index 02cd8c6..0000000 --- a/modules/ace/include/dpl/ace/CombinerImpl.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : CombinerImpl.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#ifndef _COMBINER_IMPL_H -#define _COMBINER_IMPL_H - -#include -#include - -#include "Combiner.h" -#include "Effect.h" -#include "Policy.h" -#include "Subject.h" - -class CombinerImpl : public Combiner -{ - public: - - virtual Effect combineRules(const TreeNode * rule); - virtual Effect combinePolicies(const TreeNode * policy); - - virtual ~CombinerImpl() - { - } - - protected: - - bool checkIfTargetMatches(const std::list * subjectsSet, - bool &isUndetermined); - - Effect combine(Policy::CombineAlgorithm algorithm, - std::list & effects); - - Effect denyOverrides(const std::list & effects); - Effect permitOverrides(const std::list & effects); - Effect firstApplicable(const std::list & effects); - Effect firstMatchingTarget(const std::list & effects); - - std::list * convertEffectsToInts(const std::list * effects); - Effect convertIntToEffect(int intEffect); - - void showEffectList(std::list & effects) - { - std::list::iterator it = effects.begin(); - for (; it != effects.end(); ++it) { - LogDebug(toString(*it)); - } - } - - private: - bool isError(const std::list & effects); - static const int - DenyInt, - UndeterminedInt, - PromptOneShotInt, - PromptSessionInt, - PromptBlanketInt, - PermitInt, - InapplicableInt, - NotMatchingTargetInt, - ErrorInt; -}; - -#endif //_COMBINERIMPL_H diff --git a/modules/ace/include/dpl/ace/Condition.h b/modules/ace/include/dpl/ace/Condition.h deleted file mode 100644 index 4574673..0000000 --- a/modules/ace/include/dpl/ace/Condition.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// File: Condition.h -// Author: notroot -// -// Created on June 3, 2009, 9:00 AM -// -#ifndef _CONDITION_H -#define _CONDITION_H - -#include -#include -#include -#include - -#include "Attribute.h" -#include "Effect.h" -#include "TreeNode.h" - -class Condition -{ - public: - enum CombineType - { - AND, OR - }; - - void addCondition(const Condition & condition) - { - this->conditions.push_back(condition); - } - - void addAttribute(const Attribute & attribute) - { - this->attributes.push_back(attribute); - } - - void setCombineType(CombineType type) - { - this->combineType = type; - } - - Condition() : combineType(AND), - parent(NULL) - { - } - - Condition(CombineType type) : combineType(type), - parent(NULL) - { - } - - virtual ~Condition() - { - } - - Condition * getParent() - { - return this->parent; - } - - void setParent(Condition * condition) - { - this->parent = condition; - } - - Attribute::MatchResult evaluateCondition( - const AttributeSet * attrSet) const; - - friend std::ostream & operator<<(std::ostream & out, - Condition & condition) - { - FOREACH (it, condition.attributes) - { - out << *it; - } - return out; - } - //[CR] change function name - void getAttributes(AttributeSet * attrSet); - - //deserializer, TODO - first condition doesnt have Condtion parent - Condition(std::istream&, - Condition* parent = NULL); - - bool serialize(std::ostream&); - - private: - Attribute::MatchResult evaluateChildConditions( - const AttributeSet * attrSet, - bool &isFinalMatch, - bool & undefinedMatchFound) const; - - Attribute::MatchResult evaluateAttributes( - const AttributeSet * attrSet, - bool& isFinalMatch, - bool & undefinedMatchFound) const; - - // KW Attribute::MatchResult performANDalgorithm(const std::set * attributes) const; - - // KW Attribute::MatchResult performORalgorithm(const std::set * attributes) const; - - bool isEmpty() const - { - return attributes.empty() && conditions.empty(); - } - - bool isAndCondition() const - { - return combineType == AND; - } - - bool isOrCondition() const - { - return combineType == OR; - } - - std::list conditions; - CombineType combineType; - std::list attributes; - Condition *parent; -}; - -#endif /* _CONDITION_H */ - diff --git a/modules/ace/include/dpl/ace/ConfigurationManager.h b/modules/ace/include/dpl/ace/ConfigurationManager.h deleted file mode 100644 index 9de311a..0000000 --- a/modules/ace/include/dpl/ace/ConfigurationManager.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _CONFIGURATIONMANAGER_H_ -#define _CONFIGURATIONMANAGER_H_ - -#include -#include -#include -#include -#include "Constants.h" -#include -#include -#include - -#define ATTR_ACTIVE_POLICY BAD_CAST("active") - -#define PARSER_ERROR 1 -#define PARSER_SUCCESS 0 - -class ConfigurationManager -{ - public: - enum ConfigurationManagerResult - { - CM_OPERATION_SUCCESS = 0, - CM_GENERAL_ERROR = -1, - CM_FILE_EXISTS = -2, - CM_REMOVE_ERROR = -3, - CM_REMOVE_CURRENT = -4, - CM_REMOVE_NOT_EXISTING = -5 - }; - - /** - * Current policy file getter - * @return Name of the current ACE policy file - */ - std::string getCurrentPolicyFile(void) const; - - /** - * ACE policy file path getter - * @return Full path to ACE current policy file - */ - std::string getFullPathToCurrentPolicyFile(void) const; - - /** - * ACE policy dtd file path getter - * @return Full path to ACE current policy file - */ - std::string getFullPathToCurrentPolicyXMLSchema(void) const; - - /** - * ACE policy storage path getter - * @return Full path to ACE policy file storage - */ - std::string getStoragePath(void) const; - - /** - * Adds file to ACE policy storage - * @param filePath full path to policy to be added - * @return CM_OPERATION_SUCCESS on success, - * CM_FILE_EXISTS if file with the same name already exists in the storage (the new file is not added), - * other error code on other error - * - */ - int addPolicyFile(const std::string & filePath); - - /** - * Removes file with a given filename from ACE policy storage - * @param fileName name of the policy to be removed - * @return CM_OPERATION_SUCCESS on success, - * CM_REMOVE_CURRENT if file to be removed is a current file (it cannot be removed) - * CM_REMOVE_NOT_EXISTING if file already doesn't exists - * other error code on other error - * - */ - int removePolicyFile(const std::string& fileName); - - //change current PolicyFile - /** - * @param filePath Name of the policy file in the policy storage that should be made - * a current policy file - * @param CM_OPERATION_SUCCESS on success or error code on error - */ - int changeCurrentPolicyFile(const std::string& filePath); - - //TODO this getInstance() method is a little bit to complicated - /** - * Method to obtain instance of configuration manager - * @return retuns pointer to configuration manager or NULL in case of error - */ - static ConfigurationManager * getInstance() - { - if (!instance) { - instance = new ConfigurationManager(); - if (instance->parse(std::string(ACE_CONFIGURATION_PATH)) != - PARSER_SUCCESS) { - delete instance; - LogError( - "Couldn't parse configuration file " ACE_CONFIGURATION_PATH); - return NULL; - } - } - return instance; - } - - /** - * Extracts filename from full path - * @param path Full path from which filename should be extracted - * @return returns extracted filename - */ - std::string extractFilename(const std::string& path) const; - - protected: - - /** - * Parse given ACE configuration file - * @param configFileName full path to configuration file to be parsed - * @return PARSER_SUCCESS on succes, PARSER_ERROR on error - */ - int parse(const std::string &configFileName); - /** - * @param path full path to the file which size should be obtained - * @return size of a given file in bytes - */ - int getFileSize(const std::string & path) const; - bool copyFile(FILE * source, - FILE * destination, - int lenght = 1024) const; - bool checkIfFileExistst(const std::string & newFilePath) const; - - const std::list & getPolicyFiles() const - { - return policyFiles; - } - - const std::string & getConfigFile() const - { - return configFile; - } - - ConfigurationManager() : xmlActive(false) - { - } - virtual ~ConfigurationManager() - { - } - - private: - - /** - * Internal parser methods - */ - void extractFileAttributes(void); - void startNodeHandler(void); - void endNodeHandler(void); - void textNodeHandler(void); - void processNode(void); - //Save configuration file - int saveConfig(); - - //Private fields for parser state representation - xmlTextReaderPtr reader; - std::string currentText; - bool xmlActive; - - static ConfigurationManager * instance; - - /** - * Full path to ACE configuration file - */ - std::string configFile; - /** - * ACE policy file storage path - */ - std::string storagePath; - /** - * Name of the current ACE policy - */ - std::string currentPolicyFile; - /** - * List of available ACE policy files - */ - std::list policyFiles; - - //////////NEW -}; - -#endif - diff --git a/modules/ace/include/dpl/ace/Constants.h b/modules/ace/include/dpl/ace/Constants.h deleted file mode 100644 index db1b798..0000000 --- a/modules/ace/include/dpl/ace/Constants.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file Constants.h - * @author Piotr Fatyga (p.fatyga@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef _CONSTANTS_H -#define _CONSTANTS_H - -#define ACE_MAIN_STORAGE "/usr/etc/ace" -#define ACE_CONFIGURATION_PATH ACE_MAIN_STORAGE "/config.xml" -#define ACE_CONFIGURATION_DTD ACE_MAIN_STORAGE "/config.dtd" -#define ACE_DTD_LOCATION ACE_MAIN_STORAGE "/bondixml.dtd" - -/////////////////FOR GUI////////////////////// - -#define MYSTERIOUS_BITMAP "/usr/apps/org.tizen.policy/d.png" -#define MYSTERIOUS_BITMAP2 "/usr/apps/org.tizen.policy/file.png" - -///////////////////FOR TESTS////////////////////////// - -#define COMBINER_TEST "/usr/etc/ace/CMTest/com_general-test.xml" -#define CONFIGURATION_MGR_TEST_PATH "/usr/etc/ace/CMTest/" -#define CONFIGURATION_MGR_TEST_CONFIG ACE_MAIN_STORAGE "/CMTest/pms_config.xml" -#define CONFIGURATION_MGR_TEST_POLICY_STORAGE ACE_MAIN_STORAGE "/CMTest/active" -#define CONFIGURATION_MGR_TEST_POLICY_STORAGE_MOVED ACE_MAIN_STORAGE \ - "/CMTest/activeMoved" -#define CONFIGURATION_MGR_TEST_POLICY CONFIGURATION_MGR_TEST_POLICY_STORAGE \ - "/pms_general-test.xml" -#define POLICIES_TO_SIGN_DIR ACE_MAIN_STORAGE "/SignerTests/" - -#define OUTPUT_DIR ACE_MAIN_STORAGE "/SignerTests/signedPolicies/" -#define PRIVATE_KEY_DIR ACE_MAIN_STORAGE "/SignerTests/PrvKey/" -#define X509_DATA_BASE_DIR ACE_MAIN_STORAGE "/SignerTests/X509Data/" - -#endif /* _CONSTANTS_H */ - diff --git a/modules/ace/include/dpl/ace/Effect.h b/modules/ace/include/dpl/ace/Effect.h deleted file mode 100644 index 301e821..0000000 --- a/modules/ace/include/dpl/ace/Effect.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : Effect.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#if !defined(_EFFECT_H) -#define _EFFECT_H - -enum Effect -{ - Deny =0, - Undetermined=1, // jk mb added this enum, so the ones below are inceremented!!!!!!! - PromptOneShot =2, - PromptSession =3, - PromptBlanket =4, - Permit =5, - Inapplicable =6, - NotMatchingTarget=7, - Error -}; - -const char * toString(Effect); - -#endif //_EFFECT_H diff --git a/modules/ace/include/dpl/ace/NodeFactory.h b/modules/ace/include/dpl/ace/NodeFactory.h deleted file mode 100644 index 9abb490..0000000 --- a/modules/ace/include/dpl/ace/NodeFactory.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#if !defined(_NODE_FACTORY_H) -#define _NODE_FACTORY_H - -#include -#include "TreeNode.h" -#include "Policy.h" -#include "PolicySet.h" -#include "Rule.h" - -class NodeFactory -{ - public: - static NodeFactory* getInstance(); - AbstractTreeElement* create(std::istream&, - TreeNode:: TypeID); - private: - NodeFactory() - { - } - static NodeFactory* pInstance; -}; - -#endif - diff --git a/modules/ace/include/dpl/ace/PermissionTriple.h b/modules/ace/include/dpl/ace/PermissionTriple.h deleted file mode 100644 index c55f9d7..0000000 --- a/modules/ace/include/dpl/ace/PermissionTriple.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : PermissionTriple.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#if !defined(_PERMISSION_TRIPLE_H) -#define _PERMISSION_TRIPLE_H - -#include -#include -#include -#include - -typedef AceDB::BasePermission PermissionTriple; -typedef AceDB::BasePermissionList PermissionList; - -struct GeneralSetting -{ - GeneralSetting(const std::string& resourceName, - AceDB::PreferenceTypes accessAllowed) : generalSettingName(resourceName), - access(accessAllowed) - { - } - std::string generalSettingName; - AceDB::PreferenceTypes access; -}; - -#endif //_PERMISSION_TRIPLE_H diff --git a/modules/ace/include/dpl/ace/Policy.h b/modules/ace/include/dpl/ace/Policy.h deleted file mode 100644 index e70a355..0000000 --- a/modules/ace/include/dpl/ace/Policy.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : Policy.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#if !defined(_POLICY_H) -#define _POLICY_H - -#include - -#include -#include -#include -#include -#include -#include - -class Policy : public AbstractTreeElement, - DPL::Noncopyable -{ - public: - enum CombineAlgorithm { DenyOverride, PermitOverride, FirstApplicable, - FirstTargetMatching }; - - Policy(std::istream& is); - - void serialize(std::ostream& os); - - Policy() - { - combineAlgorithm = DenyOverride; - subjects = new std::list(); - } - - CombineAlgorithm getCombineAlgorithm() const - { - return this->combineAlgorithm; - } - - void setCombineAlgorithm(CombineAlgorithm algorithm) - { - this->combineAlgorithm = algorithm; - } - - const std::list * getSubjects() const - { - return this->subjects; - } - - void addSubject(const Subject * subject) - { - if (this->subjects == NULL) { - return; - } - this->subjects->push_back(subject); - } - - virtual ~Policy(); - - void printData(); - - std::string printCombineAlgorithm(CombineAlgorithm algorithm); - - private: - std::list *subjects; - CombineAlgorithm combineAlgorithm; -}; - -const char * toString(Policy::CombineAlgorithm algorithm); - -#endif //_POLICY_H diff --git a/modules/ace/include/dpl/ace/PolicyEffect.h b/modules/ace/include/dpl/ace/PolicyEffect.h deleted file mode 100644 index 43c79d7..0000000 --- a/modules/ace/include/dpl/ace/PolicyEffect.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file PolicyEffect.h - * @author B.Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of PolicyEffect type. - */ -#ifndef _SRC_ACCESS_CONTROL_COMMON_POLICY_EFFECT_H_ -#define _SRC_ACCESS_CONTROL_COMMON_POLICY_EFFECT_H_ - -enum class PolicyEffect { - DENY = 0, - PERMIT, - PROMPT_ONESHOT, - PROMPT_SESSION, - PROMPT_BLANKET -}; - -inline static std::ostream & operator<<(std::ostream& stream, - PolicyEffect effect) -{ - switch (effect) { - case PolicyEffect::DENY: stream << "DENY"; break; - case PolicyEffect::PERMIT: stream << "PERMIT"; break; - case PolicyEffect::PROMPT_ONESHOT: stream << "PROMPT_ONESHOT"; break; - case PolicyEffect::PROMPT_SESSION: stream << "PROMPT_SESSION"; break; - case PolicyEffect::PROMPT_BLANKET: stream << "PROMPT_BLANKET"; break; - default: Assert(false && "Invalid PolicyEffect constant"); - } - return stream; -} - -#endif // _SRC_ACCESS_CONTROL_COMMON_POLICY_EFFECT_H_ diff --git a/modules/ace/include/dpl/ace/PolicyEnforcementPoint.h b/modules/ace/include/dpl/ace/PolicyEnforcementPoint.h deleted file mode 100644 index 027e4d9..0000000 --- a/modules/ace/include/dpl/ace/PolicyEnforcementPoint.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This class simply redirects the access requests to access control engine. - * The aim is to hide access control engine specific details from WRT modules. - * It also implements WRT_INTERFACE.h interfaces, so that ACE could access - * WRT specific and other information during the decision making. - * - * @file security_logic.h - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @author Ming Jin(ming79.jin@samsung.com) - * @brief Implementation file for security logic - */ -#ifndef POLICY_ENFORCEMENT_POINT_H -#define POLICY_ENFORCEMENT_POINT_H - -#include -#include -#include - -//#include -//#include -//#include - -//#include -#include -#include - -#include -#include - -// Forwards -class IWebRuntime; -class IResourceInformation; -class IOperationSystem; -class PolicyEvaluator; -class PolicyInformationPoint; -class Request; - -class PolicyEnforcementPoint : public AbstractPolicyEnforcementPoint -{ - public: - OptionalPolicyResult checkFromCache(Request &request); - PolicyResult check(Request &request); - OptionalPolicyResult check(Request &request, - bool fromCacheOnly); - - virtual ~PolicyEnforcementPoint(); - - class PEPException - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, AlreadyInitialized) - }; - - /** - * This function take ownership of objects pass in call. - * Object will be deleted after call Deinitialize function. - */ - void initialize(IWebRuntime *wrt, - IResourceInformation *resource, - IOperationSystem *operation); - void terminate(); - - void updatePolicy(const std::string &policy); - - PolicyEvaluator *getPdp() const { return this->m_pdp; } - PolicyInformationPoint *getPip() const { return this->m_pip; } - - protected: - PolicyEnforcementPoint(); - friend class SecurityLogic; - private: // private data - IWebRuntime *m_wrt; - IResourceInformation *m_res; - IOperationSystem *m_sys; - PolicyEvaluator *m_pdp; - PolicyInformationPoint *m_pip; -}; - -#endif // POLICY_ENFORCEMENT_POINT_H diff --git a/modules/ace/include/dpl/ace/PolicyEvaluator.h b/modules/ace/include/dpl/ace/PolicyEvaluator.h deleted file mode 100644 index 418faef..0000000 --- a/modules/ace/include/dpl/ace/PolicyEvaluator.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : PolicyEvaluator.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#ifndef _POLICY_EVALUATOR_H -#define _POLICY_EVALUATOR_H - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -class PolicyEvaluator : DPL::Noncopyable -{ - protected: - - /** - * Internal method used to initiate policy evaluation. Called after attribute set has been fetched - * by PIP. - * @param root root of the policies tree to be evaluated - */ - virtual Effect evaluatePolicies(const TreeNode * root); - - enum updateErrors - { - POLICY_PARSING_SUCCESS = 0, - POLICY_FILE_ERROR = 1, - PARSER_CREATION_ERROR, - POLICY_PARSING_ERROR - }; - private: - AttributeSet m_attributeSet; - - TreeNode * m_root; - Combiner * m_combiner; - AsyncVerdictResultListener * m_verdictListener; - PolicyInformationPoint * m_pip; - // Required by unittests. - std::string m_currentPolicyFile; - - /** - * Method used to extract attributes from subtree defined by PolicySet - * @param root original TreeStructure root node - * @param newRoot copy of TreeStructure containing only policies that matches current request - * - */ - void extractAttributesFromSubtree(const TreeNode *root); - - /** - * Method used to extract attributes from Tree Structure - * @return pointer to set of attributes needed to evaluate current request - * @return if extraction has been successful - * TODO return reducte tree structure - * TODO change comments - */ - bool extractAttributesFromRules(const TreeNode *); - - /** - * Extracts attributes from target of a given policy that are required to be fetched by PIP - */ - void extractTargetAttributes(const Policy *policy); - bool extractAttributes(); - - OptionalPolicyResult getPolicyForRequestInternal(bool fromCacheOnly); - PolicyResult effectToPolicyResult(Effect effect); - public: - PolicyEvaluator(PolicyInformationPoint * pip) : - m_root(NULL), - m_combiner(new CombinerImpl()), - m_verdictListener(NULL), - m_pip(pip) - { - } - - bool extractAttributesTest() - { - m_attributeSet.clear(); - if (!extractAttributes()) { - LogInfo("Warnign attribute set cannot be extracted. Returning Deny"); - return true; - } - - return extractAttributes(); - } - - AttributeSet * getAttributeSet() - { - return &m_attributeSet; - } - - virtual bool initPDP(); - virtual ~PolicyEvaluator(); - virtual PolicyResult getPolicyForRequest(const Request &request); - virtual OptionalPolicyResult getPolicyForRequestFromCache( - const Request &request); - virtual OptionalPolicyResult getPolicyForRequest(const Request &request, - bool fromCacheOnly); - bool fillAttributeWithPolicy(); - - virtual int updatePolicy(const char *); - // Required by unittests. - // It's used to check environment before each unittest. - std::string getCurrentPolicy(); -}; - -#endif //_POLICYEVALUATOR_H diff --git a/modules/ace/include/dpl/ace/PolicyEvaluatorFactory.h b/modules/ace/include/dpl/ace/PolicyEvaluatorFactory.h deleted file mode 100644 index 19ad88e..0000000 --- a/modules/ace/include/dpl/ace/PolicyEvaluatorFactory.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file AbstractObjectFactory.h - * @author Piotr Fatyga (p.fatyga@samsung.com) - * @version 0.1 - * @brief - */ - -#ifndef _ABSTRACTOBJECTFACTORY_H -#define _ABSTRACTOBJECTFACTORY_H - -#include - -class AbstractPolicyEvaluatorFactory -{ - public: - virtual PolicyEvaluator * createPolicyEvaluator(PolicyInformationPoint *pip) - const = 0; -}; - -class PolicyEvaluatorFactory : public AbstractPolicyEvaluatorFactory -{ - public: - PolicyEvaluator * createPolicyEvaluator(PolicyInformationPoint *pip) const - { - return new PolicyEvaluator(pip); - } -}; - -#endif /* _ABSTRACTOBJECTFACTORY_H */ - diff --git a/modules/ace/include/dpl/ace/PolicyInformationPoint.h b/modules/ace/include/dpl/ace/PolicyInformationPoint.h deleted file mode 100644 index 2b3de29..0000000 --- a/modules/ace/include/dpl/ace/PolicyInformationPoint.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : PolicyInformationPoint.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#ifndef _POLICY_INFORMATION_POINT_H -#define _POLICY_INFORMATION_POINT_H - -#include - -#include -#include - -#include - -#include - -typedef int PipResponse; - -class PolicyInformationPoint -{ - private: - - /** queries for interfaces*/ - std::list resourceAttributesQuery; - std::list environmentAttributesQuery; - std::list subjectAttributesQuery; - std::list functionParamAttributesQuery; - - /** create queries */ - void createQueries(AttributeSet* attributes); - - IWebRuntime* wrtInterface; - IResourceInformation* resourceInformation; - IOperationSystem* operationSystem; - - public: - static const int ERROR_SHIFT_RESOURCE = 3; - static const int ERROR_SHIFT_OS = 6; - static const int ERROR_SHIFT_FP = 9; - - /** Mask used to identify PIP error */ - enum ResponseTypeMask - { - SUCCESS = 0, - /* WebRuntime Error */ - WRT_UNKNOWN_SUBJECT = 1 << 0, - WRT_UNKNOWN_ATTRIBUTE = 1 << 1, - WRT_INTERNAL_ERROR = 1 << 2, - /* Resource Information Storage Error */ - RIS_UNKNOWN_RESOURCE = 1 << 3, - RIS_UNKNOWN_ATTRIBUTE = 1 << 4, - RIS_INTERNAL_ERROR = 1 << 5, - /*Operating system */ - OS_UNKNOWN_ATTRIBUTE = 1 << 6, - OS_INTERNAL_ERROR = 1 << 7 - }; - - //TODO add checking values of attributes - /** gather attributes values from adequate interfaces */ - virtual PipResponse getAttributesValues(const Request* request, - AttributeSet* attributes); - virtual ~PolicyInformationPoint(); - PolicyInformationPoint(IWebRuntime *wrt, - IResourceInformation *resource, - IOperationSystem *system) : wrtInterface(wrt), - resourceInformation(resource), - operationSystem(system) - { - } - virtual void update(IWebRuntime *wrt, - IResourceInformation *resource, - IOperationSystem *system) - { - wrtInterface = wrt; - resourceInformation = resource; - operationSystem = system; - } - IWebRuntime * getWebRuntime() - { - return wrtInterface; - } -}; - -#endif //_POLICY_INFORMATION_POINT_H diff --git a/modules/ace/include/dpl/ace/PolicyResult.h b/modules/ace/include/dpl/ace/PolicyResult.h deleted file mode 100644 index 8ccb41e..0000000 --- a/modules/ace/include/dpl/ace/PolicyResult.h +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _SRC_ACCESS_CONTROL_COMMON_POLICY_RESULT_H_ -#define _SRC_ACCESS_CONTROL_COMMON_POLICY_RESULT_H_ - -#include -#include -#include - -#include - -typedef DPL::Optional OptionalPolicyEffect; - -class PolicyDecision -{ -public: - enum Value { NOT_APPLICABLE = -1 }; - - PolicyDecision(PolicyEffect effect) - : m_isPolicyEffect(true) - , m_effect(effect) - {} - - PolicyDecision(const PolicyDecision &decision) - : m_isPolicyEffect(decision.m_isPolicyEffect) - , m_effect(decision.m_effect) - {} - - PolicyDecision(Value) - : m_isPolicyEffect(false) - {} - - bool operator==(const PolicyDecision &decision) const { - return (m_isPolicyEffect - && decision.m_isPolicyEffect - && m_effect == decision.m_effect) - || (!m_isPolicyEffect && !decision.m_isPolicyEffect); - } - - bool operator==(Value) const { - return !m_isPolicyEffect; - } - - bool operator!=(const PolicyDecision &decision) const { - return !(*this == decision); - } - - bool operator!=(Value value) const { - return !(*this == value); - } - - OptionalPolicyEffect getEffect() const - { - if (!m_isPolicyEffect) { - return OptionalPolicyEffect(); - } - return OptionalPolicyEffect(m_effect); - } - - std::ostream & toStream(std::ostream& stream) { - if (m_isPolicyEffect) - stream << m_effect; - else - stream << "NOT-APPLICABLE"; - return stream; - } - -private: - bool m_isPolicyEffect; - PolicyEffect m_effect; -}; - -inline static bool operator==(PolicyEffect e, const PolicyDecision &d) { - return d.operator==(e); -} - -inline static bool operator!=(PolicyEffect e, const PolicyDecision &d) { - return !(e == d); -} - -inline static std::ostream & operator<<(std::ostream& stream, - PolicyDecision decision) -{ - return decision.toStream(stream); -} - -class PolicyResult { -public: - enum Value { UNDETERMINED = -2 }; - - // This constructor is required by dpl controller and by dpl optional - PolicyResult() - : m_isDecision(false) - , m_decision(PolicyDecision::Value::NOT_APPLICABLE) // don't care - {} - - PolicyResult(PolicyEffect effect) - : m_isDecision(true) - , m_decision(effect) - {} - - PolicyResult(const PolicyDecision &decision) - : m_isDecision(true) - , m_decision(decision) - {} - - PolicyResult(const PolicyResult &result) - : m_isDecision(result.m_isDecision) - , m_decision(result.m_decision) - {} - - PolicyResult(PolicyDecision::Value value) - : m_isDecision(true) - , m_decision(value) - {} - - PolicyResult(Value) - : m_isDecision(false) - , m_decision(PolicyDecision::Value::NOT_APPLICABLE) // don't care - {} - - bool operator==(const PolicyResult &result) const { - return (m_isDecision - && result.m_isDecision - && m_decision == result.m_decision) - || (!m_isDecision && !result.m_isDecision); - } - - bool operator==(Value) const { - return !m_isDecision; - } - - bool operator!=(const PolicyResult &result) const { - return !(*this == result); - } - - bool operator!=(Value value) const { - return !(*this == value); - } - - OptionalPolicyEffect getEffect() const - { - if (!m_isDecision) { - return OptionalPolicyEffect(); - } - return m_decision.getEffect(); - } - - static int serialize(const PolicyResult &policyResult) - { - if (!policyResult.m_isDecision) { - return BD_UNDETERMINED; - } else if (policyResult.m_decision == - PolicyDecision::Value::NOT_APPLICABLE) - { - return BD_NOT_APPLICABLE; - } else if (policyResult.m_decision == PolicyEffect::PROMPT_BLANKET) { - return BD_PROMPT_BLANKET; - } else if (policyResult.m_decision == PolicyEffect::PROMPT_SESSION) { - return BD_PROMPT_SESSION; - } else if (policyResult.m_decision == PolicyEffect::PROMPT_ONESHOT) { - return BD_PROMPT_ONESHOT; - } else if (policyResult.m_decision == PolicyEffect::PERMIT) { - return BD_PERMIT; - } else if (policyResult.m_decision == PolicyEffect::DENY) { - return BD_DENY; - } - Assert(false && "Unknown value of policyResult."); - } - - static PolicyResult deserialize(int dec){ - switch (dec) { - case BD_DENY: - return PolicyEffect::DENY; - case BD_PERMIT: - return PolicyEffect::PERMIT; - case BD_PROMPT_ONESHOT: - return PolicyEffect::PROMPT_ONESHOT; - case BD_PROMPT_SESSION: - return PolicyEffect::PROMPT_SESSION; - case BD_PROMPT_BLANKET: - return PolicyEffect::PROMPT_BLANKET; - case BD_NOT_APPLICABLE: - return PolicyDecision::Value::NOT_APPLICABLE; - case BD_UNDETERMINED: - return Value::UNDETERMINED; - } - Assert(false && "Broken database"); - } - - std::ostream & toStream(std::ostream& stream) { - if (m_isDecision) - stream << m_decision; - else - stream << "UNDETERMINED"; - return stream; - } - -private: - static const int BD_UNDETERMINED = 6; - static const int BD_NOT_APPLICABLE = 5; - static const int BD_PROMPT_BLANKET = 4; - static const int BD_PROMPT_SESSION = 3; - static const int BD_PROMPT_ONESHOT = 2; - static const int BD_PERMIT = 1; - static const int BD_DENY = 0; - - bool m_isDecision; - PolicyDecision m_decision; -}; - -inline static bool operator==(const PolicyDecision &d, const PolicyResult &r) { - return r == d; -} - -inline static bool operator!=(const PolicyDecision &d, const PolicyResult &r) { - return !(d == r); -} - -inline static bool operator==(const PolicyEffect &e, const PolicyResult &r) { - return e == r; -} - -inline static bool operator!=(const PolicyEffect &e, const PolicyResult &r) { - return !(e == r); -} - -inline static std::ostream & operator<<(std::ostream& stream, - PolicyResult result) -{ - return result.toStream(stream); -} - -typedef DPL::Optional OptionalPolicyResult; - -#endif // _SRC_ACCESS_CONTROL_COMMON_POLICY_RESULT_H_ diff --git a/modules/ace/include/dpl/ace/PolicySet.h b/modules/ace/include/dpl/ace/PolicySet.h deleted file mode 100644 index 6d6307d..0000000 --- a/modules/ace/include/dpl/ace/PolicySet.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : PolicySet.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#if !defined(_POLICYSET_H) -#define _POLICYSET_H - -#include "Policy.h" -#include - -class PolicySet : public Policy -{ - public: - - //TODO Clean this class - //PolicySet(CombineAlgorithm algorithm, std::list * targetAttr,const std::string & subjectId) - // : Policy(algorithm,targetAttr,subjectId) - // {} - PolicySet() - { - } - ~PolicySet() - { - } - - PolicySet(std::istream& is) : Policy(is) - { - } -}; - -#endif //_POLICYSET_H diff --git a/modules/ace/include/dpl/ace/Preference.h b/modules/ace/include/dpl/ace/Preference.h deleted file mode 100644 index 97b34fc..0000000 --- a/modules/ace/include/dpl/ace/Preference.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : Preference.h -// @ Date : 2009-05-2 -// @ Author : Samsung -// -// - -#ifndef _Preference_H_ -#define _Preference_H_ - -#include -#include - -#include - -typedef AceDB::PreferenceTypes Preference; -typedef AceDB::PreferenceTypesMap PreferenceMap; - -#endif //_Preference_H - diff --git a/modules/ace/include/dpl/ace/PromptDecision.h b/modules/ace/include/dpl/ace/PromptDecision.h deleted file mode 100644 index bfe425b..0000000 --- a/modules/ace/include/dpl/ace/PromptDecision.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _SRC_ACCESS_CONTROL_COMMON_PROMPT_DECISION_H_ -#define _SRC_ACCESS_CONTROL_COMMON_PROMPT_DECISION_H_ - -#include -#include - -enum class PromptDecision { - ALLOW_ALWAYS, - DENY_ALWAYS, - ALLOW_THIS_TIME, - DENY_THIS_TIME, - ALLOW_FOR_SESSION, - DENY_FOR_SESSION -}; - -typedef DPL::Optional OptionalPromptDecision; - -struct CachedPromptDecision { - PromptDecision decision; - DPL::OptionalString session; -}; - -typedef DPL::Optional OptionalCachedPromptDecision; - -#endif // _SRC_ACCESS_CONTROL_COMMON_PROMPT_DECISION_H_ diff --git a/modules/ace/include/dpl/ace/Request.h b/modules/ace/include/dpl/ace/Request.h deleted file mode 100644 index c29def4..0000000 --- a/modules/ace/include/dpl/ace/Request.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : Request.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#ifndef _REQUEST_H_ -#define _REQUEST_H_ - -#include -#include -#include - -#include - -#include - -class Request : public AceDB::IRequest -{ - public: - typedef std::string DeviceCapability; - typedef std::set DeviceCapabilitySet; - - Request(WidgetHandle widgetHandle, - WidgetExecutionPhase phase, - IFunctionParam *functionParam = 0) - : m_widgetHandle(widgetHandle) - , m_phase(phase) - , m_functionParam(functionParam) - {} - - WidgetHandle getWidgetHandle() const - { - return m_widgetHandle; - } - - WidgetExecutionPhase getExecutionPhase() const - { - return m_phase; - } - - IFunctionParam *getFunctionParam() const - { - return m_functionParam; - } - - void addDeviceCapability(const std::string& device) - { - m_devcapSet.insert(device); - } - - DeviceCapabilitySet getDeviceCapabilitySet() const - { - return m_devcapSet; - } - - private: - WidgetHandle m_widgetHandle; - WidgetExecutionPhase m_phase; - //! \brief list of function param (only for intercept) - IFunctionParam *m_functionParam; - //! \brief Set of defice capabilities - DeviceCapabilitySet m_devcapSet; -}; - -typedef std::vector Requests; - -#endif //_REQUEST_H_ diff --git a/modules/ace/include/dpl/ace/Rule.h b/modules/ace/include/dpl/ace/Rule.h deleted file mode 100644 index 7877ced..0000000 --- a/modules/ace/include/dpl/ace/Rule.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : Rule.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#if !defined(_RULE_H) -#define _RULE_H - -#include "Attribute.h" -#include "Effect.h" -#include "Condition.h" -#include - -class Rule : public AbstractTreeElement -{ - public: - - Effect evaluateRule(const AttributeSet * attrSet) const; - - // KW Rule(Effect effect, Condition condition) : effect(effect), condition(condition) { - // KW //TODO we should set it to deny or smth, not inapplicable - // KW } - - Rule() - { - //TODO we should set it to deny or smth, not inapplicable - this->effect = Inapplicable; - } - - // KW Effect getEffect() const { - // KW return this->effect; - // KW }; - - void setEffect(Effect effect) - { - //We should not allow to set "Inapplicable" effect. - //Rules cannot have effect that is inapplicable, evaluation of the rules may however - //render the effect inapplicable. - Assert(effect != Inapplicable); - this->effect = effect; - } - void setCondition(Condition condition) - { - this->condition = condition; - } - void getAttributes(AttributeSet * attrSet) - { - condition.getAttributes(attrSet); - } - - //deserialize - Rule(std::istream& is); - void serialize(std::ostream& os); - - //DEBUG methods - std::string printEffect(const Effect effect) const; - void printData(); - - private: - - Effect effect; - Condition condition; -}; - -#endif //_RULE_H diff --git a/modules/ace/include/dpl/ace/Serializer.h b/modules/ace/include/dpl/ace/Serializer.h deleted file mode 100644 index 1e1c4cb..0000000 --- a/modules/ace/include/dpl/ace/Serializer.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#if !defined(_SERIALIZER_H) -#define _SERIALIZER_H - -#include -#include -#include - -#include "TreeNode.h" -#include "Attribute.h" -#include "Subject.h" -#include "Policy.h" -#include "Condition.h" - -class Serializer -{ - public: - static Serializer* getInstance(); - - /**** Interaface ****************/ - - /** - * Serialized tree given by - * @param root - * */ - // KW void serializeTree(TreeNode* root); - - /** - * deserialize tree - * @return pointer to deserialized tree - * or NULL if error occur - * */ - // KW TreeNode* deserializeTree(); - - /* ------------------------------*/ - - void serializeInt(std::ostream& os, - const int value); - int deserializeInt(std::istream& is); - - void serializeString(std::ostream& os, - const std::string& text) const; - std::string deserializeString(std::istream& is); - - void serializeListAttributes(std::ostream& os, - const std::list& inputList); - std::list deserializeListAttributes(std::istream& is); - - void serializeType(std::ostream& os, - const Attribute::Type& typeId) const; - Attribute::Type deserializeType(std::istream& is); - - void serializeListStrings(std::ostream& os, - const std::list& inputList) const; - - std::list deserializeListStrings(std::istream&is); - - void serializeMatch(std::ostream& os, - const Attribute::Match& match) const; - Attribute::Match deserializeMatch(std::istream& is); - //TODO add smartptr - bool serializeModifier(std::ostream& os, - const Attribute::Modifier& modifier) const; - Attribute::Modifier deserializeModifier(std::istream& is); - - void serializeListTreeNode(std::ostream& os, - std::list& inputList); - std::list deserializeListTreeNode(std::istream&is, - TreeNode* parent); - - void serializeTypeAbstract(std::ostream& os, - const TreeNode::TypeID& typeId); - TreeNode::TypeID deserializeTypeAbstract(std::istream& is); - - void serializeAbstractElement(std::ostream& os, - AbstractTreeElement* element); - AbstractTreeElement* deserializeAbstractElement(std::istream& is, - TreeNode::TypeID&); - - void serializeListSubjects(std::ostream& os, - std::list& inputList); - std::list* deserializeListSubjects(std::istream& is); - - void serializeCombineAlgorithm(std::ostream& os, - const Policy::CombineAlgorithm & combAlg); - Policy::CombineAlgorithm deserializeCombineAlgorithm(std::istream& is); - - void serializeCombineType(std::ostream& os, - const Condition::CombineType& combType); - Condition::CombineType deserializeCombineType(std::istream& is); - - void serializeListConditions(std::ostream& os, - std::list& inputList); - std::list deserializeListConditions(std::istream& is, - Condition* parent); - - void serializeEffect(std::ostream& os, - Effect effect); - Effect deserializeEffect(std::istream& is); - - void serializeCondition(std::ostream& os, - Condition& cond); - Condition& deserializeCondition(std::istream& is); - - private: - Serializer() - { - } - static Serializer* pInstance; - - std::filebuf fileBuffer; -}; - -#endif - diff --git a/modules/ace/include/dpl/ace/SettingsLogic.h b/modules/ace/include/dpl/ace/SettingsLogic.h deleted file mode 100644 index 62096db..0000000 --- a/modules/ace/include/dpl/ace/SettingsLogic.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file SettingsLogic.h - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 0.1 - * @brief Header file for class getting/setting user/global ACE settings - */ - -#ifndef WRT_SRC_ACCESS_CONTROL_LOGIC_SETTINGS_LOGIC_H_ -#define WRT_SRC_ACCESS_CONTROL_LOGIC_SETTINGS_LOGIC_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class SettingsLogic -{ - public: - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, DatabaseError) - }; - - // global settings - static AceDB::PreferenceTypes findGlobalUserSettings( - const std::string &resource, - WidgetHandle handler); - - static AceDB::PreferenceTypes findGlobalUserSettings( - const Request &request); - - // resource settings - static AceDB::PreferenceTypes getDevCapSetting( - const std::string &request); - static void getDevCapSettings(AceDB::PreferenceTypesMap *preferences); - static void setDevCapSetting(const std::string &resource, - AceDB::PreferenceTypes preference); - static void setAllDevCapSettings( - const std::list > &resourcesList); - static void removeDevCapSetting(const std::string &resource); - static void updateDevCapSetting(const std::string &resource, - AceDB::PreferenceTypes p); - - // user settings - static AceDB::PreferenceTypes getWidgetDevCapSetting( - const std::string &resource, - WidgetHandle handler); - static void getWidgetDevCapSettings(PermissionList *permissions); - static void setWidgetDevCapSetting(const std::string &resource, - WidgetHandle handler, - AceDB::PreferenceTypes preference); - static void setWidgetDevCapSettings(const PermissionList &tripleList); - static void removeWidgetDevCapSetting(const std::string &resource, - WidgetHandle handler); - - private: - SettingsLogic() - { - } - -}; - -#endif /* WRT_SRC_ACCESS_CONTROL_LOGIC_SETTINGS_LOGIC_H_ */ diff --git a/modules/ace/include/dpl/ace/Subject.h b/modules/ace/include/dpl/ace/Subject.h deleted file mode 100644 index 5821429..0000000 --- a/modules/ace/include/dpl/ace/Subject.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// File: Subject.h -// Author: notroot -// -// Created on June 2, 2009, 8:47 AM -// - -#ifndef _SUBJECT_H -#define _SUBJECT_H - -#include -#include -#include -#include -#include - -#include "Attribute.h" - -class Subject : DPL::Noncopyable -{ - std::string subjectId; - std::list targetAttributes; - - public: - Subject() - {} - - //deserialize - Subject(std::istream&); - - virtual bool serialize (std::ostream& os); - - const std::list& getTargetAttributes() const; - - void setSubjectId(const std::string & subjectId) - { - this->subjectId = subjectId; - } - - //TODO maybe we should remove that becuase this causes a memory leak right now!! [CR] maybe thats true, maybe whe can remove this fun - // KW void setTargetAttributes(std::list * targetAttributes){ this->targetAttributes = targetAttributes; } - - const std::string & getSubjectId() const - { - return this->subjectId; - } - - void addNewAttribute(Attribute & attr) - { - this->targetAttributes.push_back(attr); - } - - //TODO in 1.0 change to true/false/undetermined - bool matchSubject(const AttributeSet *attrSet, - bool &isUndetermined) const; - - ~Subject() - {} -}; - -#endif /* _SUBJECT_H */ - diff --git a/modules/ace/include/dpl/ace/TestTimer.h b/modules/ace/include/dpl/ace/TestTimer.h deleted file mode 100644 index 1f07e61..0000000 --- a/modules/ace/include/dpl/ace/TestTimer.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _TEST_TIMER_H -#define _TEST_TIMER_H - -#include - -class TestTimer -{ - time_t startt, endt; - - public: - void start() - { - time(&startt); - } - void stop() - { - time(&endt); - } - double getTime() - { - return difftime(endt, startt); - } -}; - -#endif //_TEST_TIMER_H - diff --git a/modules/ace/include/dpl/ace/TreeNode.h b/modules/ace/include/dpl/ace/TreeNode.h deleted file mode 100644 index 05bb0e6..0000000 --- a/modules/ace/include/dpl/ace/TreeNode.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : TreeNode.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#ifndef _TREE_NODE_H -#define _TREE_NODE_H - -#include -#include - -#include - -class TreeNode; - -typedef std::list ChildrenSet; -typedef std::list::iterator ChildrenIterator; -typedef std::list::const_iterator ChildrenConstIterator; - -class TreeNode -{ - public: - //TODO nazwac pozadnie TYPY - moze jakas konwencja ... ??!! - enum TypeID { Policy =0, PolicySet=1, Rule=2}; - - virtual bool serialize(std::ostream& os); - - TreeNode(std::istream& is, - TreeNode* parent); - - const ChildrenSet & getChildrenSet() const - { - return children; - } - - TreeNode * getParent() const - { - return this->parent; - } - - void setParent(TreeNode *parent) - { - this->parent = parent; - } - - TypeID getTypeID() const - { - return this->typeID; - } - - void addChild(TreeNode *child) - { - child->setParent(this); - children.push_back(child); - } - - /** - * Clone the node - */ - // KW TreeNode * clone() { return new TreeNode(NULL,this->getTypeID(),this->getElement()); } - - TreeNode(TreeNode * parent, - TypeID type, - AbstractTreeElement * element) : - parent(parent), - typeID(type), - element(element) - { - } - - AbstractTreeElement * getElement() const - { - return element; - } - - private: - virtual ~TreeNode(); - - public: - /* - * It is common that we create a copy of tree structure created out of xml file. However we don't want to - * copy abstract elements ( Policies and Rules ) because we need them only for reading. We want to modify the - * tree structure though. Therefore we copy TreeNode. When the copy of the original tree is being destroyed method - * releaseTheSubtree should be called on "root". It automatically traverse the tree and call TreeNode destructors for - * each TreeNode in the tree. It doesn't remove the abstract elements in the tree ( there is always at most one abstract - * element instance, when tree is copied it is a shallow copy. - * When we want to completely get rid of the the tree and abstract elements we have to call releaseResources on tree root. - * We may want to do this for instance when we want to serialize the tree to disc. releaseResource method traverses the tree - * and releses the resources, as well as the TreeNode so NO releaseTheSubtree is required any more - */ - void releaseResources(); - - /** - * Used to delete the copies of tree structure. The original tree structure should be removed with releaseResources method. - * ReleaseTheSubtree method doesn't delete the abstract elements, only TreeNodes. It traverses the whole tree, so it should be - * called on behalf of root of the tree - */ - // KW void releaseTheSubtree(); - - friend std::ostream & operator<<(std::ostream & out, - const TreeNode * node); - // KW void printSubtree(); - - private: - // KW TreeNode(const TreeNode& pattern){ (void)pattern; } - - std::list children; - TreeNode * parent; - //TODO standarize ID case - TypeID typeID; - AbstractTreeElement * element; - static int level; -}; - -#endif //_TREE_NODE_H diff --git a/modules/ace/include/dpl/ace/UserDecision.h b/modules/ace/include/dpl/ace/UserDecision.h deleted file mode 100644 index 4bc405d..0000000 --- a/modules/ace/include/dpl/ace/UserDecision.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : UserDecision.h -// @ Date : 2009-05-22 -// @ Author : Samsung -// -// - -#ifndef _USERDECISION_H -#define _USERDECISION_H - -#include -#include - -typedef AceDB::ValidityTypes Validity; - -const char * toString(Validity validity); - -#endif //_USERDECISION_H - diff --git a/modules/ace/include/dpl/ace/Verdict.h b/modules/ace/include/dpl/ace/Verdict.h deleted file mode 100644 index 805d02a..0000000 --- a/modules/ace/include/dpl/ace/Verdict.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : Verdict.h -// @ Date : 2009-05-2 -// @ Author : Samsung -// -// - -#ifndef _VERDICT_H -#define _VERDICT_H - -#include -#include -#include - -typedef AceDB::VerdictTypes Verdict; -//typedef AceDB::TimedVerdict TimedVerdict; - -const char * toString(Verdict verditct); - -#endif //_VERDICT_H - diff --git a/modules/ace/include/dpl/ace/WRT_INTERFACE.h b/modules/ace/include/dpl/ace/WRT_INTERFACE.h deleted file mode 100644 index 2f5b80b..0000000 --- a/modules/ace/include/dpl/ace/WRT_INTERFACE.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _WRT_INERFACE_4_ACE_EXAMPLE_H_ -#define _WRT_INERFACE_4_ACE_EXAMPLE_H_ - -#include -#include -#include - -#include - -class Request; - -enum WidgetExecutionPhase -{ - WidgetExecutionPhase_Unknown = 0, - WidgetExecutionPhase_WidgetInstall = 1 << 0, - WidgetExecutionPhase_WidgetInstantiate = 1 << 1, - WidgetExecutionPhase_WebkitBind = 1 << 2, - WidgetExecutionPhase_Invoke = 1 << 3 -}; - -struct RequestContext -{ - const WidgetHandle Handle; - WidgetExecutionPhase Phase; - - RequestContext(WidgetHandle handle, - WidgetExecutionPhase phase) : - Handle(handle), - Phase(phase) - { - } -}; - -// Pair of pointer to attribute name and pointer to list of value for -// this attribute name -typedef std::pair< const std::string* const, std::list* > -ATTRIBUTE; - -/* - * Each function should return 0 as success and positive value as error - * - * Possible return value: - * 0 - succes - * 1 - subjectId/resourceId name unknown - * 2 - unknown attribute name - * 4 - interface error - **/ - -/************** Web Runtime ********************/ - -class IWebRuntime -{ - public: - - /** - * gather and set attributes values for specified subjectId - * and attribute name - * @param subjectId is a name of subject (widget or internet site URI ) - * @param attributes is a list of pairs( - * first: pointer to attribute name - * second: list of values for attribute (std::string) - - * its a list of string (BONDI requirement), but usually there will - * be only one string - * */ - virtual int getAttributesValues(const Request &request, - std::list *attributes) = 0; - - /*return current sessionId */ - virtual std::string getSessionId(const Request &request) = 0; - - virtual ~IWebRuntime() - { - } -}; - -/************** Resource Information ********************/ -class IResourceInformation -{ - public: - /** - * gather and set attributes values for specified resourceId - * and attribute name - * @param resourceId is a name of subject (widget or internet site URI ) - * @param attributes is a list of pairs( - * first: pointer to attribute name - * second: list of values for attribute (std::string) - - * its a list of string (BONDI requirement), but usually there will - * be only one string - * */ - virtual int getAttributesValues(const Request &request, - std::list *attributes) = 0; - - virtual ~IResourceInformation() - { - } -}; - -/************** Operation System ********************/ -class IOperationSystem -{ - public: - - /** - * gather and set attributes values for specified attribute name - * @param attributes is a list of pairs( - * first: pointer to attribute name - * second: list of values for attribute (std::string) - - * its a list of string (BONDI requirement), but usually - * there will be only one string - * */ - virtual int getAttributesValues(const Request &request, - std::list *attributes) = 0; - - virtual ~IOperationSystem() - { - } -}; - -class IFunctionParam -{ - public: - virtual int getAttributesValues(const Request &request, - std::list *attributes) = 0; - virtual ~IFunctionParam() - { - } -}; - -#endif //_WRT_INERFACE_4_ACE_EXAMPLE_H_ diff --git a/modules/ace/include/dpl/ace/WidgetUsageModel.h b/modules/ace/include/dpl/ace/WidgetUsageModel.h deleted file mode 100644 index 09d15f8..0000000 --- a/modules/ace/include/dpl/ace/WidgetUsageModel.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// @ Project : Access Control Engine -// @ File Name : UserDecision.h -// @ Date : 2009-05-22 -// @ Author : Samsung -// -// - -#ifndef _WIDGET_USAGE_H -#define _WIDGET_USAGE_H - -#include - -#include "Request.h" -#include "AsyncVerdictResultListener.h" - -enum UsageValidity -{ - USAGE_UNKNOWN, - USAGE_ONCE, - USAGE_SESSION, - USAGE_ALWAYS -}; - -enum UsageVerdict -{ - USAGE_VERDICT_PERMIT, - USAGE_VERDICT_DENY, - USAGE_VERDICT_INAPPLICABLE, - USAGE_VERDICT_UNDETERMINED, - USAGE_VERDICT_UNKNOWN, - USAGE_VERDICT_ERROR -}; -//Forward declaration -class PolicyEvaluator; - -class PolicyEvaluatorData -{ - private: - Request m_request; - UsageValidity m_validity; - UsageVerdict m_verdict; - AsyncVerdictResultListener *m_listener; - public: - - PolicyEvaluatorData(const Request& request, - AsyncVerdictResultListener *listener) : - m_request(request), - m_validity(USAGE_UNKNOWN), - m_verdict(USAGE_VERDICT_ERROR), - m_listener(listener) - { - } - - // KW UsageValidity getValidity() const { - // KW return m_validity; - // KW } - // KW - // KW UsageVerdict getVerdict() const { - // KW return m_verdict; - // KW } - // KW - // KW void setValidity(UsageValidity validity) { - // KW this->m_validity = validity; - // KW } - // KW - // KW void setVerdict(UsageVerdict verdict) { - // KW this->m_verdict = verdict; - // KW } - - const Request& getRequest() const - { - return m_request; - } - - AsyncVerdictResultListener* getListener() const - { - return m_listener; - } -}; - -#endif //_USERDECISION_H diff --git a/modules/ace/include/dpl/ace/acf_consts.h b/modules/ace/include/dpl/ace/acf_consts.h deleted file mode 100644 index 93ecfae..0000000 --- a/modules/ace/include/dpl/ace/acf_consts.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * This file contain consts for Signing Template and Policy Manager - * This values will be used to specified and identified algorithms in xml policy documents. - * Its consistent with BONDI 1.0 released requirements - * - * NOTE: This values should be verified when ACF will be updated to the latest version of BONDI requirements - * This values comes from widget digital signature 1.0 - required version of this doc is very important - * - **/ - -#ifndef ACF_CONSTS_TYPES_H -#define ACF_CONSTS_TYPES_H - -//Digest Algorithms -extern const char* DIGEST_ALG_SHA256; - -//Canonicalization Algorithms -extern const char* CANONICAL_ALG_C14N; - -//Signature Algorithms -extern const char* SIGNATURE_ALG_RSA_with_SHA256; -extern const char* SIGNATURE_ALG_DSA_with_SHA1; -extern const char* SIGNATURE_ALG_ECDSA_with_SHA256; - -#endif - diff --git a/modules/ace/include/dpl/ace/parser.h b/modules/ace/include/dpl/ace/parser.h deleted file mode 100644 index 4fcd4d4..0000000 --- a/modules/ace/include/dpl/ace/parser.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// -// -// @ Project : Access Control Engine -// @ File Name : parser.h -// @ Date : 2009-05-06 -// @ Author : Samsung -// -// - -#ifndef _PARSER_H_ -#define _PARSER_H_ - -//#include "/usr/include/libxml2/libxml/parser.h" -#include -#include -#include -#include -#include - -#include "Policy.h" -#include "PolicySet.h" -#include "Request.h" -#include "Rule.h" -#include "Attribute.h" -#include "TreeNode.h" -#include "Subject.h" -#include "Condition.h" - -#define whitespaces " \n\t\r" - -enum CanonicalizationAlgorithm -{ - C14N, - C14NEXCLUSIVE -}; - -class Parser -{ - private: - - xmlTextReaderPtr reader; - - TreeNode * root; - TreeNode * currentRoot; - Subject * currentSubject; - Condition * currentCondition; - Attribute * currentAttribute; - std::string * currentText; - - bool processingSignature; - bool canonicalizeOnce; - - void processNode(xmlTextReaderPtr reader); - - //Node Handlers - void endNodeHandler(xmlTextReaderPtr reader); - void textNodeHandler(xmlTextReaderPtr reader); - void startNodeHandler(xmlTextReaderPtr reader); - - //Node names handlers - void handleAttr(xmlTextReaderPtr reader); - void handleRule(xmlTextReaderPtr reader); - void handleSubject(); - void handleCondition(xmlTextReaderPtr reader); - void handleSubjectMatch(xmlTextReaderPtr reader); - void handleMatch(xmlTextReaderPtr reader, - Attribute::Type); - void handlePolicy(xmlTextReaderPtr reader, - TreeNode::TypeID type); - - //helpers - Policy::CombineAlgorithm convertToCombineAlgorithm(xmlChar*); - Effect convertToEffect(xmlChar *effect); - Attribute::Match convertToMatchFunction(xmlChar * func); - void consumeCurrentText(); - void consumeCurrentAttribute(); - void consumeSubjectMatch(xmlChar * value = NULL); - void consumeCurrentSubject(); - void consumeCurrentCondition(); - void trim(std::string *); - // KW void canonicalize(const char *, const char *, CanonicalizationAlgorithm canonicalizationAlgorithm); - // KW int extractNodeToFile(xmlTextReaderPtr reader, const char * filename); - - static const char *TOKEN_PARAM; - public: - Parser(); - ~Parser(); - TreeNode * parse(const std::string& filename, const std::string& schema); -}; - -#endif //_PARSER_H diff --git a/modules/ace/orm/ace_db b/modules/ace/orm/ace_db deleted file mode 100644 index 0dc1c27..0000000 --- a/modules/ace/orm/ace_db +++ /dev/null @@ -1,60 +0,0 @@ -SQL( - PRAGMA foreign_keys = ON; - BEGIN TRANSACTION; -) - -CREATE_TABLE(AcePolicyResult) - COLUMN_NOT_NULL(decision, INTEGER, check(decision between 0 and 6)) - COLUMN_NOT_NULL(hash, TEXT,) - TABLE_CONSTRAINTS( - PRIMARY KEY(hash) - ) -CREATE_TABLE_END() - -CREATE_TABLE(AcePromptDecision) - COLUMN_NOT_NULL(user_param, TEXT,) - COLUMN_NOT_NULL(decision, INTEGER, check(decision between 0 and 5)) - COLUMN(session, TEXT,) - COLUMN_NOT_NULL(hash, TEXT,) - TABLE_CONSTRAINTS( - PRIMARY KEY(hash,user_param) - ) -CREATE_TABLE_END() - -CREATE_TABLE(AceAttribute) - COLUMN_NOT_NULL(attr_id, INTEGER, primary key autoincrement) - COLUMN_NOT_NULL(name, TEXT,) - COLUMN_NOT_NULL(type, INTEGER, check(type between 0 and 3)) - - TABLE_CONSTRAINTS(unique(name,type)) -CREATE_TABLE_END() - -CREATE_TABLE(AceSubject) - COLUMN_NOT_NULL(subject_id, INTEGER, primary key autoincrement) - COLUMN_NOT_NULL(id_uri, TEXT, unique) -CREATE_TABLE_END() - -CREATE_TABLE(AceDevCap) - COLUMN_NOT_NULL(resource_id, INTEGER, primary key autoincrement) - COLUMN_NOT_NULL(id_uri, TEXT, unique) - COLUMN_NOT_NULL(general_setting,INTEGER, check(general_setting between -1 and 4)) -CREATE_TABLE_END() - -CREATE_TABLE(AceWidgetDevCapSetting) - COLUMN_NOT_NULL(app_id, INTEGER, not null) - COLUMN_NOT_NULL(resource_id, INTEGER, references AceDevCap(resource_id)) - COLUMN_NOT_NULL(access_value, INTEGER, check(access_value between -1 and 4)) - - TABLE_CONSTRAINTS(unique(app_id,resource_id)) -CREATE_TABLE_END() - -CREATE_TABLE(AceStaticDevCapPermission) - COLUMN_NOT_NULL(app_id, INTEGER, not null) - COLUMN_NOT_NULL(dev_cap, TEXT,) - - TABLE_CONSTRAINTS(unique(app_id,dev_cap)) -CREATE_TABLE_END() - -SQL( - COMMIT; -) diff --git a/modules/ace/orm/ace_db_definitions b/modules/ace/orm/ace_db_definitions deleted file mode 100644 index 46836e9..0000000 --- a/modules/ace/orm/ace_db_definitions +++ /dev/null @@ -1,6 +0,0 @@ -DATABASE_START(ace) - -#include "ace_db" -#include "version_db" - -DATABASE_END() diff --git a/modules/ace/orm/ace_db_sql_generator.h b/modules/ace/orm/ace_db_sql_generator.h deleted file mode 100644 index 5af05ac..0000000 --- a/modules/ace/orm/ace_db_sql_generator.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file wrt_db_sql_generator.h - * @author Bartosz Janiak (b.janiak@samsung.com) - * @version 1.0 - * @brief Macro definitions for generating the SQL input file from database definition. - */ - -//Do not include this file directly! It is used only for SQL code generation. - -#include - -#include "ace_db_definitions" diff --git a/modules/ace/orm/gen_db_md5.sh b/modules/ace/orm/gen_db_md5.sh deleted file mode 100755 index 38587b7..0000000 --- a/modules/ace/orm/gen_db_md5.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -CHECKSUM=`cat ${2} ${3} 2>/dev/null | md5sum 2>/dev/null | cut -d\ -f1 2>/dev/null` -echo "#define DB_CHECKSUM DB_VERSION_${CHECKSUM}" > ${1} -echo "#define DB_CHECKSUM_STR \"DB_VERSION_${CHECKSUM}\"" >> ${1} - diff --git a/modules/ace/orm/orm_generator_ace.h b/modules/ace/orm/orm_generator_ace.h deleted file mode 100644 index 640dd35..0000000 --- a/modules/ace/orm/orm_generator_ace.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ORM_GENERATOR_ACE_H -#define ORM_GENERATOR_ACE_H - -#define ORM_GENERATOR_DATABASE_NAME ace_db_definitions -#include -#undef ORM_GENERATOR_DATABASE_NAME - -#endif diff --git a/modules/ace/orm/version_db b/modules/ace/orm/version_db deleted file mode 100644 index 7e20d8d..0000000 --- a/modules/ace/orm/version_db +++ /dev/null @@ -1,5 +0,0 @@ -SQL( - BEGIN TRANSACTION; - CREATE TABLE DB_CHECKSUM (version INT); - COMMIT; -) diff --git a/modules/core/include/dpl/file_input_mapping.h b/modules/core/include/dpl/file_input_mapping.h deleted file mode 100644 index fd2d206..0000000 --- a/modules/core/include/dpl/file_input_mapping.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file file_input_mapping.h - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the header file of file input mapping - */ -#ifndef DPL_FILE_INPUT_MAPPING_H -#define DPL_FILE_INPUT_MAPPING_H - -#include -#include - -namespace DPL -{ -class FileInputMapping - : private Noncopyable -{ -public: - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, OpenFailed) - }; - -private: - int m_handle; - off64_t m_size; - unsigned char *m_address; - -public: - /** - * Constructor - */ - explicit FileInputMapping(const std::string &fileName); - - /** - * Destructor - */ - ~FileInputMapping(); - - /** - * Get file mapping total size - * - * @return 64-bit size - */ - off64_t GetSize() const; - - /** - * Get file mapping base address - * - * @return Base address of file mapping - */ - const unsigned char *GetAddress() const; -}; -} // namespace DPL - -#endif // DPL_FILE_INPUT_MAPPING_H diff --git a/modules/core/src/file_input_mapping.cpp b/modules/core/src/file_input_mapping.cpp deleted file mode 100644 index 2bfcd15..0000000 --- a/modules/core/src/file_input_mapping.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file file_input_mapping.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of file input mapping - */ -#include -#include -#include -#include -#include -#include -#include -#include - -namespace DPL -{ -FileInputMapping::FileInputMapping(const std::string &fileName) - : m_handle(-1), - m_size(0), - m_address(NULL) -{ - // Open device and map it to user space - int file = TEMP_FAILURE_RETRY(open(fileName.c_str(), O_RDONLY)); - - if (file == -1) - { - int error = errno; - ThrowMsg(FileInputMapping::Exception::OpenFailed, - "Failed to open file. errno = " << error); - } - - // Scoped close on file - ScopedClose scopedClose(file); - - // Calculate file size - off64_t size = lseek64(file, 0, SEEK_END); - - if (size == static_cast(-1)) - { - int error = errno; - ThrowMsg(FileInputMapping::Exception::OpenFailed, - "Failed to seek file. errno = " << error); - } - - // Map file to usespace - void *address = mmap(0, static_cast(size), - PROT_READ, MAP_SHARED, file, 0); - - if (address == MAP_FAILED) - { - int error = errno; - ThrowMsg(FileInputMapping::Exception::OpenFailed, - "Failed to map file. errno = " << error); - } - - // Release scoped close - m_handle = scopedClose.Release(); - - // Save mapped up address - m_size = size; - m_address = static_cast(address); - - LogPedantic("Created file mapping: " << fileName << - " of size: " << m_size << - " at address: " << std::hex << static_cast(m_address)); -} - -FileInputMapping::~FileInputMapping() -{ - // Close mapping - if (munmap(m_address, static_cast(m_size)) == -1) - { - int error = errno; - LogPedantic("Failed to munmap file. errno = " << error); - } - - // Close file descriptor - if (TEMP_FAILURE_RETRY(close(m_handle)) == -1) - { - int error = errno; - LogPedantic("Failed to close file. errno = " << error); - } -} - -off64_t FileInputMapping::GetSize() const -{ - return m_size; -} - -const unsigned char *FileInputMapping::GetAddress() const -{ - return m_address; -} -} // namespace DPL diff --git a/modules/core/src/named_input_pipe.cpp b/modules/core/src/named_input_pipe.cpp deleted file mode 100644 index bda52f2..0000000 --- a/modules/core/src/named_input_pipe.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file named_input_pipe.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of named input pipe - */ -#include -#include -#include -#include -#include -#include -#include - -namespace DPL -{ -namespace // anonymous -{ -const size_t DEFAULT_READ_BUFFER_SIZE = 1024; -} // namespace anonymous - -NamedInputPipe::NamedInputPipe() - : m_fifo(-1) -{ -} - -NamedInputPipe::~NamedInputPipe() -{ - Close(); -} - -void NamedInputPipe::Open(const std::string& pipeName) -{ - // Open pipe for reading - int fifo = TEMP_FAILURE_RETRY(open(pipeName.c_str(), O_RDONLY | O_NONBLOCK)); - - if (fifo == -1) - ThrowMsg(Exception::OpenFailed, pipeName); - - m_fifo = fifo; -} - -void NamedInputPipe::Close() -{ - if (m_fifo == -1) - return; - - if (TEMP_FAILURE_RETRY(close(m_fifo)) == -1) - Throw(Exception::CloseFailed); - - m_fifo = -1; -} - -BinaryQueueAutoPtr NamedInputPipe::Read(size_t size) -{ - size_t bytesToRead = size > DEFAULT_READ_BUFFER_SIZE ? DEFAULT_READ_BUFFER_SIZE : size; - - // Malloc default read buffer size - // It is unmanaged, so it can be then attached directly to binary queue - void *buffer = malloc(bytesToRead); - - if (buffer == NULL) - throw std::bad_alloc(); - - ssize_t result = TEMP_FAILURE_RETRY(read(m_fifo, buffer, bytesToRead)); - - if (result > 0) - { - // Succedded to read socket data - BinaryQueueAutoPtr binaryQueue(new BinaryQueue()); - - // Append unmanaged memory - binaryQueue->AppendUnmanaged(buffer, result, &BinaryQueue::BufferDeleterFree, NULL); - - // Return buffer - return binaryQueue; - } - else if (result == 0) - { - // Socket was gracefuly closed - free(buffer); - - // Return empty buffer - return BinaryQueueAutoPtr(new BinaryQueue()); - } - else - { - // Must first save errno value, because it may be altered - int lastErrno = errno; - - // Free buffer - free(buffer); - - // Interpret error result - (void)lastErrno; - - // FIXME: Handle specific errno - Throw(AbstractInput::Exception::ReadFailed); - } -} - -int NamedInputPipe::WaitableReadHandle() const -{ - return m_fifo; -} -} // namespace DPL diff --git a/modules/event/include/dpl/event/event_delivery.h b/modules/event/include/dpl/event/event_delivery.h deleted file mode 100644 index f4c893c..0000000 --- a/modules/event/include/dpl/event/event_delivery.h +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file event_delivery.h - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the header file of event delivery class - */ -#ifndef DPL_EVENT_DELIVERY_H -#define DPL_EVENT_DELIVERY_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Event delivery system - * - * Sample usages: - * - * I. Listening for standard predefined notifications - * - * class MyClass - * : public EventListener - * { - * void OnEventReceived(const EventMessages::RoamingChanged& event) - * { - * std::cout << "Roaming is now " << event.GetRoamingEnabled() ? "ENABLED" : "DISABLED" << std::endl; - * } - * - * public: - * MyClass() - * { - * EventDeliverySystem::AddListener(this); - * } - * - * virtual ~MyClass() - * { - * EventDeliverySystem::RemoveListener(this); - * } - * - * void SendSampleSignal() - * { - * EventMessages::RoamingChanged roamingMessage(true); - * EventDeliverySystem::Publish(roamingMessage); - * } - * } - * - * II. Creation of custom generic events, and listening for them - * - * EVENT_DELIVERY_DECLARE_EVENT_MESSAGE_2(MyEvent, int, float); - * - * class MyClass - * : public EventListener - * { - * void OnEventReceived(const MyEvent &event) - * { - * std::cout << "Event contents: " << event.GetArg0() << ", " << event.GetArg1() << std::endl; - * } - * - * public: - * MyClass() - * { - * EventDeliverySystem::AddListener(this); - * } - * - * virtual ~MyClass() - * { - * EventDeliverySystem::RemoveListener(this); - * } - * - * void SendSampleSignal() - * { - * MyEvent myEvent(5, 3.14f); - * EventDeliverySystem::Publish(myEvent); - * } - * } - * - * In source file, one must add implementation of event delivery message: - * - * EVENT_DELIVERY_IMPLEMENT_EVENT_MESSAGE(MyEvent) - * - */ -namespace DPL -{ -namespace Event -{ - -class AbstractEventDeliverySystemPublisher -{ -public: - virtual ~AbstractEventDeliverySystemPublisher() = 0; -}; - -template -class EventDeliverySystemPublisher - : private EventSupport - , public AbstractEventDeliverySystemPublisher -{ -public: - typedef typename EventSupport::EventListenerType EventListenerType; - -private: - friend class EventDeliverySystem; - - EventDeliverySystemPublisher(EventListenerType *eventListener) - : m_eventListener(eventListener) - { - EventSupport::AddListener(m_eventListener); - } - - EventListenerType *m_eventListener; - -public: - ~EventDeliverySystemPublisher() - { - EventSupport::RemoveListener(m_eventListener); - } - - void PublishEvent(const EventType &event) - { - EmitEvent(event, EmitMode::Queued); - } - - EventListenerType *GetListener() const - { - return m_eventListener; - } -}; - -template -class EventDeliverySystemTraits -{ -public: - typedef Type EventType; - typedef EventDeliverySystemPublisher PublisherType; - typedef typename PublisherType::EventListenerType EventListenerType; - typedef SharedPtr PublisherPtrType; - typedef std::list PublisherPtrContainerType; -}; - -class EventDeliverySystem - : private Noncopyable -{ -private: - typedef SharedPtr AbstractPublisherPtrType; - typedef std::list AbstractPublisherPtrContainerType; - typedef AbstractPublisherPtrContainerType::const_iterator AbstractPublisherPtrContainerTypeConstIterator; - typedef AbstractPublisherPtrContainerType::iterator AbstractPublisherPtrContainerTypeIterator; - typedef std::map AbstractPublisherPtrContainerMapType; - - template - class CrtDeleteCheck - { - private: - const AbstractPublisherPtrContainerType &m_publisherContainer; - - public: - CrtDeleteCheck(const AbstractPublisherPtrContainerType &publisherContainer) - : m_publisherContainer(publisherContainer) - { - } - - virtual ~CrtDeleteCheck() - { - Assert(m_publisherContainer.empty() && "All event delivery listeners must be removed before exit!"); - } - }; - - // Map containing publishers for all registered events - static AbstractPublisherPtrContainerMapType m_publishers; - - // Detail implementation: lazy initialized - static EventDeliverySystemDetail m_detailSystem; - - EventDeliverySystem() - { - } - - template - static AbstractPublisherPtrContainerType &GetPublisherContainerRef() - { - std::string typeId = typeid(EventType).name(); - - //FIXME: problem with linking per compilation unit won't hurt this check? - static CrtDeleteCheck crtDeleteCheck(m_publishers[typeId]); - (void)crtDeleteCheck; - - return m_publishers[typeId]; - } - - template - static typename EventDeliverySystemTraits::PublisherPtrContainerType GetPublisherContainer() - { - std::string typeId = typeid(EventType).name(); - typedef typename EventDeliverySystemTraits::PublisherPtrContainerType PublisherContainerType; - typedef typename EventDeliverySystemTraits::PublisherType PublisherType; - typedef typename EventDeliverySystemTraits::PublisherPtrType PublisherPtrType; - - AbstractPublisherPtrContainerType eventPublishers = m_publishers[typeId]; - PublisherContainerType publisherContainer; - - FOREACH(iterator, eventPublishers) - { - PublisherPtrType publisher = - StaticPointerCast(*iterator); - publisherContainer.push_back(publisher); - } - - return publisherContainer; - } - - // Detail access - template - static void Inject(const EventType &event) - { - typedef typename EventDeliverySystemTraits::PublisherPtrContainerType PublisherContainerType; - typedef typename EventDeliverySystemTraits::PublisherPtrType PublisherPtrType; - - PublisherContainerType publisherContainer = GetPublisherContainer(); - typename PublisherContainerType::iterator iterator; - - for (iterator = publisherContainer.begin(); iterator != publisherContainer.end(); ++iterator) - { - PublisherPtrType &publisher = *iterator; - publisher->PublishEvent(event); - } - } - - template - class PublisherPtrContainerListenerPredicate - { - public: - typedef EventListener EventListenerType; - - private: - EventListenerType *m_listener; - - public: - PublisherPtrContainerListenerPredicate(EventListenerType *listener) - : m_listener(listener) - { - } - - bool operator()(const AbstractPublisherPtrType &publisher) const - { - return StaticPointerCast::PublisherType>(publisher)->GetListener() == m_listener; - } - }; - - friend class EventDeliverySystemInjector; - -public: - virtual ~EventDeliverySystem() - { - } - - template - static void AddListener(EventListener *listener) - { - typedef typename EventDeliverySystemTraits::PublisherType PublisherType; - typedef typename EventDeliverySystemTraits::PublisherPtrType PublisherPtrType; - typedef typename EventDeliverySystemTraits::PublisherPtrContainerType PublisherPtrContainerType; - - typedef PublisherPtrContainerListenerPredicate PublisherPtrContainerListenerPredicateType; - - AbstractPublisherPtrContainerType &publisherContainer = GetPublisherContainerRef(); - AbstractPublisherPtrContainerTypeConstIterator iterator = - std::find_if(publisherContainer.begin(), publisherContainer.end(), PublisherPtrContainerListenerPredicateType(listener)); - - Assert(iterator == publisherContainer.end() && "Listener already exists"); - - // Add new publisher - publisherContainer.push_back(AbstractPublisherPtrType(new PublisherType(listener))); - - // When first listener is inserted, start to listen for events - if (publisherContainer.size() == 1) { - m_detailSystem.Listen(EventType()); - } - } - - template - static void RemoveListener(EventListener *listener) - { - typedef typename EventDeliverySystemTraits::PublisherType PublisherType; - typedef typename EventDeliverySystemTraits::PublisherPtrType PublisherPtrType; - typedef typename EventDeliverySystemTraits::PublisherPtrContainerType PublisherPtrContainerType; - - typedef PublisherPtrContainerListenerPredicate PublisherPtrContainerListenerPredicateType; - - AbstractPublisherPtrContainerType &publisherContainer = GetPublisherContainerRef(); - - AbstractPublisherPtrContainerTypeIterator iterator = - std::find_if(publisherContainer.begin(), publisherContainer.end(), PublisherPtrContainerListenerPredicateType(listener)); - - Assert(iterator != publisherContainer.end() && "Listener does not exist"); - - // Remove publisher - publisherContainer.erase(iterator); - - // When last listener was removed, stop to listen for events - if (publisherContainer.empty()) - m_detailSystem.Unlisten(EventType()); - } - - template - static void Publish(const EventType &event) - { - m_detailSystem.Publish(event); - } -}; - -} -} // namespace DPL - -#endif // DPL_EVENT_DELIVERY_H diff --git a/modules/event/include/dpl/event/event_delivery_detail.h b/modules/event/include/dpl/event/event_delivery_detail.h deleted file mode 100644 index b5907d0..0000000 --- a/modules/event/include/dpl/event/event_delivery_detail.h +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file event_delivery_detail.h - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the header file of event delivery EFL detail class - */ -#ifndef DPL_EVENT_DELIVERY_DETAIL_EFL_H -#define DPL_EVENT_DELIVERY_DETAIL_EFL_H - -#include -#include -#include -#include -#include -#include - -namespace DPL -{ -namespace Event -{ - -class EventDeliverySystemDetail - : private Noncopyable -{ -private: - // Generic noti event prefixes - static const char *NOTI_EVENT_ID_GENERIC_0; - static const char *NOTI_EVENT_ID_GENERIC_1; - static const char *NOTI_EVENT_ID_GENERIC_2; - static const char *NOTI_EVENT_ID_GENERIC_3; - static const char *NOTI_EVENT_ID_GENERIC_4; - - // Other noti events - static const char *NOTI_EVENT_ID_NULL; - - // Main noti handle - int m_notiHandle; - - // Noti signaling class - class NotiSignal - { - private: - EventDeliverySystemDetail *m_receiver; - const char *m_gcid; - int m_sysnoti; - std::string m_eventName; - - public: - NotiSignal(EventDeliverySystemDetail *receiver, const char *gcid, const std::string &eventName) - : m_receiver(receiver), - m_gcid(gcid), - m_sysnoti(-1), - m_eventName(eventName) - { - Assert(receiver != NULL); - } - - NotiSignal(EventDeliverySystemDetail *receiver, int sysnoti) - : m_receiver(receiver), - m_gcid(NULL), - m_sysnoti(sysnoti) - { - Assert(receiver != NULL); - } - - const char *GetGcid() const - { - return m_gcid; - } - - int GetSysNoti() const - { - return m_sysnoti; - } - - std::string GetEventName() const - { - return m_eventName; - } - - EventDeliverySystemDetail *GetReceiver() const - { - return m_receiver; - } - }; - - // Registered noti singal list - typedef std::list NotiSignalList; - NotiSignalList m_notiSignalList; - - // setting library callbacks - class SettingSignal - { - private: - EventDeliverySystemDetail *m_receiver; - std::string m_key; - - public: - SettingSignal(EventDeliverySystemDetail *receiver, const std::string &key) - : m_receiver(receiver), - m_key(key) - { - } - - std::string GetKey() const - { - return m_key; - } - - EventDeliverySystemDetail *GetReceiver() const - { - return m_receiver; - } - }; - - typedef std::list SettingSignalList; - SettingSignalList m_settingSignalList; - - // Global noti callbacks - class GlobalNotiSignal - { - private: - EventDeliverySystemDetail *m_receiver; - std::string m_key; - - public: - GlobalNotiSignal(EventDeliverySystemDetail *receiver, const std::string &key) - : m_receiver(receiver), - m_key(key) - { - } - - std::string GetKey() const - { - return m_key; - } - - EventDeliverySystemDetail *GetReceiver() const - { - return m_receiver; - } - }; - - typedef std::list GlobalNotiSignalList; - GlobalNotiSignalList m_globalNotiSignalList; - - // Utilities - std::string ReadFile(const std::string &fileName) const; - std::string GetGenericNotiFilePath(const std::string &eventName) const; - - // Noti callback registration/unregistration - void RegisterFileNotiCallback(const char *gcid, const std::string &eventName); - void UnregisterFileNotiCallback(const std::string &eventName); - - void RegisterSettingCallback(const std::string &key); - void UnregisterSettingCallback(const std::string &key); - - void RegisterGlobalNotiCallback(const std::string &key); - void UnregisterGlobalNotiCallback(const std::string &key); - - // Emit noti signal - void SignalGenericNoti(const std::string &eventName, const std::string &contents) const; - - // Signals - static void OnNotiGlobalSignal(void *notiData); - static void OnSettingSignal(keynode_t *keyNode, void *userParam); - static void OnGlobalNotiSignal(void *globalNotiData); - - void OnNotiSignal(NotiSignal *notiSignal); - -public: - EventDeliverySystemDetail(); - virtual ~EventDeliverySystemDetail(); - - void Listen(const EventMessages::RoamingChanged &event); - void Listen(const EventMessages::NetworkTypeChanged &event); - void Listen(const EventMessages::HibernationEnter &event); - void Listen(const EventMessages::HibernationLeave &event); - - void Unlisten(const EventMessages::RoamingChanged &event); - void Unlisten(const EventMessages::NetworkTypeChanged &event); - void Unlisten(const EventMessages::HibernationEnter &event); - void Unlisten(const EventMessages::HibernationLeave &event); - - void Publish(const EventMessages::Generic0 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_0) + event.GetGcid(); - SignalGenericNoti(eventName, event.SerializeType()); - } - - template - void Publish(const EventMessages::Generic1 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_1) + event.GetGcid(); - SignalGenericNoti(eventName, event.SerializeType()); - } - - template - void Publish(const EventMessages::Generic2 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_2) + event.GetGcid(); - SignalGenericNoti(eventName, event.SerializeType()); - } - - template - void Publish(const EventMessages::Generic3 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_3) + event.GetGcid(); - SignalGenericNoti(eventName, event.SerializeType()); - } - - template - void Publish(const EventMessages::Generic4 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_4) + event.GetGcid(); - SignalGenericNoti(eventName, event.SerializeType()); - } - - void Listen(const EventMessages::Generic0 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_0) + event.GetGcid(); - RegisterFileNotiCallback(event.GetGcid(), eventName); - } - - template - void Listen(const EventMessages::Generic1 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_1) + event.GetGcid(); - RegisterFileNotiCallback(event.GetGcid(), eventName); - } - - template - void Listen(const EventMessages::Generic2 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_2) + event.GetGcid(); - RegisterFileNotiCallback(event.GetGcid(), eventName); - } - - template - void Listen(const EventMessages::Generic3 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_3) + event.GetGcid(); - RegisterFileNotiCallback(event.GetGcid(), eventName); - } - - template - void Listen(const EventMessages::Generic4 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_4) + event.GetGcid(); - RegisterFileNotiCallback(event.GetGcid(), eventName); - } - - void Unlisten(const EventMessages::Generic0 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_0) + event.GetGcid(); - UnregisterFileNotiCallback(eventName); - } - - template - void Unlisten(const EventMessages::Generic1 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_1) + event.GetGcid(); - UnregisterFileNotiCallback(eventName); - } - - template - void Unlisten(const EventMessages::Generic2 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_2) + event.GetGcid(); - UnregisterFileNotiCallback(eventName); - } - - template - void Unlisten(const EventMessages::Generic3 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_3) + event.GetGcid(); - UnregisterFileNotiCallback(eventName); - } - - template - void Unlisten(const EventMessages::Generic4 &event) - { - std::string eventName = std::string(NOTI_EVENT_ID_GENERIC_4) + event.GetGcid(); - UnregisterFileNotiCallback(eventName); - } -}; - -} -} // namespace DPL - -#endif // DPL_EVENT_DELIVERY_DETAIL_EFL_H diff --git a/modules/event/include/dpl/event/event_delivery_injector.h b/modules/event/include/dpl/event/event_delivery_injector.h deleted file mode 100644 index 546b4c3..0000000 --- a/modules/event/include/dpl/event/event_delivery_injector.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file event_delivery_injector.h - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the header file of event delivery injector - */ -#ifndef DPL_EVENT_DELIVERY_INJECTOR_H -#define DPL_EVENT_DELIVERY_INJECTOR_H - -#include -#include -#include -#include -#include -#include - -namespace DPL -{ -namespace Event -{ - -class EventDeliverySystemInjector - : private Noncopyable -{ -private: - EventDeliverySystemInjector() - { - } - - typedef void (*MetaCall)(const std::string &metaData); - typedef std::map MetaCallContainer; - MetaCallContainer m_metaCalls; - -public: - virtual ~EventDeliverySystemInjector() - { - } - - static EventDeliverySystemInjector &Instance() - { - static EventDeliverySystemInjector instance; - return instance; - } - - void PublishMetaType(const char *metaType, const std::string &metaData) - { - // Unwrap meta type (indirect Publish meta call) - m_metaCalls[metaType](metaData); - } - - template - void Publish(const EventMessageType &message) - { - EventDeliverySystem::Inject(message); - } - - void RegisterMetaCall(const char *metaType, MetaCall metaCall) - { - m_metaCalls.insert(std::make_pair(metaType, metaCall)); - } -}; - -} -} // namespace DPL - -#endif // DPL_EVENT_DELIVERY_INJECTOR_H diff --git a/modules/event/include/dpl/event/event_delivery_messages.h b/modules/event/include/dpl/event/event_delivery_messages.h deleted file mode 100644 index 046738d..0000000 --- a/modules/event/include/dpl/event/event_delivery_messages.h +++ /dev/null @@ -1,923 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file event_delivery_messages.h - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the header file of event delivery messages - */ -#ifndef DPL_EVENT_DELIVERY_MESSAGES_H -#define DPL_EVENT_DELIVERY_MESSAGES_H - -#include -#include -#include -#include - -namespace DPL -{ -namespace Event -{ - -namespace EventMessages -{ -/** - * Generic event message base - * - * Custom events are derived from these templates - * Only template GenericN members are serialized - * - * Assumptions: - * - * 1. Arg* must be default constructible - * 2. For Arg* there must be defined << and >> operators - */ -class GenericBase -{ -private: - const char *m_gcid; ///< Global class ID - static const char SEPARATOR = '\254'; ///< Unique serialized data separator - static const size_t DESERIALIZE_STRING_FIELD_CHUNK_SIZE = 128; ///< Chunk size while parsing serialized event data - -protected: - template - void SerializeField(std::ostream &stream, const Type &type) const - { - stream << type; - } - - void SerializeSeparator(std::ostream &stream) const - { - stream << SEPARATOR; - } - - std::vector SplitStream(const std::string &stream) const - { - char separator[2] = {}; - separator[0] = SEPARATOR; - std::vector splitVector; - - char *splitTab = new char[stream.size() + 1]; - strcpy(splitTab, stream.c_str()); - - // Split serialized stream - char *savePtr; - char *splitPtr = strtok_r(splitTab, separator, &savePtr); - - while (splitPtr != NULL) - { - splitVector.push_back(std::string(splitPtr)); - splitPtr = strtok_r(NULL, separator, &savePtr); - } - - delete [] splitTab; - - return splitVector; - } - - template - Type DeserializeField(std::istream &stream, const Type &) const - { - Type type; - stream >> type; - return type; - } - - std::string DeserializeField(std::istream &stream, const std::string &) const - { - std::string result; - char buffer[DESERIALIZE_STRING_FIELD_CHUNK_SIZE]; - - for (;;) - { - stream.get(buffer, DESERIALIZE_STRING_FIELD_CHUNK_SIZE); - - if (stream.gcount() < 1) - break; - - result += std::string(buffer, buffer + stream.gcount()); - } - - return result; - } - -public: - /** - * Init constructor - */ - explicit GenericBase(const char *gcid) - : m_gcid(gcid) - { - } - - /** - * Destructor - */ - virtual ~GenericBase() - { - } - - const char *GetGcid() const { return m_gcid; } - - /** - * Serialize event n-tuple - * - * @return Ouput serialized stream - * @warning Internal use only - */ - virtual std::string SerializeType() const = 0; - - /** - * Deserialize event n-tuple - * - * @param[in] stream Input stream to deserialize from - * @warning Internal use only - */ - virtual void DeserializeType(const std::string &stream) = 0; -}; - -class Generic0 - : public GenericBase -{ -public: - /** - * Init constructor - */ - explicit Generic0(const char *Gcid) - : GenericBase(Gcid) - { - } - - /** - * Destructor - */ - virtual ~Generic0() - { - } - - /** - * Serialize event 0-tuple - * - * @return Ouput serialized stream - * @warning Internal use only - */ - virtual std::string SerializeType() const - { - return std::string(); - } - - /** - * Deserialize event 0-tuple - * - * @param[in] stream Input stream to deserialize from - * @warning Internal use only - */ - virtual void DeserializeType(const std::string &stream) - { - (void)stream; - } -}; - -template -class Generic1 - : public GenericBase -{ -public: - typedef Arg0Type Arg0; - -private: - Arg0 m_arg0; - -public: - /** - * Init constructor - */ - explicit Generic1(const char *Gcid) - : GenericBase(Gcid), - m_arg0() - { - } - - /** - * Full init constructor - */ - explicit Generic1(const char *Gcid, const Arg0 &arg0) - : GenericBase(Gcid), - m_arg0(arg0) - { - } - - /** - * Destructor - */ - virtual ~Generic1() - { - } - - /** - * Retrieve value of argument 0 from tuple - * - * @return Argument value - */ - const Arg0 &GetArg0() const - { - return m_arg0; - } - - /** - * Set value of argument 0 in tuple - * - * @param[in] value Argument value - */ - void SetArg0(const Arg0 &value) - { - m_arg0 = value; - } - - /** - * Serialize event 1-tuple - * - * @return Ouput serialized stream - * @warning Internal use only - */ - virtual std::string SerializeType() const - { - std::ostringstream s; - SerializeField(s, m_arg0); - return s.str(); - } - - /** - * Deserialize event 1-tuple - * - * @param[in] stream Input stream to deserialize from - * @warning Internal use only - */ - virtual void DeserializeType(const std::string &stream) - { - std::vector splitVector = SplitStream(stream); - if (splitVector.size() != 1) - return; - std::istringstream s0(splitVector[0]); - m_arg0 = DeserializeField(s0, Arg0()); - } -}; - -template -class Generic2 - : public GenericBase -{ -public: - typedef Arg0Type Arg0; - typedef Arg1Type Arg1; - -private: - Arg0 m_arg0; - Arg1 m_arg1; - -public: - /** - * Init constructor - */ - explicit Generic2(const char *Gcid) - : GenericBase(Gcid), - m_arg0(), - m_arg1() - { - } - - /** - * Full init constructor - */ - explicit Generic2(const char *Gcid, const Arg0 &arg0, const Arg1 &arg1) - : GenericBase(Gcid), - m_arg0(arg0), - m_arg1(arg1) - { - } - - /** - * Destructor - */ - virtual ~Generic2() - { - } - - /** - * Retrieve value of argument 0 from tuple - * - * @return Argument value - */ - const Arg0 &GetArg0() const - { - return m_arg0; - } - - /** - * Set value of argument 0 in tuple - * - * @param[in] value Argument value - */ - void SetArg0(const Arg0 &value) - { - m_arg0 = value; - } - - /** - * Retrieve value of argument 1 from tuple - * - * @return Argument value - */ - const Arg1 &GetArg1() const - { - return m_arg1; - } - - /** - * Set value of argument 1 in tuple - * - * @param[in] value Argument value - */ - void SetArg1(const Arg1 &value) - { - m_arg1 = value; - } - - /** - * Serialize event 2-tuple - * - * @return Ouput serialized stream - * @warning Internal use only - */ - virtual std::string SerializeType() const - { - std::ostringstream s; - SerializeField(s, m_arg0); - SerializeSeparator(s); - SerializeField(s, m_arg1); - return s.str(); - } - - /** - * Deserialize event 2-tuple - * - * @param[in] stream Input stream to deserialize from - * @warning Internal use only - */ - virtual void DeserializeType(const std::string &stream) - { - std::vector splitVector = SplitStream(stream); - if (splitVector.size() != 2) - return; - std::istringstream s0(splitVector[0]); - std::istringstream s1(splitVector[1]); - m_arg0 = DeserializeField(s0, Arg0()); - m_arg1 = DeserializeField(s1, Arg1()); - } -}; - -template -class Generic3 - : public GenericBase -{ -public: - typedef Arg0Type Arg0; - typedef Arg1Type Arg1; - typedef Arg2Type Arg2; - -private: - Arg0 m_arg0; - Arg1 m_arg1; - Arg2 m_arg2; - -public: - /** - * Init constructor - */ - explicit Generic3(const char *Gcid) - : GenericBase(Gcid), - m_arg0(), - m_arg1(), - m_arg2() - { - } - - /** - * Full init constructor - */ - explicit Generic3(const char *Gcid, const Arg0 &arg0, const Arg1 &arg1, const Arg2 &arg2) - : GenericBase(Gcid), - m_arg0(arg0), - m_arg1(arg1), - m_arg2(arg2) - { - } - - /** - * Destructor - */ - virtual ~Generic3() - { - } - - /** - * Retrieve value of argument 0 from tuple - * - * @return Argument value - */ - const Arg0 &GetArg0() const - { - return m_arg0; - } - - /** - * Set value of argument 0 in tuple - * - * @param[in] value Argument value - */ - void SetArg0(const Arg0 &value) - { - m_arg0 = value; - } - - /** - * Retrieve value of argument 1 from tuple - * - * @return Argument value - */ - const Arg1 &GetArg1() const - { - return m_arg1; - } - - /** - * Set value of argument 1 in tuple - * - * @param[in] value Argument value - */ - void SetArg1(const Arg1 &value) - { - m_arg1 = value; - } - - /** - * Retrieve value of argument 2 from tuple - * - * @return Argument value - */ - const Arg2 &GetArg2() const - { - return m_arg2; - } - - /** - * Set value of argument 2 in tuple - * - * @param[in] value Argument value - */ - void SetArg2(const Arg2 &value) - { - m_arg2 = value; - } - - /** - * Serialize event 3-tuple - * - * @return Ouput serialized stream - * @warning Internal use only - */ - virtual std::string SerializeType() const - { - std::ostringstream s; - SerializeField(s, m_arg0); - SerializeSeparator(s); - SerializeField(s, m_arg1); - SerializeSeparator(s); - SerializeField(s, m_arg2); - return s.str(); - } - - /** - * Deserialize event 3-tuple - * - * @param[in] stream Input stream to deserialize from - * @warning Internal use only - */ - virtual void DeserializeType(const std::string &stream) - { - std::vector splitVector = SplitStream(stream); - if (splitVector.size() != 3) - return; - std::istringstream s0(splitVector[0]); - std::istringstream s1(splitVector[1]); - std::istringstream s2(splitVector[2]); - m_arg0 = DeserializeField(s0, Arg0()); - m_arg1 = DeserializeField(s1, Arg1()); - m_arg2 = DeserializeField(s2, Arg2()); - } -}; - -template -class Generic4 - : public GenericBase -{ -public: - typedef Arg0Type Arg0; - typedef Arg1Type Arg1; - typedef Arg2Type Arg2; - typedef Arg3Type Arg3; - -private: - Arg0 m_arg0; - Arg1 m_arg1; - Arg2 m_arg2; - Arg3 m_arg3; - -public: - /** - * Init constructor - */ - explicit Generic4(const char *Gcid) - : GenericBase(Gcid), - m_arg0(), - m_arg1(), - m_arg2(), - m_arg3() - { - } - - /** - * Full init constructor - */ - explicit Generic4(const char *Gcid, const Arg0 &arg0, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) - : GenericBase(Gcid), - m_arg0(arg0), - m_arg1(arg1), - m_arg2(arg2), - m_arg3(arg3) - { - } - - /** - * Destructor - */ - virtual ~Generic4() - { - } - - /** - * Retrieve value of argument 0 from tuple - * - * @return Argument value - */ - const Arg0 &GetArg0() const - { - return m_arg0; - } - - /** - * Set value of argument 0 in tuple - * - * @param[in] value Argument value - */ - void SetArg0(const Arg0 &value) - { - m_arg0 = value; - } - - /** - * Retrieve value of argument 1 from tuple - * - * @return Argument value - */ - const Arg1 &GetArg1() const - { - return m_arg1; - } - - /** - * Set value of argument 1 in tuple - * - * @param[in] value Argument value - */ - void SetArg1(const Arg1 &value) - { - m_arg1 = value; - } - - /** - * Retrieve value of argument 2 from tuple - * - * @return Argument value - */ - const Arg2 &GetArg2() const - { - return m_arg2; - } - - /** - * Set value of argument 2 in tuple - * - * @param[in] value Argument value - */ - void SetArg2(const Arg2 &value) - { - m_arg2 = value; - } - - /** - * Retrieve value of argument 3 from tuple - * - * @return Argument value - */ - const Arg3 &GetArg3() const - { - return m_arg3; - } - - /** - * Set value of argument 3 in tuple - * - * @param[in] value Argument value - */ - void SetArg3(const Arg3 &value) - { - m_arg3 = value; - } - - /** - * Serialize event 4-tuple - * - * @return Ouput serialized stream - * @warning Internal use only - */ - virtual std::string SerializeType() const - { - std::ostringstream s; - SerializeField(s, m_arg0); - SerializeSeparator(s); - SerializeField(s, m_arg1); - SerializeSeparator(s); - SerializeField(s, m_arg2); - SerializeSeparator(s); - SerializeField(s, m_arg3); - return s.str(); - } - - /** - * Deserialize event 4-tuple - * - * @param[in] stream Input stream to deserialize from - * @warning Internal use only - */ - virtual void DeserializeType(const std::string &stream) - { - std::vector splitVector = SplitStream(stream); - if (splitVector.size() != 4) - return; - std::istringstream s0(splitVector[0]); - std::istringstream s1(splitVector[1]); - std::istringstream s2(splitVector[2]); - std::istringstream s3(splitVector[3]); - m_arg0 = DeserializeField(s0, Arg0()); - m_arg1 = DeserializeField(s1, Arg1()); - m_arg2 = DeserializeField(s2, Arg2()); - m_arg3 = DeserializeField(s3, Arg3()); - } -}; - -// Event declarators -#define EVENT_DELIVERY_DECLARE_EVENT_MESSAGE_0(EventType) \ - void EventType##_Inject(const std::string &metaData); \ - struct EventType##_StaticDeclarator \ - { \ - static char Name[0xFF]; \ - EventType##_StaticDeclarator(); \ - }; \ - class EventType : public DPL::Event::EventMessages::Generic0 \ - { \ - public: \ - EventType() : DPL::Event::EventMessages::Generic0(EventType##_StaticDeclarator::Name) {} \ - }; - -#define EVENT_DELIVERY_DECLARE_EVENT_MESSAGE_1(EventType, EventArg0Type) \ - void EventType##_Inject(const std::string &metaData); \ - struct EventType##_StaticDeclarator \ - { \ - static char Name[0xFF]; \ - EventType##_StaticDeclarator(); \ - }; \ - class EventType : public DPL::Event::EventMessages::Generic1 \ - { \ - public: \ - EventType() : DPL::Event::EventMessages::Generic1(EventType##_StaticDeclarator::Name) {} \ - EventType(const Arg0 &arg0) : DPL::Event::EventMessages::Generic1(EventType##_StaticDeclarator::Name, arg0) {} \ - }; - -#define EVENT_DELIVERY_DECLARE_EVENT_MESSAGE_2(EventType, EventArg0Type, EventArg1Type) \ - void EventType##_Inject(const std::string &metaData); \ - struct EventType##_StaticDeclarator \ - { \ - static char Name[0xFF]; \ - EventType##_StaticDeclarator(); \ - }; \ - class EventType : public DPL::Event::EventMessages::Generic2 \ - { \ - public: \ - EventType() : DPL::Event::EventMessages::Generic2(EventType##_StaticDeclarator::Name) {} \ - EventType(const Arg0 &arg0, const Arg1 &arg1) : DPL::Event::EventMessages::Generic2(EventType##_StaticDeclarator::Name, arg0, arg1) {} \ - }; - -#define EVENT_DELIVERY_DECLARE_EVENT_MESSAGE_3(EventType, EventArg0Type, EventArg1Type, EventArg2Type) \ - void EventType##_Inject(const std::string &metaData); \ - struct EventType##_StaticDeclarator \ - { \ - static char Name[0xFF]; \ - EventType##_StaticDeclarator(); \ - }; \ - class EventType : public DPL::Event::EventMessages::Generic3 \ - { \ - public: \ - EventType() : DPL::Event::EventMessages::Generic3(EventType##_StaticDeclarator::Name) {} \ - EventType(const Arg0 &arg0, const Arg1 &arg1, const Arg2 &arg2) : DPL::Event::EventMessages::Generic3(EventType##_StaticDeclarator::Name, arg0, arg1, arg2) {} \ - }; - -#define EVENT_DELIVERY_DECLARE_EVENT_MESSAGE_4(EventType, EventArg0Type, EventArg1Type, EventArg2Type, EventArg3Type) \ - void EventType##_Inject(const std::string &metaData); \ - struct EventType##_StaticDeclarator \ - { \ - static char Name[0xFF]; \ - EventType##_StaticDeclarator(); \ - }; \ - class EventType : public DPL::Event::EventMessages::Generic4 \ - { \ - public: \ - EventType() : DPL::Event::EventMessages::Generic4(EventType##_StaticDeclarator::Name) {} \ - EventType(const Arg0 &arg0, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) : DPL::Event::EventMessages::Generic4(EventType##_StaticDeclarator::Name, arg0, arg1, arg2, arg3) {} \ - }; - -#define EVENT_DELIVERY_IMPLEMENT_EVENT_MESSAGE(EventType) \ - char EventType##_StaticDeclarator::Name[0xFF] = {}; \ - void EventType##_Inject(const std::string &metaData) \ - { \ - EventType newType; \ - newType.DeserializeType(metaData); \ - DPL::Event::EventDeliverySystemInjector::Instance().Publish(newType); \ - } \ - EventType##_StaticDeclarator::EventType##_StaticDeclarator() \ - { \ - strcpy(Name, #EventType); \ - DPL::Event::EventDeliverySystemInjector::Instance().RegisterMetaCall(EventType##_StaticDeclarator::Name, EventType##_Inject); \ - } \ - namespace { EventType##_StaticDeclarator dummyInitializer_##EventType##_StaticDeclarator; } - -// BUILT-IN EVENTS -class RoamingChanged -{ -protected: - bool m_enabled; ///< Status whether roaming is enabled during call - -public: - /** - * Constructor - */ - RoamingChanged() - : m_enabled(false) - { - } - - /** - * Init constructor - */ - RoamingChanged(bool enabled) - : m_enabled(enabled) - { - } - - /** - * Destructor - */ - virtual ~RoamingChanged() - { - } - - /** - * Retrieve status whether roaming is enabled - * - * @return Current roaming status - */ - bool GetEnabled() const - { - return m_enabled; - } -}; - -class NetworkTypeChanged -{ -protected: - /** - * Status whether phone is working in: - * home network (true) - * roaming (false) - */ - bool m_homeNetwork; - -public: - /** - * Constructor - */ - NetworkTypeChanged() - : m_homeNetwork(true) - { - } - - /** - * Init constructor - */ - NetworkTypeChanged(bool homeNetwork) - : m_homeNetwork(homeNetwork) - { - } - - /** - * Destructor - */ - virtual ~NetworkTypeChanged() - { - } - - /** - * Retrieve status whether home network is active - * - * @return Current network status - */ - bool IsHomeNetwork() const - { - return m_homeNetwork; - } - - /** - * Retrieve status whether home network is active - * - * @return Current network status - */ - bool IsRoaming() const - { - return !m_homeNetwork; - } -}; - -class HibernationEnter -{ -public: - /** - * Constructor - */ - HibernationEnter() - { - } - - /** - * Destructor - */ - virtual ~HibernationEnter() - { - } -}; - -class HibernationLeave -{ -public: - /** - * Constructor - */ - HibernationLeave() - { - } - - /** - * Destructor - */ - virtual ~HibernationLeave() - { - } -}; - -} // namespace EventMessages -} -} // namespace DPL - -#endif // DPL_EVENT_DELIVERY_MESSAGES_H diff --git a/modules/event/include/dpl/event/nested_loop.h b/modules/event/include/dpl/event/nested_loop.h deleted file mode 100644 index 7138c8a..0000000 --- a/modules/event/include/dpl/event/nested_loop.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This file contains the declaration of the NestedLoopManager class. - * - * @file nested_loop.h - * @author Lukasz Marek (l.marek@samsung.com) - * @version 0.1 - * @brief This file contains the declaration of the NestedLoopManager class. - */ - -#ifndef DPL_NESTED_LOOP_H_ -#define DPL_NESTED_LOOP_H_ - -#include -#include -#include -#include -#include - -namespace DPL -{ -namespace Event -{ - -class LoopExitEvent -{ -}; - -typedef unsigned LoopHandle; -typedef std::list LoopHandleList; - -const LoopHandle UNDEFINED_LOOP_HANDLE = 0; - -class NestedLoopManager : - protected Controller::Type> -{ - public: - void* begin(LoopHandle loopHandle); - void exit(LoopHandle loopHandle, - void *userParam = NULL); - size_t getLevel() const; - LoopHandle getNewHandle(); - - protected: - void OnEventReceived(const LoopExitEvent& event); - - private: - struct LoopInformation - { - LoopInformation(LoopHandle handle) : - loopHandle(handle), - exitFlag(false), - userParam(NULL) - { - } - - LoopHandle loopHandle; - bool exitFlag; - void *userParam; - }; - - class RunningLoopsHandlePredicate - { - public: - RunningLoopsHandlePredicate(LoopHandle handle) : - m_handle(handle) - { - } - - bool operator()(const LoopInformation &loopInformation) const - { - return loopInformation.loopHandle == m_handle; - } - - private: - LoopHandle m_handle; - }; - - NestedLoopManager(); - ~NestedLoopManager(); - - typedef std::vector RunningLoopsList; - typedef RunningLoopsList::iterator RunningLoopsListIterator; - - bool m_eventGuard; // only one event is allowed - LoopHandle m_handle; - RunningLoopsList m_runningLoops; - - friend class Singleton; -}; - -typedef Singleton NestedLoopManagerSingleton; - -} -} // namespace DPL - -#endif // WRT_ENGINE_SRC_COMMON_NESTED_LOOP_H_ diff --git a/modules/event/src/event_delivery.cpp b/modules/event/src/event_delivery.cpp deleted file mode 100644 index 4a3dacc..0000000 --- a/modules/event/src/event_delivery.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file wrt_event_delivery.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of event delivery class - */ -#include -#include - -namespace DPL -{ -namespace Event -{ - -EventDeliverySystemDetail EventDeliverySystem::m_detailSystem; -EventDeliverySystem::AbstractPublisherPtrContainerMapType EventDeliverySystem::m_publishers; - -namespace // anonymous -{ -int InitializeMainSingleton(); - -int g_dummyInitializer = InitializeMainSingleton(); - -int InitializeMainSingleton() -{ - (void)g_dummyInitializer; - MainSingleton::Instance(); - return 0; -} -} // namespace anonymous - -AbstractEventDeliverySystemPublisher::~AbstractEventDeliverySystemPublisher() { } - -} -} // namespace DPL diff --git a/modules/event/src/event_delivery_detail.cpp b/modules/event/src/event_delivery_detail.cpp deleted file mode 100644 index 9c7e493..0000000 --- a/modules/event/src/event_delivery_detail.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file wrt_event_delivery_detail.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of event delivery EFL detail class - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace // anonymous -{ -const char *GENERIC_NOTI_ROOT_PATH = "/tmp/noti/generic"; -} // namespace anonymous - -namespace DPL -{ -namespace Event -{ - -const char *EventDeliverySystemDetail::NOTI_EVENT_ID_GENERIC_0 = "GenericEvent0_"; -const char *EventDeliverySystemDetail::NOTI_EVENT_ID_GENERIC_1 = "GenericEvent1_"; -const char *EventDeliverySystemDetail::NOTI_EVENT_ID_GENERIC_2 = "GenericEvent2_"; -const char *EventDeliverySystemDetail::NOTI_EVENT_ID_GENERIC_3 = "GenericEvent3_"; -const char *EventDeliverySystemDetail::NOTI_EVENT_ID_GENERIC_4 = "GenericEvent4_"; - -// Global noti signal names -const char *GlobalNotiHibernationEnterSignal = "HIBERNATION_ENTER"; -const char *GlobalNotiHibernationLeaveSignal = "HIBERNATION_LEAVE"; - -EventDeliverySystemDetail::EventDeliverySystemDetail() -{ - // Open noti subsystem - LogInfo("Initializing core_util_noti subsystem..."); - - m_notiHandle = heynoti_init(); - Assert(m_notiHandle != -1); - - // Assume that there is ECORE environment running, attach noti library to it - LogPedantic("Attaching core_util_noti subsystem to ECORE..."); - - int ret = heynoti_attach_handler(m_notiHandle); - Assert(ret != -1); - - (void)ret; - - LogInfo("core_util_noti subsystem successfuly initialized."); -} - -EventDeliverySystemDetail::~EventDeliverySystemDetail() -{ - // All signal handlers should be deattached - Assert(m_notiSignalList.empty()); - Assert(m_settingSignalList.empty()); - Assert(m_globalNotiSignalList.empty()); - - // Detach noti library from ECORE environment - LogPedantic("Detaching core_util_noti subsystem from ECORE..."); - - int ret = heynoti_detach_handler(m_notiHandle); - Assert(ret != -1); - - (void)ret; - - // Close noti sybsystem - LogInfo("Deinitializing core_util_noti subsystem..."); - - Assert(m_notiHandle != -1); - heynoti_close(m_notiHandle); - - LogInfo("core_util_noti subsystem successfuly deinitialized."); -} - -std::string EventDeliverySystemDetail::ReadFile(const std::string &fileName) const -{ - LogPedantic("Reading event file: " << fileName << "..."); - - std::ifstream fileStream(fileName.c_str(), std::ios::binary); - - if (fileStream.fail()) - return std::string(""); - - fileStream.seekg (0, std::ios::end); - std::streamoff length = fileStream.tellg(); - fileStream.seekg (0, std::ios::beg); - - ScopedArray buffer(new char[length]); - fileStream.read(buffer.Get(), static_cast(length)); - - if (fileStream.fail()) - return std::string(); - - LogPedantic("Successfuly read: " << fileName << "."); - - return std::string(buffer.Get(), buffer.Get() + length); -} - -void EventDeliverySystemDetail::OnNotiGlobalSignal(void *notiData) -{ - Assert(notiData); - NotiSignal *notiSignal = static_cast(notiData); - notiSignal->GetReceiver()->OnNotiSignal(notiSignal); -} - -void EventDeliverySystemDetail::OnSettingSignal(keynode_t *keyNode, void *userParam) -{ - SettingSignal *settingSignal = static_cast(userParam); - (void)settingSignal; - - LogPedantic("Got setting signal for key: " << settingSignal->GetKey()); - - std::string key = vconf_keynode_get_name(keyNode); - - if (key == VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL) - { - int value = vconf_keynode_get_bool(keyNode); - EventMessages::RoamingChanged message(value > 0); - EventDeliverySystemInjector::Instance().Publish(message); - } - else if (key == VCONFKEY_TELEPHONY_SVC_ROAM) - { - int result = 0; - if(vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &result) != 0) - { - LogPedantic("Cannot get current roaming status"); - return; - } - else - { - bool homeNetwork = (result != VCONFKEY_TELEPHONY_SVC_ROAM_ON); - EventMessages::NetworkTypeChanged message1(homeNetwork); - EventDeliverySystemInjector::Instance().Publish(message1); - } - } - else - { - LogPedantic("Unexpected setting signal key: " << key << "!"); - return; - } -} - -void EventDeliverySystemDetail::OnGlobalNotiSignal(void *globalNotiData) -{ - GlobalNotiSignal *globalNotiSignal = static_cast(globalNotiData); - - LogPedantic("Got global noti signal for key: " << globalNotiSignal->GetKey()); - - std::string key = globalNotiSignal->GetKey(); - - if (key == GlobalNotiHibernationEnterSignal) - { - // We need to disconnect from VCONF - for (SettingSignalList::iterator iterator = globalNotiSignal->GetReceiver()->m_settingSignalList.begin(); - iterator != globalNotiSignal->GetReceiver()->m_settingSignalList.end(); ++iterator) - { - // Unegister from VCONF signals - int ret = vconf_ignore_key_changed(iterator->GetKey().c_str(), OnSettingSignal); - - if (ret == -1) - LogPedantic("Failed to unlisten setting: " << key << ", errno = " << errno << "."); - } - - // Publish - EventMessages::HibernationEnter message; - EventDeliverySystemInjector::Instance().Publish(message); - } - else if (key == GlobalNotiHibernationLeaveSignal) - { - // We need to reconnect to VCONF - for (SettingSignalList::iterator iterator = globalNotiSignal->GetReceiver()->m_settingSignalList.begin(); - iterator != globalNotiSignal->GetReceiver()->m_settingSignalList.end(); ++iterator) - { - // Register for VCONF signals - int ret = vconf_notify_key_changed(iterator->GetKey().c_str(), OnSettingSignal, &*iterator); - - if (ret == -1) - LogPedantic("Failed to listen setting: key = " << key << ", errno = " << errno << "."); - } - - // Publish - EventMessages::HibernationLeave message; - EventDeliverySystemInjector::Instance().Publish(message); - } - else - { - LogPedantic("Unexpected global noti signal key: " << key << "!"); - return; - } -} - -void EventDeliverySystemDetail::OnNotiSignal(NotiSignal *notiSignal) -{ - LogPedantic("Got core_util_noti signal."); - - if (notiSignal->GetEventName().substr(0, strlen(NOTI_EVENT_ID_GENERIC_0)) == NOTI_EVENT_ID_GENERIC_0) - { - LogPedantic("GeneticEvent0 message signal."); - - EventDeliverySystemInjector::Instance().PublishMetaType(notiSignal->GetGcid(), ReadFile(GetGenericNotiFilePath(notiSignal->GetEventName()))); - } - else if (notiSignal->GetEventName().substr(0, strlen(NOTI_EVENT_ID_GENERIC_1)) == NOTI_EVENT_ID_GENERIC_1) - { - LogPedantic("GeneticEvent1 message signal."); - - EventDeliverySystemInjector::Instance().PublishMetaType(notiSignal->GetGcid(), ReadFile(GetGenericNotiFilePath(notiSignal->GetEventName()))); - } - else if (notiSignal->GetEventName().substr(0, strlen(NOTI_EVENT_ID_GENERIC_2)) == NOTI_EVENT_ID_GENERIC_2) - { - LogPedantic("GeneticEvent2 message signal."); - - EventDeliverySystemInjector::Instance().PublishMetaType(notiSignal->GetGcid(), ReadFile(GetGenericNotiFilePath(notiSignal->GetEventName()))); - } - else if (notiSignal->GetEventName().substr(0, strlen(NOTI_EVENT_ID_GENERIC_3)) == NOTI_EVENT_ID_GENERIC_3) - { - LogPedantic("GeneticEvent3 message signal."); - - EventDeliverySystemInjector::Instance().PublishMetaType(notiSignal->GetGcid(), ReadFile(GetGenericNotiFilePath(notiSignal->GetEventName()))); - } - else if (notiSignal->GetEventName().substr(0, strlen(NOTI_EVENT_ID_GENERIC_4)) == NOTI_EVENT_ID_GENERIC_4) - { - LogPedantic("GeneticEvent4 message signal."); - - EventDeliverySystemInjector::Instance().PublishMetaType(notiSignal->GetGcid(), ReadFile(GetGenericNotiFilePath(notiSignal->GetEventName()))); - } -} - -void EventDeliverySystemDetail::RegisterFileNotiCallback(const char *gcid, const std::string &eventName) -{ - LogPedantic("Registering core_util_noti callback: gcid = " << (gcid ? gcid : "") << ", eventName = " << eventName << "."); - Assert(m_notiHandle != -1); - - // Check if already registered for signal - NotiSignalList::const_iterator iterator; - - for (iterator = m_notiSignalList.begin(); iterator != m_notiSignalList.end(); ++iterator) - { - if (iterator->GetEventName() == eventName) - return; - } - - // Make real noti path - std::string filePath = GetGenericNotiFilePath(eventName); - - LogPedantic("Listening file: " << filePath << "."); - - // New noti signal - m_notiSignalList.push_back(NotiSignal(this, gcid, eventName)); - NotiSignal *notiSignal = &m_notiSignalList.back(); - - // Register for noti signals - int ret = heynoti_subscribe_file(m_notiHandle, filePath.c_str(), OnNotiGlobalSignal, notiSignal, IN_CLOSE_WRITE); - - if (ret == -1) - { - LogPedantic("Failed to listen file: " << filePath << "."); - return; - } - - LogPedantic("Successfuly registered listening file: " << filePath << "."); -} - -void EventDeliverySystemDetail::UnregisterFileNotiCallback(const std::string &eventName) -{ - LogPedantic("Unegistering core_util_noti callback: eventName = " << eventName << "."); - - Assert(m_notiHandle != -1); - - NotiSignalList::iterator iterator; - - for (iterator = m_notiSignalList.begin(); iterator != m_notiSignalList.end(); ++iterator) - { - if (iterator->GetEventName() == eventName) - break; - } - - if (iterator == m_notiSignalList.end()) - return; - - // Remove registered slot - m_notiSignalList.erase(iterator); - - // Make real noti path - std::string filePath = GetGenericNotiFilePath(eventName); - - LogPedantic("Unlistening file: " << filePath << "."); - - // Register for noti signals - int ret = heynoti_unsubscribe_file(m_notiHandle, filePath.c_str(), OnNotiGlobalSignal); - - if (ret == -1) - { - LogPedantic("Failed to unlisten file: " << filePath << "."); - return; - } -} - -void EventDeliverySystemDetail::RegisterSettingCallback(const std::string &key) -{ - LogPedantic("Registering setting: key = " << key << "."); - - // Check if already registered for signal - SettingSignalList::const_iterator iterator; - - for (iterator = m_settingSignalList.begin(); iterator != m_settingSignalList.end(); ++iterator) - { - if (iterator->GetKey() == key) - return; - } - - // New noti signal - m_settingSignalList.push_back(SettingSignal(this, key)); - SettingSignal *settingSignal = &m_settingSignalList.back(); - - // Register for setting signals - int ret = vconf_notify_key_changed(key.c_str(), OnSettingSignal, settingSignal); - - if (ret == -1) - { - LogPedantic("Failed to listen setting: key = " << key << ", errno = " << errno << "."); - return; - } - - LogPedantic("Successfuly registered setting: key = " << key << "."); -} - -void EventDeliverySystemDetail::UnregisterSettingCallback(const std::string &key) -{ - LogPedantic("Unegistering setting: key = " << key << "."); - - SettingSignalList::iterator iterator; - - for (iterator = m_settingSignalList.begin(); iterator != m_settingSignalList.end(); ++iterator) - { - if (iterator->GetKey() == key) - break; - } - - if (iterator == m_settingSignalList.end()) - return; - - // Remove registered slot - m_settingSignalList.erase(iterator); - - // Register for noti signals - int ret = vconf_ignore_key_changed(key.c_str(), OnSettingSignal); - - if (ret == -1) - { - LogPedantic("Failed to unlisten setting: " << key << ", errno = " << errno << "."); - return; - } -} - -void EventDeliverySystemDetail::RegisterGlobalNotiCallback(const std::string &key) -{ - LogPedantic("Registering global noti: key = " << key << "."); - - // Check if already registered for signal - GlobalNotiSignalList::const_iterator iterator; - - for (iterator = m_globalNotiSignalList.begin(); iterator != m_globalNotiSignalList.end(); ++iterator) - { - if (iterator->GetKey() == key) - return; - } - - // New noti signal - m_globalNotiSignalList.push_back(GlobalNotiSignal(this, key)); - GlobalNotiSignal *globalNotiSignal = &m_globalNotiSignalList.back(); - - // Register for global noti signals - int ret = heynoti_subscribe(m_notiHandle, key.c_str(), OnGlobalNotiSignal, globalNotiSignal); - - if (ret == -1) - { - LogPedantic("Failed to listen global noti: key = " << key << ", errno = " << errno << "."); - return; - } - - LogPedantic("Successfuly registered global noti: key = " << key << "."); -} - -void EventDeliverySystemDetail::UnregisterGlobalNotiCallback(const std::string &key) -{ - LogPedantic("Unegistering global noti: key = " << key << "."); - - GlobalNotiSignalList::iterator iterator; - - for (iterator = m_globalNotiSignalList.begin(); iterator != m_globalNotiSignalList.end(); ++iterator) - { - if (iterator->GetKey() == key) - break; - } - - if (iterator == m_globalNotiSignalList.end()) - return; - - // Remove registered slot - m_globalNotiSignalList.erase(iterator); - - // Register for noti signals - int ret = heynoti_unsubscribe(m_notiHandle, key.c_str(), OnGlobalNotiSignal); - - if (ret == -1) - { - LogPedantic("Failed to unlisten global noti: " << key << ", errno = " << errno << "."); - return; - } -} - -void EventDeliverySystemDetail::SignalGenericNoti(const std::string &eventName, const std::string &contents) const -{ - LogPedantic("Signaling core_util_noti with: eventName = " << eventName << ", buffer = " << contents << "."); - - Assert(m_notiHandle != -1); - - // Make real noto path - std::string filePath = GetGenericNotiFilePath(eventName); - - LogPedantic("Signaling file: " << filePath << "."); - - // Emit noti signal with user data - int fd = open(filePath.c_str(), O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR); - - if (fd == -1) - { - LogPedantic("Failed to signal file: " << filePath << "."); - return; - } - - // Write contents of signal to file - std::string::size_type written = 0; - - while (written < contents.size()) - { - int done = TEMP_FAILURE_RETRY(write(fd, static_cast(&contents[written]), contents.size() - written)); - - if (done <= 0) - { - LogPedantic("File stream broken: " << filePath << "."); - break; - } - - written += done; - } - - // Close signal file - int ret = close(fd); - - if (ret == -1) - { - LogPedantic("Failed to close signal file: " << filePath << "."); - return; - } -} - -std::string EventDeliverySystemDetail::GetGenericNotiFilePath(const std::string &eventName) const -{ - // Make sure that the path exists - if (access(GENERIC_NOTI_ROOT_PATH, F_OK) == -1) - { - LogPedantic("No root path found. Creating root path..."); - - // Create path - if (mkdir(GENERIC_NOTI_ROOT_PATH, 0755) == -1) - { - LogPedantic("Failed to create root path!"); - return std::string("~") + eventName; - } - - LogPedantic("Root path created."); - } - - return std::string(GENERIC_NOTI_ROOT_PATH) + "/" + eventName; -} - -void EventDeliverySystemDetail::Listen(const EventMessages::RoamingChanged &event) -{ - LogPedantic("RoamingChanged message listen."); - - (void)event; - RegisterSettingCallback(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL); -} - -void EventDeliverySystemDetail::Listen(const EventMessages::NetworkTypeChanged &event) -{ - LogPedantic("NetworkTypeChanged message listen."); - - (void)event; - RegisterSettingCallback(VCONFKEY_TELEPHONY_SVC_ROAM); -} - -void EventDeliverySystemDetail::Listen(const EventMessages::HibernationEnter &event) -{ - LogPedantic("HibernationEnter message listen."); - - (void)event; - RegisterGlobalNotiCallback(GlobalNotiHibernationEnterSignal); -} - -void EventDeliverySystemDetail::Listen(const EventMessages::HibernationLeave &event) -{ - LogPedantic("HibernationLeave message listen."); - - (void)event; - RegisterGlobalNotiCallback(GlobalNotiHibernationLeaveSignal); -} - -void EventDeliverySystemDetail::Unlisten(const EventMessages::RoamingChanged &event) -{ - LogPedantic("RoamingChanged message unlisten."); - - (void)event; - UnregisterSettingCallback(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL); -} - -void EventDeliverySystemDetail::Unlisten(const EventMessages::NetworkTypeChanged &event) -{ - LogPedantic("NetworkTypeChanged message unlisten."); - - (void)event; - UnregisterSettingCallback(VCONFKEY_TELEPHONY_SVC_ROAM); -} - -void EventDeliverySystemDetail::Unlisten(const EventMessages::HibernationEnter &event) -{ - LogPedantic("HibernationEnter message unlisten."); - - (void)event; - UnregisterGlobalNotiCallback(GlobalNotiHibernationEnterSignal); -} - -void EventDeliverySystemDetail::Unlisten(const EventMessages::HibernationLeave &event) -{ - LogPedantic("HibernationLeave message unlisten."); - - (void)event; - UnregisterGlobalNotiCallback(GlobalNotiHibernationLeaveSignal); -} - -} -} // namespace DPL diff --git a/modules/event/src/nested_loop.cpp b/modules/event/src/nested_loop.cpp deleted file mode 100644 index c142fd7..0000000 --- a/modules/event/src/nested_loop.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This file contains the definition of the NestedLoopManager class. - * - * @file nested_loop.cpp - * @author Lukasz Marek (l.marek@samsung.com) - * @version 0.1 - * @brief This file contains the definition of the NestedLoopManager class. - */ - -#include -#include -#include -#include -#include -#include - -IMPLEMENT_SINGLETON(DPL::Event::NestedLoopManager) - -namespace DPL -{ -namespace Event -{ - -NestedLoopManager::NestedLoopManager() : m_eventGuard(false), - m_handle(0) -{ - Touch(); -} - -NestedLoopManager::~NestedLoopManager() -{ -} - -void* NestedLoopManager::begin(LoopHandle loopHandle) -{ - LoopInformation info(loopHandle); - m_runningLoops.push_back(info); - LogPedantic("Nested loop begin. Nested loop level: " << getLevel()); - - ecore_main_loop_begin(); - - Assert(m_runningLoops.size() && "No loop on the stack"); - - info = m_runningLoops.back(); - m_runningLoops.pop_back(); - - Assert(info.loopHandle == loopHandle && "You exit from wrong loop"); - Assert(info.exitFlag == true && "Exit flag not set"); - - LogPedantic("Nested loop quit. Nested loop level: " << getLevel()); - - if (!m_runningLoops.empty() && m_runningLoops.back().exitFlag && - !m_eventGuard) { - m_eventGuard = true; - LoopExitEvent event; - PostEvent(event); - } - return info.userParam; -} - -void NestedLoopManager::exit(LoopHandle loopHandle, - void *userParam) -{ - RunningLoopsListIterator iterator = std::find_if( - m_runningLoops.begin(), - m_runningLoops.end(), - RunningLoopsHandlePredicate(loopHandle)); - - Assert(iterator != m_runningLoops.end() && "Unknown loopHandle"); - Assert(iterator->exitFlag == false && "You cannot close a loop twice."); - - iterator->exitFlag = true; - iterator->userParam = userParam; - - if (m_runningLoops.back().exitFlag && !m_eventGuard) { - m_eventGuard = true; - LoopExitEvent event; - PostEvent(event); - } -} - -size_t NestedLoopManager::getLevel() const -{ - return m_runningLoops.size(); -} - -LoopHandle NestedLoopManager::getNewHandle() -{ - return m_handle++; -} - -void NestedLoopManager::OnEventReceived(const LoopExitEvent& event) -{ - (void)event; - Assert(!m_runningLoops.empty()); - m_eventGuard = false; // no event in queue - if (m_runningLoops.back().exitFlag) { - //exit loop when last started one is readu to finish - //this will post event if next loop is ready to exit - ecore_main_loop_quit(); - } -} - -} -} diff --git a/modules/popup/DESCRIPTION b/modules/popup/DESCRIPTION deleted file mode 100644 index 665e43e..0000000 --- a/modules/popup/DESCRIPTION +++ /dev/null @@ -1,2 +0,0 @@ -!!!options!!! stop -UI module for displaying all kinds of pop-up dialogs diff --git a/modules/popup/config.cmake b/modules/popup/config.cmake deleted file mode 100644 index 7a304d9..0000000 --- a/modules/popup/config.cmake +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# @file CMakeLists.txt -# @author Pawel Sikorski (p.sikorski@samsung.com) -# @version 1.0 -# - -SET(DPL_POPUP_SOURCES - ${PROJECT_SOURCE_DIR}/modules/popup/src/popup_manager.cpp - ${PROJECT_SOURCE_DIR}/modules/popup/src/evas_object.cpp - ${PROJECT_SOURCE_DIR}/modules/popup/src/popup_renderer.cpp - ${PROJECT_SOURCE_DIR}/modules/popup/src/popup_controller.cpp - PARENT_SCOPE - ) - -SET(DPL_POPUP_HEADERS - ${PROJECT_SOURCE_DIR}/modules/popup/include/dpl/popup/popup.h - ${PROJECT_SOURCE_DIR}/modules/popup/include/dpl/popup/evas_object.h - ${PROJECT_SOURCE_DIR}/modules/popup/include/dpl/popup/popup_controller.h - ${PROJECT_SOURCE_DIR}/modules/popup/include/dpl/popup/popup_manager.h - ${PROJECT_SOURCE_DIR}/modules/popup/include/dpl/popup/popup_object.h - ${PROJECT_SOURCE_DIR}/modules/popup/include/dpl/popup/popup_renderer.h - PARENT_SCOPE - ) - -SET(DPL_POPUP_INCLUDE_DIR - ${PROJECT_SOURCE_DIR}/modules/popup/include - PARENT_SCOPE -) \ No newline at end of file diff --git a/modules/popup/include/dpl/popup/evas_object.h b/modules/popup/include/dpl/popup/evas_object.h deleted file mode 100644 index ba4ad9b..0000000 --- a/modules/popup/include/dpl/popup/evas_object.h +++ /dev/null @@ -1,661 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file evas_object.h - * @author Lukasz Wrzosek (l.wrzosel@samsung.com) - * @version 1.0 - * @brief This file is the header for Evas_Object wrapper from Efl. - */ -#ifndef WRT_SRC_DOMAIN_EFL_EVAS_OBJECT_H -#define WRT_SRC_DOMAIN_EFL_EVAS_OBJECT_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace DPL { -namespace Popup { - -class EvasObject -{ - class EvasObjectShared; - typedef DPL::SharedPtr EvasObjectSharedPtr; - - public: - class IConnection - { - public: - Evas_Object* GetEvasObject(); - void Disconnect(); - - private: - IConnection(EvasObjectShared* object); - virtual ~IConnection() - { - } - virtual void Call(void* /*event_info*/) = 0; - - static void SmartCallbackWrapper(void* data, - Evas_Object* /*object*/, - void* event_info); - static void EvasCallbackWrapper(void* data, - Evas* /*evas*/, - Evas_Object* /*object*/, - void* event_info); - - virtual void ConnectPrv() = 0; - virtual void DisconnectPrv() = 0; - - friend class EvasObjectShared; - - EvasObjectShared* m_object; - }; - - private: - class EvasObjectShared : DPL::Noncopyable - { - public: - friend class IConnection; - Evas_Object* GetObject(); - - typedef std::set IConnectionsSet; - - class SmartConnectionBase : public IConnection - { - public: - SmartConnectionBase(const std::string& name, - EvasObjectShared* object); - - virtual void ConnectPrv(); - virtual void DisconnectPrv(); - std::string m_callbackName; - }; - - template - class SmartConnection : public SmartConnectionBase - { - public: - typedef void (*CbType)(IConnection* connection, - void* event_info, - Args ... args); - - SmartConnection(const std::string& name, - CbType callback, - EvasObjectShared* object, - Args ... args) : - SmartConnectionBase(name, object), - m_callback(callback), - m_args(args ...) - { - } - - virtual ~SmartConnection() - { - } - - virtual void Call(void* event_info) - { - DPL::Apply(m_callback, - m_args, - this, - event_info); - } - - private: - CbType m_callback; - std::tuple m_args; - }; - - template - class SmartMemberConnection1 : public SmartConnectionBase - { - public: - typedef void (ThisType::*CbType)(IConnection* connection, - void* event_info, ArgType1 *arg1); - - SmartMemberConnection1(const std::string& name, - CbType callback, - ThisType* callee, - ArgType1* arg1, - EvasObjectShared* object) : - SmartConnectionBase(name, object), - m_callback(callback), - m_callee(callee), - m_arg1(arg1) - { - } - - virtual ~SmartMemberConnection1() - { - } - - virtual void Call(void* event_info) - { - (m_callee->*m_callback)(this, event_info, m_arg1); - } - - private: - CbType m_callback; - ThisType* m_callee; - ArgType1* m_arg1; - }; - - template - class SmartMemberConnection2 : public SmartConnectionBase - { - public: - typedef void (ThisType::*CbType)(IConnection* connection, - void* event_info, ArgType1 *arg1, - ArgType2* arg2); - - SmartMemberConnection2(const std::string& name, - CbType callback, - ThisType* callee, - ArgType1* arg1, - ArgType2* arg2, - EvasObjectShared* object) : - SmartConnectionBase(name, object), - m_callback(callback), - m_callee(callee), - m_arg1(arg1), - m_arg2(arg2) - { - } - - virtual ~SmartMemberConnection2() - { - } - - virtual void Call(void* event_info) - { - (m_callee->*m_callback)(this, event_info, m_arg1, m_arg2); - } - - private: - CbType m_callback; - ThisType* m_callee; - ArgType1* m_arg1; - ArgType2* m_arg2; - }; - - class EvasConnectionBase : public IConnection - { - public: - EvasConnectionBase(Evas_Callback_Type type, - EvasObjectShared* object); - - virtual void ConnectPrv(); - virtual void DisconnectPrv(); - - Evas_Callback_Type m_callbackType; - }; - - template - class EvasConnection1 : public EvasConnectionBase - { - public: - typedef void (*CbType)(IConnection* connection, void* event_info, - ArgType1 *arg1); - - EvasConnection1(Evas_Callback_Type type, - CbType callback, - ArgType1* arg1, - EvasObjectShared* object) : - EvasConnectionBase(type, object), - m_callback(callback), - m_arg1(arg1) - { - } - - virtual ~EvasConnection1() - { - } - - virtual void Call(void* event_info) - { - m_callback(this, event_info, m_arg1); - } - - private: - CbType m_callback; - ArgType1* m_arg1; - }; - - template - class EvasConnection2 : public EvasConnectionBase - { - public: - typedef void (*CbType)(IConnection* connection, void* event_info, - ArgType1 *arg1, ArgType2 *arg2); - - EvasConnection2(Evas_Callback_Type type, - CbType callback, - ArgType1* arg1, - ArgType2* arg2, - EvasObjectShared* object) : - EvasConnectionBase(type, object), - m_callback(callback), - m_arg1(arg1), - m_arg2(arg2) - { - } - - virtual ~EvasConnection2() - { - } - - virtual void Call(void* event_info) - { - m_callback(this, event_info, m_arg1, m_arg2); - } - - private: - CbType m_callback; - ArgType1* m_arg1; - ArgType2* m_arg2; - }; - - template - class EvasMemberConnection1 : public EvasConnectionBase - { - public: - typedef void (ThisType::*CbType)(IConnection* connection, - void* event_info, ArgType1 *arg1); - - EvasMemberConnection1(Evas_Callback_Type type, - CbType callback, - ThisType* callee, - ArgType1* arg1, - EvasObjectShared* object) : - EvasConnectionBase(type, object), - m_callback(callback), - m_callee(callee), - m_arg1(arg1) - { - } - - virtual ~EvasMemberConnection1() - { - } - - virtual void Call(void* event_info) - { - (m_callee->*m_callback)(this, event_info, m_arg1); - } - - private: - CbType m_callback; - ThisType* m_callee; - ArgType1* m_arg1; - }; - - template - class EvasMemberConnection2 : public EvasConnectionBase - { - public: - typedef void (ThisType::*CbType)(IConnection* connection, - void* event_info, ArgType1* arg1, - ArgType2* arg2); - - EvasMemberConnection2(Evas_Callback_Type type, - CbType callback, - ThisType* callee, - ArgType1* arg1, - ArgType2* arg2, - EvasObjectShared* object) : - EvasConnectionBase(type, object), - m_callback(callback), - m_callee(callee), - m_arg1(arg1), - m_arg2(arg2) - { - } - - virtual ~EvasMemberConnection2() - { - } - - virtual void Call(void* event_info) - { - (m_callee->*m_callback)(this, event_info, m_arg1, m_arg2); - } - - private: - CbType m_callback; - ThisType* m_callee; - ArgType1* m_arg1; - ArgType2* m_arg2; - }; - - EvasObjectShared(); - explicit EvasObjectShared(Evas_Object* object); - void SetObject(Evas_Object* object); - ~EvasObjectShared(); - - template - IConnection* ConnectSmartCallback(const char* callbackName, - typename SmartConnection::CbType callback, - Args ... args) - { - Assert(m_object); - Assert(callbackName); - Assert(callback); - IConnection* connection = new SmartConnection( - callbackName, - callback, - this, - args ...); - m_connections.insert(connection); - connection->ConnectPrv(); - return connection; - } - - template - IConnection* ConnectMemberSmartCallback( - const char* callbackName, - typename SmartMemberConnection2::CbType callback, - ThisType* callee, - ArgType1* arg1, - ArgType2* arg2) - { - Assert(m_object); - Assert(callee); - Assert(callbackName); - Assert(callback); - IConnection* connection = - new SmartMemberConnection2( - callbackName, - callback, - callee, - arg1, - arg2, - this); - m_connections.insert(connection); - connection->ConnectPrv(); - return connection; - } - - template - IConnection* ConnectMemberSmartCallback( - const char* callbackName, - typename SmartMemberConnection1::CbType callback, - ThisType* callee, - ArgType1* arg1) - { - Assert(m_object); - Assert(callee); - Assert(callbackName); - Assert(callback); - IConnection* connection = - new SmartMemberConnection1(callbackName, - callback, - callee, - arg1, - this); - m_connections.insert(connection); - connection->ConnectPrv(); - return connection; - } - - template - IConnection* ConnectEvasCallback(Evas_Callback_Type callbackType, - typename EvasConnection2::CbType callback, - ArgType1* arg1, - ArgType2* arg2) - { - Assert(m_object); - Assert(callbackType); - Assert(callback); - IConnection* connection = new EvasConnection2( - callbackType, - callback, - arg1, - arg2, - this); - m_connections.insert(connection); - connection->ConnectPrv(); - return connection; - } - - template - IConnection* ConnectEvasCallback(Evas_Callback_Type callbackType, - typename EvasConnection1::CbType callback, - ArgType1* arg1) - { - Assert(m_object); - Assert(callbackType); - Assert(callback); - IConnection* connection = new EvasConnection1( - callbackType, - callback, - arg1, - this); - m_connections.insert(connection); - connection->ConnectPrv(); - return connection; - } - - template - IConnection* ConnectMemberEvasCallback( - Evas_Callback_Type callbackType, - typename EvasMemberConnection2::CbType callback, - ThisType* callee, - ArgType1* arg1, - ArgType2* arg2) - { - Assert(m_object); - Assert(callee); - Assert(callbackType); - Assert(callback); - IConnection* connection = - new EvasMemberConnection2( - callbackType, - callback, - callee, - arg1, - arg2, - this); - m_connections.insert(connection); - connection->ConnectPrv(); - return connection; - } - - template - IConnection* ConnectMemberEvasCallback( - Evas_Callback_Type callbackType, - typename EvasMemberConnection1::CbType callback, - ThisType* callee, - ArgType1* arg1) - { - Assert(m_object); - Assert(callee); - Assert(callbackType); - Assert(callback); - IConnection* connection = - new EvasMemberConnection1(callbackType, - callback, - callee, - arg1, - this); - m_connections.insert(connection); - connection->ConnectPrv(); - return connection; - } - - bool DisconnectCallback(IConnection* connection); - void DisconnectAll(); - - static void StaticOnDelEvent(void* data, - Evas* /*e*/, - Evas_Object* /*o*/, - void* /*ev*/); - - IConnectionsSet m_connections; - Evas_Object* m_object; - }; - - public: - EvasObject(); - explicit EvasObject(Evas_Object* object); - EvasObject(const EvasObject& other); - ~EvasObject(); - - EvasObject& operator=(const EvasObject& other); - EvasObject* operator=(Evas_Object* object); - - operator Evas_Object *(); - - bool IsValid() const - { - Assert(m_object); - return m_object->GetObject() != NULL; - } - - bool DisconnectCallback(IConnection* connection); - void DisconnectAll(); - - template - IConnection* ConnectSmartCallback( - const char* callbackName, - typename EvasObjectShared::SmartConnection::CbType - callback, - Args ... args) - { - Assert(m_object); - return m_object->ConnectSmartCallback(callbackName, callback, args ...); - } - - template - IConnection* ConnectMemberSmartCallback( - const char* callbackName, - typename EvasObjectShared::SmartMemberConnection2::CbType - callback, - ThisType* callee, - ArgType1* arg1, - ArgType2* arg2) - { - Assert(m_object); - Assert(callee); - Assert(callback); - return m_object->ConnectMemberSmartCallback(callbackName, - callback, - callee, - arg1, - arg2); - } - - template - IConnection* ConnectMemberSmartCallback( - const char* callbackName, - typename EvasObjectShared::SmartMemberConnection1::CbType - callback, - ThisType* callee, - ArgType1* arg1) - { - Assert(m_object); - Assert(callee); - Assert(callback); - return m_object->ConnectMemberSmartCallback(callbackName, - callback, - callee, - arg1); - } - - template - IConnection* ConnectEvasCallback( - Evas_Callback_Type callbackType, - typename EvasObjectShared::EvasConnection1::CbType - callback, - ArgType1* arg1, - ArgType2* arg2) - { - Assert(m_object); - return m_object->ConnectEvasCallback(callbackType, callback, arg1, arg2); - } - - template - IConnection* ConnectEvasCallback( - Evas_Callback_Type callbackType, - typename EvasObjectShared::EvasConnection1::CbType - callback, - ArgType1* arg1) - { - Assert(m_object); - return m_object->ConnectEvasCallback(callbackType, callback, arg1); - } - - template - IConnection* ConnectMemberEvasCallback( - Evas_Callback_Type callbackType, - typename EvasObjectShared::EvasMemberConnection1::CbType - callback, - ThisType* callee, - ArgType1* arg1) - { - Assert(m_object); - Assert(callee); - Assert(callback); - return m_object->ConnectMemberEvasCallback(callbackType, - callback, - callee, - arg1); - } - - template - IConnection* ConnectMemberEvasCallback( - Evas_Callback_Type callbackType, - typename EvasObjectShared::EvasMemberConnection2::CbType - callback, - ThisType* callee, - ArgType1* arg1, - ArgType2* arg2) - { - Assert(m_object); - Assert(callee); - Assert(callback); - return m_object->ConnectMemberEvasCallback(callbackType, - callback, - callee, - arg1, - arg2); - } - - private: - EvasObjectSharedPtr m_object; -}; - -}//namespace -}//namespace - - -#endif //WRT_SRC_DOMAIN_EFL_EVAS_OBJECT_H - diff --git a/modules/popup/include/dpl/popup/popup.h b/modules/popup/include/dpl/popup/popup.h deleted file mode 100644 index 59fd854..0000000 --- a/modules/popup/include/dpl/popup/popup.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file popup.h - * @author Lukasz Wrzosek (l.wrzosek@samsung.com) - * @version 1.0 - * @brief This is popup inteface declaration - */ - -#ifndef WRT_SRC_POPUP_POPUP_H_ -#define WRT_SRC_POPUP_POPUP_H_ - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace DPL { -namespace Popup { - -struct AnswerCallbackData -{ - int buttonAnswer; - DPL::Optional password; - bool chackState; - DPL::Event::LoopHandle loopHandle; -}; - -class PopupManager; -class IPopup; -typedef DPL::SharedPtr IPopupPtr; - -class IPopup : protected DPL::EnableSharedFromThis -{ - public: - virtual void SetTitle(const std::string &title) = 0; - /*The object is deleted automatically after rendered */ - virtual void Append(PopupObject::IPopupObject *object) = 0; - - protected: - typedef void (*PopupCallbackType)(const AnswerCallbackData& answer, - void *data); - virtual void Show(PopupCallbackType callback, - void* data) = 0; - virtual ~IPopup() - { - } - - private: - friend class PopupManager; - friend class DPL::SharedPtr; -}; - -} // namespace Popup -} // namespace DPL - -#endif //WRT_SRC_POPUP_POPUP_H_ diff --git a/modules/popup/include/dpl/popup/popup_controller.h b/modules/popup/include/dpl/popup/popup_controller.h deleted file mode 100644 index 3550b3a..0000000 --- a/modules/popup/include/dpl/popup/popup_controller.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file popup_controller.h - * @author Lukasz Wrzosek (l.wrzosek@samsung.com) - * @version 1.0 - * @bref Header file for popup controller - */ - -/** - * To display a popup from a given class: - * - **class ABC - **{ - * void AskUser() - * { - * } - * - * void DoSomeLogicWithAnswer() - * { - * } - **}; - * - * ... update the class to something simmilar: - * - **class ABC : Popup::PopupControllerUser - **{ - * void AskUser() { - * using namespace Popup; - * CtrlPopupPtr popup = - * PopupControllerSingletion::Instance().CreatePopup(); - * popup->SetTitle("Title"); - * popup->SetContent("Content"); - * popup->AddButton("name1", 1); - * popup->AddButton("name2", 2); - * ListenForAnswer(popup); - * ShowPopupEvent event(popup, - * MakeAnswerCallback(this, - * &ABC::DoSomeLogicWithAnswer)); - * CONTROLLER_POST_EVENT(PopupController, event); - * } - * - * void DoSomeLogicWithAnswer(Popup::LabelId answer) { - * if (answer == 1) - * ;//name1 pressed - * else if (answer == 2) - * ;//name2 pressed - * } - **}; - **/ - -#ifndef WRT_SRC_POPUP_CONTROLLER_POPUP_CONTROLLER_H_ -#define WRT_SRC_POPUP_CONTROLLER_POPUP_CONTROLLER_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace DPL { -namespace Popup { -typedef int LabelId; - -struct PopupAnswerCallback -{ - typedef void (PopupAnswerCallback::*MemberPtr)(); - - void* callee; - MemberPtr member; - void (*callTranslator)(PopupAnswerCallback* callData, - const AnswerCallbackData& answer); - - void Call(const AnswerCallbackData& answer) - { - callTranslator(this, answer); - } -}; - -class PopupController; -class CtrlPopup; - -typedef DPL::SharedPtr CtrlPopupPtr; - -DECLARE_GENERIC_EVENT_3(PopupAnswerEvent, - CtrlPopupPtr, - PopupAnswerCallback, - AnswerCallbackData) -DECLARE_GENERIC_EVENT_3(ShowPopupEvent, - CtrlPopupPtr, - PopupAnswerCallback, - DPL::Event::LoopHandle) - -class CtrlPopup : public DPL::Event::EventSupport, - protected DPL::EnableSharedFromThis -{ - public: - void SetTitle(const std::string &title); - void Append(PopupObject::IPopupObject *object); - - private: - friend class PopupController; - friend class DPL::SharedPtr; - - explicit CtrlPopup(IPopupPtr popup); - ~CtrlPopup(); - void EmitAnswer(const AnswerCallbackData& answer); - - IPopupPtr m_popup; - PopupAnswerCallback m_callback; - DPL::Event::LoopHandle m_loopHandle; -}; - -class PopupController : - public DPL::Event::Controller::Type> -{ - public: - CtrlPopupPtr CreatePopup() const; - - void setExternalCanvas(void* canvas) - { - m_canvas = canvas; - } - void* getExternalCanvas() const - { - return m_canvas; - } - void* m_canvas; - - protected: - virtual void OnEventReceived(const ShowPopupEvent& event); - PopupController(); - - private: - static void StaticOnAnswerReceived(const AnswerCallbackData& answer, - CtrlPopupPtr* popup); -}; - -class PopupControllerUser : DPL::Event::EventListener -{ - template - struct PopupAnswerCallbackCreator - { - typedef void (Type::*MemberPtr)(const AnswerCallbackData& answer); - union Caster - { - MemberPtr specific; - PopupAnswerCallback::MemberPtr generic; - }; - - static PopupAnswerCallback Create(Type* callee, - MemberPtr callback) - { - PopupAnswerCallback callData; - - callData.callee = callee; - - Caster caster; - caster.specific = callback; - callData.member = caster.generic; - - callData.callTranslator = - &PopupAnswerCallbackCreator::MemberCallbackTranslator; - - return callData; - } - - static void MemberCallbackTranslator(PopupAnswerCallback* callData, - const AnswerCallbackData& answer) - { - Type* typedThis = static_cast(callData->callee); - Caster caster; - caster.generic = callData->member; - MemberPtr typedCallback = caster.specific; - (typedThis->*typedCallback)(answer); - } - }; - - protected: - virtual void OnEventReceived(const PopupAnswerEvent& event); - void ListenForAnswer(CtrlPopupPtr popup); - - template - PopupAnswerCallback MakeAnswerCallback(Type* This, - void (Type::*callback) - (const AnswerCallbackData &)) - { - return PopupAnswerCallbackCreator::Create(This, callback); - } -}; - -typedef DPL::Singleton PopupControllerSingleton; - -} //namespace Popup -} //namespace DPL - -#endif //WRT_SRC_POPUP_CONTROLLER_POPUP_CONTROLLER_H_ diff --git a/modules/popup/include/dpl/popup/popup_manager.h b/modules/popup/include/dpl/popup/popup_manager.h deleted file mode 100644 index 512ddd6..0000000 --- a/modules/popup/include/dpl/popup/popup_manager.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file popup_manager.h - * @author Lukasz Wrzosek (l.wrzosek@samsung.com) - * @version 1.0 - * @brief This is popup_manager declaration file - */ - -#ifndef WRT_SRC_POPUP_POPUP_MANAGER_H_ -#define WRT_SRC_POPUP_POPUP_MANAGER_H_ - -#include -#include -#include -#include -#include -#include -#include - -namespace DPL { -namespace Popup { - -class PopupManager : DPL::Noncopyable -{ - template - struct TemplatedPopupCallback - { - typedef void (*Type)(const AnswerCallbackData& answer, ArgType* data); - }; - - public: - PopupManager() : m_initialized(false) {} - ~PopupManager() - { - Assert(!m_initialized); - } - void Initialize (PopupRendererPtr creator); - void Deinitialize(); - void SetPopupRenderer (PopupRendererPtr creator); - IPopupPtr CreatePopup(); - - template - void RunAsyncWithArgType(IPopupPtr popup, - typename TemplatedPopupCallback::Type callback, - ArgType* argument) - { - Assert(callback); - WrapCbAndArg* wrapped = - new WrapCbAndArg(callback, argument); - popup->Show(&CallbackArgTypeTranslator, wrapped); - } - - void Show(IPopupPtr popup, - IPopup::PopupCallbackType callback, - void* userdata) - { - popup->Show(callback, userdata); - } - - void setExternalCanvas(void* externalCanvas) - { - Assert(m_initialized && "Manger should be initialized"); - m_popupRenderer->setExternalCanvas(externalCanvas); - } - - private: - template - struct WrapCbAndArg - { - WrapCbAndArg(typename TemplatedPopupCallback::Type cb, - ArgType* arg) : - callback(cb), - argument(arg) - { - } - - typename TemplatedPopupCallback::Type callback; - ArgType* argument; - }; - - template - static void CallbackArgTypeTranslator(const AnswerCallbackData & answer, - void* data) - { - WrapCbAndArg* wrapped = - static_cast< WrapCbAndArg* >(data); - wrapped->callback(answer, wrapped->argument); - delete wrapped; - } - - bool m_initialized; - PopupRendererPtr m_popupRenderer; -}; - -typedef DPL::Singleton PopupManagerSingleton; - -} // namespace Popup -} // namespace DPL - -#endif //WRT_SRC_POPUP_POPUP_MANAGER_H_ diff --git a/modules/popup/include/dpl/popup/popup_object.h b/modules/popup/include/dpl/popup/popup_object.h deleted file mode 100644 index 5eddc49..0000000 --- a/modules/popup/include/dpl/popup/popup_object.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file popup_object.h - * @author Justyna Mejzner (j.mejzner@samsung.com) - * @version 1.0 - * @brief This is declaration file of PopupObject - */ - -#ifndef WRT_SRC_POPUP_POPUPOBJECT_H_ -#define WRT_SRC_POPUP_POPUPOBJECT_H_ - -#include - -#include -#include - -namespace DPL { -namespace Popup { - -namespace PopupObject { -class IPopupObject; -class PopupObjectBase; -class Button; -class Label; -class Check; - -typedef std::list PopupObjects; - -enum PopupType -{ - BUTTON, - LABEL, - CHECK -}; - -class IPopupObject -{ - public: - virtual Button* asButton() = 0; - virtual Label* asLabel() = 0; - virtual Check* asCheck() = 0; - virtual PopupType getType() const = 0; - virtual ~IPopupObject() - { - } -}; - -class PopupObjectBase : public IPopupObject -{ - public: - virtual Button* asButton() - { - Assert("wrong type"); - return NULL; - } - virtual Label* asLabel() - { - Assert("wrong type"); - return NULL; - } - virtual Check* asCheck() - { - Assert("wrong type"); - return NULL; - } - - PopupType getType() const - { - return m_type; - } - - protected: - PopupObjectBase(PopupType type) : m_type(type) - { - } - - PopupType m_type; -}; - -class Button : public PopupObjectBase -{ - public: - Button(const std::string& label, - int labelId) : - PopupObjectBase(BUTTON), - m_label(label), - m_labelId(labelId) - { - } - - Button* asButton() - { - return this; - } - - const std::string& getLabel() const - { - return m_label; - } - - int getLabelId() const - { - return m_labelId; - } - - private: - std::string m_label; - int m_labelId; -}; - -class Label : public PopupObjectBase -{ - public: - Label(const std::string &label) : - PopupObjectBase(LABEL), - m_label(label) - { - } - - Label* asLabel() - { - return this; - } - - const std::string& getLabel() const - { - return m_label; - } - - private: - std::string m_label; -}; - -class Check : public PopupObjectBase -{ - public: - Check(const std::string &label) : - PopupObjectBase(CHECK), - m_checkLabel(label) - { - } - - Check* asCheck() - { - return this; - } - - const std::string& getCheckLabel() const - { - return m_checkLabel; - } - - private: - std::string m_checkLabel; -}; -} /*PopupObject*/ - -}//namespace Popup -}//namespace DPL - -#endif //WRT_SRC_POPUP_POPUPOBJECT_H_ diff --git a/modules/popup/include/dpl/popup/popup_renderer.h b/modules/popup/include/dpl/popup/popup_renderer.h deleted file mode 100644 index 593c231..0000000 --- a/modules/popup/include/dpl/popup/popup_renderer.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file popup_renderer.h - * @author Lukasz Wrzosek (l.wrzosek@samsung.com) - * @version 1.0 - * @brief This is declaration file of PopupRenderer - */ - -#ifndef WRT_SRC_POPUP_POPUP_RENDERER_H_ -#define WRT_SRC_POPUP_POPUP_RENDERER_H_ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -namespace DPL { -namespace Popup { - -class PopupRenderer : public DPL::EnableSharedFromThis -{ - public: - PopupRenderer(); - ~PopupRenderer(); - void Initialize(); - void Deinitialize(); - IPopupPtr CreatePopup(); - virtual void setExternalCanvas(void* externalCanvas); - protected: - class Popup; - typedef DPL::SharedPtr PopupPtr; - - class Popup : public IPopup - { - public: - typedef std::map ButtonMap; - virtual void SetTitle(const std::string &title) - { - LogDebug(title); - Assert(m_title.empty()); - m_title = title; - } - - virtual void Append(PopupObject::IPopupObject *object) - { - m_popupObjectList.push_back(object); - } - - virtual void Show(IPopup::PopupCallbackType callback, - void* data) - { - Assert(callback); - m_data = data; - m_callback = callback; - m_renderer->Render(DPL::StaticPointerCast(SharedFromThis())); - } - - const std::string& GetTitle() const - { - return m_title; - } - - PopupObject::PopupObjects& GetPopupObjects() - { - return m_popupObjectList; - } - - virtual ~Popup() - { - FOREACH(it, m_popupObjectList) { - delete *it; - } - } - - private: - friend class PopupRenderer; - friend class DPL::SharedPtr; - friend class PopupObjectTheme; - - Popup(DPL::SharedPtr renderer) : m_renderer(renderer) - { - } - - void ForwardAnswer(const AnswerCallbackData & answer) const - { - m_callback(answer, m_data); - } - - std::string m_title; - void* m_data; - IPopup::PopupCallbackType m_callback; - PopupObject::PopupObjects m_popupObjectList; - DPL::SharedPtr m_renderer; - }; - - private: - void Render (PopupPtr popup); - - class Impl; - Impl* m_impl; -}; - -typedef DPL::SharedPtr PopupRendererPtr; - -} // namespace Popup -} // namespace DPL - -#endif //WRT_SRC_POPUP_POPUP_RENDERER_H_ diff --git a/modules/popup/src/evas_object.cpp b/modules/popup/src/evas_object.cpp deleted file mode 100644 index aa41500..0000000 --- a/modules/popup/src/evas_object.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file evas_object.cpp - * @author Lukasz Wrzosek (l.wrzosel@samsung.com) - * @version 1.0 - * @brief This file is the implementation for Evas_Object wrapper from Efl. - */ - -#include -#include - -namespace DPL { -namespace Popup { - -Evas_Object* EvasObject::IConnection::GetEvasObject() -{ - return m_object->GetObject(); -} - -void EvasObject::IConnection::Disconnect() -{ - m_object->DisconnectCallback(this); -} - -EvasObject::IConnection::IConnection(EvasObject::EvasObjectShared* object) : - m_object(object) -{ -} - -void EvasObject::IConnection::SmartCallbackWrapper(void* data, - Evas_Object* /*object*/, - void* event_info) -{ - Assert(data); - IConnection* Calle = static_cast(data); - Calle->Call(event_info); -} - -void EvasObject::IConnection::EvasCallbackWrapper(void* data, - Evas* /*evas*/, - Evas_Object* /*object*/, - void* event_info) -{ - Assert(data); - IConnection* Calle = static_cast(data); - Calle->Call(event_info); -} - -Evas_Object* EvasObject::EvasObjectShared::GetObject() -{ - return m_object; -} - -EvasObject::EvasObjectShared::SmartConnectionBase::SmartConnectionBase( - const std::string& name, - EvasObject::EvasObjectShared* object) : - IConnection(object), - m_callbackName(name) -{ -} - -void EvasObject::EvasObjectShared::SmartConnectionBase::ConnectPrv() -{ - evas_object_smart_callback_add(GetEvasObject(), - m_callbackName.c_str(), - &IConnection::SmartCallbackWrapper, this); -} - -void EvasObject::EvasObjectShared::SmartConnectionBase::DisconnectPrv() -{ - evas_object_smart_callback_del(GetEvasObject(), - m_callbackName.c_str(), - &IConnection::SmartCallbackWrapper); -} - -EvasObject::EvasObjectShared::EvasConnectionBase::EvasConnectionBase( - Evas_Callback_Type type, - EvasObject::EvasObjectShared* object) : - IConnection(object), - m_callbackType(type) -{ -} - -void EvasObject::EvasObjectShared::EvasConnectionBase::ConnectPrv() -{ - evas_object_event_callback_add( - GetEvasObject(), m_callbackType, &IConnection::EvasCallbackWrapper, - this); -} - -void EvasObject::EvasObjectShared::EvasConnectionBase::DisconnectPrv() -{ - evas_object_event_callback_del_full( - GetEvasObject(), m_callbackType, &IConnection::EvasCallbackWrapper, - this); -} - -EvasObject::EvasObjectShared::EvasObjectShared() : - m_object(NULL) -{ -} - -EvasObject::EvasObjectShared::EvasObjectShared(Evas_Object* object) : - m_object(object) -{ - Assert(m_object); - evas_object_event_callback_add(m_object, - EVAS_CALLBACK_DEL, - &StaticOnDelEvent, - this); -} - -void EvasObject::EvasObjectShared::SetObject(Evas_Object* object) -{ - Assert(m_object == NULL); - Assert(object != NULL); - m_object = object; - evas_object_event_callback_add(m_object, - EVAS_CALLBACK_DEL, - &StaticOnDelEvent, - this); -} - -EvasObject::EvasObjectShared::~EvasObjectShared() -{ - if (m_object) { - DisconnectAll(); - evas_object_event_callback_del(m_object, - EVAS_CALLBACK_DEL, - &StaticOnDelEvent); - m_object = NULL; - } -} - -bool EvasObject::EvasObjectShared::DisconnectCallback(IConnection* connection) -{ - IConnectionsSet::iterator it = m_connections.find(connection); - if (it != m_connections.end()) { - (*it)->DisconnectPrv(); - delete connection; - m_connections.erase(it); - return true; - } - return false; -} - -void EvasObject::EvasObjectShared::DisconnectAll() -{ - FOREACH(it, m_connections) - { - (*it)->DisconnectPrv(); - delete *it; - } - m_connections.clear(); -} - -void EvasObject::EvasObjectShared::StaticOnDelEvent(void* data, - Evas* /*e*/, - Evas_Object* /*o*/, - void* /*ev*/) -{ - Assert(data); - EvasObjectShared* This = static_cast(data); - if (This->m_object) { - evas_object_event_callback_del(This->m_object, - EVAS_CALLBACK_DEL, - &StaticOnDelEvent); - This->DisconnectAll(); - This->m_object = NULL; - } -} - -EvasObject::EvasObject() : - m_object(new EvasObjectShared()) -{ -} - -EvasObject::EvasObject(Evas_Object* object) : - m_object(new EvasObjectShared(object)) -{ -} - -EvasObject::EvasObject(const EvasObject& other) : - m_object(other.m_object) -{ -} - -//this destructor must be here to let pimpl with shared_ptr work without warning -EvasObject::~EvasObject() -{ -} - -EvasObject& EvasObject::operator=(const EvasObject& other) -{ - Assert(m_object); - m_object = other.m_object; - return *this; -} - -EvasObject* EvasObject::operator=(Evas_Object* object) -{ - Assert(m_object); - m_object->SetObject(object); - return this; -} - -bool EvasObject::DisconnectCallback(IConnection* connection) -{ - Assert(m_object); - return m_object->DisconnectCallback(connection); -} - -void EvasObject::DisconnectAll() -{ - Assert(m_object); - m_object->DisconnectAll(); -} - -EvasObject::operator Evas_Object *() -{ - Assert(m_object); - return m_object->GetObject(); -} - -} // namespace DPL -} // namespace Popup diff --git a/modules/popup/src/popup_controller.cpp b/modules/popup/src/popup_controller.cpp deleted file mode 100644 index e8163be..0000000 --- a/modules/popup/src/popup_controller.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file popup_controller.cpp - * @author Lukasz Wrzosek (l.wrzosek@samsung.com) - * @version 1.0 - * @bref Implementation file for popup controller - */ - -#include - -#include -#include -#include -IMPLEMENT_SINGLETON(DPL::Popup::PopupController) - -namespace DPL { -namespace Popup { - -void CtrlPopup::SetTitle(const std::string &title) -{ - Assert(m_popup); - m_popup->SetTitle(title); -} - -void CtrlPopup::Append(PopupObject::IPopupObject *object) -{ - Assert(m_popup); - m_popup->Append(object); -} - -CtrlPopup::CtrlPopup(IPopupPtr popup) : - m_popup(popup), - m_callback() -{ - Assert(m_popup); -} - -CtrlPopup::~CtrlPopup() -{ -} - -void CtrlPopup::EmitAnswer(const AnswerCallbackData & answer) -{ - AnswerCallbackData l_answer = answer; - l_answer.loopHandle = m_loopHandle; - PopupAnswerEvent event(SharedFromThis(), m_callback, l_answer); - DPL::Event::EventSupport::EmitEvent(event); -} - -PopupController::PopupController() : m_canvas(NULL) -{ -} - -CtrlPopupPtr PopupController::CreatePopup() const -{ - return CtrlPopupPtr( - new CtrlPopup(PopupManagerSingleton::Instance().CreatePopup())); -} - -void PopupController::OnEventReceived(const ShowPopupEvent& event) -{ - CtrlPopupPtr popup = event.GetArg0(); - popup->m_callback = event.GetArg1(); - popup->m_loopHandle = event.GetArg2(); - - //pass canvas from controller to manager - //canvas is not passed earlier because value wasn't set properly - PopupManagerSingleton::Instance().setExternalCanvas(getExternalCanvas()); - - PopupManagerSingleton::Instance().RunAsyncWithArgType( - popup->m_popup, - &PopupController::StaticOnAnswerReceived, - new CtrlPopupPtr(popup)); -} - -void PopupController::StaticOnAnswerReceived(const AnswerCallbackData & answer, - CtrlPopupPtr* popup) -{ - Assert(popup != NULL); - (*popup)->EmitAnswer(answer); - delete popup; // Just SharedPtr is destroyed, not the popup itself -} - -void PopupControllerUser::OnEventReceived(const PopupAnswerEvent& event) -{ - //Here we are in a proper context to call the callback - PopupAnswerCallback answerCall = event.GetArg1(); - AnswerCallbackData answer = event.GetArg2(); - answerCall.Call(answer); - event.GetArg0()->DPL::Event::EventSupport::RemoveListener(this); -} - -void PopupControllerUser::ListenForAnswer(CtrlPopupPtr popup) -{ - popup->DPL::Event::EventSupport::AddListener(this); -} -} //namespace Popup -} //namespace DPL diff --git a/modules/popup/src/popup_manager.cpp b/modules/popup/src/popup_manager.cpp deleted file mode 100644 index 6e838f6..0000000 --- a/modules/popup/src/popup_manager.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file popup_manager.cpp - * @author Lukasz Wrzosek (l.wrzosek@samsung.com) - * @version 1.0 - * @brief This is popup_manager implementation file - */ - -#include -#include - -#include -#include -#include -#include - -IMPLEMENT_SINGLETON(DPL::Popup::PopupManager) - -namespace DPL { -namespace Popup { - -void PopupManager::Initialize(PopupRendererPtr renderer) -{ - Assert(!m_initialized); - m_popupRenderer = renderer; - m_popupRenderer->Initialize(); - m_initialized = true; -} - -void PopupManager::Deinitialize() -{ - m_popupRenderer->Deinitialize(); - Assert(m_initialized); - m_popupRenderer.Reset(); - m_initialized = false; -} - -IPopupPtr PopupManager::CreatePopup() -{ - Assert(m_initialized); - return m_popupRenderer->CreatePopup(); -} - -} // namespace Popup -} // namespace DPL diff --git a/modules/popup/src/popup_renderer.cpp b/modules/popup/src/popup_renderer.cpp deleted file mode 100644 index 7a45c77..0000000 --- a/modules/popup/src/popup_renderer.cpp +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file popup_renderer.cpp - * @author Lukasz Wrzosek (l.wrzosek@samsung.com) - * @version 1.0 - * @brief This is efl specific implementation for PopupRenderer - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace DPL { - -namespace { -using namespace Popup; -const char* EDJ_NAME = "/usr/share/edje/ace/generic_popup.edj"; -const char* POPUP_LAYOUT1 = "popup_layout1"; -const char* POPUP_LAYOUT2 = "popup_layout2"; -const char* BUTTON_RESPONSE_CALLBACK_NAME = "response"; -const char* CHANGED_CALLBACK_NAME = "changed"; -const unsigned int MAX_NUMBER_OF_VERTICAL = 2; - -Evas_Object* create_layout_main(Evas_Object* parent, int totalV) -{ - Evas_Object *layout = elm_layout_add(parent); - - if (totalV == 1) { - elm_layout_file_set(layout, EDJ_NAME, POPUP_LAYOUT1); - } else if (totalV == 2) { - elm_layout_file_set(layout, EDJ_NAME, POPUP_LAYOUT2); - } else { - Assert("popup needs define new group in the edc"); - } - - evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - return layout; -} -} //namespace - -namespace Popup { -class PopupRenderer::Impl -{ - public: - Impl() : - m_popupsToRender(), - m_current(), - m_initialized(false) - { - } - - ~Impl() - { - Assert(!m_initialized); - } - - void Initialize() - { - Assert(!m_initialized); - m_initialized = true; - } - - void Deinitialize() - { - Assert(m_initialized); - m_current.Reset(NULL); - while (!m_popupsToRender.empty()) { - m_popupsToRender.pop(); - } - m_initialized = false; - } - - void ButtonCallback(EvasObject::IConnection* /*connection*/, - void* event_info, - void* /*unused*/) - { - LogInfo("ButtonCallback"); - Assert(m_initialized); - AnswerCallbackData answerData; - - answerData.buttonAnswer = int(event_info); - answerData.chackState = m_checkState; - answerData.password = m_password; - m_current->ForwardAnswer(answerData); - m_current.Reset(); - - FOREACH(it, m_createdObjects) - { - if (it->IsValid()) { - evas_object_del(*it); - } - } - m_createdObjects.clear(); - m_checkState = false; - DoRender(); - } - - void CheckCallback(EvasObject::IConnection* connection, - void* /*event_info*/, - void* /* unused */) - { - m_checkState = - elm_check_state_get(connection->GetEvasObject()); - } - - void Render (PopupPtr popup) - { - Assert(m_initialized); - m_popupsToRender.push(popup); - DoRender(); - } - - void DoRender(const PopupObject::Label& object, - EvasObject& parent, - EvasObject& layout, - int themeIndex) - { - EvasObject label(elm_label_add(parent)); - - elm_object_style_set(label, "popup_description/default"); - elm_label_line_wrap_set(label, ELM_WRAP_WORD); - elm_object_text_set(label, object.getLabel().c_str()); - evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(label); - - elm_layout_content_set( - layout, - DPL::lexical_cast(themeIndex).c_str(), - label); - m_createdObjects.push_back(label); - } - - void DoRender(const PopupObject::Check& object, - EvasObject& parent, - EvasObject& layout, - int themeIndex) - { - EvasObject check(elm_check_add(parent)); - - evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0); - elm_object_text_set(check, - object.getCheckLabel().c_str()); - elm_layout_content_set( - layout, - DPL::lexical_cast(themeIndex).c_str(), - check); - - check.ConnectMemberSmartCallback(CHANGED_CALLBACK_NAME, - &Impl::CheckCallback, - this, - static_cast(NULL)); - evas_object_show(check); - m_createdObjects.push_back(check); - } - - void DoRender(const PopupObject::Button& object, - EvasObject &parent) - { - elm_popup_buttons_add(parent, - 1, - object.getLabel().c_str(), - object.getLabelId(), - NULL); - parent.ConnectMemberSmartCallback( - BUTTON_RESPONSE_CALLBACK_NAME, - &Impl::ButtonCallback, - this, - static_cast(NULL)); - } - - void DoRender(const PopupObject::Button& object1, - const PopupObject::Button& object2, - EvasObject &parent) - { - elm_popup_buttons_add(parent, - 2, - object1.getLabel().c_str(), - object1.getLabelId(), - object2.getLabel().c_str(), - object2.getLabelId(), - NULL); - parent.ConnectMemberSmartCallback( - BUTTON_RESPONSE_CALLBACK_NAME, - &Impl::ButtonCallback, - this, - static_cast(NULL)); - } - - void DoRender(const PopupObject::Button& object1, - const PopupObject::Button& object2, - const PopupObject::Button& object3, - EvasObject &parent) - { - elm_popup_buttons_add(parent, - 3, - object1.getLabel().c_str(), - object1.getLabelId(), - object2.getLabel().c_str(), - object2.getLabelId(), - object3.getLabel().c_str(), - object3.getLabelId(), - NULL); - parent.ConnectMemberSmartCallback( - BUTTON_RESPONSE_CALLBACK_NAME, - &Impl::ButtonCallback, - this, - static_cast(NULL)); - } - - EvasObject getBaseObject() - { - if (getExternalCanvas() == NULL) { - LogInfo("Create old style popup"); - EvasObject win(elm_win_add(NULL, "Popup", ELM_WIN_DIALOG_BASIC)); - elm_win_borderless_set(win, EINA_TRUE); - elm_win_alpha_set(win, EINA_TRUE); - elm_win_raise(win); - { - int w, h, x, y; - ecore_x_window_geometry_get(ecore_x_window_root_first_get(), - &x, - &y, - &w, - &h); - evas_object_resize(win, w, h); - evas_object_move(win, x, y); - } - m_createdObjects.push_back(win); - evas_object_show(win); - return win; - } else { - LogInfo("Create new style popup"); - EvasObject win(getExternalCanvas()); - evas_object_show(win); - return win; - } - } - - void DoRender() - { - if (!m_current && !m_popupsToRender.empty()) { - m_current = m_popupsToRender.front(); - m_popupsToRender.pop(); - - m_themeIndexV = 0; - - // preprocessing - std::vector countPopupObjects = {0 /* PopupObject::BUTTON */, - 0 /* PopupObject::LABEL */, - 0 /* PopupObject::CHECK */}; - FOREACH(it, m_current->GetPopupObjects()) { - Assert((*it)->getType() < countPopupObjects.size() && - "Wrong PopupObject assigned"); - countPopupObjects[(*it)->getType()]++; - } - int needsIndexV = countPopupObjects[PopupObject::LABEL] + - countPopupObjects[PopupObject::CHECK]; - - EvasObject win = getBaseObject(); - EvasObject main(elm_popup_add(win)); - - evas_object_size_hint_weight_set(main, - EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - elm_popup_title_label_set(main, - m_current->GetTitle().c_str()); - - m_createdObjects.push_back(main); - std::vector buttonObjectList; - EvasObject layout(create_layout_main(main, needsIndexV)); - m_createdObjects.push_back(layout); - - FOREACH(it, m_current->GetPopupObjects()) { - switch ((*it)->getType()) { - case PopupObject::BUTTON: - buttonObjectList.push_back(*(*it)->asButton()); - break; - case PopupObject::LABEL: - DoRender(*(*it)->asLabel(), - main, - layout, - m_themeIndexV++); - break; - case PopupObject::CHECK: - DoRender(*(*it)->asCheck(), - main, - layout, - m_themeIndexV++); - break; - default: - Assert("incorrect type"); - } - Assert(m_themeIndexV <= MAX_NUMBER_OF_VERTICAL); - } - elm_popup_content_set(main, - layout); - - // show buution - switch(buttonObjectList.size()) { - case 0: - LogInfo("no button"); - break; - case 1: - DoRender(buttonObjectList.at(0), - main); - break; - case 2: - DoRender(buttonObjectList.at(0), - buttonObjectList.at(1), - main); - break; - case 3: - DoRender(buttonObjectList.at(0), - buttonObjectList.at(1), - buttonObjectList.at(2), - main); - break; - default: - Assert("incorrect button number"); - break; - } - - evas_object_show(main); - } - } - - void setExternalCanvas(void* externalCanvas) - { - m_externalCanvas = static_cast(externalCanvas); - } - - Evas_Object* getExternalCanvas() const - { - return m_externalCanvas; - } - - std::queue m_popupsToRender; - std::list m_createdObjects; - PopupPtr m_current; - bool m_initialized; - bool m_checkState; - DPL::Optional m_password; - unsigned int m_themeIndexV; - - private: - Evas_Object* m_externalCanvas; -}; - -PopupRenderer::PopupRenderer() -{ - m_impl = new PopupRenderer::Impl(); -} - -PopupRenderer::~PopupRenderer() -{ - delete m_impl; -} - -void PopupRenderer::Initialize() -{ - Assert(m_impl); - m_impl->Initialize(); -} - -void PopupRenderer::Deinitialize() -{ - Assert(m_impl); - m_impl->Deinitialize(); -} - -IPopupPtr PopupRenderer::CreatePopup() -{ - return DPL::StaticPointerCast(IPopupPtr - (new Popup(SharedFromThis()))); -} - -void PopupRenderer::Render(PopupPtr popup) -{ - m_impl->Render(popup); -} - -void PopupRenderer::setExternalCanvas(void* externalCanvas) -{ - m_impl->setExternalCanvas(externalCanvas); -} - -} // namespace Popup -} // namespace DPL diff --git a/modules/utils/include/file_utils.h b/modules/utils/include/file_utils.h deleted file mode 100644 index 77e4aa3..0000000 --- a/modules/utils/include/file_utils.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file file_utils.h - * @author Bartosz Janiak (b.janiak@samsung.com) - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @version 1.0 - */ - -#ifndef FILEUTILS_H -#define FILEUTILS_H - -#include -#include - -#include -#include - -namespace FileUtils { -DECLARE_EXCEPTION_TYPE(DPL::Exception, RemoveDirectoryException) - -bool FileExists(const DPL::String& absolutePath); - -/** - * Creates specified path recursively. - * @param path Path to create (e.g. /tmp/dir1/dir2). - * @param mode Mode for the non-existing parts of the path (e.g. 0755). - * @throw DPL::CommonException::::InternalError If sth bad happens. - */ -void MakePath(const std::string& path, - mode_t mode); - -/** - * Removes specified directory recursively. - * @param path Full path to directory to remove. - * @throw FileUtils::DirectoryRemoveException If an error occured. - */ -void RemoveDir(const std::string& path); -}; - -#endif diff --git a/modules/utils/include/folder_size.h b/modules/utils/include/folder_size.h deleted file mode 100644 index db51de9..0000000 --- a/modules/utils/include/folder_size.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * - * @file folder_size.h - * @author Jaroslaw Osmanski (j.osmanski@samsung.com) - * @version 1.0 - * @brief Declaration for function calculating directory size - */ - -#ifndef SRC_COMMON_FOLDER_SIZE_H_ -#define SRC_COMMON_FOLDER_SIZE_H_ - -#include - -#include - -namespace Utils { - -size_t getFolderSize(const std::string& path); - -DPL::String fromFileSizeString(size_t fileSize); - -} - -#endif /* SRC_COMMON_FOLDER_SIZE_H_ */ diff --git a/modules/utils/include/mime_type_utils.h b/modules/utils/include/mime_type_utils.h deleted file mode 100644 index b536c20..0000000 --- a/modules/utils/include/mime_type_utils.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef MIME_TYPE_UTILS_H -#define MIME_TYPE_UTILS_H - -#include -#include - -class MimeTypeUtils -{ - public: - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, InvalidFileName) - }; - - private: - //TODO use hash_map if possible - static const std::set& getMimeTypesSupportedForIcon(); - static const std::set& getMimeTypesSupportedForStartFile(); - - typedef std::map FileIdentificationMap; - - static DPL::String getFileNameFromPath(const DPL::String& path); - static const FileIdentificationMap& getFileIdentificationMap(); - static DPL::String stripMimeParameters(const DPL::String& mimeType); - - public: - typedef std::map MimeAttributes; - static bool isValidIcon(const DPL::String& path); - static bool isValidStartFile(const DPL::String& path, - const DPL::OptionalString& providedMimeType); - static bool isMimeTypeSupportedForStartFile(const DPL::String& mimeType); - static bool isMimeTypeSupportedForIcon(const DPL::String& mimeType); - static MimeAttributes getMimeAttributes(const DPL::String& mimeType); - ///implements 9.1.10. (Rule for Identifying the Media Type of a File) - ///from W3C packaging specification - static DPL::String identifyFileMimeType(const DPL::String& path); -}; - -#endif /* MIME_TYPE_UTILS_H */ - diff --git a/modules/utils/include/warp_iri.h b/modules/utils/include/warp_iri.h deleted file mode 100644 index 901fd15..0000000 --- a/modules/utils/include/warp_iri.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _WARPIRI_H_ -#define _WARPIRI_H_ - -#include - -#include -#include - -class WarpIRI -{ - static const unsigned int UNKNOWN_PORT = 0; - public: - WarpIRI(); - - void set(const char *iri, - bool domain); - void set(const DPL::String &iristring, - bool domain); - - /* It also checks port and schema */ - bool isSubDomain(const WarpIRI &second) const; - bool isAccessDefinition() const; - // KW bool isIRIValid() const; - bool getSubDomain() const; - - /* This is debug function */ - // KW void print() const { - // KW LogInfo("P:" << m_port << " S:" << m_schema); - // KW for (size_t i = 0; i < m_host.size(); ++i) - // KW LogInfo(" " << m_host[i]); - // KW } - - static bool isIRISchemaIgnored(const char *iri); - - bool operator ==(const WarpIRI &other) const - { - return m_domain == other.m_domain && - m_host == other.m_host && - m_schema == other.m_schema && - m_port == other.m_port && - m_isAccessDefinition == other.m_isAccessDefinition && - m_isIRIValid == other.m_isIRIValid; - } - - private: - unsigned int getPort(const DPL::String &schema) const; - - bool m_domain; - std::vector m_host; - DPL::String m_schema; - unsigned int m_port; - bool m_isAccessDefinition; - bool m_isIRIValid; -}; - -#endif // _WarpIRI_H_ diff --git a/modules/utils/include/widget_version.h b/modules/utils/include/widget_version.h deleted file mode 100644 index 5f40e72..0000000 --- a/modules/utils/include/widget_version.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file widget_version.h - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief Header file for widget version - */ -#ifndef WIDGET_VERSION_H -#define WIDGET_VERSION_H - -#include -#include -#include - -/* - * Note: This class also support non-WAC compliant version numbers - * - * WAC Waikiki Beta Release Core Specification: Widget Runtime - * 10 Dec 2010 - * - * WL-3370 The WRT MUST process widget packages as an update when received under the following conditions: - * - * - the Widget Id matches the Widget Id of an installed widget - * - the Widget version number is greater (as a compared string) than that of the installed widget, or no version - * information was provided for the installed widget - * - * To ensure that a string comparison of widget versions can reliably determine which version is an updated widget, - * WAC will mandate a specific version string format for WAC widgets. All widgets coming through the WAC channel - * will be required to have version strings in this format. Side-loaded widgets may have any format and, in this - * case, there is no requirement that the WRT support version detection for update of these widgets. - * - * The widget version format is the rec-version-tag grammar as described in [Widget Packaging]: - * - * rec-version-tag = 1*DIGIT "." 1*DIGIT [ "." 1*DIGIT] *[ 1*ALPHA / SP / 1*DIGIT ] - * - * Examples of rec-version-tag: - * - * 1.0 - * 1.10.1 beta1 - * 1.02.12 RC1 - * - * WL-3371 The WRT MUST use the following widget version comparison algorithm to compare WAC widget version strings: - * - * - prepare the version strings for comparison: - * - all leading zeros are discarded - * - the optional *[ 1*ALPHA / SP / 1*DIGIT ] part, if present, is discarded - * - the resulting numbers are then in the format major.minor[.micro] - * - Version A = Amajor.Aminor[.Amicro] is equal to Version B = Bmajor.Bminor[.Bmicro] if and only if: - * - Amajor Bmajor - * - Aminor Bminor - * - both Amicro and Bmicro are present and Amicro == Bmicro; or both Amicro and Bmicro are absent. - * - Version A = Amajor.Aminor[.Amicro] is greater than Version B = Bmajor.Bminor[.Bmicro] if and only if: - * - Amajor > Bmajor; or - * - Amajor Bmajor && Aminor > Bminor; or - * - Amajor Bmajor && Aminor == Bminor && both Amicro and Bmicro are present and Amicro > Bmicro; or Bmicro is absent. - */ -class WidgetVersion -{ - private: - bool m_isWac; - DPL::String m_raw; - - DPL::String m_major; - DPL::String m_minor; - DPL::Optional m_micro; - DPL::Optional m_optional; - - void WacCertify(const DPL::String &major, - const DPL::String &minor, - const DPL::Optional µ, - const DPL::Optional &optional); - - public: - explicit WidgetVersion(const DPL::String &str = DPL::String()); - WidgetVersion(const DPL::String &major, - const DPL::String &minor, - const DPL::Optional µ, - const DPL::Optional &optional); - - bool IsWac() const; - const DPL::String &Raw() const; - - const DPL::String &Major() const; - const DPL::String &Minor() const; - const DPL::Optional &Micro() const; - const DPL::Optional &Optional() const; -}; - -bool operator<(const WidgetVersion &left, - const WidgetVersion &right); -bool operator<=(const WidgetVersion &left, - const WidgetVersion &right); -bool operator>(const WidgetVersion &left, - const WidgetVersion &right); -bool operator>=(const WidgetVersion &left, - const WidgetVersion &right); -bool operator==(const WidgetVersion &left, - const WidgetVersion &right); -bool operator!=(const WidgetVersion &left, - const WidgetVersion &right); -std::ostream & operator<<(std::ostream& stream, - const WidgetVersion& version); - -#endif // WIDGET_VERSION_H diff --git a/modules/utils/include/wrt_global_settings.h b/modules/utils/include/wrt_global_settings.h deleted file mode 100644 index 9a51cd1..0000000 --- a/modules/utils/include/wrt_global_settings.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file wrt_global_settings.h - * @version 0.6 - * @author Pawel Sikorski(p.sikorski@samsung.com) - * @brief Header file for global predefined wrt setting - */ - -#ifndef WRT_COMMON_GLOBAL_SETTINGS_H_ -#define WRT_COMMON_GLOBAL_SETTINGS_H_ - -namespace GlobalSettings { -//TODO description -bool GetPopupsEnabledFlag(); -} - -#endif /* WRT_COMMON_GLOBAL_SETTINGS_H_ */ diff --git a/modules/utils/include/wrt_global_settings_internal.h b/modules/utils/include/wrt_global_settings_internal.h deleted file mode 100644 index ac57956..0000000 --- a/modules/utils/include/wrt_global_settings_internal.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file wrt_global_settings_internal.h - * @version 0.6 - * @author Lukasz Wrzosek (l.wrzosek@samsung.com) - * @brief Header file for global predefined wrt setting - internal interface - */ - -#ifndef WRT_SRC_COMMON_WRT_GLOBAL_SETTINGS_INTERNAL_H_ -#define WRT_SRC_COMMON_WRT_GLOBAL_SETTINGS_INTERNAL_H_ - -namespace GlobalSettings { -struct IGlobalSettingsFunctions -{ - bool (*getPopupsEnabledFlag)(); -}; - -void SetPredefinedGlobalSettings(IGlobalSettingsFunctions functions); -} - -#endif //WRT_SRC_COMMON_WRT_GLOBAL_SETTINGS_INTERNAL_H_ diff --git a/modules/utils/include/wrt_utility.h b/modules/utils/include/wrt_utility.h deleted file mode 100644 index 30f8114..0000000 --- a/modules/utils/include/wrt_utility.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file wrt_utility.h - * @version 0.6 - * @author Wei Dong(d.wei@samsung.com) - * @author Ma Quan(jason.ma@samsung.com) - * @brief Header file of widget manager common functions - */ - -#ifndef _WRT_UTILITY_H_ -#define _WRT_UTILITY_H_ - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -#ifndef MAX_WIDGET_PATH_LENGTH -#define MAX_WIDGET_PATH_LENGTH 1024 -#endif - -/** - * File options - */ -enum -{ - WRT_FILEUTILS_PRESERVE_STATUS = 1, - WRT_FILEUTILS_PRESERVE_SYMLINKS = 2, - WRT_FILEUTILS_RECUR = 4, - WRT_FILEUTILS_FORCE = 8, - WRT_FILEUTILS_INTERACTIVE = 16 -}; - -/** - * Combine the parentPath and fileName into a new absolute file name. - * - * @param[out] absolutePath - * @param[in] parentPath - * @param[in] fileName - * - * @return if success, return true; or return false. - */ -bool _WrtUtilSetAbsolutePath(char* absolutePath, - const char* parentPath, - const char* fileName); - -/** - * Change the string to bool value,no case sensitive, e.x., "true" or "1" to ture; "False" or "0" to false. - * - * @param[in] value - * @param[out] result - * - * @return if success, return true; or return false. - */ -// KW bool _WrtUtilConvertStrToBool(char* value, bool *result); - -/** - * Get the dir path and file name from the full path. e.x., "/opt/lib/filename" as fullPath, "/opt/lib/" as dirName, "filename" as fileName. - * it's necessary to free *dirName or *fileName if either of them is not NULL. - * - * @param[in] fullPath - * @param[out] dirName - * @param[out] fileName - * - * @return - */ -void _WrtUtilGetDirAndFileName(const char* fullPath, - char** dirName, - char** fileName); - -#if 0 -/** - * Change the provided string into lower case, caller should allocate the memory of source and dest. - * - * @param[in] source the source string to be changed - * @param[out] dest the dest string with lower case - * - * return if success, return true, or return false. - */ -bool _WrtUtilStringToLower(const char* source, - char* dest); -#endif - -/** - * Compare two string, no case sensitive. - * - * @param[in] srcStr - * @param[in] destStr - * - * return return true if the two strings are identical, or return false. - */ -// KW bool _WrtUtilStringCmp(const char* srcStr, const char* destStr); - -/** - * This function is used to make a directory. - * it's neccessary to free the returned dir path. - * - * @param[in] path Specified the directory path - * @param[in] mode Operation mode the you want to set - * @param[in] flags WRT_FILEUTILS_RECUR if you want to make parent's directory recusively, - * WRT_FILEUTILS_NONE if not. - * - * @return TRUE on success or FALSE on failure. - */ -bool _WrtMakeDir (const char *path, - long mode, - int flags); - -/** - * This function is used to change to specified directory. - * If the directory does not exist, it will create it directly. - * - * @param[in] path Specified the directory path - * - * @return TRUE on success or FALSE on failure. - */ -bool _WrtUtilChangeDir(const char* path); - -/** - * This function is used to remove a directory from the file system. - * - * @param[in] path Specified the directory path - * - * @return TRUE on success or FALSE on failure. - */ -bool _WrtUtilRemoveDir(const char* path); - -// KW /** -// KW * This function is used to make a temp directory in root directory. -// KW * -// KW * @param[in] root Specified the root directory -// KW * -// KW * @return if fails, return NULL, else return the temp path. -// KW * it's necessary to free the returned memory space. -// KW */ -// KW char* _WrtUtilMakeTempDir(const char* root); - -/** - * This function is used to convert a string to lowercase. - * - * @param[in] str the string need to be converted. - * @param[in] lowerStr the converted string. - * - * @return TRUE on success or FALSE on failure. - */ -bool _WrtUtilStringToLower(const char* str, - char** lowerStr); - -#ifdef __cplusplus -} -#endif - -#endif //_WRT_UTILITY_H_ - diff --git a/modules/utils/src/wrt_global_settings_internal.cpp b/modules/utils/src/wrt_global_settings_internal.cpp deleted file mode 100644 index 7940cd1..0000000 --- a/modules/utils/src/wrt_global_settings_internal.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file wrt_global_settings_internal.cpp - * @version 0.6 - * @author Lukasz Wrzosek (l.wrzosek@samsung.com) - */ - -#include -#include -#include -#include - -namespace GlobalSettings { -static IGlobalSettingsFunctions globalSettingsFunctions; - -// INTERNAL -void SetPredefinedGlobalSettings(IGlobalSettingsFunctions functions) -{ - globalSettingsFunctions = functions; - LogDebug("Global settings are set"); -} - -// PUBLIC -bool GetPopupsEnabledFlag() -{ - Assert(globalSettingsFunctions.getPopupsEnabledFlag && - "Global settings are unset"); - return globalSettingsFunctions.getPopupsEnabledFlag(); -} -} //namespace GlobalSettings diff --git a/modules/vcore/CMakeLists.txt b/modules/vcore/CMakeLists.txt deleted file mode 100644 index 8c492f4..0000000 --- a/modules/vcore/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -#DB vcore -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_BINARY_DIR}/modules/vcore/src/database_checksum_vcore.h - COMMAND ${CMAKE_SOURCE_DIR}/modules/vcore/src/orm/gen_db_md5.sh - ARGS ${CMAKE_BINARY_DIR}/modules/vcore/src/database_checksum_vcore.h - ${CMAKE_SOURCE_DIR}/modules/vcore/src/orm/vcore_db - DEPENDS ${CMAKE_SOURCE_DIR}/modules/vcore/src/orm/vcore_db - ${CMAKE_SOURCE_DIR}/modules/vcore/src/orm/gen_db_md5.sh - COMMENT "Generating VCORE database checksum" - ) - -ADD_CUSTOM_COMMAND( OUTPUT .vcore.db - COMMAND rm -f ${CMAKE_CURRENT_BINARY_DIR}/.vcore.db - COMMAND gcc -Wall -include ${CMAKE_BINARY_DIR}/modules/vcore/src/database_checksum_vcore.h -I${PROJECT_SOURCE_DIR}/modules/db/include/ -I${PROJECT_SOURCE_DIR}/modules/vcore/src/orm -E ${PROJECT_SOURCE_DIR}/modules/vcore/src/orm/vcore_db_sql_generator.h | grep --invert-match "^#" > ${CMAKE_CURRENT_BINARY_DIR}/vcore_db.sql - COMMAND sqlite3 ${CMAKE_CURRENT_BINARY_DIR}/.vcore.db ".read ${CMAKE_CURRENT_BINARY_DIR}/vcore_db.sql" || rm -f ${CMAKE_CURRENT_BINARY_DIR}/.vcore.db - DEPENDS ${CMAKE_BINARY_DIR}/modules/vcore/src/database_checksum_vcore.h ${PROJECT_SOURCE_DIR}/modules/vcore/src/orm/vcore_db_sql_generator.h ${PROJECT_SOURCE_DIR}/modules/vcore/src/orm/vcore_db - ) - -ADD_CUSTOM_COMMAND( OUTPUT .vcore.db-journal - COMMAND touch - ARGS ${CMAKE_CURRENT_BINARY_DIR}/.vcore.db-journal - ) - -ADD_CUSTOM_TARGET(Sqlite3DbVCORE ALL DEPENDS .vcore.db .vcore.db-journal) - -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/vcore_db.sql - DESTINATION share/wrt-engine/ - ) - -ADD_SUBDIRECTORY(src) diff --git a/modules/vcore/src/CMakeLists.txt b/modules/vcore/src/CMakeLists.txt deleted file mode 100644 index 5d56cda..0000000 --- a/modules/vcore/src/CMakeLists.txt +++ /dev/null @@ -1,132 +0,0 @@ -INCLUDE(FindPkgConfig) - -PKG_CHECK_MODULES(VCORE_DEPS - cert-svc - ecore - appcore-efl - libxml-2.0 - libsoup-2.4 - openssl - xmlsec1 - tapi - REQUIRED) - -SET(VCORE_DIR - ${PROJECT_SOURCE_DIR}/modules/vcore - ) - -SET(VCORE_SRC_DIR - ${VCORE_DIR}/src/vcore - ) - -SET(VCORE_SOURCES - ${VCORE_SRC_DIR}/Base64.cpp - ${VCORE_SRC_DIR}/CachedCRL.cpp - ${VCORE_SRC_DIR}/CachedOCSP.cpp - ${VCORE_SRC_DIR}/Certificate.cpp - ${VCORE_SRC_DIR}/CertificateCacheDAO.cpp - ${VCORE_SRC_DIR}/CertificateCollection.cpp - ${VCORE_SRC_DIR}/CertificateConfigReader.cpp - ${VCORE_SRC_DIR}/CertificateLoader.cpp - ${VCORE_SRC_DIR}/CertificateVerifier.cpp - ${VCORE_SRC_DIR}/Config.cpp - ${VCORE_SRC_DIR}/CRL.cpp - ${VCORE_SRC_DIR}/Database.cpp - ${VCORE_SRC_DIR}/DeveloperModeValidator.cpp - ${VCORE_SRC_DIR}/OCSP.cpp - ${VCORE_SRC_DIR}/OCSPCertMgrUtil.cpp - ${VCORE_SRC_DIR}/OCSPUtil.c - ${VCORE_SRC_DIR}/ReferenceValidator.cpp - ${VCORE_SRC_DIR}/RevocationCheckerBase.cpp - ${VCORE_SRC_DIR}/SaxReader.cpp - ${VCORE_SRC_DIR}/SignatureFinder.cpp - ${VCORE_SRC_DIR}/SignatureReader.cpp - ${VCORE_SRC_DIR}/SignatureValidator.cpp - ${VCORE_SRC_DIR}/SoupMessageSendBase.cpp - ${VCORE_SRC_DIR}/SoupMessageSendSync.cpp - ${VCORE_SRC_DIR}/SoupMessageSendAsync.cpp - ${VCORE_SRC_DIR}/VerificationStatus.cpp - ${VCORE_SRC_DIR}/ValidatorFactories.cpp - ${VCORE_SRC_DIR}/VCore.cpp - ${VCORE_SRC_DIR}/XmlsecAdapter.cpp - ) - -SET(VCORE_INCLUDES - ${PROJECT_SOURCE_DIR}/modules/core/include - ${PROJECT_SOURCE_DIR}/modules/log/include - ${PROJECT_SOURCE_DIR}/modules/db/include - ${VCORE_DEPS_INCLUDE_DIRS} - ${VCORE_SRC_DIR} - ${VCORE_DIR}/src - ${VCORE_DIR}/src/orm - ${VCORE_DIR}/src/legacy - ${CMAKE_BINARY_DIR}/modules/vcore/src - ) - -ADD_DEFINITIONS(${VCORE_DEPS_CFLAGS}) -ADD_DEFINITIONS(${VCORE_DEPS_CFLAGS_OTHER}) -ADD_DEFINITIONS("-DSEPARATED_SINGLETON_IMPLEMENTATION") - -INCLUDE_DIRECTORIES(${VCORE_INCLUDES}) - -ADD_LIBRARY(${TARGET_VCORE_LIB} SHARED ${VCORE_SOURCES}) -SET_TARGET_PROPERTIES(${TARGET_VCORE_LIB} PROPERTIES - SOVERSION ${VERSION}) - -ADD_DEPENDENCIES(${TARGET_VCORE_LIB} Sqlite3DbWTF) - -SET_TARGET_PROPERTIES(${TARGET_VCORE_LIB} PROPERTIES - COMPILE_FLAGS -fPIC) - -TARGET_LINK_LIBRARIES(${TARGET_VCORE_LIB} - ${VCORE_DEPS_LIBRARIES} - ${TARGET_DPL_EFL} - ${TARGET_DPL_DB_EFL} - ) - -INSTALL(TARGETS ${TARGET_VCORE_LIB} - DESTINATION lib - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ - ) - -INSTALL(FILES - ${VCORE_SRC_DIR}/Base64.h - ${VCORE_SRC_DIR}/CachedCRL.h - ${VCORE_SRC_DIR}/CachedOCSP.h - ${VCORE_SRC_DIR}/Certificate.h - ${VCORE_SRC_DIR}/CertificateCacheDAO.h - ${VCORE_SRC_DIR}/CertificateCollection.h - ${VCORE_SRC_DIR}/CertificateConfigReader.h - ${VCORE_SRC_DIR}/CertificateLoader.h - ${VCORE_SRC_DIR}/CertificateStorage.h - ${VCORE_SRC_DIR}/CertificateVerifier.h - ${VCORE_SRC_DIR}/CertStoreType.h - ${VCORE_SRC_DIR}/Config.h - ${VCORE_SRC_DIR}/CRL.h - ${VCORE_SRC_DIR}/Database.h - ${VCORE_SRC_DIR}/DeveloperModeValidator.h - ${VCORE_SRC_DIR}/IAbstractResponseCache.h - ${VCORE_SRC_DIR}/OCSP.h - ${VCORE_SRC_DIR}/OCSPCertMgrUtil.h - ${VCORE_SRC_DIR}/ParserSchema.h - ${VCORE_SRC_DIR}/ReferenceValidator.h - ${VCORE_SRC_DIR}/RevocationCheckerBase.h - ${VCORE_SRC_DIR}/SaxReader.h - ${VCORE_SRC_DIR}/scoped_gpointer.h - ${VCORE_SRC_DIR}/SignatureData.h - ${VCORE_SRC_DIR}/SignatureFinder.h - ${VCORE_SRC_DIR}/SignatureReader.h - ${VCORE_SRC_DIR}/SignatureValidator.h - ${VCORE_SRC_DIR}/SoupMessageSendBase.h - ${VCORE_SRC_DIR}/SoupMessageSendSync.h - ${VCORE_SRC_DIR}/SoupMessageSendAsync.h - ${VCORE_SRC_DIR}/SSLContainers.h - ${VCORE_SRC_DIR}/VerificationStatus.h - ${VCORE_SRC_DIR}/ValidatorCommon.h - ${VCORE_SRC_DIR}/ValidatorFactories.h - ${VCORE_SRC_DIR}/VCore.h - ${VCORE_SRC_DIR}/XmlsecAdapter.h - DESTINATION include/dpl-efl/dpl/vcore/vcore - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ - ) - diff --git a/modules/vcore/src/orm/DESCRIPTION b/modules/vcore/src/orm/DESCRIPTION deleted file mode 100644 index 7d25d0d..0000000 --- a/modules/vcore/src/orm/DESCRIPTION +++ /dev/null @@ -1 +0,0 @@ -Scripts required to create vcoredatabase. diff --git a/modules/vcore/src/orm/gen_db_md5.sh b/modules/vcore/src/orm/gen_db_md5.sh deleted file mode 100755 index a81d5f7..0000000 --- a/modules/vcore/src/orm/gen_db_md5.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -CHECKSUM=`cat ${2} ${3} 2>/dev/null | md5sum 2>/dev/null | cut -d\ -f1 2>/dev/null` -echo "#define DB_CHECKSUM DB_VERSION_${CHECKSUM}" > ${1} -echo "#define DB_CHECKSUM_STR \"DB_VERSION_${CHECKSUM}\"" >> ${1} - diff --git a/modules/vcore/src/orm/orm_generator_vcore.h b/modules/vcore/src/orm/orm_generator_vcore.h deleted file mode 100644 index 862bc80..0000000 --- a/modules/vcore/src/orm/orm_generator_vcore.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ORM_GENERATOR_VCORE_H -#define ORM_GENERATOR_VCORE_H - -#define ORM_GENERATOR_DATABASE_NAME vcore_db_definitions -#include -#undef ORM_GENERATOR_DATABASE_NAME - -#endif // ORM_GENERATOR_VCORE_H diff --git a/modules/vcore/src/orm/vcore_db b/modules/vcore/src/orm/vcore_db deleted file mode 100644 index 71080da..0000000 --- a/modules/vcore/src/orm/vcore_db +++ /dev/null @@ -1,20 +0,0 @@ -SQL( - PRAGMA foreign_keys = ON; - BEGIN TRANSACTION; -) -CREATE_TABLE(OCSPResponseStorage) - COLUMN_NOT_NULL(cert_chain, TEXT, primary key) - COLUMN(end_entity_check, INT,) - COLUMN(ocsp_status, INT,) - COLUMN(next_update_time, BIGINT,) -CREATE_TABLE_END() - -CREATE_TABLE(CRLResponseStorage) - COLUMN_NOT_NULL(distribution_point,TEXT, primary key) - COLUMN_NOT_NULL(crl_body, TEXT,) - COLUMN(next_update_time, BIGINT,) -CREATE_TABLE_END() - -SQL( - COMMIT; -) diff --git a/modules/vcore/src/orm/vcore_db_definitions b/modules/vcore/src/orm/vcore_db_definitions deleted file mode 100644 index 61018c4..0000000 --- a/modules/vcore/src/orm/vcore_db_definitions +++ /dev/null @@ -1,6 +0,0 @@ -DATABASE_START(vcore) - -#include "vcore_db" -#include "version_db" - -DATABASE_END() diff --git a/modules/vcore/src/orm/vcore_db_sql_generator.h b/modules/vcore/src/orm/vcore_db_sql_generator.h deleted file mode 100644 index 76f0448..0000000 --- a/modules/vcore/src/orm/vcore_db_sql_generator.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//Do not include this file directly! It is used only for SQL code generation. - -#include - -#include "vcore_db_definitions" diff --git a/modules/vcore/src/orm/version_db b/modules/vcore/src/orm/version_db deleted file mode 100644 index 7e20d8d..0000000 --- a/modules/vcore/src/orm/version_db +++ /dev/null @@ -1,5 +0,0 @@ -SQL( - BEGIN TRANSACTION; - CREATE TABLE DB_CHECKSUM (version INT); - COMMIT; -) diff --git a/modules/vcore/src/vcore/Base64.cpp b/modules/vcore/src/vcore/Base64.cpp deleted file mode 100644 index b772178..0000000 --- a/modules/vcore/src/vcore/Base64.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Base64.h" - -namespace ValidationCore { -Base64Encoder::Base64Encoder() : - m_b64(0), - m_bmem(0), - m_finalized(false) -{ -} - -void Base64Encoder::append(const std::string &data) -{ - if (m_finalized) { - LogWarning("Already finalized."); - ThrowMsg(Exception::AlreadyFinalized, "Already finalized"); - } - - if (!m_b64) { - reset(); - } - BIO_write(m_b64, data.c_str(), data.size()); -} - -void Base64Encoder::finalize() -{ - if (m_finalized) { - LogWarning("Already finalized."); - ThrowMsg(Exception::AlreadyFinalized, "Already finalized."); - } - m_finalized = true; - BIO_flush(m_b64); -} - -std::string Base64Encoder::get() -{ - if (!m_finalized) { - LogWarning("Not finalized"); - ThrowMsg(Exception::NotFinalized, "Not finalized"); - } - BUF_MEM *bptr = 0; - BIO_get_mem_ptr(m_b64, &bptr); - if (bptr == 0) { - LogError("Bio internal error"); - ThrowMsg(Exception::InternalError, "Bio internal error"); - } - - if (bptr->length > 0) { - return std::string(bptr->data, bptr->length - 1); - } - return std::string(); -} - -void Base64Encoder::reset() -{ - m_finalized = false; - BIO_free_all(m_b64); - m_b64 = BIO_new(BIO_f_base64()); - m_bmem = BIO_new(BIO_s_mem()); - if (!m_b64 || !m_bmem) { - LogError("Error during allocation memory in BIO"); - ThrowMsg(Exception::InternalError, - "Error during allocation memory in BIO"); - } - m_b64 = BIO_push(m_b64, m_bmem); -} - -Base64Encoder::~Base64Encoder() -{ - BIO_free_all(m_b64); -} - -Base64Decoder::Base64Decoder() : - m_finalized(false) -{ -} - -void Base64Decoder::append(const std::string &data) -{ - if (m_finalized) { - LogWarning("Already finalized."); - ThrowMsg(Exception::AlreadyFinalized, "Already finalized."); - } - m_input.append(data); -} - -static bool whiteCharacter(char a) -{ - if (a == '\n') { return true; } - return false; -} - -bool Base64Decoder::finalize() -{ - if (m_finalized) { - LogWarning("Already finalized."); - ThrowMsg(Exception::AlreadyFinalized, "Already finalized."); - } - - m_finalized = true; - - m_input.erase(std::remove_if(m_input.begin(), - m_input.end(), - whiteCharacter), - m_input.end()); - - for (size_t i = 0; i tmp(strdup(m_input.c_str())); - m_input.clear(); - - bmem = BIO_new_mem_buf(tmp.Get(), len); - - if (!bmem) { - BIO_free(b64); - LogError("Internal error in BIO"); - ThrowMsg(Exception::InternalError, "Internal error in BIO"); - } - - bmem = BIO_push(b64, bmem); - - if (!bmem) { - BIO_free(b64); - LogError("Internal error in BIO"); - ThrowMsg(Exception::InternalError, "Internal error in BIO"); - } - - int readlen = BIO_read(bmem, buffer.Get(), len); - m_output.clear(); - - bool status = true; - - if (readlen > 0) { - m_output.append(buffer.Get(), readlen); - } else { - status = false; - } - - BIO_free_all(bmem); - return status; -} - -std::string Base64Decoder::get() const -{ - if (!m_finalized) { - LogWarning("Not finalized."); - ThrowMsg(Exception::NotFinalized, "Not finalized"); - } - return m_output; -} - -void Base64Decoder::reset() -{ - m_finalized = false; - m_input.clear(); - m_output.clear(); -} -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/Base64.h b/modules/vcore/src/vcore/Base64.h deleted file mode 100644 index 520662e..0000000 --- a/modules/vcore/src/vcore/Base64.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _BASE64_H_ -#define _BASE64_H_ - -#include -#include -#include - -struct bio_st; -typedef bio_st BIO; - -namespace ValidationCore { -class Base64Encoder : public DPL::Noncopyable -{ - public: - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, InternalError) - DECLARE_EXCEPTION_TYPE(Base, NotFinalized) - DECLARE_EXCEPTION_TYPE(Base, AlreadyFinalized) - }; - Base64Encoder(); - void append(const std::string &data); - void finalize(); - std::string get(); - void reset(); - ~Base64Encoder(); - - private: - BIO *m_b64; - BIO *m_bmem; - bool m_finalized; -}; - -class Base64Decoder : public DPL::Noncopyable -{ - public: - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, InternalError) - DECLARE_EXCEPTION_TYPE(Base, NotFinalized) - DECLARE_EXCEPTION_TYPE(Base, AlreadyFinalized) - }; - Base64Decoder(); - void append(const std::string &data); - - /* - * Function will return false when BIO_read fails - * (for example: when string was not in base64 format). - */ - bool finalize(); - std::string get() const; - void reset(); - ~Base64Decoder() - { - } - - private: - std::string m_input; - std::string m_output; - bool m_finalized; -}; -} // namespace ValidationCore - -#endif diff --git a/modules/vcore/src/vcore/CRL.cpp b/modules/vcore/src/vcore/CRL.cpp deleted file mode 100644 index 98643df..0000000 --- a/modules/vcore/src/vcore/CRL.cpp +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Piotr Marcinkiewicz(p.marcinkiew@samsung.com) - * @version 0.1 - * @file CRL.h - * @brief Routines for certificate validation over CRL - */ - -#include "CRL.h" - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "Base64.h" -#include "Certificate.h" -#include "SoupMessageSendSync.h" -#include "CertificateCacheDAO.h" - -namespace { -const char *CRL_LOOKUP_DIR_1 = "/usr/share/cert-svc/ca-certs/code-signing/wac"; -const char *CRL_LOOKUP_DIR_2 = "/opt/share/cert-svc/certs/code-signing/wac"; -} //anonymous namespace - -namespace ValidationCore { - -CRL::StringList CRL::getCrlUris(const CertificatePtr &argCert) -{ - StringList result = argCert->getCrlUris(); - - if (!result.empty()) { - return result; - } - LogInfo("No distribution points found. Getting from CA cert."); - X509_STORE_CTX *ctx = createContext(argCert); - X509_OBJECT obj; - - //Try to get distribution points from CA certificate - int retVal = X509_STORE_get_by_subject(ctx, X509_LU_X509, - X509_get_issuer_name(argCert-> - getX509()), - &obj); - X509_STORE_CTX_free(ctx); - if (0 >= retVal) { - LogError("No dedicated CA certificate available"); - return result; - } - CertificatePtr caCert(new Certificate(obj.data.x509)); - X509_OBJECT_free_contents(&obj); - return caCert->getCrlUris(); -} - -CRL::CRL() -{ - LogInfo("CRL storage initialization."); - m_store = X509_STORE_new(); - if (!m_store) { - LogError("Failed to create new store."); - ThrowMsg(CRLException::StorageError, - "Not possible to create new store."); - } - m_lookup = X509_STORE_add_lookup(m_store, X509_LOOKUP_hash_dir()); - if (!m_lookup) { - cleanup(); - LogError("Failed to add hash dir lookup"); - ThrowMsg(CRLException::StorageError, - "Not possible to add hash dir lookup."); - } - // Add hash dir pathname for CRL checks - bool retVal = X509_LOOKUP_add_dir(m_lookup, - CRL_LOOKUP_DIR_1, X509_FILETYPE_PEM) == 1; - retVal &= retVal && (X509_LOOKUP_add_dir(m_lookup, CRL_LOOKUP_DIR_1, - X509_FILETYPE_ASN1) == 1); - retVal &= retVal && (X509_LOOKUP_add_dir(m_lookup, CRL_LOOKUP_DIR_2, - X509_FILETYPE_PEM) == 1); - retVal &= retVal && (X509_LOOKUP_add_dir(m_lookup, CRL_LOOKUP_DIR_2, - X509_FILETYPE_ASN1) == 1); - if (!retVal) { - LogError("Failed to add lookup dir for PEM files."); - cleanup(); - ThrowMsg(CRLException::StorageError, - "Failed to add lookup dir for PEM files."); - } - LogInfo("CRL storage initialization complete."); -} - -CRL::~CRL() -{ - cleanup(); -} - -void CRL::cleanup() -{ - LogInfo("Free CRL storage"); - // STORE is responsible for LOOKUP release - // X509_LOOKUP_free(m_lookup); - X509_STORE_free(m_store); -} - -CRL::RevocationStatus CRL::checkCertificate(const CertificatePtr &argCert) -{ - RevocationStatus retStatus = {false, false}; - int retVal = 0; - StringList crlUris = getCrlUris(argCert); - FOREACH(it, crlUris) { - CRLDataPtr crl = getCRL(*it); - if (!crl) { - LogDebug("CRL not found for URI: " << *it); - continue; - } - X509_CRL *crlInternal = convertToInternal(crl); - - //Check date - if (X509_CRL_get_nextUpdate(crlInternal)) { - retVal = X509_cmp_current_time( - X509_CRL_get_nextUpdate(crlInternal)); - retStatus.isCRLValid = retVal > 0; - } else { - // If nextUpdate is not set assume it is actual. - retStatus.isCRLValid = true; - } - LogInfo("CRL valid: " << retStatus.isCRLValid); - X509_REVOKED rev; - rev.serialNumber = X509_get_serialNumber(argCert->getX509()); - // sk_X509_REVOKED_find returns index if serial number is found on list - retVal = sk_X509_REVOKED_find(crlInternal->crl->revoked, &rev); - X509_CRL_free(crlInternal); - retStatus.isRevoked = retVal != -1; - LogInfo("CRL revoked: " << retStatus.isRevoked); - - if (!retStatus.isRevoked && isOutOfDate(crl)) { - LogDebug("Certificate is not Revoked, but CRL is outOfDate."); - continue; - } - - return retStatus; - } - // If there is no CRL for any of URIs it means it's not possible to - // tell anything about revocation status but it's is not an error. - return retStatus; -} - -CRL::RevocationStatus CRL::checkCertificateChain(CertificateCollection - certChain) -{ - if (!certChain.sort()) { - LogError("Certificate list doesn't create chain."); - ThrowMsg(CRLException::InvalidParameter, - "Certificate list doesn't create chain."); - } - - RevocationStatus ret; - ret.isCRLValid = true; - ret.isRevoked = false; - const CertificateList &certList = certChain.getChain(); - FOREACH(it, certList) { - if (!(*it)->isRootCert()) { - LogInfo("Certificate common name: " << *((*it)->getCommonName())); - RevocationStatus certResult = checkCertificate(*it); - ret.isCRLValid &= certResult.isCRLValid; - ret.isRevoked |= certResult.isRevoked; - if (ret.isCRLValid && !ret.isRevoked) { - addToStorage(*it); - } - if (ret.isRevoked) { - return ret; - } - } - } - return ret; -} - -VerificationStatus CRL::checkEndEntity(CertificateCollection &chain) -{ - if (!chain.sort() && !chain.empty()) { - LogInfo("Could not find End Entity certificate. " - "Collection does not form chain."); - return VERIFICATION_STATUS_ERROR; - } - CertificateList::const_iterator iter = chain.begin(); - RevocationStatus stat = checkCertificate(*iter); - if (stat.isRevoked) { - return VERIFICATION_STATUS_REVOKED; - } - if (stat.isCRLValid) { - return VERIFICATION_STATUS_GOOD; - } - return VERIFICATION_STATUS_ERROR; -} - -void CRL::addToStorage(const CertificatePtr &argCert) -{ - X509_STORE_add_cert(m_store, argCert->getX509()); -} - -bool CRL::isOutOfDate(const CRLDataPtr &crl) const { - X509_CRL *crlInternal = convertToInternal(crl); - - bool result = false; - if (X509_CRL_get_nextUpdate(crlInternal)) { - if (0 > X509_cmp_current_time(X509_CRL_get_nextUpdate(crlInternal))) { - result = true; - } else { - result = false; - } - } else { - result = true; - } - X509_CRL_free(crlInternal); - return result; -} - -bool CRL::updateList(const CertificatePtr &argCert, - const UpdatePolicy updatePolicy) -{ - LogInfo("Update CRL for certificate"); - - // Retrieve distribution points - StringList crlUris = getCrlUris(argCert); - FOREACH(it, crlUris) { - // Try to get CRL from database - LogInfo("Getting CRL for URI: " << *it); - - bool downloaded = false; - - CRLDataPtr crl; - - // If updatePolicy == UPDATE_ON_DEMAND we dont care - // about data in cache. New crl must be downloaded. - if (updatePolicy == UPDATE_ON_EXPIRED) { - crl = getCRL(*it); - } - - if (!!crl && isOutOfDate(crl)) { - LogDebug("Crl out of date - downloading."); - crl = downloadCRL(*it); - downloaded = true; - } - - if (!crl) { - LogDebug("Crl not found in cache - downloading."); - crl = downloadCRL(*it); - downloaded = true; - } - - if (!crl) { - LogDebug("Failed to obtain CRL. URL: " << *it); - continue; - } - - if (!!crl && isOutOfDate(crl)) { - LogError("CRL out of date. Broken URL: " << *it); - } - - // Make X509 internal structure - X509_CRL *crlInternal = convertToInternal(crl); - - //Check if CRL is signed - if (!verifyCRL(crlInternal, argCert)) { - LogError("Failed to verify CRL. URI: " << crl->uri); - X509_CRL_free(crlInternal); - return false; - } - X509_CRL_free(crlInternal); - - if (downloaded) { - updateCRL(crl); - } - return true; - } - - return false; -} - -void CRL::addToStore(const CertificateCollection &collection) -{ - FOREACH(it, collection){ - addToStorage(*it); - } -} - -bool CRL::updateList(const CertificateCollection &collection, - UpdatePolicy updatePolicy) -{ - bool failed = false; - - FOREACH(it, collection){ - failed |= !updateList(*it, updatePolicy); - } - - return !failed; -} - -bool CRL::verifyCRL(X509_CRL *crl, - const CertificatePtr &cert) -{ - X509_OBJECT obj; - X509_STORE_CTX *ctx = createContext(cert); - - /* get issuer certificate */ - int retVal = X509_STORE_get_by_subject(ctx, X509_LU_X509, - X509_CRL_get_issuer(crl), &obj); - X509_STORE_CTX_free(ctx); - if (0 >= retVal) { - LogError("Unknown CRL issuer certificate!"); - return false; - } - - /* extract public key and verify signature */ - EVP_PKEY *pkey = X509_get_pubkey(obj.data.x509); - X509_OBJECT_free_contents(&obj); - if (!pkey) { - LogError("Failed to get issuer's public key."); - return false; - } - retVal = X509_CRL_verify(crl, pkey); - EVP_PKEY_free(pkey); - if (0 > retVal) { - LogError("Failed to verify CRL."); - return false; - } else if (0 == retVal) { - LogError("CRL is invalid"); - return false; - } - LogInfo("CRL is valid."); - return true; -} - -bool CRL::isPEMFormat(const CRLDataPtr &crl) const -{ - const char *pattern = "-----BEGIN X509 CRL-----"; - std::string content(crl->buffer, crl->length); - if (content.find(pattern) != std::string::npos) { - LogInfo("CRL is in PEM format."); - return true; - } - LogInfo("CRL is in DER format."); - return false; -} - -X509_CRL *CRL::convertToInternal(const CRLDataPtr &crl) const -{ - //At this point it's not clear does crl have DER or PEM format - X509_CRL *ret = NULL; - if (isPEMFormat(crl)) { - BIO *bmem = BIO_new_mem_buf(crl->buffer, crl->length); - if (!bmem) { - LogError("Failed to allocate memory in BIO"); - ThrowMsg(CRLException::InternalError, - "Failed to allocate memory in BIO"); - } - ret = PEM_read_bio_X509_CRL(bmem, NULL, NULL, NULL); - BIO_free_all(bmem); - } else { - //If it's not PEM it must be DER format - std::string content(crl->buffer, crl->length); - const unsigned char *buffer = - reinterpret_cast(crl->buffer); - ret = d2i_X509_CRL(NULL, &buffer, crl->length); - } - if (!ret) { - LogError("Failed to convert to internal structure"); - ThrowMsg(CRLException::InternalError, - "Failed to convert to internal structure"); - } - return ret; -} - -X509_STORE_CTX *CRL::createContext(const CertificatePtr &argCert) -{ - X509_STORE_CTX *ctx; - ctx = X509_STORE_CTX_new(); - if (!ctx) { - ThrowMsg(CRLException::StorageError, "Failed to create new context."); - } - X509_STORE_CTX_init(ctx, m_store, argCert->getX509(), NULL); - return ctx; -} - -CRL::CRLDataPtr CRL::downloadCRL(const std::string &uri) -{ - using namespace SoupWrapper; - - char *cport = 0, *chost = 0,*cpath = 0; - int use_ssl = 0; - - if (!OCSP_parse_url(const_cast(uri.c_str()), - &chost, - &cport, - &cpath, - &use_ssl)) - { - LogWarning("Error in OCSP_parse_url"); - return CRLDataPtr(); - } - - std::string host = chost; - if (cport) { - host += ":"; - host += cport; - } - - free(cport); - free(chost); - free(cpath); - - SoupMessageSendSync message; - message.setHost(uri); - message.setHeader("Host", host); - - if (SoupMessageSendSync::REQUEST_STATUS_OK != message.sendSync()) { - LogWarning("Error in sending network request."); - return CRLDataPtr(); - } - - SoupMessageSendBase::MessageBuffer mBuffer = message.getResponse(); - return CRLDataPtr(new CRLData(mBuffer,uri)); -} - -CRL::CRLDataPtr CRL::getCRL(const std::string &uri) const -{ - CRLCachedData cachedCrl; - cachedCrl.distribution_point = uri; - if (!CertificateCacheDAO::getCRLResponse(&cachedCrl)) { - LogInfo("CRL not present in database. URI: " << uri); - return CRLDataPtr(); - } - - std::string body = cachedCrl.crl_body; - - LogInfo("CRL found in database."); - //TODO: remove when ORM::blob available - //Encode buffer to base64 format to store in database - - Base64Decoder decoder; - decoder.append(body); - if (!decoder.finalize()) { - LogError("Failed to decode base64 format."); - ThrowMsg(CRLException::StorageError, "Failed to decode base64 format."); - } - std::string crlBody = decoder.get(); - - DPL::ScopedArray bodyBuffer(new char[crlBody.length()]); - crlBody.copy(bodyBuffer.Get(), crlBody.length()); - return CRLDataPtr(new CRLData(bodyBuffer.Release(), crlBody.length(), - uri)); -} - -void CRL::updateCRL(const CRLDataPtr &crl) -{ - //TODO: remove when ORM::blob available - //Encode buffer to base64 format to store in database - Base64Encoder encoder; - if (!crl || !crl->buffer) { - ThrowMsg(CRLException::InternalError, "CRL buffer is empty"); - } - encoder.append(std::string(crl->buffer, crl->length)); - encoder.finalize(); - std::string b64CRLBody = encoder.get(); - - time_t nextUpdateTime = 0; - X509_CRL *crlInternal = convertToInternal(crl); - - if (X509_CRL_get_nextUpdate(crlInternal)) { - asn1TimeToTimeT(X509_CRL_get_nextUpdate(crlInternal), - &nextUpdateTime); - } - - X509_CRL_free(crlInternal); - //Update/insert crl body - CertificateCacheDAO::setCRLResponse(crl->uri,b64CRLBody,nextUpdateTime); -} -} // ValidationCore diff --git a/modules/vcore/src/vcore/CRL.h b/modules/vcore/src/vcore/CRL.h deleted file mode 100644 index 9ba64bb..0000000 --- a/modules/vcore/src/vcore/CRL.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Piotr Marcinkiewicz(p.marcinkiew@samsung.com) - * @version 0.4 - * @file CRL.h - * @brief Routines for certificate validation over CRL - */ - -#ifndef WRT_ENGINE_SRC_VALIDATION_CORE_ENGINE_CRL_H_ -#define WRT_ENGINE_SRC_VALIDATION_CORE_ENGINE_CRL_H_ - -#include -#include -#include -#include - -#include "Certificate.h" -#include "CertificateCollection.h" -#include "SoupMessageSendBase.h" -#include "VerificationStatus.h" - -namespace ValidationCore { -namespace CRLException { -DECLARE_EXCEPTION_TYPE(DPL::Exception, CRLException) -DECLARE_EXCEPTION_TYPE(CRLException, StorageError) -DECLARE_EXCEPTION_TYPE(CRLException, DownloadFailed) -DECLARE_EXCEPTION_TYPE(CRLException, InternalError) -DECLARE_EXCEPTION_TYPE(CRLException, InvalidParameter) -} - -class CachedCRL; // forward declaration - -class CRL -{ - protected: - X509_STORE *m_store; - X509_LOOKUP *m_lookup; - - class CRLData : DPL::Noncopyable - { - public: - //TODO: change to SharedArray when available - char *buffer; - size_t length; - std::string uri; - - CRLData(char* _buffer, - size_t _length, - const std::string &_uri) : - buffer(_buffer), - length(_length), - uri(_uri) - { - } - - CRLData(const SoupWrapper::SoupMessageSendBase::MessageBuffer &mBuff, - const std::string &mUri) - : uri(mUri) - { - buffer = new char[mBuff.size()]; - length = mBuff.size(); - memcpy(buffer, &mBuff[0], mBuff.size()); - } - - ~CRLData() - { - LogInfo("Delete buffer"); - delete[] buffer; - } - }; - typedef DPL::SharedPtr CRLDataPtr; - typedef std::list StringList; - - CRLDataPtr getCRL(const std::string &uri) const; - CRLDataPtr downloadCRL(const std::string &uri); - X509_STORE_CTX *createContext(const CertificatePtr &argCert); - void updateCRL(const CRLDataPtr &crl); - X509_CRL *convertToInternal(const CRLDataPtr &crl) const; - StringList getCrlUris(const CertificatePtr &argCert); - bool isPEMFormat(const CRLDataPtr &crl) const; - bool verifyCRL(X509_CRL *crl, - const CertificatePtr &cert); - void addToStorage(const CertificatePtr &argCert); - void cleanup(); - bool isOutOfDate(const CRLDataPtr &crl) const; - - friend class CachedCRL; - public: - enum UpdatePolicy - { - UPDATE_ON_EXPIRED, /**< Download and update CRL only when next update - date has expired */ - UPDATE_ON_DEMAND /**< Download and update CRL regardless next update - date */ - }; - - struct RevocationStatus - { - bool isCRLValid; /**< True when CRL was valid during - certificate validation */ - bool isRevoked; /**< True when certificate is revoked */ - }; - - CRL(); - ~CRL(); - - /** - * @brief Checks if given certificate is revoked. - * - * @details This function doesn't update CRL list. If related CRL - * is out of date the #isCRLValid return parameter is set to false. - * - * @param[in] argCert The certificate to check against revocation. - * @return RevocationStatus.isRevoked True when certificate is revoked, - * false otherwise. - * RevocationStatus.isCRLValid True if related CRL has not expired, - * false otherwise. - */ - RevocationStatus checkCertificate(const CertificatePtr &argCert); - - /** - * @brief Checks if any certificate from certificate chain is revoked. - * - * @details This function doesn't update CRL lists. If any of related - * CRL is out of date the #isCRLValid parameter is set to true. - * This function adds valid certificates from the chain to internal storage - * map so they'll be available in further check operations for current - * CRL object. - * - * @param[in] argCert The certificate chain to check against revocation. - * @return RevocationStatus.isRevoked True when any from certificate chain - * is revoked, false otherwise. - * RevocationStatus.isCRLValid True if all of related CRLs has - * not expired, false otherwise. - */ - RevocationStatus checkCertificateChain(CertificateCollection certChain); - - VerificationStatus checkEndEntity(CertificateCollection &chain); - - /** - * @brief Updates CRL related with given certificate. - * - * @details This function updates CRL list related with given certificate. - * If CRL related with given certificate is not stored in database - * then this function will download CRL and store it in database. - * - * @param[in] argCert The certificate for which the CRL will be updated - * @param[in] updatePolicy Determine when CRL will be downloaded and updated - * @return True when CRL for given certificate was updated successfully, - * false otherwise. - */ - bool updateList(const CertificatePtr &argCert, - const UpdatePolicy updatePolicy); - - /** - * @brief Updates CRL related with given certificates. - * - * @details This function updates CRL lists related with given certificates. - * If CRL related with given certificate is not stored in database - * then this function will download CRL and store it in database. - * - * @param[in] collection The certificate collection for which the CRL will - * be updated - * @param[in] updatePolicy Determine when CRL will be downloaded and updated - * @return True when CRL for given certificate was updated successfully, - * false otherwise. - */ - bool updateList(const CertificateCollection &collection, - const UpdatePolicy updatePolisy); - - /** - * @brief Add certificate to known certificates store. - * - * @param[in] collection The certificate collection which will be - * added to known certificate store. - */ - void addToStore(const CertificateCollection &collection); -}; -} // ValidationCore - -#endif //ifndef WRT_ENGINE_SRC_VALIDATION_CORE_ENGINE_CRL_H_ diff --git a/modules/vcore/src/vcore/CachedCRL.cpp b/modules/vcore/src/vcore/CachedCRL.cpp deleted file mode 100644 index 08448bf..0000000 --- a/modules/vcore/src/vcore/CachedCRL.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * @file CachedCRL.cpp - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 0.1 - * @brief Cached CRL class implementation - */ - -#include -#include - -#include -#include -#include - -#include "CRL.h" -#include "CachedCRL.h" -#include "Certificate.h" -#include "CertificateCacheDAO.h" - -namespace ValidationCore { - -const time_t CachedCRL::CRL_minTimeValid = 3600; // one hour in seconds - -const time_t CachedCRL::CRL_maxTimeValid = 3600 * 24 * 7; // one week in seconds - -const time_t CachedCRL::CRL_refreshBefore = 3600; // one hour in seconds - -VerificationStatus CachedCRL::check(const CertificateCollection &certs) -{ - CRL crl; - bool allValid = true; - // we dont check CRL validity since - // we may use crl for longer time - // in smart cache than in regular CRL class (time clamping) - crl.addToStore(certs); - FOREACH(cert, certs){ - CRL::StringList crlUris = crl.getCrlUris(*cert); - FOREACH(uri, crlUris) { - allValid = allValid && updateCRLForUri(*uri,false); - } - } - if (!allValid) { - // problems with CRL validity - LogDebug("Some CRLs not valid"); - } - CRL::RevocationStatus stat = crl.checkCertificateChain(certs); - if (stat.isRevoked) { - LogDebug("Status REVOKED"); - return VERIFICATION_STATUS_REVOKED; - } - LogDebug("Status GOOD"); - return VERIFICATION_STATUS_GOOD; -} - -VerificationStatus CachedCRL::checkEndEntity(CertificateCollection &certs) -{ - if (certs.empty()) { - LogError("Collection empty. This should never happen."); - LogDebug("Status ERROR"); - return VERIFICATION_STATUS_ERROR; - } - if (!certs.sort()) { - LogError("Could not find End Entity certificate. " - "Collection does not form chain."); - LogDebug("Status ERROR"); - return VERIFICATION_STATUS_ERROR; - } - CRL crl; - bool allValid = true; - // we dont check CRL validity since - // we may use crl for longer time - // in smart cache than in regular CRL class (time clamping) - crl.addToStore(certs); - CertificateList::const_iterator icert = certs.begin(); - if (icert != certs.end()) { - CRL::StringList crlUris = crl.getCrlUris(*icert); - FOREACH(uri, crlUris) { - allValid = allValid && updateCRLForUri(*uri,false); - } - } - if (!allValid) { - // problems with CRL validity - LogDebug("Some CRLs not valid"); - } - CertificateList::const_iterator iter = certs.begin(); - CRL::RevocationStatus stat = crl.checkCertificate(*iter); - if (stat.isRevoked) { - LogDebug("Status REVOKED"); - return VERIFICATION_STATUS_REVOKED; - } - LogDebug("Status GOOD"); - return VERIFICATION_STATUS_GOOD; -} - -void CachedCRL::updateCache() -{ - CRLCachedDataList list; - CertificateCacheDAO::getCRLResponseList(&list); - FOREACH(db_crl, list) { - updateCRLForUri(db_crl->distribution_point, true); - } -} - -bool CachedCRL::updateCRLForUri(const std::string & uri, bool useExpiredShift) -{ - CRLCachedData cachedCRL; - cachedCRL.distribution_point = uri; - time_t now; - time(&now); - if (useExpiredShift) { - now += CRL_refreshBefore; - } - if (CertificateCacheDAO::getCRLResponse(&cachedCRL)) { - if (now < cachedCRL.next_update_time) { - LogDebug("Cached CRL still valid for: " << uri); - return true; - } - } - // need to download new CRL - CRL crl; - CRL::CRLDataPtr list = crl.downloadCRL(uri); - if (!list) { - LogWarning("Could not retreive CRL from " << uri); - return false; - } - crl.updateCRL(list); - CertificateCacheDAO::getCRLResponse(&cachedCRL); // save it the way CRL does - cachedCRL.next_update_time = - getNextUpdateTime(now,cachedCRL.next_update_time); - CertificateCacheDAO::setCRLResponse(cachedCRL.distribution_point, - cachedCRL.crl_body, - cachedCRL.next_update_time); - return true; -} - -time_t CachedCRL::getNextUpdateTime(time_t now, time_t response_validity) -{ - time_t min = now + CRL_minTimeValid; - time_t max = now + CRL_maxTimeValid; - if (response_validity < min) { - return min; - } - if (response_validity > max) { - return max; - } - return response_validity; -} - -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/CachedCRL.h b/modules/vcore/src/vcore/CachedCRL.h deleted file mode 100644 index 65e6509..0000000 --- a/modules/vcore/src/vcore/CachedCRL.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * @file CachedCRL.h - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 0.1 - * @brief Header file for smart cached CRL class - */ - -#ifndef _SRC_VALIDATION_CORE_CACHED_CRL_ -#define _SRC_VALIDATION_CORE_CACHED_CRL_ - -#include "CRL.h" -#include "IAbstractResponseCache.h" - -namespace ValidationCore { - -class CachedCRL : public IAbstractResponseCache { - public: - // cache can't be refreshed more frequently than CRL_minTimeValid - static const time_t CRL_minTimeValid; - - // to be even more secure, cache will be refreshed for certificate at least - // after CRL_maxTimeValid from last response - static const time_t CRL_maxTimeValid; - - // upon cache refresh, responses that will be invalid in CRL_refreshBefore - // seconds will be refreshed - static const time_t CRL_refreshBefore; - - VerificationStatus check(const CertificateCollection &certs); - VerificationStatus checkEndEntity(CertificateCollection &certs); - void updateCache(); - - CachedCRL() - { - } - virtual ~CachedCRL() - { - } - - private: - - // updates CRL cache for distributor URI - // useExpiredShift ==true should be used in cron/global cache update - // since it updates all CRLs that will be out of date in next - // CRL_refreshBefore seconds - bool updateCRLForUri(const std::string & uri, - bool useExpiredShift); - time_t getNextUpdateTime(time_t now, time_t response_validity); -}; - -} // namespace ValidationCore - -#endif /* _SRC_VALIDATION_CORE_CACHED_CRL_ */ diff --git a/modules/vcore/src/vcore/CachedOCSP.cpp b/modules/vcore/src/vcore/CachedOCSP.cpp deleted file mode 100644 index 21a8122..0000000 --- a/modules/vcore/src/vcore/CachedOCSP.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * @file CachedOCSP.cpp - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 0.1 - * @brief Cached OCSP class implementation - */ - -#include -#include - -#include -#include -#include - -#include "OCSP.h" -#include "CachedOCSP.h" -#include "Certificate.h" -#include "CertificateCacheDAO.h" - -namespace ValidationCore { - -const time_t CachedOCSP::OCSP_minTimeValid = 3600; // one hour in seconds - -const time_t CachedOCSP::OCSP_maxTimeValid = - 3600 * 24 * 7; // one week in seconds - -const time_t CachedOCSP::OCSP_refreshBefore = 3600; // one hour in seconds - -VerificationStatus CachedOCSP::check(const CertificateCollection &certs) -{ - OCSPCachedStatus db_status; - time_t now; - time(&now); - - db_status.cert_chain = certs.toBase64String(); - db_status.end_entity_check = false; - - if (CertificateCacheDAO::getOCSPStatus(&db_status)) { - LogDebug("Found cache entry for OCSP"); - if (now < db_status.next_update_time) { - LogDebug("Cache response valid"); - return db_status.ocsp_status; - } - } - - // here we need to get OCSP result and add/update cache - OCSP ocsp; - CertificateList list = certs.getChain(); - ocsp.setTrustedStore(list); - - VerificationStatusSet statusSet = ocsp.validateCertificateList(list); - db_status.ocsp_status = statusSet.convertToStatus(); - db_status.next_update_time = ocsp.getResponseValidity(); - CertificateCacheDAO::setOCSPStatus(db_status.cert_chain, - db_status.ocsp_status, - db_status.end_entity_check, - getNextUpdateTime( - now, - db_status.next_update_time)); - return db_status.ocsp_status; -} - -VerificationStatus CachedOCSP::checkEndEntity(CertificateCollection &certs) -{ - OCSPCachedStatus db_status; - time_t now; - time(&now); - - db_status.cert_chain = certs.toBase64String(); - db_status.end_entity_check = true; - - if (CertificateCacheDAO::getOCSPStatus(&db_status)) { - LogDebug("Found cache entry for OCSP"); - if (now < db_status.next_update_time) { - LogDebug("Cache response valid"); - return db_status.ocsp_status; - } - } - - // here we need to send request via OCSP and add/update cache - CertificateList clst; - getCertsForEndEntity(certs, &clst); - - OCSP ocsp; - ocsp.setTrustedStore(certs.getCertificateList()); - - const char *defResponderURI = getenv(OCSP::DEFAULT_RESPONDER_URI_ENV); - - if (defResponderURI) { - ocsp.setUseDefaultResponder(true); - ocsp.setDefaultResponder(defResponderURI); - } - - VerificationStatusSet statusSet = ocsp.validateCertificateList(clst); - db_status.ocsp_status = statusSet.convertToStatus(); - db_status.next_update_time = ocsp.getResponseValidity(); - - CertificateCacheDAO::setOCSPStatus(db_status.cert_chain, - db_status.ocsp_status, - db_status.end_entity_check, - getNextUpdateTime( - now, - db_status.next_update_time)); - - return db_status.ocsp_status; -} - -void CachedOCSP::updateCache() -{ - time_t now; - time(&now); - now += OCSP_refreshBefore; - OCSPCachedStatusList list; - CertificateCacheDAO::getOCSPStatusList(&list); - FOREACH(db_status, list) { - if (now >= db_status->next_update_time) { - // this response needs to be refreshed - // TODO: check result? update even errors? need to check RFC - CertificateCollection col; - col.load(db_status->cert_chain); - - OCSP ocsp; - CertificateList chain = col.getChain(); - ocsp.setTrustedStore(chain); - - VerificationStatusSet statusSet; - - if (db_status->end_entity_check) { - CertificateList clst; - getCertsForEndEntity(col, &clst); - statusSet = ocsp.validateCertificateList(clst); - } else { - statusSet = ocsp.validateCertificateList(chain); - } - - db_status->ocsp_status = statusSet.convertToStatus(); - db_status->next_update_time = ocsp.getResponseValidity(); - - CertificateCacheDAO::setOCSPStatus(db_status->cert_chain, - db_status->ocsp_status, - db_status->end_entity_check, - db_status->next_update_time); - } - } -} - -void CachedOCSP::getCertsForEndEntity( - const CertificateCollection &certs, CertificateList* clst) -{ - if (NULL == clst) { - LogError("NULL pointer"); - return; - } - - if (certs.isChain() && certs.size() >= 2) { - CertificateList::const_iterator icert = certs.begin(); - clst->push_back(*icert); - ++icert; - clst->push_back(*icert); - } -} - -time_t CachedOCSP::getNextUpdateTime(time_t now, time_t response_validity) -{ - long min = now + OCSP_minTimeValid; - long max = now + OCSP_maxTimeValid; - if (response_validity < min) { - return min; - } - if (response_validity > max) { - return max; - } - return response_validity; -} - -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/CachedOCSP.h b/modules/vcore/src/vcore/CachedOCSP.h deleted file mode 100644 index 517e49f..0000000 --- a/modules/vcore/src/vcore/CachedOCSP.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * @file CachedOCSP.h - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 0.1 - * @brief Header file for smart cached OCSP class - */ - -#ifndef _SRC_VALIDATION_CORE_CACHED_OCSP_ -#define _SRC_VALIDATION_CORE_CACHED_OCSP_ - -#include "OCSP.h" -#include "IAbstractResponseCache.h" - -namespace ValidationCore { - -class CachedOCSP : public IAbstractResponseCache { - public: - // cache can't be refreshed more frequently than OCSP_minTimeValid - static const time_t OCSP_minTimeValid; - - // to be even more secure, cache will be refreshed for certificate at least - // after OCSP_minTimeValid from last response - static const time_t OCSP_maxTimeValid; - - // upon cache refresh, responses that will be invalid in OCSP_refreshBefore - // seconds will be refreshed - static const time_t OCSP_refreshBefore; - - VerificationStatus check(const CertificateCollection &certs); - VerificationStatus checkEndEntity(CertificateCollection &certs); - void updateCache(); - - CachedOCSP() - { - } - virtual ~CachedOCSP() - { - } - - private: - - void getCertsForEndEntity(const CertificateCollection &certs, - CertificateList* clst); - time_t getNextUpdateTime(time_t now, time_t response_validity); -}; - -} // namespace ValidationCore - -#endif /* _SRC_VALIDATION_CORE_CACHED_OCSP_ */ diff --git a/modules/vcore/src/vcore/CertStoreType.h b/modules/vcore/src/vcore/CertStoreType.h deleted file mode 100644 index 7cf6232..0000000 --- a/modules/vcore/src/vcore/CertStoreType.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#ifndef _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTSTORETYPE_H_ -#define _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTSTORETYPE_H_ - -namespace ValidationCore { -namespace CertStoreId { -typedef unsigned int Type; - -// RootCA certificates for developer mode. -const Type DEVELOPER = 1; -// RootCA certificates for author signatures. -const Type WAC_PUBLISHER = 1 << 1; -// RootCA certificates for wac-signed widgets. -const Type WAC_ROOT = 1 << 2; -// RootCA certificates for wac-members ie. operators, manufacturers. -const Type WAC_MEMBER = 1 << 3; - -class Set -{ - public: - Set() : - m_certificateStorage(0) - { - } - - void add(Type second) - { - m_certificateStorage |= second; - } - - bool contains(Type second) const - { - return static_cast(m_certificateStorage & second); - } - - bool isEmpty() const - { - return m_certificateStorage == 0; - } - - private: - Type m_certificateStorage; -}; -} // namespace CertStoreId -} // namespace ValidationCore - -#endif // _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTSTORETYPE_H_ diff --git a/modules/vcore/src/vcore/Certificate.cpp b/modules/vcore/src/vcore/Certificate.cpp deleted file mode 100644 index 9ec2868..0000000 --- a/modules/vcore/src/vcore/Certificate.cpp +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#include "Certificate.h" - -#include - -#include -#include - -#include - -namespace ValidationCore { - -int asn1TimeToTimeT(ASN1_TIME *t, - time_t *res) -{ - struct tm tm; - int offset; - - (*res) = 0; - if (!ASN1_TIME_check(t)) { - return -1; - } - - memset(&tm, 0, sizeof(tm)); - -#define g2(p) (((p)[0] - '0') * 10 + (p)[1] - '0') - if (t->type == V_ASN1_UTCTIME) { - Assert(t->length > 12); - - /* this code is copied from OpenSSL asn1/a_utctm.c file */ - tm.tm_year = g2(t->data); - if (tm.tm_year < 50) { - tm.tm_year += 100; - } - tm.tm_mon = g2(t->data + 2) - 1; - tm.tm_mday = g2(t->data + 4); - tm.tm_hour = g2(t->data + 6); - tm.tm_min = g2(t->data + 8); - tm.tm_sec = g2(t->data + 10); - if (t->data[12] == 'Z') { - offset = 0; - } else { - Assert(t->length > 16); - - offset = g2(t->data + 13) * 60 + g2(t->data + 15); - if (t->data[12] == '-') { - offset = -offset; - } - } - tm.tm_isdst = -1; - } else { - Assert(t->length > 14); - - tm.tm_year = g2(t->data) * 100 + g2(t->data + 2); - tm.tm_mon = g2(t->data + 4) - 1; - tm.tm_mday = g2(t->data + 6); - tm.tm_hour = g2(t->data + 8); - tm.tm_min = g2(t->data + 10); - tm.tm_sec = g2(t->data + 12); - if (t->data[14] == 'Z') { - offset = 0; - } else { - Assert(t->length > 18); - - offset = g2(t->data + 15) * 60 + g2(t->data + 17); - if (t->data[14] == '-') { - offset = -offset; - } - } - tm.tm_isdst = -1; - } -#undef g2 - (*res) = timegm(&tm) - offset * 60; - return 0; -} - -int asn1GeneralizedTimeToTimeT(ASN1_GENERALIZEDTIME *tm, - time_t *res) -{ - /* - * This code is based on following assumption: - * from openssl/a_gentm.c: - * GENERALIZEDTIME is similar to UTCTIME except the year is - * represented as YYYY. This stuff treats everything as a two digit - * field so make first two fields 00 to 99 - */ - const int DATE_BUFFER_LENGTH = 15; // YYYYMMDDHHMMSSZ - - if (NULL == res || NULL == tm) { - LogError("NULL pointer"); - return -1; - } - - if (DATE_BUFFER_LENGTH != tm->length || NULL == tm->data) { - LogError("Invalid ASN1_GENERALIZEDTIME"); - return -1; - } - - struct tm time_s; - if (sscanf ((char*)tm->data, - "%4d%2d%2d%2d%2d%2d", - &time_s.tm_year, - &time_s.tm_mon, - &time_s.tm_mday, - &time_s.tm_hour, - &time_s.tm_min, - &time_s.tm_sec) < 6) - { - LogError("Could not extract time data from ASN1_GENERALIZEDTIME"); - return -1; - } - - time_s.tm_year -= 1900; - time_s.tm_mon -= 1; - time_s.tm_isdst = 0; // UTC - time_s.tm_gmtoff = 0; // UTC - time_s.tm_zone = NULL; // UTC - - *res = mktime(&time_s); - - return 0; -} - -Certificate::Certificate(X509 *cert) -{ - Assert(cert); - m_x509 = X509_dup(cert); - if (!m_x509) { - LogWarning("Internal Openssl error in d2i_X509 function."); - ThrowMsg(Exception::OpensslInternalError, - "Internal Openssl error in d2i_X509 function."); - } -} - -Certificate::Certificate(cert_svc_mem_buff &buffer) -{ - Assert(buffer.data); - const unsigned char *ptr = buffer.data; - m_x509 = d2i_X509(NULL, &ptr, buffer.size); - if (!m_x509) { - LogWarning("Internal Openssl error in d2i_X509 function."); - ThrowMsg(Exception::OpensslInternalError, - "Internal Openssl error in d2i_X509 function."); - } -} - -Certificate::Certificate(const std::string &der, - Certificate::FormType form) -{ - Assert(der.size()); - - int size; - const unsigned char *ptr; - std::string tmp; - - if (FORM_BASE64 == form) { - Base64Decoder base64; - base64.reset(); - base64.append(der); - base64.finalize(); - tmp = base64.get(); - ptr = reinterpret_cast(tmp.c_str()); - size = static_cast(tmp.size()); - } else { - ptr = reinterpret_cast(der.c_str()); - size = static_cast(der.size()); - } - - m_x509 = d2i_X509(NULL, &ptr, size); - if (!m_x509) { - LogError("Internal Openssl error in d2i_X509 function."); - ThrowMsg(Exception::OpensslInternalError, - "Internal Openssl error in d2i_X509 function."); - } -} - -Certificate::~Certificate() -{ - X509_free(m_x509); -} - -X509* Certificate::getX509(void) const -{ - return m_x509; -} - -std::string Certificate::getDER(void) const -{ - unsigned char *rawDer = NULL; - int size = i2d_X509(m_x509, &rawDer); - if (!rawDer || size <= 0) { - LogError("i2d_X509 failed"); - ThrowMsg(Exception::OpensslInternalError, - "i2d_X509 failed"); - } - - std::string output(reinterpret_cast(rawDer), size); - OPENSSL_free(rawDer); - return output; -} - -std::string Certificate::getBase64(void) const -{ - Base64Encoder base64; - base64.reset(); - base64.append(getDER()); - base64.finalize(); - return base64.get(); -} - -bool Certificate::isSignedBy(const CertificatePtr &parent) const -{ - if (!parent) { - LogDebug("Invalid certificate parameter."); - return false; - } - return 0 == X509_NAME_cmp(X509_get_subject_name(parent->m_x509), - X509_get_issuer_name(m_x509)); -} - -Certificate::Fingerprint Certificate::getFingerprint( - Certificate::FingerprintType type) const -{ - size_t fingerprintlength = EVP_MAX_MD_SIZE; - unsigned char fingerprint[EVP_MAX_MD_SIZE]; - Fingerprint raw; - - if (type == FINGERPRINT_MD5) { - if (!X509_digest(m_x509, EVP_md5(), fingerprint, &fingerprintlength)) { - LogError("MD5 digest counting failed!"); - ThrowMsg(Exception::OpensslInternalError, - "MD5 digest counting failed!"); - } - } - - if (type == FINGERPRINT_SHA1) { - if (!X509_digest(m_x509, EVP_sha1(), fingerprint, - &fingerprintlength)) - { - LogError("SHA1 digest counting failed"); - ThrowMsg(Exception::OpensslInternalError, - "SHA1 digest counting failed!"); - } - } - - raw.resize(fingerprintlength); // improve performance - std::copy(fingerprint, fingerprint + fingerprintlength, raw.begin()); - - return raw; -} - -DPL::OptionalString Certificate::getField(FieldType type, - int fieldNid) const -{ - X509_NAME *subjectName = NULL; - switch (type) { - case FIELD_ISSUER: - subjectName = X509_get_issuer_name(m_x509); - break; - case FIELD_SUBJECT: - subjectName = X509_get_subject_name(m_x509); - break; - default: - Assert("Invalid type"); - } - - if (!subjectName) { - LogError("Error during subject name extraction."); - ThrowMsg(Exception::OpensslInternalError, - "Error during subject name extraction."); - } - - X509_NAME_ENTRY *subjectEntry = NULL; - - DPL::Optional < DPL::String > output; - - int entryCount = X509_NAME_entry_count(subjectName); - - for (int i = 0; i < entryCount; ++i) { - subjectEntry = X509_NAME_get_entry(subjectName, - i); - - if (!subjectEntry) { - continue; - } - - int nid = OBJ_obj2nid( - static_cast( - X509_NAME_ENTRY_get_object(subjectEntry))); - - if (nid != fieldNid) { - continue; - } - - ASN1_STRING* pASN1Str = subjectEntry->value; - - unsigned char* pData = NULL; - int nLength = ASN1_STRING_to_UTF8(&pData, - pASN1Str); - - if (nLength < 0) { - LogError("Reading field error."); - ThrowMsg(Exception::OpensslInternalError, - "Reading field error."); - } - - std::string strEntry(reinterpret_cast(pData), - nLength); - output = DPL::FromUTF8String(strEntry); - OPENSSL_free(pData); - } - return output; -} - -DPL::OptionalString Certificate::getCommonName(FieldType type) const -{ - return getField(type, NID_commonName); -} - -DPL::OptionalString Certificate::getCountryName(FieldType type) const -{ - return getField(type, NID_countryName); -} - -DPL::OptionalString Certificate::getStateOrProvinceName(FieldType type) const -{ - return getField(type, NID_stateOrProvinceName); -} - -DPL::OptionalString Certificate::getLocalityName(FieldType type) const -{ - return getField(type, NID_localityName); -} - -DPL::OptionalString Certificate::getOrganizationName(FieldType type) const -{ - return getField(type, NID_organizationName); -} - -DPL::OptionalString Certificate::getOrganizationalUnitName(FieldType type) const -{ - return getField(type, NID_organizationalUnitName); -} - -DPL::OptionalString Certificate::getOCSPURL() const -{ - // TODO verify this code - DPL::OptionalString retValue; - AUTHORITY_INFO_ACCESS *aia = static_cast( - X509_get_ext_d2i(m_x509, - NID_info_access, - NULL, - NULL)); - - // no AIA extension in the cert - if (NULL == aia) { - return retValue; - } - - int count = sk_ACCESS_DESCRIPTION_num(aia); - - for (int i = 0; i < count; ++i) { - ACCESS_DESCRIPTION* ad = sk_ACCESS_DESCRIPTION_value(aia, i); - - if (OBJ_obj2nid(ad->method) == NID_ad_OCSP && - ad->location->type == GEN_URI) - { - void* data = ASN1_STRING_data(ad->location->d.ia5); - retValue = DPL::OptionalString(DPL::FromUTF8String( - static_cast(data))); - - break; - } - } - sk_ACCESS_DESCRIPTION_free(aia); - return retValue; -} - -Certificate::AltNameSet Certificate::getAlternativeNameDNS() const -{ - AltNameSet set; - - GENERAL_NAME *namePart = NULL; - - STACK_OF(GENERAL_NAME)* san = - static_cast( - X509_get_ext_d2i(m_x509,NID_subject_alt_name,NULL,NULL)); - - while (sk_GENERAL_NAME_num(san) > 0) { - namePart = sk_GENERAL_NAME_pop(san); - if (GEN_DNS == namePart->type) { - std::string temp = - reinterpret_cast(ASN1_STRING_data(namePart->d.dNSName)); - DPL::String altDNSName = DPL::FromASCIIString(temp); - set.insert(altDNSName); - LogDebug("FOUND GEN_DNS: " << temp); - } else { - LogDebug("FOUND GEN TYPE ID: " << namePart->type); - } - } - return set; -} - -time_t Certificate::getNotAfter() const -{ - ASN1_TIME *time = X509_get_notAfter(m_x509); - if (!time) { - LogError("Reading Not After error."); - ThrowMsg(Exception::OpensslInternalError, "Reading Not After error."); - } - time_t output; - if (asn1TimeToTimeT(time, &output)) { - LogError("Converting ASN1_time to time_t error."); - ThrowMsg(Exception::OpensslInternalError, - "Converting ASN1_time to time_t error."); - } - return output; -} - -bool Certificate::isRootCert() -{ - // based on that root certificate has the same subject as issuer name - return isSignedBy(this->SharedFromThis()); -} - -std::list -Certificate::getCrlUris() const -{ - std::list result; - - STACK_OF(DIST_POINT)* distPoints = - static_cast( - X509_get_ext_d2i( - getX509(), - NID_crl_distribution_points, - NULL, - NULL)); - if (!distPoints) { - LogDebug("No distribution points in certificate."); - return result; - } - - int count = sk_DIST_POINT_num(distPoints); - for (int i = 0; i < count; ++i) { - DIST_POINT* point = sk_DIST_POINT_value(distPoints, i); - if (!point) { - LogError("Failed to get distribution point."); - continue; - } - if (point->distpoint != NULL && - point->distpoint->name.fullname != NULL) - { - int countName = - sk_GENERAL_NAME_num(point->distpoint->name.fullname); - for (int j = 0; j < countName; ++j) { - GENERAL_NAME* name = sk_GENERAL_NAME_value( - point->distpoint->name.fullname, j); - if (name != NULL && GEN_URI == name->type) { - char *crlUri = - reinterpret_cast(name->d.ia5->data); - if (!crlUri) { - LogError("Failed to get URI."); - continue; - } - result.push_back(crlUri); - } - } - } - } - sk_DIST_POINT_pop_free(distPoints, DIST_POINT_free); - return result; -} -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/Certificate.h b/modules/vcore/src/vcore/Certificate.h deleted file mode 100644 index de7636d..0000000 --- a/modules/vcore/src/vcore/Certificate.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#ifndef _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTIFICATE_H_ -#define _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTIFICATE_H_ - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace ValidationCore { - -// from OpenSSL asn1/a_utctm.c code -int asn1TimeToTimeT(ASN1_TIME *t, - time_t *res); - - -int asn1GeneralizedTimeToTimeT(ASN1_GENERALIZEDTIME *tm, - time_t *res); - -class Certificate; - -typedef DPL::SharedPtr CertificatePtr; -typedef std::list CertificateList; - -class Certificate : public DPL::EnableSharedFromThis -{ - public: - typedef std::vector Fingerprint; - typedef DPL::String AltName; - typedef std::set AltNameSet; - - enum FingerprintType - { - FINGERPRINT_MD5, - FINGERPRINT_SHA1 - }; - enum FieldType - { - FIELD_ISSUER, - FIELD_SUBJECT - }; - - enum FormType - { - FORM_DER, - FORM_BASE64 - }; - - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, OpensslInternalError) - }; - - explicit Certificate(X509 *cert); - - explicit Certificate(cert_svc_mem_buff &buffer); - - explicit Certificate(const std::string &der, - FormType form = FORM_DER); - - ~Certificate(); - - // It returns pointer to internal structure! - // Do not free this pointer! - X509 *getX509(void) const; - - std::string getDER(void) const; - - std::string getBase64(void) const; - - // This const is cheating here because you have no - // guarantee that X509_get_subject_name will not - // change X509 object. - bool isSignedBy(const CertificatePtr &parent) const; - - Fingerprint getFingerprint(FingerprintType type) const; - - DPL::OptionalString getCommonName(FieldType type = FIELD_SUBJECT) const; - DPL::OptionalString getCountryName(FieldType type = FIELD_SUBJECT) const; - DPL::OptionalString getStateOrProvinceName( - FieldType type = FIELD_SUBJECT) const; - DPL::OptionalString getLocalityName(FieldType type = FIELD_SUBJECT) const; - DPL::OptionalString getOrganizationName( - FieldType type = FIELD_SUBJECT) const; - DPL::OptionalString getOrganizationalUnitName( - FieldType type = FIELD_SUBJECT) const; - DPL::OptionalString getOCSPURL() const; - - // Openssl supports 9 types of alternative name filed. - // 4 of them are "string similar" types so it is possible - // to create more generic function. - AltNameSet getAlternativeNameDNS() const; - - time_t getNotAfter() const; - - /** - * @brief This is convenient function. - * - * @details It can't be const function (however it doesn't change internal - * object). For details see #isSignedBy() function description. - */ - bool isRootCert(); - - /** - * @brief Gets list of CRL distribution's points URIs - */ - std::list getCrlUris() const; - - protected: - DPL::OptionalString getField(FieldType type, - int fieldNid) const; - - X509 *m_x509; -}; -} // namespace ValidationCore - -#endif diff --git a/modules/vcore/src/vcore/CertificateCacheDAO.cpp b/modules/vcore/src/vcore/CertificateCacheDAO.cpp deleted file mode 100644 index 04956a3..0000000 --- a/modules/vcore/src/vcore/CertificateCacheDAO.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file CertificateCacheDAO.cpp - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 0.1 - * @brief CertificateCacheDAO implementation - */ - -#include "CertificateCacheDAO.h" -#include "VCorePrivate.h" - -#include -#include -#include -#include -#include - -using namespace DPL::DB::ORM; -using namespace DPL::DB::ORM::vcore; - -namespace ValidationCore { - -void CertificateCacheDAO::setOCSPStatus(const std::string& cert_chain, - VerificationStatus ocsp_status, - bool end_entity_check, - time_t next_update_time) -{ - Try { - ScopedTransaction transaction(&ThreadInterface()); - OCSPCachedStatus status; - status.cert_chain = cert_chain; - status.end_entity_check = end_entity_check; - if (getOCSPStatus(&status)) { - // only need to update data in DB - Equals e1( - DPL::FromUTF8String(cert_chain)); - Equals e2( - end_entity_check ? 1 : 0); - - OCSPResponseStorage::Row row; - - row.Set_ocsp_status(ocsp_status); - row.Set_next_update_time(next_update_time); - - VCORE_DB_UPDATE(update, OCSPResponseStorage, &ThreadInterface()) - update->Where(And(e1,e2)); - update->Values(row); - update->Execute(); - } else { - // need to insert data - OCSPResponseStorage::Row row; - - row.Set_cert_chain(DPL::FromUTF8String(cert_chain)); - row.Set_ocsp_status(ocsp_status); - row.Set_next_update_time(next_update_time); - row.Set_end_entity_check(end_entity_check ? 1 : 0); - - VCORE_DB_INSERT(insert, OCSPResponseStorage, &ThreadInterface()) - insert->Values(row); - insert->Execute(); - } - transaction.Commit(); - } Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to setOCSPStatus"); - } -} - -bool CertificateCacheDAO::getOCSPStatus(OCSPCachedStatus* cached_status) -{ - if (NULL == cached_status) { - LogError("NULL pointer"); - return false; - } - Try { - Equals e1( - DPL::FromUTF8String(cached_status->cert_chain)); - Equals e2( - cached_status->end_entity_check ? 1 : 0); - - VCORE_DB_SELECT(select, OCSPResponseStorage, &ThreadInterface()) - - select->Where(And(e1,e2)); - std::list rows = select->GetRowList(); - if (1 == rows.size()) { - OCSPResponseStorage::Row row = rows.front(); - cached_status->ocsp_status = intToVerificationStatus( - *(row.Get_ocsp_status())); - cached_status->next_update_time = *(row.Get_next_update_time()); - return true; - } - - LogDebug("Cached OCSP status not found"); - return false; - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to getOCSPStatus"); - } -} - -void CertificateCacheDAO::getOCSPStatusList( - OCSPCachedStatusList* cached_status_list) -{ - if (NULL == cached_status_list) { - LogError("NULL pointer"); - return; - } - Try { - VCORE_DB_SELECT(select, OCSPResponseStorage, &ThreadInterface()) - typedef std::list RowList; - RowList list = select->GetRowList(); - - FOREACH(i, list) { - OCSPCachedStatus status; - status.cert_chain = DPL::ToUTF8String(i->Get_cert_chain()); - status.ocsp_status = intToVerificationStatus( - *(i->Get_ocsp_status())); - status.end_entity_check = - *(i->Get_end_entity_check()) == 1 ? true : false; - status.next_update_time = *(i->Get_next_update_time()); - cached_status_list->push_back(status); - } - - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to getOCSPStatusList"); - } -} - - -void CertificateCacheDAO::setCRLResponse(const std::string& distribution_point, - const std::string& crl_body, - time_t next_update_time) -{ - Try { - ScopedTransaction transaction(&ThreadInterface()); - CRLCachedData data; - data.distribution_point = distribution_point; - if (getCRLResponse(&data)) { - // only need to update data in DB - VCORE_DB_UPDATE(update, CRLResponseStorage, &ThreadInterface()) - Equals e1( - DPL::FromUTF8String(distribution_point)); - CRLResponseStorage::Row row; - - update->Where(e1); - row.Set_crl_body(DPL::FromUTF8String(crl_body)); - row.Set_next_update_time(next_update_time); - update->Values(row); - update->Execute(); - } else { - // need to insert data - VCORE_DB_INSERT(insert, CRLResponseStorage, &ThreadInterface()) - CRLResponseStorage::Row row; - - row.Set_distribution_point(DPL::FromUTF8String(distribution_point)); - row.Set_crl_body(DPL::FromUTF8String(crl_body)); - row.Set_next_update_time(next_update_time); - insert->Values(row); - insert->Execute(); - } - transaction.Commit(); - } Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to setOCSPStatus"); - } -} - -bool CertificateCacheDAO::getCRLResponse(CRLCachedData* cached_data) -{ - if (NULL == cached_data) { - LogError("NULL pointer"); - return false; - } - Try { - VCORE_DB_SELECT(select, CRLResponseStorage, &ThreadInterface()) - Equals e1( - DPL::FromUTF8String(cached_data->distribution_point)); - - select->Where(e1); - std::list rows = select->GetRowList(); - if (1 == rows.size()) { - CRLResponseStorage::Row row = rows.front(); - cached_data->crl_body = DPL::ToUTF8String(row.Get_crl_body()); - cached_data->next_update_time = *(row.Get_next_update_time()); - return true; - } - - LogDebug("Cached CRL not found"); - return false; - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to getCRLResponse"); - } -} - -void CertificateCacheDAO::getCRLResponseList( - CRLCachedDataList* cached_data_list) -{ - if (NULL == cached_data_list) { - LogError("NULL pointer"); - return; - } - Try { - VCORE_DB_SELECT(select, CRLResponseStorage, &ThreadInterface()) - typedef std::list RowList; - RowList list = select->GetRowList(); - - FOREACH(i, list) { - CRLCachedData response; - response.distribution_point = DPL::ToUTF8String( - i->Get_distribution_point()); - response.crl_body = DPL::ToUTF8String(i->Get_crl_body()); - response.next_update_time = *(i->Get_next_update_time()); - cached_data_list->push_back(response); - } - - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to getCRLResponses"); - } -} - -void CertificateCacheDAO::clearCertificateCache() -{ - Try { - ScopedTransaction transaction(&ThreadInterface()); - VCORE_DB_DELETE(del1, OCSPResponseStorage, &ThreadInterface()) - del1->Execute(); - VCORE_DB_DELETE(del2, CRLResponseStorage, &ThreadInterface()) - del2->Execute(); - transaction.Commit(); - } - Catch(DPL::DB::SqlConnection::Exception::Base) { - ReThrowMsg(Exception::DatabaseError, "Failed to clearUserSettings"); - } -} - -VerificationStatus CertificateCacheDAO::intToVerificationStatus(int p) -{ - switch (p) { - case 1: - return VERIFICATION_STATUS_GOOD; - case 1 << 1: - return VERIFICATION_STATUS_REVOKED; - case 1 << 2: - return VERIFICATION_STATUS_UNKNOWN; - case 1 << 3: - return VERIFICATION_STATUS_VERIFICATION_ERROR; - case 1 << 4: - return VERIFICATION_STATUS_NOT_SUPPORT; - case 1 << 5: - return VERIFICATION_STATUS_CONNECTION_FAILED; - case 1 << 6: - return VERIFICATION_STATUS_ERROR; - default: - return VERIFICATION_STATUS_ERROR; - } -} - -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/CertificateCacheDAO.h b/modules/vcore/src/vcore/CertificateCacheDAO.h deleted file mode 100644 index ba26091..0000000 --- a/modules/vcore/src/vcore/CertificateCacheDAO.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file CertificateCacheDAO.h - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 0.1 - * @brief Header file for class managing CRL and OCSP cached responses - */ - -#ifndef _WRT_SRC_CONFIGURATION_CERTIFICATE_CACHE_DAO_H_ -#define _WRT_SRC_CONFIGURATION_CERTIFICATE_CACHE_DAO_H_ - -#include -#include - -#include - -#include "VerificationStatus.h" - -namespace ValidationCore { - -struct OCSPCachedStatus -{ - std::string cert_chain; - VerificationStatus ocsp_status; - bool end_entity_check; - time_t next_update_time; -}; - -typedef std::list OCSPCachedStatusList; - -struct CRLCachedData -{ - std::string distribution_point; - std::string crl_body; - time_t next_update_time; -}; - -typedef std::list CRLCachedDataList; - -class CertificateCacheDAO { - public: - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, DatabaseError) - }; - - // OCSP statuses - - static void setOCSPStatus(const std::string& cert_chain, - VerificationStatus ocsp_status, - bool end_entity_check, - time_t next_update_time); - - /* - * fill cert_chain and end_entity_check in cached_status - * returns true iff cached status found without errors - */ - static bool getOCSPStatus(OCSPCachedStatus* cached_status); - static void getOCSPStatusList(OCSPCachedStatusList* cached_status_list); - - // CRL responses - - static void setCRLResponse(const std::string& distribution_point, - const std::string& crl_body, - time_t next_update_time); - - /* - * fill distribution_point - * returns true iff cached list for dist. point found without errors - */ - static bool getCRLResponse(CRLCachedData* cached_data); - static void getCRLResponseList(CRLCachedDataList* cached_data_list); - - - // clears CRL and OCSP cached data - static void clearCertificateCache(); - - private: - - static VerificationStatus intToVerificationStatus(int p); - - CertificateCacheDAO() - { - } -}; - -} // namespace ValidationCore - -#endif /* _WRT_SRC_CONFIGURATION_CERTIFICATE_CACHE_DAO_H_ */ diff --git a/modules/vcore/src/vcore/CertificateCollection.cpp b/modules/vcore/src/vcore/CertificateCollection.cpp deleted file mode 100644 index 988c510..0000000 --- a/modules/vcore/src/vcore/CertificateCollection.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include - -#include - -#include -#include -#include - -#include - -namespace { -using namespace ValidationCore; - -inline std::string toBinaryString(int data) -{ - char buffer[sizeof(int)]; - memcpy(buffer, &data, sizeof(int)); - return std::string(buffer, buffer + sizeof(int)); -} - -// helper functor for finding certificate basing on subject field -class SubjectElementFinder -{ - public: - SubjectElementFinder(CertificatePtr &cert) : m_searchFor(cert) - { - } - bool operator()(const CertificatePtr &cert) const - { - return cert->isSignedBy(m_searchFor); - } - void setCert(CertificatePtr &cert) - { - m_searchFor = cert; - } - - private: - CertificatePtr m_searchFor; -}; - -// helper functor for finding certificate basing on issuer field -class IssuerElementFinder -{ - public: - IssuerElementFinder(CertificatePtr &cert) : m_searchFor(cert) - { - } - bool operator()(const CertificatePtr &cert) const - { - return m_searchFor->isSignedBy(cert); - } - void setCert(CertificatePtr &cert) - { - m_searchFor = cert; - } - - private: - CertificatePtr m_searchFor; -}; - -//! Helper function -// pops an element from list, finder is responsible for match certificates -template -static CertificatePtr popAnElementFromList(CertificateList& lCertificates, - const T& finder) -{ - CertificatePtr pOutCertificate; - CertificateList::iterator it = - std::find_if(lCertificates.begin(), lCertificates.end(), finder); - - if (it != lCertificates.end()) { - pOutCertificate = *it; - lCertificates.erase(it); - } - - return pOutCertificate; -} -} // namespace - -namespace ValidationCore { -CertificateCollection::CertificateCollection() : - m_collectionStatus(COLLECTION_UNSORTED) -{ -} - -void CertificateCollection::clear(void) -{ - m_collectionStatus = COLLECTION_UNSORTED; - m_certList.clear(); -} - -void CertificateCollection::load(const CertificateList &certList) -{ - m_collectionStatus = COLLECTION_UNSORTED; - std::copy(certList.begin(), - certList.end(), - std::back_inserter(m_certList)); -} - -bool CertificateCollection::load(const std::string &buffer) -{ - Base64Decoder base64; - base64.reset(); - base64.append(buffer); - if (!base64.finalize()) { - LogWarning("Error during chain decoding"); - return false; - } - std::string binaryData = base64.get(); - - DPL::BinaryQueue queue; - queue.AppendCopy(binaryData.c_str(), binaryData.size()); - - int certNum; - queue.FlattenConsume(&certNum, sizeof(int)); - - CertificateList list; - - for (int i = 0; i < certNum; ++i) { - int certSize; - queue.FlattenConsume(&certSize, sizeof(int)); - std::vector rawDERCert; - rawDERCert.resize(certSize); - queue.FlattenConsume(&rawDERCert[0], certSize); - Try { - list.push_back(CertificatePtr( - new Certificate(std::string(rawDERCert.begin(), - rawDERCert.end())))); - } Catch(Certificate::Exception::Base) { - LogWarning("Error during certificate creation."); - return false; - } - LogDebug("Read certificate from database. Certificate common name: " << - list.back()->getCommonName()); - } - load(list); - return true; -} - -std::string CertificateCollection::toBase64String() const -{ - std::ostringstream output; - int certNum = m_certList.size(); - output << toBinaryString(certNum); - FOREACH(i, m_certList){ - std::string derCert = (*i)->getDER(); - output << toBinaryString(derCert.size()); - output << derCert; - } - Base64Encoder base64; - base64.reset(); - base64.append(output.str()); - base64.finalize(); - return base64.get(); -} - -CertificateList CertificateCollection::getCertificateList() const -{ - return m_certList; -} - -bool CertificateCollection::isChain() const -{ - if (COLLECTION_SORTED != m_collectionStatus) { - LogError("You must sort certificates first"); - ThrowMsg(Exception::WrongUsage, - "You must sort certificates first"); - } - return (COLLECTION_SORTED == m_collectionStatus) ? true : false; -} - -bool CertificateCollection::sort() -{ - if (COLLECTION_UNSORTED == m_collectionStatus) { - sortCollection(); - } - return (COLLECTION_SORTED == m_collectionStatus) ? true : false; -} - -CertificateList CertificateCollection::getChain() const -{ - if (COLLECTION_SORTED != m_collectionStatus) { - LogError("You must sort certificates first"); - ThrowMsg(Exception::WrongUsage, - "You must sort certificates first"); - } - return m_certList; -} - -void CertificateCollection::sortCollection() -{ - CertificateList lCertificates = m_certList; - // sorting is not necessary - if (lCertificates.empty()) { - m_collectionStatus = COLLECTION_SORTED; - return; - } - - // backup input list - CertificateList lBackup = lCertificates; - - // create a new output list - CertificateList lSortedCertificates; - - CertificatePtr pCertificate = lCertificates.front(); - - lCertificates.pop_front(); - lSortedCertificates.push_back(pCertificate); - - // indicates whether any matching certificate was found - bool bFound = false; - - CertificatePtr pSubjectCert = pCertificate; - - // lCertificates is very short (3 elements) so - // O(n^2) algorithm is good enough. - if (!lCertificates.empty()) { - // First, find all predecessors for, next all successors - // for pCertificate - SubjectElementFinder subjectFinder(pCertificate); - while ((pSubjectCert = popAnElementFromList(lCertificates, - subjectFinder)) != NULL) { - lSortedCertificates.push_front(pSubjectCert); - subjectFinder.setCert(pSubjectCert); - bFound = true; - } - - CertificatePtr pIssuerCert = pCertificate; - - IssuerElementFinder issuerFinder(pCertificate); - while ((pIssuerCert = popAnElementFromList(lCertificates, - issuerFinder)) != NULL) { - lSortedCertificates.push_back(pIssuerCert); - issuerFinder.setCert(pIssuerCert); - bFound = true; - } - - if (!bFound || !lCertificates.empty()) { - // well, those certificates don't form a valid chain - LogWarning("Certificates don't form a valid chain"); - lCertificates = lBackup; - m_collectionStatus = COLLECTION_CHAIN_BROKEN; - return; - } - } - - m_certList = lSortedCertificates; - m_collectionStatus = COLLECTION_SORTED; -} -} // namespace ValidationCore - diff --git a/modules/vcore/src/vcore/CertificateCollection.h b/modules/vcore/src/vcore/CertificateCollection.h deleted file mode 100644 index 67b9ce9..0000000 --- a/modules/vcore/src/vcore/CertificateCollection.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _WRT_ENGINE_SRC_VALIDATION_CORE_CERTIFICATECOLLECTION_H_ -#define _WRT_ENGINE_SRC_VALIDATION_CORE_CERTIFICATECOLLECTION_H_ - -#include -#include - -#include - -#include - -namespace ValidationCore { -/* - * This class is used to store Certificate Chain. - * It could serialize chain to std::string in base64 form. - * It could read chain written in base64 form. - * It could check if collection creates certificate chain. - */ - -class CertificateCollection -{ - public: - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, WrongUsage) - }; - - CertificateCollection(); - - typedef CertificateList::const_iterator const_iterator; - - /* - * Remove all certificates from collection. - */ - void clear(); - - /* - * In current implemenation this function MUST success. - * - * This function will add new certificate to collection. - * This function DOES NOT clean collection. - */ - void load(const CertificateList &certList); - - /* - * This function will return false if base64 string is broken - * (is not encoded in base64 format) or one from certificate - * is broken (is not encoded in der format). - * - * This function will add new certificate to collection. - * This function DOES NOT clean collection. - */ - bool load(const std::string &base64); - - /* - * This function will return all certificates from - * collection encoded in base64 format. - */ - std::string toBase64String() const; - - /* - * This will return all certificate from collection. - */ - CertificateList getCertificateList() const; - - /* - * This function will return true if certificates - * in in this structure were sorted and create - * certificate chain. - - * Note: You MUST sort certificates first. - */ - bool isChain() const; - - /* - * This function will return true if all certificate are - * able to create certificate chain. - * - * This function will sort certificates if collection - * is not sorted. - * - * Note: This function will make all iterators invalid. - */ - bool sort(); - - /* - * This function will return Certificate chain. - * - * Note: You MUST sort certificates first and - * check if certificates creates proper chain. - */ - CertificateList getChain() const; - - /* - * It returns size of certificate collection. - */ - inline size_t size() const - { - return m_certList.size(); - } - - /* - * Return true if collection is empty. - */ - inline bool empty() const - { - return m_certList.empty(); - } - - /* - * This will return end iterator to internal collection. - * - * Note: this iterator will lose validity if you call non const - * method on CertificateCollection class. - */ - inline const_iterator begin() const - { - return m_certList.begin(); - } - - /* - * This will return end iterator to internal collection. - * - * Note: this iterator will lose validity if you call non const - * method on CertificateCollection class. - */ - inline const_iterator end() const - { - return m_certList.end(); - } - - /* - * This function will return the last certificate from collection. - * - * Note: There is no point to call this function if certificate - * collection is not sorted! - */ - inline CertificatePtr back() const - { - return m_certList.back(); - } - - protected: - void sortCollection(void); - - enum CollectionStatus - { - // Certificate collection are not sorted in any way - COLLECTION_UNSORTED, - // Certificate collection creates certificate chain - COLLECTION_SORTED, - // Cerfificate collection is not able to create certificate chain - COLLECTION_CHAIN_BROKEN, - }; - - CollectionStatus m_collectionStatus; - CertificateList m_certList; -}; - -typedef std::list CertificateCollectionList; -} // namespace ValidationCore - -#endif // _WRT_ENGINE_SRC_VALIDATION_CORE_CERTIFICATECHAIN_H_ diff --git a/modules/vcore/src/vcore/CertificateConfigReader.cpp b/modules/vcore/src/vcore/CertificateConfigReader.cpp deleted file mode 100644 index 2a61940..0000000 --- a/modules/vcore/src/vcore/CertificateConfigReader.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#include "CertificateConfigReader.h" - -#include - -#include - -namespace { -const std::string XML_EMPTY_NAMESPACE = ""; - -const std::string TOKEN_CERTIFICATE_SET = "CertificateSet"; -const std::string TOKEN_CERTIFICATE_DOMAIN = "CertificateDomain"; -const std::string TOKEN_FINGERPRINT_SHA1 = "FingerprintSHA1"; - -const std::string TOKEN_ATTR_NAME = "name"; -const std::string TOKEN_VALUE_WAC_ROOT = "wacroot"; -const std::string TOKEN_VALUE_WAC_PUBLISHER = "wacpublisher"; -const std::string TOKEN_VALUE_WAC_MEMBER = "wacmember"; -const std::string TOKEN_VALUE_DEVELOPER = "developer"; - -int hexCharToInt(char c) -{ - if (c >= 'a' && c <= 'f') { - return 10 + static_cast(c) - 'a'; - } - if (c >= 'A' && c <= 'F') { - return 10 + static_cast(c) - 'A'; - } - if (c >= '0' && c <= '9') { - return static_cast(c) - '0'; - } - return c; -} -} // anonymous namespace - -namespace ValidationCore { -CertificateConfigReader::CertificateConfigReader() : - m_certificateDomain(0), - m_parserSchema(this) -{ - m_parserSchema.addBeginTagCallback( - TOKEN_CERTIFICATE_SET, - XML_EMPTY_NAMESPACE, - &CertificateConfigReader::blankFunction); - - m_parserSchema.addBeginTagCallback( - TOKEN_CERTIFICATE_DOMAIN, - XML_EMPTY_NAMESPACE, - &CertificateConfigReader::tokenCertificateDomain); - - m_parserSchema.addBeginTagCallback( - TOKEN_FINGERPRINT_SHA1, - XML_EMPTY_NAMESPACE, - &CertificateConfigReader::blankFunction); - - m_parserSchema.addEndTagCallback( - TOKEN_CERTIFICATE_SET, - XML_EMPTY_NAMESPACE, - &CertificateConfigReader::blankFunction); - - m_parserSchema.addEndTagCallback( - TOKEN_CERTIFICATE_DOMAIN, - XML_EMPTY_NAMESPACE, - &CertificateConfigReader::blankFunction); - - m_parserSchema.addEndTagCallback( - TOKEN_FINGERPRINT_SHA1, - XML_EMPTY_NAMESPACE, - &CertificateConfigReader::tokenEndFingerprintSHA1); -} - -void CertificateConfigReader::tokenCertificateDomain(CertificateIdentifier &) -{ - std::string name = m_parserSchema.getReader(). - attribute(TOKEN_ATTR_NAME, SaxReader::THROW_DISABLE); - - if (name.empty()) { - LogWarning("Invalid fingerprint file. Domain name is mandatory"); - ThrowMsg(Exception::InvalidFile, - "Invalid fingerprint file. Domain name is mandatory"); - } else if (name == TOKEN_VALUE_DEVELOPER) { - m_certificateDomain = CertStoreId::DEVELOPER; - } else if (name == TOKEN_VALUE_WAC_ROOT) { - m_certificateDomain = CertStoreId::WAC_ROOT; - } else if (name == TOKEN_VALUE_WAC_PUBLISHER) { - m_certificateDomain = CertStoreId::WAC_PUBLISHER; - } else if (name == TOKEN_VALUE_WAC_MEMBER) { - m_certificateDomain = CertStoreId::WAC_MEMBER; - } -} - -void CertificateConfigReader::tokenEndFingerprintSHA1( - CertificateIdentifier &identificator) -{ - std::string text = m_parserSchema.getText(); - text += ":"; // add guard at the end of fingerprint - Certificate::Fingerprint fingerprint; - int s = 0; - int byteDescLen = 0; - for (size_t i = 0; i < text.size(); ++i) { - if (isxdigit(text[i])) { - s <<= 4; - s += hexCharToInt(text[i]); - byteDescLen++; - if (byteDescLen > 2) { - Assert(0 && "Unsupported fingerprint format in xml file."); - } - } else if (text[i] == ':') { - fingerprint.push_back(static_cast(s)); - s = 0; - byteDescLen = 0; - } else { - Assert(0 && "Unussported fingerprint format in xml file."); - } - } - identificator.add(fingerprint, m_certificateDomain); -} -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/CertificateConfigReader.h b/modules/vcore/src/vcore/CertificateConfigReader.h deleted file mode 100644 index 92e000e..0000000 --- a/modules/vcore/src/vcore/CertificateConfigReader.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#ifndef \ - _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTIFICATE_CONFIG_READER_H_ -#define \ - _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTIFICATE_CONFIG_READER_H_ - -#include -#include - -#include "CertificateIdentifier.h" -#include "CertStoreType.h" -#include "ParserSchema.h" - -namespace ValidationCore { -class CertificateConfigReader -{ - public: - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, InvalidFile) - }; - CertificateConfigReader(); - - void initialize(const std::string &file, - const std::string &scheme) - { - m_parserSchema.initialize(file, true, SaxReader::VALIDATION_XMLSCHEME, - scheme); - } - - void read(CertificateIdentifier &identificator) - { - m_parserSchema.read(identificator); - } - - private: - void blankFunction(CertificateIdentifier &) - { - } - void tokenCertificateDomain(CertificateIdentifier &identificator); - void tokenEndFingerprintSHA1(CertificateIdentifier &identificator); - - CertStoreId::Type m_certificateDomain; - ParserSchema - m_parserSchema; -}; -} // namespace ValidationCore - -#endif // _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTIFICATE_CONFIG_READER_H_ diff --git a/modules/vcore/src/vcore/CertificateIdentifier.h b/modules/vcore/src/vcore/CertificateIdentifier.h deleted file mode 100644 index f9ed48c..0000000 --- a/modules/vcore/src/vcore/CertificateIdentifier.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#ifndef \ - _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTIFICATEIDENTIFICATOR_H_ -#define \ - _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTIFICATEIDENTIFICATOR_H_ - -#include - -#include - -#include "Certificate.h" -#include "CertStoreType.h" - -namespace ValidationCore { -class CertificateIdentifier : public DPL::Noncopyable -{ - public: - typedef std::map FingerPrintMap; - - CertificateIdentifier() - { - } - ~CertificateIdentifier() - { - } - - void add(const Certificate::Fingerprint &fingerprint, - CertStoreId::Type domain) - { - fingerPrintMap[fingerprint].add(domain); - } - - CertStoreId::Set find(const Certificate::Fingerprint &fingerprint) const - { - FingerPrintMap::const_iterator iter = fingerPrintMap.find(fingerprint); - if (iter == fingerPrintMap.end()) { - return CertStoreId::Set(); - } - return iter->second; - } - - CertStoreId::Set find(const CertificatePtr &certificate) const - { - return - find(certificate->getFingerprint(Certificate::FINGERPRINT_SHA1)); - } - - private: - FingerPrintMap fingerPrintMap; -}; -} // namespace ValidationCore - -#endif // _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTIFICATEIDENTIFICATOR_H_ diff --git a/modules/vcore/src/vcore/CertificateLoader.cpp b/modules/vcore/src/vcore/CertificateLoader.cpp deleted file mode 100644 index 3bc50de..0000000 --- a/modules/vcore/src/vcore/CertificateLoader.cpp +++ /dev/null @@ -1,725 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include -#include - -#include "Base64.h" -#include "CertificateLoader.h" -#include "SSLContainers.h" - -namespace { -const int MIN_RSA_KEY_LENGTH = 1024; -//const char *OID_CURVE_SECP256R1 = "urn:oid:1.2.840.10045.3.1.7"; -} // namespace anonymous - -namespace ValidationCore { -//// COMPARATOR CLASS START //// - -//class CertificateLoaderECDSA : public CertificateLoader::CertificateLoaderComparator, DPL::Noncopyable { -//public: -// CertificateLoaderECDSA(const std::string &publicKey) -// : m_ecPublicKey(NULL) -// , m_searchKey(NULL) -// { -// m_bnCtx = BN_CTX_new(); // if fails we can continue anyway -// m_tmpPoint = BN_new(); // if fails we can continue anyway -// m_initialized = CertificateLoader::convertBase64NodeToBigNum(publicKey, &m_searchKey); -// -// if(!m_initialized) -// LogError("Init failed!"); -// } -// -// virtual bool compare(X509 *x509cert){ -// if(!m_initialized) -// return false; -// -// EVP_PKEY_free(m_ecPublicKey); -// -// m_ecPublicKey = X509_get_pubkey(x509cert); -// -// if(m_ecPublicKey == NULL) -// return false; -// -// if(m_ecPublicKey->type != EVP_PKEY_EC){ -// LogError("ecPublicKey has wrong type!"); -// return false; -// } -// -// // Pointer to internal data of ecPublicKey. Do not free! -// EC_KEY *eckey = m_ecPublicKey->pkey.ec; -// -// const EC_POINT *ecpoint = EC_KEY_get0_public_key(eckey); -// const EC_GROUP *ecgroup = EC_KEY_get0_group(eckey); -// -// m_tmpPoint = EC_POINT_point2bn(ecgroup, ecpoint, POINT_CONVERSION_UNCOMPRESSED, m_tmpPoint, m_bnCtx); -// -// if(BN_cmp(m_tmpPoint, m_searchKey) == 0) -// return true; -// -// return false; -// } -// -// ~CertificateLoaderECDSA(){ -// BN_CTX_free(m_bnCtx); -// EVP_PKEY_free(m_ecPublicKey); -// BN_free(m_searchKey); -// BN_free(m_tmpPoint); -// } -// -//private: -// bool m_initialized; -// EVP_PKEY *m_ecPublicKey; -// BN_CTX *m_bnCtx; -// BIGNUM *m_searchKey; -// BIGNUM *m_tmpPoint; -//}; - -///// COMPARETORS CLASS END ///// - -//// COMPARATOR RSA CLASS START //// - -//class CertificateLoaderRSA : public CertificateLoader::CertificateLoaderComparator, DPL::Noncopyable { -//public: -// CertificateLoaderRSA(const std::string &m_modulus,const std::string &m_exponent ) -// : m_rsaPublicKey(NULL) -// , m_modulus_bn(NULL) -// , m_exponent_bn(NULL) -// { -// -// m_initialized_modulus = CertificateLoader::convertBase64NodeToBigNum(m_modulus, &m_modulus_bn); -// m_initialized_exponent = CertificateLoader::convertBase64NodeToBigNum(m_exponent, &m_exponent_bn); -// -// if(!m_initialized_modulus || !m_initialized_exponent) -// LogError("Init failed!"); -// } -// -// virtual bool compare(X509 *x509cert){ -// -// if(!m_initialized_modulus || !m_initialized_exponent) -// return false; -// -// EVP_PKEY_free(m_rsaPublicKey); -// m_rsaPublicKey = X509_get_pubkey(x509cert); -// -// if(m_rsaPublicKey == NULL) -// return false; -// -// if(m_rsaPublicKey->type != EVP_PKEY_RSA){ -// LogInfo("rsaPublicKey has wrong type!"); -// return false; -// } -// -// RSA *rsa = NULL; -// rsa = m_rsaPublicKey->pkey.rsa; -// -// if (BN_cmp(m_modulus_bn, rsa->n) == 0 && -// BN_cmp(m_exponent_bn, rsa->e) == 0 ){ -// LogError ("Compare TRUE"); -// return true; -// } -// return false; -// } -// -// ~CertificateLoaderRSA(){ -// EVP_PKEY_free(m_rsaPublicKey); -// BN_free(m_modulus_bn); -// BN_free(m_exponent_bn); -// -// } -// -//private: -// bool m_initialized_modulus; -// bool m_initialized_exponent; -// EVP_PKEY *m_rsaPublicKey; -// BIGNUM *m_modulus_bn; -// BIGNUM *m_exponent_bn; -//}; - -///// COMPARETORS RSA CLASS END ///// - -CertificateLoader::CertificateLoaderResult CertificateLoader:: - loadCertificateBasedOnExponentAndModulus(const std::string &m_modulus, - const std::string &m_exponent) -{ - (void) m_modulus; - (void) m_exponent; - LogError("Not implemented."); - return UNKNOWN_ERROR; - // if (m_exponent.empty() || m_modulus.empty()) - // return WRONG_ARGUMENTS; - // - // CertificateLoaderRSA comparator(m_modulus,m_exponent); - // - // CertificateLoaderResult result = NO_ERROR; - // for(int i=0; storeId[i]; ++i){ - // result = loadCertificate(std::string(storeId[i]), &comparator); - // - // if(result == ERR_NO_MORE_CERTIFICATES) - // continue; - // - // return result; - // } - // - // return result; -} - -CertificateLoader::CertificateLoaderResult CertificateLoader::loadCertificate( - const std::string &storageName, - CertificateLoader::CertificateLoaderComparator *cmp) -{ - (void) storageName; - (void) cmp; - LogError("Not Implemented"); - return UNKNOWN_ERROR; - // long int result = OPERATION_SUCCESS; - // - // char storeId[CERTMGR_MAX_PLUGIN_ID_SIZE]; - // char type[CERTMGR_MAX_CERT_TYPE_SIZE]; - // certmgr_cert_id certId; - // certmgr_ctx context; - // certmgr_mem_buff certRetrieved; - // unsigned char buffer[CERTMGR_MAX_BUFFER_SIZE]; - // - // certmgr_cert_descriptor descriptor; - // - // certRetrieved.data = buffer; - // certRetrieved.firstFree = 0; - // certRetrieved.size = CERTMGR_MAX_BUFFER_SIZE; - // certId.storeId = storeId; - // certId.type = type; - // - // CERTMGR_INIT_CONTEXT((&context), (sizeof(context))) - // - // strncpy(context.storeId, storageName.c_str(), storageName.size()); - // - // for(certRetrieved.firstFree = 0; - // OPERATION_SUCCESS == (result = certmgr_retrieve_certificate_from_store(&context, &certRetrieved, &certId)); - // certRetrieved.firstFree = 0) - // { - // - // if(OPERATION_SUCCESS!=certmgr_extract_certificate_data(&certRetrieved, &descriptor)){ - // LogError("Extracting Certificate Data failed \n"); - // continue; - // } - // - // const unsigned char *ptr = certRetrieved.data; - // - // X509 *x509cert = d2i_X509(NULL, &ptr, certRetrieved.size); - // if(x509cert == NULL){ - // certmgr_release_certificate_data(&descriptor); - // LogError("Error extracting certificate (d2i_X509)."); - // return UNKNOWN_ERROR; - // } - // - // LogDebug("The subject of this certificate is " << descriptor.mandatory.subject); - // if(cmp->compare(x509cert)){ - // LogDebug("Found match. Coping bytes: " << certRetrieved.size); - // m_certificatePtr = CertificatePtr(new Certificate(certRetrieved)); - // certmgr_release_certificate_data(&descriptor); - // X509_free(x509cert); - // break; - // } - // - // LogDebug("Release"); - // X509_free(x509cert); - // certmgr_release_certificate_data(&descriptor); - // } - // - // if(ERR_NO_MORE_CERTIFICATES == result){ - // LogError("Certificates for given DN not found\n"); - // return CERTIFICATE_NOT_FOUND; - // } - // - // if(result!= OPERATION_SUCCESS){ - // LogError("Certificate Manager Error\n"); - // return UNKNOWN_ERROR; - // } - // - // LogDebug("Exit"); - // return NO_ERROR; -} - -// TODO -CertificateLoader::CertificateLoaderResult CertificateLoader:: - loadCertificateBasedOnSubjectName(const std::string &subjectName) -{ - (void) subjectName; - LogError("Not implemented."); - return UNKNOWN_ERROR; - // if(subjectName.empty()) - // { - // return WRONG_ARGUMENTS; - // } - // - // long int result = OPERATION_SUCCESS; - // - // char storeId[CERTMGR_MAX_PLUGIN_ID_SIZE]; - // char type[CERTMGR_MAX_CERT_TYPE_SIZE]; - // certmgr_cert_id certId; - // certmgr_ctx context; - // certmgr_mem_buff certRetrieved; - // unsigned char buffer[CERTMGR_MAX_BUFFER_SIZE]; - // - // certmgr_cert_descriptor descriptor; - // - // certRetrieved.data = buffer; - // certRetrieved.firstFree = 0; - // certRetrieved.size = CERTMGR_MAX_BUFFER_SIZE; - // certId.storeId = storeId; - // certId.type = type; - // - // CERTMGR_INIT_CONTEXT((&context), (sizeof(context))) - // - // for(certRetrieved.firstFree = 0; - // OPERATION_SUCCESS == (result = certmgr_retrieve_certificate_from_store(&context, &certRetrieved, &certId)); - // certRetrieved.firstFree = 0) - // { - // - // if(OPERATION_SUCCESS!=certmgr_extract_certificate_data(&certRetrieved, &descriptor)){ - // LogError("Extracting Certificate Data failed \n"); - // continue; - // } - // - // if(!strcmp(subjectName.c_str(), descriptor.mandatory.subject)){ - // LogDebug("The subject of this certificate is " << descriptor.mandatory.subject); - // m_certificatePtr = CertificatePtr(new Certificate(certRetrieved)); - // certmgr_release_certificate_data(&descriptor); - // break; - // } - // LogDebug("Release"); - // certmgr_release_certificate_data(&descriptor); - // } - // - // if(ERR_NO_MORE_CERTIFICATES == result) { - // LogError("Certificates for given DN not found\n"); - // return CERTIFICATE_NOT_FOUND; - // } - // if(result!= OPERATION_SUCCESS){ - // LogError("Certificate Manager Error\n"); - // return UNKNOWN_ERROR; - // } - // LogDebug("Exit"); - // return NO_ERROR; -} - -// KW CertificateLoader::CertificateLoaderResult CertificateLoader::loadCertificateBasedOnIssuerName(const std::string &issuerName, const std::string &serialNumber) -// KW { -// KW if(issuerName.empty() || serialNumber.empty()) -// KW { -// KW return WRONG_ARGUMENTS; -// KW } -// KW -// KW if(m_cmBuff.data){ -// KW delete[] m_cmBuff.data; -// KW memset(&m_cmBuff, 0, sizeof(certmgr_mem_buff)); -// KW } -// KW -// KW LogDebug("IssuerName: " << issuerName << " serialNumber: " << serialNumber); -// KW -// KW //used to check status of retrieved certificate -// KW long int result = OPERATION_SUCCESS; -// KW char storeId[CERTMGR_MAX_PLUGIN_ID_SIZE]; -// KW char type[CERTMGR_MAX_CERT_TYPE_SIZE]; -// KW certmgr_cert_id certId; -// KW certmgr_ctx context; -// KW certmgr_mem_buff certRetrieved; -// KW unsigned char buffer[CERTMGR_MAX_BUFFER_SIZE]; -// KW -// KW certmgr_cert_descriptor descriptor; -// KW -// KW certRetrieved.data = buffer; -// KW certRetrieved.firstFree = 0; -// KW certRetrieved.size = CERTMGR_MAX_BUFFER_SIZE; -// KW certId.storeId = storeId; -// KW certId.type = type; -// KW -// KW CERTMGR_INIT_CONTEXT((&context), (sizeof(context))) -// KW -// KW for(certRetrieved.firstFree = 0; -// KW OPERATION_SUCCESS == (result = certmgr_retrieve_certificate_from_store(&context, &certRetrieved, &certId)); -// KW certRetrieved.firstFree = 0) -// KW { -// KW -// KW LogDebug("Extracting certificate from CertMgr"); -// KW -// KW if( OPERATION_SUCCESS != certmgr_extract_certificate_data(&certRetrieved, &descriptor) ){ -// KW LogError("Extracting Certificate Data failed \n"); -// KW continue; -// KW } -// KW -// KW LogDebug("Issuer: " << descriptor.mandatory.issuer); -// KW -// KW const unsigned char *ptr = certRetrieved.data; -// KW char *tmp; -// KW -// KW X509 *x509cert = d2i_X509(NULL, &ptr, certRetrieved.size); -// KW std::string serialNO = std::string(tmp = i2s_ASN1_INTEGER(NULL, X509_get_serialNumber(x509cert))); -// KW OPENSSL_free(tmp); -// KW X509_free(x509cert); -// KW -// KW LogInfo("Certificate number found: " << serialNO); -// KW LogInfo("Certificate number looking for: " << serialNumber); -// KW -// KW if(!strcmp(issuerName.c_str(), descriptor.mandatory.issuer) -// KW && serialNumber == serialNO) -// KW { -// KW LogError("The issuer of this certificate is " << descriptor.mandatory.issuer); -// KW -// KW m_cmBuff.data = new unsigned char[certRetrieved.size]; -// KW m_cmBuff.firstFree = m_cmBuff.size = certRetrieved.size; -// KW memcpy(m_cmBuff.data, certRetrieved.data, certRetrieved.size); -// KW certmgr_release_certificate_data(&descriptor); -// KW break; -// KW } -// KW certmgr_release_certificate_data(&descriptor); -// KW } -// KW -// KW if(ERR_NO_MORE_CERTIFICATES == result) { -// KW LogError("Certificates not found"); -// KW return CERTIFICATE_NOT_FOUND; -// KW } -// KW if(result != OPERATION_SUCCESS){ -// KW LogError("Certificate Manager Error"); -// KW return UNKNOWN_ERROR; -// KW } -// KW return NO_ERROR; -// KW } - -CertificateLoader::CertificateLoaderResult CertificateLoader:: - loadCertificateWithECKEY(const std::string &curveName, - const std::string &publicKey) -{ - (void) curveName; - (void) publicKey; - LogError("Not implemented."); - return UNKNOWN_ERROR; - // if(curveName != OID_CURVE_SECP256R1){ - // LogError("Found field id: " << curveName << " Expected: " << OID_CURVE_SECP256R1); - // return UNSUPPORTED_CERTIFICATE_FIELD; - // } - // - // CertificateLoaderECDSA comparator(publicKey); - // - // CertificateLoaderResult result = NO_ERROR; - // for(int i=0; storeId[i]; ++i){ - // result = loadCertificate(std::string(storeId[i]), &comparator); - // - // if(result == ERR_NO_MORE_CERTIFICATES) - // continue; - // - // return result; - // } - // - // return result; -} - -CertificateLoader::CertificateLoaderResult CertificateLoader:: - loadCertificateFromRawData(const std::string &rawData) -{ - Try { - Base64Decoder base; - base.reset(); - base.append(rawData); - if (!base.finalize()) { - LogWarning("Certificate format is broken."); - return UNKNOWN_ERROR; - } - std::string derCert = base.get(); - m_certificatePtr = CertificatePtr(new Certificate(derCert)); - } Catch(Certificate::Exception::Base) { - LogWarning("Error reading certificate by openssl."); - return UNKNOWN_ERROR; - } - - // Check the key length if sig algorithm is RSA - EVP_PKEY *pKey = X509_get_pubkey(m_certificatePtr->getX509()); - - if (pKey->type == EVP_PKEY_RSA) { - RSA* pRSA = pKey->pkey.rsa; - - if (pRSA) { - int keyLength = RSA_size(pRSA); - - // key Length (modulus) is in bytes - keyLength <<= 3; - LogDebug("RSA key length: " << keyLength << " bits"); - - if (keyLength < MIN_RSA_KEY_LENGTH) { - LogError( - "RSA key too short!" << "Has only " << keyLength << " bits"); - return CERTIFICATE_SECURITY_ERROR; - } - } - } - - return NO_ERROR; -} - -// DEPRACETED FUNCTION -//CertificateLoader::CertificateLoaderResult CertificateLoader::loadCertificateFromRawData(const std::string &rawData) -//{ -// certmgr_mem_buff cmBuff = {0,0,0}; -// -// long int size; -// cmBuff.data = certmgr_util_base64_decode(const_cast(static_cast(rawData.c_str())), rawData.size(), &size); -// -// cmBuff.firstFree = cmBuff.size = size; -// -// certmgr_cert_descriptor descriptor; -// -// long int result = certmgr_extract_certificate_data(&cmBuff, &descriptor); -// -// if (result != OPERATION_SUCCESS) -// { -// LogError("Unable to load certificate"); -// return UNKNOWN_ERROR; -// } -// -// certmgr_release_certificate_data(&descriptor); -// -// m_certificatePtr = CertificatePtr(new Certificate(cmBuff)); -// -// // we have to use temp pointer cause d2i_x509 modifies its input -// const unsigned char* tmpPtr = cmBuff.data; -// X509* pCertificate = d2i_X509(NULL, &tmpPtr, cmBuff.size); -// -// if (pCertificate) -// { -// SSLSmartContainer pX509(pCertificate); -// -// // Check the key length if sig algorithm is RSA -// EVP_PKEY *pKey = X509_get_pubkey(pX509); -// -// if (pKey->type == EVP_PKEY_RSA) -// { -// RSA* pRSA = pKey->pkey.rsa; -// -// if (pRSA) -// { -// int keyLength = RSA_size(pRSA); -// -// // key Length (modulus) is in bytes -// keyLength <<= 3; -// LogDebug("RSA key length: " << keyLength << " bits"); -// -// if (keyLength < MIN_RSA_KEY_LENGTH) -// { -// LogError("RSA key too short!" << "Has only " << keyLength << " bits"); -// return CERTIFICATE_SECURITY_ERROR; -// } -// } -// } -// } -// -// return NO_ERROR; -//} - -CertificateLoader::CertificateLoaderResult CertificateLoader:: - loadCertificateBasedOnDSAComponents(const std::string& strP, - const std::string& strQ, - const std::string& strG, - const std::string& strY, - const std::string& strJ, - const std::string& strSeed, - const std::string& strPGenCounter) -{ - (void) strP; - (void) strQ; - (void) strG; - (void) strY; - (void) strJ; - (void) strSeed; - (void) strPGenCounter; - LogError("Not implemented."); - return UNKNOWN_ERROR; - // (void)strY; - // (void)strJ; - // (void)strSeed; - // (void)strPGenCounter; - // - // long int result = UNKNOWN_ERROR; - // - // char storeId[CERTMGR_MAX_PLUGIN_ID_SIZE]; - // char type[CERTMGR_MAX_CERT_TYPE_SIZE]; - // certmgr_cert_id certId; - // certmgr_ctx context; - // certmgr_mem_buff certRetrieved; - // - // unsigned char buffer[CERTMGR_MAX_BUFFER_SIZE]; - // - // certmgr_cert_descriptor descriptor; - // - // certRetrieved.data = buffer; - // certRetrieved.firstFree = 0; - // certRetrieved.size = CERTMGR_MAX_BUFFER_SIZE; - // certId.storeId = storeId; - // certId.type = type; - // - // CERTMGR_INIT_CONTEXT((&context), (sizeof(context))) - // std::string strStoreType("Operator"); - // strncpy(context.storeId, strStoreType.c_str(), strStoreType.length()); - // - // for (certRetrieved.firstFree = 0; - // OPERATION_SUCCESS == (result = certmgr_retrieve_certificate_from_store(&context, &certRetrieved, &certId)); - // certRetrieved.firstFree = 0) - // { - // - // if (OPERATION_SUCCESS != certmgr_extract_certificate_data(&certRetrieved, &descriptor)) - // { - // LogDebug("unable to retrieve cert from storage"); - // continue; - // } - // - // X509* pCertificate = d2i_X509(NULL, (const unsigned char**) &(certRetrieved.data), certRetrieved.size); - // - // if (pCertificate) - // { - // EVP_PKEY *pKey = X509_get_pubkey(pCertificate); - // - // if (pKey->type == EVP_PKEY_DSA) - // { - // DSA* pDSA = pKey->pkey.dsa; - // - // if (pDSA) - // { - // BIGNUM *pDSApBigNum = NULL, *pDSAqBigNum = NULL, *pDSAgBigNum = NULL; - // - // convertBase64NodeToBigNum(strP, &pDSApBigNum); - // convertBase64NodeToBigNum(strQ, &pDSAqBigNum); - // convertBase64NodeToBigNum(strG, &pDSAgBigNum); - // - // if (pDSApBigNum && pDSAqBigNum && pDSAgBigNum && - // BN_cmp(pDSApBigNum, pDSA->p) == 0 && - // BN_cmp(pDSAqBigNum, pDSA->q) == 0 && - // BN_cmp(pDSAgBigNum, pDSA->g) == 0) - // { - // LogInfo("DSA Certificate found"); - // /* TODO load this certificate to m_cmBuff value */ - // LogError("Not implemented!"); - // - // EVP_PKEY_free(pKey); - // X509_free(pCertificate); - // - // BN_free(pDSApBigNum); - // BN_free(pDSAqBigNum); - // BN_free(pDSAgBigNum); - // - // certmgr_release_certificate_data(&descriptor); - // return NO_ERROR; - // } - // - // if (pDSApBigNum) - // { - // BN_free(pDSApBigNum); - // } - // if (pDSAqBigNum) - // { - // BN_free(pDSAqBigNum); - // } - // if (pDSAgBigNum) - // { - // BN_free(pDSAgBigNum); - // } - // - // } - // EVP_PKEY_free(pKey); - // } - // X509_free(pCertificate); - // } - // else - // LogError("Unable to load certificate"); - // - // certmgr_release_certificate_data(&descriptor); - // } - // - // LogError("No DSA certificate with given parameters"); - // - // return CERTIFICATE_NOT_FOUND; -} - -bool CertificateLoader::convertBase64NodeToBigNum(const std::string& strNode, - BIGNUM** ppBigNum) -{ - (void) strNode; - (void) ppBigNum; - LogError("Not implemented."); - return false; - // if (!ppBigNum || *ppBigNum != NULL) - // { - // LogError("Ptr variable not initialized properly!"); - // return false; - // } - // - // // decode base64 to binary - // long int binBuffLength = 0; - // unsigned char* binBuff = NULL; - // - // binBuff = certmgr_util_base64_decode(const_cast (strNode.c_str()), strNode.length(), &binBuffLength); - // - // if (!binBuff) - // { - // LogError("base64 decode failed"); - // return false; - // } - // - // // convert binary to bignum - // *ppBigNum = BN_bin2bn(binBuff, binBuffLength, *ppBigNum); - // - // free(binBuff); - // - // if (!(*ppBigNum)) - // { - // LogError("Conversion from node to bignum failed"); - // return false; - // } - // - // return true; -} - -// KW bool CertificateLoader::convertBigNumToBase64Node(const BIGNUM* pBigNum, std::string& strNode) -// KW { -// KW if (!pBigNum) -// KW { -// KW LogError("null ptr"); -// KW return false; -// KW } -// KW -// KW int nNumLength = BN_num_bytes(pBigNum); -// KW unsigned char* buffer = new unsigned char[nNumLength + 1]; -// KW -// KW // convert bignum to binary format -// KW if (BN_bn2bin(pBigNum, buffer) < 0) -// KW { -// KW LogError("Conversion from bignum to binary failed"); -// KW delete []buffer; -// KW return false; -// KW } -// KW -// KW char* pBase64Node = NULL; -// KW unsigned long int buffLen = 0; -// KW certmgr_util_base64_encode(buffer, (unsigned long int) nNumLength, &pBase64Node, &buffLen); -// KW -// KW strNode.assign(pBase64Node, buffLen); -// KW -// KW delete []buffer; -// KW return true; -// KW } -} // namespace ValidationCore - diff --git a/modules/vcore/src/vcore/CertificateLoader.h b/modules/vcore/src/vcore/CertificateLoader.h deleted file mode 100644 index 64c38ac..0000000 --- a/modules/vcore/src/vcore/CertificateLoader.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _CERTIFICATELOADER_H_ -#define _CERTIFICATELOADER_H_ - -#include -#include - -#include -#include - -#include - -#include "Certificate.h" - -namespace ValidationCore { -class CertificateLoader : public DPL::Noncopyable -{ - public: - class CertificateLoaderComparator - { - public: - virtual bool compare(X509 *x509cert) = 0; - virtual ~CertificateLoaderComparator() - { - } - }; - - enum CertificateLoaderResult - { - NO_ERROR, - CERTIFICATE_NOT_FOUND, - UNSUPPORTED_CERTIFICATE_FIELD, - WRONG_ARGUMENTS, - CERTIFICATE_SECURITY_ERROR, //!< there are some issues with certificate security (i.e. key too short) - UNKNOWN_ERROR - }; - - CertificateLoader() - { - } - - virtual ~CertificateLoader() - { - } - - CertificateLoaderResult loadCertificate(const std::string& storage, - CertificateLoaderComparator *cmp); - - CertificateLoaderResult loadCertificateBasedOnSubjectName( - const std::string &subjectName); - CertificateLoaderResult loadCertificateBasedOnExponentAndModulus( - const std::string &m_modulus, - const std::string &m_exponent); - // KW CertificateLoaderResult loadCertificateBasedOnIssuerName(const std::string &isserName, - // KW const std::string &serialNumber); - - CertificateLoaderResult loadCertificateFromRawData( - const std::string &rawData); - - CertificateLoaderResult loadCertificateBasedOnDSAComponents( - const std::string& strP, - const std::string& strQ, - const std::string& strG, - const std::string& strY, - const std::string& strJ, - const std::string& strSeed, - const std::string& strPGenCounter); - - CertificateLoaderResult loadCertificateWithECKEY( - const std::string &curveName, - const std::string &publicKey); - - /** - * converts base64 encoded node to SSL bignum - * allocates mem on *ppBigNum, don't forget to free it later with BN_free! - * returns conversion status - */ - static bool convertBase64NodeToBigNum(const std::string& strNode, - BIGNUM** ppBigNum); - - /* - * encodes SSL bignum into base64 octstring - * returns conversion status - */ - // KW static bool convertBigNumToBase64Node(const BIGNUM* pBigNum, std::string& strNode); - - CertificatePtr getCertificatePtr() const - { - return m_certificatePtr; - } - private: - CertificatePtr m_certificatePtr; -}; -} // namespace ValidationCore - -#endif // _CERTIFICATELOADER_H_ diff --git a/modules/vcore/src/vcore/CertificateStorage.h b/modules/vcore/src/vcore/CertificateStorage.h deleted file mode 100644 index 7fbcb6b..0000000 --- a/modules/vcore/src/vcore/CertificateStorage.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef VCORE_SRC_VCORE_CERTIFICATESTORAGE_H -#define VCORE_SRC_VCORE_CERTIFICATESTORAGE_H - -#include -#include - -namespace ValidationCore { -typedef std::list < X509* > X509CertificatesList; -} - -#endif // VCORE_SRC_VCORE_CERTIFICATESTORAGE_H diff --git a/modules/vcore/src/vcore/CertificateVerifier.cpp b/modules/vcore/src/vcore/CertificateVerifier.cpp deleted file mode 100644 index f05662a..0000000 --- a/modules/vcore/src/vcore/CertificateVerifier.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Bartlomiej Grzelewski (b.grzelewski@gmail.com) - * @version 0.1 - * @file CertificateVerifier.cpp - * @brief This class integrates OCSP and CRL. - */ -#include "CertificateVerifier.h" - -#include -#include -#include - -namespace ValidationCore { - -CertificateVerifier::CertificateVerifier(bool enableOcsp, bool enableCrl) -: m_enableOcsp(enableOcsp) -, m_enableCrl(enableCrl) -{} - -VerificationStatus CertificateVerifier::check( - CertificateCollection &certCollection) const -{ - LogDebug("== Certificate collection validation start =="); - Assert(certCollection.isChain() && "Collection must form chain."); - - VerificationStatus statusOcsp; - VerificationStatus statusCrl; - - if (m_enableOcsp) { - statusOcsp = obtainOcspStatus(certCollection); - } else { - statusOcsp = VERIFICATION_STATUS_GOOD; - } - - if (m_enableCrl) { - statusCrl = obtainCrlStatus(certCollection); - } else { - statusCrl = VERIFICATION_STATUS_GOOD; - } - LogDebug("== Certificate collection validation end =="); - return getStatus(statusOcsp, statusCrl); -} - -VerificationStatus CertificateVerifier::obtainOcspStatus( - const CertificateCollection &chain) const -{ - LogDebug("== Obtain ocsp status =="); - CachedOCSP ocsp; - return ocsp.check(chain); -} - -VerificationStatus CertificateVerifier::obtainCrlStatus( - const CertificateCollection &chain) const -{ - LogDebug("== Obtain crl status =="); - CachedCRL crl; - return crl.check(chain); -} - -VerificationStatus CertificateVerifier::getStatus( - VerificationStatus ocsp, - VerificationStatus crl) const -{ - if (ocsp == VERIFICATION_STATUS_REVOKED || - crl == VERIFICATION_STATUS_REVOKED) - { - LogDebug("Return status: REVOKED"); - return VERIFICATION_STATUS_REVOKED; - } - - if (ocsp == VERIFICATION_STATUS_GOOD) { - LogDebug("Return status: GOOD"); - return VERIFICATION_STATUS_GOOD; - } - - if (ocsp == VERIFICATION_STATUS_UNKNOWN) { - LogDebug("Return status: UNKNOWN"); - return VERIFICATION_STATUS_UNKNOWN; - } - - if (ocsp == VERIFICATION_STATUS_NOT_SUPPORT) { - LogDebug("Return status: NOT_SUPPORT"); - return VERIFICATION_STATUS_GOOD; - } - - LogDebug("Return status: ERROR"); - return VERIFICATION_STATUS_ERROR; -} - -VerificationStatus CertificateVerifier::checkEndEntity( - CertificateCollectionList &collectionList) const -{ - VerificationStatusSet statusOcsp; - VerificationStatusSet statusCrl; - - if (m_enableOcsp) { - CachedOCSP ocsp; - FOREACH(it, collectionList){ - statusOcsp.add(ocsp.checkEndEntity(*it)); - } - } else { - statusOcsp.add(VERIFICATION_STATUS_GOOD); - } - - if (m_enableCrl) { - CachedCRL crl; - FOREACH(it, collectionList){ - statusCrl.add(crl.checkEndEntity(*it)); - } - } else { - statusCrl.add(VERIFICATION_STATUS_GOOD); - } - LogDebug("== Certificate collection validateion end =="); - return getStatus(statusOcsp.convertToStatus(), statusCrl.convertToStatus()); -} - -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/CertificateVerifier.h b/modules/vcore/src/vcore/CertificateVerifier.h deleted file mode 100644 index ea77812..0000000 --- a/modules/vcore/src/vcore/CertificateVerifier.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Bartlomiej Grzelewski (b.grzelewski@gmail.com) - * @version 0.1 - * @file CertificateVerifier.h - * @brief This class integrates OCSP and CRL into one module. - */ -#ifndef _SRC_VALIDATION_CORE_CERTIFICATE_VERIFIER_H_ -#define _SRC_VALIDATION_CORE_CERTIFICATE_VERIFIER_H_ - -#include "Certificate.h" -#include "CertificateCollection.h" -#include "CachedCRL.h" -#include "CachedOCSP.h" -#include "VerificationStatus.h" - -namespace ValidationCore { - -class CertificateVerifier { - public: - explicit CertificateVerifier(bool enableOcsp, bool enableCrl); - ~CertificateVerifier(){} - - /* - * Run OCSP and CRL for all certificates in collection. - * Collection must represent chain. - * - * Evaluate status. This function converts ocsp status set - * into one status - the most restricted. This one ocsp status - * and status from crl is evaluated to end result. - * - * Algorithm to evaluate result is represented in table: - * - * +--------------+-------+-------+-------+------------+---------+ - * | OCSP |Good |Revoked|Unknown|Undetermined|Not | - * | | | | | |supported| - * | CRL | | | | | | - * +--------------+-------+-------+-------+------------+---------+ - * | GOOD |GOOD |Revoked|Unknown|Undetermined|Good | - * +--------------+-------+-------+-------+------------+---------+ - * | REVOKED |Revoked|Revoked|Revoked|Revoked |Revoked | - * +--------------+-------+-------+-------+------------+---------+ - * | UNDETERMINED |Good |Revoked|Unknown|Undetermined|Good | - * +--------------+-------+-------+-------+------------+---------+ - * | Not supported|Good |Revoked|Unknown|Undetermined|Good | - * +--------------+-------+-------+-------+------------+---------+ - * - * As Undetermind function returns VERIFICATION_STATUS_ERROR. - */ - - VerificationStatus check(CertificateCollection &certCollection) const; - - VerificationStatus checkEndEntity( - CertificateCollectionList &certCollectionList) const; - - private: - VerificationStatus obtainOcspStatus( - const CertificateCollection &chain) const; - VerificationStatus obtainCrlStatus( - const CertificateCollection &chain) const; - VerificationStatus getStatus(VerificationStatus ocsp, - VerificationStatus crl) const; - - bool m_enableOcsp; - bool m_enableCrl; -}; - -} // namespace ValidationCore - -#endif // _SRC_VALIDATION_CORE_CERTIFICATE_VERIFIER_H_ - diff --git a/modules/vcore/src/vcore/Config.cpp b/modules/vcore/src/vcore/Config.cpp deleted file mode 100644 index 7dfaedf..0000000 --- a/modules/vcore/src/vcore/Config.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Config.h" - -#include -IMPLEMENT_SINGLETON(ValidationCore::Config) diff --git a/modules/vcore/src/vcore/Config.h b/modules/vcore/src/vcore/Config.h deleted file mode 100644 index 0783cd1..0000000 --- a/modules/vcore/src/vcore/Config.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _SRC_VALIDATION_CORE_VALIDATION_CORE_CONFIG_H_ -#define _SRC_VALIDATION_CORE_VALIDATION_CORE_CONFIG_H_ - -#include - -#include - -namespace ValidationCore { -class Config { -public: - /* - * Set path to config file with certificate description. - */ - bool setXMLConfigPath(const std::string& path) { - if (!m_certificateXMLConfigPath.empty()) { - return false; - } - m_certificateXMLConfigPath = path; - return true; - } - - /* - * Set path to schema of config file. - */ - bool setXMLSchemaPath(const std::string& path) { - if (!m_certificateXMLSchemaPath.empty()) { - return false; - } - m_certificateXMLSchemaPath = path; - return true; - } - - /* - * Set path to database with OCSP/CRL Cache. - */ - bool setDatabasePath(const std::string& path) { - if (!m_databasePath.empty()) { - return false; - } - m_databasePath = path; - return true; - } - - /* - * Get path to config file with certificate description. - */ - std::string getXMLConfigPath() { - return m_certificateXMLConfigPath; - } - - /* - * Get path to schema of config file. - */ - std::string getXMLSchemaPath() { - return m_certificateXMLSchemaPath; - } - - /* - * Get path to database with OCSP/CRL Cache. - */ - std::string getDatabasePath() { - return m_databasePath; - } - -private: - std::string m_certificateXMLConfigPath; - std::string m_certificateXMLSchemaPath; - std::string m_databasePath; -}; - -typedef DPL::Singleton ConfigSingleton; - -} // namespace ValidationCore - -#endif // _SRC_VALIDATION_CORE_VALIDATION_CORE_CONFIG_H_ - diff --git a/modules/vcore/src/vcore/Database.cpp b/modules/vcore/src/vcore/Database.cpp deleted file mode 100644 index 6d363af..0000000 --- a/modules/vcore/src/vcore/Database.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file webruntime_database.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file contains the definition of webruntime database - */ -#include "Database.h" - -#include -#include -#include - -#include "Config.h" - -const char* VCoreDatabaseConnectionTraits::Address() -{ - /* This function should be fixed but some changes in - * dpl are required. - */ -// return ValidationCore::VCConfigSingleton::Instance(). -// getDatabasePath().c_str(); - - LogWarning( - "VCore will use hardcoded path for database: /opt/dbspace/.vcore.db"); - return "/opt/dbspace/.vcore.db"; -} - -DPL::Mutex g_vcoreDbQueriesMutex; diff --git a/modules/vcore/src/vcore/Database.h b/modules/vcore/src/vcore/Database.h deleted file mode 100644 index 7c30bc1..0000000 --- a/modules/vcore/src/vcore/Database.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file webruntime_database.h - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of webruntime database - */ -#ifndef VCORE_SRC_VCORE_DATABASE_H -#define VCORE_SRC_VCORE_DATABASE_H - -#include -#include -#include -#include - -struct VCoreDatabaseConnectionTraits -{ - static const char *Address(); - - static DPL::DB::SqlConnection::Flag::Type Flags() - { - return DPL::DB::SqlConnection::Flag::UseLucene; - } -}; - -extern DPL::Mutex g_vcoreDbQueriesMutex; - -#define VCORE_DB_INTERNAL(tlsCommand, InternalType, interface) \ - static DPL::ThreadLocalVariable *tlsCommand ## Ptr = NULL; \ - { \ - DPL::Mutex::ScopedLock lock(&g_vcoreDbQueriesMutex); \ - if (!tlsCommand ## Ptr) { \ - static DPL::ThreadLocalVariable tmp; \ - tlsCommand ## Ptr = &tmp; \ - } \ - } \ - DPL::ThreadLocalVariable &tlsCommand = *tlsCommand ## Ptr; \ - if (tlsCommand.IsNull()) { tlsCommand = InternalType(interface); } - -#define VCORE_DB_SELECT(name, type, interface) \ - VCORE_DB_INTERNAL(name, type::Select, interface) - -#define VCORE_DB_INSERT(name, type, interface) \ - VCORE_DB_INTERNAL(name, type::Insert, interface) - -#define VCORE_DB_UPDATE(name, type, interface) \ - VCORE_DB_INTERNAL(name, type::Update, interface) - -#define VCORE_DB_DELETE(name, type, interface) \ - VCORE_DB_INTERNAL(name, type::Delete, interface) - -#endif // define VCORE_SRC_VCORE_DATABASE_H diff --git a/modules/vcore/src/vcore/DeveloperModeValidator.cpp b/modules/vcore/src/vcore/DeveloperModeValidator.cpp deleted file mode 100644 index 7c30d49..0000000 --- a/modules/vcore/src/vcore/DeveloperModeValidator.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file DeveloperModeValidator.cpp - * @author Bartosz Janiak (b.janiak@samsung.com) - * @version 1.0 - * @brief DeveloperModeValidatorValidator - implementing WAC 2.0 spec, including TargetRestriction - */ - -#include "DeveloperModeValidator.h" -#include -#include -#include -#include -#include - -namespace ValidationCore { - -DeveloperModeValidator::DeveloperModeValidator(bool complianceMode, - const std::string& fakeIMEI, - const std::string& fakeMEID): - m_complianceModeEnabled(complianceMode), - m_fakeIMEI(fakeIMEI), - m_fakeMEID(fakeMEID) -{ -} - -void DeveloperModeValidator::check(const SignatureData &data) -{ - LogDebug("entered"); - const SignatureData::IMEIList& IMEIList = data.getIMEIList(); - const SignatureData::MEIDList& MEIDList = data.getMEIDList(); - - if (IMEIList.empty() && MEIDList.empty()) { - LogDebug("No TargetRestriction in signature."); - return; - } - - if (!IMEIList.empty()) { - std::string phoneIMEIString = m_fakeIMEI; - if (!m_complianceModeEnabled) { - LogDebug("Compilance Mode is not enabled"); - DPL::ScopedFree phoneIMEI( - vconf_get_str(VCONFKEY_TELEPHONY_IMEI)); - if (!phoneIMEI.Get()) { - ThrowMsg(Exception::NoTargetRestrictionSatisfied, - "Unable to get phone IMEI from vconf."); - } - phoneIMEIString = phoneIMEI.Get(); - } - - LogDebug("Phone IMEI: " << phoneIMEIString); - if (IMEIList.end() == - std::find(IMEIList.begin(), IMEIList.end(), phoneIMEIString)) - { - Throw(Exception::NoTargetRestrictionSatisfied); - } - } - - if (!MEIDList.empty()) { - std::string phoneMEIDString = m_fakeMEID; - if (!m_complianceModeEnabled) - { - TelMiscSNInformation phoneInfo; - if (TAPI_API_SUCCESS != - tel_get_misc_me_sn(TAPI_MISC_ME_MEID, &phoneInfo)) - { - ThrowMsg(Exception::NoTargetRestrictionSatisfied, - "Unable to get phone MEID from Tapi service."); - } - phoneMEIDString = reinterpret_cast(phoneInfo.szNumber); - } - - LogDebug("Phone MEID: " << phoneMEIDString); - if (MEIDList.end() == - std::find(MEIDList.begin(), MEIDList.end(), phoneMEIDString)) - { - Throw(Exception::NoTargetRestrictionSatisfied); - } - } - LogDebug("exit: ok"); -} - -} //ValidationCore diff --git a/modules/vcore/src/vcore/DeveloperModeValidator.h b/modules/vcore/src/vcore/DeveloperModeValidator.h deleted file mode 100644 index a99076c..0000000 --- a/modules/vcore/src/vcore/DeveloperModeValidator.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file DeveloperModeValidator.h - * @author Bartosz Janiak (b.janiak@samsung.com) - * @version 1.0 - * @brief DeveloperModeValidatorValidator - implementing WAC 2.0 spec, including TargetRestriction - */ - -#ifndef \ - WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_DEVELOPER_MODE_VALIDATOR_H -#define \ - WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_DEVELOPER_MODE_VALIDATOR_H - -#include -#include -#include "SignatureData.h" - -namespace ValidationCore { - -class DeveloperModeValidator -{ - public: - explicit DeveloperModeValidator(bool complianceMode = false, - const std::string &fakeIMEI = "", - const std::string &fakeMEID = ""); - - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, UnableToLoadTestCertificate) - DECLARE_EXCEPTION_TYPE(Base, NoTargetRestrictionSatisfied) - }; - - void check(const SignatureData &data); - private: - bool m_complianceModeEnabled; - std::string m_fakeIMEI; - std::string m_fakeMEID; -}; - -} -#endif /* WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_DEVELOPER_MODE_VALIDATOR_H */ - diff --git a/modules/vcore/src/vcore/IAbstractResponseCache.h b/modules/vcore/src/vcore/IAbstractResponseCache.h deleted file mode 100644 index 38a6fa8..0000000 --- a/modules/vcore/src/vcore/IAbstractResponseCache.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * - * @file AbstractResponseCache.h - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 0.1 - * @brief Common interface for OCSP/CRL caches - */ - -#ifndef _SRC_VALIDATION_CORE_IABSTRACT_RESPONSE_CACHE_H_ -#define _SRC_VALIDATION_CORE_IABSTRACT_RESPONSE_CACHE_H_ - -#include "Certificate.h" -#include "CertificateCollection.h" -#include "VerificationStatus.h" - -namespace ValidationCore { - -class IAbstractResponseCache { - public: - virtual VerificationStatus check(const CertificateCollection &certs) = 0; - virtual VerificationStatus checkEndEntity(CertificateCollection &certs) = 0; - virtual void updateCache() = 0; - - virtual ~IAbstractResponseCache() - { - } -}; - -} // namespace ValidationCore - -#endif /* _SRC_VALIDATION_CORE_IABSTRACT_RESPONSE_CACHE_H_ */ diff --git a/modules/vcore/src/vcore/OCSP.cpp b/modules/vcore/src/vcore/OCSP.cpp deleted file mode 100644 index d276b87..0000000 --- a/modules/vcore/src/vcore/OCSP.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Tomasz Morawski(t.morawski@samsung.com) - * @author Michal Ciepielski(m.ciepielski@samsung.com) - * @author Piotr Marcinkiewicz(p.marcinkiew@samsung.com) - * @version 0.4 - * @file OCPS.cpp - * @brief Routines for certificate validation over OCSP - */ - -#include "OCSP.h" - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include "Certificate.h" -#include "SoupMessageSendSync.h" - -extern "C" { -// This function is needed to fix "Invalid conversion from void* -// to unsigned char*" C++ compiler error during calling -// i2d_OCSP_REQUEST_bio macro - extern bool convertToBuffer(OCSP_REQUEST* req, - char** buf, - int* size); -} - -namespace { -const int ConnectionTimeoutInSeconds = 6; -const int ConnectionRetryCount = 5; - -//! Maximum leeway in validity period in seconds: default 1 day -//! (@see checkRevocationStatus function code) - -//! Maximum validity time for revocation status (1 day) -const int MaxValidatyPeriodInSeconds = 24 * 60 * 60; - -//! Max age (@see checkRevocationStatus function code) -const int MaxAge = -1; -} - -namespace ValidationCore { - -const char* OCSP::DEFAULT_RESPONDER_URI_ENV = "OCSP_DEFAULT_RESPONDER_URI"; - -OCSP::DigestAlgorithmMap createDigestAlgMap() -{ - OCSP::DigestAlgorithmMap mDigestAlg = OCSP::DigestAlgorithmMap(); - - mDigestAlg.insert(std::make_pair(OCSP::SHA1, EVP_sha1())); - mDigestAlg.insert(std::make_pair(OCSP::SHA224, EVP_sha224())); - mDigestAlg.insert(std::make_pair(OCSP::SHA256, EVP_sha256())); - mDigestAlg.insert(std::make_pair(OCSP::SHA384, EVP_sha384())); - mDigestAlg.insert(std::make_pair(OCSP::SHA512, EVP_sha512())); - - return mDigestAlg; -} - -OCSP::DigestAlgorithmMap OCSP::m_sDigestAlgMap = createDigestAlgMap(); - -OCSP::OCSP() : - /* Upgrade of openssl is required to support sha256 */ - // m_pCertIdDigestAlg(EVP_sha256()), - // m_pRequestDigestAlg(EVP_sha256()), - m_pCertIdDigestAlg(EVP_sha1()), - m_pRequestDigestAlg(EVP_sha1()), - m_bUseNonce(false), - m_bUseDefResponder(false), - m_bSignRequest(false), - m_pSignKey(0) -{ -} - -SoupWrapper::SoupMessageSendBase::RequestStatus OCSP::sendOcspRequest( - OCSP_REQUEST* argRequest, - const DPL::OptionalString& argUri) -{ - using namespace SoupWrapper; - // convert OCSP_REQUEST to memory buffer - std::string url = DPL::ToUTF8String(*argUri); - char* requestBuffer; - int requestSizeInt; - if (!convertToBuffer(argRequest, &requestBuffer, &requestSizeInt)) { - ThrowMsg(OCSP::Exception::VerificationError, - "OCSP: failed to convert OCSP_REQUEST to mem buffer"); - } - - Assert(requestSizeInt >= 0); - - SoupMessageSendBase::MessageBuffer buffer; - buffer.resize(requestSizeInt); - memcpy(&buffer[0], requestBuffer, requestSizeInt); - free(requestBuffer); - - char *cport = 0,*chost = 0,*cpath = 0; - int use_ssl = 0; - - if (!OCSP_parse_url(const_cast(url.c_str()), - &chost, - &cport, - &cpath, - &use_ssl)) - { - LogWarning("Error in OCSP_parse_url"); - return SoupMessageSendBase::REQUEST_STATUS_CONNECTION_ERROR; - } - - std::string host = chost; - - if (cport) { - host += ":"; - host += cport; - } - - free(cport); - free(chost); - free(cpath); - - m_soupMessage.setHost(url); - m_soupMessage.setHeader("Host", host); - m_soupMessage.setRequest(std::string("application/ocsp-request"), - buffer); - - return m_soupMessage.sendSync(); -} - -ValidationCore::VerificationStatusSet OCSP::validateCertificateList( - const CertificateList &certs) -{ - VerificationStatusSet statusSet; - - if (certs.size() < 2) { - // no certificates to verify, just return a error - LogWarning("No validation will be proceed. OCSP require at" - " least 2 certificates in chain. Found only " << - certs.size()); - statusSet.add(VERIFICATION_STATUS_ERROR); - return statusSet; - } - - CertificateList::const_iterator iter = certs.begin(); - CertificateList::const_iterator parent = iter; - - time_t minValidity = 0; - for (++parent; parent != certs.end(); ++iter, ++parent) { - LogDebug("Certificate validation (CN:" << - (*iter)->getCommonName() << ")"); - statusSet.add(validateCertificate(*iter, *parent)); - if ((0 == minValidity || minValidity > m_responseValidity) && - m_responseValidity > 0) - { - minValidity = m_responseValidity; - } - } - m_responseValidity = minValidity; - - return statusSet; -} - -VerificationStatus OCSP::checkEndEntity( - const CertificateCollection &chain) -{ - const char *defResponderURI = getenv(OCSP::DEFAULT_RESPONDER_URI_ENV); - - VerificationStatusSet verSet; - if (defResponderURI) { - setUseDefaultResponder(true); - setDefaultResponder(defResponderURI); - } - - // this is temporary fix. it must be rewriten - CertificateList clst; - if (chain.isChain() && chain.size() >= 2) { - CertificateList::const_iterator icert = chain.begin(); - clst.push_back(*icert); - ++icert; - clst.push_back(*icert); - } - verSet += validateCertificateList(clst); - - return verSet.convertToStatus(); -} - -VerificationStatus OCSP::validateCertificate(CertificatePtr argCert, - CertificatePtr argIssuer) -{ - using namespace SoupWrapper; - - Assert(!!argCert); - Assert(!!argIssuer); - - Try { - DPL::OptionalString uri; - - if (!m_bUseDefResponder) { - uri = argCert->getOCSPURL(); - if (!uri) { - return VERIFICATION_STATUS_NOT_SUPPORT; - } - } else { - if (m_strResponderURI.empty()) { - ThrowMsg(Exception::VerificationError, - "Default responder is not set"); - } - LogWarning("Default responder will be used"); - - uri = m_strResponderURI; - } - - // creates a request - CreateRequestResult newRequest = createRequest(argCert, argIssuer); - if (!newRequest.success) { - ThrowMsg(Exception::VerificationError, "Request creation failed"); - } - - // SSLSmartContainer certIdCont(certId); - // this smart ptr is commented out in purpose. request - // manages certIdmemory (which was done in createRequest above) - SSLSmartContainer requestCont(newRequest.ocspRequest); - - SoupMessageSendBase::RequestStatus requestStatus; - requestStatus = sendOcspRequest(requestCont, uri); - - if (requestStatus != SoupMessageSendBase::REQUEST_STATUS_OK) { - return VERIFICATION_STATUS_CONNECTION_FAILED; - } - - // Response is m_soupMessage, convert it to OCSP_RESPONSE - OcspResponse response = convertToResponse(); - - if (!response.first) { - ThrowMsg(OCSP::Exception::VerificationError, - "OCSP: failed to convert mem buffer to OCSP_RESPONSE"); - } - - SSLSmartContainer responseCont(response.second); - // verify response eg. check response status, - // validate responder certificate - validateResponse(requestCont, - responseCont, - newRequest.ocspCertId); - } Catch(Exception::ConnectionError) { - LogWarning("OCSP: ConnectionError"); - return VERIFICATION_STATUS_CONNECTION_FAILED; - } Catch(Exception::CertificateRevoked) { - LogWarning("OCSP: Revoked"); - return VERIFICATION_STATUS_REVOKED; - } Catch(Exception::CertificateUnknown) { - LogWarning("OCSP: Unknown"); - return VERIFICATION_STATUS_UNKNOWN; - } Catch(Exception::VerificationError) { - LogWarning("OCSP: Verification error"); - return VERIFICATION_STATUS_VERIFICATION_ERROR; - } Catch(Exception::Base) { - LogWarning("OCSP: Error"); - return VERIFICATION_STATUS_ERROR; - } - LogWarning("OCSP: Good"); - return VERIFICATION_STATUS_GOOD; -} - -OCSP::CreateRequestResult OCSP::createRequest(CertificatePtr argCert, - CertificatePtr argIssuer) -{ - OCSP_REQUEST* newRequest = OCSP_REQUEST_new(); - - if (!newRequest) { - LogWarning("OCSP: Failed to create a request"); - return CreateRequestResult(); - } - - SSLSmartContainer requestCont(newRequest); - - OCSP_CERTID* certId = addSerial(argCert, argIssuer); - - if (!certId) { - LogWarning("OCSP: Unable to create a serial id"); - return CreateRequestResult(); - } - SSLSmartContainer certIdCont(certId); - - // Inserting certificate ID to request - if (!OCSP_request_add0_id(requestCont, certIdCont)) { - LogWarning("OCSP: Unable to create a certificate id"); - return CreateRequestResult(); - } - - if (m_bUseNonce) { - OCSP_request_add1_nonce(requestCont, 0, -1); - } - - if (m_bSignRequest) { - if (!m_pSignCert || !m_pSignKey) { - LogWarning("OCSP: Unable to sign request if " - "SignCert or SignKey was not set"); - return CreateRequestResult(); - } - - if (!OCSP_request_sign(requestCont, - m_pSignCert->getX509(), - m_pSignKey, - m_pRequestDigestAlg, - 0, - 0)) - { - LogWarning("OCSP: Unable to sign request"); - return CreateRequestResult(); - } - } - return CreateRequestResult(true, - requestCont.DetachPtr(), - certIdCont.DetachPtr()); -} - -OCSP_CERTID* OCSP::addSerial(CertificatePtr argCert, - CertificatePtr argIssuer) -{ - X509_NAME* iname = X509_get_subject_name(argIssuer->getX509()); - ASN1_BIT_STRING* ikey = X509_get0_pubkey_bitstr(argIssuer->getX509()); - ASN1_INTEGER* serial = X509_get_serialNumber(argCert->getX509()); - - return OCSP_cert_id_new(m_pCertIdDigestAlg, iname, ikey, serial); -} - -void OCSP::setDigestAlgorithmForCertId(DigestAlgorithm alg) -{ - DigestAlgorithmMap::const_iterator cit = m_sDigestAlgMap.find(alg); - - if (cit != m_sDigestAlgMap.end()) { - m_pCertIdDigestAlg = cit->second; - } else { - LogDebug("Request for unsupported CertId digest algorithm" - "ignored!"); - } -} - -void OCSP::setDigestAlgorithmForRequest(DigestAlgorithm alg) -{ - DigestAlgorithmMap::const_iterator cit = m_sDigestAlgMap.find(alg); - - if (cit != m_sDigestAlgMap.end()) { - m_pRequestDigestAlg = cit->second; - } else { - LogDebug("Request for unsupported OCSP request digest algorithm" - "ignored!"); - } -} - -void OCSP::setTrustedStore(const CertificateList& certs) -{ - X509_STORE *store = X509_STORE_new(); - m_pTrustedStore = store; - // create a trusted store basing on certificate chain from a signature - FOREACH(iter, certs) { - X509_STORE_add_cert(store, (*iter)->getX509()); - } -} - -void OCSP::validateResponse(OCSP_REQUEST* argRequest, - OCSP_RESPONSE* argResponse, - OCSP_CERTID* argCertId) -{ - int result = OCSP_response_status(argResponse); - - if (result != OCSP_RESPONSE_STATUS_SUCCESSFUL) { - handleInvalidResponse(result); - ThrowMsg(Exception::VerificationError, "OCSP_response_status failed"); - } - - // get response object - OCSP_BASICRESP* basic = OCSP_response_get1_basic(argResponse); - if (!basic) { - ThrowMsg(Exception::VerificationError, - "OCSP: Unable to get a BASICRESP object."); - } - - SSLSmartContainer basicRespCont(basic); - if (m_bUseNonce && OCSP_check_nonce(argRequest, basicRespCont) <= 0) { - ThrowMsg(Exception::VerificationError, "OCSP: Invalid nonce"); - } - - if (!verifyResponse(basic)) { - ThrowMsg(Exception::VerificationError, - "Unable to verify the OCSP responder's certificate"); - } - - checkRevocationStatus(basicRespCont, argCertId); -} - -bool OCSP::verifyResponse(OCSP_BASICRESP* basic) -{ - Assert(m_pTrustedStore); - // verify ocsp response - int response = OCSP_basic_verify(basic, NULL, m_pTrustedStore, 0); - if (response <= 0) { - LogWarning("OCSP verification failed"); - } - - return response > 0; -} - -void OCSP::checkRevocationStatus(OCSP_BASICRESP* basic, - OCSP_CERTID* id) -{ - ASN1_GENERALIZEDTIME* producedAt; - ASN1_GENERALIZEDTIME* thisUpdate; - ASN1_GENERALIZEDTIME* nextUpdate; - int reason; - int status; - - m_responseValidity = 0; - - if (!OCSP_resp_find_status(basic, - id, - &status, - &reason, - &producedAt, - &thisUpdate, - &nextUpdate)) - { - ThrowMsg(Exception::VerificationError, - "OCSP: Failed to find certificate status."); - } - - if (!OCSP_check_validity(thisUpdate, - nextUpdate, - MaxValidatyPeriodInSeconds, - MaxAge)) - { - ThrowMsg(Exception::VerificationError, - "OCSP: Failed to check certificate validate."); - } - - if (nextUpdate) { - asn1GeneralizedTimeToTimeT(nextUpdate,&m_responseValidity); - time_t now; - time(&now); - LogDebug("Time of next OCSP update got from server: " << - m_responseValidity); - LogDebug("Expires in: " << (m_responseValidity - now)); - LogDebug("Original: " << nextUpdate->data); - } - - switch (status) { - case V_OCSP_CERTSTATUS_GOOD: - return; - case V_OCSP_CERTSTATUS_REVOKED: - ThrowMsg(Exception::CertificateRevoked, "Certificate is Revoked"); - case V_OCSP_CERTSTATUS_UNKNOWN: - ThrowMsg(Exception::CertificateUnknown, "Certificate is Unknown"); - default: - Assert(false && "Invalid status"); - } -} - -OCSP::OcspResponse OCSP::convertToResponse() -{ - using namespace SoupWrapper; - - // convert memory buffer to ocsp response object - BUF_MEM res_bmem; - OCSP_RESPONSE* response; - - SoupMessageSendBase::MessageBuffer buffer = m_soupMessage.getResponse(); - - res_bmem.length = buffer.size(); - res_bmem.data = &buffer[0]; - res_bmem.max = buffer.size(); - - BIO* res_mem_bio = BIO_new(BIO_s_mem()); - BIO_set_mem_buf(res_mem_bio, &res_bmem, BIO_NOCLOSE); - - response = d2i_OCSP_RESPONSE_bio(res_mem_bio, NULL); - BIO_free_all(res_mem_bio); - - if (!response) { - LogWarning("OCSP: Failed to convert OCSP Response to DER format"); - return std::make_pair(false, static_cast(NULL)); - } - - return std::make_pair(true, response); -} - -void OCSP::handleInvalidResponse(int result) -{ - switch (result) { - case OCSP_RESPONSE_STATUS_MALFORMEDREQUEST: - LogWarning("OCSP: Server returns " - "OCSP_RESPONSE_STATUS_MALFORMEDREQUEST status"); - break; - case OCSP_RESPONSE_STATUS_INTERNALERROR: - LogWarning("OCSP: Server returns " - "OCSP_RESPONSE_STATUS_INTERNALERROR status"); - break; - case OCSP_RESPONSE_STATUS_TRYLATER: - LogWarning("OCSP: Server returns " - "OCSP_RESPONSE_STATUS_TRYLATER status"); - break; - case OCSP_RESPONSE_STATUS_SIGREQUIRED: - LogWarning("OCSP: Server returns " - "OCSP_RESPONSE_STATUS_SIGREQUIRED status"); - break; - case OCSP_RESPONSE_STATUS_UNAUTHORIZED: - LogWarning("OCSP: Server returns " - "OCSP_RESPONSE_STATUS_UNAUTHORIZED status"); - break; - default: - Assert(false && "Invalid result value"); - } -} -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/OCSP.h b/modules/vcore/src/vcore/OCSP.h deleted file mode 100644 index 5f60da0..0000000 --- a/modules/vcore/src/vcore/OCSP.h +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Tomasz Morawski(t.morawski@samsung.com) - * @author Michal Ciepielski(m.ciepielski@samsung.com) - * @author Piotr Marcinkiewicz(p.marcinkiew@samsung.com) - * @version 0.4 - * @file OCPS.h - * @brief Routines for certificate validation over OCSP - */ - -#ifndef WRT_ENGINE_SRC_VALIDATION_CORE_ENGINE_OCSP_H_ -#define WRT_ENGINE_SRC_VALIDATION_CORE_ENGINE_OCSP_H_ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "OCSPCertMgrUtil.h" -#include "CertificateCollection.h" -#include "CertificateStorage.h" -#include "VerificationStatus.h" -#include "SSLContainers.h" - -#include "SoupMessageSendBase.h" -#include "SoupMessageSendSync.h" -/* - * The WRT MUST NOT allow installation of widgets with revoked signatures. - * - * The WRT MUST NOT allow use of widgets with revoked signatures. - * - * The WRT MUST support checking for revocation of widget signatures via - * OCSP [RFC 2560] at widget installation time, according to the following: - * - * At widget installation time, the WRT shall make several attempts - * (5 attempts at 6 seconds apart recommended) to establish contact with - * the OCSP server. - * - * If connectivity is successful and the application is validated, the - * installation process shall continue. - * - * If connectivity is successful and if the widget signature is - * determined to be revoked, the WRT shall issue a suitable error message - * and cancel installation. - * - * If connectivity is successful and revocation status is unknown or if - * connectivity is unsuccessful, the user must be notified that the - * widget was unable to be installed as trusted - the certification of - * the widget signature has not been validated -, and prompt the user to allow - * the user to install the widget as an untrusted application, or reject - * the installation. - * - * The WRT MUST support checking for revocation of widget signatures via OCSP - * [RFC 2560] at widget runtime. - * - * The WRT MUST support OCSP access policy. - */ - -namespace ValidationCore { - -class OCSP -// : public RevocationCheckerBase -{ - public: - static const char* DEFAULT_RESPONDER_URI_ENV; - - VerificationStatus checkEndEntity(const CertificateCollection &certList); - OCSP(); - - enum DigestAlgorithm - { - SHA1, - SHA224, - SHA256, - SHA384, - SHA512 - }; - typedef std::map DigestAlgorithmMap; - /** - * Sets digest algorithm for certid in ocsp request - */ - void setDigestAlgorithmForCertId(DigestAlgorithm alg); - - /** - * Sets digest algorithm for certid in ocsp request - */ - void setDigestAlgorithmForRequest(DigestAlgorithm alg); - - void setTrustedStore(const CertificateList& certs); - - VerificationStatusSet validateCertificateList(const CertificateList &certs); - - VerificationStatus validateCertificate(CertificatePtr argCert, - CertificatePtr argIssuer); - - void setDefaultResponder(const char* uri) - { - Assert(uri); - m_strResponderURI = DPL::FromUTF8String(uri); - } - - void setUseDefaultResponder(bool value) - { - m_bUseDefResponder = value; - } - - /** - * @return time when response will become invalid - for list of - * certificates, this is the minimum of all validities; value is - * valid only for not-revoked certificates (non error validation result) - */ - time_t getResponseValidity() - { - return m_responseValidity; - } - - private: - typedef WRT::ScopedGPointer ScopedSoupSession; - typedef WRT::ScopedGPointer ScopedSoupMessage; - - void handleInvalidResponse(int result); - void sendHTTPRequest(ScopedSoupSession& session, - ScopedSoupMessage& msg, - const char* host, - const char* port, - const char* path, - char* requestBuffer, - size_t reqestSize); - void sendRequest(const std::string& uri, - char* requestBuffer, - size_t requestSize, - char** responseBuffer, - size_t* responseSize); - - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, ConnectionError) - DECLARE_EXCEPTION_TYPE(Base, CertificateRevoked) - DECLARE_EXCEPTION_TYPE(Base, CertificateUnknown) - DECLARE_EXCEPTION_TYPE(Base, VerificationError) - DECLARE_EXCEPTION_TYPE(Base, RetrieveCertFromStoreError) - DECLARE_EXCEPTION_TYPE(Base, VerificationNotSupport) - }; - - const EVP_MD* m_pCertIdDigestAlg; - const EVP_MD* m_pRequestDigestAlg; - static DigestAlgorithmMap m_sDigestAlgMap; - - typedef std::pair HttpResponseBuffer; - - SoupWrapper::SoupMessageSendBase::RequestStatus sendOcspRequest( - OCSP_REQUEST* argRequest, - const DPL::OptionalString& argUri); - - //! Validates a single certificate - /*! - * @param cert The certificate to check - * @param issuer A certificate used to sign the certificate to check. - */ - - struct CreateRequestResult - { - bool success; - OCSP_REQUEST* ocspRequest; - OCSP_CERTID* ocspCertId; - CreateRequestResult(bool argSuccess = false, - OCSP_REQUEST* argOcspRequest = NULL, - OCSP_CERTID* argOcspCertId = NULL) : - success(argSuccess), - ocspRequest(argOcspRequest), - ocspCertId(argOcspCertId) - { - } - }; - - //! Creates a OCSP request - /*! - * @param request Returns created OCSP_REQUEST - * @param id Returns CertId that is used to find proper OCSP result in - * the OCSP response (@see checkRevocationStatus for more details). - * - */ - CreateRequestResult createRequest(CertificatePtr argCert, - CertificatePtr argIssuer); - - OCSP_CERTID* addSerial(CertificatePtr argCert, - CertificatePtr argIssuer); - - void validateResponse(OCSP_REQUEST* argRequest, - OCSP_RESPONSE* argResponse, - OCSP_CERTID* argCertId); - - //! Create a X509 store - bool verifyResponse(OCSP_BASICRESP* argResponse); - - void checkRevocationStatus(OCSP_BASICRESP* argBasicResponse, - OCSP_CERTID* argCertId); - - typedef std::pair OcspResponse; - - OcspResponse convertToResponse(); - - time_t m_responseValidity; - bool m_bUseNonce; - bool m_bUseDefResponder; - DPL::String m_strResponderURI; - bool m_bSignRequest; - EVP_PKEY* m_pSignKey; - CertificatePtr m_pSignCert; - SSLSmartContainer m_pTrustedStore; - SoupWrapper::SoupMessageSendSync m_soupMessage; -}; -} // ValidationCore - -#endif //ifndef WRT_ENGINE_SRC_VALIDATION_CORE_ENGINE_OCSP_H_ diff --git a/modules/vcore/src/vcore/OCSPCertMgrUtil.cpp b/modules/vcore/src/vcore/OCSPCertMgrUtil.cpp deleted file mode 100644 index 794ecfa..0000000 --- a/modules/vcore/src/vcore/OCSPCertMgrUtil.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @author Michal Ciepielski(m.ciepielski@samsung.com) - * @version 0.3 - * @brief - */ - -#include "OCSPCertMgrUtil.h" -#include "SSLContainers.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace { -const int MAX_BUF = 1024; - -struct ContextDeleter -{ - typedef CERT_CONTEXT* Type; - static Type NullValue() - { - return NULL; - } - static void Destroy(Type context) - { - if (context) { - cert_svc_cert_context_final(context); - } - } -}; -} - -namespace ValidationCore { -namespace OCSPCertMgrUtil { -/* - * TODO This API function should be changed to: - * CertifiatePtr getCertFromStore(const std::string &subject); - * - * All of cert_svc function could return error because input - * data are corruped. That's why I dont want to throw exceptions - * in this function. - */ -void getCertFromStore(X509_NAME *subject, - X509 **xcert) -{ - if (!xcert || *xcert || !subject) { - LogError("Invalid input!"); - return; - } - - typedef DPL::ScopedResource ScopedContext; - - int result; - char buffer[MAX_BUF]; - const unsigned char* ptr = NULL; - X509 *pCertificate = NULL; - cert_svc_filename_list *fileList = NULL; - - X509_NAME_oneline(subject, buffer, MAX_BUF); - - ScopedContext ctx(cert_svc_cert_context_init()); - if (ctx.Get() == NULL) { - LogWarning("Error in cert_svc_cert_context_init."); - return; - } - - LogDebug("Search certificate with subject: " << buffer); - result = cert_svc_search_certificate(ctx.Get(), SUBJECT_STR, buffer); - LogDebug("Search finished!"); - - if (CERT_SVC_ERR_NO_ERROR != result) { - LogWarning("Error during certificate search"); - return; - } - - fileList = ctx.Get()->fileNames; - - if (fileList == NULL) { - LogDebug("No certificate found"); - return; - } - - if (fileList->filename == NULL) { - LogWarning("Empty filename"); - return; - } - - LogDebug("Found cert file: " << fileList->filename); - ScopedContext ctx2(cert_svc_cert_context_init()); - - if (ctx2.Get() == NULL) { - LogWarning("Error in cert_svc_cert_context_init."); - return; - } - - // TODO add read_certifcate_from_file function to Certificate.h - if (CERT_SVC_ERR_NO_ERROR != - cert_svc_load_file_to_context(ctx2.Get(), fileList->filename)) { - LogWarning("Error in cert_svc_load_file_to_context"); - return; - } - - ptr = ctx2.Get()->certBuf->data; - // create a certificate from mem buff - pCertificate = d2i_X509(NULL, &ptr, ctx2.Get()->certBuf->size); - - if (pCertificate == NULL) { - LogWarning("Error during certificate conversion in d2i_X509"); - return; - } - - *xcert = pCertificate; - if (fileList->next != NULL) { - LogError("There is more then one certificate with same subject :/"); - // TODO Implement me. - for (fileList = fileList->next; - fileList != NULL; - fileList = fileList->next) { - LogError( - "Additional certificate with same subject: " << - fileList->filename); - } - } -} - -CertificatePtr getParentFromStore(const CertificatePtr &certificate) -{ - Assert(certificate.Get()); - X509* rawPtr = certificate->getX509(); - - /* TODO Add getIssuerName function to Certificate.h */ - X509_NAME *name = X509_get_issuer_name(rawPtr); - - X509* rawTemp = NULL; - getCertFromStore(name, &rawTemp); - - if (rawTemp == NULL) { - return CertificatePtr(); - } - - SSLSmartContainer scope(rawTemp); - return CertificatePtr(new Certificate(rawTemp)); -} - -CertificateList completeCertificateChain(const CertificateList &certificateList) -{ - CertificateList result = certificateList; - CertificatePtr last = result.back(); - if (last->isSignedBy(last)) { - return result; - } - CertificatePtr parent = getParentFromStore(last); - if (parent.Get()) { - result.push_back(parent); - } - return result; -} -} // namespace OCSPCertMgrUtil -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/OCSPCertMgrUtil.h b/modules/vcore/src/vcore/OCSPCertMgrUtil.h deleted file mode 100644 index a93a42e..0000000 --- a/modules/vcore/src/vcore/OCSPCertMgrUtil.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @author Tomasz Morawski(t.morawski@samsung.com) - * @author Michal Ciepielski(m.ciepielski@samsung.com) - * @version 0.2 - * @brief - */ - -#ifndef _WRT_OCSP_CERT_MGR_UTIL_H_ -#define _WRT_OCSP_CERT_MGR_UTIL_H_ - -#include - -#include "Certificate.h" - -namespace ValidationCore { -namespace OCSPCertMgrUtil { -void getCertFromStore(X509_NAME *subject, - X509 **xcert); -CertificatePtr getParentFromStore(const CertificatePtr &certificate); -/* - * Look for "parent" certificate from store. - * It returns new certificate chain. - */ -CertificateList completeCertificateChain(const CertificateList &certList); -} // namespace OCSPCertMgrUtil -} // namespace ValidationCore -#endif - diff --git a/modules/vcore/src/vcore/OCSPUtil.c b/modules/vcore/src/vcore/OCSPUtil.c deleted file mode 100644 index 451884a..0000000 --- a/modules/vcore/src/vcore/OCSPUtil.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @author Tomasz Morawski(t.morawski@samsung.com) - * @version 0.1 - * @brief - */ - -#include - -/* - * This function is needed to fix "Invalid conversion from void* to unsigned char*" - * C++ compiler error during calling i2d_OCSP_REQUEST_bio macro - */ -int convertToBuffer(OCSP_REQUEST *req, char **buf, int *size) { - BIO *req_mem_bio; - BUF_MEM req_bmem; - - /* - * size and membuffer for request - */ - *size = i2d_OCSP_REQUEST(req, NULL); - *buf = (char*) malloc(*size); - - if (!*buf) - return 0; - - /* copy request into buffer */ - req_bmem.length = 0; - req_bmem.data = *buf; - req_bmem.max = *size; - - /* - * create a new buffer using openssl - */ - req_mem_bio = BIO_new(BIO_s_mem()); - - if (!req_mem_bio) { - /* - * creation failed, return - */ - free(*buf); - *buf = NULL; - return 0; - } - - BIO_set_mem_buf(req_mem_bio, &req_bmem, BIO_NOCLOSE); - - /* - * prepare request - */ - if (i2d_OCSP_REQUEST_bio(req_mem_bio, req) <= 0) { - free(*buf); - *buf = NULL; - BIO_free_all(req_mem_bio); - return 0; - } - - /* - * check consistency - */ - if (*size != ((int)req_bmem.length) || req_bmem.length != req_bmem.max) - { - free(*buf); - *buf = NULL; - BIO_free_all(req_mem_bio); - return 0; - } - - /* - * free all reserved memory - */ - BIO_free_all(req_mem_bio); - - /* - * and return success - */ - return 1; -} diff --git a/modules/vcore/src/vcore/ParserSchema.h b/modules/vcore/src/vcore/ParserSchema.h deleted file mode 100644 index 6fabff8..0000000 --- a/modules/vcore/src/vcore/ParserSchema.h +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file ParserSchema.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#ifndef _PARSERSCHEMA_H_ -#define _PARSERSCHEMA_H_ - -#include -#include - -#include - -#include "SaxReader.h" - -namespace ValidationCore { -namespace ParserSchemaException { -DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) -DECLARE_EXCEPTION_TYPE(Base, XmlReaderError) -DECLARE_EXCEPTION_TYPE(Base, CertificateLoaderError) -DECLARE_EXCEPTION_TYPE(Base, UnsupportedAlgorithm) -DECLARE_EXCEPTION_TYPE(Base, UnsupportedValue) -} - -template -class ParserSchema -{ - public: - struct TagDescription - { - TagDescription(const std::string &tag, - const std::string & xmlNamespace) : - tagName(tag), - namespaceUri(xmlNamespace) - { - } - - std::string tagName; - std::string namespaceUri; - - bool operator<(const TagDescription &second) const - { - if (tagName < second.tagName) { - return true; - } - if (tagName > second.tagName) { - return false; - } - if (namespaceUri < second.namespaceUri) { - return true; - } - return false; - } - }; - - ParserSchema(ParserType * parser) : - m_functions(parser) - { - } - - virtual ~ParserSchema() - { - } - - void initialize(const std::string &filename, - bool defaultArgs, - SaxReader::ValidationType valType, - const std::string &xmlschema) - { - Try - { - m_reader.initialize(filename, defaultArgs, valType, xmlschema); - } - Catch(SaxReader::Exception::Base) - { - ReThrowMsg(ParserSchemaException::XmlReaderError, "XmlReaderError"); - } - } - - void deinitialize() - { - m_reader.deinitialize(); - } - - void read(DataType &dataContainer) - { - Try { - while (m_reader.next()) { - switch (m_reader.type()) { - case SaxReader::NODE_BEGIN: - beginNode(dataContainer); - break; - case SaxReader::NODE_END: - endNode(dataContainer); - break; - case SaxReader::NODE_TEXT: - textNode(dataContainer); - break; - default: - // LogInfo("Unknown Type Node"); - break; - } - } - } - Catch(SaxReader::Exception::Base) - { - ReThrowMsg(ParserSchemaException::XmlReaderError, "XmlReaderError"); - } - } - - typedef void (ParserType::*FunctionPtr)(DataType &data); - typedef std::map FunctionMap; - - void addBeginTagCallback(const std::string &tag, - const std::string &namespaceUri, - FunctionPtr function) - { - TagDescription desc(tag, namespaceUri); - m_beginFunctionMap[desc] = function; - } - - void addEndTagCallback(const std::string &tag, - const std::string &namespaceUri, - FunctionPtr function) - { - TagDescription desc(tag, namespaceUri); - m_endFunctionMap[desc] = function; - } - - SaxReader& getReader(void) - { - return m_reader; - } - - std::string& getText(void) - { - return m_textNode; - } - - protected: - void beginNode(DataType &dataContainer) - { - TagDescription desc(m_reader.name(), m_reader.namespaceURI()); - FunctionPtr fun = m_beginFunctionMap[desc]; - - if (fun == 0) { - LogDebug("No function found for xml tag: " << m_reader.name()); - return; - } - - (m_functions->*fun)(dataContainer); - } - - void endNode(DataType &dataContainer) - { - TagDescription desc(m_reader.name(), m_reader.namespaceURI()); - FunctionPtr fun = m_endFunctionMap[desc]; - - if (fun == 0) { - LogDebug("No function found for xml tag: " << m_reader.name()); - return; - } - - (m_functions->*fun)(dataContainer); - } - - void textNode(DataType &dataContainer) - { - (void)dataContainer; - m_textNode = m_reader.value(); - } - - ParserType *m_functions; - - SaxReader m_reader; - FunctionMap m_beginFunctionMap; - FunctionMap m_endFunctionMap; - - // temporary values require due parsing textNode - std::string m_textNode; -}; -} // namespace ValidationCore -#endif diff --git a/modules/vcore/src/vcore/ReferenceValidator.cpp b/modules/vcore/src/vcore/ReferenceValidator.cpp deleted file mode 100644 index d56eea8..0000000 --- a/modules/vcore/src/vcore/ReferenceValidator.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include - -#include -#include - -#include "Base64.h" -#include "ReferenceValidator.h" - -namespace { -const char *SPECIAL_SYMBOL_CURRENT_DIR = "."; -const char *SPECIAL_SYMBOL_UPPER_DIR = ".."; -const char *SPECIAL_SYMBOL_AUTHOR_SIGNATURE_FILE = "author-signature.xml"; -const char *REGEXP_DISTRIBUTOR_SIGNATURE = "^signature[1-9][0-9]*\\.xml"; -} // namespace anonymous - -namespace ValidationCore { -ReferenceValidator::ReferenceValidator(const std::string &dirpath) : - m_dirpath(dirpath), - m_signatureRegexp(REGEXP_DISTRIBUTOR_SIGNATURE) -{ -} - -ReferenceValidator::Result ReferenceValidator::checkReferences( - const SignatureData &signatureData) -{ - return dfsCheckDirectories(signatureData, std::string()); -} - -ReferenceValidator::Result ReferenceValidator::dfsCheckDirectories( - const SignatureData &signatureData, - const std::string &directory) -{ - DIR *dp; - struct dirent *dirp; - std::string currentDir = m_dirpath + directory; - - if ((dp = opendir(currentDir.c_str())) == NULL) { - LogError("Error opening directory: " << currentDir.c_str()); - m_errorDescription = currentDir; - return ERROR_OPENING_DIR; - } - - for (errno = 0; (dirp = readdir(dp)) != NULL; errno = 0) { - if (!strcmp(dirp->d_name, SPECIAL_SYMBOL_CURRENT_DIR)) { - continue; - } - - if (!strcmp(dirp->d_name, SPECIAL_SYMBOL_UPPER_DIR)) { - continue; - } - - if (currentDir == m_dirpath && dirp->d_type == DT_REG && - !strcmp(dirp->d_name, - SPECIAL_SYMBOL_AUTHOR_SIGNATURE_FILE) && - signatureData.isAuthorSignature()) { - continue; - } - - if (currentDir == m_dirpath && dirp->d_type == DT_REG && - isDistributorSignature(dirp->d_name)) { - continue; - } - - if (dirp->d_type == DT_DIR) { - LogDebug("Open directory: " << (directory + dirp->d_name)); - std::string tmp_directory = directory + dirp->d_name + "/"; - Result result = dfsCheckDirectories(signatureData, tmp_directory); - if (result != NO_ERROR) { - closedir(dp); - return result; - } - } else if (dirp->d_type == DT_REG) { - LogDebug("Found file: " << (directory + dirp->d_name)); - const ReferenceSet &referenceSet = signatureData.getReferenceSet(); - if (referenceSet.end() == - referenceSet.find(directory + dirp->d_name)) { - closedir(dp); - m_errorDescription = directory + dirp->d_name; - return ERROR_REFERENCE_NOT_FOUND; - } - } else { - LogError("Unknown file type."); - closedir(dp); - m_errorDescription = directory + dirp->d_name; - return ERROR_UNSUPPORTED_FILE_TYPE; - } - } - - if (errno != 0) { - m_errorDescription = DPL::GetErrnoString(); - LogError("readdir failed. Errno code: " << errno << - " Description: " << m_errorDescription); - closedir(dp); - return ERROR_READING_DIR; - } - - closedir(dp); - - return NO_ERROR; -} -} diff --git a/modules/vcore/src/vcore/ReferenceValidator.h b/modules/vcore/src/vcore/ReferenceValidator.h deleted file mode 100644 index 5f05095..0000000 --- a/modules/vcore/src/vcore/ReferenceValidator.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _REFERENCEVALIDATOR_H_ -#define _REFERENCEVALIDATOR_H_ - -#include - -#include "SignatureData.h" - -namespace ValidationCore { -class ReferenceValidator -{ - public: - enum Result - { - NO_ERROR = 0, - ERROR_OPENING_DIR, - ERROR_READING_DIR, - ERROR_UNSUPPORTED_FILE_TYPE, - ERROR_REFERENCE_NOT_FOUND - }; - - ReferenceValidator(const std::string &dirpath); - - virtual ~ReferenceValidator() - { - } - - Result checkReferences(const SignatureData &signatureData); - - private: - - Result dfsCheckDirectories(const SignatureData &signatureData, - const std::string &directory); - - inline bool isDistributorSignature(const char *cstring) const - { - return m_signatureRegexp.FullMatch(cstring); - } - - std::string m_dirpath; - std::string m_errorDescription; - pcrecpp::RE m_signatureRegexp; -}; -} - -#endif // _REFERENCEVALIDATOR_H_ diff --git a/modules/vcore/src/vcore/RevocationCheckerBase.cpp b/modules/vcore/src/vcore/RevocationCheckerBase.cpp deleted file mode 100644 index f0e43e7..0000000 --- a/modules/vcore/src/vcore/RevocationCheckerBase.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Piotr Marcinkiewicz(p.marcinkiew@samsung.com) - * @version 0.4 - * @file CommonCertValidator.cpp - * @brief Common routines for certificate validation over OCSP and CRL - */ - -#include "RevocationCheckerBase.h" - -#include - -#include - -#include - -#include "Certificate.h" -#include "CertificateCollection.h" - -namespace { -const char DefaultBundlePatch[] = "/opt/etc/ssl/certs/ca-certificates.crt"; -} //Anonymous name space - -namespace ValidationCore { -CertificatePtr RevocationCheckerBase::loadPEMFile(const char* fileName) -{ - DPL::ScopedFClose fd(fopen(fileName, "rb")); - - // no such file, return NULL - if (!fd.Get()) { - return CertificatePtr(); - } - - // create a new X509 certificate basing on file - CertificatePtr cert(new Certificate(PEM_read_X509(fd.Get(), - NULL, - NULL, - NULL))); - return cert; -} - -bool RevocationCheckerBase::sortCertList(CertificateList &lCertificates) -{ - CertificateCollection collection; - collection.load(lCertificates); - - if (collection.sort()) { - lCertificates = collection.getChain(); - return true; - } - return false; -} - -} // ValidationCore diff --git a/modules/vcore/src/vcore/RevocationCheckerBase.h b/modules/vcore/src/vcore/RevocationCheckerBase.h deleted file mode 100644 index 3ce934d..0000000 --- a/modules/vcore/src/vcore/RevocationCheckerBase.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Piotr Marcinkiewicz(p.marcinkiew@samsung.com) - * @version 0.4 - * @file CommonCertValidator.h - * @brief Common routines for certificate validation over OCSP and CRL - */ - -#ifndef WRT_ENGINE_SRC_VALIDATION_CORE_REVOCATIONCHECKERBASE_H_ -#define WRT_ENGINE_SRC_VALIDATION_CORE_REVOCATIONCHECKERBASE_H_ - -#include - -#include "Certificate.h" - -namespace ValidationCore { -class RevocationCheckerBase -{ - public: - //! Loads a PEM file and returns X509 certificate object. - static CertificatePtr loadPEMFile(const char* path); - - //! Sorts a list of certficates and verifies them if they form - //! a valid chain - static bool sortCertList(CertificateList &cert) __attribute__((deprecated)); -}; -} // ValidationCore - -#endif //ifndef WRT_ENGINE_SRC_VALIDATION_CORE_REVOCATIONCHECKERBASE_H_ - diff --git a/modules/vcore/src/vcore/SSLContainers.h b/modules/vcore/src/vcore/SSLContainers.h deleted file mode 100644 index e18cb00..0000000 --- a/modules/vcore/src/vcore/SSLContainers.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _SSLCONTAINERS_H -#define _SSLCONTAINERS_H - -#include -#include - -/* - * default deleter functor with no overloaded operator() - */ -template -struct MySSLFree {}; - -/* - * macro for defining custom deleters for openssl structs - * usage DECLARE_DELETER(OpenSSLType) - */ -#define DECLARE_DELETER(Type) template<> \ - struct MySSLFree \ - { \ - void operator() (Type* p) \ - { \ - Type ## _free(p); \ - } \ - \ - }; - -/* - * declare custom deleter for X509 structs - */ -DECLARE_DELETER(X509) -/* - * declare custom deleter for OCSP_REQUEST structs - */ -DECLARE_DELETER(OCSP_REQUEST) -/* - * declare custom deleter for OCSP_RESPONSE structs - */ -DECLARE_DELETER(OCSP_RESPONSE) -/* - * declare custom deleter for OCSP_CERTID structs - */ -DECLARE_DELETER(OCSP_CERTID) -/* - * declare custom deleter for OCSP_BASICRESP structs - */ -DECLARE_DELETER(OCSP_BASICRESP) -/* - * declare custom deleter for X509_STORE structs - */ -DECLARE_DELETER(X509_STORE) - -/* - * undef it, so anyone could use that macro name - */ -#undef DECLARE_DELETER - -/* - * OpenSSL smart container - * usage SSLSmartContainer smartptr = ptrToOpenSSLType - * remember to add OpenSSLType to macro list few lines above - */ -template > -class SSLSmartContainer -{ - public: - SSLSmartContainer() : m_pData(NULL) - { - } - - /* - * explicit constructor, we don't want any auto casting - */ - explicit SSLSmartContainer(T* pData) - { - m_pData = pData; - } - - /* - * overloaded assignment operator - */ - SSLSmartContainer & operator=(SSLSmartContainer& pContainer) - { - /* - * check if no assignment was done before - */ - if (this != &pContainer) { - // if so, free internal data - deleter ssl_free; - ssl_free(m_pData); - - // and assign new - m_pData = pContainer.m_pData; - - pContainer.m_pData = NULL; - } - - return *this; - } - - SSLSmartContainer & operator=(T* pData) - { - /* - * check if no assignment was done before - */ - if (m_pData != pData) { - // if so, free internal data - deleter ssl_free; - ssl_free(m_pData); - - // and assign new - m_pData = pData; - } - - return *this; - } - - ~SSLSmartContainer() - { - deleter ssl_free; - ssl_free(m_pData); - } - - /* - * overloaded operators for standardptr - like usage - */ - SSLSmartContainer & operator*() - { - return *m_pData; - } - SSLSmartContainer* operator->() - { - return m_pData; - } - - /* - * auto cast to T operator - */ - operator T *() const { return m_pData; - } - - /* - * detachs internal pointer from smart pointer - */ - T* DetachPtr() - { - T* pData = m_pData; - m_pData = NULL; - return pData; - } - - private: - /* - * blocked assignment from another types operator - */ - template - T & operator = (S& pContainer) - { - return *this; - } - - /* - * internal data - */ - T* m_pData; -}; - -#endif /* _SSLCONTAINERS_H */ - diff --git a/modules/vcore/src/vcore/SaxReader.cpp b/modules/vcore/src/vcore/SaxReader.cpp deleted file mode 100644 index 5bef911..0000000 --- a/modules/vcore/src/vcore/SaxReader.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file SaxReader.cpp - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief Simple c++ interface for libxml2. - */ -#include -#include -#include - -#include "SaxReader.h" - -namespace ValidationCore { -SaxReader::SaxReader() : - m_reader(0) -{ -} - -SaxReader::~SaxReader() -{ - if (m_reader) { - deinitialize(); - } -} - -void SaxReader::initialize(const std::string &filename, - bool defaultArgs, - ValidationType validate, - const std::string &schema) -{ - Assert(m_reader == 0 && "Double initialization of SaxReader"); - - LogDebug("SaxReader opening file: " << filename); - - /* - * create a new xml text reader - */ - m_reader = xmlNewTextReaderFilename(filename.c_str()); - - if (m_reader == NULL) { - /* - * no such file, return - */ - LogWarning("Error during opening file " << filename); - Throw(Exception::FileOpeningError); - } - if (validate == VALIDATION_XMLSCHEME && - xmlTextReaderSchemaValidate(m_reader, schema.c_str())) { - /* - * unable to turn on schema validation - */ - LogError("Turn on Schema validation failed."); - ThrowMsg(Exception::ParserInternalError, - "Turn on Scheme validation failed!"); - } - // Path to DTD schema is taken from xml file. - if (validate == VALIDATION_DTD && - xmlTextReaderSetParserProp(m_reader, XML_PARSER_VALIDATE, 1)) { - /* - * unable to turn on DTD validation - */ - LogError("Turn on DTD validation failed!"); - ThrowMsg(Exception::ParserInternalError, - "Turn on DTD validation failed!"); - } - if (defaultArgs && - xmlTextReaderSetParserProp(m_reader, XML_PARSER_DEFAULTATTRS, 1)) { - /* - * unable to turn on default arguments - */ - LogError("Turn on default arguments failed"); - ThrowMsg(Exception::ParserInternalError, - "Turn on Default Arguments failed!"); - } -} - -void SaxReader::deinitialize() -{ - xmlFreeTextReader(m_reader); - m_reader = 0; -} - -bool SaxReader::next() -{ - int res = xmlTextReaderRead(m_reader); - - if (0 == xmlTextReaderIsValid(m_reader)) { - LogWarning("Throw exception file not valid!"); - Throw(Exception::FileNotValid); - } - - if (res == 1) { - return true; - } - - if (res == 0) { - return false; - } - LogError("ParserInternalError"); - Throw(Exception::ParserInternalError); -} - -void SaxReader::next(const std::string &token) -{ - xmlTextReaderRead(m_reader); - if (0 == xmlTextReaderIsValid(m_reader)) { - /* - * invalid file - */ - LogWarning("Throw exception file not valid!"); - Throw(Exception::FileNotValid); - } - - xmlChar *name = xmlTextReaderName(m_reader); - - if (name == NULL) { - /* - * invalid file - */ - LogWarning("File not Valid"); - Throw(Exception::FileNotValid); - } - - if (token == reinterpret_cast(name)) { - xmlFree(name); - } else { - /* - * we encountered wrong token - */ - xmlFree(name); - LogWarning("Wrong Token"); - Throw(Exception::WrongToken); - } -} - -bool SaxReader::isEmpty(void) -{ - int ret = xmlTextReaderIsEmptyElement(m_reader); - if (-1 == ret) { - LogError("Parser Internal Error"); - Throw(Exception::ParserInternalErrorInEmptyQuery); - } - return ret; -} - -std::string SaxReader::attribute(const std::string &token, - ThrowType throwStatus) -{ - std::string value; - xmlChar *attr = xmlTextReaderGetAttribute(m_reader, BAD_CAST(token.c_str())); - if ((NULL == attr) && (throwStatus == THROW_DISABLE)) { - /* - * return empty string - */ - //TODO why not DPL::Optional? - return std::string(); - } - if (NULL == attr) { - /* - * error during read attribute - */ - LogError("Error in reading attribute."); - Throw(Exception::ParserInternalErrorInReadingAttribute); - } - - /* - * cast it to val and return it - */ - value = reinterpret_cast(attr); - xmlFree(attr); - return value; -} - -// KW std::string SaxReader::fullName(){ -// KW std::string value; -// KW xmlChar *name = xmlTextReaderName(m_reader); -// KW if(NULL == name) { -// KW LogError("Error in reading name."); -// KW Throw(Exception::ErrorReadingName); -// KW } -// KW value = reinterpret_cast(name); -// KW xmlFree(name); -// KW return value; -// KW } - -std::string SaxReader::name() -{ - std::string value; - xmlChar *name = xmlTextReaderName(m_reader); - if (NULL == name) { - LogError("Error in reading name."); - Throw(Exception::ErrorReadingName); - } - value = reinterpret_cast(name); - xmlFree(name); - size_t pos = value.find_last_of(":"); - if (pos != std::string::npos) { - value.erase(0, pos + 1); - } - return value; -} - -std::string SaxReader::namespaceURI() -{ - std::string value; - xmlChar *name = xmlTextReaderNamespaceUri(m_reader); - if (NULL != name) { - value = reinterpret_cast(name); - xmlFree(name); - } - return value; -} - -std::string SaxReader::value() -{ - std::string value; - /* - * get value of node - */ - xmlChar *text = xmlTextReaderValue(m_reader); - if (NULL == text) { - LogError("Error in reading value"); - Throw(Exception::ErrorReadingValue); - } - value = reinterpret_cast(text); - /* - * free text and return the val - */ - xmlFree(text); - return value; -} - -SaxReader::NodeType SaxReader::type() -{ - xmlReaderTypes type = - static_cast(xmlTextReaderNodeType(m_reader)); - switch (type) { - case XML_READER_TYPE_ELEMENT: - return NODE_BEGIN; - case XML_READER_TYPE_END_ELEMENT: - return NODE_END; - case XML_READER_TYPE_TEXT: - return NODE_TEXT; - case XML_READER_TYPE_NONE: - case XML_READER_TYPE_ATTRIBUTE: - case XML_READER_TYPE_CDATA: - case XML_READER_TYPE_ENTITY_REFERENCE: - case XML_READER_TYPE_ENTITY: - case XML_READER_TYPE_PROCESSING_INSTRUCTION: - case XML_READER_TYPE_COMMENT: - case XML_READER_TYPE_DOCUMENT: - case XML_READER_TYPE_DOCUMENT_TYPE: - case XML_READER_TYPE_DOCUMENT_FRAGMENT: - case XML_READER_TYPE_NOTATION: - case XML_READER_TYPE_WHITESPACE: - case XML_READER_TYPE_SIGNIFICANT_WHITESPACE: - case XML_READER_TYPE_END_ENTITY: - case XML_READER_TYPE_XML_DECLARATION: - default: - return NODE_UNSUPPORTED; - } -} - -void SaxReader::dumpNode(std::string &buffer) -{ - /* - * size of buffer - */ - int size; - /* - * pointer to buffer - */ - xmlBufferPtr buff = xmlBufferCreate(); - - xmlNodePtr node = xmlTextReaderExpand(m_reader); - - if (node == NULL) { - /* - * internal parser error - */ - xmlBufferFree(buff); - LogError("Parser Internal Error"); - Throw(Exception::ParserInternalError); - } - - /* - * get a size and fill in a buffer - */ - size = xmlNodeDump(buff, node->doc, node, 0, 0); - buffer.insert(0, reinterpret_cast(buff->content), size); - xmlBufferFree(buff); -} -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/SaxReader.h b/modules/vcore/src/vcore/SaxReader.h deleted file mode 100644 index 816405f..0000000 --- a/modules/vcore/src/vcore/SaxReader.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file SaxReader.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief Simple c++ interface for libxml2. - */ -#ifndef _SAXREADER_H_ -#define _SAXREADER_H_ - -#include -#include -#include - -namespace ValidationCore { -class SaxReader -{ - public: - SaxReader(); - ~SaxReader(); - - /* - * custom exceptions - */ - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, FileOpeningError) - DECLARE_EXCEPTION_TYPE(Base, FileNotValid) - DECLARE_EXCEPTION_TYPE(Base, ParserInternalError) - DECLARE_EXCEPTION_TYPE(Base, WrongToken) - DECLARE_EXCEPTION_TYPE(Base, ParserInternalErrorInReadingAttribute) - DECLARE_EXCEPTION_TYPE(Base, ParserInternalErrorInEmptyQuery) - DECLARE_EXCEPTION_TYPE(Base, ErrorReadingValue) - DECLARE_EXCEPTION_TYPE(Base, ErrorReadingName) - DECLARE_EXCEPTION_TYPE(Base, UnsupportedType) - }; - - enum NodeType - { - NODE_UNSUPPORTED, - NODE_BEGIN, - NODE_END, - NODE_TEXT - }; - - enum ThrowType - { - THROW_ENABLE = 0, - THROW_DISABLE - }; - - /* - * xml validation modes - */ - enum ValidationType - { - VALIDATION_DISABLE, - VALIDATION_XMLSCHEME, - VALIDATION_DTD - }; - - /* - * initializes parser - */ - void initialize(const std::string &filename, - bool defaultArgs = false, - ValidationType validation = VALIDATION_DISABLE, - const std::string &schema = std::string()); - /* - * deinitializes parser - */ - void deinitialize(); - - /** - * Move to next xml node. - */ - bool next(); - - /** - * Move to next xml node. If next node name is differ from token the exception will - * be thrown. - */ - void next(const std::string &token); - - /** - * Check if xml tag is empty. - */ - bool isEmpty(void); - - /** - * Read attribute tag. - */ - std::string attribute(const std::string &token, - ThrowType throwStatus = THROW_ENABLE); - - /** - * Read xml tag name with namespace. - */ - // KW std::string fullName(); - - /** - * Read xml tag name without namespace. - */ - std::string name(); - - /** - * Read xml tag namespace URI - */ - std::string namespaceURI(); - - /** - * Read xml tag value. - */ - std::string value(); - - /** - * Return information about node type. - */ - NodeType type(); - - /** - * Save all contonet of xml file which is between current tag and - * it's close tag into buffer. - */ - void dumpNode(std::string &buffer); - - private: - /* - * internal libxml text reader - */ - xmlTextReaderPtr m_reader; -}; -} - -#endif // _SAXREADER_H_ diff --git a/modules/vcore/src/vcore/SignatureData.h b/modules/vcore/src/vcore/SignatureData.h deleted file mode 100644 index c0b7aad..0000000 --- a/modules/vcore/src/vcore/SignatureData.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file SignatureData.cpp - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief SignatureData is used to storage data parsed from digsig file. - */ -#ifndef _SIGNATUREDATA_H_ -#define _SIGNATUREDATA_H_ - -#include -#include -#include - -#include -#include -#include - -#include "Certificate.h" -#include "CertStoreType.h" -#include "ValidatorCommon.h" - -/* TODO this class should not depend from OCSP headers */ -#include "OCSPCertMgrUtil.h" - -namespace ValidationCore { -class SignatureData -{ - public: - - SignatureData() : - m_signatureNumber(-1), - m_certificateSorted(false) - { - } - - SignatureData(std::string fileName, - int fileNumber) : - m_signatureNumber(fileNumber), - m_fileName(fileName), - m_certificateSorted(false) - { - } - - virtual ~SignatureData() - { - } - typedef std::list IMEIList; - typedef std::list MEIDList; - - const ReferenceSet& getReferenceSet() const - { - return m_referenceSet; - } - - void setReference(const ReferenceSet &referenceSet) - { - m_referenceSet = referenceSet; - } - - CertificateList getCertList(void) const - { - return m_certList; - } - - void setSortedCertificateList(const CertificateList &list) - { - m_certList = list; - m_certificateSorted = true; - } - - bool isAuthorSignature(void) const - { - return m_signatureNumber == -1; - } - - std::string getSignatureFileName(void) const - { - return m_fileName; - } - - int getSignatureNumber() const - { - return m_signatureNumber; - } - - std::string getRoleURI() const - { - return m_roleURI; - } - - std::string getProfileURI() const - { - return m_profileURI; - } - - bool containObjectReference(const std::string &ref) const - { - std::string rName = "#"; - rName += ref; - return m_referenceSet.end() != m_referenceSet.find(rName); - } - - ObjectList getObjectList() const - { - return m_objectList; - } - - void setStorageType(const CertStoreId::Set &storeIdSet) - { - m_storeIdSet = storeIdSet; - } - - const CertStoreId::Set& getStorageType(void) const - { - return m_storeIdSet; - } - - const IMEIList& getIMEIList() const - { - return m_imeiList; - } - - const MEIDList& getMEIDList() const - { - return m_meidList; - } - - CertificatePtr getEndEntityCertificatePtr() const - { - if (m_certificateSorted) { - return m_certList.front(); - } - return CertificatePtr(); - } - - CertificatePtr getRootCaCertificatePtr() const - { - if (m_certificateSorted) { - return m_certList.back(); - } - return CertificatePtr(); - } - - friend class SignatureReader; - private: - ReferenceSet m_referenceSet; - CertificateList m_certList; - - //TargetRestriction - IMEIList m_imeiList; - MEIDList m_meidList; - - /* - * This number is taken from distributor signature file name. - * Author signature do not contain any number on the file name. - * Author signature should have signature number equal to -1. - */ - int m_signatureNumber; - std::string m_fileName; - std::string m_roleURI; - std::string m_profileURI; - std::string m_identifier; - ObjectList m_objectList; - CertStoreId::Set m_storeIdSet; - bool m_certificateSorted; -}; - -typedef std::set SignatureDataSet; -} - -#endif diff --git a/modules/vcore/src/vcore/SignatureFinder.cpp b/modules/vcore/src/vcore/SignatureFinder.cpp deleted file mode 100644 index ed2a27f..0000000 --- a/modules/vcore/src/vcore/SignatureFinder.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file SignatureFinder.cpp - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief Search for author-signature.xml and signatureN.xml files. - */ -#include -#include -#include - -#include - -#include "SignatureFinder.h" - -namespace ValidationCore { -static const char *SIGNATURE_AUTHOR = "author-signature.xml"; -static const char *REGEXP_DISTRIBUTOR_SIGNATURE = - "^(signature)([1-9][0-9]*)(\\.xml)"; - -SignatureFinder::SignatureFinder(const std::string& dir) : - m_dir(dir), - m_signatureRegexp(REGEXP_DISTRIBUTOR_SIGNATURE) -{ -} - -SignatureFinder::Result SignatureFinder::find(SignatureFileInfoSet &set) -{ - DIR *dp; - struct dirent *dirp; - - /* - * find a dir - */ - if ((dp = opendir(m_dir.c_str())) == NULL) { - LogError("Error opening directory:" << m_dir); - return ERROR_OPENING_DIR; - } - - for (errno = 0; (dirp = readdir(dp)) != NULL; errno = 0) { - /** - * check if it's author signature - */ - if (!strcmp(dirp->d_name, SIGNATURE_AUTHOR)) { - set.insert(SignatureFileInfo(std::string(dirp->d_name), -1)); - continue; - } - - std::string sig, num, xml; - if (m_signatureRegexp.FullMatch(dirp->d_name, &sig, &num, &xml)) { - std::istringstream stream(num); - int number; - stream >> number; - - if (stream.fail()) { - closedir(dp); - return ERROR_ISTREAM; - } - - set.insert(SignatureFileInfo(std::string(dirp->d_name), number)); - } - } - - if (errno != 0) { - LogError("Error in readdir"); - closedir(dp); - return ERROR_READING_DIR; - } - - closedir(dp); - return NO_ERROR; -} -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/SignatureFinder.h b/modules/vcore/src/vcore/SignatureFinder.h deleted file mode 100644 index 0e04213..0000000 --- a/modules/vcore/src/vcore/SignatureFinder.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file SignatureFinder.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief Search for author-signature.xml and signatureN.xml files. - */ -#ifndef _SIGNATUREFINDER_H_ -#define _SIGNATUREFINDER_H_ - -#include -#include - -#include - -#include "SignatureData.h" - -namespace ValidationCore { -class SignatureFileInfo -{ - public: - SignatureFileInfo(const std::string &fileName, - int num) : - m_fileName(fileName), - m_fileNumber(num) - { - } - - std::string getFileName() const - { - return m_fileName; - } - - int getFileNumber() const - { - return m_fileNumber; - } - - bool operator<(const SignatureFileInfo &second) const - { - return m_fileNumber < second.m_fileNumber; - } - private: - std::string m_fileName; - int m_fileNumber; -}; - -typedef std::set SignatureFileInfoSet; - -class SignatureFinder -{ - public: - enum Result - { - NO_ERROR, - ERROR_OPENING_DIR, - ERROR_READING_DIR, - ERROR_ISTREAM - }; - - SignatureFinder(const std::string& dir); - - Result find(SignatureFileInfoSet &set); - - private: - std::string m_dir; - pcrecpp::RE m_signatureRegexp; -}; -} // namespace ValidationCore - -#endif diff --git a/modules/vcore/src/vcore/SignatureReader.cpp b/modules/vcore/src/vcore/SignatureReader.cpp deleted file mode 100644 index cf7540c..0000000 --- a/modules/vcore/src/vcore/SignatureReader.cpp +++ /dev/null @@ -1,582 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file SignatureReader.cpp - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief SignatureReader is used to parse widget digital signature. - */ -#include "SignatureReader.h" - -#include "CertificateLoader.h" - -namespace ValidationCore { -static const std::string XML_NAMESPACE = - "http://www.w3.org/2000/09/xmldsig#"; -static const std::string XML_NAMESPACE_DIGITALSIG = - "http://wacapps.net/ns/digsig"; -static const std::string XML_OBJ_NS = - "http://www.w3.org/2009/xmldsig-properties"; - -// TAG TOKENS -static const std::string TOKEN_SIGNATURE = "Signature"; -static const std::string TOKEN_SIGNED_INFO = "SignedInfo"; -static const std::string TOKEN_CANONICALIZATION_METHOD = - "CanonicalizationMethod"; -static const std::string TOKEN_SIGNATURE_METHOD = "SignatureMethod"; -static const std::string TOKEN_REFERENCE = "Reference"; -static const std::string TOKEN_TRANSFORMS = "Transforms"; -static const std::string TOKEN_TRANSFORM = "Transform"; -static const std::string TOKEN_DIGEST_METHOD = "DigestMethod"; -static const std::string TOKEN_DIGEST_VALUE = "DigestValue"; -static const std::string TOKEN_SIGNATURE_VALUE = "SignatureValue"; -static const std::string TOKEN_KEY_INFO = "KeyInfo"; -static const std::string TOKEN_X509DATA = "X509Data"; -static const std::string TOKEN_X509CERTIFICATE = "X509Certificate"; -static const std::string TOKEN_KEY_VALUE = "KeyValue"; -static const std::string TOKEN_RSA_KEY_VALUE = "RSAKeyValue"; -static const std::string TOKEN_MODULUS_COMPONENT = "Modulus"; -static const std::string TOKEN_EXPONENT_COMPONENT = "Exponent"; -static const std::string TOKEN_ECKEY_VALUE = "ECKeyValue"; -static const std::string TOKEN_NAMED_CURVE = "NamedCurve"; -static const std::string TOKEN_PUBLIC_KEY = "PublicKey"; -static const std::string TOKEN_OBJECT = "Object"; -static const std::string TOKEN_SIGNATURE_PROPERTIES = "SignatureProperties"; -static const std::string TOKEN_SIGNATURE_PROPERTY = "SignatureProperty"; -static const std::string TOKEN_PROFILE = "Profile"; -static const std::string TOKEN_ROLE = "Role"; -static const std::string TOKEN_IDENTIFIER = "Identifier"; -static const std::string TOKEN_DSAKEYVALUE = "DSAKeyValue"; -static const std::string TOKEN_DSA_P_COMPONENT = "P"; -static const std::string TOKEN_DSA_Q_COMPONENT = "Q"; -static const std::string TOKEN_DSA_G_COMPONENT = "G"; -static const std::string TOKEN_DSA_Y_COMPONENT = "Y"; -static const std::string TOKEN_DSA_J_COMPONENT = "J"; -static const std::string TOKEN_DSA_SEED_COMPONENT = "Seed"; -static const std::string TOKEN_DSA_PGENCOUNTER_COMPONENT = "PgenCounter"; -static const std::string TOKEN_TARGET_RESTRICTION = "TargetRestriction"; - -// ATTRIBUTTE TOKENS - -static const std::string TOKEN_ALGORITHM = "Algorithm"; -static const std::string TOKEN_URI = "URI"; -static const std::string TOKEN_ID = "Id"; -static const std::string TOKEN_TARGET = "Target"; -static const std::string TOKEN_IMEI = "IMEI"; -static const std::string TOKEN_MEID = "MEID"; - -// ATTIRUBTE VALUES - -static const std::string TOKEN_ATTR_PROFILE = "profile"; -static const std::string TOKEN_ATTR_ROLE = "role"; -static const std::string TOKEN_ATTR_IDENTIFIER = "identifier"; - -// ALGORITHMS - -//static const std::string TOKEN_ALGORITHM_XML_EXC_CAN = -// "http://www.w3.org/2001/10/xml-exc-c14n#"; -//static const std::string TOKEN_ALGORITHM_RSA_SHA256 = -// "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"; -//static const std::string TOKEN_ALGORITHM_DSA_SHA1 = -// "http://www.w3.org/2000/09/xmldsig#dsa-sha1"; -//static const std::string TOKEN_ALGORITHM_ECDSA_SHA256 = -// "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"; -//static const std::string TOKEN_ALGORITHM_SHA1 = -// "http://www.w3.org/2000/09/xmldsig#sha1"; -//static const std::string TOKEN_ALGORITHM_SHA256 = -// "http://www.w3.org/2001/04/xmlenc#sha256"; -//static const std::string TOKEN_ALGORITHM_SHA384 = -// "http://www.w3.org/2001/04/xmldsig-more#sha384"; -//static const std::string TOKEN_ALGORITHM_SHA512 = -// "http://www.w3.org/2001/04/xmlenc#sha512"; - -SignatureReader::SignatureReader() : - m_signaturePropertiesCounter(0), - m_targetRestrictionObjectFound(false), - m_parserSchema(this) -{ - /** - * member func pointers map - */ - m_parserSchema.addBeginTagCallback(TOKEN_SIGNATURE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_SIGNED_INFO, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_CANONICALIZATION_METHOD, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_SIGNATURE_METHOD, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_REFERENCE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_TRANSFORMS, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_TRANSFORM, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_DIGEST_METHOD, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_DIGEST_VALUE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_SIGNATURE_VALUE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_KEY_INFO, - XML_NAMESPACE, - &SignatureReader::tokenKeyInfo); - m_parserSchema.addBeginTagCallback(TOKEN_X509DATA, - XML_NAMESPACE, - &SignatureReader::tokenX509Data); - m_parserSchema.addBeginTagCallback(TOKEN_X509CERTIFICATE, - XML_NAMESPACE, - &SignatureReader::tokenX509Certificate); - m_parserSchema.addBeginTagCallback(TOKEN_ECKEY_VALUE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_NAMED_CURVE, - XML_NAMESPACE, - &SignatureReader::tokenNamedCurve); - m_parserSchema.addBeginTagCallback(TOKEN_PUBLIC_KEY, - XML_NAMESPACE, - &SignatureReader::tokenPublicKey); - m_parserSchema.addBeginTagCallback(TOKEN_OBJECT, - XML_NAMESPACE, - &SignatureReader::tokenObject); - m_parserSchema.addBeginTagCallback( - TOKEN_SIGNATURE_PROPERTIES, - XML_NAMESPACE, - &SignatureReader:: - tokenSignatureProperties); - m_parserSchema.addBeginTagCallback(TOKEN_SIGNATURE_PROPERTY, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_PROFILE, - XML_OBJ_NS, - &SignatureReader::tokenProfile); - m_parserSchema.addBeginTagCallback(TOKEN_ROLE, - XML_OBJ_NS, - &SignatureReader::tokenRole); - m_parserSchema.addBeginTagCallback(TOKEN_IDENTIFIER, - XML_OBJ_NS, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_KEY_VALUE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_DSAKEYVALUE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_DSA_P_COMPONENT, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_DSA_Q_COMPONENT, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_DSA_G_COMPONENT, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_DSA_Y_COMPONENT, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_DSA_J_COMPONENT, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_DSA_SEED_COMPONENT, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_DSA_PGENCOUNTER_COMPONENT, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_RSA_KEY_VALUE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_MODULUS_COMPONENT, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_EXPONENT_COMPONENT, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addBeginTagCallback(TOKEN_TARGET_RESTRICTION, - XML_NAMESPACE_DIGITALSIG, - &SignatureReader::tokenTargetRestriction); - - m_parserSchema.addEndTagCallback(TOKEN_SIGNATURE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_SIGNED_INFO, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_CANONICALIZATION_METHOD, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_SIGNATURE_METHOD, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_REFERENCE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_TRANSFORMS, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_TRANSFORM, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_DIGEST_METHOD, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_DIGEST_VALUE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_SIGNATURE_VALUE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_KEY_INFO, - XML_NAMESPACE, - &SignatureReader::tokenEndKeyInfo); - m_parserSchema.addEndTagCallback(TOKEN_X509DATA, - XML_NAMESPACE, - &SignatureReader::tokenEndX509Data); - m_parserSchema.addEndTagCallback(TOKEN_X509CERTIFICATE, - XML_NAMESPACE, - &SignatureReader::tokenEndX509Certificate); - m_parserSchema.addEndTagCallback(TOKEN_ECKEY_VALUE, - XML_NAMESPACE, - &SignatureReader::tokenEndECKeyValue); - m_parserSchema.addEndTagCallback(TOKEN_PUBLIC_KEY, - XML_NAMESPACE, - &SignatureReader::tokenEndPublicKey); - m_parserSchema.addEndTagCallback(TOKEN_OBJECT, - XML_NAMESPACE, - &SignatureReader::tokenEndObject); - m_parserSchema.addEndTagCallback(TOKEN_SIGNATURE_PROPERTIES, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_SIGNATURE_PROPERTY, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_PROFILE, - XML_OBJ_NS, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_ROLE, - XML_OBJ_NS, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_IDENTIFIER, - XML_OBJ_NS, - &SignatureReader::tokenEndIdentifier); - m_parserSchema.addEndTagCallback(TOKEN_KEY_VALUE, - XML_NAMESPACE, - &SignatureReader::blankFunction); - m_parserSchema.addEndTagCallback(TOKEN_DSAKEYVALUE, - XML_NAMESPACE, - &SignatureReader::tokenEndDSAKeyValue); - m_parserSchema.addEndTagCallback(TOKEN_DSA_P_COMPONENT, - XML_NAMESPACE, - &SignatureReader::tokenEndDSAPComponent); - m_parserSchema.addEndTagCallback(TOKEN_DSA_Q_COMPONENT, - XML_NAMESPACE, - &SignatureReader::tokenEndDSAQComponent); - m_parserSchema.addEndTagCallback(TOKEN_DSA_G_COMPONENT, - XML_NAMESPACE, - &SignatureReader::tokenEndDSAGComponent); - m_parserSchema.addEndTagCallback(TOKEN_DSA_Y_COMPONENT, - XML_NAMESPACE, - &SignatureReader::tokenEndDSAYComponent); - m_parserSchema.addEndTagCallback(TOKEN_DSA_J_COMPONENT, - XML_NAMESPACE, - &SignatureReader::tokenEndDSAJComponent); - m_parserSchema.addEndTagCallback(TOKEN_DSA_SEED_COMPONENT, - XML_NAMESPACE, - &SignatureReader::tokenEndDSASeedComponent); - m_parserSchema.addEndTagCallback( - TOKEN_DSA_PGENCOUNTER_COMPONENT, - XML_NAMESPACE, - &SignatureReader:: - tokenEndDSAPGenCounterComponent); - m_parserSchema.addEndTagCallback(TOKEN_RSA_KEY_VALUE, - XML_NAMESPACE, - &SignatureReader::tokenEndRSAKeyValue); - m_parserSchema.addEndTagCallback(TOKEN_MODULUS_COMPONENT, - XML_NAMESPACE, - &SignatureReader::tokenEndKeyModulus); - m_parserSchema.addEndTagCallback(TOKEN_EXPONENT_COMPONENT, - XML_NAMESPACE, - &SignatureReader::tokenEndKeyExponent); - m_parserSchema.addEndTagCallback(TOKEN_TARGET_RESTRICTION, - XML_NAMESPACE, - &SignatureReader::blankFunction); -} - -void SignatureReader::tokenKeyInfo(SignatureData &signatureData) -{ - (void)signatureData; -} -void SignatureReader::tokenX509Data(SignatureData &signatureData) -{ - (void)signatureData; -} -void SignatureReader::tokenX509Certificate(SignatureData &signatureData) -{ - (void)signatureData; -} -void SignatureReader::tokenPublicKey(SignatureData &signatureData) -{ - (void)signatureData; -} - -void SignatureReader::tokenNamedCurve(SignatureData &signatureData) -{ - (void)signatureData; - m_nameCurveURI = m_parserSchema.getReader().attribute(TOKEN_URI); -} - -void SignatureReader::tokenTargetRestriction(SignatureData &signatureData) -{ - std::string IMEI = m_parserSchema.getReader().attribute( - TOKEN_IMEI, - SaxReader:: - THROW_DISABLE); - std::string MEID = m_parserSchema.getReader().attribute( - TOKEN_MEID, - SaxReader:: - THROW_DISABLE); - - //less verbose way to say (IMEI && MEID) || (!IMEI && !MEID) - if (IMEI.empty() == MEID.empty()) { - //WAC 2.0 WR-4650 point 4 - ThrowMsg(Exception::TargetRestrictionException, - "TargetRestriction should contain exactly one attribute."); - return; - } - - if (!IMEI.empty()) { - signatureData.m_imeiList.push_back(IMEI); - } - if (!MEID.empty()) { - signatureData.m_meidList.push_back(MEID); - } -} - -void SignatureReader::tokenEndKeyInfo(SignatureData &signatureData) -{ - (void)signatureData; -} - -void SignatureReader::tokenEndX509Data(SignatureData &signatureData) -{ - (void)signatureData; -} - -void SignatureReader::tokenEndX509Certificate(SignatureData &signatureData) -{ - CertificateLoader loader; - if (CertificateLoader::NO_ERROR != - loader.loadCertificateFromRawData(m_parserSchema.getText())) { - LogWarning("Certificate could not be loaded!"); - ThrowMsg(ParserSchemaException::CertificateLoaderError, - "Certificate could not be loaded."); - } - signatureData.m_certList.push_back(loader.getCertificatePtr()); -} -// KW void SignatureReader::tokenEndKeyName(SignatureData &signatureData){ -// KW CertificateLoader loader; -// KW if(CertificateLoader::NO_ERROR != loader.loadCertificateBasedOnSubjectName(m_parserSchema.getText())){ -// KW LogError("Certificate could not be loaded!"); -// KW ThrowMsg(ParserSchemaException::CertificateLoaderError, "Certificate could not be loaded."); -// KW } -// KW signatureData.m_certList.push_back(loader); -// KW } - -void SignatureReader::tokenEndRSAKeyValue(SignatureData &signatureData) -{ - CertificateLoader loader; - if (CertificateLoader::NO_ERROR != - loader.loadCertificateBasedOnExponentAndModulus(m_modulus, - m_exponent)) { - LogWarning("Certificate could not be loaded!"); - ThrowMsg(ParserSchemaException::CertificateLoaderError, - "Certificate could not be loaded."); - } - signatureData.m_certList.push_back(loader.getCertificatePtr()); -} - -void SignatureReader::tokenEndKeyModulus(SignatureData &signatureData) -{ - (void)signatureData; - m_modulus = m_parserSchema.getText(); -} - -void SignatureReader::tokenEndKeyExponent(SignatureData &signatureData) -{ - (void)signatureData; - m_exponent = m_parserSchema.getText(); -} - -void SignatureReader::tokenEndPublicKey(SignatureData &signatureData) -{ - (void)signatureData; - m_publicKey = m_parserSchema.getText(); -} - -void SignatureReader::tokenEndECKeyValue(SignatureData &signatureData) -{ - CertificateLoader loader; - if (CertificateLoader::NO_ERROR != - loader.loadCertificateWithECKEY(m_nameCurveURI, m_publicKey)) { - ThrowMsg(ParserSchemaException::CertificateLoaderError, - "Certificate could not be loaded."); - } - signatureData.m_certList.push_back(loader.getCertificatePtr()); -} - -void SignatureReader::tokenEndObject(SignatureData &signatureData) -{ - m_signaturePropertiesCounter = 0; - - if (((!signatureData.m_imeiList.empty()) || - (!signatureData.m_meidList.empty())) && - m_targetRestrictionObjectFound) { - //WAC 2.0 WR-4650 point 1 - ThrowMsg( - Exception::TargetRestrictionException, - "TargetRestriction should contain exactly one ds:Object containing zero or more wac:TargetRestriction children."); - return; - } - if ((!signatureData.m_imeiList.empty()) || - (!signatureData.m_meidList.empty())) { - m_targetRestrictionObjectFound = true; - } -} -void SignatureReader::tokenEndDSAPComponent(SignatureData& signatureData) -{ - (void)signatureData; - m_dsaKeyPComponent = m_parserSchema.getText(); -} - -void SignatureReader::tokenEndDSAQComponent(SignatureData& signatureData) -{ - (void)signatureData; - m_dsaKeyQComponent = m_parserSchema.getText(); -} - -void SignatureReader::tokenEndDSAGComponent(SignatureData& signatureData) -{ - (void)signatureData; - m_dsaKeyGComponent = m_parserSchema.getText(); -} - -void SignatureReader::tokenEndDSAYComponent(SignatureData& signatureData) -{ - (void)signatureData; - m_dsaKeyYComponent = m_parserSchema.getText(); -} - -void SignatureReader::tokenEndDSAJComponent(SignatureData& signatureData) -{ - (void)signatureData; - m_dsaKeyJComponent = m_parserSchema.getText(); -} - -void SignatureReader::tokenEndDSASeedComponent(SignatureData& signatureData) -{ - (void)signatureData; - m_dsaKeySeedComponent = m_parserSchema.getText(); -} - -void SignatureReader::tokenEndDSAPGenCounterComponent( - SignatureData& signatureData) -{ - (void)signatureData; - m_dsaKeyPGenCounter = m_parserSchema.getText(); -} - -void SignatureReader::tokenEndDSAKeyValue(SignatureData& signatureData) -{ - CertificateLoader loader; - - if (CertificateLoader::NO_ERROR != - loader.loadCertificateBasedOnDSAComponents(m_dsaKeyPComponent, - m_dsaKeyQComponent, - m_dsaKeyGComponent, - m_dsaKeyYComponent, - m_dsaKeyJComponent, - m_dsaKeySeedComponent, - m_dsaKeyPGenCounter)) { - LogWarning("Certificate could not be loaded."); - ThrowMsg(ParserSchemaException::CertificateLoaderError, - "Certificate could not be loaded."); - } - signatureData.m_certList.push_back(loader.getCertificatePtr()); -} - -void SignatureReader::tokenRole(SignatureData &signatureData) -{ - if (!signatureData.m_roleURI.empty()) { - LogWarning("Multiple definition of Role is not allowed."); - ThrowMsg(ParserSchemaException::UnsupportedValue, - "Multiple definition of Role is not allowed."); - } - signatureData.m_roleURI = m_parserSchema.getReader().attribute(TOKEN_URI); -} - -void SignatureReader::tokenProfile(SignatureData &signatureData) -{ - if (!signatureData.m_profileURI.empty()) { - LogWarning("Multiple definition of Profile is not allowed."); - ThrowMsg(ParserSchemaException::UnsupportedValue, - "Multiple definition of Profile is not allowed."); - } - signatureData.m_profileURI = m_parserSchema.getReader().attribute(TOKEN_URI); -} - -void SignatureReader::tokenEndIdentifier(SignatureData &signatureData) -{ - if (!signatureData.m_identifier.empty()) { - LogWarning("Multiple definition of Identifier is not allowed."); - ThrowMsg(ParserSchemaException::UnsupportedValue, - "Multiple definition of Identifier is not allowed."); - } - signatureData.m_identifier = m_parserSchema.getText(); -} - -void SignatureReader::tokenObject(SignatureData &signatureData) -{ - std::string id = m_parserSchema.getReader().attribute(TOKEN_ID); - - if (id.empty()) { - LogWarning("Unsupported value of Attribute Id in Object tag."); - ThrowMsg(ParserSchemaException::UnsupportedValue, - "Unsupported value of Attribute Id in Object tag."); - } - - signatureData.m_objectList.push_back(id); -} - -void SignatureReader::tokenSignatureProperties(SignatureData &signatureData) -{ - (void)signatureData; - if (++m_signaturePropertiesCounter > 1) { - LogWarning("Only one SignatureProperties tag is allowed in Object"); - ThrowMsg(ParserSchemaException::UnsupportedValue, - "Only one SignatureProperties tag is allowed in Object"); - } -} -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/SignatureReader.h b/modules/vcore/src/vcore/SignatureReader.h deleted file mode 100644 index e6368fc..0000000 --- a/modules/vcore/src/vcore/SignatureReader.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file SignatureReader.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief SignatureReader is used to parse widget digital signature. - */ -#ifndef _SIGNATUREREADER_H_ -#define _SIGNATUREREADER_H_ - -#include -#include - -#include "SignatureData.h" -#include "ParserSchema.h" - -namespace ValidationCore { -class SignatureReader -{ - public: - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, TargetRestrictionException) - }; - - SignatureReader(); - - void initialize(SignatureData &data, - const std::string &xmlscheme) - { - m_parserSchema.initialize( - data.getSignatureFileName(), true, SaxReader::VALIDATION_XMLSCHEME, - xmlscheme); - } - - void read(SignatureData &data) - { - m_parserSchema.read(data); - } - - private: - void blankFunction(SignatureData &) - { - } - - void tokenKeyInfo(SignatureData &signatureData); - void tokenKeyModulus(SignatureData &signatureData); - void tokenKeyExponent(SignatureData &signatureData); - void tokenX509Data(SignatureData &signatureData); - void tokenX509Certificate(SignatureData &signatureData); - void tokenPublicKey(SignatureData &signatureData); - void tokenNamedCurve(SignatureData &signatureData); - void tokenRole(SignatureData &signatureData); - void tokenProfile(SignatureData &signatureData); - void tokenObject(SignatureData &signatureData); - void tokenSignatureProperties(SignatureData &signatureData); - void tokenTargetRestriction(SignatureData &signatureData); - - void tokenEndKeyInfo(SignatureData &signatureData); - // KW void tokenEndKeyName(SignatureData &signatureData); - void tokenEndRSAKeyValue(SignatureData &signatureData); - void tokenEndKeyModulus(SignatureData &signatureData); - void tokenEndKeyExponent(SignatureData &signatureData); - void tokenEndX509Data(SignatureData &signatureData); - void tokenEndX509Certificate(SignatureData &signatureData); - void tokenEndPublicKey(SignatureData &signatureData); - void tokenEndECKeyValue(SignatureData &signatureData); - void tokenEndIdentifier(SignatureData &signatureData); - void tokenEndObject(SignatureData &signatureData); - - // DSA key components - void tokenEndDSAPComponent(SignatureData& signatureData); - void tokenEndDSAQComponent(SignatureData& signatureData); - void tokenEndDSAGComponent(SignatureData& signatureData); - void tokenEndDSAYComponent(SignatureData& signatureData); - void tokenEndDSAJComponent(SignatureData& signatureData); - - void tokenEndDSAKeyValue(SignatureData& signatureData); - - void tokenEndDSASeedComponent(SignatureData& signatureData); - void tokenEndDSAPGenCounterComponent(SignatureData& signatureData); - - // temporary values required due reference parsing process - // optional parameters for dsa - std::string m_dsaKeyPComponent; - std::string m_dsaKeyQComponent; - std::string m_dsaKeyGComponent; - std::string m_dsaKeyYComponent; - std::string m_dsaKeyJComponent; - std::string m_dsaKeySeedComponent; - std::string m_dsaKeyPGenCounter; - // temporary values of ecdsa key - std::string m_publicKey; - std::string m_nameCurveURI; - std::string m_modulus; - std::string m_exponent; - - // temporary values required due Object parsing - int m_signaturePropertiesCounter; - bool m_targetRestrictionObjectFound; - - ParserSchema m_parserSchema; -}; -} - -#endif diff --git a/modules/vcore/src/vcore/SignatureValidator.cpp b/modules/vcore/src/vcore/SignatureValidator.cpp deleted file mode 100644 index e965ecc..0000000 --- a/modules/vcore/src/vcore/SignatureValidator.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include - -#include - -#include "CertificateVerifier.h" -#include "OCSPCertMgrUtil.h" -#include "Certificate.h" -#include "ReferenceValidator.h" -#include "SignatureValidator.h" -#include "SSLContainers.h" -#include "ValidatorCommon.h" -#include "ValidatorFactories.h" -#include "XmlsecAdapter.h" - -namespace { -const time_t TIMET_DAY = 60 * 60 * 24; - -const std::string TOKEN_ROLE_AUTHOR_URI = - "http://www.w3.org/ns/widgets-digsig#role-author"; -const std::string TOKEN_ROLE_DISTRIBUTOR_URI = - "http://www.w3.org/ns/widgets-digsig#role-distributor"; -const std::string TOKEN_PROFILE_URI = - "http://www.w3.org/ns/widgets-digsig#profile"; -} // namespace anonymouse - -namespace ValidationCore { - -SignatureValidator::SignatureValidator(bool ocspEnable, - bool crlEnable, - bool complianceMode) : - m_ocspEnable(ocspEnable), - m_crlEnable(crlEnable), - m_complianceModeEnabled(complianceMode) -{ -} - -SignatureValidator::~SignatureValidator() -{ -} - -bool SignatureValidator::checkRoleURI(const SignatureData &data) -{ - std::string roleURI = data.getRoleURI(); - - if (roleURI.empty()) { - LogWarning("URI attribute in Role tag couldn't be empty."); - return false; - } - - if (roleURI != TOKEN_ROLE_AUTHOR_URI && data.isAuthorSignature()) { - LogWarning("URI attribute in Role tag does not " - "match with signature filename."); - return false; - } - - if (roleURI != TOKEN_ROLE_DISTRIBUTOR_URI && !data.isAuthorSignature()) { - LogWarning("URI attribute in Role tag does not " - "match with signature filename."); - return false; - } - return true; -} - -bool SignatureValidator::checkProfileURI(const SignatureData &data) -{ - if (TOKEN_PROFILE_URI != data.getProfileURI()) { - LogWarning( - "Profile tag contains unsupported value in URI attribute(" << - data.getProfileURI() << ")."); - return false; - } - return true; -} - -bool SignatureValidator::checkObjectReferences(const SignatureData &data) -{ - ObjectList objectList = data.getObjectList(); - ObjectList::const_iterator iter; - for (iter = objectList.begin(); iter != objectList.end(); ++iter) { - if (!data.containObjectReference(*iter)) { - LogWarning("Signature does not contain reference for object " << - *iter); - return false; - } - } - return true; -} - -SignatureValidator::Result SignatureValidator::check( - SignatureData &data, - const std::string &widgetContentPath) -{ - bool disregard = false; - - if (!checkRoleURI(data)) { - return SIGNATURE_INVALID; - } - - if (!checkProfileURI(data)) { - return SIGNATURE_INVALID; - } - - // CertificateList sortedCertificateList = data.getCertList(); - - CertificateCollection collection; - collection.load(data.getCertList()); - - // First step - sort certificate - if (!collection.sort()) { - LogWarning("Certificates do not form valid chain."); - return SIGNATURE_INVALID; - } - - // Check for error - if (collection.empty()) { - LogWarning("Certificate list in signature is empty."); - return SIGNATURE_INVALID; - } - - CertificateList sortedCertificateList = collection.getChain(); - - // TODO move it to CertificateCollection - // Add root CA and CA certificates (if chain is incomplete) - sortedCertificateList = - OCSPCertMgrUtil::completeCertificateChain(sortedCertificateList); - - CertificatePtr root = sortedCertificateList.back(); - - // Is Root CA certificate trusted? - CertStoreId::Set storeIdSet = createCertificateIdentifier().find(root); - - // WAC chapter 3.2.1 - verified definition - if (data.isAuthorSignature()) { - if (!storeIdSet.contains(CertStoreId::WAC_PUBLISHER)) { - LogWarning("Author signature has got unrecognized Root CA " - "certificate. Signature will be disregarded."); - disregard = true; - } - LogDebug("Root CA for author signature is correct."); - } else { - if (!storeIdSet.contains(CertStoreId::DEVELOPER) && - !storeIdSet.contains(CertStoreId::WAC_ROOT) && - !storeIdSet.contains(CertStoreId::WAC_MEMBER)) - { - LogWarning("Distiributor signature has got unrecognized Root CA " - "certificate. Signature will be disregarded."); - disregard = true; - } - LogDebug("Root CA for distributor signature is correct."); - } - - data.setStorageType(storeIdSet); - data.setSortedCertificateList(sortedCertificateList); - - // We add only Root CA certificate because WAC ensure that the rest - // of certificates are present in signature files ;-) - XmlSec::XmlSecContext context; - context.signatureFile = data.getSignatureFileName(); - context.certificatePtr = root; - - // Now we should have full certificate chain. - // If the end certificate is not ROOT CA we should disregard signature - // but still signature must be valid... Aaaaaa it's so stupid... - if (!(root->isSignedBy(root))) { - LogWarning("Root CA certificate not found. Chain is incomplete."); - context.allowBrokenChain = true; - } - - // WAC 2.0 SP-2066 The wrt must not block widget installation - // due to expiration of the author certificate. - time_t notAfter = data.getEndEntityCertificatePtr()->getNotAfter(); - bool expired = notAfter < time(NULL); - if (data.isAuthorSignature() && expired) { - context.validationTime = notAfter - TIMET_DAY; - } - // end - - if (XmlSec::NO_ERROR != XmlSecSingleton::Instance().validate(&context)) { - LogWarning("Installation break - invalid package!"); - return SIGNATURE_INVALID; - } - - data.setReference(context.referenceSet); - - if (!checkObjectReferences(data)) { - return SIGNATURE_INVALID; - } - - ReferenceValidator fileValidator(widgetContentPath); - if (ReferenceValidator::NO_ERROR != fileValidator.checkReferences(data)) { - LogWarning("Invalid package - file references broken"); - return SIGNATURE_INVALID; - } - - // It is good time to do OCSP check - // ocspCheck will throw an exception on any error. - // TODO Probably we should catch this exception and add - // some information to SignatureData. - if (!m_complianceModeEnabled && !data.isAuthorSignature()) { - CertificateCollection coll; - coll.load(sortedCertificateList); - - if (!coll.sort()) { - LogDebug("Collection does not contain chain!"); - return SIGNATURE_INVALID; - } - - CertificateVerifier verificator(m_ocspEnable, m_crlEnable); - VerificationStatus result = verificator.check(coll); - - if (result == VERIFICATION_STATUS_REVOKED) { - return SIGNATURE_REVOKED; - } - - if (result == VERIFICATION_STATUS_UNKNOWN || - result == VERIFICATION_STATUS_ERROR) - { - disregard = true; - } - } - - if (disregard) { - LogWarning("Signature is disregard."); - return SIGNATURE_DISREGARD; - } - return SIGNATURE_VERIFIED; -} - -std::string SignatureValidator::FingerprintToColonHex( - const Certificate::Fingerprint &fingerprint) -{ - std::string outString; - - char buff[8]; - - for (size_t i = 0; i < fingerprint.size(); ++i) { - snprintf(buff, - sizeof(buff), - "%02X:", - static_cast(fingerprint[i])); - outString += buff; - } - - // remove trailing ":" - outString.erase(outString.end() - 1); - return outString; -} -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/SignatureValidator.h b/modules/vcore/src/vcore/SignatureValidator.h deleted file mode 100644 index aa381cb..0000000 --- a/modules/vcore/src/vcore/SignatureValidator.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _SIGNATUREVALIDATOR_H_ -#define _SIGNATUREVALIDATOR_H_ - -#include - -#include "Certificate.h" -#include "OCSPCertMgrUtil.h" -#include "SignatureData.h" - -#include "ValidatorCommon.h" -#include "VerificationStatus.h" - -namespace ValidationCore { -// Todo nocopyable -class SignatureValidator -{ - public: - enum Result - { - SIGNATURE_VALID, - SIGNATURE_INVALID, - SIGNATURE_VERIFIED, - SIGNATURE_DISREGARD, // no ocsp response or ocsp return unknown status - SIGNATURE_REVOKED - }; - - /** - * Validation of the signature. - * If falidation succeed SignatureData will contains: - * list of validated references - * set selfSigned value - * root ca certificate - * end entity certificate - */ - Result check(SignatureData &data, - const std::string &widgetContentPath); - - static std::string FingerprintToColonHex( - const Certificate::Fingerprint &fingerprint); - - explicit SignatureValidator(bool ocspEnable, - bool crlEnable, - bool complianceMode); - virtual ~SignatureValidator(); - - private: - bool checkRoleURI(const SignatureData &data); - bool checkProfileURI(const SignatureData &data); - bool checkObjectReferences(const SignatureData &data); - - bool m_ocspEnable; - bool m_crlEnable; - bool m_complianceModeEnabled; -}; - -} // namespace ValidationCore - -#endif // _SIGNATUREVALIDATOR_H_ diff --git a/modules/vcore/src/vcore/SoupMessageSendAsync.cpp b/modules/vcore/src/vcore/SoupMessageSendAsync.cpp deleted file mode 100644 index d8bb132..0000000 --- a/modules/vcore/src/vcore/SoupMessageSendAsync.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ diff --git a/modules/vcore/src/vcore/SoupMessageSendAsync.h b/modules/vcore/src/vcore/SoupMessageSendAsync.h deleted file mode 100644 index c6900e2..0000000 --- a/modules/vcore/src/vcore/SoupMessageSendAsync.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 0.1 - * @file SoupMessageSendAsync.h - * @brief Routines for certificate validation over OCSP - */ -#ifndef _SRC_VALIDATION_CORE_SOUP_MESSAGE_SEND_ASYNC_H_ -#define _SRC_VALIDATION_CORE_SOUP_MESSAGE_SEND_ASYNC_H_ - -#include -#include - -#include - -#include - -#include "SoupMessageSendBase.h" - -namespace SoupWrapper { - -class SoupMessageSendAsync - : public SoupMessageSendBase - , public DPL::Event::ICDelegateSupport -{ - typedef DPL::Event::ICDelegate SoupDelegate; - public: - void sendAsync() { - Assert(m_status == STATUS_IDLE); - Assert(!m_soupSession); - Assert(!m_soupMessage); - - m_status = STATUS_SEND_ASYNC; - m_tryLeft = m_tryCount; - m_mainContext = g_main_context_new(); - - if (!m_mainContext){ - m_status = STATUS_IDLE; - - // call the delegate to outside with error! - return; - } - - m_soupSession = soup_session_async_new_with_options( - SOUP_SESSION_ASYNC_CONTEXT, - m_mainContext, - SOUP_SESSION_TIMEOUT, - m_timeout, - NULL); - - if (!m_soupSession){ - m_status = STATUS_IDLE; - g_object_unref(m_mainContext); - m_mainContext = 0; - - // call the deletage to outside with error! - return; - } - - m_soupMessage = createRequest(); - - if (!m_soupMessage){ - m_status = STATUS_IDLE; - g_object_unref(m_soupSession); - m_soupSession = 0; - g_object_unref(m_mainContext); - m_mainContext = 0; - - // call the delegate to outsize with error! - return; - } - - sendAsyncIterationStart(); - } - - protected: - - struct SoupDelegateOpaque { - SoupDelegate dlg; - }; - - void sendAsyncIterationStart(){ - // ICDelegate could be called only once. - // We can set user data only once. - // We need nasty hack because we will call ICDelegate m_tryCount times. - SoupDelegateOpaque *opaq = new SoupDelegateOpaque; - opaq->dlg = makeICDelegate(&SoupMessageSendAsync::requestReceiver); - - soup_session_queue_message(m_soupSession, - m_soupMessage, - soupSessionCallback, - reinterpret_cast(opaq)); - } - - void sendAsyncIteration(SoupDelegateOpaque *opaq){ - // Replace used ICDelegate with new one without changing - // userdata ;-) - opaq->dlg = makeICDelegate(&SoupMessageSendAsync::requestReceiver); - soup_session_requeue_message(m_soupSession, - m_soupMessage); - } - - void requestReceiver(SoupSession *session, SoupMessage *msg, void *opaque){ - // We are in thread which called sendAsync function. - Assert(session == m_soupSession); - Assert(msg == m_soupMessage); - Assert(opaque != 0); - Assert(m_status == STATUS_SEND_ASYNC); - - m_tryLeft--; - - if (msg->status_code == SOUP_STATUS_OK) { - m_responseBuffer.resize(msg->response_body->length); - memcpy(&m_responseBuffer[0], - msg->response_body->data, - msg->response_body->length); - // We are done. - m_status = STATUS_IDLE; - delete static_cast(opaque); - - // call the delegate to outside! - return; - } - - // Error protocol // - if (m_tryLeft <= 0) { - m_status = STATUS_IDLE; - delete static_cast(opaque); - - // call the delegate to outside with error! - return; - } - - // create delegate and send the request once again. - sendAsyncIteration(reinterpret_cast(opaque)); - } - - static void soupSessionCallback(SoupSession *session, - SoupMessage *msg, - gpointer userdata) - { - // We are in main thread. We need to switch context. - // This delegate can switch context to dpl thread or main thread. - SoupDelegateOpaque *opaque; - opaque = reinterpret_cast(userdata); - opaque->dlg(session, msg, userdata); - } - - int m_tryLeft; - - GMainContext *m_mainContext; - SoupSession *m_soupSession; - SoupMessage *m_soupMessage; -}; - -} // namespace ValidationCore - -#endif diff --git a/modules/vcore/src/vcore/SoupMessageSendBase.cpp b/modules/vcore/src/vcore/SoupMessageSendBase.cpp deleted file mode 100644 index 4d1fafa..0000000 --- a/modules/vcore/src/vcore/SoupMessageSendBase.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 0.1 - * @file SoupMessageSendBase.cpp - * @brief Simple wrapper for soup. - */ -#include "SoupMessageSendBase.h" - -#include -#include -#include - -namespace SoupWrapper { - -SoupMessageSendBase::SoupMessageSendBase() - : m_status(STATUS_IDLE) - , m_timeout(30) - , m_tryCount(5) -{} - -SoupMessageSendBase::~SoupMessageSendBase(){ - Assert(m_status == STATUS_IDLE); -} - -void SoupMessageSendBase::setHeader(const std::string &property, const std::string &value){ - Assert(m_status == STATUS_IDLE); - m_headerMap[property] = value; -} - -void SoupMessageSendBase::setHost(const std::string &host){ - Assert(m_status == STATUS_IDLE); - m_host = host; -} - -void SoupMessageSendBase::setRequest(const std::string &contentType, const MessageBuffer &message){ - Assert(m_status == STATUS_IDLE); - m_requestType = contentType; - m_requestBuffer = message; -} - -SoupMessageSendBase::MessageBuffer SoupMessageSendBase::getResponse() const { - Assert(m_status == STATUS_IDLE); - return m_responseBuffer; -} - -void SoupMessageSendBase::setTimeout(int seconds) { - Assert(m_status == STATUS_IDLE); - Assert(seconds >= 0); - m_timeout = seconds; -} - -void SoupMessageSendBase::setRetry(int retry) { - Assert(m_status == STATUS_IDLE); - Assert(retry >= 0); - m_tryCount = retry + 1; -} - - -SoupMessage* SoupMessageSendBase::createRequest(){ - SoupMessage *message; - - LogInfo("Soup message will be send to: " << m_host.c_str()); - - if (!m_requestBuffer.empty()) { - message = soup_message_new("POST", m_host.c_str()); - } else { - message = soup_message_new("GET", m_host.c_str()); - } - - if (!message) { - LogError("Error creating request!"); - return 0; - } - - FOREACH(it, m_headerMap){ - soup_message_headers_append(message->request_headers, - it->first.c_str(), - it->second.c_str()); - } - - if (!m_requestBuffer.empty()) { - soup_message_set_http_version(message, SOUP_HTTP_1_0); - soup_message_set_request(message, - m_requestType.c_str(), - SOUP_MEMORY_COPY, - &m_requestBuffer[0], - m_requestBuffer.size()); - } - soup_message_set_flags(message, SOUP_MESSAGE_NO_REDIRECT); - return message; -} - -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/SoupMessageSendBase.h b/modules/vcore/src/vcore/SoupMessageSendBase.h deleted file mode 100644 index aaa5fb4..0000000 --- a/modules/vcore/src/vcore/SoupMessageSendBase.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 0.1 - * @file SoupMessageSendBase.h - * @brief Simple wrapper for soup. - */ -#ifndef _SRC_VALIDATION_CORE_SOUP_MESSAGE_SEND_BASE_H_ -#define _SRC_VALIDATION_CORE_SOUP_MESSAGE_SEND_BASE_H_ - -#include -#include -#include - -#include - -namespace SoupWrapper { - -class SoupMessageSendBase { - public: - - typedef std::vector MessageBuffer; - typedef std::map HeaderMap; - - enum RequestStatus { - REQUEST_STATUS_OK, - REQUEST_STATUS_CONNECTION_ERROR - }; - - SoupMessageSendBase(); - - virtual ~SoupMessageSendBase(); - - /** - * Add specific information to request header. - * - * @param[in] property property name (for example "Host") - * @param[in] value property value (for example "onet.pl:80") - */ - void setHeader(const std::string &property, - const std::string &value); - - /** - * Set request destination. - * - * @param[in] host - full path to source (http://onet.pl/index.html) - */ - void setHost(const std::string &host); - - /** - * Set body of request. - * - * @param[in] contentType (for example: "application/ocsp-request") - * @param[in] message body of reqeust - */ - void setRequest(const std::string &contentType, - const MessageBuffer &message); - - /** - * Set network timeout. Default is 30 seconds. - * - * @param[in] seconds timeout in seconds - */ - void setTimeout(int seconds); - - /** - * How many erros soup will accept before he will terminate connection. - * Default is 5. - * - * @param[in] retry number - */ - void setRetry(int retry); - - /** - * Get response from serwer. - */ - MessageBuffer getResponse() const; - - protected: - - SoupMessage* createRequest(); - - enum Status { - STATUS_IDLE, - STATUS_SEND_SYNC, - STATUS_SEND_ASYNC - }; - - Status m_status; - - int m_timeout; - int m_tryCount; - - std::string m_host; - std::string m_requestType; - MessageBuffer m_requestBuffer; - MessageBuffer m_responseBuffer; - HeaderMap m_headerMap; -}; - -} // namespace ValidationCore - -#endif diff --git a/modules/vcore/src/vcore/SoupMessageSendSync.cpp b/modules/vcore/src/vcore/SoupMessageSendSync.cpp deleted file mode 100644 index bca8e3e..0000000 --- a/modules/vcore/src/vcore/SoupMessageSendSync.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 0.1 - * @file SoupMessageSendSync.cpp - * @brief Implementation of soup synchronous interface. - */ -#include "SoupMessageSendSync.h" - -#include -#include - -#include - -#include - -namespace SoupWrapper { - -SoupMessageSendBase::RequestStatus SoupMessageSendSync::sendSync() -{ - Assert(m_status == STATUS_IDLE); - m_status = STATUS_SEND_SYNC; - - ScopedGMainContext context(g_main_context_new()); - - std::unique_ptr > - proxy(vconf_get_str(VCONFKEY_NETWORK_PROXY), free); - - std::unique_ptr > - proxyURI(soup_uri_new (proxy.get()), soup_uri_free); - - LogDebug("Proxy ptr:" << (void*)proxy.get() << - " Proxy addr: " << proxy.get()); - - for(int tryCount = 0; tryCount < m_tryCount; ++ tryCount){ - LogDebug("Try(" << tryCount << ") to download " << m_host); - - ScopedSoupSession session(soup_session_async_new_with_options( - SOUP_SESSION_ASYNC_CONTEXT, - &*context, - SOUP_SESSION_TIMEOUT, - m_timeout, - SOUP_SESSION_PROXY_URI, - proxyURI.get(), - NULL)); - - ScopedSoupMessage msg; - - msg.Reset(createRequest()); - - if (!msg) { - LogError("Unable to send HTTP request."); - m_status = STATUS_IDLE; - return REQUEST_STATUS_CONNECTION_ERROR; - } - soup_session_send_message(&*session, &*msg); - - // if (SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) - - if (msg->status_code == SOUP_STATUS_OK) { - m_responseBuffer.resize(msg->response_body->length); - memcpy(&m_responseBuffer[0], - msg->response_body->data, - msg->response_body->length); - // We are done. - m_status = STATUS_IDLE; - return REQUEST_STATUS_OK; - } else { - LogWarning("Soup failed with code " << msg->status_code - << " message \n------------\n" - << msg->response_body->data - << "\n--------------\n"); - } - } - - m_status = STATUS_IDLE; - return REQUEST_STATUS_CONNECTION_ERROR; -} - -} // namespave ValidationCore diff --git a/modules/vcore/src/vcore/SoupMessageSendSync.h b/modules/vcore/src/vcore/SoupMessageSendSync.h deleted file mode 100644 index ebb451d..0000000 --- a/modules/vcore/src/vcore/SoupMessageSendSync.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 0.1 - * @file SoupMessageSendSync.h - * @brief Wrapper for soup synchronous interface. - */ -#ifndef _SRC_VALIDATION_CORE_SOUP_MESSAGE_SEND_SYNC_H_ -#define _SRC_VALIDATION_CORE_SOUP_MESSAGE_SEND_SYNC_H_ - -#include "SoupMessageSendBase.h" - -#include - -namespace SoupWrapper { - -class SoupMessageSendSync : public SoupMessageSendBase { - public: - RequestStatus sendSync(); - protected: - typedef WRT::ScopedGPointer ScopedSoupMessage; - typedef WRT::ScopedGPointer ScopedSoupSession; - typedef WRT::ScopedGPointer ScopedGMainContext; -}; - -} // namespace ValidationCore - -#endif diff --git a/modules/vcore/src/vcore/VCore.cpp b/modules/vcore/src/vcore/VCore.cpp deleted file mode 100644 index 60bf47e..0000000 --- a/modules/vcore/src/vcore/VCore.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file VCore.cpp - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @brief - */ - -#include -#include -#include -#include -#include -#include -#include - -namespace { -DPL::DB::ThreadDatabaseSupport threadInterface( - VCoreDatabaseConnectionTraits::Address(), - VCoreDatabaseConnectionTraits::Flags()); -} // namespace anonymous - -namespace ValidationCore { - -void AttachToThread(void){ - threadInterface.AttachToThread(); -} - -void DetachFromThread(void){ - threadInterface.DetachFromThread(); -} - -DPL::DB::ThreadDatabaseSupport& ThreadInterface(void) { - return threadInterface; -} - -bool VCoreInit(const std::string& configFilePath, - const std::string& configSchemaPath, - const std::string& databasePath) -{ - SSL_library_init(); - g_thread_init(NULL); - g_type_init(); - - LogDebug("Initializing VCore"); - Config &globalConfig = ConfigSingleton::Instance(); - bool returnValue = globalConfig.setXMLConfigPath(configFilePath) && - globalConfig.setXMLSchemaPath(configSchemaPath) && - globalConfig.setDatabasePath(databasePath); - - Assert(ThreadInterface().CheckTableExist(DB_CHECKSUM_STR) && - "Not a valid vcore database version"); - - return returnValue; -} - -} // namespace ValidationCore - diff --git a/modules/vcore/src/vcore/VCore.h b/modules/vcore/src/vcore/VCore.h deleted file mode 100644 index bb3029a..0000000 --- a/modules/vcore/src/vcore/VCore.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file VCore.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#ifndef _VCORE_SRC_VCORE_VCORE_H_ -#define _VCORE_SRC_VCORE_VCORE_H_ - -#include - -namespace ValidationCore { -/* - * configFilePath - path to XML config file with certificates configuration - * - * configSchemaPath - XMLschema of config file - * - * databasePath - path to database with OCSP/CRL cache. - * - * This function could be run only once. If you call it twice it will - * return false and non data will be set. - * - */ -bool VCoreInit(const std::string& configFilePath, - const std::string& configSchemaPath, - const std::string& databasePath); - -/* - * All thread with are using OCSP/CRL must call AttachToThread function before - * it can call OCSP/CRL. More than one thread could be Attach with OCPS/CRL. - * - * You mast attach thread to OCSP/CRL because OCSP/CRL is using database - * CertificateCachedDAO. For each thread that will be using this database - * vcore must create internal structure (with connection info). - * - */ -void AttachToThread(void); -void DetachFromThread(void); - -} // namespace ValidationCore - -#endif // _VCORE_SRC_VCORE_VCORE_H_ - diff --git a/modules/vcore/src/vcore/VCorePrivate.h b/modules/vcore/src/vcore/VCorePrivate.h deleted file mode 100644 index ed85958..0000000 --- a/modules/vcore/src/vcore/VCorePrivate.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file VCore.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#ifndef _VCORE_SRC_VCORE_VCOREPRIVATE_H_ -#define _VCORE_SRC_VCORE_VCOREPRIVATE_H_ - -#include -#include -#include -#include - -namespace ValidationCore { -DPL::DB::ThreadDatabaseSupport& ThreadInterface(void); -} // namespace ValidationCore - -#endif // _VCORE_SRC_VCORE_VCORE_H_ - diff --git a/modules/vcore/src/vcore/ValidatorCommon.h b/modules/vcore/src/vcore/ValidatorCommon.h deleted file mode 100644 index 8815239..0000000 --- a/modules/vcore/src/vcore/ValidatorCommon.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file ValidatorCommon.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief This file contais definictions of common types used in ValidationCore. - */ -#ifndef _VALIDATORCOMMON_H_ -#define _VALIDATORCOMMON_H_ - -#include -#include -#include - -namespace ValidationCore { -typedef std::set< std::string > ReferenceSet; -typedef std::list< std::string > ObjectList; - -/* - * base deleter func - */ -template -struct ValidatorCoreUniversalFree {}; - -// Template Specialization -#define VC_DECLARE_DELETER(type, function) \ - template <> \ - struct ValidatorCoreUniversalFree { \ - void universal_free(type *ptr){ \ - if (ptr) { \ - function(ptr); } \ - } \ - }; - -template -class AutoPtr -{ - public: - AutoPtr(T *ptr) : - m_data(ptr) - { - } - - AutoPtr(const AutoPtr &second) - { - m_data = second.m_data; - second.m_data = 0; - } - - AutoPtr & operator=(const AutoPtr &second) - { - if (this != &second) { - ValidatorCoreUniversalFree deleter; - deleter.universal_free(m_data); - m_data = second.m_data; - second.m_data = 0; - } - return *this; - } - - /** - * overloaded -> operator, so smart ptr could act as ordinary ptr - */ - T* operator->() - { - return m_data; - } - - ~AutoPtr() - { - ValidatorCoreUniversalFree deleter; - deleter.universal_free(m_data); - } - - /** - * get internal pointer - */ - T* get(void) - { - return m_data; - } - - private: - mutable T *m_data; -}; -} // namespace ValidationCore - -#endif // _VALIDATORCOMMON_H_ diff --git a/modules/vcore/src/vcore/ValidatorFactories.cpp b/modules/vcore/src/vcore/ValidatorFactories.cpp deleted file mode 100644 index bd72237..0000000 --- a/modules/vcore/src/vcore/ValidatorFactories.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#include - -#include - -#include -#include -#include - -namespace ValidationCore { - -const CertificateIdentifier& createCertificateIdentifier() -{ - static CertificateIdentifier certificateIdentifier; - static bool initialized = false; - if (!initialized) { - CertificateConfigReader reader; - std::string file = - ConfigSingleton::Instance().getXMLConfigPath(); - std::string schema = - ConfigSingleton::Instance().getXMLSchemaPath(); - reader.initialize(file, schema); - reader.read(certificateIdentifier); - initialized = true; - } - return certificateIdentifier; -} - -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/ValidatorFactories.h b/modules/vcore/src/vcore/ValidatorFactories.h deleted file mode 100644 index 075eef1..0000000 --- a/modules/vcore/src/vcore/ValidatorFactories.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#ifndef _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_VALIDATORFACTORY_H_ -#define _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_VALIDATORFACTORY_H_ - -#include - -namespace ValidationCore { -// First use of CertificateIdentificator should initialized it. -// We do not want to create cyclic dependencies between -// CertificateConfigReader and CertificateIdentificator so -// we are using factory method to create CertificateIdentificator. - -const CertificateIdentifier& createCertificateIdentifier(); -} // namespace ValidationCore - -#endif // _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_VALIDATORFACTORY_H_ diff --git a/modules/vcore/src/vcore/VerificationStatus.cpp b/modules/vcore/src/vcore/VerificationStatus.cpp deleted file mode 100644 index 98199ad..0000000 --- a/modules/vcore/src/vcore/VerificationStatus.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "VerificationStatus.h" - -namespace ValidationCore { -VerificationStatus VerificationStatusSet::convertToStatus() const -{ - if (m_verdictMap & VERIFICATION_STATUS_REVOKED) { - return VERIFICATION_STATUS_REVOKED; - } - - if (m_verdictMap & VERIFICATION_STATUS_VERIFICATION_ERROR) { - return VERIFICATION_STATUS_VERIFICATION_ERROR; - } - - if (m_verdictMap & VERIFICATION_STATUS_ERROR) { - return VERIFICATION_STATUS_ERROR; - } - - if (m_verdictMap & VERIFICATION_STATUS_UNKNOWN) { - return VERIFICATION_STATUS_UNKNOWN; - } - - if (m_verdictMap & VERIFICATION_STATUS_CONNECTION_FAILED) { - return VERIFICATION_STATUS_CONNECTION_FAILED; - } - - if (m_verdictMap & VERIFICATION_STATUS_NOT_SUPPORT) { - return VERIFICATION_STATUS_NOT_SUPPORT; - } - - if (m_verdictMap & VERIFICATION_STATUS_GOOD) { - return VERIFICATION_STATUS_GOOD; - } - - return VERIFICATION_STATUS_ERROR; -} -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/VerificationStatus.h b/modules/vcore/src/vcore/VerificationStatus.h deleted file mode 100644 index 67eecac..0000000 --- a/modules/vcore/src/vcore/VerificationStatus.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _SRC_VALIDATION_CORE_VERIFICATION_STATUS_H_ -#define _SRC_VALIDATION_CORE_VERIFICATION_STATUS_H_ - -namespace ValidationCore { -enum VerificationStatus -{ - //! The certificate has not been revoked. - /*! Connection to OCSP responder was successful and the certificate - * has not been revoked. - */ - VERIFICATION_STATUS_GOOD = 1, - - //! The certificate has been revoked. - /*! Connection to OCSP responder was successful and the certificate - * has been revoked. - * RFC2560: "The "revoked" state indicates that the certificate has - * been revoked (either permanantly or temporarily - * (on hold))." - */ - VERIFICATION_STATUS_REVOKED = 1 << 1, - - //! The certificate status is unknown. - /*! Connection to OCSP responder was successful and the certificate - * has unknown status. - * - * RFC2560: "The "unknown" state indicates that the responder - * doesn't know about the certificate being requested." - */ - VERIFICATION_STATUS_UNKNOWN = 1 << 2, - - //! The certificate status was not figure out. - /*! The response from ocsp/crl server contains broken signature. */ - VERIFICATION_STATUS_VERIFICATION_ERROR = 1 << 3, - - //! The certificate status was not figure out. - /*! The certificate does not contain ocsp/crl extension. */ - VERIFICATION_STATUS_NOT_SUPPORT = 1 << 4, - - //! The certificate status was not figure out. - /*! The CertMgr could not connect to OCSP responder. */ - VERIFICATION_STATUS_CONNECTION_FAILED = 1 << 5, - - //! The certificate status is unknown due to internal error inside OCSP - VERIFICATION_STATUS_ERROR = 1 << 6 -}; - -class VerificationStatusSet -{ - public: - VerificationStatusSet() : m_verdictMap(0) - { - } - - inline void add(VerificationStatus status) - { - m_verdictMap |= status; - } - - inline bool contains(VerificationStatus status) const - { - return m_verdictMap & status; - } - - inline bool isEmpty() const - { - return 0 == m_verdictMap; - } - - inline void operator+=(const VerificationStatusSet &second) - { - m_verdictMap |= second.m_verdictMap; - } - - inline void reset() - { - m_verdictMap = 0; - } - - VerificationStatus convertToStatus() const; - - private: - unsigned int m_verdictMap; -}; - -/* TODO this status should be defined in wrt-engine sources */ -enum WidgetVerificationStatus -{ - // All certificate has been veficated and all certificates are good. - // Widget is able to be installed. - WIDGET_VERIFICATION_STATUS_GOOD, - // Some certificate has been revoked. Widget is not able to be installed. - WIDGET_VERIFICATION_STATUS_REVOKED, -}; -} // namespace ValidationCore - -#endif // _SRC_VALIDATION_CORE_VERIFICATION_STATUS_H_ diff --git a/modules/vcore/src/vcore/WacOrigin.cpp b/modules/vcore/src/vcore/WacOrigin.cpp deleted file mode 100644 index 7ca0174..0000000 --- a/modules/vcore/src/vcore/WacOrigin.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#include "WacOrigin.h" - -#include -#include -#include - -#include <> - -#include -#include "ValidatorCommon.h" - -namespace { -const std::string SCHEME_HTTP = "http"; -const std::string SCHEME_HTTPS = "https"; -const int PORT_HTTP = 80; -const int PORT_HTTPS = 443; -} - -namespace ValidationCore { -VC_DECLARE_DELETER(iri_struct, iri_destroy) - -WacOrigin::WacOrigin(const std::string &url) : - m_port(0), - m_parseFailed(false) -{ - parse(url.c_str()); -} - -WacOrigin::WacOrigin(const char *url) : - m_port(0), - m_parseFailed(false) -{ - parse(url); -} - -bool WacOrigin::operator==(const WacOrigin &second) const -{ - if (m_parseFailed || second.m_parseFailed) { - return false; - } - - return (m_scheme == second.m_scheme) && - (m_host == second.m_host) && - (m_port == second.m_port); -} - -void WacOrigin::parse(const char *url) -{ - // Step are taken from algorihtm: - // http://www.w3.org/TR/html5/origin-0.html#origin-0 - - // Step 1 - // Step 2 - AutoPtr iri(iri_parse(url)); - if (!iri.get()) { - m_parseFailed = true; - return; - } - - if (iri->scheme) { - m_scheme = iri->scheme; - } else { - m_parseFailed = true; - return; - } - - // Step 3 - Skip this point. - // WAC 2.0 PRV - we are suport only "http" and "https" schemas. - - // Step 4 - Todo - - // Step 5 - std::transform(m_scheme.begin(), m_scheme.end(), m_scheme.begin(), tolower); - - // Step 6 - we only support "http" and "https" schemas - if ((m_scheme != SCHEME_HTTP) && (m_scheme != SCHEME_HTTPS)) { - m_parseFailed = true; - return; - } - - // Step 7 - Skip. We do not support "file" schema. - - // Step 8 - if (iri->host) { - m_host = iri->host; - } else { - m_parseFailed = true; - return; - } - - // Step 9 - char *output = NULL; - if (IDNA_SUCCESS != - idna_to_ascii_lz(m_host.c_str(), &output, IDNA_USE_STD3_ASCII_RULES)) { - LogError("libidn error"); - m_parseFailed = true; - free(output); - return; - } - m_host = output; - free(output); - - // Step 10 - std::transform(m_host.begin(), m_host.end(), m_host.begin(), ::tolower); - - // Step 11 - if (iri->port) { - m_port = iri->port; - } else { - setPort(); - } - - // Step 12 - Skip it. We do not return anything. - // User should create geters if he need access to schema/host/port. -} - -void WacOrigin::setPort() -{ - if (SCHEME_HTTP == m_scheme) { - m_port = PORT_HTTP; - return; - } else if (SCHEME_HTTPS == m_scheme) { - m_port = PORT_HTTPS; - return; - } else { - LogDebug("Scheme " << m_scheme << " is not support by WAC2.0"); - m_parseFailed = true; - } -} -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/WacOrigin.h b/modules/vcore/src/vcore/WacOrigin.h deleted file mode 100644 index d706fe3..0000000 --- a/modules/vcore/src/vcore/WacOrigin.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief This is stub for HTML5Origin implementation. - * This implementation is compatible with WAC 2.0 PRV requirements - * and is _not_ full compatible with ORIGIN algorithm requirements - * defined in http://www.w3.org/TR/html5/origin-0.html#origin-0 - */ -#ifndef _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_HTML5ORIGIN_H_ -#define _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_HTML5ORIGIN_H_ - -#include - -namespace ValidationCore { -class WacOrigin -{ - public: - - WacOrigin(const std::string &url); - WacOrigin(const char *url); - - bool operator!=(const WacOrigin &second) const - { - return !(operator==(second)); - } - - bool operator==(const WacOrigin &second) const; - - private: - void parse(const char *url); - void setPort(); - - std::string m_scheme; - std::string m_host; - int m_port; - bool m_parseFailed; // if parsing failed we should return unique identifier -}; -} //namespace ValidationCore - -#endif // _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_HTML5ORIGIN_H_ diff --git a/modules/vcore/src/vcore/XmlsecAdapter.cpp b/modules/vcore/src/vcore/XmlsecAdapter.cpp deleted file mode 100644 index 2c3f231..0000000 --- a/modules/vcore/src/vcore/XmlsecAdapter.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file XmlsecAdapter.cpp - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ - -/* - * Copyright (C) 2002-2003 Aleksey Sanin. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include -#include - -#include -#include -#include - -#ifndef XMLSEC_NO_XSLT -#include -#endif /* XMLSEC_NO_XSLT */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "XmlsecAdapter.h" -#include -IMPLEMENT_SINGLETON(ValidationCore::XmlSec) - -namespace ValidationCore { -VC_DECLARE_DELETER(xmlSecKeysMngr, xmlSecKeysMngrDestroy) - -static const char* DIGEST_MD5 = "md5"; - -std::string XmlSec::s_prefixPath; - -int XmlSec::fileMatchCallback(const char *filename) -{ - std::string path = s_prefixPath + filename; - return xmlFileMatch(path.c_str()); -} - -void* XmlSec::fileOpenCallback(const char *filename) -{ - std::string path = s_prefixPath + filename; - LogDebug("Xmlsec opening: " << path); - return xmlFileOpen(path.c_str()); -} - -int XmlSec::fileReadCallback(void *context, - char *buffer, - int len) -{ - return xmlFileRead(context, buffer, len); -} - -int XmlSec::fileCloseCallback(void *context) -{ - return xmlFileClose(context); -} - -void XmlSec::fileExtractPrefix(XmlSecContext *context) -{ - if (!(context->workingDirectory.empty())) { - s_prefixPath = context->workingDirectory; - return; - } - - s_prefixPath = context->signatureFile; - size_t pos = s_prefixPath.rfind('/'); - if (pos == std::string::npos) { - s_prefixPath.clear(); - } else { - s_prefixPath.erase(pos + 1, std::string::npos); - } -} - -XmlSec::XmlSec() : - m_initialized(false) -{ - LIBXML_TEST_VERSION - xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; - xmlSubstituteEntitiesDefault(1); -#ifndef XMLSEC_NO_XSLT - xmlIndentTreeOutput = 1; -#endif - - if (xmlSecInit() < 0) { - LogError("Xmlsec initialization failed."); - ThrowMsg(Exception::InternalError, "Xmlsec initialization failed."); - } - - if (xmlSecCheckVersion() != 1) { - xmlSecShutdown(); - LogError("Loaded xmlsec library version is not compatible."); - ThrowMsg(Exception::InternalError, - "Loaded xmlsec library version is not compatible."); - } - -#ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING - if (xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) { - xmlSecShutdown(); - LogError( - "Error: unable to load default xmlsec-crypto library. Make sure " - "that you have it installed and check shared libraries path " - "(LD_LIBRARY_PATH) envornment variable."); - ThrowMsg(Exception::InternalError, - "Unable to load default xmlsec-crypto library."); - } -#endif - - if (xmlSecCryptoAppInit(NULL) < 0) { - xmlSecShutdown(); - LogError("Crypto initialization failed."); - ThrowMsg(Exception::InternalError, "Crypto initialization failed."); - } - - if (xmlSecCryptoInit() < 0) { - xmlSecCryptoAppShutdown(); - xmlSecShutdown(); - LogError("Xmlsec-crypto initialization failed."); - ThrowMsg(Exception::InternalError, - "Xmlsec-crypto initialization failed."); - } - - m_initialized = true; -} - -void XmlSec::deinitialize(void) -{ - Assert(m_initialized); - - /* Shutdown xmlsec-crypto library */ - xmlSecCryptoShutdown(); - - /* Shutdown crypto library */ - xmlSecCryptoAppShutdown(); - - /* Shutdown xmlsec library */ - xmlSecShutdown(); - - /* Shutdown libxslt/libxml */ -#ifndef XMLSEC_NO_XSLT - xsltCleanupGlobals(); -#endif /* XMLSEC_NO_XSLT */ - - s_prefixPath.clear(); - m_initialized = false; -} - -XmlSec::~XmlSec() -{ - if (m_initialized) { - deinitialize(); - } -} - -XmlSec::Result XmlSec::validateFile(XmlSecContext *context, - xmlSecKeysMngrPtr mngr) -{ - xmlDocPtr doc = NULL; - xmlNodePtr node = NULL; - xmlSecDSigCtxPtr dsigCtx = NULL; - int size, res = -1; - - fileExtractPrefix(context); - LogDebug("Prefix path: " << s_prefixPath); - - xmlSecIOCleanupCallbacks(); - - xmlSecIORegisterCallbacks( - fileMatchCallback, - fileOpenCallback, - fileReadCallback, - fileCloseCallback); - - /* load file */ - doc = xmlParseFile(context->signatureFile.c_str()); - if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)) { - LogWarning("Unable to parse file " << context->signatureFile); - goto done; - } - - /* find start node */ - node = xmlSecFindNode(xmlDocGetRootElement( - doc), xmlSecNodeSignature, xmlSecDSigNs); - if (node == NULL) { - LogWarning("Start node not found in " << context->signatureFile); - goto done; - } - - /* create signature context */ - dsigCtx = xmlSecDSigCtxCreate(mngr); - if (dsigCtx == NULL) { - LogError("Failed to create signature context."); - goto done; - } - - if (context->allowBrokenChain) { - dsigCtx->keyInfoReadCtx.flags |= - XMLSEC_KEYINFO_FLAGS_ALLOW_BROKEN_CHAIN; - } - - if (context->validationTime) { - LogDebug("Setting validation time."); - dsigCtx->keyInfoReadCtx.certsVerificationTime = context->validationTime; - } - - /* Verify signature */ - if (xmlSecDSigCtxVerify(dsigCtx, node) < 0) { - LogWarning("Signature verify error."); - goto done; - } - - if (dsigCtx->keyInfoReadCtx.flags2 & - XMLSEC_KEYINFO_ERROR_FLAGS_BROKEN_CHAIN) { - LogWarning("XMLSEC_KEYINFO_FLAGS_ALLOW_BROKEN_CHAIN was set to true!"); - LogWarning("Signature contains broken chain!"); - context->errorBrokenChain = true; - } - - /* print verification result to stdout */ - if (dsigCtx->status == xmlSecDSigStatusSucceeded) { - LogDebug("Signature is OK"); - res = 0; - } else { - LogDebug("Signature is INVALID"); - goto done; - } - - if (dsigCtx->c14nMethod && dsigCtx->c14nMethod->id && - dsigCtx->c14nMethod->id->name) { - LogInfo("Canonicalization method: " << - reinterpret_cast(dsigCtx->c14nMethod->id->name)); - } - - size = xmlSecPtrListGetSize(&(dsigCtx->signedInfoReferences)); - for (int i = 0; i < size; ++i) { - xmlSecDSigReferenceCtxPtr dsigRefCtx = - (xmlSecDSigReferenceCtxPtr)xmlSecPtrListGetItem(&(dsigCtx-> - signedInfoReferences), - i); - if (dsigRefCtx && dsigRefCtx->uri) { - if (dsigRefCtx->digestMethod && dsigRefCtx->digestMethod->id && - dsigRefCtx->digestMethod->id->name) { - const char* pDigest = - reinterpret_cast(dsigRefCtx->digestMethod->id - ->name); - std::string strDigest(pDigest); - LogInfo("reference digest method: " << - reinterpret_cast(dsigRefCtx->digestMethod - ->id - ->name)); - if (strDigest == DIGEST_MD5) { - LogWarning("MD5 digest method used! Please use sha"); - res = -1; - break; - } - } - context->referenceSet.insert(std::string(reinterpret_cast( - dsigRefCtx->uri))); - } - } - -done: - /* cleanup */ - if (dsigCtx != NULL) { - xmlSecDSigCtxDestroy(dsigCtx); - } - - if (doc != NULL) { - xmlFreeDoc(doc); - } - - if (res) { - return ERROR_INVALID_SIGNATURE; - } - return NO_ERROR; -} - -void XmlSec::loadDERCertificateMemory(XmlSecContext *context, - xmlSecKeysMngrPtr mngr) -{ - unsigned char *derCertificate = NULL; - int size = i2d_X509(context->certificatePtr->getX509(), &derCertificate); - - if (!derCertificate) { - LogError("Failed during x509 conversion to der format."); - ThrowMsg(Exception::InternalError, - "Failed during x509 conversion to der format."); - } - - if (xmlSecCryptoAppKeysMngrCertLoadMemory(mngr, - derCertificate, - size, - xmlSecKeyDataFormatDer, - xmlSecKeyDataTypeTrusted) < 0) { - OPENSSL_free(derCertificate); - LogError("Failed to load der certificate from memory."); - ThrowMsg(Exception::InternalError, - "Failed to load der certificate from memory."); - } - - OPENSSL_free(derCertificate); -} - -void XmlSec::loadPEMCertificateFile(XmlSecContext *context, - xmlSecKeysMngrPtr mngr) -{ - if (xmlSecCryptoAppKeysMngrCertLoad(mngr, - context->certificatePath.c_str(), - xmlSecKeyDataFormatPem, - xmlSecKeyDataTypeTrusted) < 0) { - LogError("Failed to load PEM certificate from file."); - ThrowMsg(Exception::InternalError, - "Failed to load PEM certificate from file."); - } -} - -XmlSec::Result XmlSec::validate(XmlSecContext *context) -{ - Assert(context); - Assert(!(context->signatureFile.empty())); - Assert(context->certificatePtr.Get() || !(context->certificatePath.empty())); - - if (!m_initialized) { - LogError("XmlSec is not initialized."); - ThrowMsg(Exception::InternalError, "XmlSec is not initialized"); - } - - AutoPtr mngr(xmlSecKeysMngrCreate()); - - if (!mngr.get()) { - LogError("Failed to create keys manager."); - ThrowMsg(Exception::InternalError, "Failed to create keys manager."); - } - - if (xmlSecCryptoAppDefaultKeysMngrInit(mngr.get()) < 0) { - LogError("Failed to initialize keys manager."); - ThrowMsg(Exception::InternalError, "Failed to initialize keys manager."); - } - context->referenceSet.clear(); - - if (context->certificatePtr.Get()) { - loadDERCertificateMemory(context, mngr.get()); - } - - if (!context->certificatePath.empty()) { - loadPEMCertificateFile(context, mngr.get()); - } - - return validateFile(context, mngr.get()); -} -} // namespace ValidationCore diff --git a/modules/vcore/src/vcore/XmlsecAdapter.h b/modules/vcore/src/vcore/XmlsecAdapter.h deleted file mode 100644 index 4104c88..0000000 --- a/modules/vcore/src/vcore/XmlsecAdapter.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file XmlSecAdapter.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief - */ -#ifndef _XMLSECADAPTER_H_ -#define _XMLSECADAPTER_H_ - -#include - -#include -#include -#include - -#include "Certificate.h" -#include "ValidatorCommon.h" - -namespace ValidationCore { -class XmlSec : public DPL::Noncopyable -{ - public: - - struct XmlSecContext - { - /* You _must_ set one of the value: certificatePath or certificate. */ - XmlSecContext() : - validationTime(0), - allowBrokenChain(false), - errorBrokenChain(false) - { - } - - /* - * Absolute path to signature file. - */ - std::string signatureFile; - /* - * Direcotory with signed data. - * If you leave it empty xmlsec will use directory extracted - * from signatureFile. - */ - std::string workingDirectory; - /* - * Path to trusted certificate. - */ - std::string certificatePath; - /* - * Trusted certificate. In most cases it should be Root CA certificate. - */ - CertificatePtr certificatePtr; - /* - * Validation date. - * 0 - uses current time. - */ - time_t validationTime; - /* - * Input parameter. - * If true, signature validation will not be interrupted by chain error. - * If true and chain is broken then the value errorBrokenChain will be - * set to true. - */ - bool allowBrokenChain; - /* - * Output parameter. - * This will be set if chain is incomplete or broken. - */ - bool errorBrokenChain; - /* - * Output parameter. - * Reference checked by xmlsec - */ - ReferenceSet referenceSet; - }; - - enum Result - { - NO_ERROR, - ERROR_INVALID_SIGNATURE - }; - - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, InternalError) - }; - - /* - * Context - input/output param. - */ - Result validate(XmlSecContext *context); - protected: - XmlSec(); - ~XmlSec(); - private: - void deinitialize(void); - - void loadDERCertificateMemory(XmlSecContext *context, - xmlSecKeysMngrPtr mngr); - void loadPEMCertificateFile(XmlSecContext *context, - xmlSecKeysMngrPtr mngr); - Result validateFile(XmlSecContext *context, - xmlSecKeysMngrPtr mngr); - - bool m_initialized; - - static std::string s_prefixPath; - static int fileMatchCallback(const char *filename); - static void* fileOpenCallback(const char *filename); - static int fileReadCallback(void *context, - char *buffer, - int len); - static int fileCloseCallback(void *context); - static void fileExtractPrefix(XmlSecContext *context); -}; - -typedef DPL::Singleton XmlSecSingleton; -} // namespace ValidationCore -#endif // _XMLSECVERIFICATOR_H_ diff --git a/modules/vcore/src/vcore/scoped_gpointer.h b/modules/vcore/src/vcore/scoped_gpointer.h deleted file mode 100644 index 78772df..0000000 --- a/modules/vcore/src/vcore/scoped_gpointer.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @file scoped_fclose.h - * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of scoped fclose RAII - */ -#ifndef WRT_ENGINE_SRC_COMMON_SCOPED_GPOINTER_H -#define WRT_ENGINE_SRC_COMMON_SCOPED_GPOINTER_H - -#include -#include - -#include -#include - -namespace WRT { -struct ScopedGPointerPolicy -{ - typedef gpointer Type; - static Type NullValue() - { - return NULL; - } - static void Destroy(Type pointer) - { - if (pointer != NULL) { - g_object_unref(pointer); - } - } -}; - -template -class ScopedGPointer : public DPL::ScopedResource -{ - typedef ScopedGPointerPolicy Policy; - typedef DPL::ScopedResource BaseType; - - public: - explicit ScopedGPointer(typename Policy::Type pointer = - Policy::NullValue()) : - BaseType(pointer) - { - } - - Class *operator->() const throw() - { - Assert(this->m_value != Policy::NullValue() && - "Dereference of scoped NULL pointer!"); - return static_cast(this->m_value); - } - - Class & operator *() const throw() - { - Assert(this->m_value != Policy::NullValue() && - "Dereference of scoped NULL pointer!"); - return *static_cast(this->m_value); - } -}; -} // namespace WRT - -#endif // WRT_ENGINE_SRC_COMMON_SCOPED_GPOINTER_H diff --git a/modules/widget_dao/dao/bind_to_dao.h b/modules/widget_dao/dao/bind_to_dao.h deleted file mode 100644 index 9b9c2d3..0000000 --- a/modules/widget_dao/dao/bind_to_dao.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file bind_to_dao.h - * @author Grzegorz Krawczyk (g.krawczyk@samsung.com) - * @version 1.0 - * @brief - */ - -#ifndef WRT_SRC_CONFIGURATION_BIND_TO_DAO_H_ -#define WRT_SRC_CONFIGURATION_BIND_TO_DAO_H_ - -namespace WrtDB { - -/** - * @param ObjectType type of object used as delegate argument - * @param RetType Type returned from the external function - * @param ExtArg Type of argument required by external fun - * @param getterFun Object Type method which returns value of type ExtArg - * used as argument for external function - * */ -//STATIC FUNCTION -template < - typename ObjectType, - typename ValueType, - typename ExtArg, - ExtArg(ObjectType::*argGetter) () const, - ValueType(*externalGetter) (ExtArg) - > -struct BindToDAO_Static -{ - static ValueType Get(DPL::Model* obj) - { - ObjectType* instance = static_cast(obj); - - return externalGetter((instance->*argGetter)()); - } -}; - -template < - typename ObjectType, - typename ValueType, - typename ExtArg, - typename ExtObject, - ExtArg(ObjectType::*argGetter) () const, - ValueType(ExtObject::*externalGetter) () const - > -struct BindToDAO -{ - static ValueType Get(DPL::Model* obj) - { - ObjectType* instance = static_cast(obj); - ExtObject extObject((instance->*argGetter)()); - return (extObject.*externalGetter)(); - } -}; - -} // namespace WrtDB - -#endif diff --git a/modules/widget_dao/dao/global_config.cpp b/modules/widget_dao/dao/global_config.cpp deleted file mode 100644 index bf68cc4..0000000 --- a/modules/widget_dao/dao/global_config.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include - -#include -#include - -namespace WrtDB { -namespace GlobalConfig { -bool IsOCSPEnabled() -{ - static const char *val = getenv("WRT_OCSP_ENABLE"); - static bool enableOCSP = val && (strcmp(val, "1") == 0); - return enableOCSP; -} - -bool IsCRLEnabled() -{ - static const char *val = getenv("WRT_CRL_ENABLE"); - static bool enableOCSP = val && (strcmp(val, "1") == 0); - return enableOCSP; -} - -} // namespace GlobalConfig -} // namespace WrtDB - diff --git a/packaging/dpl.spec b/packaging/dpl.spec deleted file mode 100644 index 0b043d7..0000000 --- a/packaging/dpl.spec +++ /dev/null @@ -1,79 +0,0 @@ -Name: dpl -Summary: Design patterns library -Version: 0.1.57 -Release: 1 -Group: System/Libraries -License: TBD -Source0: %{name}-%{version}.tar.bz2 -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig -BuildRequires: cmake -BuildRequires: pkgconfig(ecore) -BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(heynoti) -BuildRequires: pkgconfig(appcore-efl) -BuildRequires: pkgconfig(libssl) -BuildRequires: pkgconfig(sqlite3) -BuildRequires: pkgconfig(db-util) -BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(zlib) -BuildRequires: pkgconfig(libpcrecpp) -BuildRequires: pkgconfig(icu-uc) - -BuildRoot: %{_tmppath}/%{name}-%{version}-build - -%description -Design patterns library is a collection of useful C++ utilities to easily develop window applications. - -%package efl -Summary: Design patterns library - EFL based -Group: System/Libraries - -%description efl -Design patterns library is a collection of useful C++ utilities to easily develop window applications. - -%package efl-devel -Summary: Design patterns library - EFL based developer files -Group: Development/Libraries -Requires: %{name}-efl = %{version}-%{release} - -%description efl-devel -Design patterns library is a collection of useful C++ utilities to easily develop window applications. The most important part of library is full MVC support. It also supports event-based architecture, adds wrappers for many packages and provides many basic C++ utilities as RAII objects, singletons, and many other. - -%prep -%setup -q -n %{name}-%{version} - -%build - -cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ - -DDPL_LOG=ON \ - -DDISABLE_GTK=ON - -# Call make instruction with smp support -make %{?jobs:-j%jobs} - -# >> build post -# << build post -%install -rm -rf %{buildroot} -%make_install - -%clean -rm -rf %{buildroot} - -%post -p /sbin/ldconfig - -%postun -p /sbin/ldconfig - - -%files efl -%defattr(-,root,root,-) -%{_libdir}/lib*-efl.so* -# << files - -%files efl-devel -%defattr(-,root,root,-) -%{_includedir}/dpl-efl/* -%{_libdir}/pkgconfig/*-efl.pc - diff --git a/tests/ace/AttributeSetter.cpp b/tests/ace/AttributeSetter.cpp deleted file mode 100644 index 18a31f0..0000000 --- a/tests/ace/AttributeSetter.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "AttributeSetter.h" - -#include -IMPLEMENT_SINGLETON(AttributeSetter) diff --git a/tests/ace/AttributeSetter.h b/tests/ace/AttributeSetter.h deleted file mode 100644 index 20962ae..0000000 --- a/tests/ace/AttributeSetter.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file AttributeSetter.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 0.1 - * @brief Stub for attribute_facade.h - */ -#ifndef _TEST_ACE_TESTS_ATTRIBUTE_SETTER_ -#define _TEST_ACE_TESTS_ATTRIBUTE_SETTER_ - -#include -#include -#include - -#include -#include -#include - -#include -#include - -class AttributeSetter { -public: - typedef std::list ValueList; - typedef std::map AttributeMap; - typedef std::map CollectionHandlerMap; - - typedef std::list Evil; - - void get(const Request &request, - const Evil* evil) - { - int handle = request.getWidgetHandle(); - - CollectionHandlerMap::iterator widgetContextIt = - m_collectionMap.find(handle); - - if (widgetContextIt == m_collectionMap.end()) { - LogError("WidgetContext is empty"); - return; - } - - FOREACH(it, *evil) - { - std::string attrName = *(it->first); - - if (attrName == "device-cap") { - Request::DeviceCapabilitySet devCapSet = - request.getDeviceCapabilitySet(); - std::copy(devCapSet.begin(), - devCapSet.end(), - std::back_inserter(*(it->second))); - continue; - } - - AttributeMap::iterator attrIt = - widgetContextIt->second.find(attrName); - - if (attrIt == widgetContextIt->second.end()) { - LogError("No attribute: " << attrName << - " in context nr: " << handle); - const ATTRIBUTE &a = *it; - const_cast(a).second = NULL; - continue; - } - - ValueList valueList = attrIt->second; - - std::copy(valueList.begin(), - valueList.end(), - std::back_inserter(*(it->second))); - } - } - - void addValue(int handler, - const std::string &attributeName, - const std::string &attributeValue) - { - m_collectionMap[handler][attributeName].push_back(attributeValue); - } - - std::string getValue(int handler, const std::string &attributeName) - { - std::list lst = m_collectionMap[handler][attributeName]; - if (lst.empty()) - return "fake-device-name-that-should-not-match-with-anything"; - return lst.front(); - } - - void addValue(int handler, - const char *attributeName, - const char *attributeValue) - { - std::string aN = attributeName; - std::string aV = attributeValue; - addValue(handler, aN, aV); - } - - void clear() { - m_collectionMap.clear(); - } -protected: - AttributeSetter(){} - ~AttributeSetter(){} -private: - CollectionHandlerMap m_collectionMap; -}; - -typedef DPL::Singleton AttributeSetterSingleton; - -#endif // _TEST_ACE_TESTS_ATTRIBUTE_SETTER_ diff --git a/tests/ace/CMakeLists.txt b/tests/ace/CMakeLists.txt deleted file mode 100644 index b65f6bf..0000000 --- a/tests/ace/CMakeLists.txt +++ /dev/null @@ -1,75 +0,0 @@ -# -#Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) -# @version 0.1 -# @brief -# -INCLUDE(FindPkgConfig) -SET(TARGET_ACE_TEST "dpl-tests-ace") - -PKG_CHECK_MODULES(ACE_TEST_DEP - libxml-2.0 - gobject-2.0 - REQUIRED - ) - -# Set DPL tests sources -SET(ACE_TESTS_SOURCES - ${PROJECT_SOURCE_DIR}/tests/ace/ace_tests.cpp - ${PROJECT_SOURCE_DIR}/tests/ace/loop_control.cpp - ${PROJECT_SOURCE_DIR}/tests/ace/TestSuite01.cpp - ${PROJECT_SOURCE_DIR}/tests/ace/TestSuite02.cpp - ${PROJECT_SOURCE_DIR}/tests/ace/TestSuite03.cpp - ${PROJECT_SOURCE_DIR}/tests/ace/TestSuite04.cpp - ${PROJECT_SOURCE_DIR}/tests/ace/TestSuite05.cpp - ${PROJECT_SOURCE_DIR}/tests/ace/TestSuite06.cpp - ${PROJECT_SOURCE_DIR}/tests/ace/TestSuite07.cpp - ${PROJECT_SOURCE_DIR}/tests/ace/Interfaces.cpp - ${PROJECT_SOURCE_DIR}/tests/ace/PEPSingleton.cpp - ${PROJECT_SOURCE_DIR}/tests/ace/AttributeSetter.cpp - ) - -INCLUDE_DIRECTORIES( - ${SYS_EFL_INCLUDE_DIRS} - ${DPL_TEST_INCLUDE_DIR} - ${PROJECT_SOURCE_DIR}/modules/ace/include - ${PROJECT_SOURCE_DIR}/tests/ace - ${ACE_TEST_DEP_INCLUDE_DIRS} - ) - -ADD_EXECUTABLE(${TARGET_ACE_TEST} ${ACE_TESTS_SOURCES}) - -TARGET_LINK_LIBRARIES(${TARGET_ACE_TEST} - ${SYS_EFL_LIBRARIES} - ${TARGET_DPL_EFL} - ${TARGET_DPL_TEST_ENGINE_EFL} - ${TARGET_ACE_LIB} - ${ACE_TEST_DEP_LIBRARIES} - ) - -INSTALL(TARGETS ${TARGET_ACE_TEST} - DESTINATION bin - PERMISSIONS OWNER_READ - OWNER_WRITE - OWNER_EXECUTE - GROUP_READ - GROUP_EXECUTE - WORLD_READ - WORLD_EXECUTE - ) - -ADD_SUBDIRECTORY(test-configuration) diff --git a/tests/ace/Interfaces.cpp b/tests/ace/Interfaces.cpp deleted file mode 100644 index 78ed1d0..0000000 --- a/tests/ace/Interfaces.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file Interfaces.cpp - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief Stubs used by PolicyInformationPoint.h - */ -#include "Interfaces.h" - -#include - -#include "AttributeSetter.h" - -int WebRuntimeImp::getAttributesValues( - const Request &request, - std::list *attribute) -{ - LogError("Running stub"); - AttributeSetterSingleton::Instance().get(request, attribute); - return 0; -} - -int ResourceInformationImp::getAttributesValues( - const Request &request, - std::list *attribute) -{ - LogError("Running stub"); - AttributeSetterSingleton::Instance().get(request, attribute); - return 0; -} - -int OperationSystemImp::getAttributesValues( - const Request &request, - std::list *attribute) -{ - LogError("Running stub"); - AttributeSetterSingleton::Instance().get(request, attribute); - return 0; -} - -int FunctionParamImpl::getAttributesValues(const Request & /* request*/, - std::list *attributes) -{ - LogError("Running stub"); - FOREACH(iter, *attributes) - { - std::string attributeName = *(iter->first); - - ParamMap::const_iterator i; - std::pair jj = - paramMap.equal_range(attributeName); - - for (i = jj.first; i != jj.second; ++i) { - iter->second->push_back(i->second); - LogDebug("Attribute: " << attributeName << " Value: " << - i->second); - } - } - return 0; -} - diff --git a/tests/ace/Interfaces.h b/tests/ace/Interfaces.h deleted file mode 100644 index 6d769e5..0000000 --- a/tests/ace/Interfaces.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file Interfaces.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief Stubs used by PolicyInformationPoint.h - */ -#ifndef _TEST_ACE_TESTS_INTERFACE_H_ -#define _TEST_ACE_TESTS_INTERFACE_H_ - -#include -#include -#include -#include - -class Request; - -class WebRuntimeImp : public IWebRuntime { -public: - int getAttributesValues( - const Request &request, - std::list *attribute); - std::string getSessionId(const Request &) { return std::string(); } -}; - -class ResourceInformationImp : public IResourceInformation { -public: - int getAttributesValues( - const Request &request, - std::list *attribute); -}; - -class OperationSystemImp : public IOperationSystem { -public: - int getAttributesValues( - const Request &request, - std::list *attribute); -}; - -class FunctionParamImpl : public IFunctionParam -{ -public: - virtual int getAttributesValues(const Request & /* request*/, - std::list *attributes); - void addAttribute(const std::string &key, - const std::string &value) - { - paramMap.insert(make_pair(key, value)); - } - virtual ~FunctionParamImpl() {} -private: - typedef std::multimap ParamMap; - ParamMap paramMap; -}; - -#endif // _TEST_ACE_TESTS_INTERFACE_H_ diff --git a/tests/ace/PEPSingleton.cpp b/tests/ace/PEPSingleton.cpp deleted file mode 100644 index 9551700..0000000 --- a/tests/ace/PEPSingleton.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file Interfaces.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief Instance of PEP used in tests. - */ -#include "PEPSingleton.h" - -#include -IMPLEMENT_SINGLETON(PolicyEnforcementPoint) - diff --git a/tests/ace/PEPSingleton.h b/tests/ace/PEPSingleton.h deleted file mode 100644 index 1dfb912..0000000 --- a/tests/ace/PEPSingleton.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file Interfaces.h - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief Instantion of PEP used in tests. - */ -#ifndef _TEST_ACE_TEST_PEPSINGLETON_H_ -#define _TEST_ACE_TEST_PEPSINGLETON_H_ - -#include -#include - -typedef DPL::Singleton PEPSingleton; - -#endif // _TEST_ACE_TEST_PEPSINGLETON_H_ - diff --git a/tests/ace/TestSuite01.cpp b/tests/ace/TestSuite01.cpp deleted file mode 100644 index 1d169ae..0000000 --- a/tests/ace/TestSuite01.cpp +++ /dev/null @@ -1,986 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file TestSuite01.cpp - * @author unknown - * @version 1.0 - * @brief Test cases for PolicyEvaluator class. - */ -#include - -#include -#include - -#include -#include -#include -#include - -#include "AttributeSetter.h" -#include "Interfaces.h" -#include "PEPSingleton.h" - -#define GENERAL_TEST_POLICY "/usr/etc/ace/general-test.xml" -#define GENERAL_TEST_POLICY_UNDETERMIND "/usr/etc/ace/undefined-test.xml" -#define GENERAL_TEST_POLICY_GSETTINGS "/usr/etc/ace/policy-test-gsettings.xml" -#define GENERAL_TEST_POLICY_TEST "/usr/etc/ace/policy-test.xml" - -#define CLEANENV(d) \ - do{ \ - if (PEPSingleton::Instance().getPdp()->getCurrentPolicy() != (d)) { \ - PEPSingleton::Instance().getPdp()->updatePolicy(d); \ - } \ - AttributeSetterSingleton::Instance().clear(); \ - AceDB::AceDAO::clearWidgetDevCapSettings(); \ - AceDB::AceDAO::clearDevCapSettings(); \ - }while(0) - -#define QU(nr, subid, resid) \ - do{ \ - AttributeSetterSingleton::Instance().addValue((nr), "id", (subid)); \ - AttributeSetterSingleton::Instance().addValue((nr), "resource-id", (resid));\ - }while(0) - -#define QA(nr, attrname, attrvalue) \ - AttributeSetterSingleton::Instance().addValue((nr), (attrname), (attrvalue)) - -#define QC(nr, expect) \ - do{ \ - Request request((nr), WidgetExecutionPhase_Unknown); \ - std::string a = \ - AttributeSetterSingleton::Instance().getValue((nr),"resource-id"); \ - request.addDeviceCapability(a); \ - PolicyResult result = PEPSingleton::Instance().check(request); \ - RUNNER_ASSERT(result == (expect)); \ - }while(0) - -#define QCP(nr, param, expect) \ - do{ \ - Request request((nr), WidgetExecutionPhase_Unknown, (param)); \ - std::string a = \ - AttributeSetterSingleton::Instance().getValue((nr),"resource-id"); \ - request.addDeviceCapability(a); \ - PolicyResult result = PEPSingleton::Instance().check(request); \ - RUNNER_ASSERT(result == (expect)); \ - }while(0) - -#define TESTSUITE01(n) \ -RUNNER_TEST(ts01_general_tests_ ## n) - -TESTSUITE01(01){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "subject", "resource"); - QA(1, "version", "3"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(02){ - CLEANENV(GENERAL_TEST_POLICY); - QU(2, "subject2", "resource"); - QA(2, "version", "1"); - QC(2, PolicyEffect::DENY); -} - -TESTSUITE01(03){ - CLEANENV(GENERAL_TEST_POLICY); - QU(3, "subject3", "resource2"); - QC(3, PolicyEffect::DENY); -} - -TESTSUITE01(04){ - CLEANENV(GENERAL_TEST_POLICY); - QU(4, "subject4", "resource4"); - QA(4, "version", "4"); - QC(4, PolicyEffect::PERMIT); -} - -TESTSUITE01(05){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(5, "subject5", "resource5"); - QA(5, "version", "5"); - QC(5, PolicyEffect::PERMIT); - - QU(6, "subject5", "resource5"); - QA(6, "version", "1"); - QC(6, PolicyDecision::NOT_APPLICABLE); - - QU(7, "subject6", "resource6"); - QA(7, "version", "1"); - QC(7, PolicyEffect::PERMIT); -} - -TESTSUITE01(06){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(6, "subject7", "resource7"); - QA(6, "version", "7"); - QA(6, "author", "author"); - QC(6, PolicyDecision::NOT_APPLICABLE); - - QU(7, "subject7", "resource7"); - QA(7, "version", "7"); - QA(7, "author", "author2"); - QC(7, PolicyEffect::PERMIT); -} - -TESTSUITE01(07){ - CLEANENV(GENERAL_TEST_POLICY); - QU(3, "subject7", "resource7"); - QA(3, "version", "1"); - QA(3, "author", "author3"); - QC(3, PolicyEffect::DENY); -} - -TESTSUITE01(08){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(8, "s8a", "r8"); - QA(8, "r8v1", "1"); - QA(8, "r8v2", "2"); - QC(8, PolicyEffect::PERMIT); - - QU(9, "s8b", "r8"); - QA(9, "r8v1", "1"); - QA(9, "r8v2", "2"); - QC(9, PolicyEffect::DENY); - - QU(19, "s8c", "r8"); - QA(19, "r8v1", "1"); - QA(19, "r8v2", "2"); - QC(19, PolicyDecision::NOT_APPLICABLE); -} - -TESTSUITE01(09){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s9a", "r9"); - QA(1, "r9a", "http://onet.pl:90/test.html"); - QA(1, "r9b", "http://onet.pl:80/test.html"); - QA(1, "r9c", "http://onet.pl:80"); - QA(1, "r9d", "http://onet.pl:80"); - QA(1, "r9e", "http://onet.pl:80/test.html"); - QA(1, "r9g", "http://onet.pl:80/test.html"); - QC(1, PolicyEffect::PERMIT); - - QU(2, "s9b", "r9"); - QA(2, "r9a", "http://onet.pl:90/test.html"); - QA(2, "r9b", "http://onet.pl:80/test.html"); - QA(2, "r9c", "http://onet.pl:80"); - QA(2, "r9d", "http://onet.pl:80"); - QA(2, "r9e", "http://onet.pl:80/test.html"); - QA(2, "r9g", "http://onet.pl:80/test.html"); - QC(2, PolicyEffect::DENY); - - QU(3, "s9c", "r9"); - QA(3, "r9a", "http://onet.pl:90/test.html"); - QA(3, "r9b", "http://onet.pl:80/test.html"); - QA(3, "r9c", "http://onet.pl:80"); - QA(3, "r9d", "http://onet.pl:80"); - QA(3, "r9e", "http://onet.pl:80/test.html"); - QA(3, "r9g", "http://onet.pl:80/test.html"); - QC(3, PolicyEffect::PERMIT); - - QU(4, "s9d", "r9"); - QA(4, "r9a", "http://onet.pl:90/test.html"); - QA(4, "r9b", "http://onet.pl:80/test.html"); - QA(4, "r9c", "http://onet.pl:80"); - QA(4, "r9d", "http://onet.pl:80"); - QA(4, "r9e", "http://onet.pl:80/test.html"); - QA(4, "r9g", "http://onet.pl:80/test.html"); - QC(4, PolicyEffect::DENY); - - QU(5, "s9e", "r9"); - QA(5, "r9a", "http://onet.pl:90/test.html"); - QA(5, "r9b", "http://onet.pl:80/test.html"); - QA(5, "r9c", "http://onet.pl:80"); - QA(5, "r9d", "http://onet.pl:80"); - QA(5, "r9e", "http://onet.pl:80/test.html"); - QA(5, "r9g", "http://onet.pl:80/test.html"); - QC(5, PolicyEffect::DENY); - - QU(6, "s9f", "r9"); - QA(6, "r9a", "http://onet.pl:90/test.html"); - QA(6, "r9b", "http://onet.pl:80/test.html"); - QA(6, "r9c", "http://onet.pl:80"); - QA(6, "r9d", "http://onet.pl:80"); - QA(6, "r9e", "http://onet.pl:80/test.html"); - QA(6, "r9g", "http://onet.pl:80/test.html"); - QC(6, PolicyEffect::PERMIT); - - QU(7, "s9g", "r9"); - QA(7, "r9a", "http://onet.pl:90/test.html"); - QA(7, "r9b", "http://onet.pl:80/test.html"); - QA(7, "r9c", "http://onet.pl:80"); - QA(7, "r9d", "http://onet.pl:80"); - QA(7, "r9e", "http://onet.pl:80/test.html"); - QA(7, "r9g", "http://onet.pl:80/test.html"); - QC(7, PolicyEffect::DENY); - - QU(8, "s9h", "r9"); - QA(8, "r9a", "http://onet.pl:90/test.html"); - QA(8, "r9b", "http://onet.pl:80/test.html"); - QA(8, "r9c", "http://onet.pl:80"); - QA(8, "r9d", "http://onet.pl:80"); - QA(8, "r9e", "http://onet.pl:80/test.html"); - QA(8, "r9g", "http://onet.pl:80/test.html"); - QC(8, PolicyEffect::PERMIT); -} - -TESTSUITE01(10){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s10a", "r10"); - QA(1, "r10a", "15ba"); - QA(1, "r10c", "15a1"); - QC(1, PolicyEffect::PERMIT); - - QU(2, "s10b", "r10"); - QA(2, "r10a", "15ba"); - QA(2, "r10c", "15a1"); - QC(2, PolicyEffect::DENY); - - QU(3, "s10c", "r10"); - QA(3, "r10a", "15ba"); - QA(3, "r10c", "15a1"); - QC(3, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(11){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s15", "device:pim.contacts"); - QA(1, "uri", "//buu.com.pl"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(12){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s16", "device:pim.contacts"); - QA(1, "uri", "//v.com.pl"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(13){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s17a", "resource4"); - QA(1, "version", "4"); - QC(1, PolicyEffect::PERMIT); - - QU(2, "s17b", "resource4"); - QA(2, "version", "4"); - QC(2, PolicyEffect::DENY); -} - -TESTSUITE01(14){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s18a", "device:pim.contacts"); - QA(1, "uri", "buu.com.pl"); - QC(1, PolicyEffect::PERMIT); - - QU(2, "s18b", "device:pim.contacts"); - QA(2, "uri", "buu.com.pl"); - QC(2, PolicyEffect::PERMIT); - - QU(3, "s18c", "device:pim.contacts"); - QA(3, "uri", "buu.com.pl"); - QC(3, PolicyEffect::PERMIT); -} - -TESTSUITE01(15){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s19.1", "resource4"); - QA(1, "key-root-trust", "voperator"); - QC(1, PolicyEffect::DENY); - - QU(2, "s19.2", "resource4"); - QA(2, "key-root-trust", "voperator"); - QC(2, PolicyEffect::PERMIT); -} - -TESTSUITE01(16){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s20.1", "resource4"); - QA(1, "signer-id", "v7zha89%49x£$"); - QC(1, PolicyEffect::DENY); - - QU(2, "s20.2", "resource4"); - QA(2, "signer-id", "v7zha89%49x£$"); - QC(2, PolicyEffect::PERMIT); -} - -TESTSUITE01(17){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s21", "undetermined"); - QC(1, PolicyDecision::NOT_APPLICABLE); - - - QU(2, "s21a", "undetermined"); - QC(2, PolicyEffect::PERMIT); -} - -TESTSUITE01(18){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s23", "device:pim.contacts"); - QA(1, "version", "undetermined"); - QC(1, PolicyDecision::NOT_APPLICABLE); -} - -TESTSUITE01(19){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s24", "device:pim"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(20){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s25.1", "device:pim.contacts"); - QA(1, "version", "5"); - QA(1, "roaming", "off"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(21){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s25.2", "device:pim.contacts"); - QA(1, "version", "undetermined"); - QC(1, PolicyDecision::NOT_APPLICABLE); -} - -TESTSUITE01(22){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - QU(1, "s25.3", "device:pim.contacts"); -// undetermined QA(1, "version", ""); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(23){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - QU(1, "s25.4", "device:pim.contacts"); - //undetermined - //QA(1, "version", "", true); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(24){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - QU(1, "s26.1", "device:pim.contacts"); - QA(1, "version", "5"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(25){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - QU(1, "s26.2", "device:pim.contacts"); - //undetermined - //QA(1, "version", "", true); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(26){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - QU(1, "s26.3", "device:pim.contacts"); - //undetermined - //QA(1, "version", "", true); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(27){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - QU(1, "s26.4", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(28){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - QU(1, "s27.1", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(29){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - QU(1, "s27.2", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(30){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - QU(1, "s27.3", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyDecision::NOT_APPLICABLE); -} - -TESTSUITE01(31){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - QU(1, "s27.4", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(32){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - QU(1, "s28", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(33){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - QU(1, "s29", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(34){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - QU(1, "s30.1", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(35){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - QU(1, "s30.2", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(36){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - QU(1, "s30.3", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(37){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - QU(1, "s30.4", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(38){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - QU(1, "s31.1", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(39){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s31.2.1", "device:pim.contacts"); - QC(1, PolicyEffect::DENY); -} - -TESTSUITE01(40){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s31.2.2", "device:pim.contacts"); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(41){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s31.3", "device:pim.contacts"); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(42){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s32.1", "device:pim.contacts"); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(43){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s32.2.1", "device:pim.contacts"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(44){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s32.2.2", "device:pim.contacts"); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(45){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s32.3", "device:pim.contacts"); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(46){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s33.1", "device:pim.contacts"); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(47){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s33.2", "device:pim.contacts"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(48){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s33.3", "device:pim.contacts"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(49){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //Test undetermined, we have to refine this tests to test something - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s34.1", "device:pim.contacts"); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(50){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s34.2", "device:pim.contacts"); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(51){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s35.1", "device:pim.contacts"); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(52){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - //undetermined - //QA(1, "version", "undetermined", true); - QU(1, "s35.2", "device:pim.contacts"); - QC(1, PolicyResult::UNDETERMINED); -} - -TESTSUITE01(53){ - CLEANENV(GENERAL_TEST_POLICY_UNDETERMIND); - QU(1, "s36", "device:pim.contacts"); - //undetermined - //QA(1, "version", "undetermined", true); - QC(1, PolicyDecision::NOT_APPLICABLE); -} - -TESTSUITE01(54){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s37", "device:pim.contacts.read"); - QC(1, PolicyEffect::PROMPT_ONESHOT); -} - -TESTSUITE01(55){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s38", "device:pim.contacts.read"); - QC(1, PolicyEffect::PROMPT_SESSION); - - QU(2, "s38.4", "device:pim.contacts.read"); - QC(2, PolicyEffect::PROMPT_SESSION); -} - -TESTSUITE01(56){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s39", "device:pim.contacts.read"); - QC(1, PolicyEffect::PROMPT_BLANKET); - - QU(2, "s39.4", "device:pim.contacts.read"); - QC(2, PolicyEffect::PROMPT_BLANKET); -} - -TESTSUITE01(57){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s40", "r40"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(58){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s41", "r41"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(59){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s42.1", "r42.1"); - QC(1, PolicyEffect::DENY); -} - -TESTSUITE01(60){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s42.2", "r42.2"); - QC(1, PolicyEffect::DENY); - -} - -TESTSUITE01(61){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s43.1", "r43.1"); - QC(1, PolicyEffect::DENY); -} - -TESTSUITE01(62){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s43.2", "r43.2"); - QC(1, PolicyEffect::DENY); -} - -TESTSUITE01(63){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s44.1", "r44.1"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(64){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s44.2", "r44.2"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(65){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s45.1", "r45.1"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(66){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s45.2", "r45.2"); - QC(1, PolicyEffect::DENY); -} - -TESTSUITE01(67){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s46.1", "r46.1"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(68){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s46.2", "r46.2"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(69){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s47.1", "r47.1"); - QC(1, PolicyEffect::DENY); -} - -TESTSUITE01(70){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s47.2", "r47.2"); - QC(1, PolicyEffect::DENY); -} - -TESTSUITE01(71){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "s48", "device:pim.contacts"); - QA(1, "uri", "http://www.test.pl:80"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(72){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "BF00", "BFR00"); - QC(1, PolicyEffect::DENY); -} - -TESTSUITE01(73){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "BF01", "BFR01"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(74){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "BF02", "BFR02"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(75){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "BF03", "BFR03"); - QC(1, PolicyEffect::DENY); -} - -TESTSUITE01(76){ - CLEANENV(GENERAL_TEST_POLICY); - QU(1, "BF04", "BFR04"); - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(77){ - CLEANENV(GENERAL_TEST_POLICY); - FunctionParamImpl functionParam; - functionParam.addAttribute("param:recipients","+44091234"); - QU(1, "paramTestSubject", "resource"); - QA(1, "dev-cap","messaging"); - QCP(1, &functionParam, PolicyEffect::DENY); -} - -TESTSUITE01(78){ - CLEANENV(GENERAL_TEST_POLICY); - FunctionParamImpl functionParam; - functionParam.addAttribute("param:recipients","+44081234"); - QU(1, "paramTestSubject", "resource"); - QA(1, "dev-cap","messaging"); - QCP(1, &functionParam, PolicyEffect::PERMIT); -} - -TESTSUITE01(79){ - CLEANENV(GENERAL_TEST_POLICY); - FunctionParamImpl functionParam; - functionParam.addAttribute("param:recipients","+4812345656"); - QU(1, "paramTestSubject", "resource"); - QA(1, "dev-cap","messaging"); - QCP(1, &functionParam, PolicyEffect::PERMIT); -} - -TESTSUITE01(80){ - CLEANENV(GENERAL_TEST_POLICY); - FunctionParamImpl functionParam; - functionParam.addAttribute("param:quality","low"); - QU(1, "paramTestSubject", "resource"); - QA(1, "dev-cap","messaging"); - QCP(1, &functionParam, PolicyDecision::NOT_APPLICABLE); -} - -TESTSUITE01(81){ - CLEANENV(GENERAL_TEST_POLICY); - FunctionParamImpl functionParam; - functionParam.addAttribute("param:quality", "high"); - QU(1, "paramTestSubject", "resource"); - QA(1, "dev-cap","camera"); - QCP(1, &functionParam, PolicyEffect::PERMIT); -} - -TESTSUITE01(82){ - CLEANENV(GENERAL_TEST_POLICY); - - QU(1, "s61a", "r61a"); - QC(1, PolicyEffect::DENY); - - FunctionParamImpl functionParam; - functionParam.addAttribute("param:name", "type"); - QU(2, "s61b", "r61b"); - QCP(2, &functionParam, PolicyEffect::PERMIT); - - QU(3, "s61c", "r61c"); - QC(3, PolicyEffect::DENY); - - FunctionParamImpl functionParam4; - functionParam4.addAttribute("param:name", "type"); - functionParam4.addAttribute("param:name", "port"); - QU(4, "s61d", "r61d"); - QCP(4, &functionParam4, PolicyEffect::PERMIT); -} - -TESTSUITE01(83){ - CLEANENV(GENERAL_TEST_POLICY_TEST); - - PermissionList sList; - sList.push_back(PermissionTriple(1, "b1", Preference::PREFERENCE_PERMIT)); - sList.push_back(PermissionTriple(2, "bb2", Preference::PREFERENCE_DENY)); - sList.push_back(PermissionTriple(3, "d3", Preference::PREFERENCE_DEFAULT)); - SettingsLogic::setWidgetDevCapSettings(sList); - - QU(1, "a1", "b1"); - QC(1, PolicyEffect::DENY); - - QU(2, "aa2", "bb2"); - QC(2, PolicyEffect::DENY); - - QU(3, "c3", "d3"); - QC(3, PolicyEffect::PERMIT); -} - -TESTSUITE01(84){ - CLEANENV(GENERAL_TEST_POLICY_TEST); - PermissionList sList; - sList.push_back(PermissionTriple(3, "d3", Preference::PREFERENCE_ONE_SHOT_PROMPT)); - SettingsLogic::setWidgetDevCapSettings(sList); - QU(3, "c3", "d3"); - QC(3, PolicyEffect::PROMPT_ONESHOT); -} - -TESTSUITE01(85){ - CLEANENV(GENERAL_TEST_POLICY_TEST); - - PermissionList sList; - sList.push_back(PermissionTriple(1, "bnp", Preference::PREFERENCE_DEFAULT)); - sList.push_back(PermissionTriple(2, "bbnp", Preference::PREFERENCE_DENY)); - sList.push_back(PermissionTriple(3, "dnp", Preference::PREFERENCE_PERMIT)); - - SettingsLogic::setWidgetDevCapSettings(sList); - - QU(1, "anp", "bnp"); - QC(1, PolicyDecision::NOT_APPLICABLE); - - QU(2, "aanp", "bbnp"); - QC(2, PolicyEffect::DENY); - - QU(3, "cnp", "dnp"); - QC(3, PolicyEffect::PERMIT); -} - -TESTSUITE01(86){ - CLEANENV(GENERAL_TEST_POLICY_TEST); - - PermissionList sList; - sList.push_back(PermissionTriple(1, "b1", Preference::PREFERENCE_DEFAULT)); - sList.push_back(PermissionTriple(2, "bb", Preference::PREFERENCE_DENY)); - sList.push_back(PermissionTriple(3, "d3", Preference::PREFERENCE_PERMIT)); - sList.push_back(PermissionTriple(4, "b1", Preference::PREFERENCE_PERMIT)); - sList.push_back(PermissionTriple(5, "bb2", Preference::PREFERENCE_DENY)); - sList.push_back(PermissionTriple(6, "d3", Preference::PREFERENCE_DEFAULT)); - - SettingsLogic::setWidgetDevCapSettings(sList); - - QU(1, "a1", "b1"); - QC(1, PolicyEffect::DENY); - - QU(2, "aa", "bb"); - QC(2, PolicyEffect::DENY); - - QU(3, "c3", "d3"); - QC(3, PolicyEffect::PERMIT); - - QU(5, "aa2", "bb2"); - QC(5, PolicyEffect::DENY); -} - -TESTSUITE01(87){ - CLEANENV(GENERAL_TEST_POLICY_TEST); - - QU(1, "c3", "d3"); - QC(1, PolicyEffect::PERMIT); - - QU(2, "aa2", "bb2"); - QC(2, PolicyEffect::PERMIT); - - SettingsLogic::updateDevCapSetting("d3", Preference::PREFERENCE_DENY); - SettingsLogic::updateDevCapSetting("bb2", Preference::PREFERENCE_DEFAULT); - - QC(1, PolicyEffect::DENY); - - QC(2, PolicyEffect::PERMIT); - - SettingsLogic::updateDevCapSetting("d3", Preference::PREFERENCE_PERMIT); - - QC(1, PolicyEffect::PERMIT); -} - -TESTSUITE01(88){ - CLEANENV(GENERAL_TEST_POLICY_GSETTINGS); - std::string d3("d3"); - - QU(1, "c3", "d3"); - QC(1, PolicyEffect::PERMIT); - - QU(2, "aa2", "bb2"); - QC(2, PolicyEffect::PERMIT); - - QU(3, "a1", "d3"); - QC(3, PolicyEffect::DENY); - - SettingsLogic::updateDevCapSetting(d3, Preference::PREFERENCE_DEFAULT); - - QC(1, PolicyEffect::PERMIT); - - QC(2, PolicyEffect::PERMIT); - - QC(3, PolicyEffect::DENY); - - SettingsLogic::updateDevCapSetting(d3, Preference::PREFERENCE_DENY); - - QC(1, PolicyEffect::DENY); - - QC(3, PolicyEffect::DENY); - - SettingsLogic::updateDevCapSetting(d3, Preference::PREFERENCE_PERMIT); - - QC(1, PolicyEffect::PERMIT); - - QC(3, PolicyEffect::DENY); -} - diff --git a/tests/ace/TestSuite02.cpp b/tests/ace/TestSuite02.cpp deleted file mode 100644 index 66d79f5..0000000 --- a/tests/ace/TestSuite02.cpp +++ /dev/null @@ -1,913 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file TestSuite02.cpp - * @author unknown - * @version 1.0 - * @brief Test cases for Attribute class. - */ -#include - -#include -#include - -#include -#include - -#include - -#include "PEPSingleton.h" - -#define POLICY_ATTR_EXAMPLE "/usr/etc/ace/attr_policy-example.xml" -#define POLICY_ATTR_EXAMPLE1 "/usr/etc/ace/attr_policy-example1.xml" -#define POLICY_ATTR_EXAMPLE2 "/usr/etc/ace/attr_policy-example2.xml" -#define POLICY_ATTR_EXAMPLE3 "/usr/etc/ace/attr_policy-example3.xml" -#define POLICY_ATTR_EXAMPLE4 "/usr/etc/ace/attr_policy-example4.xml" -#define POLICY_ATTR_EXAMPLE5 "/usr/etc/ace/attr_policy-example5.xml" -#define POLICY_ATTR_EXAMPLE6 "/usr/etc/ace/attr_policy-example6.xml" -#define POLICY_ATTR_EXAMPLE7 "/usr/etc/ace/attr_policy-example7.xml" -#define POLICY_ATTR_EXAMPLE8 "/usr/etc/ace/attr_policy-example8.xml" - -#define CLEANENV(d) \ - do{ \ - if (PEPSingleton::Instance().getPdp()->getCurrentPolicy() != (d)) { \ - PEPSingleton::Instance().getPdp()->updatePolicy(d); \ - } \ - }while(0) - -#define PEPTR PEPSingleton::Instance().getPdp() - -#define TESTSUITE02(n) \ -RUNNER_TEST(ts02_extract_attributes_tests_ ## n) - -using namespace AceDB; - -bool AttrEqual(const AttributeSet &actual, AttributeSet * expected) -{ - bool match = false; - for (AttributeSet::const_iterator ita = actual.begin(); - ita != actual.end(); - ++ita) - { - match = false; - for (AttributeSet::const_iterator ite = expected->begin(); - ite != expected->end(); - ++ite) - { - if ((*(*ita)->getName() == *(*ite)->getName()) && - ((*ita)->getType() == (*ite)->getType())) - { - match = true; - } - } - if (!match) - { - LogError("Not found " << - *(*ita)->getName() << - " " << static_cast((*ita)->getType())); - return false; - } - } - return true; -} - -TESTSUITE02(01){ - CLEANENV(POLICY_ATTR_EXAMPLE); - - AttributeSet attrSet; - std::string n1("name"); - BaseAttributePtr a1(new Attribute(&n1, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a1); - - - std::string n2("resource-id"); - BaseAttributePtr a2(new Attribute(&n2, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a2); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - -TESTSUITE02(02){ - CLEANENV(POLICY_ATTR_EXAMPLE1); - - AttributeSet attrSet; - - std::string n3("uri.host"); - BaseAttributePtr a3(new Attribute(&n3, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a3); - - std::string n4("key-root-trust"); - BaseAttributePtr a4(new Attribute(&n4, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a4); - - std::string n5("id"); - BaseAttributePtr a5(new Attribute(&n5, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a5); - - std::string n6("signer-id"); - BaseAttributePtr a6(new Attribute(&n6, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a6); - - std::string n7("version"); - BaseAttributePtr a7(new Attribute(&n7, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a7); - - std::string n8("r8v2"); - BaseAttributePtr a8(new Attribute(&n8, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a8); - - std::string n9("author"); - BaseAttributePtr a9(new Attribute(&n9, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a9); - - std::string n10("r9a.scheme"); - BaseAttributePtr a10(new Attribute(&n10, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a10); - - std::string n11("r9b.authority"); - BaseAttributePtr a11(new Attribute(&n11, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a11); - - std::string n12("r9c.scheme-authority"); - BaseAttributePtr a12(new Attribute(&n12, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a12); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - -TESTSUITE02(03){ - CLEANENV(POLICY_ATTR_EXAMPLE2); - - AttributeSet attrSet; - - std::string n1("id"); - BaseAttributePtr a1(new Attribute(&n1, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a1); - - std::string n3("version"); - BaseAttributePtr a3(new Attribute(&n3, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a3); - - std::string n2("resource-id"); - BaseAttributePtr a2(new Attribute(&n2, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a2); - - std::string n4("author"); - BaseAttributePtr a4(new Attribute(&n4, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a4); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - -TESTSUITE02(04){ - CLEANENV(POLICY_ATTR_EXAMPLE3); - - AttributeSet attrSet; - - std::string n1("id"); - BaseAttributePtr a1(new Attribute(&n1, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a1); - - std::string n3("version"); - BaseAttributePtr a3(new Attribute(&n3, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a3); - - std::string n2("resource-id"); - BaseAttributePtr a2(new Attribute(&n2, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a2); - - std::string n4("author"); - BaseAttributePtr a4(new Attribute(&n4, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a4); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - -TESTSUITE02(05){ - CLEANENV(POLICY_ATTR_EXAMPLE4); - - AttributeSet attrSet; - - std::string n1("id"); - BaseAttributePtr a1(new Attribute(&n1, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a1); - - std::string n3("version"); - BaseAttributePtr a3(new Attribute(&n3, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a3); - - - std::string n2("resource-id"); - BaseAttributePtr a2(new Attribute(&n2, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a2); - - std::string n4("author"); - BaseAttributePtr a4(new Attribute(&n4, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a4); - - std::string n5("author"); - BaseAttributePtr a5(new Attribute(&n5, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a5); - - std::string n6("version"); - BaseAttributePtr a6(new Attribute(&n6, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a6); - - std::string n7("ver"); - BaseAttributePtr a7(new Attribute(&n7, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a7); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - -TESTSUITE02(06){ - CLEANENV(POLICY_ATTR_EXAMPLE5); - - AttributeSet attrSet; - - std::string n3("uri.host"); - BaseAttributePtr a3(new Attribute(&n3, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a3); - - std::string n4("key-root-trust"); - BaseAttributePtr a4(new Attribute(&n4, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a4); - - std::string n5("id"); - BaseAttributePtr a5(new Attribute(&n5, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a5); - - std::string n6("signer-id"); - BaseAttributePtr a6(new Attribute(&n6, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a6); - - std::string n7("version"); - BaseAttributePtr a7(new Attribute(&n7, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a7); - - std::string n13("name"); - BaseAttributePtr a13(new Attribute(&n13, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a13); - - std::string n14("resource-id"); - BaseAttributePtr a14(new Attribute(&n14, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a14); - - std::string n15("r8v2"); - BaseAttributePtr a15(new Attribute(&n15, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a15); - - std::string n16("author"); - BaseAttributePtr a16(new Attribute(&n16, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a16); - - std::string n17("r9a.scheme"); - BaseAttributePtr a17(new Attribute(&n17, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a17); - - std::string n18("r9b.authority"); - BaseAttributePtr a18(new Attribute(&n18, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a18); - - std::string n19("r9c.scheme-authority"); - BaseAttributePtr a19(new Attribute(&n19, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a19); - - std::string n20("resource-id"); - BaseAttributePtr a20(new Attribute(&n20, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a20); - - std::string n8("r8v2"); - BaseAttributePtr a8(new Attribute(&n8, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a8); - - std::string n9("author"); - BaseAttributePtr a9(new Attribute(&n9, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a9); - - std::string n10("r9a.scheme"); - BaseAttributePtr a10(new Attribute(&n10, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a10); - - std::string n11("r9b.authority"); - BaseAttributePtr a11(new Attribute(&n11, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a11); - - std::string n12("r9c.scheme-authority"); - BaseAttributePtr a12(new Attribute(&n12, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a12); - - std::string n21("resource-id"); - BaseAttributePtr a21(new Attribute(&n21, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a21); - - std::string n22("r8v2"); - BaseAttributePtr a22(new Attribute(&n22, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a22); - - std::string n23("author"); - BaseAttributePtr a23(new Attribute(&n23, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a23); - - std::string n24("r9a.scheme"); - BaseAttributePtr a24(new Attribute(&n24, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a24); - - std::string n25("r9b.authority"); - BaseAttributePtr a25(new Attribute(&n25, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a25); - - std::string n26("r9c.scheme-authority"); - BaseAttributePtr a26(new Attribute(&n26, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a26); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - -TESTSUITE02(07){ - CLEANENV(POLICY_ATTR_EXAMPLE6); - - AttributeSet attrSet; - - std::string n3("s-uri.host"); - BaseAttributePtr a3(new Attribute(&n3, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a3); - - std::string n4("s-key-root-trust"); - BaseAttributePtr a4(new Attribute(&n4, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a4); - - std::string n5("s-id"); - BaseAttributePtr a5(new Attribute(&n5, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a5); - - std::string n6("s-signer-id"); - BaseAttributePtr a6(new Attribute(&n6, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a6); - - std::string n7("s-version"); - BaseAttributePtr a7(new Attribute(&n7, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a7); - - std::string n13("s-name"); - BaseAttributePtr a13(new Attribute(&n13, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a13); - - std::string n14("s-resource-id"); - BaseAttributePtr a14(new Attribute(&n14, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a14); - - std::string n15("s-r8v2"); - BaseAttributePtr a15(new Attribute(&n15, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a15); - - std::string n16("s-author"); - BaseAttributePtr a16(new Attribute(&n16, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a16); - - std::string n17("s-r9a.scheme"); - BaseAttributePtr a17(new Attribute(&n17, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a17); - - std::string n18("s-r9b.authority"); - BaseAttributePtr a18(new Attribute(&n18, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a18); - - std::string n19("s-r9c.scheme-authority"); - BaseAttributePtr a19(new Attribute(&n19, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a19); - - std::string n20("r-resource-id"); - BaseAttributePtr a20(new Attribute(&n20, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a20); - - std::string n8("r-r8v2"); - BaseAttributePtr a8(new Attribute(&n8, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a8); - - std::string n9("r-author"); - BaseAttributePtr a9(new Attribute(&n9, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a9); - - std::string n10("r-r9a.scheme"); - BaseAttributePtr a10(new Attribute(&n10, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a10); - - std::string n11("r-r9b.authority"); - BaseAttributePtr a11(new Attribute(&n11, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a11); - - std::string n12("r-r9c.scheme-authority"); - BaseAttributePtr a12(new Attribute(&n12, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a12); - - std::string n21("e-resource-id"); - BaseAttributePtr a21(new Attribute(&n21, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a21); - - std::string n22("e-r8v2"); - BaseAttributePtr a22(new Attribute(&n22, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a22); - - std::string n23("e-author"); - BaseAttributePtr a23(new Attribute(&n23, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a23); - - std::string n24("e-r9a.scheme"); - BaseAttributePtr a24(new Attribute(&n24, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a24); - - std::string n25("e-r9b.authority"); - BaseAttributePtr a25(new Attribute(&n25, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a25); - - std::string n26("e-r9c.scheme-authority"); - BaseAttributePtr a26(new Attribute(&n26, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a26); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - -TESTSUITE02(08){ - CLEANENV(POLICY_ATTR_EXAMPLE2); - - AttributeSet attrSet; - - std::string n1("id"); - BaseAttributePtr a1(new Attribute(&n1, - Attribute::Match::Glob, - Attribute::Type::Subject)); - attrSet.insert(a1); - - std::string n3("version"); - BaseAttributePtr a3(new Attribute(&n3, - Attribute::Match::Glob, - Attribute::Type::Subject)); - attrSet.insert(a3); - - - std::string n2("resource-id"); - BaseAttributePtr a2(new Attribute(&n2, - Attribute::Match::Glob, - Attribute::Type::Resource)); - attrSet.insert(a2); - - std::string n4("author"); - BaseAttributePtr a4(new Attribute(&n4, - Attribute::Match::Glob, - Attribute::Type::Resource)); - attrSet.insert(a4); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - -TESTSUITE02(09){ - CLEANENV(POLICY_ATTR_EXAMPLE2); - - AttributeSet attrSet; - - std::string n1("id"); - BaseAttributePtr a1(new Attribute(&n1, - Attribute::Match::Regexp, - Attribute::Type::Subject)); - attrSet.insert(a1); - - std::string n3("version"); - BaseAttributePtr a3(new Attribute(&n3, - Attribute::Match::Regexp, - Attribute::Type::Subject)); - attrSet.insert(a3); - - - std::string n2("resource-id"); - BaseAttributePtr a2(new Attribute(&n2, - Attribute::Match::Regexp, - Attribute::Type::Resource)); - attrSet.insert(a2); - - std::string n4("author"); - BaseAttributePtr a4(new Attribute(&n4, - Attribute::Match::Regexp, - Attribute::Type::Resource)); - attrSet.insert(a4); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - -TESTSUITE02(10){ - CLEANENV(POLICY_ATTR_EXAMPLE2); - - AttributeSet attrSet; - - std::string n1("id"); - BaseAttributePtr a1(new Attribute(&n1, - Attribute::Match::Regexp, - Attribute::Type::Subject)); - attrSet.insert(a1); - - std::string n3("version"); - BaseAttributePtr a3(new Attribute(&n3, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a3); - - - std::string n2("resource-id"); - BaseAttributePtr a2(new Attribute(&n2, - Attribute::Match::Glob, - Attribute::Type::Resource)); - attrSet.insert(a2); - - std::string n4("author"); - BaseAttributePtr a4(new Attribute(&n4, - Attribute::Match::Regexp, - Attribute::Type::Resource)); - attrSet.insert(a4); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - -TESTSUITE02(11){ - CLEANENV(POLICY_ATTR_EXAMPLE7); - - AttributeSet attrSet; - - std::string n3("uri.host"); - BaseAttributePtr a3(new Attribute(&n3, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a3); - - std::string n4("key-root-trust"); - BaseAttributePtr a4(new Attribute(&n4, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a4); - - std::string n5("id"); - BaseAttributePtr a5(new Attribute(&n5, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a5); - - std::string n6("signer-id"); - BaseAttributePtr a6(new Attribute(&n6, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a6); - - std::string n7("version"); - BaseAttributePtr a7(new Attribute(&n7, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a7); - - std::string n13("name"); - BaseAttributePtr a13(new Attribute(&n13, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a13); - - std::string n14("resource-id"); - BaseAttributePtr a14(new Attribute(&n14, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a14); - - std::string n15("r8v2"); - BaseAttributePtr a15(new Attribute(&n15, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a15); - - std::string n16("author"); - BaseAttributePtr a16(new Attribute(&n16, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a16); - - std::string n17("r9a.scheme"); - BaseAttributePtr a17(new Attribute(&n17, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a17); - - std::string n18("r9b.authority"); - BaseAttributePtr a18(new Attribute(&n18, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a18); - - std::string n19("r9c.scheme-authority"); - BaseAttributePtr a19(new Attribute(&n19, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a19); - - std::string n20("resource-id"); - BaseAttributePtr a20(new Attribute(&n20, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a20); - - std::string n8("r8v2"); - BaseAttributePtr a8(new Attribute(&n8, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a8); - - std::string n9("author"); - BaseAttributePtr a9(new Attribute(&n9, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a9); - - std::string n10("r9a.scheme"); - BaseAttributePtr a10(new Attribute(&n10, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a10); - - std::string n11("r9b.authority"); - BaseAttributePtr a11(new Attribute(&n11, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a11); - - std::string n12("r9c.scheme-authority"); - BaseAttributePtr a12(new Attribute(&n12, - Attribute::Match::Equal, - Attribute::Type::Resource)); - attrSet.insert(a12); - - std::string n21("resource-id"); - BaseAttributePtr a21(new Attribute(&n21, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a21); - - std::string n22("r8v2"); - BaseAttributePtr a22(new Attribute(&n22, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a22); - - std::string n23("author"); - BaseAttributePtr a23(new Attribute(&n23, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a23); - - std::string n24("r9a.scheme"); - BaseAttributePtr a24(new Attribute(&n24, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a24); - - std::string n25("r9b.authority"); - BaseAttributePtr a25(new Attribute(&n25, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a25); - - std::string n26("r9c.scheme-authority"); - BaseAttributePtr a26(new Attribute(&n26, - Attribute::Match::Equal, - Attribute::Type::Environment)); - attrSet.insert(a26); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - -TESTSUITE02(12){ - CLEANENV(POLICY_ATTR_EXAMPLE8); - - AttributeSet attrSet; - - std::string n1("id"); - BaseAttributePtr a1(new Attribute(&n1, - Attribute::Match::Regexp, - Attribute::Type::Subject)); - attrSet.insert(a1); - - std::string n3("version"); - BaseAttributePtr a3(new Attribute(&n3, - Attribute::Match::Equal, - Attribute::Type::Subject)); - attrSet.insert(a3); - - - std::string n2("resource-id"); - BaseAttributePtr a2(new Attribute(&n2, - Attribute::Match::Glob, - Attribute::Type::Resource)); - attrSet.insert(a2); - - std::string n4("author"); - BaseAttributePtr a4(new Attribute(&n4, - Attribute::Match::Regexp, - Attribute::Type::Resource)); - attrSet.insert(a4); - - PEPTR->extractAttributesTest(); - - bool result = AttrEqual(attrSet, PEPTR->getAttributeSet()); - RUNNER_ASSERT(result); -} - diff --git a/tests/ace/TestSuite03.cpp b/tests/ace/TestSuite03.cpp deleted file mode 100644 index 53c86ca..0000000 --- a/tests/ace/TestSuite03.cpp +++ /dev/null @@ -1,533 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file TestSuite03.cpp - * @author Piotr Fatyga (p.fatyga@samsung.com) - * @version 0.1 - * @brief Test cases for Condition class. - */ - -#include - -#include -#include - -#include -#include -#include - -#define TESTSUITE03(n) \ -RUNNER_TEST(ts03_condtitions_tests_ ## n) - -using namespace AceDB; - -BaseAttributePtr createAttribute( - const char *name, - const char * value, - const Attribute::Type type = Attribute::Type::Subject) -{ - std::string aName(name); - BaseAttributePtr attr(new Attribute(&aName, Attribute::Match::Equal, type)); - if(value != NULL){ - std::string aValue(value); - DPL::StaticPointerCast(attr)->addValue(&aValue); - } - return attr; -} - -BaseAttributePtr createAttribute( - const char *name, - const char *value, - const char *value2, - const Attribute::Type type = Attribute::Type::Subject) -{ - std::string aName(name); - BaseAttributePtr attr(new Attribute(&aName, Attribute::Match::Equal, type)); - if(value != NULL && value2 != NULL ){ - std::string aValue(value), aValue2(value2); - DPL::StaticPointerCast(attr)->addValue(&aValue); - DPL::StaticPointerCast(attr)->addValue(&aValue2); - } - return attr; -} - - -bool MatchResultEqual( - Attribute::MatchResult actual, - Attribute::MatchResult expected) -{ - return actual == expected; -} - -bool evaluateResult( - Condition con, - AttributeSet & attrs, - Attribute::MatchResult expectedResult) -{ - Attribute::MatchResult matchResult = con.evaluateCondition(&attrs); - return MatchResultEqual(matchResult ,expectedResult); -} - -TESTSUITE03(01){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("r8v2","var2"); - BaseAttributePtr a3 = createAttribute("author","va3"); - - con.addAttribute(*DPL::StaticPointerCast(a1)); - con.addAttribute(*DPL::StaticPointerCast(a2)); - con.addAttribute(*DPL::StaticPointerCast(a3)); - - attrSet.insert(a1); - attrSet.insert(a2); - attrSet.insert(a3); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRTrue)); -} - -TESTSUITE03(02){ - Condition con(Condition::AND); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("r8v2","var2"); - BaseAttributePtr a3 = createAttribute("author","va3"); - - con.addAttribute(*DPL::StaticPointerCast(a1)); - con.addAttribute(*DPL::StaticPointerCast(a2)); - con.addAttribute(*DPL::StaticPointerCast(a3)); - - attrSet.insert(a1); - attrSet.insert(a2); - attrSet.insert(a3); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRTrue)); -} - -TESTSUITE03(03){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("r8v2","var2"); - BaseAttributePtr a3 = createAttribute("author","va3"); - BaseAttributePtr a4 = createAttribute("version","wrongValue"); - - con.addAttribute(*DPL::StaticPointerCast(a1)); - con.addAttribute(*DPL::StaticPointerCast(a2)); - con.addAttribute(*DPL::StaticPointerCast(a3)); - - attrSet.insert(a2); - attrSet.insert(a3); - attrSet.insert(a4); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRTrue)); -} - -TESTSUITE03(04){ - Condition con(Condition::AND); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("r8v2","var2"); - BaseAttributePtr a3 = createAttribute("author","va3"); - BaseAttributePtr a4 = createAttribute("version","bad"); - BaseAttributePtr a5 = createAttribute("version","var1", Attribute::Type::Resource); - - con.addAttribute(*DPL::StaticPointerCast(a1)); - con.addAttribute(*DPL::StaticPointerCast(a2)); - con.addAttribute(*DPL::StaticPointerCast(a3)); - - attrSet.insert(a2); - attrSet.insert(a3); - attrSet.insert(a4); - attrSet.insert(a5); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRFalse)); -} - -TESTSUITE03(05){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("r8v2","var2"); - BaseAttributePtr a3 = createAttribute("author","va3"); - - BaseAttributePtr a4 = createAttribute("version","var1"); - BaseAttributePtr a5 = createAttribute("r8v2","var2"); - BaseAttributePtr a6 = createAttribute("author","va3"); - - con.addAttribute(*DPL::StaticPointerCast(a1)); - con.addAttribute(*DPL::StaticPointerCast(a2)); - con.addAttribute(*DPL::StaticPointerCast(a3)); - - attrSet.insert(a4); - attrSet.insert(a5); - attrSet.insert(a6); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRTrue)); -} - -TESTSUITE03(06){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("r8v2","var2"); - BaseAttributePtr a3 = createAttribute("author","va3"); - - BaseAttributePtr a4 = createAttribute("version","var2"); - BaseAttributePtr a5 = createAttribute("r8v2","var3"); - BaseAttributePtr a6 = createAttribute("author","va4"); - - con.addAttribute(*DPL::StaticPointerCast(a1)); - con.addAttribute(*DPL::StaticPointerCast(a2)); - con.addAttribute(*DPL::StaticPointerCast(a3)); - - attrSet.insert(a4); - attrSet.insert(a5); - attrSet.insert(a6); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRFalse)); -} - -TESTSUITE03(07){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("r8v2","var2"); - BaseAttributePtr a3 = createAttribute("author","va3"); - - BaseAttributePtr a4 = createAttribute("version","var1", Attribute::Type::Resource ); - BaseAttributePtr a5 = createAttribute("r8v2","var2", Attribute::Type::Resource); - BaseAttributePtr a6 = createAttribute("author","va3", Attribute::Type::Resource); - - BaseAttributePtr a7 = createAttribute("version","var2" ); - BaseAttributePtr a8 = createAttribute("r8v2","var3"); - BaseAttributePtr a9 = createAttribute("author","va4"); - - con.addAttribute(*DPL::StaticPointerCast(a1)); - con.addAttribute(*DPL::StaticPointerCast(a2)); - con.addAttribute(*DPL::StaticPointerCast(a3)); - - attrSet.insert(a4); - attrSet.insert(a5); - attrSet.insert(a6); - attrSet.insert(a7); - attrSet.insert(a8); - attrSet.insert(a9); - - //Despite that there are attribute a4,a5,a6 that matches the value of attributes - //a1,a2,a3 the type of the attributes is different - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRFalse)); -} - -//Test if the same attributes (but other instances) passes the test - -TESTSUITE03(08){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("r8v2","var2"); - BaseAttributePtr a3 = createAttribute("author","va3"); - - BaseAttributePtr a4 = createAttribute("version","var1"); - BaseAttributePtr a5 = createAttribute("r8v2","var2", Attribute::Type::Resource); - BaseAttributePtr a6 = createAttribute("author","va3", Attribute::Type::Resource); - BaseAttributePtr a7 = createAttribute("r8v2","aaa"); - BaseAttributePtr a8 = createAttribute("author","aaa"); - - con.addAttribute(*DPL::StaticPointerCast(a1)); - con.addAttribute(*DPL::StaticPointerCast(a2)); - con.addAttribute(*DPL::StaticPointerCast(a3)); - - attrSet.insert(a4); - attrSet.insert(a5); - attrSet.insert(a6); - attrSet.insert(a7); - attrSet.insert(a8); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRTrue)); -} - -TESTSUITE03(09){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version", NULL); //empty bag - con.addAttribute(*DPL::StaticPointerCast(a1)); - attrSet.insert(a1); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRFalse)); -} - -TESTSUITE03(10){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1","var2"); - - BaseAttributePtr a4 = createAttribute("version","var1"); - - con.addAttribute(*DPL::StaticPointerCast(a1)); - attrSet.insert(a4); - //It's enough that one value from string bag matches - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRTrue)); -} - -TESTSUITE03(11){ - Condition con(Condition::AND); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1","var2"); - BaseAttributePtr a2 = createAttribute("version","var3","var1"); - - BaseAttributePtr a4 = createAttribute("version","var1"); - - con.addAttribute(*DPL::StaticPointerCast(a1)); - con.addAttribute(*DPL::StaticPointerCast(a2)); - attrSet.insert(a4); - //It's enough that one value from string bag matches - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRTrue)); -} - - -TESTSUITE03(12){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("r8v2","var2"); - BaseAttributePtr a3 = createAttribute("author","va3"); - - BaseAttributePtr a4 = createAttribute("version","var1"); - BaseAttributePtr a5 = createAttribute("r8v2","var2", Attribute::Type::Resource); - BaseAttributePtr a6 = createAttribute("author","va3", Attribute::Type::Resource); - - con.addAttribute(*DPL::StaticPointerCast(a1)); - con.addAttribute(*DPL::StaticPointerCast(a2)); - con.addAttribute(*DPL::StaticPointerCast(a3)); - - attrSet.insert(a4); - attrSet.insert(a5); - attrSet.insert(a6); - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRTrue)); -} - -TESTSUITE03(13){ - Condition con(Condition::AND); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version",NULL); - a1->setUndetermind(true); - BaseAttributePtr a4 = createAttribute("version","var1"); - con.addAttribute(*DPL::StaticPointerCast(a4)); - attrSet.insert(a1); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRUndetermined)); -} - -TESTSUITE03(14){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version",NULL); - a1->setUndetermind(true); - BaseAttributePtr a2 = createAttribute("author","good"); - BaseAttributePtr a4 = createAttribute("version","var1"); - con.addAttribute(*DPL::StaticPointerCast(a4)); - con.addAttribute(*DPL::StaticPointerCast(a2)); - attrSet.insert(a1); - attrSet.insert(a2); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRTrue)); -} - -TESTSUITE03(15){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version",NULL,NULL); - a1->setUndetermind(true); - BaseAttributePtr a4 = createAttribute("version","var1"); - con.addAttribute(*DPL::StaticPointerCast(a4)); - attrSet.insert(a1); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRUndetermined)); -} - -TESTSUITE03(16){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1","aaa"); - a1->setUndetermind(true); - BaseAttributePtr a4 = createAttribute("version","var1"); - con.addAttribute(*DPL::StaticPointerCast(a4)); - attrSet.insert(a1); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRUndetermined)); -} - -TESTSUITE03(17){ - Condition con(Condition::AND); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("version1","var1"); - BaseAttributePtr a3 = createAttribute("version2","var1"); - BaseAttributePtr a4 = createAttribute("version3","var1"); - BaseAttributePtr a5 = createAttribute("version1","var2"); - - Condition con2(Condition::AND); - con2.addAttribute(*DPL::StaticPointerCast(a2)); - Condition con3(Condition::OR); - con3.addAttribute(*DPL::StaticPointerCast(a3)); - con3.addAttribute(*DPL::StaticPointerCast(a4)); - - con.addCondition(con2); - con.addCondition(con3); - - con.addAttribute(*DPL::StaticPointerCast(a4)); - attrSet.insert(a1); - attrSet.insert(a3); - attrSet.insert(a4); - attrSet.insert(a5); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRFalse)); -} - -TESTSUITE03(18){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("version1","var1"); - BaseAttributePtr a3 = createAttribute("version2","var1"); - BaseAttributePtr a4 = createAttribute("version3","var1"); - BaseAttributePtr a5 = createAttribute("version1","var2"); - - Condition con2(Condition::AND); - con2.addAttribute(*DPL::StaticPointerCast(a2)); - con2.addAttribute(*DPL::StaticPointerCast(a5)); - Condition con3(Condition::AND); - con3.addAttribute(*DPL::StaticPointerCast(a3)); - con3.addAttribute(*DPL::StaticPointerCast(a4)); - Condition con4(Condition::AND); - con4.addAttribute(*DPL::StaticPointerCast(a2)); - - con3.addCondition(con4); - con.addCondition(con2); - con.addCondition(con3); - - attrSet.insert(a1); - attrSet.insert(a3); - attrSet.insert(a4); - attrSet.insert(a5); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRFalse)); -} - -TESTSUITE03(19){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("version1","var1"); - BaseAttributePtr a3 = createAttribute("version2","var1"); - BaseAttributePtr a4 = createAttribute("version3","var1"); - BaseAttributePtr a5 = createAttribute("version1","var2"); - - Condition con2(Condition::AND); - con2.addAttribute(*DPL::StaticPointerCast(a2)); - con2.addAttribute(*DPL::StaticPointerCast(a5)); - Condition con3(Condition::OR); - con3.addAttribute(*DPL::StaticPointerCast(a3)); - con3.addAttribute(*DPL::StaticPointerCast(a4)); - - con.addCondition(con2); - con.addCondition(con3); - - attrSet.insert(a1); - attrSet.insert(a3); - attrSet.insert(a4); - attrSet.insert(a5); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRTrue)); -} - -TESTSUITE03(20){ - Condition con(Condition::OR); - AttributeSet attrSet; - - BaseAttributePtr a1 = createAttribute("version","var1"); - BaseAttributePtr a2 = createAttribute("version1","var1"); - BaseAttributePtr a3 = createAttribute("version2","var1"); - BaseAttributePtr a4 = createAttribute("version3","var1"); - - BaseAttributePtr a5 = createAttribute("version1","var2"); - BaseAttributePtr a6 = createAttribute("version2","var2"); - BaseAttributePtr a7 = createAttribute("version3","var2"); - BaseAttributePtr a8 = createAttribute("version4","var2"); - - Condition con2(Condition::OR); - Condition con3(Condition::OR); - Condition con4(Condition::OR); - Condition con5(Condition::OR); - - con2.addAttribute(*DPL::StaticPointerCast(a2)); - con3.addAttribute(*DPL::StaticPointerCast(a3)); - con4.addAttribute(*DPL::StaticPointerCast(a4)); - con5.addAttribute(*DPL::StaticPointerCast(a1)); - - con2.addCondition(con4); - con3.addCondition(con5); - con.addCondition(con2); - con.addCondition(con3); - - attrSet.insert(a1); - attrSet.insert(a5); - attrSet.insert(a6); - attrSet.insert(a7); - attrSet.insert(a8); - - RUNNER_ASSERT( - evaluateResult(con,attrSet,Attribute::MatchResult::MRTrue)); -} diff --git a/tests/ace/TestSuite04.cpp b/tests/ace/TestSuite04.cpp deleted file mode 100644 index 4cbdf1c..0000000 --- a/tests/ace/TestSuite04.cpp +++ /dev/null @@ -1,627 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file TestSuite04.cpp - * @author unknown - * @version 1.0 - * @brief Test cases for Combiner. - */ - -#include -#include - -#include -#include - -#include -#include -#include - -#define TESTSUITE04(n) \ -RUNNER_TEST(ts04_combiner_tests_ ## n) - -bool assertEffectEqual(Effect actual, Effect expected){ - return (actual == expected); -} - -class WTF : public CombinerImpl{ -public: - // the evaluation functions should be static and public - // but they are protected methods! - Effect denyOverrides(std::list &lst){ - return CombinerImpl::denyOverrides(lst); - } - Effect permitOverrides(std::list &lst){ - return CombinerImpl::permitOverrides(lst); - } - Effect firstApplicable(std::list &lst){ - return CombinerImpl::firstApplicable(lst); - } - Effect firstMatchingTarget(std::list &lst){ - return CombinerImpl::firstMatchingTarget(lst); - } -}; - -Effect denyOverridesTest(std::list &lst) { - WTF impl; - return impl.denyOverrides(lst); -} - -Effect permitOverridesTest(std::list &lst) { - WTF impl; - return impl.permitOverrides(lst); -} - -Effect firstApplicableTest(std::list &lst) { - WTF impl; - return impl.firstApplicable(lst); -} - -Effect firstMatchingTargetTest(std::list &lst) { - WTF impl; - return impl.firstMatchingTarget(lst); -} - -TESTSUITE04(00_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Undetermined); - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Deny)); -} - -TESTSUITE04(01_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Undetermined); - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - effectList->push_back(Deny); - effectList->push_back(Permit); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Deny)); -} - -TESTSUITE04(02_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Undetermined); - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - effectList->push_back(Permit); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Undetermined)); -} - -TESTSUITE04(03_denyOverrides){ - std::list * effectList = new std::list (); - - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - effectList->push_back(Permit); - effectList->push_back(Undetermined); - effectList->push_back(PromptSession); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Undetermined)); -} - -TESTSUITE04(04_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - effectList->push_back(Permit); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, PromptOneShot)); -} - -TESTSUITE04(05_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - effectList->push_back(Permit); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, PromptSession)); -} - -TESTSUITE04(06_denyOverrides){ - std::list * effectList = new std::list (); - - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - effectList->push_back(Permit); - effectList->push_back(PromptBlanket); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, PromptBlanket)); -} - -TESTSUITE04(07_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - effectList->push_back(Permit); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Permit)); -} - -TESTSUITE04(08_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Inapplicable); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Inapplicable)); -} - -TESTSUITE04(09_denyOverrides){ - std::list * effectList = new std::list (); - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Inapplicable)); -} - -TESTSUITE04(10_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Undetermined); - effectList->push_back(Permit); - effectList->push_back(Error); - effectList->push_back(Inapplicable); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(11_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Error); - effectList->push_back(Undetermined); - effectList->push_back(Error); - effectList->push_back(Inapplicable); - effectList->push_back(Permit); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(12_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - effectList->push_back(Permit); - effectList->push_back(Error); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(13_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - effectList->push_back(Permit); - effectList->push_back(Error); - effectList->push_back(PromptBlanket); - effectList->push_back(PromptSession); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(14_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Error); - effectList->push_back(Inapplicable); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(15_denyOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Inapplicable); - effectList->push_back(Error); - - Effect eff = denyOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(16_permitOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Undetermined); - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Permit)); -} - -TESTSUITE04(17_permitOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Inapplicable); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - effectList->push_back(Undetermined); - - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Undetermined)); -} - -TESTSUITE04(18_permitOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Inapplicable); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - - - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, PromptBlanket)); -} - -TESTSUITE04(19_permitOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptSession); - effectList->push_back(Inapplicable); - - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, PromptSession)); -} - -TESTSUITE04(20_permitOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Inapplicable); - effectList->push_back(PromptOneShot); - - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, PromptOneShot)); -} - -TESTSUITE04(21_permitOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Inapplicable); - - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Deny)); -} - -TESTSUITE04(22_permitOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Inapplicable); - - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Inapplicable)); -} - -TESTSUITE04(23_permitOverrides){ - std::list * effectList = new std::list (); - - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Inapplicable)); -} - -TESTSUITE04(24_permitOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Undetermined); - effectList->push_back(Permit); - effectList->push_back(Inapplicable); - effectList->push_back(Error); - effectList->push_back(PromptSession); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptBlanket); - - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(25_permitOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Inapplicable); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - effectList->push_back(Undetermined); - effectList->push_back(Error); - - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(26_permitOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Error); - effectList->push_back(Inapplicable); - effectList->push_back(PromptOneShot); - - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(27_permitOverrides){ - std::list * effectList = new std::list (); - effectList->push_back(Error); - Effect eff = permitOverridesTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(28_firstApplicable){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Inapplicable); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - effectList->push_back(Undetermined); - - Effect eff = firstApplicableTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Deny)); -} - -TESTSUITE04(29_firstApplicable){ - std::list * effectList = new std::list (); - effectList->push_back(Undetermined); - effectList->push_back(Deny); - effectList->push_back(PromptOneShot); - effectList->push_back(Inapplicable); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - effectList->push_back(Undetermined); - - Effect eff = firstApplicableTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Undetermined)); -} - -TESTSUITE04(30_firstApplicable){ - std::list * effectList = new std::list (); - effectList->push_back(Inapplicable); - effectList->push_back(Deny); - effectList->push_back(PromptOneShot); - effectList->push_back(Inapplicable); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - effectList->push_back(Undetermined); - - Effect eff = firstApplicableTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Deny)); -} - -TESTSUITE04(31_firstApplicable){ - std::list * effectList = new std::list (); - effectList->push_back(Inapplicable); - effectList->push_back(Undetermined); - effectList->push_back(PromptOneShot); - effectList->push_back(Inapplicable); - effectList->push_back(PromptOneShot); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - effectList->push_back(Undetermined); - - Effect eff = firstApplicableTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Undetermined)); -} - -TESTSUITE04(32_firstApplicable){ - std::list * effectList = new std::list (); - effectList->push_back(Inapplicable); - effectList->push_back(Inapplicable); - effectList->push_back(Inapplicable); - - Effect eff = firstApplicableTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Inapplicable)); -} - -TESTSUITE04(33_firstApplicable){ - std::list * effectList = new std::list (); - effectList->push_back(Inapplicable); - effectList->push_back(Inapplicable); - effectList->push_back(Inapplicable); - effectList->push_back(Permit); - - Effect eff = firstApplicableTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Permit)); -} - -TESTSUITE04(34_firstApplicable){ - std::list * effectList = new std::list (); - - Effect eff = firstApplicableTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Inapplicable)); -} - -TESTSUITE04(35_firstApplicable){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Inapplicable); - effectList->push_back(PromptOneShot); - effectList->push_back(Error); - effectList->push_back(PromptSession); - effectList->push_back(PromptBlanket); - effectList->push_back(Undetermined); - - Effect eff = firstApplicableTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(36_firstApplicable){ - std::list * effectList = new std::list (); - effectList->push_back(Inapplicable); - effectList->push_back(Inapplicable); - effectList->push_back(Inapplicable); - effectList->push_back(Error); - effectList->push_back(Permit); - - Effect eff = firstApplicableTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(37_firstApplicable){ - std::list * effectList = new std::list (); - effectList->push_back(Error); - - Effect eff = firstApplicableTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(38_firstMatching){ - std::list * effectList = new std::list (); - effectList->push_back(Inapplicable); - effectList->push_back(Deny); - effectList->push_back(PromptOneShot); - effectList->push_back(Inapplicable); - - Effect eff = firstMatchingTargetTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Inapplicable)); -} - -TESTSUITE04(39_firstMatching){ - std::list * effectList = new std::list (); - effectList->push_back(Undetermined); - effectList->push_back(Deny); - effectList->push_back(PromptOneShot); - effectList->push_back(Inapplicable); - - Effect eff = firstMatchingTargetTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Undetermined)); -} - -TESTSUITE04(39a_firstMatching){ - std::list * effectList = new std::list (); - effectList->push_back(Deny); - effectList->push_back(Inapplicable); - - Effect eff = firstMatchingTargetTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Deny)); -} - -TESTSUITE04(39b_firstMatching){ - std::list * effectList = new std::list (); - effectList->push_back(Permit); - - Effect eff = firstMatchingTargetTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Permit)); -} - -TESTSUITE04(40_firstMatching){ - std::list * effectList = new std::list (); - effectList->push_back(Undetermined); - effectList->push_back(Undetermined); - effectList->push_back(Undetermined); - - Effect eff = firstMatchingTargetTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Undetermined)); -} - -TESTSUITE04(41_firstMatching){ - std::list * effectList = new std::list (); - - Effect eff = firstMatchingTargetTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Inapplicable)); -} - -TESTSUITE04(42_firstMatching){ - std::list * effectList = new std::list (); - effectList->push_back(Inapplicable); - - Effect eff = firstMatchingTargetTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Inapplicable)); -} - -TESTSUITE04(43_firstMatching){ - - std::list * effectList = new std::list (); - effectList->push_back(Undetermined); - effectList->push_back(Undetermined); - effectList->push_back(Undetermined); - effectList->push_back(Deny); - effectList->push_back(Inapplicable); - effectList->push_back(Undetermined); - effectList->push_back(Deny); - effectList->push_back(PromptOneShot); - effectList->push_back(Inapplicable); - - Effect eff = firstMatchingTargetTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Undetermined)); -} - -TESTSUITE04(44_firstMatching){ - - std::list * effectList = new std::list (); - effectList->push_back(Inapplicable); - effectList->push_back(Deny); - effectList->push_back(PromptOneShot); - effectList->push_back(Error); - effectList->push_back(Inapplicable); - - Effect eff = firstMatchingTargetTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(45_firstMatching){ - - std::list * effectList = new std::list (); - effectList->push_back(Undetermined); - effectList->push_back(Undetermined); - effectList->push_back(Error); - effectList->push_back(Undetermined); - effectList->push_back(Deny); - effectList->push_back(Inapplicable); - effectList->push_back(Undetermined); - effectList->push_back(Deny); - effectList->push_back(PromptOneShot); - effectList->push_back(Inapplicable); - - Effect eff = firstMatchingTargetTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} - -TESTSUITE04(46_firstMatching){ - - std::list * effectList = new std::list (); - effectList->push_back(Error); - - Effect eff = firstMatchingTargetTest(*effectList); - RUNNER_ASSERT(assertEffectEqual(eff, Error)); -} diff --git a/tests/ace/TestSuite05.cpp b/tests/ace/TestSuite05.cpp deleted file mode 100644 index 57eb061..0000000 --- a/tests/ace/TestSuite05.cpp +++ /dev/null @@ -1,620 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file TestSuite05.cpp - * @author unknown - * @version 1.0 - * @brief Test cases for Attribute class. - */ - -#include -#include -#include -#include - -#include - -#include -#include - -#define TESTSUITE05(n) \ -RUNNER_TEST(ts05_attr_tests_ ## n) - -class AT : public Attribute { -public: - AT(std::string nm) - : Attribute(nm) - {} - - static std::string* uriAuthorityStatic(const std::string *input) { - AT at("Micky"); - return at.uriAuthority(input); - } - - static std::string* uriHostStatic(const std::string *input) { - AT at("Pluto"); - return at.uriHost(input); - } - - static std::string* uriSchemeStatic(const std::string *input) { - AT at("Donald"); - return at.uriScheme(input); - } - - static std::string* uriSchemeAuthorityStatic(const std::string *input) { - AT at("Winnie the Pooh"); - return at.uriSchemeAuthority(input); - } - - static std::string* uriPathStatic(const std::string *input) { - AT at("Hannibal"); - return at.uriPath(input); - } - - static bool markTest(){ - bool result = true; - for(int i =0; i<128; ++i){ - if( i == '-' || i == '_' || i == '.'|| i == '!'|| i == '~' || i == '*' || i == '\'' || i == ')' || i == '(' ){ - if (!mark[i]){ - result = false; - break; - } - } - else{ - if(mark[i]){ - result =false; - break; - } - } - } - return result; - } - - static bool digitTest(){ - bool result = true; - for(int i =0; i<128; ++i){ - if( i > 47 && i < 58 ){ - if (!digit[i]){ - result = false; - break; - } - } - else{ - if(digit[i]){ - result =false; - break; - } - } - } - return result; - } - - static bool alphaTest(){ - bool result = true; - for(int i =0; i<128; ++i){ - if( ( i>64 && i<91 ) || ( i>96 && i<123 ) ) { - if (!alpha[i]){ - result = false; - break; - } - } - else{ - if(alpha[i]){ - result =false; - break; - } - } - } - return result; - } - - static bool isEscapedStatic(const char esc[3]) { - AT at("Swinka"); - return at.isEscaped(esc); - } -}; - -bool assertEqual(const std::string * actual, const char * intended) { - if (actual == NULL || intended == NULL) { - if (intended == NULL && actual == NULL) { - return true; - } - else { - return false; - } - } - - std::string temp(intended); - - if (temp == *actual) { - return true; - } - else { - return false; - } -} - -bool assertTrue(bool condition){ - return condition; -} - -bool assertFalse(bool condition){ - return !condition; -} - -TESTSUITE05(01_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://www.wp.pl"); - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "www.wp.pl")); - delete outcome; -} - -TESTSUITE05(02_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://authority?path/asdf"); - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "authority")); - delete outcome; -} - -TESTSUITE05(03_uriAuthority){ - std::string * outcome = NULL; - std::string query("abcd"); //This should be interpreted as schema - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "")); - delete outcome; -} - -TESTSUITE05(04_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://authority/asdf"); - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "authority")); - delete outcome; -} - -TESTSUITE05(05_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://user@host:20?ds"); - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "user@host:20")); - delete outcome; -} - -TESTSUITE05(06_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://hostname:23"); - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "hostname:23")); - delete outcome; -} - -TESTSUITE05(07_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://user@host:port"); - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "user@host:port")); - delete outcome; -} - -TESTSUITE05(08_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://1user@host:port"); //This is a VALID URI - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "1user@host:port")); - delete outcome; -} - -TESTSUITE05(09_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://abc%30"); //This is not a valid uri - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "abc%30")); - delete outcome; -} - -TESTSUITE05(10_uriAuthority){ - std::string * outcome = NULL; - std::string query("http:///asd"); //This is not a valid uri - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "")); - delete outcome; -} - -TESTSUITE05(11_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://?asd"); //This is not a valid uri - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "")); - delete outcome; -} - -TESTSUITE05(12_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://%34%56%67%ab"); - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "%34%56%67%ab")); - delete outcome; -} - -TESTSUITE05(13_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://<>"); //This is not a valid uri - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, NULL)); - delete outcome; -} - -TESTSUITE05(14_uriAuthority){ - std::string * outcome = NULL; - std::string query("http://\\/"); //This is not a valid uri - outcome = AT::uriAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, NULL)); - delete outcome; -} - -TESTSUITE05(15_uriHost){ - std::string * outcome = NULL; - std::string query("http://user@host:23"); - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "host")); - delete outcome; -} - -TESTSUITE05(16_uriHost){ - std::string * outcome = NULL; - std::string query("http://user@host:name"); //This is not a valid uri - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "")); - delete outcome; -} - -TESTSUITE05(17_uriHost){ - std::string * outcome = NULL; - std::string query("http::::"); //This is a valid uri - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "")); - delete outcome; -} - -TESTSUITE05(18_uriHost){ - std::string * outcome = NULL; - std::string query("..%%%."); //This is not a valid uri - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, NULL)); - delete outcome; -} - -TESTSUITE05(19_uriHost){ - std::string * outcome = NULL; - std::string query("ftp://abds.eu/fda"); - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "abds.eu")); - delete outcome; -} - -TESTSUITE05(20_uriHost){ - std::string * outcome = NULL; - std::string query("abs%14ccc"); - //This is a valid uri because it's interpreted as a path not a host - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "")); - delete outcome; -} - -TESTSUITE05(21_uriHost){ - std::string * outcome = NULL; - std::string query("http://abc@123.2.23.213:982"); - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "123.2.23.213")); - delete outcome; -} - -TESTSUITE05(22_uriHost){ - std::string * outcome = NULL; - std::string query("http://abc@1233.2.23.213:982"); - //Hostname is invalid, but uri is valid - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "")); - delete outcome; -} - -TESTSUITE05(23_uriHost){ - std::string * outcome = NULL; - std::string query("http://ab%23c@host"); //Valid escaped characters - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "host")); - delete outcome; -} - -TESTSUITE05(24_uriHost){ - std::string * outcome = NULL; - std::string query("http://ab%23c@host%34"); //Invalid escaped characters in hostname - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "")); - delete outcome; -} - -TESTSUITE05(25_uriHost){ - std::string * outcome = NULL; - std::string query("http://ab%GGc@host"); //Wrong character % - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, NULL)); - delete outcome; -} - -TESTSUITE05(26_uriHost){ - std::string * outcome = NULL; - std::string query("http://www.example.pl"); - outcome = AT::uriHostStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "www.example.pl")); - delete outcome; -} - -TESTSUITE05(27_uriScheme){ - std::string * outcome = NULL; - std::string query("http://host"); - outcome = AT::uriSchemeStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "http")); - delete outcome; -} - -TESTSUITE05(28_uriScheme){ - std::string * outcome = NULL; - //Wrong character '1' in scheme , it's not an URI because two slashes are not acceptable - //in any other place than in separation between scheme and pat - std::string query("1http://host"); - outcome = AT::uriSchemeStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, NULL)); - delete outcome; -} - -TESTSUITE05(29_uriScheme){ - std::string * outcome = NULL; - std::string query("ftp+a-fdf.ads://host"); - outcome = AT::uriSchemeStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "ftp+a-fdf.ads")); - delete outcome; -} - -TESTSUITE05(30_uriScheme){ - std::string * outcome = NULL; - //Scheme cannot start with plus, it's not an URI because two slashes are not acceptable - //in any other place than in separation between scheme and path - std::string query("+++://host"); - outcome = AT::uriSchemeStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, NULL)); - delete outcome; -} - -TESTSUITE05(31_uriScheme){ - std::string * outcome = NULL; - std::string query("aaaac"); //It's a path not a scheme'a - outcome = AT::uriSchemeStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "")); - delete outcome; -} - -TESTSUITE05(32_uriScheme){ - std::string * outcome = NULL; - //no escaped characters in schema, it's not an URI because two slashes are not acceptable - //in any other place than in separation between scheme and path - std::string query("ftpa%34fdfads://host"); - outcome = AT::uriSchemeStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, NULL)); - delete outcome; -} - -TESTSUITE05(33_uriScheme){ - std::string * outcome = NULL; - //no escaped characters in schema, it's not an URI because two slashes are not acceptable - //in any other place than in separation between scheme and path - std::string query("meaninglessstring://host%34"); - outcome = AT::uriSchemeStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "meaninglessstring")); - delete outcome; -} - -TESTSUITE05(34_uriScheme){ - std::string * outcome = NULL; - std::string query("meaninglessstring2://"); - outcome = AT::uriSchemeStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "meaninglessstring2")); - delete outcome; -} - -TESTSUITE05(35_uriScheme){ - std::string * outcome = NULL; - std::string query("http://www.samsung.com/ace/bondi#5"); - outcome = AT::uriSchemeStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "http")); - delete outcome; -} - -TESTSUITE05(36_uriScheme){ - std::string * outcome = NULL; - std::string query("www.samsung.com"); - outcome = AT::uriSchemeStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "")); - delete outcome; -} - -TESTSUITE05(37_uriSchemeAuthority){ - std::string * outcome = NULL; - std::string query("http://www.samsung.com"); - outcome = AT::uriSchemeAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "http://www.samsung.com")); - delete outcome; -} - -TESTSUITE05(38_uriSchemeAuthority){ - std::string * outcome = NULL; - std::string query("ftp23://www.samsung.com/avc%23"); - outcome = AT::uriSchemeAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "ftp23://www.samsung.com")); - delete outcome; -} - -TESTSUITE05(39_uriSchemeAuthority){ - std::string * outcome = NULL; - std::string query("ftp++://anonymous@hostname:12/avc%23"); - outcome = AT::uriSchemeAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "ftp++://anonymous@hostname:12")); - delete outcome; -} - -TESTSUITE05(40_uriSchemeAuthority){ - std::string * outcome = NULL; - std::string query("32ftp://anonymous@hostname:12/avc%23"); - outcome = AT::uriSchemeAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, NULL)); - delete outcome; -} - -TESTSUITE05(41_uriSchemeAuthority){ - std::string * outcome = NULL; - std::string query("http://aaabbb?acd"); - outcome = AT::uriSchemeAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "http://aaabbb")); - delete outcome; -} - -TESTSUITE05(42_uriSchemeAuthority){ - std::string * outcome = NULL; - std::string query("http://aaabbb/acd;sdf;sdf"); - outcome = AT::uriSchemeAuthorityStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "http://aaabbb")); - delete outcome; -} - -TESTSUITE05(43_uriPath){ - std::string * outcome = NULL; - std::string query("ftp://authority//invalidpath"); - outcome = AT::uriPathStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, NULL)); - delete outcome; -} - -TESTSUITE05(44_uriPath){ - std::string * outcome = NULL; - std::string query("ftp://authority/validpath"); - outcome = AT::uriPathStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "validpath")); - delete outcome; -} - -TESTSUITE05(45_uriPath){ - std::string * outcome = NULL; - std::string query("ftp://authority/validpath;param;param"); - outcome = AT::uriPathStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "validpath;param;param")); - delete outcome; -} - -TESTSUITE05(46_uriPath){ - std::string * outcome = NULL; - std::string query("ftp://authority/validpath;param;param?query"); - outcome = AT::uriPathStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "validpath;param;param")); - delete outcome; -} - -TESTSUITE05(47_uriPath){ - std::string * outcome = NULL; - std::string query("ftp://authority/validpath;?param;param?query"); - outcome = AT::uriPathStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "validpath;")); - delete outcome; -} - -TESTSUITE05(48_uriPath){ - std::string * outcome = NULL; - std::string query("ftp://authority/validpath;param?;param?query"); - outcome = AT::uriPathStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "validpath;param")); - delete outcome; -} - -TESTSUITE05(49_uriPath){ - std::string * outcome = NULL; - std::string query("ftp://authority/valid:path?query"); - outcome = AT::uriPathStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "valid:path")); - delete outcome; -} - -TESTSUITE05(50_uriPath){ - std::string * outcome = NULL; - std::string query("ftp://authority/:::"); - outcome = AT::uriPathStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, ":::")); - delete outcome; -} - -TESTSUITE05(51_uriPath){ - std::string * outcome = NULL; - std::string query("/path1/path2?abc#fragment"); - outcome = AT::uriPathStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "path1/path2")); - delete outcome; -} - -TESTSUITE05(52_uriPath){ - std::string * outcome = NULL; - std::string query("http://www.samsung.com/normalpath/path2?query"); - outcome = AT::uriPathStatic(&query); - RUNNER_ASSERT(assertEqual(outcome, "normalpath/path2")); - delete outcome; -} - -TESTSUITE05(53_markTest){ - RUNNER_ASSERT(AT::markTest()); -} - -TESTSUITE05(54_digitTest){ - RUNNER_ASSERT(AT::digitTest()); -} - -TESTSUITE05(55_alphaTest){ - RUNNER_ASSERT(AT::alphaTest()); -} - -TESTSUITE05(56_escapedTest){ - const char * query = "%23"; - RUNNER_ASSERT(assertTrue(AT::isEscapedStatic(query))); - query = "%ab"; - RUNNER_ASSERT(assertTrue(AT::isEscapedStatic(query))); - - query = "%a"; - RUNNER_ASSERT(assertFalse(AT::isEscapedStatic(query))); - - query = "%rw"; - RUNNER_ASSERT(assertFalse(AT::isEscapedStatic(query))); - - query = NULL; - RUNNER_ASSERT(assertFalse(AT::isEscapedStatic(query))); - - query = "abc"; - RUNNER_ASSERT(assertFalse(AT::isEscapedStatic(query))); - - query = "%bc"; - RUNNER_ASSERT(assertTrue(AT::isEscapedStatic(query))); - - query = "%DF"; - RUNNER_ASSERT(assertTrue(AT::isEscapedStatic(query))); -} - diff --git a/tests/ace/TestSuite06.cpp b/tests/ace/TestSuite06.cpp deleted file mode 100644 index 7db0139..0000000 --- a/tests/ace/TestSuite06.cpp +++ /dev/null @@ -1,1610 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file TestSuite06.cpp - * @author unknown - * @version 1.0 - * @brief Test cases for AceDAO implementation. - */ -#include -#include - -#include -#include - -#include -#include -#include -#include - -#define TESTSUITE06(n) \ -RUNNER_TEST(ts06_ace_dao_ ## n) - -#define CLEANENV \ - do{ \ - AceDB::AceDAO::clearWidgetDevCapSettings(); \ - AceDB::AceDAO::clearDevCapSettings(); \ - }while(0) - -using namespace AceDB; - -int operator==(const Attribute& left, const Attribute& right) -{ - return ( (*left.getName() == *right.getName())); -} - -bool UserSettingsAgreed(std::list* expected, - std::list* allRules) -{ - if (allRules->empty() && expected->empty()) - { - return true; - } - - std::list::iterator itA; - FOREACH(itE, *expected) - { - if (itE->devCap.empty()){ - return false; //some error occur - } - - for (itA = allRules->begin(); itA != allRules->end(); ++itA){ - if (itA->appId == itE->appId && - itA->devCap == itE->devCap) - { - if (itA->access == itE->access){ - break; - } - else{ - return false; //optimization - } - } - } - - if (itA == allRules->end()) - { - if (itE->access == Preference::PREFERENCE_DEFAULT) - { // this value is not set in DB - continue; - } - //if we are here -it means that expected values doesnt exist in DB - return false; - } - else - { - continue; //go to next expected attr - } - } - - //it means that all required values exist in DB - return true; -} - - -bool UserSettingNotStored(std::list* userSettings, - std::string res, - WidgetHandle handler, - Preference pref) -{ - if (userSettings->empty()) - { - return true; - } - - FOREACH(iter, *userSettings) - { - if (iter->appId == handler && iter->devCap == res){ - if (iter->access == pref){ - return false; //this value has been saved - } - else{ - continue; //value has been saved - } - } - } - - return true; -} - - - -bool ResourceSettingsAgreed( - std::list< std::pair > *expected, - std::map* allRules) -{ - std::list< std::pair >::iterator itE; - std::map::iterator itA; - - FOREACH(itE, *expected) - { - itA = allRules->find(*(itE->first)); - if (itA != allRules->end() && itA->second == itE->second) - { - continue; - } - else - { - return false; - } - } - - return true; -} - -bool ResourceSettingsEqual( - std::list< std::pair > * actual, - std::map* expected) -{ - bool flag = false; - FOREACH(iterA, *actual) - { - FOREACH(iterE, *expected) - { - if (*(iterA->first) == iterE->first && - iterA->second == iterE->second) - { - flag = true; - } - } - if (!flag) - { - return false; - } - flag = false; - } - - return true; -} - -//bool VSPAssertEqual(Verdict actual, Verdict expected){ -// return (actual == expected); -//} - - -bool AttributeEqual(AttributeSet actual, AttributeSet expected){ - return (actual == expected); -} - -bool ResourceSettingEqual(std::map* rSettings, - std::string res, - Preference pref) -{ - std::map::iterator iter = rSettings->find(res); - - if (iter != rSettings->end() && iter->second ==pref) - { - return true; - } - - return false; -} - - -bool UserSettingEqual(std::list* userSettings, - std::string res, - WidgetHandle handler, - Preference pref) -{ - if (userSettings->empty() && pref == Preference::PREFERENCE_DEFAULT) - { - return true; - } - FOREACH(iter, *userSettings) - { - if (iter->devCap.empty()) - { - return false; //some error occurred - } - if (iter->appId == handler && iter->devCap == res){ - if (iter->access == pref) - { - return true; - } - else - { - return false; - } - } - } - - return false; -} - -//Test does verdict PERMIT is saved when validity is once -TESTSUITE06(01){ - CLEANENV; - AttributeSet attributeSet; - std::string tmp("atrS"); - std::string tmpValue("Buu"); - BaseAttributePtr atr(new Attribute(&tmp, - Attribute::Match::Equal, - Attribute::Type::Subject)); - DPL::StaticPointerCast(atr)->addValue(&tmpValue); - attributeSet.insert(atr); - - AceDAO::setPolicyResult(attributeSet, PolicyEffect::PERMIT); - OptionalPolicyResult opt = AceDAO::getPolicyResult(attributeSet); - - PolicyResult effect(PolicyEffect::DENY); - if (!opt.IsNull()) { - effect = *opt; - } - - RUNNER_ASSERT(effect == PolicyEffect::PERMIT); -} - -TESTSUITE06(02){ - CLEANENV; - AttributeSet attributeSet; - std::string tmp("atrS"); - std::string tmpValue("Buu"); - BaseAttributePtr atr(new Attribute(&tmp, - Attribute::Match::Equal, - Attribute::Type::Subject)); - DPL::StaticPointerCast(atr)->addValue(&tmpValue); - attributeSet.insert(atr); - - AceDAO::setPolicyResult(attributeSet, PolicyEffect::DENY); - OptionalPolicyResult opt = AceDAO::getPolicyResult(attributeSet); - - PolicyResult effect(PolicyEffect::PERMIT); - if (!opt.IsNull()) { - effect = *opt; - } - - RUNNER_ASSERT(effect == PolicyEffect::DENY); -} - -TESTSUITE06(03){ - CLEANENV; - AttributeSet attributeSet; - std::string tmp("atrS"); - std::string tmpValue("Buu"); - BaseAttributePtr atr(new Attribute(&tmp, - Attribute::Match::Equal, - Attribute::Type::Subject)); - DPL::StaticPointerCast(atr)->addValue(&tmpValue); - attributeSet.insert(atr); - - AceDAO::setPolicyResult(attributeSet, PolicyEffect::PROMPT_ONESHOT); - OptionalPolicyResult opt = AceDAO::getPolicyResult(attributeSet); - - PolicyResult effect(PolicyEffect::DENY); - if (!opt.IsNull()) { - effect = *opt; - } - - RUNNER_ASSERT(effect == PolicyEffect::PROMPT_ONESHOT); -} - -TESTSUITE06(04){ - CLEANENV; - AttributeSet attributeSet; - std::string tmp("atrS"); - std::string tmpValue("Buu"); - BaseAttributePtr atr(new Attribute(&tmp, - Attribute::Match::Equal, - Attribute::Type::Subject)); - DPL::StaticPointerCast(atr)->addValue(&tmpValue); - attributeSet.insert(atr); - - AceDAO::setPolicyResult(attributeSet, PolicyEffect::PROMPT_SESSION); - OptionalPolicyResult opt = AceDAO::getPolicyResult(attributeSet); - - PolicyResult effect(PolicyEffect::DENY); - if (!opt.IsNull()) { - effect = *opt; - } - - RUNNER_ASSERT(effect == PolicyEffect::PROMPT_SESSION); -} - -TESTSUITE06(05){ - CLEANENV; - AttributeSet attributeSet; - std::string tmp("atrS"); - std::string tmpValue("Buu"); - BaseAttributePtr atr(new Attribute(&tmp, - Attribute::Match::Equal, - Attribute::Type::Subject)); - DPL::StaticPointerCast(atr)->addValue(&tmpValue); - attributeSet.insert(atr); - - AceDAO::setPolicyResult(attributeSet, PolicyEffect::PROMPT_BLANKET); - OptionalPolicyResult opt = AceDAO::getPolicyResult(attributeSet); - - PolicyResult effect(PolicyEffect::DENY); - if (!opt.IsNull()) { - effect = *opt; - } - - RUNNER_ASSERT(effect == PolicyEffect::PROMPT_BLANKET); -} - -TESTSUITE06(06){ - CLEANENV; - AttributeSet attributeSet; - std::string tmp("atrS"); - std::string tmpValue("Buu"); - BaseAttributePtr atr(new Attribute(&tmp, - Attribute::Match::Equal, - Attribute::Type::Subject)); - DPL::StaticPointerCast(atr)->addValue(&tmpValue); - attributeSet.insert(atr); - - AceDAO::setPolicyResult(attributeSet, PolicyDecision::NOT_APPLICABLE); - OptionalPolicyResult opt = AceDAO::getPolicyResult(attributeSet); - - PolicyResult effect(PolicyEffect::DENY); - if (!opt.IsNull()) { - effect = *opt; - } - - RUNNER_ASSERT(effect == PolicyDecision::NOT_APPLICABLE); -} - -TESTSUITE06(07){ - CLEANENV; - AttributeSet attributeSet; - std::string tmp("atrS"); - std::string tmpValue("Buu"); - BaseAttributePtr atr(new Attribute(&tmp, - Attribute::Match::Equal, - Attribute::Type::Subject)); - DPL::StaticPointerCast(atr)->addValue(&tmpValue); - attributeSet.insert(atr); - - AceDAO::setPolicyResult(attributeSet, PolicyResult::UNDETERMINED); - OptionalPolicyResult opt = AceDAO::getPolicyResult(attributeSet); - - PolicyResult effect(PolicyEffect::DENY); - if (!opt.IsNull()) { - effect = *opt; - } - - RUNNER_ASSERT(effect == PolicyResult::UNDETERMINED); -} - -TESTSUITE06(08){ - CLEANENV; - AttributeSet attributeSet; - std::string tmp("atrS2"); - std::string tmpValue("Buu2"); - BaseAttributePtr atr(new Attribute(&tmp, - Attribute::Match::Equal, - Attribute::Type::Subject)); - DPL::StaticPointerCast(atr)->addValue(&tmpValue); - attributeSet.insert(atr); - - std::string session = "jlakjhqrwebn234324987"; - std::string param = "xxx"; - - AceDAO::setPromptDecision(attributeSet, - DPL::FromUTF8String(param), - DPL::FromUTF8String(session), - PromptDecision::ALLOW_ALWAYS); - - OptionalCachedPromptDecision decision = - AceDAO::getPromptDecision(attributeSet, param); - - DPL::String session1; - PromptDecision dec = PromptDecision::DENY_FOR_SESSION; - if (!decision.IsNull()){ - dec = (*decision).decision; - if (!decision.IsNull()) { - session1 = *((*decision).session); - } - } - RUNNER_ASSERT(dec == PromptDecision::ALLOW_ALWAYS); - RUNNER_ASSERT(DPL::ToUTF8String(session1) == session); -} - -TESTSUITE06(09){ - CLEANENV; - AttributeSet attributeSet; - std::string tmp("atrS2"); - std::string tmpValue("Buu2"); - BaseAttributePtr atr(new Attribute(&tmp, - Attribute::Match::Equal, - Attribute::Type::Subject)); - DPL::StaticPointerCast(atr)->addValue(&tmpValue); - attributeSet.insert(atr); - - std::string param = "xxx"; - - AceDAO::setPromptDecision(attributeSet, - DPL::FromUTF8String(param), - DPL::OptionalString(), - PromptDecision::ALLOW_FOR_SESSION); - - OptionalCachedPromptDecision decision = - AceDAO::getPromptDecision(attributeSet, param); - - std::string session1; - PromptDecision dec = PromptDecision::DENY_FOR_SESSION; - if (!decision.IsNull()){ - dec = (*decision).decision; - RUNNER_ASSERT((*decision).session.IsNull()); - } - RUNNER_ASSERT(dec == PromptDecision::ALLOW_FOR_SESSION); -} - -///*findVerdict*/ -// -//void AceDAOTester::test3() -//{ -//// Tests does verdict is stored for validity always -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS3"); -// std::string tmpValue("Buu3"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_PERMIT; -// Validity val = Validity::ALWAYS; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_PERMIT); -// handleResult(result, "find Verdict test 3"); -//} -///*findVerdict*/ -// -//void AceDAOTester::test4() -//{ -////tests does verdict is propertly stored (NOT saved)when session is Validity::ONCE -////and verdict is DENY -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS4"); -// std::string tmpValue("Buu4"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_DENY; -// Validity val = Validity::ONCE; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 4"); -//} -///*findVerdict*/ -// -//void AceDAOTester::test5() -//{ -////tests does verdict is properly set when validity is session -////and verdict is deny -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS5"); -// std::string tmpValue("Buu5"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_DENY; -// Validity val = Validity::SESSION; -// pip.setSessionId("5"); -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// pip.setSessionId("5"); -// session = getSession(); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_DENY); -// handleResult(result, "find Verdict test 5"); -//} -///*findVerdict*/ -// -//void AceDAOTester::test6() -//{ -////tests does verdict is properly stored for DENY Validity::ALWAYS -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS6"); -// std::string tmpValue("Buu6"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_DENY; -// Validity val = Validity::ALWAYS; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_DENY); -// handleResult(result, "find Verdict test 6"); -//} -// -// -//void AceDAOTester::test7() -//{ -////tests stored version fo INAPPLICABLE Validity::ONCE -// -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// attributeSet.insert(constructAttribute("atrS7","Buu7")); -// Verdict ver = Verdict::VERDICT_INAPPLICABLE; -// Validity val = Validity::ONCE; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// //Verdict with 'Once' validity should not be stored, therefore -// //the outcome should be UNKNOWN -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 7"); -//} -// -// -//void AceDAOTester::test8() -//{ -////tests storing data for verdict INAPLICABLE and Validity::SESSION -// -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// attributeSet.insert(constructAttribute("atrS8","Buuu8")); -// Verdict ver = Verdict::VERDICT_INAPPLICABLE; -// Validity val = Validity::SESSION; -// pip.setSessionId("8"); -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// pip.setSessionId("9"); -// session = getSession(); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 8"); -//} -///*findVerdict*/ -// -//void AceDAOTester::test9() -//{ -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS9"); -// std::string tmpValue("Buu9"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_INAPPLICABLE; -// Validity val = Validity::ALWAYS; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_INAPPLICABLE); -// handleResult(result, "find Verdict test 9"); -//} -///*findVerdict*/ -// -//void AceDAOTester::test10() -//{ -////tests does verdict is properly stored for verdict undetermined -////and validity Validity::ONCE - thats why verdict is UNKNOWN -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS10"); -// std::string tmpValue("Buu10"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_UNDETERMINED; -// Validity val = Validity::ONCE; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 10"); -//} -///*findVerdict*/ -// -//void AceDAOTester::test11() -//{ -////tests does verdict is properly stored for verdict undetermined -////and validity Validity::SESSION - TODO Verdicts for undetermined are not stored?? -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS11"); -// std::string tmpValue("Buu11"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_UNDETERMINED; -// pip.setSessionId("8"); -// Validity val = Validity::SESSION; -// pip.setSessionId("8"); -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 11"); -//} -///*findVerdict*/ -// -//void AceDAOTester::test12() -//{ -////tests does verdict is properly stored for verdict undetermined -////and validity Validity::ALWAYS - TODO Verdicts for undetermined are not stored?? -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS12"); -// std::string tmpValue("Buu12"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_UNDETERMINED; -// Validity val = Validity::ALWAYS; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 12"); -//} -///*findVerdict*/ -// -//void AceDAOTester::test13() -//{ -////tests does verdict is properly stored for verdict unknown -////and validity Validity::ONCE-thats why verdict is not stored -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS13"); -// std::string tmpValue("Buu13"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_UNKNOWN; -// Validity val = Validity::ONCE; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 13"); -//} -///*findVerdict*/ -// -//void AceDAOTester::test14() -//{ -////tests does verdict is properly stored for verdict unknown -////and validity session- TODO why is the verdict not stored? -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS14"); -// std::string tmpValue("Buu14"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_UNKNOWN; -// Validity val = Validity::SESSION; -// pip.setSessionId("8"); -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// pip.setSessionId("8"); -// session = getSession(); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 14"); -//} -///*findVerdict*/ -// -//void AceDAOTester::test15() -//{ -////tests does verdict is properly stored for verdict unknown and -////validity Validity::ALWAYS - TODO should we save Unknown verdict? -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS15"); -// std::string tmpValue("Buu15"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_UNKNOWN; -// Validity val = Validity::ALWAYS; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 15"); -//} -// -///*removeVerdict*/ //tests does verdict is properly removed -//void AceDAOTester::test16() -//{ -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS15"); -// std::string tmpValue("Buu15"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// -// Verdict ver = Verdict::VERDICT_PERMIT; -// Validity val = Validity::ALWAYS; -// //add verdict -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// //check has verdict been stored? -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_PERMIT); -// handleResult(result, "find Verdict test 16: partA"); -// -// //remove verdict -// VerdictLogic::removeVerdict(request, attributeSet); -// //verified removed -// verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 16: partB"); -//} -// -///*findVerdict*/ -//void AceDAOTester::test18() -//{ -////verdict for 3 elements on the set of attributes -// Request request("subject18","resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS60"); -// std::string tmpValue("Buu60"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// -// std::string tmp1("atrS61"); -// std::string tmpValue1("Buu61"); -// BaseAttributePtr atr1( -// new Attribute(&tmp1,Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr1)->addValue(&tmpValue1); -// attributeSet.insert(atr1); -// -// std::string tmp2("atrS62"); -// std::string tmpValue2("Buu62"); -// BaseAttributePtr atr2( -// new Attribute(&tmp2,Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr2)->addValue(&tmpValue2); -// attributeSet.insert(atr2); -// -// Verdict ver = Verdict::VERDICT_DENY; -// Validity val = Validity::ALWAYS; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_DENY); -// handleResult(result, "find Verdict test 18"); -//} -// -///*resetDatabase*/ -//void AceDAOTester::test19() -//{ -// //tests reset DB -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS15"); -// std::string tmpValue("Buu15"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// -// Verdict ver = Verdict::VERDICT_PERMIT; -// Validity val = Validity::ALWAYS; -// //add verdict -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// //check has verdict been stored? -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_PERMIT); -// handleResult(result, "reset database test 19: partA"); -// -// AceDAO::resetDatabase(); -// -// verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "reset database test 19: partB"); -//} - - -/*setWidgetDevCapSetting*/ - -TESTSUITE06(26){ - CLEANENV; - std::string res("res20"); - WidgetHandle sub = 20; - - SettingsLogic::setWidgetDevCapSetting(res, sub, Preference::PREFERENCE_PERMIT); - std::list userSettings; - SettingsLogic::getWidgetDevCapSettings(&userSettings); - RUNNER_ASSERT( - UserSettingEqual( - &userSettings, res, sub, Preference::PREFERENCE_PERMIT)); -} - -/*setWidgetDevCapSetting*/ - -TESTSUITE06(27){ - CLEANENV; - std::string res("res21"); - WidgetHandle sub = 21; - - SettingsLogic::setWidgetDevCapSetting(res, sub, Preference::PREFERENCE_DENY); - std::list userSettings; - SettingsLogic::getWidgetDevCapSettings(&userSettings); - RUNNER_ASSERT( - UserSettingEqual( - &userSettings, res, sub, Preference::PREFERENCE_DENY)); -} - -/*setWidgetDevCapSetting*/ - -TESTSUITE06(28){ - CLEANENV; - std::string res("res22"); - WidgetHandle sub = 22; - AceDAO::clearAllSettings(); - SettingsLogic::setWidgetDevCapSetting(res, sub, Preference::PREFERENCE_DEFAULT); - std::list userSettings; - SettingsLogic::getWidgetDevCapSettings(&userSettings); - RUNNER_ASSERT( - UserSettingEqual( - &userSettings, res, sub, Preference::PREFERENCE_DEFAULT)); -} - -TESTSUITE06(29){ - CLEANENV; - std::string res("res23"); - WidgetHandle sub = 23; - - SettingsLogic::setWidgetDevCapSetting(res, sub, Preference::PREFERENCE_DEFAULT); - SettingsLogic::setWidgetDevCapSetting(res, sub, Preference::PREFERENCE_DENY); - std::list userSettings; - SettingsLogic::getWidgetDevCapSettings(&userSettings); - RUNNER_ASSERT( - UserSettingEqual( - &userSettings, res, sub, Preference::PREFERENCE_DENY)); -} - -/*setWidgetDevCapSettings*/ - -TESTSUITE06(30){ - CLEANENV; - std::string resa("res24a"); - WidgetHandle suba = 241; - std::string resb("res24b"); - WidgetHandle subb = 242; - - std::list permissionsL; - - permissionsL.push_back( - PermissionTriple(suba, resa, Preference::PREFERENCE_DENY)); - permissionsL.push_back( - PermissionTriple(subb, resb, Preference::PREFERENCE_PERMIT)); - - SettingsLogic::setWidgetDevCapSettings(permissionsL); - - std::list userSettings; - SettingsLogic::getWidgetDevCapSettings(&userSettings); - RUNNER_ASSERT( - UserSettingsAgreed(&permissionsL, &userSettings)); -} - - - -TESTSUITE06(31){ - CLEANENV; -//multi set - if value is not set in DB or has DEFAUL value it is not -//send by getWidgetDevCapSettings - optimization - - std::string resa("res25a"); - WidgetHandle suba = 251; - std::string resb("res25b"); - WidgetHandle subb = 252; - std::string resc("res25c"); - WidgetHandle subc = 253; - - std::list permissionsL; - - permissionsL.push_back( - PermissionTriple(suba, resa, Preference::PREFERENCE_DENY)); - permissionsL.push_back( - PermissionTriple(subb, resb, Preference::PREFERENCE_PERMIT)); - permissionsL.push_back( - PermissionTriple(subc, resc, Preference::PREFERENCE_DEFAULT)); - - - SettingsLogic::setWidgetDevCapSettings(permissionsL); - - std::list userSettings; - SettingsLogic::getWidgetDevCapSettings(&userSettings); - RUNNER_ASSERT(UserSettingsAgreed(&permissionsL, &userSettings)); -} - -TESTSUITE06(32){ - CLEANENV; - //empty list -- TODO what is it testing? - std::list permissionsL; - - std::list userSettings; - SettingsLogic::getWidgetDevCapSettings(&userSettings); - RUNNER_ASSERT(UserSettingsAgreed(&permissionsL, &userSettings)); -} - -TESTSUITE06(33){ - CLEANENV; - //test resource setting PERMIT - std::string res("res27"); - SettingsLogic::setDevCapSetting(res, Preference::PREFERENCE_PERMIT); - std::map resourceSettings; - SettingsLogic::getDevCapSettings(&resourceSettings); - - RUNNER_ASSERT( - ResourceSettingEqual(&resourceSettings, - res, - Preference::PREFERENCE_PERMIT)); -} - -TESTSUITE06(34){ - CLEANENV; - //test resource setting DENY - std::string res("res28"); - SettingsLogic::setDevCapSetting(res, Preference::PREFERENCE_DENY); - std::map resourceSettings; - SettingsLogic::getDevCapSettings(&resourceSettings); - - RUNNER_ASSERT( - ResourceSettingEqual(&resourceSettings, - res, - Preference::PREFERENCE_DENY)); -} - -TESTSUITE06(35){ - CLEANENV; - //test resource setting Preference::PREFERENCE_DEFAULT - - std::string res("res29"); - SettingsLogic::setDevCapSetting(res, Preference::PREFERENCE_DEFAULT); - std::map resourceSettings; - SettingsLogic::getDevCapSettings(&resourceSettings); - - RUNNER_ASSERT( - ResourceSettingEqual( - &resourceSettings, - res, - Preference::PREFERENCE_DEFAULT)); -} - -TESTSUITE06(36){ - CLEANENV; - //multi set for Resource settings - - std::string resa("res30a"); - std::string resb("res30b"); - - std::list< std::pair >* resourcesL = - new std::list< std::pair >(); - - resourcesL->push_back(make_pair(&resa, Preference::PREFERENCE_DENY)); - resourcesL->push_back(make_pair(&resb, Preference::PREFERENCE_PERMIT)); - - SettingsLogic::setAllDevCapSettings (*resourcesL); - - std::map resourceSettings; - SettingsLogic::getDevCapSettings(&resourceSettings); - RUNNER_ASSERT(ResourceSettingsAgreed(resourcesL, &resourceSettings)); - delete resourcesL; -} - - -//void AceDAOTester::test31() -//{ -// // session has changed (PERMIT). -// //What is the verdict now? -// -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS31"); -// std::string tmpValue("Buu31"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_PERMIT; -// Validity val = Validity::SESSION; -// pip.setSessionId("aaa"); -// -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdictA = -// VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultA = VSPAssertEqual(verdictA, Verdict::VERDICT_PERMIT); -// handleResult(resultA, "Verdict session test 31 session a"); -// -// pip.setSessionId("bbb"); -// session = getSession(); -// Verdict verdictB = -// VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultB = VSPAssertEqual(verdictB, Verdict::VERDICT_UNKNOWN); -// handleResult(resultB, "Verdict session test 31 session b"); -//} - - -//void AceDAOTester::test32() -//{ -// //session has changed (DENY). -// //what is the verdict? -// -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS32"); -// std::string tmpValue("Buu32"); -// BaseAttributePtr atr( -// new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_DENY; -// Validity val = Validity::SESSION; -// pip.setSessionId("aaa"); -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdictA = -// VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultA = VSPAssertEqual(verdictA, Verdict::VERDICT_DENY); -// handleResult(resultA, "Verdict session test 32 session a"); -// -// pip.setSessionId("ccc"); -// -// session = getSession(); -// Verdict verdictB = -// VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultB = VSPAssertEqual(verdictB, Verdict::VERDICT_UNKNOWN); -// handleResult(resultB, "Verdict session test 32 session b"); -//} - -//void AceDAOTester::test33(){ -// -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS33"); -// std::string tmpValue("Buu33"); -// BaseAttributePtr atr(new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_INAPPLICABLE; -// Validity val = Validity::SESSION; -// pip.setSessionId("aaa"); -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdictA = VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultA = VSPAssertEqual(verdictA, Verdict::VERDICT_INAPPLICABLE); -// handleResult(resultA, "Verdict session test 33 session a"); -// -// pip.setSessionId("bbb"); -// -// session = getSession(); -// Verdict verdictB = VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultB = VSPAssertEqual(verdictB, Verdict::VERDICT_UNKNOWN); -// handleResult(resultB, "Verdict session test 33 session b"); -//} - -//void AceDAOTester::test34(){ //session has changed (UNDETERMINED). -////what is the verdict? -// -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS34"); -// std::string tmpValue("Buu34"); -// BaseAttributePtr atr(new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_UNDETERMINED; -// Validity val = Validity::SESSION; -// pip.setSessionId("aaa"); -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdictA = VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultA = VSPAssertEqual(verdictA, Verdict::VERDICT_UNKNOWN); -// handleResult(resultA, "Verdict session test 34 session a"); -// -// pip.setSessionId("bbb"); -// -// session = getSession(); -// Verdict verdictB = VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultB = VSPAssertEqual(verdictB, Verdict::VERDICT_UNKNOWN); -// handleResult(resultB, "Verdict session test 34 session b"); -//} - -//void AceDAOTester::test35(){ //session has changed(UNKNOWN), -////what is the verdict? -// -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS35"); -// std::string tmpValue("Buu35"); -// BaseAttributePtr atr(new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_UNKNOWN; -// Validity val = Validity::SESSION; -// pip.setSessionId("aaa"); -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdictA = VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultA = VSPAssertEqual(verdictA, Verdict::VERDICT_UNKNOWN); -// handleResult(resultA, "Verdict session test 35 session a"); -// pip.setSessionId("bbb"); -// -// session = getSession(); -// Verdict verdictB = VerdictLogic::findVerdict(request, session,attributeSet); -// bool resultB = VSPAssertEqual(verdictB, Verdict::VERDICT_UNKNOWN); -// handleResult(resultB, "Verdict session test 35 session b"); -//} - -//void AceDAOTester::test36(){ //changed verdict in the same session -// -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// std::string tmp("atrS36"); -// std::string tmpValue("Buu36"); -// BaseAttributePtr atr(new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// Verdict ver = Verdict::VERDICT_DENY; -// Validity val = Validity::SESSION; -// pip.setSessionId("aaa"); -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdictA = VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultA = VSPAssertEqual(verdictA ,Verdict::VERDICT_DENY); -// handleResult(resultA, "Verdict session test 36 session a"); -// -// ver = Verdict::VERDICT_PERMIT; -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdictB = VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultB = VSPAssertEqual(verdictB ,Verdict::VERDICT_PERMIT); -// handleResult(resultB, "Verdict session test 36 session b"); -//} -// -///* User settings crash tests */ -// -// -//void AceDAOTester::test37(){ //empty attribute and verdict permit always -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// -// Verdict ver = Verdict::VERDICT_PERMIT; -// Validity val = Validity::ALWAYS; -// -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict,Verdict::VERDICT_PERMIT); -// handleResult(result, "find Verdict empty attribute set test 37 "); -//} -// -//void AceDAOTester::test38(){ //empty attribute and verdict deny always -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// -// Verdict ver = Verdict::VERDICT_DENY; -// Validity val = Validity::ALWAYS; -// -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict,Verdict::VERDICT_DENY); -// handleResult(result, "find Verdict empty attribute set test 38 "); -//} -// -//void AceDAOTester::test39(){ -// -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// -// Verdict ver = Verdict::VERDICT_INAPPLICABLE; -// Validity val = Validity::ALWAYS; -// -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict,Verdict::VERDICT_INAPPLICABLE); -// handleResult(result, "find Verdict empty attribute set test 39 "); -//} -// -//void AceDAOTester::test40(){ //empty attribute and verdict unknown -// Request request("subject", "resource"); -// AttributeSet attributeSet; -// -// Verdict ver = Verdict::VERDICT_UNKNOWN; -// Validity val = Validity::ALWAYS; -// -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict,Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict empty attribute set test 40 "); -//} -// -//void AceDAOTester::test41() -//{ -// //empty string as subject and resource, -// //without attributes and verdit DENY Validity::ALWAYS -// Request request("", ""); -// //TODO is it OK to store Verdict::VERDICT for empty request? -// AttributeSet attributeSet; -// -// Verdict ver = Verdict::VERDICT_DENY; -// Validity val = Validity::ALWAYS; -// -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict,Verdict::VERDICT_DENY); -// //bool result = VSPAssertEqual(verdict,Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict empty request empty " -// "attribute set test 41 "); -//} -// -//void AceDAOTester::test42(){ -// //empty string as subject and resource, without attributes -// //and verdict is PERMIT Validity::ALWAYS -// Request request("", ""); -// -// AttributeSet attributeSet; -// std::string tmp("atrS42"); -// std::string tmpValue("Buu342"); -// BaseAttributePtr atr(new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// -// Verdict ver = Verdict::VERDICT_PERMIT; -// Validity val = Validity::ALWAYS; -// -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict,Verdict::VERDICT_PERMIT); -// handleResult(result, "find Verdict empty request test 42 "); -//} -// -//void AceDAOTester::test43(){ -// //TODO I have changed it! verdict -// //has changed and stored in DB. does current verdict is the last one? -// -// Request request("ac", "ca"); -// AttributeSet attributeSet; -// -// Verdict ver = Verdict::VERDICT_DENY; -// Verdict verp = Verdict::VERDICT_PERMIT; -// Validity val = Validity::ALWAYS; -// -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// VerdictLogic::addVerdict(request, session, attributeSet, verp, val); -// -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict,Verdict::VERDICT_PERMIT); -// handleResult(result, "find Verdict empty request empty " -// "attribute set test 43 "); -//} -// -//void AceDAOTester::test44(){ -// //empty subject and resource name - get Atributes list -// Request request("",""); -// -// AttributeSet attributeSet; -// std::string tmp("atrS44"); -// std::string tmpValue("Buu44"); -// BaseAttributePtr atr(new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// -// Verdict ver = Verdict::VERDICT_PERMIT; -// Validity val = Validity::ALWAYS; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// AttributeSet attributeS; -// AceDAO::getAttributes(&attributeS); -// -// bool result = false; -// -// result = AttributeEqual(attributeSet,attributeS); -// -// handleResult(!result,"find Attributes empty request test 44"); -//} -// -//void AceDAOTester::test45(){ -// //empty subject and resource name - what is the verdict? - is it OK?? -// Request request("", ""); -// AttributeSet attributeSet; -// std::string tmp("atrS15"); -// std::string tmpValue("Buu15"); -// BaseAttributePtr atr(new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// -// Verdict ver = Verdict::VERDICT_PERMIT; -// Validity val = Validity::ALWAYS; -// std::string session = getSession(); -// VerdictLogic::addVerdict(request, session, attributeSet, ver, val); -// -// VerdictLogic::removeVerdict(request, attributeSet); -// -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict,Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 45"); -//} -// -//void AceDAOTester::test46(){ -// // TODO is it ok that for empty subject and resource name -// // the verdict is not stored -// Request requestemp("", ""); -// Request request("aa","bb"); -// -// AttributeSet attributeSet; -// std::string tmp("atrS46"); -// std::string tmpValue("Buu146"); -// BaseAttributePtr atr(new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// -// Verdict verAdd = Verdict::VERDICT_PERMIT; -// Validity val = Validity::ALWAYS; -// std::string session = getSession(); -// VerdictLogic::addVerdict(requestemp, session, attributeSet, verAdd, val); -// VerdictLogic::addVerdict(request, session, attributeSet, verAdd, val); -// -// VerdictLogic::removeVerdict(requestemp, attributeSet); -// -// Verdict verdictA = VerdictLogic::findVerdict(requestemp, session, attributeSet); -// bool resultA = VSPAssertEqual(verdictA,Verdict::VERDICT_UNKNOWN); -// handleResult(resultA,"find Verdict test 46 A "); -// -// Verdict verdictB = VerdictLogic::findVerdict(request, session, attributeSet); -// bool resultB = VSPAssertEqual(verdictB, Verdict::VERDICT_PERMIT); -// handleResult(resultB,"find Verdict test 46 B "); -// -//} - -TESTSUITE06(53){ - CLEANENV; - //Empty resource name - std::string res(""); - SettingsLogic::setDevCapSetting(res, Preference::PREFERENCE_PERMIT); - std::map resourceSettings; - SettingsLogic::getDevCapSettings(&resourceSettings); - - RUNNER_ASSERT( - ResourceSettingEqual( - &resourceSettings, - res, - Preference::PREFERENCE_PERMIT)); -} - -//void AceDAOTester::test48(){ -// SettingsLogic::setResourceSetting(NULL, PERMIT); -// std::map* resourceSettings = -// SettingsLogic::getResourceSettings(); -// -// bool result = ResourceSettingEqual(resourceSettings, NULL,PERMIT ); -// handleResult(result, "get Resource Settings empty resource test 48"); -// printf("get Resource Settings empty resource test 48 -----> " -// "Segmentation fault\n"); -//} - -TESTSUITE06(55){ - CLEANENV; - //resource settings list with empty elemen - - std::string resb(""); - - std::list< std::pair > *resourcesL = new - std::list< std::pair >(); - - resourcesL->push_back(make_pair(&resb, Preference::PREFERENCE_PERMIT)); - - SettingsLogic::setAllDevCapSettings (*resourcesL); - - std::map resourceSettings; - SettingsLogic::getDevCapSettings(&resourceSettings); - RUNNER_ASSERT(ResourceSettingsEqual(resourcesL, &resourceSettings)); - delete resourcesL; -} - -TESTSUITE06(56){ - CLEANENV; - //user settings with empty subject and resource - //if resource or subject name is empty, values are not saved in DB - std::string resb("fake-resource"); - WidgetHandle subb = 0; - - std::list permissionsL; - - permissionsL.push_back(PermissionTriple(subb, resb, Preference::PREFERENCE_PERMIT)); - - SettingsLogic::setWidgetDevCapSettings(permissionsL); - - std::list userSettings; - SettingsLogic::getWidgetDevCapSettings(&userSettings); - RUNNER_ASSERT(UserSettingsAgreed(&permissionsL, &userSettings)); -} - -TESTSUITE06(57){ - CLEANENV; - //user setting equal - // settings with at least one empty value is not set - std::string res(""); - WidgetHandle sub = 0; - - SettingsLogic::setWidgetDevCapSetting(res, sub, Preference::PREFERENCE_PERMIT); - std::list userSettings; - SettingsLogic::getWidgetDevCapSettings(&userSettings); - RUNNER_ASSERT( - UserSettingNotStored( - &userSettings, - res, - sub, - Preference::PREFERENCE_PERMIT)); -} - -TESTSUITE06(58){ - CLEANENV; - //user settings empty values and Default access - - std::string res(""); - WidgetHandle sub = 0; - - SettingsLogic::setWidgetDevCapSetting(res, sub, Preference::PREFERENCE_DEFAULT); - std::list userSettings; - SettingsLogic::getWidgetDevCapSettings(&userSettings); - RUNNER_ASSERT( - UserSettingNotStored( - &userSettings, - res, - sub, - Preference::PREFERENCE_DEFAULT)); -} - -//void AceDAOTester::test53(){ -// Request request("1 OR sv.verdict=1 --", "r53"); -// AttributeSet attributeSet; -// std::string tmp("atrS53"); -// std::string tmpValue("Buu15"); -// BaseAttributePtr atr(new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// -//// Verdict ver = Verdict::VERDICT_PERMIT; -//// Validity val = Validity::ALWAYS; -// -// std::string session = getSession(); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 53 sql injection"); -//} - -//void AceDAOTester::test54() -//{ -// Request request("1' OR sv.verdict=1 --", "r53"); -// AttributeSet attributeSet; -// std::string tmp("atrS54"); -// std::string tmpValue("Buu15"); -// BaseAttributePtr atr(new Attribute(&tmp, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&tmpValue); -// attributeSet.insert(atr); -// -// std::string session = getSession(); -// Verdict verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "find Verdict test 54 sql injection"); -//} -// -//void AceDAOTester::test55() -//{ -// Request request("s55","r55"); -// AttributeSet attributeSet; -// std::string session = getSession(); -// Verdict verdict = Verdict::VERDICT_PERMIT; -// Validity validity = Validity::ALWAYS; -// -// VerdictLogic::addVerdict(request, session, attributeSet, verdict, validity); -// -// verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_PERMIT); -// handleResult(result, "Test 55a - clean database"); -// -// SettingsLogic::setWidgetDevCapSetting(request.getResourceId(), -// request.getSubjectId(), -// Preference::PREFERENCE_DENY); -// -// Preference preference = SettingsLogic::findGlobalUserSettings(request); -// handleResult(preference == Preference::PREFERENCE_DENY, "Test 55b - clean database"); -// -// AceDAO::resetDatabase(); -// -// verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "Test 55c - clean database"); -// -// preference = SettingsLogic::findGlobalUserSettings(request); -// handleResult(preference == Preference::PREFERENCE_DEFAULT, -// "Test 55d - clean database"); -//} -// -//void AceDAOTester::test56(){ -// Request request("s56","r56"); -// AttributeSet attributeSet; -// std::string session = getSession(); -// Verdict verdict = Verdict::VERDICT_PERMIT; -// Validity validity = Validity::ALWAYS; -// -// std::string aName("atrS15"); -// std::string aValue1("a;"); -// std::string aValue2("b"); -// BaseAttributePtr atr(new Attribute(&aName, Attribute::Match::Equal, Attribute::Type::Subject)); -// DPL::StaticPointerCast(atr)->addValue(&aValue1); -// DPL::StaticPointerCast(atr)->addValue(&aValue2); -// attributeSet.insert(atr); -// -// VerdictLogic::addVerdict(request, session, attributeSet, verdict, validity); -// -// attributeSet.clear(); -// BaseAttributePtr atr1(new Attribute(&aName, Attribute::Match::Equal, Attribute::Type::Subject)); -// aValue1 = "a"; -// aValue2 = ";b"; -// DPL::StaticPointerCast(atr1)->addValue(&aValue1); -// DPL::StaticPointerCast(atr1)->addValue(&aValue2); -// attributeSet.insert(atr1); -// -// verdict = VerdictLogic::findVerdict(request, session, attributeSet); -// bool result = VSPAssertEqual(verdict, Verdict::VERDICT_UNKNOWN); -// handleResult(result, "Test 56 - attribute hash calculation check"); -//} - - -//BaseAttributePtr AceDAOTester::constructAttribute( -// const char * name, -// const char * value, -// Attribute::Match match, -// Attribute::Type type) -//{ -// std::string tmp(name); -// std::string tmpValue(value); -// BaseAttributePtr attr(new Attribute(&tmp, match, type)); -// DPL::StaticPointerCast(attr)->addValue(&tmpValue); -// return attr; -//} - diff --git a/tests/ace/TestSuite07.cpp b/tests/ace/TestSuite07.cpp deleted file mode 100644 index b276a50..0000000 --- a/tests/ace/TestSuite07.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file TestSuite07.cpp - * @author unknown - * @version 1.0 - * @brief Test cases for ConfigurationManager - */ - - -#include -#include - -#include -#include - -#include -#include - -#include - -#define TESTSUITE07(n,path) \ -RUNNER_TEST(ts07_configuration_mng_ ## n){ \ - ConfigurationManagerTester cm; \ - cm.setUp(); \ - cm.parseTest(path); - -#define TESTSUITEEND \ - cm.cleanUp(); \ -} - -class ConfigurationManagerTester : public ConfigurationManager { -public: - int parseTest(const std::string &file) { - return parse(file); - } - - const std::string& getConfigFileTest() const { - return getConfigFile(); - } - - void prepareDir(std::string & path); - void cleanUp(); - void setUp(); - bool assertPolicyNOTinAList(const char *) const; - bool assertIsCurrentPolicy(const char * policy); - bool assertEqual(const std::string& original, const std::string & intended); - bool assertFileExists(const char * policyFile) const; - bool assertFileDoesntExist(const char * policyFile) const; - bool assertEqual(const int original,const int intended) const; - bool assertPolicyInAList(const char *)const; - - ConfigurationManagerTester() { } -}; - -TESTSUITE07(01,CONFIGURATION_MGR_TEST_CONFIG) - RUNNER_ASSERT(cm.assertIsCurrentPolicy("pms_general-test.xml") && cm.assertPolicyInAList("pms_general-test.xml")); -TESTSUITEEND - -TESTSUITE07(02,CONFIGURATION_MGR_TEST_CONFIG) - RUNNER_ASSERT(cm.assertEqual(cm.getStoragePath(), - std::string(CONFIGURATION_MGR_TEST_POLICY_STORAGE))); -TESTSUITEEND - -TESTSUITE07(03,CONFIGURATION_MGR_TEST_CONFIG) - LogInfo("Full path "<::const_iterator it = getPolicyFiles().begin(); it!=getPolicyFiles().end(); ++it){ - if( *it == expected ){ - found = true; - break; - } - } - - LogDebug("assert Policy in a list result: "<d_name); - if( fileName == "pms_general-test.xml" || fileName == "bondixml.dtd" || - fileName == "." || fileName ==".." ){ - continue; - } - std::string fullPath(CONFIGURATION_MGR_TEST_POLICY_STORAGE"/"); - fullPath.append(dirp->d_name); - if (removePolicyFile(fullPath) == CM_REMOVE_ERROR){ - LogError("Cannot clean up. Exiting"); - break; - }; - } - //Restore the backup of config file - system("cp "CONFIGURATION_MGR_TEST_PATH"backup.xml "CONFIGURATION_MGR_TEST_CONFIG); -} - -void ConfigurationManagerTester::setUp(){ - //Create backup of config file - system("cp "CONFIGURATION_MGR_TEST_CONFIG" "CONFIGURATION_MGR_TEST_PATH"backup.xml"); -} diff --git a/tests/ace/ace_tests.cpp b/tests/ace/ace_tests.cpp deleted file mode 100644 index 8202ac0..0000000 --- a/tests/ace/ace_tests.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file main.cpp - * @author Bartlomiej Grzelewski - * @version 1.0 - * @brief This file is the implementation file of main - */ -#include - -#include -#include - -#include - -#include - -#include "Interfaces.h" -#include "PEPSingleton.h" - - -using namespace LoopControl; - -class UnitTestThread -{ -public: - UnitTestThread() - { - // Attach databases - AceDB::AceDAO::attachToThread(); - } - - ~UnitTestThread() - { - // Detach databases - AceDB::AceDAO::detachFromThread(); - } -}; - -int main (int argc, char *argv[]) -{ - init_loop(argc, argv); - - LogInfo("Initializing PEPSingleton."); - - UnitTestThread attacher; - - PEPSingleton::Instance().initialize( - new WebRuntimeImp(), - new ResourceInformationImp(), - new OperationSystemImp()); - - LogInfo("Starting tests."); - - int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); - - PEPSingleton::Instance().terminate(); - - quit_loop(); - return status; -} - diff --git a/tests/ace/loop_control.cpp b/tests/ace/loop_control.cpp deleted file mode 100644 index f4cfecf..0000000 --- a/tests/ace/loop_control.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file loop_control.cpp - * @author Jaroslaw Osmanski (j.osmanski@samsung.com) - * @version 1.0 - * @brief This is implementation of EFL version of loop control - */ - -#include - -#include - -#include -#include - -#include - -namespace LoopControl -{ -void init_loop(int argc, char *argv[]) -{ - (void)argc; - (void)argv; - g_type_init(); - g_thread_init(NULL); - - LogInfo("Starting"); - elm_init(argc, argv); -} - -void wait_for_wrt_init() -{ - ecore_main_loop_begin(); -} - -void finish_wait_for_wrt_init() -{ - ecore_main_loop_quit(); -} - -void quit_loop() -{ - elm_shutdown(); -} - -void wrt_start_loop() -{ - ecore_main_loop_begin(); -} - -void wrt_end_loop() -{ - ecore_main_loop_quit(); -} - -void *abstract_window() -{ - return elm_win_add(NULL, "hello", ELM_WIN_BASIC); -} - -}//end of LoopControl namespace diff --git a/tests/ace/loop_control.h b/tests/ace/loop_control.h deleted file mode 100644 index 30aa6e8..0000000 --- a/tests/ace/loop_control.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file loop_control.cpp - * @author Jaroslaw Osmanski (j.osmanski@samsung.com) - * @version 1.0 - * @brief This file is the definitions of loop controlling utilities - */ - - -#ifndef LOOP_CONTROL_H_ -#define LOOP_CONTROL_H_ - -namespace LoopControl -{ - -void init_loop(int argc, char *argv[]); -void wait_for_wrt_init(); -void finish_wait_for_wrt_init(); -void quit_loop(); - -void wrt_start_loop(); -void wrt_end_loop(); - -void *abstract_window(); - -} - -#endif /* LOOP_CONTROL_H_ */ diff --git a/tests/ace/test-configuration/CMTest/CMakeLists.txt b/tests/ace/test-configuration/CMTest/CMakeLists.txt deleted file mode 100644 index d186839..0000000 --- a/tests/ace/test-configuration/CMTest/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/CMTest/pms_config.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/CMTest/pms_general-test.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/CMTest/policyTest1.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/CMTest/policyTest2.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/CMTest/policyTest3.xml - DESTINATION /usr/etc/ace/CMTest - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE - ) - -ADD_SUBDIRECTORY(active) - diff --git a/tests/ace/test-configuration/CMTest/active/CMakeLists.txt b/tests/ace/test-configuration/CMTest/active/CMakeLists.txt deleted file mode 100644 index baefacf..0000000 --- a/tests/ace/test-configuration/CMTest/active/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/CMTest/active/pms_general-test.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/CMTest/active/bondixml.dtd - DESTINATION /usr/etc/ace/CMTest/active - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE - ) - diff --git a/tests/ace/test-configuration/CMTest/active/bondixml.dtd b/tests/ace/test-configuration/CMTest/active/bondixml.dtd deleted file mode 100644 index 42a6c7b..0000000 --- a/tests/ace/test-configuration/CMTest/active/bondixml.dtd +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/ace/test-configuration/CMTest/active/pms_general-test.xml b/tests/ace/test-configuration/CMTest/active/pms_general-test.xml deleted file mode 100644 index ac55f33..0000000 --- a/tests/ace/test-configuration/CMTest/active/pms_general-test.xml +++ /dev/null @@ -1,2510 +0,0 @@ - - - - - - - - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - asdfkjlhxvczxnbcvnjahfjhsdfklahfdas - - - -

PValue

QValue Gvalue laj? -
- - - modulus - - - exponent - - -
- - Subject name - SKI - -
-
- - - - - - - - - subject - - - - - - - - - - - - - - - - resource - - - - - - - - - - - - - - - resource - - - - - - - - - - subject3 - - - - - - - - - - - resource2 - - - - - - - - - resource2 - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - subject5 - - - - - - - resource5 - - - - - - - - - - resource6 - - - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - - s8a - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8b - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8c - - - - - - r8 - - - - - - - - - - - - - - s9a - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9b - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9c - - - - - - r9 - - - - - - - - - r9 - - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9d - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9e - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9f - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9g - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9h - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s10a - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10b - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10c - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - - - - - - - s13 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s14 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s16 - - - - - - - - - - - - - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - subject5 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s19.1 - - - - - - - - resource4 - - - - - - - - - - s19.2 - - - - - - - - resource4 - - - - - - - - - - - - - s20.1 - - - - - - - - resource4 - - - - - - - - - - s20.2 - - - - - - - - resource4 - - - - - - - - - - - - - - s21 - - - - - - - - - - - - - - - - - - s23 - - - - - - - - - - - - - - - - - - - - s24 - - - - - - - - - - - - - - - - - - s25.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s26.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.1 - - - - - - - - - - - - - - - - - - - - - - - - - s27.2 - - - - - - - - - - - - - - - - - - - - - - - - - s27.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - s28 - - - - - - - - - - - - - - - - - - - - - - - - - - s29 - - - - - - - - - - - - - - - - - - - - - - - - - s30.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s33.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s34.1 - - - - - - - - - - - - - - - - - - - - - - - - s34.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.2 - - - - - - - - - - - - - - - - - - - - - - - - org.tizen.widget.analogclock - - - - - - - - - - - - - - - - - s36 - - - - - - - - - - - - - - - - - - - - - - - s37 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s38 - - - - - - device:pim.contacts.read - - - - - - - - - s38.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - s39 - - - - - - device:pim.contacts.read - - - - - - - - - s39.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - - - s40 - - - - - - r40 - - - - - - - r40 - - - - - - - - - - - - s41 - - - - - - r41 - - - - - r41.2 - - - - - - - - - - - - - s42.1 - - - - - - r42.1 - - - - - r42.1 - - - - - - - - - - - - - s42.2 - - - - - - r42.2 - - - - - r42.2 - - - - - - - - - - - - s43.1 - - - - - - r43.1 - - - - - - - r43.1 - - - - - - - - - - - s43.2 - - - - - - r43.2 - - - - - - - r43.2 - - - - - - - - - - - s44.1 - - - - - - r44.1 - - - - - - - r44.1 - - - - - - - - - - - s44.2 - - - - - - r44.2 - - - - - - - r44.2 - - - - - - - - - - - - - s45.1 - - - - - - r45.1 - - - - - r45.1 - - - - - - - - - - - - s45.2 - - - - - - r45.2 - - - - - r45.2 - - - - - - - - - - - - - s46.1 - - - - - - r46.1 - - - - - r46.1 - - - - - - - - - - - - s46.2 - - - - - - r46.2 - - - - - r46.2 - - - - - - - - - - - - - s47.1 - - - - - - r47.1 - - - - - r47.1 - - - - - - - - - - - s47.2 - - - - - - r47.2 - - - - - r47.2 - - - - - - - - - - - -s48 - - - - - - - - - - - - - - - - -
diff --git a/tests/ace/test-configuration/CMTest/pms_config.xml b/tests/ace/test-configuration/CMTest/pms_config.xml deleted file mode 100644 index fc9b0dc..0000000 --- a/tests/ace/test-configuration/CMTest/pms_config.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - /usr/etc/ace/CMTest/active - - pms_general-test.xml - - - - diff --git a/tests/ace/test-configuration/CMTest/pms_general-test.xml b/tests/ace/test-configuration/CMTest/pms_general-test.xml deleted file mode 100644 index ac55f33..0000000 --- a/tests/ace/test-configuration/CMTest/pms_general-test.xml +++ /dev/null @@ -1,2510 +0,0 @@ - - - - - - - - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - asdfkjlhxvczxnbcvnjahfjhsdfklahfdas - - - -

PValue

QValue Gvalue laj? -
- - - modulus - - - exponent - - -
- - Subject name - SKI - -
-
- - - - - - - - - subject - - - - - - - - - - - - - - - - resource - - - - - - - - - - - - - - - resource - - - - - - - - - - subject3 - - - - - - - - - - - resource2 - - - - - - - - - resource2 - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - subject5 - - - - - - - resource5 - - - - - - - - - - resource6 - - - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - - s8a - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8b - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8c - - - - - - r8 - - - - - - - - - - - - - - s9a - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9b - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9c - - - - - - r9 - - - - - - - - - r9 - - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9d - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9e - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9f - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9g - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9h - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s10a - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10b - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10c - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - - - - - - - s13 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s14 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s16 - - - - - - - - - - - - - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - subject5 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s19.1 - - - - - - - - resource4 - - - - - - - - - - s19.2 - - - - - - - - resource4 - - - - - - - - - - - - - s20.1 - - - - - - - - resource4 - - - - - - - - - - s20.2 - - - - - - - - resource4 - - - - - - - - - - - - - - s21 - - - - - - - - - - - - - - - - - - s23 - - - - - - - - - - - - - - - - - - - - s24 - - - - - - - - - - - - - - - - - - s25.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s26.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.1 - - - - - - - - - - - - - - - - - - - - - - - - - s27.2 - - - - - - - - - - - - - - - - - - - - - - - - - s27.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - s28 - - - - - - - - - - - - - - - - - - - - - - - - - - s29 - - - - - - - - - - - - - - - - - - - - - - - - - s30.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s33.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s34.1 - - - - - - - - - - - - - - - - - - - - - - - - s34.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.2 - - - - - - - - - - - - - - - - - - - - - - - - org.tizen.widget.analogclock - - - - - - - - - - - - - - - - - s36 - - - - - - - - - - - - - - - - - - - - - - - s37 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s38 - - - - - - device:pim.contacts.read - - - - - - - - - s38.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - s39 - - - - - - device:pim.contacts.read - - - - - - - - - s39.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - - - s40 - - - - - - r40 - - - - - - - r40 - - - - - - - - - - - - s41 - - - - - - r41 - - - - - r41.2 - - - - - - - - - - - - - s42.1 - - - - - - r42.1 - - - - - r42.1 - - - - - - - - - - - - - s42.2 - - - - - - r42.2 - - - - - r42.2 - - - - - - - - - - - - s43.1 - - - - - - r43.1 - - - - - - - r43.1 - - - - - - - - - - - s43.2 - - - - - - r43.2 - - - - - - - r43.2 - - - - - - - - - - - s44.1 - - - - - - r44.1 - - - - - - - r44.1 - - - - - - - - - - - s44.2 - - - - - - r44.2 - - - - - - - r44.2 - - - - - - - - - - - - - s45.1 - - - - - - r45.1 - - - - - r45.1 - - - - - - - - - - - - s45.2 - - - - - - r45.2 - - - - - r45.2 - - - - - - - - - - - - - s46.1 - - - - - - r46.1 - - - - - r46.1 - - - - - - - - - - - - s46.2 - - - - - - r46.2 - - - - - r46.2 - - - - - - - - - - - - - s47.1 - - - - - - r47.1 - - - - - r47.1 - - - - - - - - - - - s47.2 - - - - - - r47.2 - - - - - r47.2 - - - - - - - - - - - -s48 - - - - - - - - - - - - - - - - -
diff --git a/tests/ace/test-configuration/CMTest/policyTest1.xml b/tests/ace/test-configuration/CMTest/policyTest1.xml deleted file mode 100644 index ac55f33..0000000 --- a/tests/ace/test-configuration/CMTest/policyTest1.xml +++ /dev/null @@ -1,2510 +0,0 @@ - - - - - - - - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - asdfkjlhxvczxnbcvnjahfjhsdfklahfdas - - - -

PValue

QValue Gvalue laj? -
- - - modulus - - - exponent - - -
- - Subject name - SKI - -
-
- - - - - - - - - subject - - - - - - - - - - - - - - - - resource - - - - - - - - - - - - - - - resource - - - - - - - - - - subject3 - - - - - - - - - - - resource2 - - - - - - - - - resource2 - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - subject5 - - - - - - - resource5 - - - - - - - - - - resource6 - - - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - - s8a - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8b - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8c - - - - - - r8 - - - - - - - - - - - - - - s9a - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9b - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9c - - - - - - r9 - - - - - - - - - r9 - - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9d - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9e - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9f - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9g - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9h - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s10a - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10b - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10c - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - - - - - - - s13 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s14 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s16 - - - - - - - - - - - - - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - subject5 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s19.1 - - - - - - - - resource4 - - - - - - - - - - s19.2 - - - - - - - - resource4 - - - - - - - - - - - - - s20.1 - - - - - - - - resource4 - - - - - - - - - - s20.2 - - - - - - - - resource4 - - - - - - - - - - - - - - s21 - - - - - - - - - - - - - - - - - - s23 - - - - - - - - - - - - - - - - - - - - s24 - - - - - - - - - - - - - - - - - - s25.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s26.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.1 - - - - - - - - - - - - - - - - - - - - - - - - - s27.2 - - - - - - - - - - - - - - - - - - - - - - - - - s27.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - s28 - - - - - - - - - - - - - - - - - - - - - - - - - - s29 - - - - - - - - - - - - - - - - - - - - - - - - - s30.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s33.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s34.1 - - - - - - - - - - - - - - - - - - - - - - - - s34.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.2 - - - - - - - - - - - - - - - - - - - - - - - - org.tizen.widget.analogclock - - - - - - - - - - - - - - - - - s36 - - - - - - - - - - - - - - - - - - - - - - - s37 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s38 - - - - - - device:pim.contacts.read - - - - - - - - - s38.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - s39 - - - - - - device:pim.contacts.read - - - - - - - - - s39.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - - - s40 - - - - - - r40 - - - - - - - r40 - - - - - - - - - - - - s41 - - - - - - r41 - - - - - r41.2 - - - - - - - - - - - - - s42.1 - - - - - - r42.1 - - - - - r42.1 - - - - - - - - - - - - - s42.2 - - - - - - r42.2 - - - - - r42.2 - - - - - - - - - - - - s43.1 - - - - - - r43.1 - - - - - - - r43.1 - - - - - - - - - - - s43.2 - - - - - - r43.2 - - - - - - - r43.2 - - - - - - - - - - - s44.1 - - - - - - r44.1 - - - - - - - r44.1 - - - - - - - - - - - s44.2 - - - - - - r44.2 - - - - - - - r44.2 - - - - - - - - - - - - - s45.1 - - - - - - r45.1 - - - - - r45.1 - - - - - - - - - - - - s45.2 - - - - - - r45.2 - - - - - r45.2 - - - - - - - - - - - - - s46.1 - - - - - - r46.1 - - - - - r46.1 - - - - - - - - - - - - s46.2 - - - - - - r46.2 - - - - - r46.2 - - - - - - - - - - - - - s47.1 - - - - - - r47.1 - - - - - r47.1 - - - - - - - - - - - s47.2 - - - - - - r47.2 - - - - - r47.2 - - - - - - - - - - - -s48 - - - - - - - - - - - - - - - - -
diff --git a/tests/ace/test-configuration/CMTest/policyTest2.xml b/tests/ace/test-configuration/CMTest/policyTest2.xml deleted file mode 100644 index ac55f33..0000000 --- a/tests/ace/test-configuration/CMTest/policyTest2.xml +++ /dev/null @@ -1,2510 +0,0 @@ - - - - - - - - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - asdfkjlhxvczxnbcvnjahfjhsdfklahfdas - - - -

PValue

QValue Gvalue laj? -
- - - modulus - - - exponent - - -
- - Subject name - SKI - -
-
- - - - - - - - - subject - - - - - - - - - - - - - - - - resource - - - - - - - - - - - - - - - resource - - - - - - - - - - subject3 - - - - - - - - - - - resource2 - - - - - - - - - resource2 - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - subject5 - - - - - - - resource5 - - - - - - - - - - resource6 - - - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - - s8a - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8b - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8c - - - - - - r8 - - - - - - - - - - - - - - s9a - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9b - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9c - - - - - - r9 - - - - - - - - - r9 - - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9d - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9e - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9f - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9g - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9h - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s10a - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10b - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10c - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - - - - - - - s13 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s14 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s16 - - - - - - - - - - - - - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - subject5 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s19.1 - - - - - - - - resource4 - - - - - - - - - - s19.2 - - - - - - - - resource4 - - - - - - - - - - - - - s20.1 - - - - - - - - resource4 - - - - - - - - - - s20.2 - - - - - - - - resource4 - - - - - - - - - - - - - - s21 - - - - - - - - - - - - - - - - - - s23 - - - - - - - - - - - - - - - - - - - - s24 - - - - - - - - - - - - - - - - - - s25.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s26.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.1 - - - - - - - - - - - - - - - - - - - - - - - - - s27.2 - - - - - - - - - - - - - - - - - - - - - - - - - s27.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - s28 - - - - - - - - - - - - - - - - - - - - - - - - - - s29 - - - - - - - - - - - - - - - - - - - - - - - - - s30.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s33.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s34.1 - - - - - - - - - - - - - - - - - - - - - - - - s34.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.2 - - - - - - - - - - - - - - - - - - - - - - - - org.tizen.widget.analogclock - - - - - - - - - - - - - - - - - s36 - - - - - - - - - - - - - - - - - - - - - - - s37 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s38 - - - - - - device:pim.contacts.read - - - - - - - - - s38.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - s39 - - - - - - device:pim.contacts.read - - - - - - - - - s39.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - - - s40 - - - - - - r40 - - - - - - - r40 - - - - - - - - - - - - s41 - - - - - - r41 - - - - - r41.2 - - - - - - - - - - - - - s42.1 - - - - - - r42.1 - - - - - r42.1 - - - - - - - - - - - - - s42.2 - - - - - - r42.2 - - - - - r42.2 - - - - - - - - - - - - s43.1 - - - - - - r43.1 - - - - - - - r43.1 - - - - - - - - - - - s43.2 - - - - - - r43.2 - - - - - - - r43.2 - - - - - - - - - - - s44.1 - - - - - - r44.1 - - - - - - - r44.1 - - - - - - - - - - - s44.2 - - - - - - r44.2 - - - - - - - r44.2 - - - - - - - - - - - - - s45.1 - - - - - - r45.1 - - - - - r45.1 - - - - - - - - - - - - s45.2 - - - - - - r45.2 - - - - - r45.2 - - - - - - - - - - - - - s46.1 - - - - - - r46.1 - - - - - r46.1 - - - - - - - - - - - - s46.2 - - - - - - r46.2 - - - - - r46.2 - - - - - - - - - - - - - s47.1 - - - - - - r47.1 - - - - - r47.1 - - - - - - - - - - - s47.2 - - - - - - r47.2 - - - - - r47.2 - - - - - - - - - - - -s48 - - - - - - - - - - - - - - - - -
diff --git a/tests/ace/test-configuration/CMTest/policyTest3.xml b/tests/ace/test-configuration/CMTest/policyTest3.xml deleted file mode 100644 index ac55f33..0000000 --- a/tests/ace/test-configuration/CMTest/policyTest3.xml +++ /dev/null @@ -1,2510 +0,0 @@ - - - - - - - - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - - dGhpcyBpcyBub3QgYSBzaWduYXR1cmUK... - - - asdfkjlhxvczxnbcvnjahfjhsdfklahfdas - - - -

PValue

QValue Gvalue laj? -
- - - modulus - - - exponent - - -
- - Subject name - SKI - -
-
- - - - - - - - - subject - - - - - - - - - - - - - - - - resource - - - - - - - - - - - - - - - resource - - - - - - - - - - subject3 - - - - - - - - - - - resource2 - - - - - - - - - resource2 - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - subject5 - - - - - - - resource5 - - - - - - - - - - resource6 - - - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - - s8a - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8b - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8c - - - - - - r8 - - - - - - - - - - - - - - s9a - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9b - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9c - - - - - - r9 - - - - - - - - - r9 - - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9d - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9e - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9f - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9g - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9h - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s10a - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10b - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10c - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - - - - - - - s13 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s14 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s16 - - - - - - - - - - - - - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - subject5 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s19.1 - - - - - - - - resource4 - - - - - - - - - - s19.2 - - - - - - - - resource4 - - - - - - - - - - - - - s20.1 - - - - - - - - resource4 - - - - - - - - - - s20.2 - - - - - - - - resource4 - - - - - - - - - - - - - - s21 - - - - - - - - - - - - - - - - - - s23 - - - - - - - - - - - - - - - - - - - - s24 - - - - - - - - - - - - - - - - - - s25.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s26.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.1 - - - - - - - - - - - - - - - - - - - - - - - - - s27.2 - - - - - - - - - - - - - - - - - - - - - - - - - s27.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - s28 - - - - - - - - - - - - - - - - - - - - - - - - - - s29 - - - - - - - - - - - - - - - - - - - - - - - - - s30.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s33.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s34.1 - - - - - - - - - - - - - - - - - - - - - - - - s34.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.2 - - - - - - - - - - - - - - - - - - - - - - - - org.tizen.widget.analogclock - - - - - - - - - - - - - - - - - s36 - - - - - - - - - - - - - - - - - - - - - - - s37 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s38 - - - - - - device:pim.contacts.read - - - - - - - - - s38.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - s39 - - - - - - device:pim.contacts.read - - - - - - - - - s39.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - - - s40 - - - - - - r40 - - - - - - - r40 - - - - - - - - - - - - s41 - - - - - - r41 - - - - - r41.2 - - - - - - - - - - - - - s42.1 - - - - - - r42.1 - - - - - r42.1 - - - - - - - - - - - - - s42.2 - - - - - - r42.2 - - - - - r42.2 - - - - - - - - - - - - s43.1 - - - - - - r43.1 - - - - - - - r43.1 - - - - - - - - - - - s43.2 - - - - - - r43.2 - - - - - - - r43.2 - - - - - - - - - - - s44.1 - - - - - - r44.1 - - - - - - - r44.1 - - - - - - - - - - - s44.2 - - - - - - r44.2 - - - - - - - r44.2 - - - - - - - - - - - - - s45.1 - - - - - - r45.1 - - - - - r45.1 - - - - - - - - - - - - s45.2 - - - - - - r45.2 - - - - - r45.2 - - - - - - - - - - - - - s46.1 - - - - - - r46.1 - - - - - r46.1 - - - - - - - - - - - - s46.2 - - - - - - r46.2 - - - - - r46.2 - - - - - - - - - - - - - s47.1 - - - - - - r47.1 - - - - - r47.1 - - - - - - - - - - - s47.2 - - - - - - r47.2 - - - - - r47.2 - - - - - - - - - - - -s48 - - - - - - - - - - - - - - - - -
diff --git a/tests/ace/test-configuration/CMakeLists.txt b/tests/ace/test-configuration/CMakeLists.txt deleted file mode 100644 index 756c13e..0000000 --- a/tests/ace/test-configuration/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/policy-example.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/policy-wac-2.0.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/attr_policy-example.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/policy-example2.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/policy-example3.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/policy_example.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/general-test.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/interceptpolicy.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/policy-test.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/policy-test-gsettings.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/attre_config.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/attr_policy-example1.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/attr_policy-example2.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/attr_policy-example3.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/attr_policy-example4.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/attr_policy-example5.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/attr_policy-example6.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/attr_policy-example7.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/attr_policy-example8.xml - ${PROJECT_SOURCE_DIR}/tests/ace/test-configuration/undefined-test.xml - DESTINATION /usr/etc/ace - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE - ) - -ADD_SUBDIRECTORY(CMTest) diff --git a/tests/ace/test-configuration/attr_policy-example.xml b/tests/ace/test-configuration/attr_policy-example.xml deleted file mode 100644 index 8f0687f..0000000 --- a/tests/ace/test-configuration/attr_policy-example.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - device.simcard - - - - - - - - - - - - - - - file.write - - - - - - - - - - - - - - - - pim.contact - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/attr_policy-example1.xml b/tests/ace/test-configuration/attr_policy-example1.xml deleted file mode 100644 index a4869c5..0000000 --- a/tests/ace/test-configuration/attr_policy-example1.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/attr_policy-example2.xml b/tests/ace/test-configuration/attr_policy-example2.xml deleted file mode 100644 index e7a85be..0000000 --- a/tests/ace/test-configuration/attr_policy-example2.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/attr_policy-example3.xml b/tests/ace/test-configuration/attr_policy-example3.xml deleted file mode 100644 index 4d15108..0000000 --- a/tests/ace/test-configuration/attr_policy-example3.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - subject - - - - - - - - - - - - - - - - resource - - - - - - - - - - - - - - - resource - - - - - - - - - - subject3 - - - - - - - - - - - resource2 - - - - - - - - - resource2 - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - - subject5 - - - - - - - resource5 - - - - - - - - - - resource6 - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/attr_policy-example4.xml b/tests/ace/test-configuration/attr_policy-example4.xml deleted file mode 100644 index f709233..0000000 --- a/tests/ace/test-configuration/attr_policy-example4.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - resource7 - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/attr_policy-example5.xml b/tests/ace/test-configuration/attr_policy-example5.xml deleted file mode 100644 index f9c837e..0000000 --- a/tests/ace/test-configuration/attr_policy-example5.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - device.simcard - - - - - - - device.simcard - - - - - - - device.simcard - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/attr_policy-example6.xml b/tests/ace/test-configuration/attr_policy-example6.xml deleted file mode 100644 index 7a4c709..0000000 --- a/tests/ace/test-configuration/attr_policy-example6.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - device.simcard - - - - - - - device.simcard - - - - - - - device.simcard - - - - - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/attr_policy-example7.xml b/tests/ace/test-configuration/attr_policy-example7.xml deleted file mode 100644 index 15907f9..0000000 --- a/tests/ace/test-configuration/attr_policy-example7.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - device.simcard - - - - - - - - - - - - device.simcard - - - - - - - - - - - device.simcard - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/attr_policy-example8.xml b/tests/ace/test-configuration/attr_policy-example8.xml deleted file mode 100644 index c73be53..0000000 --- a/tests/ace/test-configuration/attr_policy-example8.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/attre_config.xml b/tests/ace/test-configuration/attre_config.xml deleted file mode 100644 index bd52527..0000000 --- a/tests/ace/test-configuration/attre_config.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - false - /usr/etc/ace/ - - attr_policy-example.xml - - - samsung - - - nokia - - - - diff --git a/tests/ace/test-configuration/general-test.xml b/tests/ace/test-configuration/general-test.xml deleted file mode 100644 index c67eaa6..0000000 --- a/tests/ace/test-configuration/general-test.xml +++ /dev/null @@ -1,2621 +0,0 @@ - - - - - - subject - - - - - - - - - - - - - - - - resource - - - - - - - - - - - - - - - resource - - - - - - - - - - subject3 - - - - - - - - - - - resource2 - - - - - - - - - resource2 - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - subject5 - - - - - - - resource5 - - - - - - - - - - resource6 - - - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - - s8a - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8b - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8c - - - - - - r8 - - - - - - - - - - - - - - s9a - - - - - - r9 - - - - - - r9 - - - - - - - - - - s9b - - - - - - r9 - - - - - - r9 - - - - - - - - - - s9c - - - - - - r9 - - - - - - r9 - - - - - - r9 - - - - - - r9 - - - - - - - - - - s9d - - - - - - r9 - - - - - - r9 - - - - - - r9 - - - - - - r9 - - - - - - - - - - s9e - - - - - - r9 - - - - - - r9 - - - - - - - - - - s9f - - - - - - r9 - - - - - - r9 - - - - - - - - - - s9g - - - - - - r9 - - - - - - r9 - - - - - - - - - - s9h - - - - - - r9 - - - - - - r9 - - - - - - - - - - s10a - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10b - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10c - - - - - - r10 - - - - - - r10 - - - - - - - - - - - - - - - - s13 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - - - - - - - - - - - - - - s16 - - - - - - - - - - - - - - - - - - - - - s17a - - - - - - - - resource4 - - - - - - - - - - - s17b - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s19.1 - - - - - - - - resource4 - - - - - - - - - - s19.2 - - - - - - - - resource4 - - - - - - - - - - - - - s20.1 - - - - - - - - resource4 - - - - - - - - - - s20.2 - - - - - - - - resource4 - - - - - - - - - - - - - - s21 - - - - - - - - - - - - - - - - s21a - - - - - - - - - - - - - - - - - s23 - - - - - - - - - - - - - - - - - - - - s24 - - - - - - - - - - - - - - - - - - s25.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.3 - - - - - - - - - - - - - - - - - - - - - - - - - s25.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s26.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.1 - - - - - - - - - - - - - - - - - - - - - - - - - s27.2 - - - - - - - - - - - - - - - - - - - - - - - - - s27.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - s28 - - - - - - - - - - - - - - - - - - - - - - - - - - s29 - - - - - - - - - - - - - - - - - - - - - - - - - s30.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s33.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s34.1 - - - - - - - - - - - - - - - - - - - - - - - - s34.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.2 - - - - - - - - - - - - - - - - - - - - - - - - org.tizen.widget.analogclock - - - - - - - - - - - - - - - - - s36 - - - - - - - - - - - - - - - - - - - - - - - s37 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s38 - - - - - - device:pim.contacts.read - - - - - - - - - s38.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - s39 - - - - - - device:pim.contacts.read - - - - - - - - - s39.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - - - s40 - - - - - - r40 - - - - - - - r40 - - - - - - - - - - - - s41 - - - - - - r41 - - - - - r41.2 - - - - - - - - - - - - - s42.1 - - - - - - r42.1 - - - - - r42.1 - - - - - - - - - - - - - s42.2 - - - - - - r42.2 - - - - - r42.2 - - - - - - - - - - - - s43.1 - - - - - - r43.1 - - - - - - - r43.1 - - - - - - - - - - - s43.2 - - - - - - r43.2 - - - - - - - r43.2 - - - - - - - - - - - s44.1 - - - - - - r44.1 - - - - - - - r44.1 - - - - - - - - - - - s44.2 - - - - - - r44.2 - - - - - - - r44.2 - - - - - - - - - - - - - s45.1 - - - - - - r45.1 - - - - - r45.1 - - - - - - - - - - - - s45.2 - - - - - - r45.2 - - - - - r45.2 - - - - - - - - - - - - - s46.1 - - - - - - r46.1 - - - - - r46.1 - - - - - - - - - - - - s46.2 - - - - - - r46.2 - - - - - r46.2 - - - - - - - - - - - - - s47.1 - - - - - - r47.1 - - - - - r47.1 - - - - - - - - - - - s47.2 - - - - - - r47.2 - - - - - r47.2 - - - - - - - - - - - - s48 - - - - - - - - - - - - - - - - - - - BF00 - - - - - - - - - - - - - - - - - - - - - - - - BF01 - - - - - - - - - - - - - - - - - - - - - - - - - BF02 - - - - - - - - - - - - - - - - - - - - - - - - BF03 - - - - - - - - - - - - - - - - - - - - - - - - - BF04 - - - - - - BFR04 - - - - - BFR04 - - - - - - - - - - - s61a - - - - - - r61a - type - - - - - r61a - - - - - - - - - s61b - - - - - - r61b - type - - - - - r61b - - - - - - - - - - s61c - - - - - - r61c - type - port - - - - - r61c - - - - - - - - - s61d - - - - - - r61d - type - port - - - - - r61d - - - - - - - - - - paramTestSubject - - - - - - messaging - +4409* - - - - - messaging - +4408* - - - - - messaging - +48* - - - - - camera - high - - - - - camera - low - - - - - - - - diff --git a/tests/ace/test-configuration/interceptpolicy.xml b/tests/ace/test-configuration/interceptpolicy.xml deleted file mode 100644 index ab055ce..0000000 --- a/tests/ace/test-configuration/interceptpolicy.xml +++ /dev/null @@ -1,495 +0,0 @@ - - - - - - - Unidentified - - - - - - - - http://jil.org/jil/api/1.1/device - - - getAvailableApplications - - - - - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.update - - - http://jil.org/jil/api/1.1/multimedia.Camera.captureImage - - - http://jil.org/jil/api/1.1/device.Device.launchApplication - - - DeviceStateInfo.requestPositionInfo - - - http://jil.org/jil/api/1.1/messaging.Messaging.sendMessage - - - - - - - http://jil.org/jil/api/1.1.1/pim.PIM.findAddressBookItems - - - http://jil.org/jil/api/1.1.1/pim.PIM.getAddressBookItem - - - http://jil.org/jil/api/1.1.1/pim.PIM.getAddressBookItemsCount - - - - - - - - Device.PositionInfo - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.getAttributeValue - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.getAvailableAttributes - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.setAttributeValue - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.open - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.play - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.pause - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.resume - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.stop - - - AudioPlayer.onStateChange - - - http://jil.org/jil/api/1.1/multimedia.Camera.onCameraCaptured - - - http://jil.org/jil/api/1.1/multimedia.Camera.setWindow - - - Device.PositionInfo - - - Device.DeviceStateInfo - - - DeviceStateInfo.onPositionRetrieved - - - http://jil.org/jil/api/1.1/messaging.Messaging.createMessage - - - Messaging.onMessageSendingFailure - - - Multimedia.getVolume - - - Multimedia.stopAll - - - Multimedia.isAudioPlaying - - - http://jil.org/jil/api/1.1.1/pim.PIM.createAddressBookItem - - - PIM.onAddressBookItemFound - - - - - - http://jil.org/jil/api/1.1/accelerometerinfo - - - http://jil.org/jil/api/1.1/addressbookitem - - - http://jil.org/jil/api/1.1.5/applicationtypes - - - http://jil.org/jil/api/1.1.2/camera - - - http://jil.org/jil/api/1.1/device - - - http://jil.org/jil/api/1.1/devicestateinfo - - - http://jil.org/jil/api/1.1.5/exception - - - http://jil.org/jil/api/1.1.5/exceptiontypes - - - http://jil.org/jil/api/1.1/message - - - http://jil.org/jil/api/1.1/messagetypes - - - http://jil.org/jil/api/1.1/messaging - - - http://jil.org/jil/api/1.1/multimedia - - - http://jil.org/jil/api/1.1.1/pim - - - http://jil.org/jil/api/1.1/positioninfo - - - http://jil.org/jil/api/1.1/widget - - - - - - - - - - - - Identified - - - - - - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.update - - - DeviceStateInfo.requestPositionInfo - - - - - - - http://jil.org/jil/api/1.1/device.Device.launchApplication - - - http://jil.org/jil/api/1.1/multimedia.Camera.captureImage - - - http://jil.org/jil/api/1.1/messaging.Messaging.sendMessage - - - http://jil.org/jil/api/1.1.1/pim.PIM.findAddressBookItems - - - http://jil.org/jil/api/1.1.1/pim.PIM.getAddressBookItem - - - http://jil.org/jil/api/1.1.1/pim.PIM.getAddressBookItemsCount - - - - - - - - http://jil.org/jil/api/1.1/device.Device.getAvailableApplications - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.getAttributeValue - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.getAvailableAttributes - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.setAttributeValue - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.open - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.play - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.pause - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.resume - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.stop - - - AudioPlayer.onStateChange - - - http://jil.org/jil/api/1.1/multimedia.Camera.onCameraCaptured - - - http://jil.org/jil/api/1.1/multimedia.Camera.setWindow - - - Device.PositionInfo - - - Device.DeviceStateInfo - - - DeviceStateInfo.onPositionRetrieved - - - http://jil.org/jil/api/1.1/messaging.Messaging.createMessage - - - Messaging.onMessageSendingFailure - - - Multimedia.getVolume - - - Multimedia.stopAll - - - Multimedia.isAudioPlaying - - - http://jil.org/jil/api/1.1.1/pim.PIM.createAddressBookItem - - - PIM.onAddressBookItemFound - - - - - - http://jil.org/jil/api/1.1/accelerometerinfo - - - http://jil.org/jil/api/1.1/addressbookitem - - - http://jil.org/jil/api/1.1.5/applicationtypes - - - http://jil.org/jil/api/1.1.2/camera - - - http://jil.org/jil/api/1.1/device - - - http://jil.org/jil/api/1.1/devicestateinfo - - - http://jil.org/jil/api/1.1.5/exception - - - http://jil.org/jil/api/1.1.5/exceptiontypes - - - http://jil.org/jil/api/1.1/message - - - http://jil.org/jil/api/1.1/messagetypes - - - http://jil.org/jil/api/1.1/messaging - - - http://jil.org/jil/api/1.1/multimedia - - - http://jil.org/jil/api/1.1.1/pim - - - http://jil.org/jil/api/1.1/positioninfo - - - http://jil.org/jil/api/1.1/widget - - - - - - - - - - - - Operator - - - - - - - - http://jil.org/jil/api/1.1/device.Device.launchApplication - - - DeviceStateInfo.requestPositionInfo - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.update - - - http://jil.org/jil/api/1.1/device.Device.getAvailableApplications - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.getAttributeValue - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.getAvailableAttributes - - - http://jil.org/jil/api/1.1/addressbookitem.AddressBookItem.setAttributeValue - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.open - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.play - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.pause - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.resume - - - http://jil.org/jil/api/1.1/multimedia.AudioPlayer.stop - - - AudioPlayer.onStateChange - - - http://jil.org/jil/api/1.1/multimedia.Camera.onCameraCaptured - - - http://jil.org/jil/api/1.1/multimedia.Camera.setWindow - - - http://jil.org/jil/api/1.1/multimedia.Camera.captureImage - - - Device.PositionInfo - - - Device.DeviceStateInfo - - - DeviceStateInfo.onPositionRetrieved - - - http://jil.org/jil/api/1.1/messaging.Messaging.createMessage - - - http://jil.org/jil/api/1.1/messaging.Messaging.sendMessage - - - Messaging.onMessageSendingFailure - - - Multimedia.getVolume - - - Multimedia.stopAll - - - Multimedia.isAudioPlaying - - - http://jil.org/jil/api/1.1.1/pim.PIM.createAddressBookItem - - - PIM.onAddressBookItemFound - - - http://jil.org/jil/api/1.1.1/pim.PIM.findAddressBookItems - - - http://jil.org/jil/api/1.1.1/pim.PIM.getAddressBookItem - - - http://jil.org/jil/api/1.1.1/pim.PIM.getAddressBookItemsCount - - - - - - http://jil.org/jil/api/1.1/accelerometerinfo - - - http://jil.org/jil/api/1.1/addressbookitem - - - http://jil.org/jil/api/1.1.5/applicationtypes - - - http://jil.org/jil/api/1.1.2/camera - - - http://jil.org/jil/api/1.1/device - - - http://jil.org/jil/api/1.1/devicestateinfo - - - http://jil.org/jil/api/1.1.5/exception - - - http://jil.org/jil/api/1.1.5/exceptiontypes - - - http://jil.org/jil/api/1.1/message - - - http://jil.org/jil/api/1.1/messagetypes - - - http://jil.org/jil/api/1.1/messaging - - - http://jil.org/jil/api/1.1/multimedia - - - http://jil.org/jil/api/1.1.1/pim - - - http://jil.org/jil/api/1.1/positioninfo - - - http://jil.org/jil/api/1.1/widget - - - - - - - diff --git a/tests/ace/test-configuration/old_policy-example.xml b/tests/ace/test-configuration/old_policy-example.xml deleted file mode 100644 index d7ce388..0000000 --- a/tests/ace/test-configuration/old_policy-example.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - device.simcard - - - - - - - - - - - - - - - file.write - - - - - - - - - - - - - - - - pim.contact - - - - - - - diff --git a/tests/ace/test-configuration/policy-example.xml b/tests/ace/test-configuration/policy-example.xml deleted file mode 100644 index c0e0857..0000000 --- a/tests/ace/test-configuration/policy-example.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - devicestatus - - - - - - - - - - - - - - - - devicestatus - - - - - - - - - - - - - - - http://bondi.omtp.org/api.appconfig - - - - - - - - - - - - - - - - - - - - - file.write - - - - - - - - - - - - - - - - pim.contact - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/policy-example2.xml b/tests/ace/test-configuration/policy-example2.xml deleted file mode 100644 index dded65c..0000000 --- a/tests/ace/test-configuration/policy-example2.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - device.simcard - - - - - - - - - - - - - - - file.write - - - - - - - - - - - - - - - - pim.contact - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/policy-example3.xml b/tests/ace/test-configuration/policy-example3.xml deleted file mode 100644 index ef0fddc..0000000 --- a/tests/ace/test-configuration/policy-example3.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - device.simcard - - - - - - - - - - - - - - - file.write - - - - - - - - - - - - - - - - pim.contact - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/policy-test-gsettings.xml b/tests/ace/test-configuration/policy-test-gsettings.xml deleted file mode 100644 index 2a242f6..0000000 --- a/tests/ace/test-configuration/policy-test-gsettings.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - a1 - - - - - - d3 - - - - - - - aa2 - - - - - - bb2 - - - - - - - - c3 - - - - - d3 - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/policy-test.xml b/tests/ace/test-configuration/policy-test.xml deleted file mode 100644 index 9094ee4..0000000 --- a/tests/ace/test-configuration/policy-test.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - a1 - - - - - - b1 - - - - - - - aa2 - - - - - - bb2 - - - - - - - - c3 - - - - - d3 - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/policy-wac-2.0.xml b/tests/ace/test-configuration/policy-wac-2.0.xml deleted file mode 100644 index cf59001..0000000 --- a/tests/ace/test-configuration/policy-wac-2.0.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/ace/test-configuration/policy_example.xml b/tests/ace/test-configuration/policy_example.xml deleted file mode 100644 index 333422d..0000000 --- a/tests/ace/test-configuration/policy_example.xml +++ /dev/null @@ -1,2407 +0,0 @@ - - - - - - subject - - - - - - - - - - - - - - - - resource - - - - - - - - - - - - - - - resource - - - - - - - - - - subject3 - - - - - - - - - - - resource2 - - - - - - - - - resource2 - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - subject5 - - - - - - - resource5 - - - - - - - - - - resource6 - - - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - resource7 - - - - - - - - - - - - - - - - - s8a - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8b - - - - - - r8 - - - - - - - - r8 - - - - - - - - - - s8c - - - - - - r8 - - - - - - - - - - - - - - s9a - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9b - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9c - - - - - - r9 - - - - - - - - - r9 - - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9d - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9e - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9f - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9g - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s9h - - - - - - r9 - - - - - - - - r9 - - - - - - - - - - s10a - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10b - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - s10c - - - - - - r10 - - - - - - - - r10 - - - - - - - - - - - - - - - - s13 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s14 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s16 - - - - - - - - - - - - - - - - - - - - - subject4 - - - - - - - - resource4 - - - - - - - - - - - subject5 - - - - - - - - resource4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s19.1 - - - - - - - - resource4 - - - - - - - - - - s19.2 - - - - - - - - resource4 - - - - - - - - - - - - - s20.1 - - - - - - - - resource4 - - - - - - - - - - s20.2 - - - - - - - - resource4 - - - - - - - - - - - - - - s21 - - - - - - - - - - - - - - - - - - s23 - - - - - - - - - - - - - - - - - - - - s24 - - - - - - - - - - - - - - - - - - s25.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s25.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s26.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.1 - - - - - - - - - - - - - - - - - - - - - - - - - s27.2 - - - - - - - - - - - - - - - - - - - - - - - - - s27.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - s28 - - - - - - - - - - - - - - - - - - - - - - - - - - s29 - - - - - - - - - - - - - - - - - - - - - - - - - s30.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s33.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s34.1 - - - - - - - - - - - - - - - - - - - - - - - - s34.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.2 - - - - - - - - - - - - - - - - - - - - - - - - org.tizen.widget.analogclock - - - - - - - - - - - - - - - - - s36 - - - - - - - - - - - - - - - - - - - - - - - s37 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - s38 - - - - - - device:pim.contacts.read - - - - - - - - - s38.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - s39 - - - - - - device:pim.contacts.read - - - - - - - - - s39.4 - - - - - - device:pim.contacts.read - - - - - - - - - - - - - - - s40 - - - - - - r40 - - - - - - - r40 - - - - - - - - - - - - s41 - - - - - - r41 - - - - - r41.2 - - - - - - - - - - - - - s42.1 - - - - - - r42.1 - - - - - r42.1 - - - - - - - - - - - - - s42.2 - - - - - - r42.2 - - - - - r42.2 - - - - - - - - - - - - s43.1 - - - - - - r43.1 - - - - - - - r43.1 - - - - - - - - - - - s43.2 - - - - - - r43.2 - - - - - - - r43.2 - - - - - - - - - - - s44.1 - - - - - - r44.1 - - - - - - - r44.1 - - - - - - - - - - - s44.2 - - - - - - r44.2 - - - - - - - r44.2 - - - - - - - - - - - - - s45.1 - - - - - - r45.1 - - - - - r45.1 - - - - - - - - - - - - s45.2 - - - - - - r45.2 - - - - - r45.2 - - - - - - - - - - - - - s46.1 - - - - - - r46.1 - - - - - r46.1 - - - - - - - - - - - - s46.2 - - - - - - r46.2 - - - - - r46.2 - - - - - - - - - - - - - s47.1 - - - - - - r47.1 - - - - - r47.1 - - - - - - - - - - - s47.2 - - - - - - r47.2 - - - - - r47.2 - - - - - - - - - - - -s48 - - - - - - - - - - - - - - - diff --git a/tests/ace/test-configuration/reproduce-abort-test.xml b/tests/ace/test-configuration/reproduce-abort-test.xml deleted file mode 100644 index ee2de20..0000000 --- a/tests/ace/test-configuration/reproduce-abort-test.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/ace/test-configuration/undefined-test.xml b/tests/ace/test-configuration/undefined-test.xml deleted file mode 100644 index 3da1b1c..0000000 --- a/tests/ace/test-configuration/undefined-test.xml +++ /dev/null @@ -1,1075 +0,0 @@ - - - - - s25.2 - - - - - - - - - - - - - - - - - - - - - - s25.3 - - - - - - - - - - - - - - - - - - - - - - - - - s25.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s26.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s26.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.1 - - - - - - - - - - - - - - - - - - - - - - - - - s27.2 - - - - - - - - - - - - - - - - - - - - - - - - - s27.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - s27.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - s28 - - - - - - - - - - - - - - - - - - - - - - - - - - s29 - - - - - - - - - - - - - - - - - - - - - - - - - s30.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s30.4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s31.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.2.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s32.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s33.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s33.3 - - - - - - - - - - - - - - - - - - - - - - - - - - s34.1 - - - - - - - - - - - - - - - - - - - - - - - - s34.2 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.1 - - - - - - - - - - - - - - - - - - - - - - - - - - s35.2 - - - - - - - - - - - - - - - - - - - - - - - - org.tizen.widget.analogclock - - - - - - - - - - - - - - - - - s36 - - - - - - - - - - - - - - diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt deleted file mode 100644 index c1fbd82..0000000 --- a/tests/core/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) -# @version 1.0 -# @brief -# - -# -# Test files -# -# Define all DPL tests sources. -# Runner is responsible for runnint it all and -# generating proper output files -# - -SET(TARGET_NAME "dpl-tests-core") - -# Set DPL tests sources -SET(DPL_TESTS_SOURCES - ${PROJECT_SOURCE_DIR}/tests/core/main.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_address.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_binary_queue.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_foreach.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_fast_delegate.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_log_unhandled_exception.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_once.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_serialization.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_scoped_array.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_scoped_close.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_scoped_fclose.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_scoped_free.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_scoped_ptr.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_semaphore.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_shared_ptr.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_string.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_task.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_thread.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_type_list.cpp - ${PROJECT_SOURCE_DIR}/tests/core/test_zip_input.cpp -) - -INCLUDE_DIRECTORIES( - ${SYS_EFL_INCLUDE_DIRS} - ${DPL_TEST_INCLUDE_DIR} -) - -LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS}) - -ADD_EXECUTABLE(${TARGET_NAME} ${DPL_TESTS_SOURCES}) - -TARGET_LINK_LIBRARIES( - ${TARGET_NAME} - ${SYS_EFL_LIBRARIES} - ${TARGET_DPL_EFL} - ${TARGET_DPL_TEST_ENGINE_EFL} -) - -SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - BUILD_WITH_INSTALL_RPATH ON - INSTALL_RPATH_USE_LINK_PATH ON -) - -INSTALL(TARGETS ${TARGET_NAME} - DESTINATION bin - PERMISSIONS OWNER_READ - OWNER_WRITE - OWNER_EXECUTE - GROUP_READ - GROUP_EXECUTE - WORLD_READ - WORLD_EXECUTE -) - -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/core/data/sample.zip - DESTINATION /opt/apps/wrt/wrt-commons/tests/core -) \ No newline at end of file diff --git a/tests/core/DESCRIPTION b/tests/core/DESCRIPTION deleted file mode 100644 index 48e5394..0000000 --- a/tests/core/DESCRIPTION +++ /dev/null @@ -1,2 +0,0 @@ -!!!options!!! stop -Test code diff --git a/tests/core/data/sample.zip b/tests/core/data/sample.zip deleted file mode 100644 index 02417d89316a2de5eb658decfa83dc60e366c8c7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 174 zcmWIWW@h1H0D-h9e>XlTKgobc3Fe?N{`GRn11vdjD z%L`_pLJ(1sT3iy~&B!FjjLRemkOd5kK)j?8#6mWg6=E)$nE~FcY#^14Ko|g|JwO}= E0Bw;T(f|Me diff --git a/tests/core/main.cpp b/tests/core/main.cpp deleted file mode 100644 index 42ffe3a..0000000 --- a/tests/core/main.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file main.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of main - */ -#include - -int main(int argc, char *argv[]) -{ - return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); -} - diff --git a/tests/core/test_address.cpp b/tests/core/test_address.cpp deleted file mode 100644 index 7aff2df..0000000 --- a/tests/core/test_address.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_address.cpp - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test address - */ -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(Address_InitialEmpty) -{ - DPL::Address address; - RUNNER_ASSERT(address.ToString() == ":0"); -} - -RUNNER_TEST(Address_InitialAddress) -{ - DPL::Address address("www.sample.com"); - RUNNER_ASSERT(address.ToString() == "www.sample.com:0"); -} - -RUNNER_TEST(Address_InitialAddressPort) -{ - DPL::Address address("www.somewhere.com", 8080); - RUNNER_ASSERT(address.ToString() == "www.somewhere.com:8080"); -} - -RUNNER_TEST(Address_Getters) -{ - DPL::Address address("www.somewhere.com", 8080); - RUNNER_ASSERT(address.GetAddress() == "www.somewhere.com"); - RUNNER_ASSERT(address.GetPort() == 8080); -} diff --git a/tests/core/test_binary_queue.cpp b/tests/core/test_binary_queue.cpp deleted file mode 100644 index d955aab..0000000 --- a/tests/core/test_binary_queue.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_binary_queue.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test binary queue - */ -#include -#include -RUNNER_TEST_GROUP_INIT(DPL) - -inline std::string BinaryQueueToString(const DPL::BinaryQueue &queue) -{ - char *buffer = new char[queue.Size()]; - queue.Flatten(buffer, queue.Size()); - std::string result = std::string(buffer, buffer + queue.Size()); - delete [] buffer; - return result; -} - -RUNNER_TEST(BinaryQueue_InitialEmpty) -{ - DPL::BinaryQueue queue; - RUNNER_ASSERT(queue.Empty() == true); -} - -RUNNER_TEST(BinaryQueue_InitialSize) -{ - DPL::BinaryQueue queue; - RUNNER_ASSERT(queue.Size() == 0); -} - -RUNNER_TEST(BinaryQueue_InitialCopy) -{ - DPL::BinaryQueue queue; - DPL::BinaryQueue copy = queue; - - RUNNER_ASSERT(copy.Size() == 0); -} - -RUNNER_TEST(BinaryQueue_InitialConsumeZero) -{ - DPL::BinaryQueue queue; - queue.Consume(0); -} - -RUNNER_TEST(BinaryQueue_InitialFlattenConsumeZero) -{ - DPL::BinaryQueue queue; - queue.FlattenConsume(NULL, 0); -} - -RUNNER_TEST(BinaryQueue_InitialFlattenZero) -{ - DPL::BinaryQueue queue; - queue.Flatten(NULL, 0); -} - -RUNNER_TEST(BinaryQueue_InitialConsumeOne) -{ - DPL::BinaryQueue queue; - - Try - { - queue.Consume(1); - } - Catch (DPL::BinaryQueue::Exception::OutOfData) - { - return; - } - - RUNNER_FAIL; -} - -RUNNER_TEST(BinaryQueue_InitialFlattenConsumeOne) -{ - DPL::BinaryQueue queue; - - Try - { - char data; - queue.FlattenConsume(&data, 1); - } - Catch (DPL::BinaryQueue::Exception::OutOfData) - { - return; - } - - RUNNER_FAIL; -} - -RUNNER_TEST(BinaryQueue_InitialFlattenOne) -{ - DPL::BinaryQueue queue; - - Try - { - char data; - queue.Flatten(&data, 1); - } - Catch (DPL::BinaryQueue::Exception::OutOfData) - { - return; - } - - RUNNER_FAIL; -} - -RUNNER_TEST(BinaryQueue_ZeroCopyFrom) -{ - DPL::BinaryQueue queue; - DPL::BinaryQueue copy; - - copy.AppendCopyFrom(queue); - RUNNER_ASSERT(queue.Empty()); -} - -RUNNER_TEST(BinaryQueue_ZeroMoveFrom) -{ - DPL::BinaryQueue queue; - DPL::BinaryQueue copy; - - copy.AppendMoveFrom(queue); - RUNNER_ASSERT(queue.Empty()); -} - -RUNNER_TEST(BinaryQueue_ZeroCopyTo) -{ - DPL::BinaryQueue queue; - DPL::BinaryQueue copy; - - queue.AppendCopyTo(copy); - RUNNER_ASSERT(queue.Empty()); -} - -RUNNER_TEST(BinaryQueue_InsertSingleCharacters) -{ - DPL::BinaryQueue queue; - - queue.AppendCopy("a", 1); - queue.AppendCopy("b", 1); - queue.AppendCopy("c", 1); - queue.AppendCopy("d", 1); - - RUNNER_ASSERT(queue.Size() == 4); - RUNNER_ASSERT(BinaryQueueToString(queue) == "abcd"); -} - -RUNNER_TEST(BinaryQueue_Consume) -{ - DPL::BinaryQueue queue; - - queue.AppendCopy("abcd", 4); - queue.AppendCopy("ef", 2); - - RUNNER_ASSERT(queue.Size() == 6); - - queue.Consume(1); - RUNNER_ASSERT(queue.Size() == 5); - RUNNER_ASSERT(BinaryQueueToString(queue) == "bcdef"); - - queue.Consume(2); - RUNNER_ASSERT(queue.Size() == 3); - RUNNER_ASSERT(BinaryQueueToString(queue) == "def"); - - queue.Consume(1); - RUNNER_ASSERT(queue.Size() == 2); - RUNNER_ASSERT(BinaryQueueToString(queue) == "ef"); - - queue.Consume(2); - RUNNER_ASSERT(queue.Size() == 0); - RUNNER_ASSERT(BinaryQueueToString(queue) == ""); -} - -RUNNER_TEST(BinaryQueue_Flatten) -{ - DPL::BinaryQueue queue; - - queue.AppendCopy("abcd", 4); - queue.AppendCopy("ef", 2); - queue.AppendCopy("g", 1); - - RUNNER_ASSERT(queue.Size() == 7); - - RUNNER_ASSERT(BinaryQueueToString(queue) == "abcdefg"); -} - -RUNNER_TEST(BinaryQueue_FlattenConsume) -{ - DPL::BinaryQueue queue; - - queue.AppendCopy("abcd", 4); - queue.AppendCopy("ef", 2); - - RUNNER_ASSERT(queue.Size() == 6); - - char buffer[7] = { '\0' }; - queue.FlattenConsume(buffer, 3); - - RUNNER_ASSERT(queue.Size() == 3); - RUNNER_ASSERT(BinaryQueueToString(queue) == "def"); -} - -RUNNER_TEST(BinaryQueue_AppendCopyFrom) -{ - DPL::BinaryQueue queue; - DPL::BinaryQueue copy; - - queue.AppendCopy("abcd", 4); - queue.AppendCopy("ef", 2); - - copy.AppendCopyFrom(queue); - - RUNNER_ASSERT(queue.Size() == 6); - RUNNER_ASSERT(copy.Size() == 6); - RUNNER_ASSERT(BinaryQueueToString(queue) == "abcdef"); - RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef"); -} - -RUNNER_TEST(BinaryQueue_AppendCopyTo) -{ - DPL::BinaryQueue queue; - DPL::BinaryQueue copy; - - queue.AppendCopy("abcd", 4); - queue.AppendCopy("ef", 2); - - queue.AppendCopyTo(copy); - - RUNNER_ASSERT(queue.Size() == 6); - RUNNER_ASSERT(copy.Size() == 6); - RUNNER_ASSERT(BinaryQueueToString(queue) == "abcdef"); - RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef"); -} - -RUNNER_TEST(BinaryQueue_AppendMoveFrom) -{ - DPL::BinaryQueue queue; - DPL::BinaryQueue copy; - - queue.AppendCopy("abcd", 4); - queue.AppendCopy("ef", 2); - - copy.AppendMoveFrom(queue); - - RUNNER_ASSERT(queue.Size() == 0); - RUNNER_ASSERT(copy.Size() == 6); - RUNNER_ASSERT(BinaryQueueToString(queue) == ""); - RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef"); -} - -RUNNER_TEST(BinaryQueue_AppendMoveTo) -{ - DPL::BinaryQueue queue; - DPL::BinaryQueue copy; - - queue.AppendCopy("abcd", 4); - queue.AppendCopy("ef", 2); - - queue.AppendMoveTo(copy); - - RUNNER_ASSERT(queue.Size() == 0); - RUNNER_ASSERT(copy.Size() == 6); - RUNNER_ASSERT(BinaryQueueToString(queue) == ""); - RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef"); -} - -class Visitor - : public DPL::BinaryQueue::BucketVisitor -{ -private: - int m_index; - -public: - Visitor() - : m_index(0) - { - } - - virtual void OnVisitBucket(const void *buffer, size_t bufferSize) - { - const char *str = static_cast(buffer); - - if (m_index == 0) - { - RUNNER_ASSERT(bufferSize == 4); - RUNNER_ASSERT(str[0] == 'a'); - RUNNER_ASSERT(str[1] == 'b'); - RUNNER_ASSERT(str[2] == 'c'); - RUNNER_ASSERT(str[3] == 'd'); - } - else if (m_index == 1) - { - RUNNER_ASSERT(bufferSize == 2); - RUNNER_ASSERT(str[0] == 'e'); - RUNNER_ASSERT(str[1] == 'f'); - } - else - { - RUNNER_FAIL; - } - - ++m_index; - } -}; - -RUNNER_TEST(BinaryQueue_Visitor) -{ - DPL::BinaryQueue queue; - - queue.AppendCopy("abcd", 4); - queue.AppendCopy("ef", 2); - - Visitor visitor; - queue.VisitBuckets(&visitor); -} - -RUNNER_TEST(BinaryQueue_AbstracInputRead) -{ - DPL::BinaryQueue queue; - - queue.AppendCopy("abcd", 4); - - queue.Read(0); - - RUNNER_ASSERT(BinaryQueueToString(*queue.Read(1).get()) == "a"); - RUNNER_ASSERT(BinaryQueueToString(*queue.Read(2).get()) == "bc"); - RUNNER_ASSERT(BinaryQueueToString(*queue.Read(1).get()) == "d"); - - RUNNER_ASSERT(queue.Size() == 0); -} - -RUNNER_TEST(BinaryQueue_AbstracOutputWrite) -{ - DPL::BinaryQueue queue; - queue.AppendCopy("abcd", 4); - - DPL::BinaryQueue stream; - - stream.Write(queue, 4); - - RUNNER_ASSERT(BinaryQueueToString(*queue.Read(4).get()) == "abcd"); -} diff --git a/tests/core/test_fast_delegate.cpp b/tests/core/test_fast_delegate.cpp deleted file mode 100644 index 947cbe5..0000000 --- a/tests/core/test_fast_delegate.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_fast_delegate.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of fast delegate tests. - */ -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -// Sample copied and adopted from -// http://www.codeproject.com/KB/cpp/FastDelegate.aspx -// -// Demonstrate the syntax for FastDelegates. -// -Don Clugston, May 2004. -// It's a really boring example, but it shows the most important cases. -// Declare some functions of varying complexity... -void SimpleStaticFunction(int num, const char *str); -void SimpleStaticFunction(int num, const char *str) -{ - LogDebug("In SimpleStaticFunction. Num=" << num << ", str =" << str); -} - -void SimpleVoidFunction(); -void SimpleVoidFunction() -{ - LogDebug("In SimpleVoidFunction with no parameters."); -} - -class CBaseClass -{ -protected: - const char *m_name; - -public: - CBaseClass(const char *name) - : m_name(name) - { - } - - virtual ~CBaseClass() - { - } - - void SimpleMemberFunction(int num, const char *str) - { - LogDebug("In SimpleMemberFunction in " << m_name << ". Num=" - << num << ", str = " << str); - } - - int SimpleMemberFunctionReturnsInt(int num, const char *str) - { - LogDebug("In SimpleMemberFunctionReturnsInt in " << m_name << ". Num=" - << num << ", str = " << str); - return -1; - } - - void ConstMemberFunction(int num, const char *str) const - { - LogDebug("In ConstMemberFunction in " << m_name << ". Num=" - << num << ", str = " << str); - } - - virtual void SimpleVirtualFunction(int num, const char *str) - { - LogDebug("In SimpleVirtualFunction in " << m_name << ". Num=" - << num << ", str = " << str); - } - - static void StaticMemberFunction(int num, const char *str) - { - LogDebug("In StaticMemberFunction Num=" - << num << ", str = " << str); - } -}; - -class COtherClass -{ - double rubbish; // to ensure this class has non-zero size. - -public: - virtual ~COtherClass() - { - } - - virtual void UnusedVirtualFunction(void) - { - } - virtual void TrickyVirtualFunction(int num, const char *str) = 0; -}; - -class VeryBigClass -{ - int letsMakeThingsComplicated[400]; -}; - -// This declaration ensures that we get a convoluted class heirarchy. -class CDerivedClass - : public VeryBigClass, - virtual public COtherClass, - virtual public CBaseClass -{ - double m_somemember[8]; - -public: - CDerivedClass() - : CBaseClass("Base of Derived") - { - m_somemember[0] = 1.2345; - } - - void SimpleDerivedFunction(int num, const char *str) - { - LogDebug("In SimpleDerivedFunction Num=" - << num << ", str = " << str); - } - - virtual void AnotherUnusedVirtualFunction(int num, const char *str) - { - LogDebug("In AnotherUnusedVirtualFunction in " << m_name << ". Num=" - << num << ", str = " << str); - } - - virtual void TrickyVirtualFunction(int num, const char *str) - { - LogDebug("In TrickyVirtualFunction in " << m_name << ". Num=" - << num << ", str = " << str); - } -}; - -RUNNER_TEST(FastDelegate_Test) -{ - // Delegates with up to 8 parameters are supported. - // Here's the case for a void function. - // We declare a delegate and attach it to SimpleVoidFunction() - DPL::FastDelegate0<> noparameterdelegate(&SimpleVoidFunction); - - // invoke the delegate - this calls SimpleVoidFunction() - noparameterdelegate(); - - LogDebug("-- Examples using two-parameter delegates (int, char *) --"); - - // By default, the return value is void. - typedef DPL::FastDelegate2 MyDelegate; - - // If you want to have a non-void return value, put it at the end. - typedef DPL::FastDelegate2 IntMyDelegate; - - - MyDelegate funclist[12]; // delegates are initialized to empty - CBaseClass a("Base A"); - CBaseClass b("Base B"); - CDerivedClass d; - CDerivedClass c; - - IntMyDelegate newdeleg; - newdeleg = DPL::MakeDelegate(&a, - &CBaseClass::SimpleMemberFunctionReturnsInt); - - // Binding a simple member function - funclist[0].bind(&a, &CBaseClass::SimpleMemberFunction); - - // You can also bind static (free) functions - funclist[1].bind(&SimpleStaticFunction); - - // and static member functions - funclist[2].bind(&CBaseClass::StaticMemberFunction); - - // and const member functions (these only need a const class pointer). - funclist[3].bind((const CBaseClass *) &a, - &CBaseClass::ConstMemberFunction); - - funclist[4].bind(&a, &CBaseClass::ConstMemberFunction); - - // and virtual member functions - funclist[5].bind(&b, &CBaseClass::SimpleVirtualFunction); - - // You can also use the = operator. For static functions, a fastdelegate - // looks identical to a simple function pointer. - funclist[6] = &CBaseClass::StaticMemberFunction; - - // The weird rule about the class of derived member function pointers - // is avoided. For MSVC, you can use &CDerivedClass::SimpleVirtualFunction - // here, but DMC will complain. Note that as well as .bind(), you can also - // use the MakeDelegate() global function. - funclist[7] = DPL::MakeDelegate(&d, &CBaseClass::SimpleVirtualFunction); - - // The worst case is an abstract virtual function of a virtually-derived - // class with at least one non-virtual base class. This is a VERY obscure - // situation, which you're unlikely to encounter in the real world. - // FastDelegate versions prior to 1.3 had problems with this case on VC6. - // Now, it works without problems on all compilers. - funclist[8].bind(&c, &CDerivedClass::TrickyVirtualFunction); - - // BUT... in such cases you should be using the base class as an - // interface, anyway. - funclist[9].bind(&c, &COtherClass::TrickyVirtualFunction); - - // Calling a function that was first declared in the derived class is - // straightforward - funclist[10] = DPL::MakeDelegate(&c, &CDerivedClass::SimpleDerivedFunction); - - // You can also bind directly using the constructor - MyDelegate dg(&b, &CBaseClass::SimpleVirtualFunction); - - const char *msg = "Looking for equal delegate"; - - for (int i = 0; i < 12; i++) - { - LogDebug(i << ":"); - - // The == and != operators are provided - // Note that they work even for inline functions. - if (funclist[i] == dg) - { - msg = "Found equal delegate"; - } - - // operator ! can be used to test for an empty delegate - // You can also use the .empty() member function. - if (!funclist[i]) - { - LogDebug("Delegate is empty"); - } - else - { - // Invocation generates optimal assembly code. - funclist[i](i, msg); - } - } -} diff --git a/tests/core/test_foreach.cpp b/tests/core/test_foreach.cpp deleted file mode 100644 index f698081..0000000 --- a/tests/core/test_foreach.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_foreach.cpp - * @author Bartosz Janiak (b.janiak@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of foreach tests. - */ - -#include -#include -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -static const size_t testContainerSize = 1024; - -template -void VerifyForeach(Container& container) -{ - size_t i = 0; - FOREACH(it, container) - { - RUNNER_ASSERT(*it == i); - i++; - } - RUNNER_ASSERT(i == container.size()); -} - -#define VERIFY_FOREACH(container) \ - { \ - size_t i = 0; \ - FOREACH(it, container) \ - { \ - RUNNER_ASSERT(*it == i); \ - i++; \ - } \ - } - -static size_t numberOfCallsToTemporaryList = 0; -std::list temporaryList(); -std::list temporaryList() -{ - ++numberOfCallsToTemporaryList; - std::list list; - for (size_t i = 0 ; i < testContainerSize ; i++) - { - list.push_back(i); - } - return list; -} - -static size_t numberOfCallsToTemporaryVector = 0; -std::vector temporaryVector(); -std::vector temporaryVector() -{ - ++numberOfCallsToTemporaryVector; - std::vector vector; - for (size_t i = 0 ; i < testContainerSize ; i++) - { - vector.push_back(i); - } - return vector; -} - -static size_t numberOfCallsToTemporarySet = 0; -std::set temporarySet(); -std::set temporarySet() -{ - ++numberOfCallsToTemporarySet; - std::set set; - for (size_t i = 0 ; i < testContainerSize ; i++) - { - set.insert(i); - } - return set; -} - -RUNNER_TEST(Foreach_std_containers) -{ - std::vector vector; - std::list list; - std::set set; - - for (size_t i = 0 ; i < testContainerSize ; i++) - { - vector.push_back(i); - list.push_back(i); - set.insert(i); - } - - VerifyForeach(vector); - VerifyForeach(list); - VerifyForeach(set); - - VERIFY_FOREACH(temporaryList()); - VERIFY_FOREACH(temporaryVector()); - VERIFY_FOREACH(temporarySet()); - - RUNNER_ASSERT(numberOfCallsToTemporaryList == 1); - RUNNER_ASSERT(numberOfCallsToTemporaryVector == 1); - RUNNER_ASSERT(numberOfCallsToTemporarySet == 1); -} diff --git a/tests/core/test_log_unhandled_exception.cpp b/tests/core/test_log_unhandled_exception.cpp deleted file mode 100644 index 0403c28..0000000 --- a/tests/core/test_log_unhandled_exception.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_log_unhandled_exception.cpp - * @author Pawel Sikorski (p.marcinkiew@samsung.com) - * @version 1.0 - * @brief - */ -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -class MyException -{ -}; - -class MyDPLException -{ -public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, MyException) -}; - -class MySTDException - : public std::exception -{ -public: - virtual const char* what()const throw() { return "my std exception occurred";} -}; - -RUNNER_TEST(Log_Unknown_Exception) -{ - UNHANDLED_EXCEPTION_HANDLER_BEGIN - { -// throw MyException(); - } - UNHANDLED_EXCEPTION_HANDLER_END - RUNNER_ASSERT(true); -} - -RUNNER_TEST(Log_DPL_Exception) -{ - UNHANDLED_EXCEPTION_HANDLER_BEGIN - { -// Throw(MyDPLException::MyException); - } - UNHANDLED_EXCEPTION_HANDLER_END - RUNNER_ASSERT(true); -} - -RUNNER_TEST(Log_STD_Exception) -{ - UNHANDLED_EXCEPTION_HANDLER_BEGIN - { -// throw MySTDException(); - } - UNHANDLED_EXCEPTION_HANDLER_END - RUNNER_ASSERT(true); -} diff --git a/tests/core/test_once.cpp b/tests/core/test_once.cpp deleted file mode 100644 index e65ea9b..0000000 --- a/tests/core/test_once.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_once.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of once tests - */ -#include -#include -#include -#include -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -namespace // anonymous -{ -gint g_counter; - -void Delegate() -{ - ++g_counter; -} -} // namespace anonymous - -RUNNER_TEST(Once_DoubleCall) -{ - g_counter = 0; - - DPL::Once once; - - once.Call(&Delegate); - once.Call(&Delegate); - - RUNNER_ASSERT_MSG(g_counter == 1, "Counter value is: " << g_counter); -} - -class MyThread - : public DPL::Thread -{ -protected: - virtual int ThreadEntry() - { - DPL::WaitForSingleHandle(m_event->GetHandle()); - m_once->Call(DPL::Once::Delegate(this, &MyThread::Call)); - return 0; - } - - void Call() - { - ++*m_atom; - } - -public: - MyThread(DPL::WaitableEvent *event, DPL::Once *once, DPL::Atomic *atom) - : m_event(event), m_once(once), m_atom(atom) - { - } - -private: - DPL::WaitableEvent *m_event; - DPL::Once *m_once; - DPL::Atomic *m_atom; -}; - -RUNNER_TEST(Once_MultiThreadCall) -{ - const size_t NUM_THREADS = 20; - typedef DPL::SharedPtr ThreadPtr; - - ThreadPtr threads[NUM_THREADS]; - DPL::WaitableEvent event; - DPL::Once once; - DPL::Atomic atom; - - for (size_t i = 0; i< NUM_THREADS; ++i) - { - (threads[i] = ThreadPtr(new MyThread(&event, &once, &atom)))->Run(); - } - - event.Signal(); - - for (size_t i = 0; i< NUM_THREADS; ++i) - threads[i]->Quit(); - - RUNNER_ASSERT_MSG(atom == 1, "Atom value is: " << atom); -} diff --git a/tests/core/test_scoped_array.cpp b/tests/core/test_scoped_array.cpp deleted file mode 100644 index 58b0603..0000000 --- a/tests/core/test_scoped_array.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_scoped_array.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test scoped array - */ -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(ScopedArray_Zero) -{ - DPL::ScopedArray array; - - RUNNER_ASSERT(!array); - RUNNER_ASSERT(!!!array); -} - -RUNNER_TEST(ScopedArray_NonZero) -{ - DPL::ScopedArray array(new char[7]); - - RUNNER_ASSERT(array); - RUNNER_ASSERT(!!array); -} - -RUNNER_TEST(ScopedArray_Reset) -{ - DPL::ScopedArray array(new char[7]); - array.Reset(); - - RUNNER_ASSERT(!array); - - array.Reset(new char); - RUNNER_ASSERT(array); -} - -RUNNER_TEST(ScopedArray_ArrayOperator) -{ - DPL::ScopedArray array(new char[7]); - - array[1] = array[2] = 3; - - RUNNER_ASSERT(array[1] == 3); - RUNNER_ASSERT(array[2] == 3); -} diff --git a/tests/core/test_scoped_close.cpp b/tests/core/test_scoped_close.cpp deleted file mode 100644 index 3549fed..0000000 --- a/tests/core/test_scoped_close.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_scoped_close.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test scoped close - */ -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -// DUNNO diff --git a/tests/core/test_scoped_fclose.cpp b/tests/core/test_scoped_fclose.cpp deleted file mode 100644 index dbdff95..0000000 --- a/tests/core/test_scoped_fclose.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @file test_scoped_fclose.cpp - * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test scoped fclose - */ - -#include -#include - -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -namespace -{ -FILE* MakeTmp() -{ - FILE* result = NULL; - do - { - result = tmpfile(); - } while (NULL != result && EINTR == errno); - return result; -} -}//anonymous namespace - -RUNNER_TEST(ScopedFClose_Zero) -{ - DPL::ScopedFClose file; - - RUNNER_ASSERT(!file); - RUNNER_ASSERT(!!!file); -} - -RUNNER_TEST(ScopedFClose_NonZero) -{ - DPL::ScopedFClose file(MakeTmp()); - - RUNNER_ASSERT(file); - RUNNER_ASSERT(!!file); -} - -RUNNER_TEST(ScopedFClose_Reset) -{ - DPL::ScopedFClose file(MakeTmp()); - file.Reset(); - - RUNNER_ASSERT(!file); - - file.Reset(MakeTmp()); - RUNNER_ASSERT(file); -} - diff --git a/tests/core/test_scoped_free.cpp b/tests/core/test_scoped_free.cpp deleted file mode 100644 index bc41a5a..0000000 --- a/tests/core/test_scoped_free.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_scoped_free.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test scoped free - */ -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(ScopedFree_Zero) -{ - DPL::ScopedFree free; - - RUNNER_ASSERT(!free); - RUNNER_ASSERT(!!!free); -} - -RUNNER_TEST(ScopedFree_NonZero) -{ - DPL::ScopedFree free(malloc(7)); - - RUNNER_ASSERT(free); - RUNNER_ASSERT(!!free); -} - -RUNNER_TEST(ScopedFree_Reset) -{ - DPL::ScopedFree free(malloc(7)); - free.Reset(); - - RUNNER_ASSERT(!free); - - free.Reset(malloc(8)); - RUNNER_ASSERT(free); -} diff --git a/tests/core/test_scoped_ptr.cpp b/tests/core/test_scoped_ptr.cpp deleted file mode 100644 index f3a7237..0000000 --- a/tests/core/test_scoped_ptr.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_scoped_ptr.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test scoped ptr - */ -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(ScopedPtr_Zero) -{ - DPL::ScopedPtr ptr; - - RUNNER_ASSERT(!ptr); - RUNNER_ASSERT(!!!ptr); -} - -RUNNER_TEST(ScopedPtr_NonZero) -{ - DPL::ScopedPtr ptr(new char(7)); - - RUNNER_ASSERT(ptr); - RUNNER_ASSERT(!!ptr); -} - -RUNNER_TEST(ScopedPtr_Reset) -{ - DPL::ScopedPtr ptr(new char(7)); - ptr.Reset(); - - RUNNER_ASSERT(!ptr); - - ptr.Reset(new char); - RUNNER_ASSERT(ptr); -} - -RUNNER_TEST(ScopedPtr_Operators) -{ - DPL::ScopedPtr ptr(new char(7)); - - RUNNER_ASSERT(*ptr == *ptr.Get()); -} diff --git a/tests/core/test_semaphore.cpp b/tests/core/test_semaphore.cpp deleted file mode 100644 index 854978e..0000000 --- a/tests/core/test_semaphore.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_semaphore.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of semaphore tests - */ -#include -#include -#include -#include -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -class SemaphoreThread - : public DPL::Thread -{ - int m_delta; - int m_times; - int *m_value; - std::string m_semaphoreName; - -public: - SemaphoreThread(int delta, - int times, - int *value, - const std::string &semaphoreName) - : m_delta(delta), - m_times(times), - m_value(value), - m_semaphoreName(semaphoreName) - { - } - -protected: - virtual int ThreadEntry() - { - DPL::Semaphore semaphore(m_semaphoreName); - - for (int i = 0; i < m_times; ++i) - { - // Take scoped semaphore lock - DPL::Semaphore::ScopedLock lock(&semaphore); - *m_value += m_delta; - } - - return 0; - } -}; - -RUNNER_TEST(Semaphore_NamedIncrementDecrement) -{ - std::string semaphoreName = - "dpl_test_semaphore_" + - DPL::lexical_cast(std::time(NULL)); - - int value = 0; - SemaphoreThread threadA(-1, 10000, &value, semaphoreName); - SemaphoreThread threadB(+1, 10000, &value, semaphoreName); - - threadA.Run(); - threadB.Run(); - - threadA.Quit(); - threadB.Quit(); - - RUNNER_ASSERT_MSG(value == 0, "Final value is: " << value); -} diff --git a/tests/core/test_serialization.cpp b/tests/core/test_serialization.cpp deleted file mode 100644 index 8776fc8..0000000 --- a/tests/core/test_serialization.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_address.cpp - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of serialization tests - */ - -#include -#include -#include -#include - -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -// test stream class -class BinaryStream : public DPL::IStream { - public: - virtual void Read(size_t num, void * bytes) - { - for (unsigned i = 0; i < num; ++i) { - ((unsigned char*)bytes)[i] = data[i + readPosition]; - } - readPosition += num; - } - virtual void Write(size_t num, const void * bytes) - { - for (unsigned i = 0; i < num; ++i) { - data.push_back(((unsigned char*)bytes)[i]); - } - } - BinaryStream() - { - readPosition = 0; - } - virtual ~BinaryStream(){}; - - private: - std::vector data; - unsigned readPosition; -}; - -//test ISerializable class -class TestClass : public DPL::ISerializable { - public: - TestClass(int val, std::string str1, std::string str2) - { - a = val; - b = str1; - c.push_back(str1); - c.push_back(str2); - c.push_back(str1 + str2); - }; - TestClass(DPL::IStream& stream) - { - DPL::Deserialization::Deserialize(stream,a); - DPL::Deserialization::Deserialize(stream,b); - DPL::Deserialization::Deserialize(stream,c); - }; - virtual void Serialize(DPL::IStream& stream) const - { - DPL::Serialization::Serialize(stream,a); - DPL::Serialization::Serialize(stream,b); - DPL::Serialization::Serialize(stream,c); - } - virtual ~TestClass(){} - virtual bool operator==(const TestClass& other) - { - return (a == other.a && - b == other.b && - c.size() == other.c.size() && - c[0] == other.c[0] && - c[1] == other.c[1] && - c[2] == other.c[2]); - } - private: - int a; - std::string b; - std::vector c; -}; - -RUNNER_TEST(Serialize_primitives) -{ - int a = 1; - bool b = true; - unsigned c = 23; - BinaryStream stream; - DPL::Serialization::Serialize(stream,a); - DPL::Serialization::Serialize(stream,b); - DPL::Serialization::Serialize(stream,c); - int test_int; - DPL::Deserialization::Deserialize(stream,test_int); - RUNNER_ASSERT(test_int == a); - bool test_bool; - DPL::Deserialization::Deserialize(stream,test_bool); - RUNNER_ASSERT(test_bool == b); - unsigned test_unsigned; - DPL::Deserialization::Deserialize(stream,test_unsigned); - RUNNER_ASSERT(test_unsigned == c); -} - -RUNNER_TEST(Serialize_primitive_pointers) -{ - int a = 1; - bool b = true; - unsigned c = 23; - BinaryStream stream; - DPL::Serialization::Serialize(stream,&a); - DPL::Serialization::Serialize(stream,&b); - DPL::Serialization::Serialize(stream,&c); - int* test_int; - DPL::Deserialization::Deserialize(stream,test_int); - RUNNER_ASSERT(test_int != NULL && *test_int == a); - bool* test_bool; - DPL::Deserialization::Deserialize(stream,test_bool); - RUNNER_ASSERT(test_bool != NULL && *test_bool == b); - unsigned* test_unsigned; - DPL::Deserialization::Deserialize(stream,test_unsigned); - RUNNER_ASSERT(test_unsigned != NULL && *test_unsigned == c); - delete test_int; - delete test_bool; - delete test_unsigned; -} - -RUNNER_TEST(Serialize_strings) -{ - std::string str1 = "ALA MA KOTA"; - std::string str2 = "MULTILINE\nTEST"; - BinaryStream stream; - DPL::Serialization::Serialize(stream,str1); - DPL::Serialization::Serialize(stream,str2); - std::string test_str1; - DPL::Deserialization::Deserialize(stream,test_str1); - RUNNER_ASSERT(test_str1 == str1); - std::string test_str2; - DPL::Deserialization::Deserialize(stream,test_str2); - RUNNER_ASSERT(test_str2 == str2); -} - -RUNNER_TEST(Serialize_string_pointers) -{ - std::string str1 = "ALA MA KOTA"; - std::string str2 = "MULTILINE\nTEST"; - BinaryStream stream; - DPL::Serialization::Serialize(stream,&str1); - DPL::Serialization::Serialize(stream,&str2); - std::string* test_str1; - DPL::Deserialization::Deserialize(stream,test_str1); - RUNNER_ASSERT(test_str1 != NULL && *test_str1 == str1); - std::string* test_str2; - DPL::Deserialization::Deserialize(stream,test_str2); - RUNNER_ASSERT(test_str2 != NULL && *test_str2 == str2); - delete test_str1; - delete test_str2; -} - -RUNNER_TEST(Serialize_containers) -{ - std::vector vec; - vec.push_back(134); - vec.push_back(265); - std::list list; - list.push_back(true); - list.push_back(false); - std::pair pair; - pair.first = -23; - pair.second = 1234; - std::map map; - map.insert(std::pair(45, "ALA MA CZARNEGO KOTA")); - map.insert(std::pair(-78, "...A MOZE\nMA\nWIELE LINIJEK")); - BinaryStream stream; - DPL::Serialization::Serialize(stream,vec); - DPL::Serialization::Serialize(stream,list); - DPL::Serialization::Serialize(stream,pair); - DPL::Serialization::Serialize(stream,map); - std::vector test_vec; - DPL::Deserialization::Deserialize(stream,test_vec); - RUNNER_ASSERT(test_vec.size() == vec.size() && - test_vec[0] == vec[0] && test_vec[1] == vec[1]); - std::list test_list; - DPL::Deserialization::Deserialize(stream,test_list); - RUNNER_ASSERT(test_list.size() == list.size() && - test_list.front() == list.front() && - test_list.back() == test_list.back()); - std::pair test_pair; - DPL::Deserialization::Deserialize(stream,test_pair); - RUNNER_ASSERT(test_pair.first == pair.first && - test_pair.second == pair.second); - std::map test_map; - DPL::Deserialization::Deserialize(stream,test_map); - RUNNER_ASSERT(test_map.size() == map.size() && - test_map.at(45) == map.at(45) && - test_map.at(-78) == map.at(-78)); -} - -RUNNER_TEST(Serialize_objects) -{ - TestClass a(123,"ASDGHUADB\n\n5679b^^()*","TEST_STRING"), - b(679,"HUSPIDNSAHDPA","\nASDSADASD\naDSADASD8"); - BinaryStream stream; - DPL::Serialization::Serialize(stream,a); - DPL::Serialization::Serialize(stream,b); - TestClass test_a(0,"",""), test_b(0,"",""); - DPL::Deserialization::Deserialize(stream, test_a); - RUNNER_ASSERT(test_a == a); - DPL::Deserialization::Deserialize(stream, test_b); - RUNNER_ASSERT(test_b == b); -} - -RUNNER_TEST(Serialize_all) -{ - std::map > map; - std::vector vec; - vec.push_back(new TestClass(123,"ASDGHUADB\n\n5679b^^()*","TEST_STRING")); - vec.push_back(new TestClass(679,"HUSPIDNSAHDPA","\nASDSADASD\naDSADASD8")); - map.insert(std::pair >("KEY1",vec)); - map.insert(std::pair >("KEY2",vec)); - BinaryStream stream; - - DPL::Serialization::Serialize(stream, map); - - std::map > test_map; - DPL::Deserialization::Deserialize(stream,test_map); - RUNNER_ASSERT(map.size() == test_map.size()); - std::vector test_vec1,test_vec2; - test_vec1 = map.at("KEY1"); - test_vec2 = test_map.at("KEY1"); - RUNNER_ASSERT(test_vec1.size() == test_vec2.size()); - unsigned i; - for (i = 0; i < test_vec1.size(); ++i) - { - RUNNER_ASSERT((*test_vec1[i]) == (*test_vec2[i])); - } - test_vec1 = map.at("KEY2"); - test_vec2 = test_map.at("KEY2"); - RUNNER_ASSERT(test_vec1.size() == test_vec2.size()); - for (i = 0; i < test_vec1.size(); ++i) - { - RUNNER_ASSERT((*test_vec1[i]) == (*test_vec2[i])); - } -} - diff --git a/tests/core/test_shared_ptr.cpp b/tests/core/test_shared_ptr.cpp deleted file mode 100644 index 541a333..0000000 --- a/tests/core/test_shared_ptr.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_shared_ptr.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test shared ptr - */ -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(SharedPtr_Zero) -{ - DPL::SharedPtr ptr; - - RUNNER_ASSERT(!ptr); - RUNNER_ASSERT(!!!ptr); - RUNNER_ASSERT(ptr == DPL::SharedPtr()); -} - -RUNNER_TEST(SharedPtr_NonZero) -{ - DPL::SharedPtr ptr(new char(7)); - - RUNNER_ASSERT(ptr); - RUNNER_ASSERT(!!ptr); - RUNNER_ASSERT(ptr != DPL::SharedPtr()); -} - -RUNNER_TEST(SharedPtr_Copy) -{ - DPL::SharedPtr ptr1(new char(7)); - DPL::SharedPtr ptr2(new char(7)); - - RUNNER_ASSERT(ptr1 != ptr2); - - ptr2 = ptr1; - - RUNNER_ASSERT(ptr1 == ptr2); -} - -RUNNER_TEST(SharedPtr_Reset) -{ - DPL::SharedPtr ptr(new char(7)); - ptr.Reset(); - - RUNNER_ASSERT(!ptr); - - ptr.Reset(new char); - RUNNER_ASSERT(ptr); -} - -RUNNER_TEST(SharedPtr_RefCounting) -{ - DPL::SharedPtr ptr1(new char(7)); - DPL::SharedPtr ptr2; - - ptr2 = ptr1; - - RUNNER_ASSERT(ptr1 == ptr2); - RUNNER_ASSERT(ptr1.GetUseCount() == ptr2.GetUseCount()); - RUNNER_ASSERT(ptr1.GetUseCount() == 2); -} - -RUNNER_TEST(SharedPtr_Operators) -{ - DPL::SharedPtr ptr(new char(7)); - - RUNNER_ASSERT(*ptr == *ptr.Get()); -} diff --git a/tests/core/test_string.cpp b/tests/core/test_string.cpp deleted file mode 100644 index dea0a22..0000000 --- a/tests/core/test_string.cpp +++ /dev/null @@ -1,384 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_string.cpp - * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of string tests - */ -#include -#include -#include -#include -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -unsigned char GetBaseCode(int index); -unsigned char GetBaseCode(int index) -{ - /* aaaack but it's fast and const should make it shared text page. */ - static const unsigned char pr2six[256] = - { - /* ASCII table */ - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, - 64, 0, 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, 64, 64, 64, 64, 64, - 64, 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, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 - }; - return pr2six[index]; -} - - -/* Function adapted from APR library (http://apr.apache.org/) */ -int wbxml_base64_decode(const char *buffer, char **result); -int wbxml_base64_decode(const char *buffer, char **result) -{ - int nbytesdecoded = 0, nprbytes = 0; - const char *bufin = NULL; - char *bufout = NULL; - - if ((buffer == NULL) || (result == NULL)) - return 0; - - /* Initialize output buffer */ - *result = NULL; - - bufin = buffer; - while (GetBaseCode(*(bufin++)) <= 63) {} - - nprbytes = (bufin - buffer) - 1; - nbytesdecoded = ((nprbytes + 3) / 4) * 3; - - /* Malloc result buffer */ - if ((*result = (char*) malloc(nbytesdecoded + 1)) == NULL) - return 0; - memset(*result, nbytesdecoded + 1, 0); - - bufout = *result; - bufin = buffer; - - while (nprbytes > 4) - { - *(bufout++) = (char)(GetBaseCode(*bufin) << 2 | GetBaseCode(bufin[1]) >> 4); - *(bufout++) = (char)(GetBaseCode(bufin[1]) << 4 | GetBaseCode(bufin[2]) >> 2); - *(bufout++) = (char)(GetBaseCode(bufin[2]) << 6 | GetBaseCode(bufin[3])); - bufin += 4; - nprbytes -= 4; - } - - /* Note: (nprbytes == 1) would be an error, so just ingore that case */ - if (nprbytes > 1) - { - *(bufout++) = (char)(GetBaseCode(*bufin) << 2 | GetBaseCode(bufin[1]) >> 4); - } - if (nprbytes > 2) - { - *(bufout++) = (char)(GetBaseCode(bufin[1]) << 4 | GetBaseCode(bufin[2]) >> 2); - } - if (nprbytes > 3) - { - *(bufout++) = (char)(GetBaseCode(bufin[2]) << 6 | GetBaseCode(bufin[3])); - } - - nbytesdecoded -= (4 - nprbytes) & 3; - - return nbytesdecoded; -} - -//#define TEST_CONVERSION(in_string, out_string, buffer_type, function - -const char utf32Encoded[] = -"RDAAAI0wAABvMAAAazAAAHswAAB4MAAAaDAAAAAwAABhMAAAijAAAGwwAACLMAAAkjAAAAAwAACP\ -MAAASzAAAIgwAABfMAAAjDAAAF0wAAAAMAAAZDAAAG0wAABqMAAAiTAAAIAwAAAAMAAARjAAAJAw\ -AABuMAAASjAAAE8wAACEMAAAfjAAAAAwAABRMAAAdTAAAFMwAABIMAAAZjAAAAAwAABCMAAAVTAA\ -AE0wAACGMAAAgTAAAH8wAABXMAAAADAAAJEwAAByMAAAgjAAAFswAABZMAAACgAAANsFAADaBQAA\ -IAAAANQFAADqBQAA6AUAAOEFAADnBQAAIAAAAOAFAADkBQAA5QUAACAAAADiBQAA3AUAACAAAADS\ -BQAA1QUAANYFAADcBQAAIAAAAOcFAADYBQAA3wUAACwAAAAgAAAA6QUAANMFAADXBQAA4wUAACAA\ -AADQBQAA6gUAACAAAADmBQAA0QUAANkFAAAgAAAA3AUAAN4FAADZBQAA3QUAAAoAAACk0AAApMIA\ -AFjHAAAgAAAA4KwAACDHAABwyAAAdKwAAEDHAAAgAAAAhccAACDCAAB8sAAArLkAACAAAADMuQAA\ -mLAAAHzFAAAgAAAAWNUAAOCsAAAgAAAAudIAAMS8AABc1QAAIAAAADCuAAAgwgAAQMcAACAAAABE\ -1QAAlMYAAFjOAAAgAAAASsUAAOSyAAAKAAAAUAAAAGMAAABoAAAAbgAAAAUBAAAHAQAAIAAAAHcA\ -AAAgAAAAdAAAABkBAAAgAAAAQgEAAPMAAABkAAAAegEAACAAAABqAAAAZQAAAHwBAABhAAAAIAAA\ -AGwAAAB1AAAAYgAAACAAAABvAAAAWwEAAG0AAAAgAAAAcwAAAGsAAAByAAAAegAAAHkAAABEAQAA\ -IAAAAGYAAABpAAAAZwAAAC4AAAAKAAAAQgAAAGwAAABvAAAAdwAAAHoAAAB5AAAAIAAAAG4AAABp\ -AAAAZwAAAGgAAAB0AAAALQAAAGYAAAByAAAAdQAAAG0AAABwAAAAcwAAACAAAAB2AAAAZQAAAHgA\ -AAAnAAAAZAAAACAAAABKAAAAYQAAAGMAAABrAAAAIAAAAFEAAAAuAAAACgAAAEYGAAA1BgAAIAAA\ -AC0GAABDBgAASgYAAEUGAAAgAAAARAYAAEcGAAAgAAAAMwYAADEGAAAgAAAAQgYAACcGAAA3BgAA\ -OQYAACAAAABIBgAAMAYAAEgGAAAgAAAANAYAACMGAABGBgAAIAAAADkGAAA4BgAASgYAAEUGAAAg\ -AAAARQYAAEMGAAAqBgAASAYAACgGAAAgAAAAOQYAAEQGAABJBgAAIAAAACsGAABIBgAAKAYAACAA\ -AAAjBgAALgYAADYGAAAxBgAAIAAAAEgGAABFBgAAOgYAAEQGAABBBgAAIAAAACgGAAAsBgAARAYA\ -AC8GAAAgAAAAIwYAADIGAAAxBgAAQgYAACAAAAAKAAAAEgQAACAAAABHBAAAMAQAAEkEAAAwBAAA\ -RQQAACAAAABOBAAAMwQAADAEAAAgAAAANgQAADgEAAA7BAAAIAAAADEEAABLBAAAIAAAAEYEAAA4\ -BAAAQgQAAEAEAABDBAAAQQQAAD8AAAAgAAAAFAQAADAEAAAsAAAAIAAAAD0EAAA+BAAAIAAAAEQE\ -AAAwBAAAOwQAAEwEAABIBAAAOAQAADIEAABLBAAAOQQAACAAAABNBAAAOgQAADcEAAA1BAAAPAQA\ -AD8EAAA7BAAATwQAAEAEAAAhAAAACgAAAKQDAACsAwAAxwMAALkDAADDAwAAxAMAALcDAAAgAAAA\ -sQMAALsDAADOAwAAwAMAALcDAAC+AwAAIAAAALIDAACxAwAAxgMAAK4DAADCAwAAIAAAAMgDAAC3\ -AwAAvAMAAK0DAAC9AwAAtwMAACAAAACzAwAAtwMAACwAAAAgAAAAtAMAAMEDAACxAwAAwwMAALoD\ -AAC1AwAAuwMAAK8DAAC2AwAAtQMAALkDAAAgAAAAxQMAAMADAACtAwAAwQMAACAAAAC9AwAAyQMA\ -ALgDAADBAwAAvwMAAM0DAAAgAAAAugMAAMUDAAC9AwAAzAMAAMIDAAAKAAAAVgAAAGkAAABjAAAA\ -dAAAAG8AAAByAAAAIAAAAGoAAABhAAAAZwAAAHQAAAAgAAAAegAAAHcAAAD2AAAAbAAAAGYAAAAg\ -AAAAQgAAAG8AAAB4AAAAawAAAOQAAABtAAAAcAAAAGYAAABlAAAAcgAAACAAAABxAAAAdQAAAGUA\ -AAByAAAAIAAAAPwAAABiAAAAZQAAAHIAAAAgAAAAZAAAAGUAAABuAAAAIAAAAGcAAAByAAAAbwAA\ -AN8AAABlAAAAbgAAACAAAABTAAAAeQAAAGwAAAB0AAAAZQAAAHIAAAAgAAAARAAAAGUAAABpAAAA\ -YwAAAGgAAAAKAAAAlokAAM6RAAAhcQAAUJYAAONeAAAM/wAAl3oAABZZAAAJZwAAzYUAAClZAAAK\ -AAAACgAAAAAAAAA="; - -const char utf8Encoded[] = -"44GE44KN44Gv44Gr44G744G444Go44CA44Gh44KK44Gs44KL44KS44CA44KP44GL44KI44Gf44KM\ -44Gd44CA44Gk44Gt44Gq44KJ44KA44CA44GG44KQ44Gu44GK44GP44KE44G+44CA44GR44G144GT\ -44GI44Gm44CA44GC44GV44GN44KG44KB44G/44GX44CA44KR44Gy44KC44Gb44GZCteb15og15TX\ -qteo16HXpyDXoNek16Ug16LXnCDXkteV15bXnCDXp9eY158sINep15PXl9ejINeQ16og16bXkdeZ\ -INec157XmdedCu2CpOyKpOydmCDqs6DsnKDsobDqsbTsnYAg7J6F7Iig64G866asIOunjOuCmOyV\ -vCDtlZjqs6Ag7Yq567OE7ZWcIOq4sOyIoOydgCDtlYTsmpTsuZgg7JWK64ukClBjaG7EhcSHIHcg\ -dMSZIMWCw7NkxbogamXFvGEgbHViIG/Fm20gc2tyennFhCBmaWcuCkJsb3d6eSBuaWdodC1mcnVt\ -cHMgdmV4J2QgSmFjayBRLgrZhti1INit2YPZitmFINmE2Ycg2LPYsSDZgtin2LfYuSDZiNiw2Ygg\ -2LTYo9mGINi52LjZitmFINmF2YPYqtmI2Kgg2LnZhNmJINir2YjYqCDYo9iu2LbYsSDZiNmF2LrZ\ -hNmBINio2KzZhNivINij2LLYsdmCIArQkiDRh9Cw0YnQsNGFINGO0LPQsCDQttC40Lsg0LHRiyDR\ -htC40YLRgNGD0YE/INCU0LAsINC90L4g0YTQsNC70YzRiNC40LLRi9C5INGN0LrQt9C10LzQv9C7\ -0Y/RgCEKzqTOrM+HzrnPg8+EzrcgzrHOu8+Oz4DOt86+IM6yzrHPhs6uz4Igz4jOt868zq3Ovc63\ -IM6zzrcsIM60z4HOsc+DzrrOtc67zq/Ots61zrkgz4XPgM6tz4Egzr3Pic64z4HOv8+NIM66z4XO\ -vc+Mz4IKVmljdG9yIGphZ3QgenfDtmxmIEJveGvDpG1wZmVyIHF1ZXIgw7xiZXIgZGVuIGdyb8Of\ -ZW4gU3lsdGVyIERlaWNoCuimlumHjueEoemZkOW7o++8jOeql+WkluacieiXjeWkqQoKAA=="; - - - - -const char asciiEncodedIso1[] = -"ISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZ\ -WltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fgA="; - -const char asciiEncodedUtf32[] = -"IQAAACIAAAAjAAAAJAAAACUAAAAmAAAAJwAAACgAAAApAAAAKgAAACsAAAAsAAAALQAAAC4AAAAv\ -AAAAMAAAADEAAAAyAAAAMwAAADQAAAA1AAAANgAAADcAAAA4AAAAOQAAADoAAAA7AAAAPAAAAD0A\ -AAA+AAAAPwAAAEAAAABBAAAAQgAAAEMAAABEAAAARQAAAEYAAABHAAAASAAAAEkAAABKAAAASwAA\ -AEwAAABNAAAATgAAAE8AAABQAAAAUQAAAFIAAABTAAAAVAAAAFUAAABWAAAAVwAAAFgAAABZAAAA\ -WgAAAFsAAABcAAAAXQAAAF4AAABfAAAAYAAAAGEAAABiAAAAYwAAAGQAAABlAAAAZgAAAGcAAABo\ -AAAAaQAAAGoAAABrAAAAbAAAAG0AAABuAAAAbwAAAHAAAABxAAAAcgAAAHMAAAB0AAAAdQAAAHYA\ -AAB3AAAAeAAAAHkAAAB6AAAAewAAAHwAAAB9AAAAfgAAAAAAAAA="; - - -RUNNER_TEST(String_ConverterFromASCII) -{ - char* inStr = NULL; - int inSize = wbxml_base64_decode(asciiEncodedIso1, &inStr); - RUNNER_ASSERT(inSize > 0); - RUNNER_ASSERT(NULL != inStr); - inStr[inSize] = '\0'; - { - DPL::String asciiString = DPL::FromASCIIString(inStr); - - std::string result = DPL::ToUTF8String(asciiString); - - RUNNER_ASSERT(strlen(inStr) == result.size()); - - RUNNER_ASSERT(0 == memcmp(inStr, result.c_str(), result.size())); - } - - free(inStr); -} - -RUNNER_TEST(String_ConverterFromUTF8) -{ - char* inStr = NULL; - int inSize = wbxml_base64_decode(asciiEncodedIso1, &inStr); - RUNNER_ASSERT(inSize > 0); - RUNNER_ASSERT(NULL != inStr); - { - DPL::String asciiString = DPL::FromUTF8String(inStr); - - std::string result = DPL::ToUTF8String(asciiString); - - RUNNER_ASSERT(strlen(inStr) == result.size()); - - RUNNER_ASSERT(0 == memcmp(inStr, result.c_str(), result.size())); - } - - free(inStr); -} - -RUNNER_TEST(String_ConverterFromUTF32) -{ - wchar_t* inStr = NULL; - int inSize = wbxml_base64_decode(utf32Encoded, reinterpret_cast(&inStr)); - RUNNER_ASSERT(inSize > 0); - RUNNER_ASSERT(NULL != inStr); - char* outStr = NULL; - int outSize = wbxml_base64_decode(utf8Encoded, &outStr); - RUNNER_ASSERT(outSize > 0); - RUNNER_ASSERT(NULL != outStr); - outStr[outSize] = '\0'; - { - DPL::String utfString = DPL::FromUTF32String(inStr); - std::string result = DPL::ToUTF8String(utfString); - - RUNNER_ASSERT(strlen(outStr) == result.size()); - RUNNER_ASSERT(0 == memcmp(outStr, result.c_str(), result.size())); - - - RUNNER_ASSERT(inSize / sizeof(wchar_t) - 1 == utfString.size()); - RUNNER_ASSERT(0 == memcmp(inStr, &(utfString[0]), utfString.size() * sizeof(wchar_t))); - - } - - free(inStr); -} - -template -void String_TokenizeReal(const DelimiterType& delimiter) -{ - DPL::String str(L".##..abc.#."); - std::vector tokens; - DPL::Tokenize(str, delimiter, std::back_inserter(tokens)); - - std::vector expectedTokens; - for ( int i = 0 ; i < 5 ; i++ ) - expectedTokens.push_back(L""); - expectedTokens.push_back(L"abc"); - for ( int i = 0 ; i < 3 ; i++ ) - expectedTokens.push_back(L""); - - RUNNER_ASSERT(expectedTokens == tokens); - tokens.clear(); - expectedTokens.clear(); - - DPL::Tokenize(str, delimiter, std::back_inserter(tokens), true); - expectedTokens.push_back(L"abc"); - RUNNER_ASSERT(expectedTokens == tokens); -} - -RUNNER_TEST(String_Tokenize) -{ - String_TokenizeReal(L"#."); - String_TokenizeReal(L".#"); - String_TokenizeReal(L".....####.###.."); - String_TokenizeReal(DPL::String(L".#")); - - std::vector tokens; - DPL::Tokenize(std::string("abc.def"), '.', std::back_inserter(tokens)); - std::vector expectedTokens; - expectedTokens.push_back("abc"); - expectedTokens.push_back("def"); - - RUNNER_ASSERT(tokens == expectedTokens); -} - -template -void TestInStreams( - std::basic_string argumentInString, - std::basic_string argumentResultString) -{ - typedef std::basic_string - String; - std::basic_istringstream - istream(argumentInString); - int intValue = 0; - double doubleValue = 0.0; - float floatValue = 0.0; - String stringValue; - - istream >> intValue; - RUNNER_ASSERT(!istream.fail()); - istream >> doubleValue; - RUNNER_ASSERT(!istream.fail()); - istream >> floatValue; - RUNNER_ASSERT(!istream.fail()); - istream >> stringValue; - RUNNER_ASSERT(!istream.fail()); - - RUNNER_ASSERT(1 == intValue); - RUNNER_ASSERT(fabs(1.1f - doubleValue) < 0.00001); - RUNNER_ASSERT(fabs(1.1f - floatValue) < 0.00001); - RUNNER_ASSERT(argumentResultString == stringValue); -} - -template -void TestOutStreams( - std::basic_string argumentInString, - std::basic_string argumentResultString) -{ - typedef std::basic_string - String; - - std::basic_ostringstream - ostream; - - int intValue = 1; - double doubleValue = 1.1; - float floatValue = 1.1f; - String stringValue = argumentInString; - - ostream << intValue; - RUNNER_ASSERT(!ostream.fail()); - ostream << doubleValue; - RUNNER_ASSERT(!ostream.fail()); - ostream << floatValue; - RUNNER_ASSERT(!ostream.fail()); - ostream << stringValue; - RUNNER_ASSERT(!ostream.fail()); - - RUNNER_ASSERT(ostream.str() == argumentResultString); -} - -RUNNER_TEST(String_Streams) -{ - TestInStreams >("1 1.1 1.1 test", "test"); - TestInStreams >(L"1 1.1 1.1 test", L"test"); - TestInStreams(L"1 1.1 1.1 test", L"test"); - TestOutStreams >("test", "11.11.1test"); - TestOutStreams >(L"test", L"11.11.1test"); - TestOutStreams(L"test", L"11.11.1test"); -} - -RUNNER_TEST(String_CompareCaseSensitive) -{ - RUNNER_ASSERT( - DPL::StringCompare( - DPL::FromUTF32String(L"Ala Makota ma żołądkówkę"), - DPL::FromUTF32String(L"Ala Makota ma żołądkówkę")) == 0); -} - -RUNNER_TEST(String_CompareCaseInsensitive) -{ - RUNNER_ASSERT( - DPL::StringCompare( - DPL::FromUTF32String(L"Ala Makota ma żołądkówkę"), - DPL::FromUTF32String(L"AlA MakOTA ma ŻoŁąDKÓwkę"), - true) == 0); -} - diff --git a/tests/core/test_task.cpp b/tests/core/test_task.cpp deleted file mode 100644 index 4ad00c3..0000000 --- a/tests/core/test_task.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_task.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of task tests - */ -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -class MySingleTask - : public DPL::TaskDecl -{ -protected: - void StepOne() - { - } - -public: - MySingleTask() - : DPL::TaskDecl(this) - { - AddStep(&MySingleTask::StepOne); - } -}; - -class MyMultiTask - : public DPL::MultiTaskDecl -{ -protected: - typedef DPL::MultiTaskDecl BaseType; - - void StepOne() - { - LogInfo("Step one"); - } - - void StepTwo() - { - LogInfo("Step two"); - } - - void StepThree() - { - LogInfo("Step three"); - } - -public: - MyMultiTask() - : BaseType(this, 2) - { - BaseType::StepList depListStepThree; - depListStepThree.push_back(&MyMultiTask::StepOne); - depListStepThree.push_back(&MyMultiTask::StepTwo); - AddStep(&MyMultiTask::StepThree, depListStepThree); - - BaseType::StepList depListStepTwo; - depListStepTwo.push_back(&MyMultiTask::StepOne); - AddStep(&MyMultiTask::StepTwo, depListStepTwo); - - BaseType::StepList depListStepOne; - AddStep(&MyMultiTask::StepOne, depListStepOne); - } -}; - -RUNNER_TEST(Task_SingleTask) -{ - MySingleTask task; - while (task.NextStep()); -} - -RUNNER_TEST(Task_MultiTask) -{ - MyMultiTask task; - while (task.NextStep()); -} diff --git a/tests/core/test_thread.cpp b/tests/core/test_thread.cpp deleted file mode 100644 index 202d468..0000000 --- a/tests/core/test_thread.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_thread.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of thread tests - */ -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -bool g_wasFooDeleted; - -class Foo -{ -public: - int id; - Foo(int i=0): id(i) - { - LogInfo("Foo: ctor: " << id); - } - - ~Foo() - { - LogInfo("Foo: dtor: " << id); - g_wasFooDeleted = true; - } - - void Bar() - { - LogInfo("Foo: bar"); - } -}; - -typedef DPL::ThreadLocalVariable TlsFoo; -TlsFoo g_foo; - -class FooThread - : public DPL::Thread -{ -protected: - virtual int ThreadEntry() - { - LogInfo("In thread"); - - RUNNER_ASSERT(!g_foo); - RUNNER_ASSERT(g_foo.IsNull()); - - g_foo = Foo(); - g_foo->Bar(); - - return 0; - } -}; - -RUNNER_TEST(Thread_ThreadLocalVariable_FooDeletion) -{ - static TlsFoo staticFooForMain; - staticFooForMain = Foo(1); - - TlsFoo fooForMain; - fooForMain = Foo(2); - - RUNNER_ASSERT(!g_foo); - RUNNER_ASSERT(g_foo.IsNull()); - - g_wasFooDeleted = false; - - FooThread thread1; - thread1.Run(); - thread1.Quit(); - - RUNNER_ASSERT(!g_foo); - RUNNER_ASSERT(g_foo.IsNull()); - - RUNNER_ASSERT(g_wasFooDeleted == true); - - FooThread thread2; - thread2.Run(); - thread2.Quit(); - - RUNNER_ASSERT(!g_foo); - RUNNER_ASSERT(g_foo.IsNull()); -} diff --git a/tests/core/test_type_list.cpp b/tests/core/test_type_list.cpp deleted file mode 100644 index 98167f3..0000000 --- a/tests/core/test_type_list.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file test_type_list.cpp - * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) - * @version 0.1 - * @brief - */ - -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(TypeList_TypeCount) -{ - typedef DPL::TypeListDecl::Type TestTypeList1; - typedef DPL::TypeListDecl::Type TestTypeList2; - typedef DPL::TypeListDecl<>::Type TestTypeList3; - typedef DPL::TypeList TestTypeList4; - - RUNNER_ASSERT(TestTypeList1::Size == 3); - RUNNER_ASSERT(TestTypeList2::Size == 1); - RUNNER_ASSERT(TestTypeList3::Size == 0); - RUNNER_ASSERT(TestTypeList4::Size == 4); - - RUNNER_ASSERT(TestTypeList4::Tail::Tail::Size == 2); -} diff --git a/tests/core/test_zip_input.cpp b/tests/core/test_zip_input.cpp deleted file mode 100644 index 9498e76..0000000 --- a/tests/core/test_zip_input.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_zip_input.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of zip input tests - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace { -const char* PATH_NO_FILE = "/opt/apps/wrt/wrt-commons/tests/core/no_such_file"; -const char* PATH_ARCHIVE = "/opt/apps/wrt/wrt-commons/tests/core/sample.zip"; -const char* ARCHIVED_FILE = "sample.txt"; -} - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(ZipInput_OpenFailed) -{ - bool opened = true; - - Try - { - DPL::ZipInput zip(PATH_NO_FILE); - (void)zip; - } - Catch(DPL::ZipInput::Exception::OpenFailed) - { - opened = false; - } - - RUNNER_ASSERT(opened == false); -} - -RUNNER_TEST(ZipInput_OpenFile) -{ - DPL::ZipInput zip(PATH_ARCHIVE); - - FOREACH(iter, zip) - { - LogDebug("---------"); - LogDebug("FileInfo: "); -#define FIELD(X) LogDebug(#X ": " << iter->X) - FIELD(name); - FIELD(comment); - FIELD(version); - FIELD(versionNeeded); - FIELD(flag); - FIELD(compressionMethod); - FIELD(dosDate); - FIELD(crc); - FIELD(compressedSize); - FIELD(uncompressedSize); - FIELD(diskNumberStart); - FIELD(internalFileAttributes); - FIELD(externalFileAttributes); -#undef FIELD - } -} - -RUNNER_TEST(ZipInput_UnzipSingleFile) -{ - DPL::ZipInput zip(PATH_ARCHIVE); - DPL::ZipInput::File *file = zip.OpenFile(ARCHIVED_FILE); - DPL::AbstractWaitableInputAdapter fileAdapter(file); - DPL::BinaryQueue buffer; - DPL::AbstractWaitableOutputAdapter bufferAdapter(&buffer); - - DPL::Copy(&fileAdapter, &bufferAdapter); - - DPL::ScopedArray data(new char[buffer.Size() + 1]); - buffer.Flatten(data.Get(), buffer.Size()); - data[buffer.Size()] = '\0'; - - RUNNER_ASSERT(std::string(data.Get()) == "test"); -} diff --git a/tests/db/CMakeLists.txt b/tests/db/CMakeLists.txt deleted file mode 100644 index 5276c06..0000000 --- a/tests/db/CMakeLists.txt +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Lukasz Marek (l.marek@samsung.com) -# @version 1.0 -# @brief -# - -# -# Test files -# -# Define all DPL tests sources. -# Runner is responsible for runnint it all and -# generating proper output files -# - -SET(TARGET_NAME "dpl-tests-db") - -# Set DPL tests sources -SET(DPL_TESTS_SOURCES - ${PROJECT_SOURCE_DIR}/tests/db/main.cpp - ${PROJECT_SOURCE_DIR}/tests/db/test_orm.cpp - ${PROJECT_SOURCE_DIR}/tests/db/test_sql_connection.cpp -) - -ADD_SUBDIRECTORY(orm) - -INCLUDE_DIRECTORIES( - ${SYS_EFL_INCLUDE_DIRS} - ${DPL_TEST_INCLUDE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/orm -) - -LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS}) - -ADD_EXECUTABLE(${TARGET_NAME} ${DPL_TESTS_SOURCES}) - -TARGET_LINK_LIBRARIES( - ${TARGET_NAME} - ${TARGET_DPL_EFL} - ${TARGET_DPL_DB_EFL} - ${TARGET_DPL_TEST_ENGINE_EFL} -) - -SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - BUILD_WITH_INSTALL_RPATH ON - INSTALL_RPATH_USE_LINK_PATH ON -) - -INSTALL(TARGETS ${TARGET_NAME} - DESTINATION bin - PERMISSIONS OWNER_READ - OWNER_WRITE - OWNER_EXECUTE - GROUP_READ - GROUP_EXECUTE - WORLD_READ - WORLD_EXECUTE -) - -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/db/orm/dpl_orm_test.db - DESTINATION /opt/apps/wrt/wrt-commons/tests/db -) \ No newline at end of file diff --git a/tests/db/main.cpp b/tests/db/main.cpp deleted file mode 100644 index 4ed6191..0000000 --- a/tests/db/main.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file main.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of main. - */ - -#include - -int main(int argc, char *argv[]) -{ - return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); -} diff --git a/tests/db/orm/CMakeLists.txt b/tests/db/orm/CMakeLists.txt deleted file mode 100644 index 5526a76..0000000 --- a/tests/db/orm/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ - -ADD_CUSTOM_COMMAND( OUTPUT dpl_orm_test_db.sql - COMMAND rm -f ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test.db - COMMAND gcc -Wall -I${DPL_DB_INCLUDE_DIR} -E ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db_sql_generator.h | grep --invert-match "^#" > ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db.sql - COMMAND sqlite3 ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test.db ".read ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db.sql" || rm -f ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test.db - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db_sql_generator.h ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db -) - -ADD_CUSTOM_TARGET( Sqlite3Db ALL DEPENDS dpl_orm_test_db.sql ) diff --git a/tests/db/orm/dpl_orm_test.db b/tests/db/orm/dpl_orm_test.db deleted file mode 100644 index 6c3d768e1ce403afaa09a48ef6cafc1567e2c934..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI&!A`_*=d5wp z=B!?4eju4Y^1S8$tILk&H%%%o?!2hl=Z<|*Ijpkk)XikAT8+MH@wS@66LQgIxYUwc z42!96lqNRX@`qv|e_mI(%p^A&7E|8nY&KUzKLP>}fB*y_009U<00Izz00bZaffW{* z&HuXjM$9ks!+ci>0s;_#00bZa0SG_<0uX=z1Rwx`^avDnLw$} zY - -#include "dpl_orm_test_db_definitions" diff --git a/tests/db/orm/generator_dpl_orm_test.h b/tests/db/orm/generator_dpl_orm_test.h deleted file mode 100644 index 39bb1b7..0000000 --- a/tests/db/orm/generator_dpl_orm_test.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ORM_GENERATOR_DPL_ORM_TEST_H -#define ORM_GENERATOR_DPL_ORM_TEST_H - -#define ORM_GENERATOR_DATABASE_NAME dpl_orm_test_db_definitions -#include -#undef ORM_GENERATOR_DATABASE_NAME - -#endif diff --git a/tests/db/test_orm.cpp b/tests/db/test_orm.cpp deleted file mode 100644 index ddcbe79..0000000 --- a/tests/db/test_orm.cpp +++ /dev/null @@ -1,712 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include - -namespace { -const char* PATH_DB = "/opt/apps/wrt/wrt-commons/tests/db/dpl_orm_test.db"; -} - -//utils - -#define TEST_REPETITION 16 - -class SmartAttach -{ -public: - - SmartAttach(bool autoattach = true) : - m_interface(PATH_DB, - DPL::DB::SqlConnection::Flag::UseLucene), - m_autoattach(autoattach) - { - if (m_autoattach) { - m_interface.AttachToThread(); - } - } - - ~SmartAttach() - { - if (m_autoattach) { - m_interface.DetachFromThread(); - } - } - - DPL::DB::ThreadDatabaseSupport* get() - { - return &m_interface; - } -private: - DPL::DB::ThreadDatabaseSupport m_interface; - bool m_autoattach; -}; - -template -bool ContainerContentsEqual(const ContainerType1& container1, const ContainerType2& container2) -{ - using namespace DPL::DB::ORM::dpl_orm_test::TestTableInsert; - typedef std::set Set1; - typedef std::set Set2; - Set1 set1(container1.begin(), container1.end()); - Set2 set2(container2.begin(), container2.end()); - - for (typename Set1::iterator it = set1.begin(); - it != set1.end(); - it++) - { - LogDebug("Set1 element: " << *it); - } - - for (typename Set2::iterator it = set2.begin(); it != set2.end(); it++) - { - LogDebug("Set2 element: " << *it); - } - - return set1 == set2; -} - -template -std::list makeList(const T& a, const T& b) -{ - std::list list; - list.push_back(a); - list.push_back(b); - return list; -} - -//tests - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(ORM_SelectSingleValue) -{ - SmartAttach interface; - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::dpl_orm_test; - //Getting each column - { - TestTable::Select select(interface.get()); - select.Where(Equals(8)); - int result; - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 6, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(8)); - DPL::String result; - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == L"seven", "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(8)); - int result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 8, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(8)); - int result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 9, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(8)); - DPL::String result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == L"ten", "Got " << result); - } - - //Where on each column - { - TestTable::Select select(interface.get()); - select.Where(Equals(6)); - int result; - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 6, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(DPL::String(L"seven"))); - DPL::String result; - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == L"seven", "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(8)); - int result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 8, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(9)); - int result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 9, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(L"ten")); - DPL::String result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == L"ten", "Got " << result); - } -} - -RUNNER_TEST(ORM_SelectSingleRow) -{ - SmartAttach interface; - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::dpl_orm_test; - { - TestTable::Select select(interface.get()); - select.Where(Equals(3)); - TestTable::Row result = select.GetSingleRow(); - TestTable::Row expected; - expected.Set_ColumnOptInt(1); - expected.Set_ColumnOptText(DPL::String(L"two")); - expected.Set_ColumnInt(3); - expected.Set_ColumnInt2(4); - expected.Set_ColumnText(L"five"); - RUNNER_ASSERT_MSG(result == expected, "Got " << result); - } - - { - TestTable::Select select(interface.get()); - select.Where(Equals(DPL::String(L"seven"))); - TestTable::Row result = select.GetSingleRow(); - TestTable::Row expected; - expected.Set_ColumnOptInt(6); - expected.Set_ColumnOptText(DPL::String(L"seven")); - expected.Set_ColumnInt(8); - expected.Set_ColumnInt2(9); - expected.Set_ColumnText(L"ten"); - RUNNER_ASSERT_MSG(result == expected, "Got " << result); - } -} - -RUNNER_TEST(ORM_SelectRowList) -{ - SmartAttach interface; - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::dpl_orm_test; - { - TestTable::Select select(interface.get()); - select.Where(Equals(3)); - std::list result = select.GetRowList(); - RUNNER_ASSERT_MSG(result.size() == 1, "Got " << result.size()); - - TestTable::Row expected; - expected.Set_ColumnOptInt(1); - expected.Set_ColumnOptText(DPL::String(L"two")); - expected.Set_ColumnInt(3); - expected.Set_ColumnInt2(4); - expected.Set_ColumnText(L"five"); - RUNNER_ASSERT_MSG(*(result.begin()) == expected, "Got " << *(result.begin()) ); - } - - { - TestTable::Select select(interface.get()); - select.Where(Equals(DPL::String(L"seven"))); - std::list result = select.GetRowList(); - RUNNER_ASSERT_MSG(result.size() == 1, "Got " << result.size()); - - TestTable::Row expected; - expected.Set_ColumnOptInt(6); - expected.Set_ColumnOptText(DPL::String(L"seven")); - expected.Set_ColumnInt(8); - expected.Set_ColumnInt2(9); - expected.Set_ColumnText(L"ten"); - RUNNER_ASSERT_MSG(*(result.begin()) == expected, "Got " << *(result.begin()) ); - } - - { - TestTable::Select select(interface.get()); - select.Where(Equals(99)); - std::list result = select.GetRowList(); - - TestTable::Row expected1; - expected1.Set_ColumnInt(99); - expected1.Set_ColumnInt2(11); - expected1.Set_ColumnText(L"twelve"); - - TestTable::Row expected2; - expected2.Set_ColumnInt(99); - expected2.Set_ColumnInt2(13); - expected2.Set_ColumnText(L"fourteen"); - - RUNNER_ASSERT(ContainerContentsEqual(makeList(expected1, expected2), result)); - } -} - -RUNNER_TEST(ORM_SelectValueList) -{ - SmartAttach interface; - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::dpl_orm_test; - //Getting each column - { - TestTable::Select select(interface.get()); - select.Where(Is(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(99, 99))); - } - { - TestTable::Select select(interface.get()); - select.Where(Is(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(11, 13))); - } - { - TestTable::Select select(interface.get()); - select.Where(Is(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(DPL::String(L"twelve"), DPL::String(L"fourteen")))); - } - { - TestTable::Select select(interface.get()); - select.Where(Is(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(DPL::Optional::Null,DPL::Optional::Null))); - } - - //Where on each column - { - TestTable::Select select(interface.get()); - select.Where(Is(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(11, 13))); - } - { - TestTable::Select select(interface.get()); - select.Where(Is(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(11, 13))); - } - { - TestTable::Select select(interface.get()); - select.Where(Is(99)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(11, 13))); - } -} - -RUNNER_TEST(ORM_MultipleCalls) -{ - for (int j = 0 ; j < TEST_REPETITION ; j++ ) - { - for (int i = 0 ; i < TEST_REPETITION ; i++ ) - ORM_SelectSingleValue(); - - for (int i = 0 ; i < TEST_REPETITION ; i++ ) - ORM_SelectSingleRow(); - - for (int i = 0 ; i < TEST_REPETITION ; i++ ) - ORM_SelectRowList(); - - for (int i = 0 ; i < TEST_REPETITION ; i++ ) - ORM_SelectValueList(); - } -} - -RUNNER_TEST(ORM_Insert) -{ - SmartAttach interface; - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::dpl_orm_test; - - TestTableInsert::Select select1(interface.get()); - std::list resultList = select1.GetValueList(); - RUNNER_ASSERT_MSG(resultList.size() == 0, "Returned list has wrong size: " << resultList.size()); - std::list list; - - TestTableInsert::Insert insert(interface.get()); - TestTableInsert::Row row; - row.Set_ColumnOptInt(1); - row.Set_ColumnInt2(2); - row.Set_ColumnText(L"three"); - insert.Values(row); - insert.Execute(); - - row.Set_ColumnInt(99); - list.push_back(row); - { - TestTableInsert::Select select2(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select2.GetRowList(), list), "Returned list doesn't match."); - } - - TestTableInsert::Insert insert2(interface.get()); - TestTableInsert::Row row2; - row2.Set_ColumnInt(4); - row2.Set_ColumnInt2(5); - row2.Set_ColumnText(L"six"); - insert2.Values(row2); - insert2.Execute(); - - list.push_back(row2); - { - TestTableInsert::Select select(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match."); - } - - TestTableInsert::Insert insert3(interface.get()); - TestTableInsert::Row row3; - row3.Set_ColumnOptInt(1); - row3.Set_ColumnInt2(7); - row3.Set_ColumnText(L"eight"); - insert3.Values(row3); - insert3.Execute(); - - row3.Set_ColumnInt(99); - list.push_back(row3); - { - TestTableInsert::Select select3(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select3.GetRowList(), list), "Returned list doesn't match."); - } - - TestTableInsert::Insert insert4(interface.get()); - TestTableInsert::Row row4; - row4.Set_ColumnOptInt(9); - row4.Set_ColumnInt2(10); - row4.Set_ColumnText(L"eleven"); - insert4.Values(row4); - insert4.Execute(); - - row4.Set_ColumnInt(99); - list.push_back(row4); - { - TestTableInsert::Select select4(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select4.GetRowList(), list), "Returned list doesn't match."); - } - - // restore original table state - { - TestTableInsert::Delete del(interface.get()); - del.Execute(); - - TestTableInsert::Select select(interface.get()); - RUNNER_ASSERT(select.GetRowList().size() == 0); - } -} - -RUNNER_TEST(ORM_MultipleBindInsert) -{ - for ( int i = 0 ; i < TEST_REPETITION ; i++ ) - { - ORM_Insert(); - } -} - -RUNNER_TEST(ORM_Delete) -{ - SmartAttach interface; - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::dpl_orm_test; - TestTableDelete::Select selectStart(interface.get()); - selectStart.OrderBy("ColumnInt2 ASC"); - std::list list = selectStart.GetRowList(); - std::list originalList = list; - - std::vector vector(list.begin(), list.end()); - RUNNER_ASSERT_MSG(list.size() == 4, "Returned list has wrong size: " << list.size()); - - typedef DPL::String S; - - //no-act deletes - { - TestTableDelete::Delete del(interface.get()); - del.Where(And(Equals(1), Equals(S(L"seven")))); - del.Execute(); - - TestTableDelete::Select select(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match."); - } - - { - TestTableDelete::Delete del(interface.get()); - del.Where(And(Equals(6), Equals(S(L"two")))); - del.Execute(); - - TestTableDelete::Select select(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match."); - } - - { - TestTableDelete::Delete del(interface.get()); - del.Where(Equals(10)); - del.Execute(); - - TestTableDelete::Select select(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match."); - } - - //act deletes - { - list.remove(vector[1]); - - TestTableDelete::Delete del(interface.get()); - del.Where(And(Equals(6), Equals(L"ten"))); - del.Execute(); - - TestTableDelete::Select select(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match."); - } - - { - list.remove(vector[2]); - list.remove(vector[3]); - - TestTableDelete::Delete del(interface.get()); - del.Where(Is(DPL::Optional::Null)); - del.Execute(); - - TestTableDelete::Select select(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match."); - } - - { - TestTableDelete::Delete del(interface.get()); - del.Execute(); - - TestTableDelete::Select select(interface.get()); - RUNNER_ASSERT_MSG(select.GetRowList().size() == 0, "Returned list is not empty"); - } - - // Restore original table state - // This also tests if multiple different binds for Insert are working properly - for (std::list::iterator i = originalList.begin(); i != originalList.end(); i++) - { - TestTableDelete::Insert insert(interface.get()); - insert.Values(*i); - insert.Execute(); - } - - { - TestTableDelete::Select select(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), originalList), "Returned list doesn't match."); - } - -} - -RUNNER_TEST(ORM_MultipleBindDelete) -{ - for ( int i = 0 ; i < TEST_REPETITION ; i++ ) - { - ORM_Delete(); - } -} - -RUNNER_TEST(ORM_MultipleBindWhere) -{ - SmartAttach interface; - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::dpl_orm_test; - { - TestTable::Select select(interface.get()); - int result; - select.Where(Equals(8)); - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 6, "Got " << result); - - select.Where(Equals(3)); - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 1, "Got " << result); - - select.Where(Equals(8)); - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 6, "Got " << result); - - select.Where(Equals(3)); - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 1, "Got " << result); - } - - { - TestTable::Select select(interface.get()); - int result; - select.Where(And(Equals(99), - Equals(L"fourteen"))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 13, "Got " << result); - - select.Where(And(Equals(99), - Equals(L"twelve"))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 11, "Got " << result); - - select.Where(And(Equals(99), - Equals(L"fourteen"))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 13, "Got " << result); - - select.Where(And(Equals(99), - Equals(L"twelve"))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 11, "Got " << result); - } - - { - TestTable::Select select(interface.get()); - int result; - select.Where(And(Equals(L"fourteen"), - Equals(99))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 13, "Got " << result); - - select.Where(And(Equals(L"twelve"), - Equals(99))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 11, "Got " << result); - - select.Where(And(Equals(L"fourteen"), - Equals(99))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 13, "Got " << result); - - select.Where(And(Equals(L"twelve"), - Equals(99))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 11, "Got " << result); - - } - -} - -RUNNER_TEST(ORM_Update) -{ - SmartAttach interface; - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::dpl_orm_test; - - std::list list; - - TestTableInsert::Delete del(interface.get()); - del.Execute(); - - // INSERT - { - TestTableInsert::Insert insert(interface.get()); - TestTableInsert::Row row; - row.Set_ColumnOptInt(5); - row.Set_ColumnInt2(2); - row.Set_ColumnText(L"two"); - insert.Values(row); - insert.Execute(); - - row.Set_ColumnInt(99); - list.push_back(row); - } - { - TestTableInsert::Insert insert(interface.get()); - TestTableInsert::Row row; - row.Set_ColumnOptInt(1); - row.Set_ColumnInt2(2); - row.Set_ColumnText(L"three"); - insert.Values(row); - insert.Execute(); - - row.Set_ColumnInt(99); - list.push_back(row); - } - { - TestTableInsert::Insert insert(interface.get()); - TestTableInsert::Row row; - row.Set_ColumnOptInt(2); - row.Set_ColumnInt2(3); - row.Set_ColumnText(L"three"); - insert.Values(row); - insert.Execute(); - - row.Set_ColumnInt(99); - list.push_back(row); - - // CHECK - TestTableInsert::Select select(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match."); - } - { - // UPDATE - no rows - TestTableInsert::Update update(interface.get()); - TestTableInsert::Row row; - row.Set_ColumnInt2(4); - row.Set_ColumnText(L"four"); - update.Values(row); - update.Where(Equals(12)); - update.Execute(); - - // CHECK - TestTableInsert::Select select(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match."); - } - { - // UPDATE - one row - TestTableInsert::Update update(interface.get()); - TestTableInsert::Row row; - row.Set_ColumnInt2(2); - row.Set_ColumnText(L"four"); - update.Values(row); - update.Where(Equals(3)); - update.Execute(); - - list.back().Set_ColumnInt2(2); - list.back().Set_ColumnText(L"four"); - - // CHECK - TestTableInsert::Select select(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match."); - } - - { - // UPDATE - multiple rows - TestTableInsert::Update update(interface.get()); - TestTableInsert::Row row; - row.Set_ColumnText(L"dup"); - update.Values(row); - update.Where(Equals(2)); - update.Execute(); - - FOREACH(it, list) - { - it->Set_ColumnText(L"dup"); - } - - // CHECK - TestTableInsert::Select select(interface.get()); - RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match."); - } - - // restore original table state - { - TestTableInsert::Delete del2(interface.get()); - del2.Execute(); - - TestTableInsert::Select select(interface.get()); - RUNNER_ASSERT(select.GetRowList().size() == 0); - } -} - -RUNNER_TEST(ORM_MultipleBindUpdate) -{ - for ( int i = 0 ; i < TEST_REPETITION ; i++ ) - { - ORM_Update(); - } -} - -RUNNER_TEST(ORM_transactions) -{ - SmartAttach interface; - DPL::DB::ORM::dpl_orm_test::ScopedTransaction transaction(interface.get()); -} - -RUNNER_TEST(ORM_MultiAttach) -{ - SmartAttach interface(false); - RUNNER_ASSERT_MSG(!interface.get()->IsAttached(), "Is attached, but shouldn't be."); - interface.get()->AttachToThread(); - RUNNER_ASSERT_MSG(interface.get()->IsAttached(), "Isn't attached, but should be."); - interface.get()->AttachToThread(); - RUNNER_ASSERT_MSG(interface.get()->IsAttached(), "Isn't attached, but should be."); - interface.get()->DetachFromThread(); - RUNNER_ASSERT_MSG(interface.get()->IsAttached(), "Isn't attached, but should be."); - interface.get()->DetachFromThread(); - RUNNER_ASSERT_MSG(!interface.get()->IsAttached(), "Is attached, but shouldn't be."); -} diff --git a/tests/db/test_sql_connection.cpp b/tests/db/test_sql_connection.cpp deleted file mode 100644 index 8dd3316..0000000 --- a/tests/db/test_sql_connection.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_sql_connection.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of sql connection tests - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -class AbstractSynchronizationObjectGenerator -{ -public: - virtual ~AbstractSynchronizationObjectGenerator() {} - - virtual DPL::DB::SqlConnection::SynchronizationObject *Create() = 0; -}; - -class NaiveSynchronizationObjectGenerator - : public AbstractSynchronizationObjectGenerator -{ -public: - virtual DPL::DB::SqlConnection::SynchronizationObject *Create() - { - return new DPL::DB::NaiveSynchronizationObject(); - } -}; - -void MassiveReadWriteTest(AbstractSynchronizationObjectGenerator *generator); - -class StressGenerator - : public DPL::Thread -{ -private: - size_t m_prefix; - std::string m_dbFileName; - AbstractSynchronizationObjectGenerator *m_generator; - -protected: - virtual int ThreadEntry() - { - DPL::DB::SqlConnection connection( - m_dbFileName, - DPL::DB::SqlConnection::Flag::None, - m_generator->Create()); - - DPL::DB::SqlConnection::DataCommandAutoPtr countCommand = - connection.PrepareDataCommand( - "SELECT COUNT(*) FROM test WHERE value=?"); - - for (size_t i = 0; i < 10; ++i) - { - std::ostringstream valueStream; - - valueStream << "value_"; - valueStream << static_cast(m_prefix); - valueStream << "_"; - valueStream << static_cast(i); - - std::string value = valueStream.str(); - - connection.ExecCommand( - "INSERT INTO test VALUES ('%s');", - value.c_str()); - - countCommand->BindString(1, value.c_str()); - - RUNNER_ASSERT(countCommand->Step()); - - RUNNER_ASSERT(countCommand->GetColumnString(0) == "1"); - - countCommand->Reset(); - } - - countCommand.reset(); - - return 0; - } - -public: - StressGenerator(size_t prefix, - const std::string &dbFileName, - AbstractSynchronizationObjectGenerator *generator) - : m_prefix(prefix), - m_dbFileName(dbFileName), - m_generator(generator) - { - } -}; - -typedef DPL::SharedPtr ThreadPtr; - -void MassiveReadWriteTest(AbstractSynchronizationObjectGenerator *generator) -{ - std::ostringstream dbFileNameStream; - dbFileNameStream << "/tmp/dpl_tests_db_"; - dbFileNameStream << rand() << ".db"; - - std::string dbFileName = dbFileNameStream.str(); - - LogDebug("Temporary database used: " << dbFileName); - - DPL::DB::SqlConnection connection(dbFileName); - connection.ExecCommand("BEGIN TRANSACTION;"); - connection.ExecCommand("CREATE TABLE test(value TEXT);"); - connection.ExecCommand("COMMIT;"); - - const size_t STRESS_GENERATOR_COUNT = 5; - ThreadPtr stressGenerators[STRESS_GENERATOR_COUNT]; - - for (size_t i = 0; i < STRESS_GENERATOR_COUNT; ++i) - { - stressGenerators[i].Reset( - new StressGenerator(i, dbFileName, generator)); - - stressGenerators[i]->Run(); - } - - for (size_t i = 0; i < STRESS_GENERATOR_COUNT; ++i) - stressGenerators[i]->Quit(); - - unlink(dbFileName.c_str()); -} - -RUNNER_TEST(SqlConnection_MassiveReadWrite_NaiveSynchronization) -{ - srand(time(NULL)); - - NaiveSynchronizationObjectGenerator m_generator; - MassiveReadWriteTest(&m_generator); -} diff --git a/tests/dbus/CMakeLists.txt b/tests/dbus/CMakeLists.txt deleted file mode 100644 index accd45a..0000000 --- a/tests/dbus/CMakeLists.txt +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) -# @version 1.0 -# @brief -# - -INCLUDE(FindPkgConfig) - -SET(TARGET_DBUS_TESTS "dpl-tests-dbus") -SET(TARGET_DBUS_TEST_SERVICE "dpl-dbus-test-service") - -PKG_CHECK_MODULES(DBUS_PKG - ecore - appcore-efl - gio-2.0 - gobject-2.0 - REQUIRED -) - -SET(DBUS_TESTS_SRCS - ${PROJECT_SOURCE_DIR}/tests/dbus/main.cpp - ${PROJECT_SOURCE_DIR}/tests/dbus/test_cases.cpp - ${PROJECT_SOURCE_DIR}/tests/dbus/dbus_test.cpp - ${PROJECT_SOURCE_DIR}/tests/dbus/loop_control.cpp -) - -SET(DBUS_TEST_SERVICE_SRCS - ${PROJECT_SOURCE_DIR}/tests/dbus/test_service.cpp - ${PROJECT_SOURCE_DIR}/tests/dbus/loop_control.cpp -) - -INCLUDE_DIRECTORIES( - ${DBUS_PKG_INCLUDE_DIRS} - ${DPL_TEST_INCLUDE_DIR} -) - -LINK_DIRECTORIES(${DBUS_PKG_LIBRARY_DIRS}) - -ADD_EXECUTABLE(${TARGET_DBUS_TESTS} - ${DBUS_TESTS_SRCS} -) - -TARGET_LINK_LIBRARIES(${TARGET_DBUS_TESTS} - ${DBUS_PKG_LIBRARIES} - ${TARGET_DPL_EFL} - ${TARGET_DPL_DBUS_EFL} - ${TARGET_DPL_TEST_ENGINE_EFL} -) - -SET_TARGET_PROPERTIES(${TARGET_DBUS_TESTS} PROPERTIES - BUILD_WITH_INSTALL_RPATH ON - INSTALL_RPATH_USE_LINK_PATH ON -) - -ADD_EXECUTABLE(${TARGET_DBUS_TEST_SERVICE} - ${DBUS_TEST_SERVICE_SRCS} -) - -TARGET_LINK_LIBRARIES(${TARGET_DBUS_TEST_SERVICE} - ${DBUS_PKG_LIBRARIES} - ${TARGET_DPL_EFL} - ${TARGET_DPL_DBUS_EFL} -) - -SET_TARGET_PROPERTIES(${TARGET_DBUS_TEST_SERVICE} PROPERTIES - BUILD_WITH_INSTALL_RPATH ON - INSTALL_RPATH_USE_LINK_PATH ON -) - -INSTALL(TARGETS ${TARGET_DBUS_TESTS} ${TARGET_DBUS_TEST_SERVICE} - DESTINATION bin - PERMISSIONS OWNER_READ - OWNER_WRITE - OWNER_EXECUTE - GROUP_READ - GROUP_EXECUTE - WORLD_READ - WORLD_EXECUTE -) - -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/dbus/data/org.tizen.DBusTestService.service - DESTINATION /usr/share/dbus-1/services -) diff --git a/tests/dbus/data/org.tizen.DBusTestService.service b/tests/dbus/data/org.tizen.DBusTestService.service deleted file mode 100644 index f024543..0000000 --- a/tests/dbus/data/org.tizen.DBusTestService.service +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.tizen.DBusTestService -Exec=/usr/bin/dpl-dbus-test-service diff --git a/tests/dbus/dbus_test.cpp b/tests/dbus/dbus_test.cpp deleted file mode 100644 index 6071f9f..0000000 --- a/tests/dbus/dbus_test.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file dbus_test.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @brief Implementation file for DBusTest and DBusTestManager. - */ - -#include -#include "loop_control.h" -#include "dbus_test.h" - -DBusTest::DBusTest(const std::string& name) - : m_name(name), - m_status(Status::NONE) -{ -} - -void DBusTest::run(unsigned int timeout) -{ - DPL::Event::ControllerEventHandler::Touch(); - DPL::Event::ControllerEventHandler::Touch(); - - DPL::Event::ControllerEventHandler::PostTimedEvent( - TimeoutEvent(), timeout); - - LoopControl::wrt_start_loop(); - - switch (m_status) - { - case Status::FAILED: - throw DPL::Test::TestRunner::TestFailed(m_name.c_str(), - __FILE__, - __LINE__, - m_message); - - default: - break; - } -} - -void DBusTest::quit() -{ - DPL::Event::ControllerEventHandler::PostEvent(QuitEvent()); -} - -void DBusTest::setStatus(Status status) -{ - m_status = status; -} - -void DBusTest::setMessage(const std::string& message) -{ - m_message = message; -} - -void DBusTest::success() -{ - m_status = Status::SUCCESS; -} - -void DBusTest::fail(const std::string& message) -{ - m_status = Status::FAILED; - m_message = message; -} - -void DBusTest::OnEventReceived(const TimeoutEvent& /*event*/) -{ - fail("Test timed out."); - - // Saving one event dispatch since Quit and Timeout work on the same thread. - LoopControl::wrt_end_loop(); -} - -void DBusTest::OnEventReceived(const QuitEvent& /*event*/) -{ - LoopControl::wrt_end_loop(); -} - -DBusTestManager& DBusTestManager::getInstance() -{ - static DBusTestManager instance; - return instance; -} - -DBusTestManager::DBusTestManager() : m_test(NULL) { } - -DBusTest& DBusTestManager::getCurrentTest() const -{ - Assert(NULL != m_test && "Test not set."); - - return *m_test; -} - -void DBusTestManager::setCurrentTest(DBusTest& test) -{ - m_test = &test; -} - -void DBusTestManager::clear() -{ - m_test = NULL; -} diff --git a/tests/dbus/dbus_test.h b/tests/dbus/dbus_test.h deleted file mode 100644 index 9b5061e..0000000 --- a/tests/dbus/dbus_test.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file dbus_test.h - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @brief Header file for DBusTest and DBusTestManager. - */ - -#ifndef WRT_TESTS_DBUS_TESTS_DBUS_TEST_H -#define WRT_TESTS_DBUS_TESTS_DBUS_TEST_H - -#include -#include -#include - -DECLARE_GENERIC_EVENT_0(QuitEvent) -DECLARE_GENERIC_EVENT_0(TimeoutEvent) - -class DBusTest : - private DPL::Event::Controller::Type> -{ -public: - enum class Status - { - NONE, - SUCCESS, - FAILED - }; - - explicit DBusTest(const std::string& name); - - void run(unsigned int timeout); - void quit(); - - void setStatus(Status status); - void setMessage(const std::string& message); - - void success(); - void fail(const std::string& message = std::string()); - -private: - void OnEventReceived(const TimeoutEvent& event); - void OnEventReceived(const QuitEvent& event); - - std::string m_name; - Status m_status; - std::string m_message; -}; - -class DBusTestManager : private DPL::Noncopyable -{ -public: - static DBusTestManager& getInstance(); - - DBusTest& getCurrentTest() const; - void setCurrentTest(DBusTest& test); - - void clear(); - -private: - DBusTestManager(); - - DBusTest* m_test; -}; - -#define DBUS_TEST(TestProc) \ - void DBus##TestProc(); \ - RUNNER_TEST(TestProc) \ - { \ - DBusTest test(#TestProc); \ - DBusTestManager::getInstance().setCurrentTest(test); \ - DBus##TestProc(); \ - DBusTestManager::getInstance().clear(); \ - } \ - void DBus##TestProc() - -#endif diff --git a/tests/dbus/loop_control.cpp b/tests/dbus/loop_control.cpp deleted file mode 100644 index c6c250e..0000000 --- a/tests/dbus/loop_control.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file loop_control.cpp - * @author Jaroslaw Osmanski (j.osmanski@samsung.com) - * @version 1.0 - * @brief This is implementation of EFL version of loop control - */ - -#include "loop_control.h" -#include - -#include - -#include -#include - - -namespace LoopControl -{ -void init_loop(int argc, char *argv[]) -{ - (void)argc; - (void)argv; - g_type_init(); - g_thread_init(NULL); - - LogInfo("Starting"); - elm_init(argc, argv); -} - -void wait_for_wrt_init() -{ - ecore_main_loop_begin(); -} - -void finish_wait_for_wrt_init() -{ - ecore_main_loop_quit(); -} - -void quit_loop() -{ - elm_shutdown(); -} - -void wrt_start_loop() -{ - ecore_main_loop_begin(); -} - -void wrt_end_loop() -{ - ecore_main_loop_quit(); -} - -void *abstract_window() -{ - return elm_win_add(NULL, "hello", ELM_WIN_BASIC); -} - -}//end of LoopControl namespace diff --git a/tests/dbus/loop_control.h b/tests/dbus/loop_control.h deleted file mode 100644 index 30aa6e8..0000000 --- a/tests/dbus/loop_control.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file loop_control.cpp - * @author Jaroslaw Osmanski (j.osmanski@samsung.com) - * @version 1.0 - * @brief This file is the definitions of loop controlling utilities - */ - - -#ifndef LOOP_CONTROL_H_ -#define LOOP_CONTROL_H_ - -namespace LoopControl -{ - -void init_loop(int argc, char *argv[]); -void wait_for_wrt_init(); -void finish_wait_for_wrt_init(); -void quit_loop(); - -void wrt_start_loop(); -void wrt_end_loop(); - -void *abstract_window(); - -} - -#endif /* LOOP_CONTROL_H_ */ diff --git a/tests/dbus/main.cpp b/tests/dbus/main.cpp deleted file mode 100644 index b6bd681..0000000 --- a/tests/dbus/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file main.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of main. - */ - -#include "loop_control.h" -#include -#include - -int main(int argc, char *argv[]) -{ - LoopControl::init_loop(argc, argv); - - LogInfo("Running tests..."); - int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); - - return status; -} diff --git a/tests/dbus/test_cases.cpp b/tests/dbus/test_cases.cpp deleted file mode 100644 index fe0f9c1..0000000 --- a/tests/dbus/test_cases.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file TestCases.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @version 1.0 - * @brief Implementation file for test cases for DBus internal tests. - */ - -#include -#include -#include -#include -#include -#include -#include "dbus_test.h" - -namespace { -const std::string dbusServiceName = "org.freedesktop.DBus"; -const std::string dbusObjectPath = "/"; -const std::string dbusInterfaceName = "org.freedesktop.DBus"; -const std::string dbusMethodGetId = "GetId"; - -const std::string serviceName = "org.tizen.DBusTestService"; -const std::string objectPath = "/org/tizen/DBusTestService"; -const std::string interfaceName = "org.tizen.DBusTestService"; -const std::string methodNameEcho = "echo"; -const std::string methodNameQuit = "quit"; -const std::string nodeInfo = - "" - "" - " " - " " - " " - " " - " " - " " - " " - " " - ""; - -const std::string challenge = "Hello world!"; - -const int DEFAULT_TIMEOUT = 2; // in seconds -} - -RUNNER_TEST(AcquireSessionBus) -{ - try - { - DPL::DBus::Connection::sessionBus(); - } - catch (const DPL::DBus::Exception& ex) - { - RUNNER_ASSERT_MSG(false, ex.DumpToString()); - } -} - -RUNNER_TEST(AcquireSystemBus) -{ - try - { - DPL::DBus::Connection::systemBus(); - } - catch (const DPL::DBus::Exception& ex) - { - RUNNER_ASSERT_MSG(false, ex.DumpToString()); - } -} - -RUNNER_TEST(ParseNodeInfo) -{ - try - { - auto ifaces = DPL::DBus::Interface::fromXMLString(nodeInfo); - RUNNER_ASSERT(!ifaces.empty()); - - auto iface = ifaces.at(0); - RUNNER_ASSERT(NULL != iface->getVTable()); - RUNNER_ASSERT(NULL != iface->getInfo()); - } - catch (const DPL::DBus::Exception& ex) - { - RUNNER_ASSERT_MSG(false, ex.DumpToString()); - } -} - -RUNNER_TEST(InvokeRemoteMethod) -{ - try - { - auto connection = DPL::DBus::Connection::systemBus(); - auto freedesktop = connection->createObjectProxy(dbusServiceName, - dbusObjectPath); - auto getId = freedesktop->createMethodProxy - (dbusInterfaceName, dbusMethodGetId); - RUNNER_ASSERT(!getId().empty()); - } - catch (const DPL::DBus::Exception& ex) - { - RUNNER_ASSERT_MSG(false, ex.DumpToString()); - } -} - -class RegisterServiceListener : - public DPL::Event::EventListener -{ -public: - void OnEventReceived( - const DPL::DBus::ConnectionEvents::ServiceNameAcquiredEvent& event) - { - DBusTest& test = DBusTestManager::getInstance().getCurrentTest(); - - auto name = event.GetArg0(); - if (serviceName == name) - { - test.success(); - } - else - { - test.fail("Acquired service name: " + name); - } - test.quit(); - } -}; - -DBUS_TEST(RegisterService) -{ - try - { - RegisterServiceListener listener; - - auto connection = DPL::DBus::Connection::sessionBus(); - connection->DPL::Event::EventSupport::AddListener(&listener); - connection->registerService(serviceName); - - DBusTestManager::getInstance().getCurrentTest().run(DEFAULT_TIMEOUT); - } - catch (const DPL::DBus::Exception& ex) - { - RUNNER_ASSERT_MSG(false, ex.DumpToString()); - } -} - -/** - * This test checks: - * - object registration (done on the wrt-dbus-test-service side) - * - service registration (done on the wrt-dbus-test-service side) - * - dispatching method calls (done on the wrt-dbus-test-service side) - * - launching dbus service on demand - * - invoking remote method(s) - */ -DBUS_TEST(InvokeTestService) -{ - try - { - auto connection = DPL::DBus::Connection::sessionBus(); - auto testService = connection->createObjectProxy(serviceName, - objectPath); - auto echo = testService->createMethodProxy - (interfaceName, methodNameEcho); - auto response = echo(challenge); - - testService->createMethodProxy(interfaceName, methodNameQuit)(); - - RUNNER_ASSERT_MSG(response == challenge, - "[challenge = " << challenge << - ", response = " << response << "]"); - } - catch (const DPL::DBus::Exception& ex) - { - RUNNER_ASSERT_MSG(false, ex.DumpToString()); - } -} diff --git a/tests/dbus/test_service.cpp b/tests/dbus/test_service.cpp deleted file mode 100644 index 63e32fb..0000000 --- a/tests/dbus/test_service.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file test_service.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @brief Implementation file for wrt-dbus-test-service. - */ - -#include -#include -#include -#include -#include -#include "loop_control.h" - -namespace { -const std::string serviceName = "org.tizen.DBusTestService"; -const std::string objectPath = "/org/tizen/DBusTestService"; -const std::string interfaceName = "org.tizen.DBusTestService"; -const std::string methodNameEcho = "echo"; -const std::string methodNameQuit = "quit"; -const std::string nodeInfo = - "" - "" - " " - " " - " " - " " - " " - " " - " " - " " - ""; -} - -class TestServiceDispatcher : public DPL::DBus::Dispatcher -{ -private: - void onMethodCall(GDBusConnection* /*connection*/, - const gchar* /*sender*/, - const gchar* /*objectPath*/, - const gchar* /*interfaceName*/, - const gchar* methodName, - GVariant* parameters, - GDBusMethodInvocation* invocation) - { - if (methodNameEcho == methodName) - { - LogDebug("Echo"); - g_dbus_method_invocation_return_value(invocation, - parameters); - } - else if (methodNameQuit == methodName) - { - LogDebug("Quit"); - g_dbus_method_invocation_return_value(invocation, NULL); - LoopControl::wrt_end_loop(); - } - } -}; - -int main(int argc, char* argv[]) -{ - LoopControl::init_loop(argc, argv); - - TestServiceDispatcher dispatcher; - - auto iface = DPL::DBus::Interface::fromXMLString(nodeInfo).at(0); - iface->setDispatcher(&dispatcher); - - auto object = DPL::DBus::Object::create(objectPath, iface); - - auto connection = DPL::DBus::Connection::sessionBus(); - connection->registerObject(object); - connection->registerService(serviceName); - - LoopControl::wrt_start_loop(); - - return 0; -} diff --git a/tests/event/CMakeLists.txt b/tests/event/CMakeLists.txt deleted file mode 100644 index 5be052c..0000000 --- a/tests/event/CMakeLists.txt +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Lukasz Marek (l.marek@samsung.com) -# @version 1.0 -# @brief -# - -# -# Test files -# -# Define all DPL tests sources. -# Runner is responsible for runnint it all and -# generating proper output files -# - -SET(TARGET_NAME "dpl-tests-event") - -# Set DPL tests sources -SET(DPL_TESTS_SOURCES - ${PROJECT_SOURCE_DIR}/tests/event/main.cpp - ${PROJECT_SOURCE_DIR}/tests/event/test_controller.cpp - ${PROJECT_SOURCE_DIR}/tests/event/test_event_support.cpp - ${PROJECT_SOURCE_DIR}/tests/event/test_ic_delegate.cpp - ${PROJECT_SOURCE_DIR}/tests/event/test_property.cpp -) - -INCLUDE_DIRECTORIES( - ${SYS_EFL_INCLUDE_DIRS} - ${DPL_TEST_INCLUDE_DIR} -) - -LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS}) - -ADD_EXECUTABLE(${TARGET_NAME} ${DPL_TESTS_SOURCES}) - -TARGET_LINK_LIBRARIES( - ${TARGET_NAME} - ${TARGET_DPL_EFL} - ${TARGET_DPL_EVENT_EFL} - ${TARGET_DPL_TEST_ENGINE_EFL} -) - -SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - BUILD_WITH_INSTALL_RPATH ON - INSTALL_RPATH_USE_LINK_PATH ON -) - -INSTALL(TARGETS ${TARGET_NAME} - DESTINATION bin - PERMISSIONS OWNER_READ - OWNER_WRITE - OWNER_EXECUTE - GROUP_READ - GROUP_EXECUTE - WORLD_READ - WORLD_EXECUTE -) \ No newline at end of file diff --git a/tests/event/main.cpp b/tests/event/main.cpp deleted file mode 100644 index 4ed6191..0000000 --- a/tests/event/main.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file main.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of main. - */ - -#include - -int main(int argc, char *argv[]) -{ - return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); -} diff --git a/tests/event/test_controller.cpp b/tests/event/test_controller.cpp deleted file mode 100644 index 33bb631..0000000 --- a/tests/event/test_controller.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_controller.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test controller - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -RUNNER_TEST_GROUP_INIT(DPL) - -class IntController - : public DPL::Event::Controller::Type> -{ -private: - int m_value; - -protected: - virtual void OnEventReceived(const int &event) - { - m_value = event; - } - -public: - IntController() - : m_value(-1) - { - } - - int Value() const - { - return m_value; - } -}; - -DECLARE_GENERIC_EVENT_1(DoneSignalEvent, DPL::WaitableEvent *) - -class ThreadController - : public DPL::Event::Controller::Type> -{ -private: - DPL::Thread *m_value; - -protected: - virtual void OnEventReceived(const DoneSignalEvent &event) - { - m_value = DPL::Thread::GetCurrentThread(); - event.GetArg0()->Signal(); - } - -public: - ThreadController() - : m_value(NULL) - { - } - - DPL::Thread *Value() const - { - return m_value; - } -}; - -struct StrangeStruct -{ - int a; - float b; - double c; -}; - -class StrangeController - : public DPL::Event::Controller::Type> -{ -protected: - virtual void OnEventReceived(const char &event) { (void)event; } - virtual void OnEventReceived(const short &event) { (void)event; } - virtual void OnEventReceived(const int &event) { (void)event; } - virtual void OnEventReceived(const long &event) { (void)event; } - virtual void OnEventReceived(const unsigned char &event) { (void)event; } - virtual void OnEventReceived(const unsigned short &event) { (void)event; } - virtual void OnEventReceived(const unsigned int &event) { (void)event; } - virtual void OnEventReceived(const unsigned long &event) { (void)event; } - virtual void OnEventReceived(const float &event) { (void)event; } - virtual void OnEventReceived(const double &event) { (void)event; } - virtual void OnEventReceived(const StrangeStruct &event) { (void)event; } -}; - -RUNNER_TEST(Controller_InitSimple) -{ - IntController controller; - controller.Touch(); - RUNNER_ASSERT(controller.Value() == -1); -} - -RUNNER_TEST(Controller_InitStrange) -{ - StrangeController controller; - controller.Touch(); -} - -RUNNER_TEST(Controller_PostEventToThread) -{ - ThreadController controller; - controller.Touch(); - - DPL::Thread thread; - thread.Run(); - - controller.SwitchToThread(&thread); - - DPL::WaitableEvent waitHandle; - - controller.PostEvent(DoneSignalEvent(&waitHandle)); - - DPL::WaitForSingleHandle(waitHandle.GetHandle()); - - controller.SwitchToThread(NULL); - - RUNNER_ASSERT(controller.Value() == &thread); -} - -RUNNER_TEST(Controller_PostTimedEventToThread) -{ - ThreadController controller; - controller.Touch(); - - DPL::Thread thread; - thread.Run(); - - controller.SwitchToThread(&thread); - - DPL::WaitableEvent waitHandle; - - controller.PostTimedEvent(DoneSignalEvent(&waitHandle), 0.5); - - DPL::WaitForSingleHandle(waitHandle.GetHandle()); - - controller.SwitchToThread(NULL); - - RUNNER_ASSERT(controller.Value() == &thread); -} - -DECLARE_GENERIC_EVENT_2(TouchInThread, DPL::WaitableEvent *, DPL::Thread **) -DECLARE_GENERIC_EVENT_2(TouchedControllerSignal, DPL::WaitableEvent *, DPL::Thread **) - -class TouchInThreadController - : public DPL::Event::Controller::Type>, - private DPL::Event::Controller::Type> -{ -public: - typedef DPL::Event::Controller::Type> PublicController; - typedef DPL::Event::Controller::Type> PrivateController; - - virtual void OnEventReceived(const TouchInThread &event) - { - // Touch controller in thread - PrivateController::Touch(); - - // Post signal - PrivateController::PostEvent(TouchedControllerSignal(event.GetArg0(), event.GetArg1())); - } - - virtual void OnEventReceived(const TouchedControllerSignal &event) - { - // Return touched thread - *event.GetArg1() = DPL::Thread::GetCurrentThread(); - - // Signal waitable event - event.GetArg0()->Signal(); - } -}; - -RUNNER_TEST(Controller_TouchInThread) -{ - TouchInThreadController controller; - controller.PublicController::Touch(); - - DPL::Thread thread; - thread.Run(); - - controller.PublicController::SwitchToThread(&thread); - - DPL::WaitableEvent waitHandle; - DPL::Thread *touchedThread = NULL; - - controller.PublicController::PostEvent(TouchInThread(&waitHandle, &touchedThread)); - - DPL::WaitForSingleHandle(waitHandle.GetHandle()); - - controller.PublicController::SwitchToThread(NULL); - - RUNNER_ASSERT(touchedThread == &thread); -} - -RUNNER_TEST(Controller_SynchronizedEvent) -{ - IntController controller; - controller.Touch(); - - DPL::Thread thread; - thread.Run(); - - controller.SwitchToThread(&thread); - controller.PostSyncEvent(12345); - controller.SwitchToThread(NULL); - - RUNNER_ASSERT(controller.Value() == 12345); -} - -const int ControllersNumber = 5; -const int MaxEventsPerController = 1; -const int MaxEvents = ControllersNumber * MaxEventsPerController; -const int ControllersPerThread = 1; - -class TestController; //Forward Declaration - -typedef DPL::SharedPtr ControllerPtr; -typedef DPL::SharedPtr ThreadPtr; -typedef std::vector ControllerList; -typedef std::list ThreadList; - -DECLARE_GENERIC_EVENT_0(QuitEvent) -class QuitController - : public DPL::Event::Controller::Type>, - public DPL::ApplicationExt -{ -public: - explicit QuitController( ) : DPL::ApplicationExt(1, NULL, "test-app") { Touch(); } -protected: - virtual void OnEventReceived(const QuitEvent &) { Quit(); } -}; - -struct TestContext -{ - ControllerList controllers; - ThreadList threads; - QuitController quitter; - DPL::Atomic g_ReceivedCounter; - DPL::Atomic g_SentCounter; -}; -typedef DPL::ScopedPtr TestContextPtr; -TestContextPtr testContextPtr; - -DECLARE_GENERIC_EVENT_0(StartSendEvent) -DECLARE_GENERIC_EVENT_0(RandomEvent) -class TestController - : public DPL::Event::Controller::Type> -{ -public: - explicit TestController() { Touch(); } -protected: - virtual void OnEventReceived(const RandomEvent &) - { - ++testContextPtr->g_ReceivedCounter; - if(testContextPtr->g_ReceivedCounter == MaxEvents) - { - testContextPtr->quitter.DPL::Event::ControllerEventHandler::PostEvent(QuitEvent()); - return; - } - } - virtual void OnEventReceived(const StartSendEvent &) - { - for (int i=0 ; ig_SentCounter > MaxEvents) - { - return; - } - ++testContextPtr->g_SentCounter; - int id = rand() % static_cast(testContextPtr->controllers.size()); - testContextPtr->controllers.at(id)->DPL::Event::ControllerEventHandler::PostEvent(RandomEvent()); - } - } -}; - -RUNNER_TEST(Controllers_MultipleEvents) -{ - srand ( time(NULL) ); - - testContextPtr.Reset(new TestContext()); - testContextPtr->controllers.reserve(ControllersNumber); - - for (int i = 0; i < ControllersNumber ; ++i) - { - if(testContextPtr->controllers.size() % ControllersPerThread ==0) - { - ThreadPtr thread = ThreadPtr(new DPL::Thread()); - testContextPtr->threads.push_back(thread); - thread->Run(); - } - - ControllerPtr controller = ControllerPtr(new TestController()); - testContextPtr->controllers.push_back(controller); - if(testContextPtr->controllers.size() % 2 == 0) - { - //This controller is being switched to thread (otherwise it is touched to main thread) - ThreadPtr thread = testContextPtr->threads.back(); - controller->SwitchToThread(thread.Get()); - } - controller->DPL::Event::ControllerEventHandler::PostEvent(StartSendEvent()); - } - testContextPtr->quitter.Exec(); - RUNNER_ASSERT(testContextPtr->g_SentCounter == testContextPtr->g_ReceivedCounter); - testContextPtr.Reset(); -} diff --git a/tests/event/test_event_support.cpp b/tests/event/test_event_support.cpp deleted file mode 100644 index af303f0..0000000 --- a/tests/event/test_event_support.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_event_support.cpp - * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com) - * @author Pawel Sikorski (p.sikorski@samsung.com) - * @version 1.0 - * @brief This file contains test for event support - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -DECLARE_GENERIC_EVENT_0(TestEvent) - -class TestListener: public DPL::Event::EventListener -{ -public: - explicit TestListener() : m_dummyVar(0) { } - void OnEventReceived(const TestEvent &) { m_dummyVar = 1; } - int GetDummyVar() const { return m_dummyVar; } - void ZeroDummyVar() { m_dummyVar = 0; } - -private: - int m_dummyVar; -}; - -class TestEventSupport - : public DPL::Event::EventSupport -{ -public: - void TestEmitEvent() { EmitEvent(TestEvent()); } -}; - -DECLARE_GENERIC_EVENT_0(QuitEvent) - -class QuitController - : public DPL::Event::Controller::Type>, - public DPL::ApplicationExt -{ -public: - QuitController() : DPL::ApplicationExt(1, NULL, "test-app") { Touch(); } - -protected: - virtual void OnEventReceived(const QuitEvent &) { Quit(); } -}; - -RUNNER_TEST(EventSupport_DestroyBeforeProcessing) -{ - QuitController quitter; - quitter.PostTimedEvent(QuitEvent(), 1.0); - - TestListener eventListener; - { - TestEventSupport eventSupport; - eventSupport.AddListener(&eventListener); - eventSupport.TestEmitEvent(); - eventSupport.RemoveListener(&eventListener); - } - eventListener.ZeroDummyVar(); - - quitter.Exec(); - RUNNER_ASSERT(eventListener.GetDummyVar() == 0); -} - -int g_delegateTest; - -void OnDelegateTest(const int &k); - -void OnDelegateTest(const int &k) -{ - LogInfo("Got delegate call"); - g_delegateTest = k; -} - -class DelegateTestSupport - : public DPL::Event::EventSupport -{ -public: - void Test() - { - EmitEvent(7); - } -}; - -RUNNER_TEST(EventSupport_BindDelegate) -{ - g_delegateTest = 0; - - DelegateTestSupport support; - support.AddListener(&OnDelegateTest); - - QuitController quitter; - quitter.PostTimedEvent(QuitEvent(), 1.0); - - support.Test(); - - quitter.Exec(); - - support.RemoveListener(&OnDelegateTest); - - RUNNER_ASSERT(g_delegateTest == 7); -} diff --git a/tests/event/test_ic_delegate.cpp b/tests/event/test_ic_delegate.cpp deleted file mode 100644 index 60a5686..0000000 --- a/tests/event/test_ic_delegate.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_ic_delegate.cpp - * @author Pawel Sikorski (p.sikorski@samsung.com) - * @author Lukasz Wrzosek (l.wrzosek@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of fast delegate tests. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -const int IntVal = 123; -const std::string StringVal = "someString"; - -typedef DPL::Event::ICDelegate<> GetNothingDlpType; -typedef DPL::Event::ICDelegate GetIntDlgType; -typedef DPL::Event::ICDelegate GetIntAndStringDlgType; -DECLARE_GENERIC_EVENT_1(GetNothingEvent, GetNothingDlpType) -DECLARE_GENERIC_EVENT_1(GetIntEvent, GetIntDlgType) -DECLARE_GENERIC_EVENT_1(GetIntAndStringEvent, GetIntAndStringDlgType) - -class ICTestController -: public DPL::Event::Controller::Type> -{ - public: - ICTestController() { } - - protected: - virtual void OnEventReceived(const GetNothingEvent& event) - { - event.GetArg0()(); //calling intercontext delegate - } - virtual void OnEventReceived(const GetIntEvent& event) - { - event.GetArg0()(IntVal); //calling intercontext delegate - } - - virtual void OnEventReceived(const GetIntAndStringEvent& event) - { - event.GetArg0()(IntVal, StringVal); //calling intercontext delegate - } -}; - -struct TestResult -{ - TestResult() : - m_correctThread0(false), - m_correctThread1(false), - m_correctThread2(false), - m_int(-1), - m_int2(-1), - m_string("") - { - } - - void TestEventsPassed() - { - RUNNER_ASSERT(m_correctThread0); - RUNNER_ASSERT(m_correctThread1); - RUNNER_ASSERT(m_int == IntVal); - RUNNER_ASSERT(m_correctThread2); - RUNNER_ASSERT(m_int2 == IntVal); - RUNNER_ASSERT(m_string == StringVal); - } - - void TestEventsDidNotPass() - { - RUNNER_ASSERT(!m_correctThread0); - RUNNER_ASSERT(!m_correctThread1); - RUNNER_ASSERT(m_int == -1); - RUNNER_ASSERT(!m_correctThread2); - RUNNER_ASSERT(m_int2 == -1); - RUNNER_ASSERT(m_string == ""); - } - - bool m_correctThread0; - bool m_correctThread1; - bool m_correctThread2; - int m_int; - int m_int2; - std::string m_string; -}; - -class TestContextFreeClass : - protected DPL::Thread, - public DPL::Event::ICDelegateSupport -{ - public: - TestContextFreeClass(ICTestController* controller, TestResult* result) : - Thread(), - m_testResult(result), - m_controller(controller) - { - LogDebug("Context thread id = " << this); - } - - void Run() - { - LogDebug("Running Context Free thread"); - Thread::Run(); - } - - void Quit() - { - LogDebug("Exiting Context Free thread"); - Thread::Quit(); - } - - - void Wait() - { - LogDebug("Waiting for thread"); - DPL::WaitForSingleHandle(m_waitable.GetHandle()); - } - - protected: - void OnNothing() - { - LogDebug("Received nothing in thread = " << GetCurrentThread()); - m_testResult->m_correctThread0 = (GetCurrentThread() == this); - } - - void OnIntReceive(int val) - { - LogDebug("Received int in thread = " << GetCurrentThread()); - m_testResult->m_correctThread1 = (GetCurrentThread() == this); - m_testResult->m_int = val; - } - - void OnIntAndStringReceive(int val, std::string stringval) - { - LogDebug("Received int and string in thread = " << GetCurrentThread()); - m_testResult->m_correctThread2 = (GetCurrentThread() == this); - m_testResult->m_int2 = val; - m_testResult->m_string = stringval; - m_waitable.Signal(); - } - - virtual int ThreadEntry() - { - GetNothingEvent getNothingEvent( - makeICDelegate( - &TestContextFreeClass::OnNothing)); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - getNothingEvent); - - GetIntEvent getIntEvent( - makeICDelegate( - &TestContextFreeClass::OnIntReceive)); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - getIntEvent); - - GetIntAndStringEvent getIntAndStringEvent( - makeICDelegate( - &TestContextFreeClass::OnIntAndStringReceive)); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - getIntAndStringEvent); - - return Thread::ThreadEntry(); - } - - private: - TestResult* m_testResult; - DPL::WaitableEvent m_waitable; - ICTestController* m_controller; -}; - -RUNNER_TEST(ICDelegate_0) -{ - DPL::Thread thread; - thread.Run(); - LogDebug("Controller thread id = " << &thread); - - ICTestController testController; - testController.Touch(); - testController.SwitchToThread(&thread); - - TestResult result; - TestContextFreeClass* contextFree = - new TestContextFreeClass(&testController, &result); - result.TestEventsDidNotPass(); - - thread.Run(); - contextFree->Run(); - contextFree->Wait(); - contextFree->Quit(); - thread.Quit(); - - delete contextFree; - - result.TestEventsPassed(); -} - -RUNNER_TEST(ICDelegate_1) -{ - DPL::Thread thread; - LogDebug("Controller thread id = " << &thread); - - ICTestController testController; - testController.Touch(); - testController.SwitchToThread(&thread); - - TestResult result; - TestContextFreeClass* contextFree = - new TestContextFreeClass(&testController, &result); - result.TestEventsDidNotPass(); - - contextFree->Run(); - contextFree->Quit(); - delete contextFree; //deleting Delegates before actual Events are worked out - thread.Run(); - thread.Quit(); - - result.TestEventsDidNotPass(); -} - -class TestContextFree; -class TestRunnerInThread; - -namespace -{ -const int ControllersPerThread = 40; -const int ContextFreePerThread = 180; -const int TestsPerController = 110; -const int TestThreads = 23; -const int TestsPerThread = 100; -const int NumberOfEvents = 230; - -typedef DPL::SharedPtr ICTestControllerPtr; -typedef DPL::SharedPtr TestContextFreePtr; -typedef DPL::SharedPtr TestRunnerInThreadPtr; -typedef DPL::SharedPtr ThreadPtr; - -DPL::Mutex mutex; -std::list frees; -std::list ctrls; -std::list frees_threads; -std::list ctrls_threads; - -} - -class TestContextFree : public DPL::Event::ICDelegateSupport -{ - public: - TestContextFree(ICTestController* controller, - int eventsCount) : - m_controller(controller), - m_eventsCount(eventsCount) - { - } - - void Wait() - { - LogDebug("Waiting for thread"); - DPL::WaitForSingleHandle(m_waitable.GetHandle()); - } - - - void OnNothing() - { - LogDebug("Got"); - m_eventsCount--; - if (m_eventsCount > 0) { - LogDebug("posting next event"); - GetIntAndStringEvent getIntAndStringEvent( - makeICDelegate( - &TestContextFree::OnIntAndStringReceive)); - LogDebug("posting next event ..."); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - getIntAndStringEvent); - LogDebug("posting next event done"); - } else { - LogDebug("test finished"); - m_waitable.Signal(); - } - } - - void OnIntReceive(int) - { - LogDebug("Got"); - m_eventsCount--; - if (m_eventsCount > 0) { - LogDebug("posting next event"); - GetNothingEvent getNothingEvent( - makeICDelegate( - &TestContextFree::OnNothing)); - LogDebug("posting next event ..."); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - getNothingEvent); - LogDebug("posting next event done"); - } else { - LogDebug("test finished"); - m_waitable.Signal(); - } - } - - void OnIntAndStringReceive(int, std::string) - { - LogDebug("Got"); - m_eventsCount--; - if (m_eventsCount > 0) { - LogDebug("posting next event"); - - GetIntEvent getIntEvent( - makeICDelegate( - &TestContextFree::OnIntReceive)); - LogDebug("posting next event ..."); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - getIntEvent); - LogDebug("posting next event done"); - } else { - LogDebug("test finished"); - m_waitable.Signal(); - } - } - - void StartTestOnNothing() - { - GetNothingEvent getNothingEvent( - makeICDelegate( - &TestContextFree::OnNothing)); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - getNothingEvent); - } - - void StartTestOnInt() - { - GetIntEvent getIntEvent( - makeICDelegate( - &TestContextFree::OnIntReceive)); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - getIntEvent); - } - - void StartTestOnIntAndString() - { - GetIntAndStringEvent getIntAndStringEvent( - makeICDelegate( - &TestContextFree::OnIntAndStringReceive)); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - getIntAndStringEvent); - } - - bool CheckTest() - { - LogDebug("Checking test result"); - return m_eventsCount == 0; - } - - private: - ICTestController* m_controller; - int m_eventsCount; - DPL::WaitableEvent m_waitable; -}; - -class TestRunnerInThread : public DPL::Thread -{ - public: - TestRunnerInThread(int events, int tests) : - m_eventsCount(events), - m_tests(tests) {} - - void WaitForInit() - { - LogDebug("Waiting for thread"); - DPL::WaitForSingleHandle(m_init.GetHandle()); - } - - protected: - virtual int ThreadEntry() - { - LogDebug("Thread starts"); - { - DPL::Mutex::ScopedLock lock(&mutex); - for (int i = 0; i < m_tests; ++i) - { - if (i % TestsPerController == 0) { - if (ctrls.size() % ControllersPerThread == 0) { - ThreadPtr thread(new DPL::Thread()); - thread->Run(); - ctrls_threads.push_back(thread); - } - ICTestControllerPtr ptr(new ICTestController()); - ptr->Touch(); - ptr->SwitchToThread(ctrls_threads.back().Get()); - ctrls.push_back(ptr); - - TestContextFreePtr t(new TestContextFree(ctrls.back().Get(), - m_eventsCount)); - t->StartTestOnNothing(); - LogDebug(""); - frees.push_back(t); - } - } - } - m_init.Signal(); - LogDebug("Thread starts loop"); - return DPL::Thread::ThreadEntry(); - } - - private: - DPL::WaitableEvent m_init; - int m_eventsCount; - int m_tests; -}; - -RUNNER_TEST(ICDelegate_2) -{ - LogDebug("Creating test threads"); - for (int i = 0; i < TestThreads; ++i) - { - TestRunnerInThreadPtr ptr( - new TestRunnerInThread(NumberOfEvents, TestsPerThread)); - frees_threads.push_back(ptr); - frees_threads.back()->Run(); - } - - FOREACH(it, frees_threads) { - (*it)->WaitForInit(); - } - LogDebug("Creating test threads done"); - - FOREACH(it, frees) { - LogDebug("..."); - (*it)->Wait(); - } - - FOREACH(it, frees) { - RUNNER_ASSERT((*it)->CheckTest()); - } - - frees.clear(); - - FOREACH(it, frees_threads) { - (*it)->Quit(); - } - - frees_threads.clear(); - - FOREACH(it, ctrls) { - (*it)->SwitchToThread(NULL); - } - - FOREACH(it, ctrls_threads) { - (*it)->Quit(); - } - - ctrls.clear(); - ctrls_threads.clear(); -} - -namespace ReuseCheck { -const int ReuseCount = 5; -typedef DPL::Event::ICDelegate<> GetNothingDlpType; -DECLARE_GENERIC_EVENT_1(ReuseCountEvent, GetNothingDlpType) - -class ICReuseTestController -: public DPL::Event::Controller::Type> -{ - public: - ICReuseTestController() { m_reuseCount = 0; } - - protected: - virtual void OnEventReceived(const ReuseCountEvent& event) - { - event.GetArg0()(); //calling intercontext delegate - if(++m_reuseCount < ReuseCount){ - LogInfo("[Send] Reuse: " << m_reuseCount); - DPL::Event::ControllerEventHandler::PostEvent(event); - } - } - - int m_reuseCount; -}; - -class ReuseTestContextFreeClass : - protected DPL::Thread, - public DPL::Event::ICDelegateSupport -{ - public: - ReuseTestContextFreeClass(ICReuseTestController* controller) : - Thread(), - m_controller(controller), - m_reuseCount(0) - { } - - void Run() { Thread::Run(); } - void Quit() { Thread::Quit(); } - void Wait() { DPL::WaitForSingleHandle(m_waitable.GetHandle()); } - - protected: - void OnReuseReceive() - { - LogDebug("[Received] : " << ++m_reuseCount); - if(m_reuseCount == ReuseCount) - m_waitable.Signal(); - } - - virtual int ThreadEntry() - { - ReuseCountEvent reuseEvent( - makeICDelegate( - &ReuseTestContextFreeClass::OnReuseReceive, - DPL::Event::ICD::Reuse::Yes)); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - reuseEvent); - - return Thread::ThreadEntry(); - } - - private: - DPL::WaitableEvent m_waitable; - ICReuseTestController* m_controller; - int m_reuseCount; -}; - -RUNNER_TEST(ICDelegate_3) -{ - DPL::Thread thread; - thread.Run(); - LogDebug("Controller thread id = " << &thread); - - ICReuseTestController testController; - testController.Touch(); - testController.SwitchToThread(&thread); - - ReuseTestContextFreeClass* contextFree = - new ReuseTestContextFreeClass(&testController); - - thread.Run(); - contextFree->Run(); - contextFree->Wait(); - contextFree->Quit(); - thread.Quit(); - - delete contextFree; - - RUNNER_ASSERT(true); -} -} //namespace ReuseCheck diff --git a/tests/event/test_property.cpp b/tests/event/test_property.cpp deleted file mode 100644 index c095e5b..0000000 --- a/tests/event/test_property.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_property.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test property - */ -#include -#include -#include -#include - -namespace { -const int PROPERTY_VALUE_INT = 2; -const std::string PROPERTY_VALUE_STRING = "aaa"; -} - -int ReadSomething2(DPL::Event::Model */*model*/); -int ReadSomething2(DPL::Event::Model */*model*/) -{ - return PROPERTY_VALUE_INT; -} - -std::string ReadSomething(DPL::Event::Model */*model*/); -std::string ReadSomething(DPL::Event::Model */*model*/) -{ - return PROPERTY_VALUE_STRING; -} - -void WriteSomething(const std::string &/*value*/, DPL::Event::Model */*model*/); -void WriteSomething(const std::string &/*value*/, DPL::Event::Model */*model*/) -{ -} - -class MyModel - : public DPL::Event::Model -{ -public: - ~MyModel() {} - - DPL::Event::Property - Caption; - - DPL::Event::Property - Testproperty0; - - DPL::Event::Property - Testproperty1; - - DPL::Event::Property - Testproperty2; - - DPL::Event::Property Testproperty3; - - DPL::Event::Property Testproperty4; - - DPL::Event::Property Testproperty5; - - MyModel() - : Caption(this, "Foo caption"), - Testproperty0(this, "", &ReadSomething), - Testproperty1(this), - Testproperty2(this), - Testproperty3(this), - Testproperty4(this, "test", &ReadSomething, &WriteSomething), - Testproperty5(this, &ReadSomething2) - { - } -}; - -std::string g_caption; - -void OnNameChanged(const DPL::Event::PropertyEvent &event); -void OnNameChanged(const DPL::Event::PropertyEvent &event) -{ - g_caption = event.value; -} - -RUNNER_TEST(Model_Test) -{ - MyModel model; - - g_caption = "It is a bad caption"; - - model.Caption.AddListener(&OnNameChanged); - model.Caption.Set("Test name"); - - RUNNER_ASSERT(model.Testproperty4.Get() == PROPERTY_VALUE_STRING); - RUNNER_ASSERT(PROPERTY_VALUE_INT == model.Testproperty5.Get()); - RUNNER_ASSERT(g_caption == "Test name"); - RUNNER_ASSERT(model.Caption.Get() == "Test name"); - - model.Caption.RemoveListener(&OnNameChanged); -} diff --git a/tests/localization/CMakeLists.txt b/tests/localization/CMakeLists.txt deleted file mode 100644 index 47e8229..0000000 --- a/tests/localization/CMakeLists.txt +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) -# @version 1.0 -# @brief -# - -# -# Test files -# -# Define all DPL tests sources. -# Runner is responsible for runnint it all and -# generating proper output files -# - -SET(TARGET_LOC "dpl-tests-loc") - -SET(MAIN_DIR ${PROJECT_SOURCE_DIR}/tests/localization) - -SET(LOC_TESTS_SOURCES - ${MAIN_DIR}/test_localization.cpp - ${MAIN_DIR}/test_suite01.cpp - ${MAIN_DIR}/mockup_src/widget_dao.cpp - ${PROJECT_SOURCE_DIR}/modules/localization/src/localization_utils.cpp - ${PROJECT_SOURCE_DIR}/modules/localization/src/w3c_file_localization.cpp -) - -INCLUDE_DIRECTORIES( - ${SYS_EFL_INCLUDE_DIRS} - ${DPL_TEST_INCLUDE_DIR} - ${MAIN_DIR}/mockup_include - ${PROJECT_SOURCE_DIR}/modules/localization/include -) - -LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS}) - -ADD_EXECUTABLE(${TARGET_LOC} ${LOC_TESTS_SOURCES}) - -TARGET_LINK_LIBRARIES( - ${TARGET_LOC} - ${SYS_EFL_LIBRARIES} - ${TARGET_DPL_EFL} - ${TARGET_DPL_TEST_ENGINE_EFL} -) - -SET_TARGET_PROPERTIES(${TARGET_LOC} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/ - BUILD_WITH_INSTALL_RPATH ON - INSTALL_RPATH_USE_LINK_PATH ON -) - -INSTALL(TARGETS ${TARGET_LOC} - DESTINATION bin - PERMISSIONS OWNER_READ - OWNER_WRITE - OWNER_EXECUTE - GROUP_READ - GROUP_EXECUTE - WORLD_READ - WORLD_EXECUTE - ) - -ADD_SUBDIRECTORY(files) diff --git a/tests/localization/files/CMakeLists.txt b/tests/localization/files/CMakeLists.txt deleted file mode 100644 index c887914..0000000 --- a/tests/localization/files/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/localization/files/one - DESTINATION - /opt/apps/widget/tests/localization/widget1/locales/pl-en - ) - -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/localization/files/one - ${PROJECT_SOURCE_DIR}/tests/localization/files/two - DESTINATION - /opt/apps/widget/tests/localization/widget2/locales/pl-en - ) - -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/localization/files/two - DESTINATION - /opt/apps/widget/tests/localization/widget2/locales/en-en - ) - diff --git a/tests/localization/files/one b/tests/localization/files/one deleted file mode 100644 index e69de29..0000000 diff --git a/tests/localization/files/two b/tests/localization/files/two deleted file mode 100644 index e69de29..0000000 diff --git a/tests/localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h b/tests/localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h deleted file mode 100644 index 9e49d0d..0000000 --- a/tests/localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h +++ /dev/null @@ -1,487 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * @file common_dao_types.h - * @author Michal Ciepielski (m.ciepielski@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of common data types for wrtdb - */ - -#ifndef WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ -#define WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ - -#include -#include -#include -#include -#include -#include -#include - -namespace WrtDB { -namespace Powder { - -typedef std::set StringSet; -//! Widget description -struct Description -{ - //!Content level - typedef enum - { - Level0 = 0, - Level1, - Level2, - Level3, - Level4, - Level5, - LevelUnknown - } LevelEnum; - struct LevelEntry - { - LevelEnum level; //!< content level - - typedef StringSet Context; - - //! POWDER context - //! xa This material appears in an artistic context - //! xb This material appears in an educational context - //! xc This material appears in a medical context - //! xd This material appears in a sports context - //! xe This material appears in a violent context - Context context; - explicit LevelEntry(LevelEnum level = LevelUnknown); - //! Function checks if context is valid - //! \param[in] level POWDER content level - //! \param[in] context POWDER context - bool isContextValid(LevelEnum level, - const DPL::OptionalString& context) const; - }; - - struct CategoryEntry - { - //! Levels entries for POWDER description - typedef std::vector LevelsContainer; - LevelsContainer levels; - //! Function checks if context is valid - //! \param[out] reason set if context invalid - //! \param[in] level POWDER content level - //! \param[in] context POWDER context - bool isCategoryValid(LevelEntry& reason, - LevelEnum level, - const DPL::OptionalString& context) const; - }; - - //! POWDER Category -> Category entry map for Widget - //! - //! nu Nudity - //! se Sex - //! vi Violence - //! la Potentially offensive language - //! dr Drug use - //! ga Gambling - //! ha Hate or harmful activities - //! ug Use of user-generated content - typedef std::map CategoryEntries; - - CategoryEntries categories; - - //! Age rating for widget - //! If Null not set - DPL::OptionalInt ageRating; -}; -} // namespace Powder - -namespace ChildProtection { - -//! Blacklist with forbidden URLs -//! It should be stored in WidgetDAO -typedef std::vector BlackList; - -//! Widget Child protection record -//! Record should be stored in WingetDAO -struct Record -{ - //! Child protection enabled - bool enabled; - explicit Record(bool enabled) : - enabled(enabled) - { - } -}; - -//! Powder processing -struct PowderRules -{ - //! Rule set by parent about forbidden category - //! Powder category - //! nu Nudity - //! se Sex - //! vi Violence - //! la Potentially offensive language - //! dr Drug use - //! ga Gambling - //! ha Hate or harmful activities - //! ug Use of user-generated content - //! Powder context - //! xa This material appears in an artistic conteaxt - //! xb This material appears in an educational context - //! xc This material appears in a medical context - //! xd This material appears in a sports context - //! xe This material appears in a violent context - struct CategoryRule - { - DPL::String category; - Powder::Description::LevelEnum level; - DPL::OptionalString context; - explicit CategoryRule(const DPL::String& category = DPL::String(), - Powder::Description::LevelEnum level = - Powder::Description::LevelUnknown, - const DPL::OptionalString& context = DPL::OptionalString()); - }; - - struct PowderResult - { - //! Reasoning outcome: part of POWDER description used to invalidate - Powder::Description::LevelEntry invalidDescription; - //! Reasoning outcome: rule set by parent not full filed by description - CategoryRule invalidRule; - - //! Reasoning outcome: type of invalidity - enum InvalidReason - { - InvalidRule, //!< One of rules was not fulfilled - InvalidAge, //!< Age is invalid - AgeRatingNotSet, //!< Age rating for widget is not set - Valid //!< Description valid - }; - InvalidReason reason; - explicit PowderResult(InvalidReason reason = Valid, - const Powder::Description::LevelEntry& invalidDescription = - Powder::Description::LevelEntry(), - const CategoryRule& invalidRule = CategoryRule()); - }; - - typedef std::pair ResultPair; - - //! Function checks if rule is fulfilled by description - //! \param[in] rule checked rule - //! \param[in] description - //! \retval true rule is valid - //! \retval false rule is invalid - ResultPair isRuleValidForDescription(const CategoryRule& rule, - const Powder::Description& description) const; - //! Function checks if age limit is fulfilled by description - //! \param[in] description - //! \retval true age is valid - //! \retval false age is invalid - ResultPair isAgeValidForDescription( - const Powder::Description& description) const; - - //! It is the maximum age rating valid for child - //! Uniform age is stored in WidgetDAO - DPL::OptionalInt ageLimit; - - //! Set to true if age rating is required - //! If ageLimit is not set value is ignored - bool isAgeRatingRequired; - - //! Set of rules configured by parent - //! Rules are stored in WidgetDAO and are uniform for all widgets - typedef std::vector RulesContainer; - RulesContainer rules; - - //! Function check if Widget description is valid for ChildProtection - //! configuration - //! \param description widget description - //! \retval true widget is valid - //! \retval false widget is invalid - ResultPair isDescriptionValid(const Powder::Description& description) - const; - - PowderRules() : - isAgeRatingRequired(false) - { - } -}; -} // namespace ChildProtection - -class PluginMetafileData -{ - public: - struct Feature - { - std::string m_name; - std::set m_deviceCapabilities; - - bool operator< (const Feature& obj) const - { - return m_name < obj.m_name; - } - }; - typedef std::set FeatureContainer; - - public: - - PluginMetafileData() - { - } - - std::string m_libraryName; - std::string m_featuresInstallURI; - std::string m_featuresKeyCN; - std::string m_featuresRootCN; - std::string m_featuresRootFingerprint; - - FeatureContainer m_featureContainer; -}; - -class PluginObjectsDAO -{ - public: - typedef std::set Objects; - typedef DPL::SharedPtr ObjectsPtr; - - public: - explicit PluginObjectsDAO() {} - - protected: - ObjectsPtr m_implemented; - ObjectsPtr m_dependent; -}; - -/** - * @brief Widget id describes web-runtime global widget identifier. - * - * Notice that only up to one widget can exist at the same time. - * DbWidgetHandle can be translated into corresponding WidgetModel by invoking - * FindWidgetModel routine. - */ -typedef int DbWidgetHandle; - -/** - * @brief Structure to hold the information of widget's size - */ -struct DbWidgetSize -{ - DPL::OptionalInt width; - DPL::OptionalInt height; - - DbWidgetSize(DPL::OptionalInt w = DPL::OptionalInt::Null, - DPL::OptionalInt h = DPL::OptionalInt::Null) : - width(w), - height(h) - { - } -}; - -inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB) -{ - if (!objA.height || !objA.width || !objB.width || !objB.height) { - return false; - } else { - return *objA.height == *objB.height && *objA.width == *objB.width; - } -} - -/** - * Widget [G]lobal [U]nique [ID]entifier - * Orginated from appstore ID - */ -typedef DPL::OptionalString WidgetGUID; - -struct WidgetAccessInfo -{ - DPL::String strIRI; /* origin iri */ - bool bSubDomains; /* do we want access to subdomains ? */ - - bool operator ==(const WidgetAccessInfo& info) const - { - return info.strIRI == strIRI && - info.bSubDomains == bSubDomains; - } -}; - -typedef std::list WidgetAccessInfoList; - -typedef std::list WindowModeList; - -/** - * @brief Widget configuration parameter key - */ -typedef DPL::String WidgetParamKey; - -/** - * @brief Widget configuration parameter value - */ -typedef DPL::String WidgetParamValue; - -/** - * @brief A map of widget configuration parameters. - * - * Widget configuration parameters are read from database and are stored - * along with feature that they describe. - */ -typedef std::multimap WidgetParamMap; - -/** - * @brief Widget feature host information about possible javascript extensions - * that widget may use - * - * Widget features are declared in configuration file in widget installation - * package. Each declared special feature is contained in some wrt-plugin that - * declares to implement it. After widget launch wrt searches for proper plugin - * libraries and load needed features. - * - * Widget features can be required or optional. It is possible to start widget - * without missing feature. When required feature cannot be loaded widget will - * not start. - */ - -enum { - INVALID_PLUGIN_HANDLE = -1 -}; -typedef int DbPluginHandle; - -struct DbWidgetFeature -{ - DPL::String name; /// Feature name - bool required; /// Whether feature is required - DbPluginHandle pluginId; /// Plugin id that implement this feature - WidgetParamMap params; /// Widget's params - - DbWidgetFeature() : - required(false), - pluginId(INVALID_PLUGIN_HANDLE) - { - } -}; - -inline bool operator < (const DbWidgetFeature &objA, - const DbWidgetFeature &objB) -{ - return objA.name.compare(objB.name) < 0; -} - -inline bool operator==(const DbWidgetFeature &featureA, - const DbWidgetFeature &featureB) -{ - return featureA.name == featureB.name && - featureA.required == featureB.required && - featureA.pluginId == featureB.pluginId; -} - -/** - * @brief Default container for features list - */ -typedef std::multiset DbWidgetFeatureSet; - -/** - * @brief Default container with DbWidgetHandle's - */ -typedef std::list DbWidgetHandleList; - -/** - * @brief Widget specific type - * - * Widget type describes belowed in WAC, TIZEN WebApp - */ -enum AppType -{ - APP_TYPE_UNKNOWN = 0, // unknown - APP_TYPE_WAC10, // WAC 1.0 - APP_TYPE_WAC20, // WAC 2.0 - APP_TYPE_TIZENWEBAPP, // slp webapp -}; - -class WidgetType -{ - public: - WidgetType() - :appType(APP_TYPE_UNKNOWN) - { - } - WidgetType(const AppType type) - :appType(type) - { - } - bool operator== (const AppType& other) const - { - return appType == other; - } - std::string getApptypeToString() - { - switch (appType) { -#define X(x) case x: return #x; - X(APP_TYPE_UNKNOWN) - X(APP_TYPE_WAC10) - X(APP_TYPE_WAC20) - X(APP_TYPE_TIZENWEBAPP) -#undef X - default: - return "UNKNOWN"; - } - } - - AppType appType; -}; - -} // namespace WrtDB - -struct WidgetSetting -{ - DPL::String settingName; - DPL::String settingValue; - - bool operator ==(const WidgetSetting& info) const - { - return (info.settingName == settingName && - info.settingValue == settingValue); - } - bool operator !=(const WidgetSetting& info) const - { - return (info.settingName != settingName || - info.settingValue != settingValue); - } -}; - -typedef std::list WidgetSettings; - -/** - * @brief Widget Application Service - * - * Application sercvice describes details of behaviour - * when widget receives aul bundle data. - */ -struct WidgetApplicationService -{ - public: - DPL::String src; /* start uri */ - DPL::String operation; /* service name */ - DPL::String scheme; /* scheme type*/ - DPL::String mime; /* mime type */ - - bool operator== (const WidgetApplicationService& other) const - { - return src == other.src && - operation == other.operation && - scheme == other.scheme && - mime == other.mime; - } -}; - -typedef std::list WidgetApplicationServiceList; -#endif /* WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ */ diff --git a/tests/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h b/tests/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h deleted file mode 100644 index 42b6c5b..0000000 --- a/tests/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This file contains the declaration of widget dao class. - * - * @file widget_dao_read_only.h - * @author Yang Jie (jie2.yang@samsung.com) - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @author Pawel Sikorski (p.sikorski@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of widget dao - */ - -#ifndef _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_ -#define _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_ - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -typedef DPL::OptionalString WidgetGUID; - -namespace ConfigParserData { - -struct Icon -{ - Icon(const DPL::String& src) : src(src) - { - } - DPL::String src; - DPL::OptionalInt width; - DPL::OptionalInt height; - bool operator==(const Icon&) const; - bool operator!=(const Icon&) const; - bool operator >(const Icon&) const; - bool operator>=(const Icon&) const; - bool operator <(const Icon&) const; - bool operator<=(const Icon&) const; -}; -} // namespace ConfigParserData -namespace WrtDB { - -typedef std::list StringList; - -struct WidgetLocalizedInfo -{ - DPL::OptionalString name; - DPL::OptionalString shortName; - DPL::OptionalString description; - DPL::OptionalString license; - DPL::OptionalString licenseHref; -}; - -typedef std::list LanguageTagList; - -class WidgetDAO -{ - public: - /** - * WidgetDAO Exception classes - */ - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, DatabaseError) - DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty) - DECLARE_EXCEPTION_TYPE(Base, GUIDisNull) - DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult) - DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist) - DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered) - }; - - protected: - DbWidgetHandle m_widgetHandle; - - public: - struct WidgetLocalizedIconRow - { - int appId; - int iconId; - DPL::String widgetLocale; - }; - typedef std::list WidgetLocalizedIconList; - - struct WidgetIconRow - { - int iconId; - int appId; - DPL::String iconSrc; - DPL::OptionalInt iconWidth; - DPL::OptionalInt iconHeight; - }; - typedef std::list WidgetIconList; - - struct WidgetStartFileRow - { - int startFileId; - int appId; - DPL::String src; - }; - typedef std::list WidgetStartFileList; - - struct WidgetLocalizedStartFileRow - { - int startFileId; - int appId; - DPL::String widgetLocale; - DPL::String type; - DPL::String encoding; - }; - typedef std::list LocalizedStartFileList; - - - /** - * This is a constructor. - * - * @param[in] widgetHandle application id of widget. - */ - WidgetDAO(DbWidgetHandle widgetHandle) - : m_widgetHandle(widgetHandle) - {} - - /** - * Destructor - */ - virtual ~WidgetDAO(){} - - /** - * This method returns widget handle(m_widgetHandle). - * - * @return widget handle(m_widgetHandle). - * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. - * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table. - */ - DbWidgetHandle getHandle() const { return m_widgetHandle; } - DbWidgetHandle getHandle(const WidgetGUID GUID) const; - static DbWidgetHandle getHandle(const DPL::String pkgName); - - /** - * This method returns the root directory of widget resource. - * - * @return path name of root directory. - * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. - * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in - * DB table. - */ - DPL::String getPath() const; - void setPath(const DPL::String &path) const; - - /** - * This method returns the defaultlocale for the widget. - * - * @return defaultlocale - * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. - * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in - * DB table. - */ - DPL::OptionalString getDefaultlocale() const; - - /** - * This method returns list of localized icons files; - * - * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. - * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in - * DB table. - */ - WidgetLocalizedIconList getLocalizedIconList() const; - - /** - * This method returns list of icons files; - * - * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. - * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in - * DB table. - */ - WidgetIconList getIconList() const; - - /** - * This method returns list of localized start files; - * - * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. - * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in - * DB table. - */ - LocalizedStartFileList getLocalizedStartFileList() const; - void setLocalizedStartFileList(const LocalizedStartFileList &list) const; - /** - * This method returns list of start files; - * - * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. - * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in - * DB table. - */ - WidgetStartFileList getStartFileList() const; - void setStartFileList(const WidgetStartFileList &list) const; - - WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const; - protected: - static std::map s_startFileMap; - static std::map s_localizedStartFileMap; - static std::map s_pathMap; -}; - -} // namespace WrtDB - -#endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_ - diff --git a/tests/localization/mockup_src/widget_dao.cpp b/tests/localization/mockup_src/widget_dao.cpp deleted file mode 100644 index 3fe877b..0000000 --- a/tests/localization/mockup_src/widget_dao.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This file contains the declaration of widget dao class. - * - * @file widget_dao_read_only.cpp - * @author Yang Jie (jie2.yang@samsung.com) - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @author Pawel Sikorski (p.sikorski@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of widget dao - */ - -#include - -#include -#include -#include -#include - -namespace WrtDB { - -std::map WidgetDAO::s_startFileMap; -std::map WidgetDAO::s_localizedStartFileMap; -std::map WidgetDAO::s_pathMap; - -DbWidgetHandle WidgetDAO::getHandle(const WidgetGUID /* GUID */) const -{ - LogError("Not impleneted!"); - return 0; -} - -DbWidgetHandle WidgetDAO::getHandle(const DPL::String /* pkgName */) -{ - LogError("Not implemented!"); - return 0; -} - -DPL::String WidgetDAO::getPath() const -{ - return s_pathMap[m_widgetHandle]; -} - -void WidgetDAO::setPath(const DPL::String &path) const -{ - s_pathMap[m_widgetHandle] = path; -} - -WidgetLocalizedInfo - WidgetDAO::getLocalizedInfo(const DPL::String& /* languageTag */) - const -{ - LogError("Not implemented!"); - return WidgetLocalizedInfo(); -} - -DPL::OptionalString WidgetDAO::getDefaultlocale() const -{ - LogError("Not implemented!"); - return DPL::OptionalString(); -} - -WidgetDAO::WidgetLocalizedIconList WidgetDAO::getLocalizedIconList() const -{ - LogError("Not implemented!"); - return WidgetLocalizedIconList(); -} - -WidgetDAO::WidgetIconList WidgetDAO::getIconList() const -{ - LogError("Not implemented!"); - return WidgetIconList(); -} - -WidgetDAO::LocalizedStartFileList WidgetDAO::getLocalizedStartFileList() const -{ - return s_localizedStartFileMap[m_widgetHandle]; -} - -void WidgetDAO::setLocalizedStartFileList(const LocalizedStartFileList &list) const { - s_localizedStartFileMap[m_widgetHandle] = list; -} - -WidgetDAO::WidgetStartFileList WidgetDAO::getStartFileList() const -{ - return s_startFileMap[m_widgetHandle]; -} - -void WidgetDAO::setStartFileList(const WidgetStartFileList &list) const -{ - s_startFileMap[m_widgetHandle] = list; -} - -} // namespace WrtDB diff --git a/tests/localization/test_localization.cpp b/tests/localization/test_localization.cpp deleted file mode 100644 index 42ffe3a..0000000 --- a/tests/localization/test_localization.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file main.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of main - */ -#include - -int main(int argc, char *argv[]) -{ - return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); -} - diff --git a/tests/localization/test_suite01.cpp b/tests/localization/test_suite01.cpp deleted file mode 100644 index 83f53f5..0000000 --- a/tests/localization/test_suite01.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include -#include - -namespace { - -WrtDB::LanguageTagList generateLanguageTags(){ - WrtDB::LanguageTagList tags; - tags.push_back(L"pl-pl"); - tags.push_back(L"en-en"); - tags.push_back(L"pl-en"); - return tags; -} - -static const WrtDB::LanguageTagList languageTags = generateLanguageTags(); -static const DPL::String widget1Path = L"/opt/apps/widget/tests/localization/widget1/"; -static const DPL::String widget2Path = L"/opt/apps/widget/tests/localization/widget2/"; - -} // anonymous namespace - -RUNNER_TEST(test01_getFilePathInWidgetPackageFromUrl){ - const int widgetHandle = 1; - WrtDB::WidgetDAO dao(widgetHandle); - dao.setPath(widget1Path); - - auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl( - widgetHandle, - languageTags, - L"widget://one"); - - RUNNER_ASSERT(*result == L"/opt/apps/widget/tests/localization/widget1/locales/pl-en/one"); -} - -RUNNER_TEST(test02_getFilePathInWidgetPackageFromUrl){ - const int widgetHandle = 2; - WrtDB::WidgetDAO dao(widgetHandle); - dao.setPath(widget2Path); - - auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl( - widgetHandle, - languageTags, - L"widget://one"); - - RUNNER_ASSERT(*result == L"/opt/apps/widget/tests/localization/widget2/locales/pl-en/one"); -} - -RUNNER_TEST(test03_getFilePathInWidgetPackageFromUrl){ - const int widgetHandle = 2; - WrtDB::WidgetDAO dao(widgetHandle); - dao.setPath(widget2Path); - - auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl( - widgetHandle, - languageTags, - L"widget://two"); - - RUNNER_ASSERT(*result == L"/opt/apps/widget/tests/localization/widget2/locales/en-en/two"); -} - -RUNNER_TEST(test04_getFilePathInWidgetPackage){ - const int widgetHandle = 1; - WrtDB::WidgetDAO dao(widgetHandle); - dao.setPath(widget1Path); - - auto result = W3CFileLocalization::getFilePathInWidgetPackage( - widgetHandle, - languageTags, - L"one"); - - RUNNER_ASSERT(*result == L"locales/pl-en/one"); -} - -RUNNER_TEST(test05_getFilePathInWidgetPackage){ - const int widgetHandle = 2; - WrtDB::WidgetDAO dao(widgetHandle); - dao.setPath(widget2Path); - - auto result = W3CFileLocalization::getFilePathInWidgetPackage( - widgetHandle, - languageTags, - L"two"); - - RUNNER_ASSERT(*result == L"locales/en-en/two"); -} - diff --git a/tests/vcore/CMakeLists.txt b/tests/vcore/CMakeLists.txt deleted file mode 100644 index 443438d..0000000 --- a/tests/vcore/CMakeLists.txt +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file CMakeLists.txt -# @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) -# @author Pawel Sikorski (p.sikorski@samsung.com) -# @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) -# @version 1.0 -# @brief -# -INCLUDE(FindPkgConfig) -SET(TARGET_VCORE_TEST "dpl-tests-vcore") - -PKG_CHECK_MODULES(VCORE_TEST_DEP - libsoup-2.4 - REQUIRED - ) - -SET(VCORE_TESTS_SOURCES - ${PROJECT_SOURCE_DIR}/tests/vcore/vcore_tests.cpp - ${PROJECT_SOURCE_DIR}/tests/vcore/TestCases.cpp - ${PROJECT_SOURCE_DIR}/tests/vcore/TestEnv.cpp - ${PROJECT_SOURCE_DIR}/tests/vcore/TestCRL.cpp - ) - -INCLUDE_DIRECTORIES( - ${SYS_EFL_INCLUDE_DIRS} - ${DPL_TEST_INCLUDE_DIR} - ${PROJECT_SOURCE_DIR}/modules/vcore/src - ${PROJECT_SOURCE_DIR}/tests/vcore - ${PROJECT_SOURCE_DIR}/modules/widget_dao/include # global_config.h - ${VCORE_TEST_DEP_INCLUDE_DIRS} - ) - -ADD_EXECUTABLE(${TARGET_VCORE_TEST} ${VCORE_TESTS_SOURCES}) - -TARGET_LINK_LIBRARIES(${TARGET_VCORE_TEST} - ${SYS_EFL_LIBRARIES} - ${TARGET_DPL_EFL} - ${TARGET_DPL_TEST_ENGINE_EFL} - ${TARGET_VCORE_LIB} - ${TARGET_WRT_DAO_RO_LIB} # global_config.h_ - ${VCORE_TEST_DEP_LIBRARIES} - ) - -INSTALL(TARGETS ${TARGET_VCORE_TEST} - DESTINATION bin - PERMISSIONS OWNER_READ - OWNER_WRITE - OWNER_EXECUTE - GROUP_READ - GROUP_EXECUTE - WORLD_READ - WORLD_EXECUTE - ) - -INSTALL(FILES ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/dpl-tests-vcore-ocsp-server.sh - DESTINATION bin - PERMISSIONS OWNER_READ - OWNER_WRITE - OWNER_EXECUTE - GROUP_READ - GROUP_EXECUTE - WORLD_READ - WORLD_EXECUTE - ) - -ADD_CUSTOM_COMMAND(TARGET ${TARGET_VCORE_TEST} POST_BUILD - COMMAND ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/create_certs.sh - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/ - COMMENT "Generate certificate chains" - ) - -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/widget/author-signature.xml - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/widget/signature1.xml - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/widget/signature22.xml - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/widget/config.xml - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/widget/index.html - DESTINATION - /opt/apps/widget/tests/vcore_widget_uncompressed - ) - -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/keys/ocsp_level0deprecated.crt - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/keys/ocsp_level1.crt - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/keys/ocsp_level2.crt - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/keys/ocsp_rootca.crt - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/keys/operator.root.cert.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/keys/root_cacert.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/test-cases/keys/CAbundle.crt - DESTINATION - /opt/apps/widget/tests/vcore_keys - ) - -INSTALL(FILES - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/demoCA/cacert.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/1second_level.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/1third_level.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/2second_level.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/2third_level.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/3second_level.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/3third_level.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/cacrl1.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/cacrl2.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/respcert.pem - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/respcert.key - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/openssl.cnf - DESTINATION - /opt/apps/widget/tests/vcore_certs/ -) - -INSTALL(DIRECTORY - ${PROJECT_SOURCE_DIR}/tests/vcore/certificate-generator/demoCA - DESTINATION - /opt/apps/widget/tests/vcore_certs/ -) - diff --git a/tests/vcore/TestCRL.cpp b/tests/vcore/TestCRL.cpp deleted file mode 100644 index 37998df..0000000 --- a/tests/vcore/TestCRL.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include -#include "TestCRL.h" - -using namespace ValidationCore; -using namespace std; - - -namespace { -const char *CRL_LOOKUP_DIR = "/opt/etc/ssl/certs/"; -const char *beginCertificate = "-----BEGIN CERTIFICATE-----"; -const char *endCertificate = "-----END CERTIFICATE-----"; -const char *beginTrustedCertificate = "-----BEGIN TRUSTED CERTIFICATE-----"; -const char *endTrustedCertificate = "-----END TRUSTED CERTIFICATE-----"; - - -bool whiteCharacter(char a){ - return a == '\n'; -} - -} - -TestCRL::TestCRL() -{ - //Add additional lookup dir - int rv = X509_LOOKUP_add_dir(m_lookup, CRL_LOOKUP_DIR, X509_FILETYPE_PEM); - if (!rv) { - LogError("Failed to add lookup dir for PEM files."); - ThrowMsg(CRLException::StorageError, - "Failed to add lookup dir for PEM files."); - } - LogInfo("CRL storage initialization complete."); -} - -std::string TestCRL::getFileContent(const std::string &filename) -{ - //Only PEM formatted files allowed - LogInfo("Read file: " << filename); - DPL::FileInputMapping file(filename); - string content(reinterpret_cast(file.GetAddress()), - file.GetSize()); - - size_t posBegin = content.find(beginCertificate); - size_t posEnd = content.find(endCertificate); - if (posBegin != string::npos && - posEnd != string::npos) { - posBegin += strlen(beginCertificate); - } else { - posBegin = content.find(beginTrustedCertificate); - posEnd = content.find(endTrustedCertificate); - if (posBegin != string::npos && - posEnd != string::npos) { - posBegin += strlen(beginTrustedCertificate); - } else { - LogError("Failed to parse PEM file"); - return string(); - } - } - //Remove whitespaces - string cert(content, posBegin, posEnd - posBegin); - cert.erase(std::remove_if(cert.begin(), cert.end(), whiteCharacter), - cert.end()); - - return cert; -} - -void TestCRL::addCRLToStore(const string &filename, const string &uri) -{ - LogInfo("Read file: " << filename); - //Only PEM formatted files allowed - DPL::FileInputMapping file(filename); - char *buffer = new char[file.GetSize()]; - memcpy(buffer, file.GetAddress(), file.GetSize()); - CRLDataPtr crl(new CRLData(buffer, file.GetSize(), uri)); - updateCRL(crl); -} diff --git a/tests/vcore/TestCRL.h b/tests/vcore/TestCRL.h deleted file mode 100644 index d6c1ee6..0000000 --- a/tests/vcore/TestCRL.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _TEST_CRL_H -#define _TEST_CRL_H - -#include -#include - -class TestCRL : public ValidationCore::CRL -{ - public: - TestCRL(); - - void addCRLToStore(const std::string &filename, const std::string &uri); - - //convinient function - std::string getFileContent(const std::string &filename); -}; - -#endif diff --git a/tests/vcore/TestCases.cpp b/tests/vcore/TestCases.cpp deleted file mode 100644 index 8fdd4e7..0000000 --- a/tests/vcore/TestCases.cpp +++ /dev/null @@ -1,1325 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "TestEnv.h" -#include -#include -#include -#include -#include -#include -#include "TestCRL.h" -#include - -namespace { - -const std::string widget_path = - "/opt/apps/widget/tests/vcore_widget_uncompressed/"; -const std::string keys_path = "/opt/apps/widget/tests/vcore_keys/"; -const std::string widget_store_path = "/opt/apps/widget/tests/vcore_widgets/"; -const std::string cert_store_path = "/opt/apps/widget/tests/vcore_certs/"; -const std::string crl_URI = "http://localhost/my.crl"; - -const std::string anka_ec_key_type = "urn:oid:1.2.840.10045.3.1.7"; -const std::string anka_ec_public_key = - "BGi9RmTUjpqCpQjx6SSiKdfmtjQBFNSN7ghm6TuaH9r4x73WddeLxLioH3VEmFLC+QLiR"\ - "kPxDxL/6YmQdgfGrqk="; - -const std::string rsa_modulus = - "ocwjKEFaPxLNcPTz2PtT2Gyu5jzkWaPo4thjZo3rXuNbD4TzjY02UGnTxvflNeORLpSS1"\ - "PeYr/1E/Nhr7qQAzj9g0DwW7p8zQEdOUi3v76VykeB0pFJH+0Fxp6LVBX9Z+EvZk+dbOy"\ - "GJ4Njm9B6M09axXlV11Anj9B/HYUDfDX8="; -const std::string rsa_exponent = "AQAB"; - -const std::string magda_dsa_p = - "2BYIQj0ePUVxzrdBT41eCblraa9Dqag7QXFMCRM2PtyS22JPDKuV77tBc/jg0V3htHWdR"\ - "q9n6/kQDwrP7FIPoLATLIiC3oAYWj46Mr6d9k/tt/JZU6PvULmB2k1wrrmvKUi+U+I5Ro"\ - "qe8ui8lqR9pp9u2WCh2QmFfCohKNjN5qs="; -const std::string magda_dsa_q = "4p4JcDqz+S7CbWyd8txApZw0sik="; -const std::string magda_dsa_g = - "AQrLND1ZGFvzwBpPPXplmPh1ijPx1O2gQEvPvyjR88guWcGqQc0m7dTb6PEvbI/oZ0o91"\ - "k7VEkfthURnNR1WtOLT8dmAuKQfwTQLPwCwUM/QiuWSlCyKLTE4Ev8aOG7ZqWudsKm/td"\ - "n9pUNGtcod1wo1ZtP7PfEJ6rYZGQDOlz8="; - -const std::string googleCA = -"MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG" -"A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz" -"cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2" -"MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV" -"BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt" -"YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN" -"ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE" -"BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is" -"I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G" -"CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do" -"lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc" -"AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k"; - -const std::string google2nd = -"MIIDIzCCAoygAwIBAgIEMAAAAjANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJV" -"UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNzA1BgNVBAsTLkNsYXNzIDMgUHVi" -"bGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNTEzMDAw" -"MDAwWhcNMTQwNTEyMjM1OTU5WjBMMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh" -"d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBD" -"QTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1NNn0I0Vf67NMf59HZGhPwtx" -"PKzMyGT7Y/wySweUvW+Aui/hBJPAM/wJMyPpC3QrccQDxtLN4i/1CWPN/0ilAL/g" -"5/OIty0y3pg25gqtAHvEZEo7hHUD8nCSfQ5i9SGraTaEMXWQ+L/HbIgbBpV8yeWo" -"3nWhLHpo39XKHIdYYBkCAwEAAaOB/jCB+zASBgNVHRMBAf8ECDAGAQH/AgEAMAsG" -"A1UdDwQEAwIBBjARBglghkgBhvhCAQEEBAMCAQYwKAYDVR0RBCEwH6QdMBsxGTAX" -"BgNVBAMTEFByaXZhdGVMYWJlbDMtMTUwMQYDVR0fBCowKDAmoCSgIoYgaHR0cDov" -"L2NybC52ZXJpc2lnbi5jb20vcGNhMy5jcmwwMgYIKwYBBQUHAQEEJjAkMCIGCCsG" -"AQUFBzABhhZodHRwOi8vb2NzcC50aGF3dGUuY29tMDQGA1UdJQQtMCsGCCsGAQUF" -"BwMBBggrBgEFBQcDAgYJYIZIAYb4QgQBBgpghkgBhvhFAQgBMA0GCSqGSIb3DQEB" -"BQUAA4GBAFWsY+reod3SkF+fC852vhNRj5PZBSvIG3dLrWlQoe7e3P3bB+noOZTc" -"q3J5Lwa/q4FwxKjt6lM07e8eU9kGx1Yr0Vz00YqOtCuxN5BICEIlxT6Ky3/rbwTR" -"bcV0oveifHtgPHfNDs5IAn8BL7abN+AqKjbc1YXWrOU/VG+WHgWv"; - -const std::string google3rd = -"MIIDITCCAoqgAwIBAgIQL9+89q6RUm0PmqPfQDQ+mjANBgkqhkiG9w0BAQUFADBM" -"MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg" -"THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0wOTEyMTgwMDAwMDBaFw0x" -"MTEyMTgyMzU5NTlaMGgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh" -"MRYwFAYDVQQHFA1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKFApHb29nbGUgSW5jMRcw" -"FQYDVQQDFA53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC" -"gYEA6PmGD5D6htffvXImttdEAoN4c9kCKO+IRTn7EOh8rqk41XXGOOsKFQebg+jN" -"gtXj9xVoRaELGYW84u+E593y17iYwqG7tcFR39SDAqc9BkJb4SLD3muFXxzW2k6L" -"05vuuWciKh0R73mkszeK9P4Y/bz5RiNQl/Os/CRGK1w7t0UCAwEAAaOB5zCB5DAM" -"BgNVHRMBAf8EAjAAMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwudGhhd3Rl" -"LmNvbS9UaGF3dGVTR0NDQS5jcmwwKAYDVR0lBCEwHwYIKwYBBQUHAwEGCCsGAQUF" -"BwMCBglghkgBhvhCBAEwcgYIKwYBBQUHAQEEZjBkMCIGCCsGAQUFBzABhhZodHRw" -"Oi8vb2NzcC50aGF3dGUuY29tMD4GCCsGAQUFBzAChjJodHRwOi8vd3d3LnRoYXd0" -"ZS5jb20vcmVwb3NpdG9yeS9UaGF3dGVfU0dDX0NBLmNydDANBgkqhkiG9w0BAQUF" -"AAOBgQCfQ89bxFApsb/isJr/aiEdLRLDLE5a+RLizrmCUi3nHX4adpaQedEkUjh5" -"u2ONgJd8IyAPkU0Wueru9G2Jysa9zCRo1kNbzipYvzwY4OA8Ys+WAi0oR1A04Se6" -"z5nRUP8pJcA2NhUzUnC+MY+f6H/nEQyNv4SgQhqAibAxWEEHXw=="; - -const std::string certVerisign = -"MIIG+DCCBeCgAwIBAgIQU9K++SSnJF6DygHkbKokdzANBgkqhkiG9w0BAQUFADCB" -"vjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL" -"ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug" -"YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykwNjE4MDYGA1UEAxMv" -"VmVyaVNpZ24gQ2xhc3MgMyBFeHRlbmRlZCBWYWxpZGF0aW9uIFNTTCBTR0MgQ0Ew" -"HhcNMTAwNTI2MDAwMDAwWhcNMTIwNTI1MjM1OTU5WjCCASkxEzARBgsrBgEEAYI3" -"PAIBAxMCVVMxGTAXBgsrBgEEAYI3PAIBAhMIRGVsYXdhcmUxGzAZBgNVBA8TElYx" -"LjAsIENsYXVzZSA1LihiKTEQMA4GA1UEBRMHMjQ5Nzg4NjELMAkGA1UEBhMCVVMx" -"DjAMBgNVBBEUBTk0MDQzMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHFA1N" -"b3VudGFpbiBWaWV3MSIwIAYDVQQJFBk0ODcgRWFzdCBNaWRkbGVmaWVsZCBSb2Fk" -"MRcwFQYDVQQKFA5WZXJpU2lnbiwgSW5jLjEmMCQGA1UECxQdIFByb2R1Y3Rpb24g" -"U2VjdXJpdHkgU2VydmljZXMxGTAXBgNVBAMUEHd3dy52ZXJpc2lnbi5jb20wggEi" -"MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCj+PvvK+fZOXwno0yT/OTy2Zm9" -"ehnZjTtO/X2IWBEa3jG30C52uHFQI4NmXiQVNvJHkBaAj0ilVjvGdxXmkyyFsugt" -"IWOTZ8pSKdX1tmGFIon6Ko9+lBFkVkudA1ogAUbtTB8IcdeOlpK78T4SjdVMhY18" -"150YzSw6hRKlw52wBaDxtGZElvOth41K7TUcaDnQVzz5SBPW5MUhi7AWrdoSk17O" -"BozOzmB/jkYDVDnwLcbR89SLHEOle/idSYSDQUmab3y0JS8RyQV1+DB70mnFALnD" -"fLiL47nMQQCGxXgp5voQ2YmSXhevKmEJ9vvtC6C7yv2W6yomfS/weUEce9pvAgMB" -"AAGjggKCMIICfjCBiwYDVR0RBIGDMIGAghB3d3cudmVyaXNpZ24uY29tggx2ZXJp" -"c2lnbi5jb22CEHd3dy52ZXJpc2lnbi5uZXSCDHZlcmlzaWduLm5ldIIRd3d3LnZl" -"cmlzaWduLm1vYmmCDXZlcmlzaWduLm1vYmmCD3d3dy52ZXJpc2lnbi5ldYILdmVy" -"aXNpZ24uZXUwCQYDVR0TBAIwADAdBgNVHQ4EFgQU8oBwK/WBXCZDWi0dbuDgPyTK" -"iJIwCwYDVR0PBAQDAgWgMD4GA1UdHwQ3MDUwM6AxoC+GLWh0dHA6Ly9FVkludGwt" -"Y3JsLnZlcmlzaWduLmNvbS9FVkludGwyMDA2LmNybDBEBgNVHSAEPTA7MDkGC2CG" -"SAGG+EUBBxcGMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LnZlcmlzaWduLmNv" -"bS9ycGEwKAYDVR0lBCEwHwYIKwYBBQUHAwEGCCsGAQUFBwMCBglghkgBhvhCBAEw" -"HwYDVR0jBBgwFoAUTkPIHXbvN1N6T/JYb5TzOOLVvd8wdgYIKwYBBQUHAQEEajBo" -"MCsGCCsGAQUFBzABhh9odHRwOi8vRVZJbnRsLW9jc3AudmVyaXNpZ24uY29tMDkG" -"CCsGAQUFBzAChi1odHRwOi8vRVZJbnRsLWFpYS52ZXJpc2lnbi5jb20vRVZJbnRs" -"MjAwNi5jZXIwbgYIKwYBBQUHAQwEYjBgoV6gXDBaMFgwVhYJaW1hZ2UvZ2lmMCEw" -"HzAHBgUrDgMCGgQUS2u5KJYGDLvQUjibKaxLB4shBRgwJhYkaHR0cDovL2xvZ28u" -"dmVyaXNpZ24uY29tL3ZzbG9nbzEuZ2lmMA0GCSqGSIb3DQEBBQUAA4IBAQB9VZxB" -"wDMRGyhFWYkY5rwUVGuDJiGeas2xRJC0G4+riQ7IN7pz2a2BhktmZ5HbxXL4ZEY4" -"yMN68DEVErhtKiuL02ng27alhlngadKQzSL8pLdmQ+3jEwm9nva5C/7pbeqy+qGF" -"is4IWNYOc4HKNkABxXm5v0ouys8HPNkTLFLep0gLqRXW3gYN2XbKUWMs7z7hJpkY" -"GxP8YQSxi513O2dWVCXB8S6erIz9E/bcfdXoCPyQdn42y3IEoJvPvBS3S55fD4+Q" -"Q43GPhumSg9a6S3hnyw8DX5OiUGmqgQrtSeDRsNmWqtWizEQbe+fotZpEn/7zYTa" -"tk1ni/k5jDH/QeuG"; - -const std::string crlExampleCertificate = -"MIIFlDCCBHygAwIBAgIBADANBgkqhkiG9w0BAQUFADBDMRIwEAYKCZImiZPyLGQB" -"GRYCZXMxGDAWBgoJkiaJk/IsZAEZFghpcmlzZ3JpZDETMBEGA1UEAxMKSVJJU0dy" -"aWRDQTAeFw0wNTA2MjgwNTAyMjhaFw0xNTA2MjYwNTAyMjhaMEMxEjAQBgoJkiaJ" -"k/IsZAEZFgJlczEYMBYGCgmSJomT8ixkARkWCGlyaXNncmlkMRMwEQYDVQQDEwpJ" -"UklTR3JpZENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1CQiWlff" -"ajoMSTuismKqLQ+Mt33Tq4bBpCZvCBXhqan1R0ksILPtK1L7C8QWqPk6AZZpuNmY" -"cNVtJGc8ksgDWvX0EB3GKwZTZ8RrSRlSEe9Otq+Ur7S9uxM1JMmCr6zZTMFANzBS" -"4btnduV78C09IhFYG4OW8IPhNrbfPaeOR+PRPAa/qdSONAwTrM1sZkIvGpAkBWM6" -"Pn7TK9BAK6GLvwgii780fWj3Cwgmp8EDCTievBbWj+z8/apMEy9R0vyB2dWNNCnk" -"6q8VvrjgMsJt33O3BqOoBuZ8R/SS9OFWLFSU3s7cfrRaUSJk/Mx8OGFizRkcXSzX" -"0Nidcg7hX5i78wIDAQABo4ICkTCCAo0wDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E" -"FgQUnUJkLlupXvH/bMg8NtPxtkOYrRowawYDVR0jBGQwYoAUnUJkLlupXvH/bMg8" -"NtPxtkOYrRqhR6RFMEMxEjAQBgoJkiaJk/IsZAEZFgJlczEYMBYGCgmSJomT8ixk" -"ARkWCGlyaXNncmlkMRMwEQYDVQQDEwpJUklTR3JpZENBggEAMA4GA1UdDwEB/wQE" -"AwIBxjARBglghkgBhvhCAQEEBAMCAAcwOwYJYIZIAYb4QgENBC4WLElSSVNHcmlk" -"IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IENlcnRpZmljYXRlMIGZBgNVHR8EgZEw" -"gY4wLqAsoCqGKGh0dHA6Ly93d3cuaXJpc2dyaWQuZXMvcGtpL2NybC9jYWNybC5w" -"ZW0wXKBaoFiGVmxkYXA6Ly9sZGFwLmlyaXNncmlkLmVzOjEzODAvY249SVJJU0dy" -"aWRDQSxkYz1pcmlzZ3JpZCxkYz1lcz9jZXJ0aWZpY2F0ZVJldm9jYXRpb25MaXN0" -"MDcGCWCGSAGG+EIBAwQqFihodHRwOi8vd3d3LmlyaXNncmlkLmVzL3BraS9jcmwv" -"Y2FjcmwucGVtME4GCWCGSAGG+EIBCARBFj9odHRwOi8vd3d3LmlyaXNncmlkLmVz" -"L3BraS9wb2xpY3kvMS4zLjYuMS40LjEuNzU0Ny4yLjIuNC4xLjEuMS8waQYDVR0g" -"BGIwYDBeBg0rBgEEAbp7AgIEAQEBME0wSwYIKwYBBQUHAgEWP2h0dHA6Ly93d3cu" -"aXJpc2dyaWQuZXMvcGtpL3BvbGljeS8xLjMuNi4xLjQuMS43NTQ3LjIuMi40LjEu" -"MS4xLzANBgkqhkiG9w0BAQUFAAOCAQEAaqRfyLER+P2QOZLLdz66m7FGsgtFsAEx" -"wiNrIChFWfyHVZG7Ph1fn/GDD5LMsrU23lx3NBN5/feHuut1XNYKNs8vtV07D70r" -"DKjUlPbmWV0B+/GDxe1FDGop/tKQfyHSUaBuauXChFU/2INu5lhBerNl7QxNJ1ws" -"cWGiT7R+L/2EjgzWgH1V/0zmIOMep6kY7MUs8rlyF0O5MNFs232cA1trl9kvhAGU" -"9p58Enf5DWMrh17SPH586yIJeiWZtPez9G54ftY+XIqfn0X0zso0dnoXNJQYS043" -"/5vSnoHdRx/EmN8yjeEavZtC48moN0iJ38eB44uKgCD77rZW5s1XqA=="; - -//class TestCleanup -//{ -// public: -// explicit TestCleanup(bool bCheckForFakeVerification = false) -// { -// if (bCheckForFakeVerification) { -// bool bUnsetEnvVar = true; -// -// m_strEnvVar = "CHECK_ONLY_DOMAIN_INSTEAD_OF_VALIDATION"; -// if (getenv(m_strEnvVar.c_str()) != NULL) { -// bUnsetEnvVar = false; -// } else { -// setenv(m_strEnvVar.c_str(), "1", 0); -// } -// } -// } -// -// ~TestCleanup() -// { -// if (!m_strRootCAPath.empty()) { -// removeCertGivenByFilename(m_strRootCAPath.c_str()); -// } -// -// if (!m_strEnvVar.empty()) { -// unsetenv(m_strEnvVar.c_str()); -// } -// } -// -// void setRootCAPath(const std::string& strRootCAPath) -// { -// m_strRootCAPath = strRootCAPath; -// } -// -// private: -// std::string m_strRootCAPath; -// std::string m_strEnvVar; -//}; -// -//class PolicyChanger : public DPL::Event::EventListener -//{ -// public: -// PolicyChanger() -// { -// DPL::Event::EventDeliverySystem::AddListener(this); -// } -// -// ~PolicyChanger() -// { -// DPL::Event::EventDeliverySystem::RemoveListener(this); -// } -// -// void OnEventReceived(const AceUpdateResponseEvent& event) -// { -// if (0 != event.GetArg0()) { -// LogError("Policy change failed"); -// } -// Assert(0 == event.GetArg0() && "Policy change failed"); -// LoopControl::finish_wait_for_wrt_init(); -// } -// -// void updatePolicy(const std::string& path) -// { -// AceUpdateRequestEvent event(path); -// DPL::Event::EventDeliverySystem::Publish(event); -// LoopControl::wait_for_wrt_init(); -// } -//}; - -} // namespace anonymous - -using namespace ValidationCore; - -////////////////////////////////////////////////// -//////// VALIDATION CORE TEST SUITE //////////// -////////////////////////////////////////////////// - -RUNNER_TEST(test01_signature_finder) -{ - SignatureFileInfoSet signatureSet; - SignatureFinder signatureFinder(widget_path); - RUNNER_ASSERT_MSG( - SignatureFinder::NO_ERROR == signatureFinder.find(signatureSet), - "SignatureFinder failed"); - RUNNER_ASSERT_MSG(signatureSet.size() == 3, - "Some signature has not been found"); - - SignatureFileInfo first = *(signatureSet.begin()); - RUNNER_ASSERT_MSG( - std::string("author-signature.xml") == first.getFileName(), - "Author Signature"); - RUNNER_ASSERT_MSG(-1 == first.getFileNumber(), "Wrong signature number."); - first = *(signatureSet.rbegin()); - RUNNER_ASSERT_MSG(std::string("signature22.xml") == first.getFileName(), - "Wrong signature fileName."); - RUNNER_ASSERT_MSG(22 == first.getFileNumber(), "Wrong signature number."); -} - -RUNNER_TEST(test02_signature_reader) -{ - SignatureFileInfoSet signatureSet; - SignatureFinder signatureFinder(widget_path); - RUNNER_ASSERT_MSG( - SignatureFinder::NO_ERROR == signatureFinder.find(signatureSet), - "SignatureFinder failed"); - - SignatureFileInfoSet::reverse_iterator iter = signatureSet.rbegin(); - - for (; iter != signatureSet.rend(); ++iter) { - SignatureData data(widget_path + iter->getFileName(), - iter->getFileNumber()); - SignatureReader xml; - xml.initialize(data, WrtDB::GlobalConfig::GetSignatureXmlSchema()); - xml.read(data); - } -} - -RUNNER_TEST(test03_signature_validator) -{ - SignatureFileInfoSet signatureSet; - SignatureFinder signatureFinder(widget_path); - RUNNER_ASSERT_MSG( - SignatureFinder::NO_ERROR == signatureFinder.find(signatureSet), - "SignatureFinder failed"); - - SignatureFileInfoSet::reverse_iterator iter = signatureSet.rbegin(); - - for (; iter != signatureSet.rend(); ++iter) { - SignatureData data(widget_path + iter->getFileName(), - iter->getFileNumber()); - SignatureReader xml; - xml.initialize(data, WrtDB::GlobalConfig::GetSignatureXmlSchema()); - xml.read(data); - - SignatureValidator validator( - false, - false, - false); - - if (data.isAuthorSignature()) { - RUNNER_ASSERT_MSG( - SignatureValidator::SIGNATURE_DISREGARD == - validator.check(data, widget_path), - "Validation failed"); - } else { - RUNNER_ASSERT_MSG( - SignatureValidator::SIGNATURE_VERIFIED == - validator.check(data, widget_path), - "Validation failed"); - } - } -} - -RUNNER_TEST(test05_signature_reference) -{ - SignatureFileInfoSet signatureSet; - SignatureFinder signatureFinder(widget_path); - RUNNER_ASSERT_MSG( - SignatureFinder::NO_ERROR == signatureFinder.find(signatureSet), - "SignatureFinder failed"); - - SignatureFileInfoSet::reverse_iterator iter = signatureSet.rbegin(); - - for (; iter != signatureSet.rend(); ++iter) { - SignatureData data(widget_path + iter->getFileName(), - iter->getFileNumber()); - SignatureReader xml; - xml.initialize(data, WrtDB::GlobalConfig::GetSignatureXmlSchema()); - xml.read(data); - - SignatureValidator sval( - false, - false, - false); - sval.check(data, widget_path); - - ReferenceValidator val(widget_path); - RUNNER_ASSERT( - ReferenceValidator::NO_ERROR == val.checkReferences(data)); - } -} - -RUNNER_TEST(test07t01_base64) -{ - std::string strraw = "1234567890qwertyuiop[]asdfghjkl;'zxcvbnm,."; - std::string strenc = - "MTIzNDU2Nzg5MHF3ZXJ0eXVpb3BbXWFzZGZnaGprbDsnenhjdmJubSwu"; - - Base64Encoder encoder; - encoder.reset(); - encoder.append(strraw); - encoder.finalize(); - RUNNER_ASSERT_MSG(strenc == encoder.get(), "Error in Base64Encoder."); - - Base64Decoder decoder; - decoder.reset(); - decoder.append(strenc); - RUNNER_ASSERT(decoder.finalize()); - RUNNER_ASSERT_MSG(strraw == decoder.get(), "Error in Base64Decoder."); -} - -RUNNER_TEST(test07t02_base64) -{ - const size_t MAX = 40; - char buffer[MAX]; - for (size_t i = 0; i(i); - } - - std::string raw(&buffer[0], &buffer[MAX]); - - RUNNER_ASSERT(MAX == raw.size()); - - Base64Encoder encoder; - encoder.reset(); - encoder.append(raw); - encoder.finalize(); - std::string enc = encoder.get(); - - Base64Decoder decoder; - decoder.reset(); - decoder.append(enc); - RUNNER_ASSERT(decoder.finalize()); - RUNNER_ASSERT_MSG(raw == decoder.get(), "Error in Base64 conversion."); -} - -RUNNER_TEST(test07t03_base64) -{ - std::string invalid = "1234)"; - - Base64Decoder decoder; - decoder.reset(); - decoder.append(invalid); - RUNNER_ASSERT(false == decoder.finalize()); -} - -RUNNER_TEST(test07t04_base64) -{ - std::string invalid = "12234"; - - Base64Decoder decoder; - decoder.reset(); - - bool exception = false; - Try { - std::string temp = decoder.get(); - } Catch(Base64Decoder::Exception::NotFinalized) { - exception = true; - } - - RUNNER_ASSERT_MSG(exception, "Base64Decoder does not throw error."); -} - -RUNNER_TEST(test08t01_Certificate) -{ - Certificate cert(certVerisign, Certificate::FORM_BASE64); - - DPL::OptionalString result; - - result = cert.getCommonName(Certificate::FIELD_SUBJECT); - RUNNER_ASSERT_MSG(!result.IsNull(), "No common name"); - RUNNER_ASSERT_MSG(*result == DPL::FromUTF8String("www.verisign.com"), - "CommonName mismatch"); - - result = cert.getCommonName(Certificate::FIELD_ISSUER); - RUNNER_ASSERT_MSG(!result.IsNull(), "No common name"); - RUNNER_ASSERT_MSG(result == DPL::FromUTF8String( - "VeriSign Class 3 Extended Validation SSL SGC CA"), - "CommonName mismatch"); - - result = cert.getCountryName(); - RUNNER_ASSERT_MSG(!result.IsNull(), "No country"); - RUNNER_ASSERT_MSG(*result == DPL::FromUTF8String("US"), - "Country mismatch"); -} - -RUNNER_TEST(test08t02_Certificate) -{ - Certificate cert(certVerisign, Certificate::FORM_BASE64); - - Certificate::Fingerprint fin = - cert.getFingerprint(Certificate::FINGERPRINT_SHA1); - - unsigned char buff[20] = { - 0xb9, 0x72, 0x1e, 0xd5, 0x49, - 0xed, 0xbf, 0x31, 0x84, 0xd8, - 0x27, 0x0c, 0xfe, 0x03, 0x11, - 0x19, 0xdf, 0xc2, 0x2b, 0x0a}; - RUNNER_ASSERT_MSG(fin.size() == 20, "Wrong size of fingerprint"); - - for (size_t i = 0; i<20; ++i) { - RUNNER_ASSERT_MSG(fin[i] == buff[i], "Fingerprint mismatch"); - } -} - -RUNNER_TEST(test08t03_Certificate) -{ - Certificate cert(certVerisign, Certificate::FORM_BASE64); - - Certificate::AltNameSet nameSet = cert.getAlternativeNameDNS(); - - RUNNER_ASSERT(nameSet.size() == 8); - - DPL::String str = DPL::FromUTF8String("verisign.com"); - RUNNER_ASSERT(nameSet.find(str) != nameSet.end()); - - str = DPL::FromUTF8String("fake.com"); - RUNNER_ASSERT(nameSet.find(str) == nameSet.end()); - -} - -RUNNER_TEST(test09t01_CertificateCollection) -{ - CertificateList list; - list.push_back(CertificatePtr( - new Certificate(google2nd, Certificate::FORM_BASE64))); - list.push_back(CertificatePtr( - new Certificate(googleCA, Certificate::FORM_BASE64))); - list.push_back(CertificatePtr( - new Certificate(google3rd, Certificate::FORM_BASE64))); - - CertificateCollection collection; - collection.load(list); - - bool exception = false; - - Try { - RUNNER_ASSERT(collection.isChain()); - } Catch (CertificateCollection::Exception::WrongUsage) { - exception = true; - } - - RUNNER_ASSERT_MSG(exception, "Exception expected!"); - - RUNNER_ASSERT_MSG(collection.sort(), "Sort failed"); - - RUNNER_ASSERT(collection.isChain()); - - std::string encoded = collection.toBase64String(); - - collection.clear(); - - RUNNER_ASSERT_MSG(collection.size() == 0, "Function clear failed."); - - collection.load(encoded); - - RUNNER_ASSERT_MSG(collection.sort(), "Sort failed"); - - list = collection.getChain(); - - RUNNER_ASSERT( - DPL::ToUTF8String(*(list.front().Get()->getCommonName())) == - "www.google.com"); - RUNNER_ASSERT( - DPL::ToUTF8String(*(list.back().Get()->getOrganizationName())) == - "VeriSign, Inc."); -} - -RUNNER_TEST(test51t01_ocsp_validation_negative) -{ - CertificateCacheDAO::clearCertificateCache(); - - CertificateList lOCSPCertificates; - CertificatePtr certificatePtr; - CertificatePtr pCert0; - CertificatePtr pCert1; - CertificatePtr pCert2; - CertificatePtr pRootCert; - std::string caRootPath(keys_path + "ocsp_rootca.crt"), - certLevel0Path(keys_path + "ocsp_level0deprecated.crt"), - certLevel1Path(keys_path + "ocsp_level1.crt"), - certLevel2Path(keys_path + "ocsp_level2.crt"); - - pRootCert = RevocationCheckerBase::loadPEMFile(caRootPath.c_str()); - if (!pRootCert) { - RUNNER_ASSERT_MSG(false, "Couldn't load ocsp_rootca.crt"); - } - lOCSPCertificates.push_back(pRootCert); - - pCert0 = RevocationCheckerBase::loadPEMFile(certLevel0Path.c_str()); - if (!pCert0) { - RUNNER_ASSERT_MSG(false, "Couldn't load ocsp_level0.crt"); - } - lOCSPCertificates.push_back(CertificatePtr(pCert0)); - - pCert1 = RevocationCheckerBase::loadPEMFile(certLevel1Path.c_str()); - if (!pCert1) { - RUNNER_ASSERT_MSG(false, "Couldn't load ocsp_level1.crt"); - } - lOCSPCertificates.push_back(CertificatePtr(pCert1)); - - pCert2 = RevocationCheckerBase::loadPEMFile(certLevel2Path.c_str()); - if (!pCert2) { - RUNNER_ASSERT_MSG(false, "Couldn't load ocsp_level2.crt"); - } - lOCSPCertificates.push_back(CertificatePtr(pCert2)); - - OCSP ocsp; - ocsp.setDigestAlgorithmForCertId(ValidationCore::OCSP::SHA1); - ocsp.setDigestAlgorithmForRequest(ValidationCore::OCSP::SHA1); - - CertificateCollection collection; - collection.load(lOCSPCertificates); - RUNNER_ASSERT(collection.sort()); - CertificateList sorted = collection.getChain(); - - ocsp.setTrustedStore(sorted); - VerificationStatusSet status = ocsp.validateCertificateList(sorted); - - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_CONNECTION_FAILED), - "Caught OCSP connection error from store exception"); - RUNNER_ASSERT_MSG(status.contains(VERIFICATION_STATUS_GOOD), - "Caught OCSP verification error exception"); - RUNNER_ASSERT_MSG(status.contains(VERIFICATION_STATUS_VERIFICATION_ERROR), - "Caught OCSP verification error exception"); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test51t02_ocsp_validation_positive) -{ - CertificateCacheDAO::clearCertificateCache(); - - CertificateList lOCSPCertificates; - CertificatePtr certificatePtr; - CertificatePtr pCert0; - CertificatePtr pCert1; - CertificatePtr pCert2; - CertificatePtr pRootCert; - std::string caRootPath(keys_path + "ocsp_rootca.crt"), - certLevel1Path(keys_path + "ocsp_level1.crt"), - certLevel2Path(keys_path + "ocsp_level2.crt"); - - pRootCert = RevocationCheckerBase::loadPEMFile(caRootPath.c_str()); - if (!pRootCert) { - RUNNER_ASSERT_MSG(false, "Couldn't load ocsp_rootca.crt"); - } - lOCSPCertificates.push_back(pRootCert); - - pCert1 = RevocationCheckerBase::loadPEMFile(certLevel1Path.c_str()); - if (!pCert1) { - RUNNER_ASSERT_MSG(false, "Couldn't load ocsp_level1.crt"); - } - lOCSPCertificates.push_back(CertificatePtr(pCert1)); - - pCert2 = RevocationCheckerBase::loadPEMFile(certLevel2Path.c_str()); - if (!pCert2) { - RUNNER_ASSERT_MSG(false, "Couldn't load ocsp_level2.crt"); - } - lOCSPCertificates.push_back(CertificatePtr(pCert2)); - - OCSP ocsp; - ocsp.setDigestAlgorithmForCertId(ValidationCore::OCSP::SHA1); - ocsp.setDigestAlgorithmForRequest(ValidationCore::OCSP::SHA1); - - CertificateCollection collection; - collection.load(lOCSPCertificates); - RUNNER_ASSERT(collection.sort()); - CertificateList sorted = collection.getChain(); - - ocsp.setTrustedStore(sorted); - VerificationStatusSet status = ocsp.validateCertificateList(sorted); - - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_CONNECTION_FAILED), - "Caught OCSP connection error from store exception"); - RUNNER_ASSERT_MSG(status.contains(VERIFICATION_STATUS_GOOD), - "Caught OCSP verification error exception"); - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_VERIFICATION_ERROR), - "Caught OCSP verification error exception"); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test51t04_ocsp_request) -{ - CertificateList lTrustedCerts; - - lTrustedCerts.push_back(CertificatePtr( - new Certificate(google3rd, Certificate::FORM_BASE64))); - lTrustedCerts.push_back(CertificatePtr( - new Certificate(google2nd, Certificate::FORM_BASE64))); - lTrustedCerts.push_back(CertificatePtr( - new Certificate(googleCA, Certificate::FORM_BASE64))); - - CertificateCollection chain; - chain.load(lTrustedCerts); - chain.sort(); - - OCSP ocsp; - ocsp.setDigestAlgorithmForCertId(OCSP::SHA1); - ocsp.setDigestAlgorithmForRequest(OCSP::SHA1); - ocsp.setTrustedStore(lTrustedCerts); - VerificationStatus result = ocsp.checkEndEntity(chain); - - RUNNER_ASSERT(VERIFICATION_STATUS_GOOD == result); -} - -RUNNER_TEST(test51t05_cached_ocsp_validation_negative) -{ - CertificateCacheDAO::clearCertificateCache(); - - CertificateList lOCSPCertificates; - CertificatePtr certificatePtr; - CertificatePtr pCert0; - CertificatePtr pCert1; - CertificatePtr pCert2; - CertificatePtr pRootCert; - std::string caRootPath(keys_path + "ocsp_rootca.crt"), - certLevel0Path(keys_path + "ocsp_level0deprecated.crt"), - certLevel1Path(keys_path + "ocsp_level1.crt"), - certLevel2Path(keys_path + "ocsp_level2.crt"); - - pRootCert = RevocationCheckerBase::loadPEMFile(caRootPath.c_str()); - RUNNER_ASSERT_MSG(pRootCert, "Couldn't load ocsp_rootca.crt"); - lOCSPCertificates.push_back(pRootCert); - - pCert0 = RevocationCheckerBase::loadPEMFile(certLevel0Path.c_str()); - RUNNER_ASSERT_MSG(pCert0, "Couldn't load ocsp_level0.crt"); - lOCSPCertificates.push_back(CertificatePtr(pCert0)); - - pCert1 = RevocationCheckerBase::loadPEMFile(certLevel1Path.c_str()); - RUNNER_ASSERT_MSG(pCert1, "Couldn't load ocsp_level1.crt"); - lOCSPCertificates.push_back(CertificatePtr(pCert1)); - - pCert2 = RevocationCheckerBase::loadPEMFile(certLevel2Path.c_str()); - RUNNER_ASSERT_MSG(pCert2, "Couldn't load ocsp_level2.crt"); - lOCSPCertificates.push_back(CertificatePtr(pCert2)); - - CachedOCSP ocsp; - - CertificateCollection collection; - collection.load(lOCSPCertificates); - RUNNER_ASSERT(collection.sort()); - - VerificationStatus status = ocsp.check(collection); - - RUNNER_ASSERT_MSG(status != VERIFICATION_STATUS_GOOD, - "Caught OCSP verification error exception"); - - OCSPCachedStatusList respList; - CertificateCacheDAO::getOCSPStatusList(&respList); - unsigned len = respList.size(); - - status = ocsp.check(collection); - - RUNNER_ASSERT_MSG(status != VERIFICATION_STATUS_GOOD, - "Caught OCSP verification error exception"); - - respList.clear(); - CertificateCacheDAO::getOCSPStatusList(&respList); - RUNNER_ASSERT_MSG(respList.size() == len && len > 0, - "Caught OCSP cache error exception"); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test51t06_cached_ocsp_validation_positive) -{ - CertificateCacheDAO::clearCertificateCache(); - - CertificateList lOCSPCertificates; - CertificatePtr certificatePtr; - CertificatePtr pCert0; - CertificatePtr pCert1; - CertificatePtr pCert2; - CertificatePtr pRootCert; - std::string caRootPath(keys_path + "ocsp_rootca.crt"), - certLevel1Path(keys_path + "ocsp_level1.crt"), - certLevel2Path(keys_path + "ocsp_level2.crt"); - - pRootCert = RevocationCheckerBase::loadPEMFile(caRootPath.c_str()); - RUNNER_ASSERT_MSG(pRootCert, "Couldn't load ocsp_rootca.crt"); - lOCSPCertificates.push_back(pRootCert); - - pCert1 = RevocationCheckerBase::loadPEMFile(certLevel1Path.c_str()); - RUNNER_ASSERT_MSG(pCert1, "Couldn't load ocsp_level1.crt"); - lOCSPCertificates.push_back(CertificatePtr(pCert1)); - - pCert2 = RevocationCheckerBase::loadPEMFile(certLevel2Path.c_str()); - RUNNER_ASSERT_MSG(pCert2, "Couldn't load ocsp_level2.crt"); - lOCSPCertificates.push_back(CertificatePtr(pCert2)); - - CachedOCSP ocsp; - - CertificateCollection collection; - collection.load(lOCSPCertificates); - RUNNER_ASSERT(collection.sort()); - - VerificationStatus status = ocsp.check(collection); - - RUNNER_ASSERT_MSG(status == VERIFICATION_STATUS_GOOD, - "Caught OCSP verification error exception"); - - OCSPCachedStatusList respList; - CertificateCacheDAO::getOCSPStatusList(&respList); - unsigned len = respList.size(); - - status = ocsp.check(collection); - - RUNNER_ASSERT_MSG(status == VERIFICATION_STATUS_GOOD, - "Caught OCSP verification error exception"); - - respList.clear(); - CertificateCacheDAO::getOCSPStatusList(&respList); - RUNNER_ASSERT_MSG(respList.size() == len && len > 0, - "Caught OCSP cache error exception"); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test61_crl_test_revocation_no_crl) -{ - //Clear CRL cache so there is no CRL for those certificates URI. - CertificateCacheDAO::clearCertificateCache(); - //Prepare certificate chain - TestCRL crl; - std::string cacertStr(crl.getFileContent(cert_store_path + "cacert.pem")); - std::string certAStr( - crl.getFileContent(cert_store_path + "1second_level.pem")); - std::string certBStr( - crl.getFileContent(cert_store_path + "1third_level.pem")); - - CertificateLoader loader; - CertificateList certList; - CertificateCollection collection; - RUNNER_ASSERT(loader.loadCertificateFromRawData(cacertStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certAStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certBStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - - collection.load(certList); - - CRL::RevocationStatus status = crl.checkCertificateChain(collection); - RUNNER_ASSERT_MSG(status.isCRLValid == false, - "Some certificate have no CRL extension!"); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test62_crl_test_revocation_set1) -{ - CertificateCacheDAO::clearCertificateCache(); - - //Prepare certificate chain - TestCRL crl; - std::string cacertStr(crl.getFileContent(cert_store_path + "cacert.pem")); - std::string certAStr( - crl.getFileContent(cert_store_path + "1second_level.pem")); - std::string certBStr( - crl.getFileContent(cert_store_path + "1third_level.pem")); - crl.addCRLToStore(cert_store_path + "cacrl1.pem", crl_URI); - - CertificateLoader loader; - CertificateList certList; - CertificateCollection collection; - RUNNER_ASSERT(loader.loadCertificateFromRawData(cacertStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certAStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certBStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - - collection.load(certList); - - CRL::RevocationStatus status = crl.checkCertificateChain(collection); - RUNNER_ASSERT(status.isCRLValid); - RUNNER_ASSERT(status.isRevoked); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test63_crl_test_revocation_set1) -{ - CertificateCacheDAO::clearCertificateCache(); - - //Prepare certificate chain - TestCRL crl; - std::string cacertStr(crl.getFileContent(cert_store_path + "cacert.pem")); - std::string certAStr( - crl.getFileContent(cert_store_path + "1second_level.pem")); - std::string certBStr( - crl.getFileContent(cert_store_path + "1third_level.pem")); - crl.addCRLToStore(cert_store_path + "cacrl1.pem", crl_URI); - - CertificateLoader loader; - CertificateList certList; - CertificateCollection collection; - RUNNER_ASSERT(loader.loadCertificateFromRawData(cacertStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certAStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certBStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - - collection.load(certList); - - CRL::RevocationStatus status = crl.checkCertificateChain(collection); - RUNNER_ASSERT(status.isCRLValid); - RUNNER_ASSERT(status.isRevoked); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test64_crl_test_revocation_set2) -{ - CertificateCacheDAO::clearCertificateCache(); - - //Prepare certificate chain - TestCRL crl; - std::string cacertStr(crl.getFileContent(cert_store_path + "cacert.pem")); - std::string certAStr( - crl.getFileContent(cert_store_path + "2second_level.pem")); - std::string certBStr( - crl.getFileContent(cert_store_path + "2third_level.pem")); - crl.addCRLToStore(cert_store_path + "cacrl1.pem", crl_URI); - - CertificateLoader loader; - CertificateList certList; - CertificateCollection collection; - RUNNER_ASSERT(loader.loadCertificateFromRawData(cacertStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certAStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certBStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - - collection.load(certList); - - CRL::RevocationStatus status = crl.checkCertificateChain(collection); - RUNNER_ASSERT(status.isCRLValid); - RUNNER_ASSERT(!status.isRevoked); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test65_crl_test_revocation_set2) -{ - CertificateCacheDAO::clearCertificateCache(); - - //Prepare certificate chain - TestCRL crl; - std::string cacertStr(crl.getFileContent(cert_store_path + "cacert.pem")); - std::string certAStr( - crl.getFileContent(cert_store_path + "2second_level.pem")); - std::string certBStr( - crl.getFileContent(cert_store_path + "2third_level.pem")); - crl.addCRLToStore(cert_store_path + "cacrl2.pem", crl_URI); - - CertificateLoader loader; - CertificateList certList; - CertificateCollection collection; - RUNNER_ASSERT(loader.loadCertificateFromRawData(cacertStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certAStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certBStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - - collection.load(certList); - - CRL::RevocationStatus status = crl.checkCertificateChain(collection); - RUNNER_ASSERT(status.isCRLValid); - RUNNER_ASSERT(status.isRevoked); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test66_crl_update_expired_lists) -{ - CertificateCacheDAO::clearCertificateCache(); - - CertificateLoader loader; - loader.loadCertificateFromRawData(google2nd); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - TestCRL crl; - RUNNER_ASSERT_MSG( - crl.updateList(loader.getCertificatePtr(), CRL::UPDATE_ON_EXPIRED), - "CRL update on expired succeeded"); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test67_crl_update_lists_on_demand) -{ - CertificateCacheDAO::clearCertificateCache(); - - CertificateLoader loader; - loader.loadCertificateFromRawData(google2nd); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - TestCRL crl; - RUNNER_ASSERT_MSG( - crl.updateList(loader.getCertificatePtr(), CRL::UPDATE_ON_DEMAND), - "CRL update on demand succeeded"); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test68_cached_crl_test_positive) -{ - CertificateCacheDAO::clearCertificateCache(); - - TestCRL crl; - - std::string cacertStr(crl.getFileContent(cert_store_path + "cacert.pem")); - std::string certAStr( - crl.getFileContent(cert_store_path + "2second_level.pem")); - std::string certBStr( - crl.getFileContent(cert_store_path + "2third_level.pem")); - crl.addCRLToStore(cert_store_path + "cacrl1.pem", crl_URI); - - CertificateLoader loader; - CertificateList certList; - CertificateCollection collection; - RUNNER_ASSERT(loader.loadCertificateFromRawData(cacertStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certAStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certBStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - - collection.load(certList); - - CRL::RevocationStatus status = crl.checkCertificateChain(collection); - - CachedCRL cached; - VerificationStatus cached_status = cached.check(collection); - CRLCachedDataList list; - CertificateCacheDAO::getCRLResponseList(&list); - unsigned len = list.size(); - - RUNNER_ASSERT(status.isCRLValid); - RUNNER_ASSERT(!status.isRevoked && - cached_status == VERIFICATION_STATUS_GOOD); - - cached_status = cached.check(collection); - list.clear(); - CertificateCacheDAO::getCRLResponseList(&list); - - RUNNER_ASSERT(len == list.size()); - RUNNER_ASSERT(!status.isRevoked && - cached_status == VERIFICATION_STATUS_GOOD); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test69_cached_crl_test_negative) -{ - CertificateCacheDAO::clearCertificateCache(); - - //Prepare certificate chain - TestCRL crl; - std::string cacertStr(crl.getFileContent(cert_store_path + "cacert.pem")); - std::string certAStr( - crl.getFileContent(cert_store_path + "2second_level.pem")); - std::string certBStr( - crl.getFileContent(cert_store_path + "2third_level.pem")); - crl.addCRLToStore(cert_store_path + "cacrl2.pem", crl_URI); - - CertificateLoader loader; - CertificateList certList; - CertificateCollection collection; - RUNNER_ASSERT(loader.loadCertificateFromRawData(cacertStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certAStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - RUNNER_ASSERT(loader.loadCertificateFromRawData(certBStr) == - CertificateLoader::NO_ERROR); - RUNNER_ASSERT(!!loader.getCertificatePtr()); - certList.push_back(loader.getCertificatePtr()); - - collection.load(certList); - - CRL::RevocationStatus status = crl.checkCertificateChain(collection); - CachedCRL cached; - VerificationStatus cached_status = cached.check(collection); - CRLCachedDataList list; - CertificateCacheDAO::getCRLResponseList(&list); - unsigned len = list.size(); - - RUNNER_ASSERT(status.isCRLValid); - RUNNER_ASSERT(status.isRevoked && - cached_status == VERIFICATION_STATUS_REVOKED); - - cached_status = cached.check(collection); - list.clear(); - CertificateCacheDAO::getCRLResponseList(&list); - - RUNNER_ASSERT(len == list.size()); - RUNNER_ASSERT(status.isRevoked && - cached_status == VERIFICATION_STATUS_REVOKED); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test70_ocsp_local_validation_positive) -{ - CertificateCacheDAO::clearCertificateCache(); - - CertificateList lOCSPCertificates; - CertificatePtr certificatePtr; - CertificatePtr pCert0; - CertificatePtr pRootCert; - std::string caRootPath(cert_store_path + "cacert.pem"), - certLevel0Path(cert_store_path + "1second_level.pem"); - - pRootCert = RevocationCheckerBase::loadPEMFile(caRootPath.c_str()); - if (!pRootCert) { - RUNNER_ASSERT_MSG(false, "Couldn't load cacert.pem"); - } - lOCSPCertificates.push_back(pRootCert); - - pCert0 = RevocationCheckerBase::loadPEMFile(certLevel0Path.c_str()); - if (!pCert0) { - RUNNER_ASSERT_MSG(false, "Couldn't load 1second_level.pem"); - } - lOCSPCertificates.push_back(CertificatePtr(pCert0)); - - OCSP ocsp; - ocsp.setDigestAlgorithmForCertId(ValidationCore::OCSP::SHA1); - ocsp.setDigestAlgorithmForRequest(ValidationCore::OCSP::SHA1); - - CertificateCollection collection; - collection.load(lOCSPCertificates); - RUNNER_ASSERT(collection.sort()); - CertificateList sorted = collection.getChain(); - - ocsp.setTrustedStore(sorted); - VerificationStatusSet status = ocsp.validateCertificateList(sorted); - - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_CONNECTION_FAILED), - "Caught OCSP connection error - check if " - "dpl-tests-vcore-ocsp-server.sh is running!"); - RUNNER_ASSERT_MSG(status.contains(VERIFICATION_STATUS_GOOD), - "Caught OCSP verification error exception"); - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_VERIFICATION_ERROR), - "Caught OCSP verification error exception"); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test71_ocsp_local_validation_positive) -{ - CertificateCacheDAO::clearCertificateCache(); - - CertificateList lOCSPCertificates; - CertificatePtr certificatePtr; - CertificatePtr pCert0; - CertificatePtr pRootCert; - std::string caRootPath(cert_store_path + "cacert.pem"), - certLevel0Path(cert_store_path + "3second_level.pem"); - - pRootCert = RevocationCheckerBase::loadPEMFile(caRootPath.c_str()); - if (!pRootCert) { - RUNNER_ASSERT_MSG(false, "Couldn't load cacert.pem"); - } - lOCSPCertificates.push_back(pRootCert); - - pCert0 = RevocationCheckerBase::loadPEMFile(certLevel0Path.c_str()); - if (!pCert0) { - RUNNER_ASSERT_MSG(false, "Couldn't load 3second_level.pem"); - } - lOCSPCertificates.push_back(CertificatePtr(pCert0)); - - OCSP ocsp; - ocsp.setDigestAlgorithmForCertId(ValidationCore::OCSP::SHA1); - ocsp.setDigestAlgorithmForRequest(ValidationCore::OCSP::SHA1); - - CertificateCollection collection; - collection.load(lOCSPCertificates); - RUNNER_ASSERT(collection.sort()); - CertificateList sorted = collection.getChain(); - - ocsp.setTrustedStore(sorted); - VerificationStatusSet status = ocsp.validateCertificateList(sorted); - - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_CONNECTION_FAILED), - "Caught OCSP connection error - check if " - "dpl-tests-vcore-ocsp-server.sh is running!"); - RUNNER_ASSERT_MSG(status.contains(VERIFICATION_STATUS_GOOD), - "Caught OCSP verification error exception"); - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_VERIFICATION_ERROR), - "Caught OCSP verification error exception"); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test72_ocsp_local_validation_revoked) -{ - CertificateCacheDAO::clearCertificateCache(); - - CertificateList lOCSPCertificates; - CertificatePtr certificatePtr; - CertificatePtr pCert0; - CertificatePtr pRootCert; - std::string caRootPath(cert_store_path + "cacert.pem"), - certLevel0Path(cert_store_path + "2second_level.pem"); - - pRootCert = RevocationCheckerBase::loadPEMFile(caRootPath.c_str()); - if (!pRootCert) { - RUNNER_ASSERT_MSG(false, "Couldn't load cacert.pem"); - } - lOCSPCertificates.push_back(pRootCert); - - pCert0 = RevocationCheckerBase::loadPEMFile(certLevel0Path.c_str()); - if (!pCert0) { - RUNNER_ASSERT_MSG(false, "Couldn't load 2second_level.pem"); - } - lOCSPCertificates.push_back(CertificatePtr(pCert0)); - - OCSP ocsp; - ocsp.setDigestAlgorithmForCertId(ValidationCore::OCSP::SHA1); - ocsp.setDigestAlgorithmForRequest(ValidationCore::OCSP::SHA1); - - CertificateCollection collection; - collection.load(lOCSPCertificates); - RUNNER_ASSERT(collection.sort()); - CertificateList sorted = collection.getChain(); - - ocsp.setTrustedStore(sorted); - VerificationStatusSet status = ocsp.validateCertificateList(sorted); - - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_CONNECTION_FAILED), - "Caught OCSP connection error - check if " - "dpl-tests-vcore-ocsp-server.sh is running!"); - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_GOOD), - "Caught OCSP verification error exception"); - RUNNER_ASSERT_MSG(status.contains(VERIFICATION_STATUS_REVOKED), - "Caught OCSP verification error exception"); - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_UNKNOWN), - "Caught OCSP verification error exception"); - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_VERIFICATION_ERROR), - "Caught OCSP verification error exception"); - - CertificateCacheDAO::clearCertificateCache(); -} - -RUNNER_TEST(test73_ocsp_local_validation_error_unknown_cert) -{ - CertificateCacheDAO::clearCertificateCache(); - - CertificateList lOCSPCertificates; - CertificatePtr certificatePtr; - CertificatePtr pCert0; - CertificatePtr pCert1; - CertificatePtr pRootCert; - std::string caRootPath(cert_store_path + "cacert.pem"), - certLevel0Path(cert_store_path + "1second_level.pem"), - certLevel1Path(cert_store_path + "1third_level.pem"); - - pRootCert = RevocationCheckerBase::loadPEMFile(caRootPath.c_str()); - if (!pRootCert) { - RUNNER_ASSERT_MSG(false, "Couldn't load cacerr.pem"); - } - lOCSPCertificates.push_back(pRootCert); - - pCert0 = RevocationCheckerBase::loadPEMFile(certLevel0Path.c_str()); - if (!pCert0) { - RUNNER_ASSERT_MSG(false, "Couldn't load 1second_level.pem"); - } - lOCSPCertificates.push_back(CertificatePtr(pCert0)); - - pCert1 = RevocationCheckerBase::loadPEMFile(certLevel1Path.c_str()); - if (!pCert1) { - RUNNER_ASSERT_MSG(false, "Couldn't load 1third_level.pem"); - } - lOCSPCertificates.push_back(CertificatePtr(pCert1)); - - OCSP ocsp; - ocsp.setDigestAlgorithmForCertId(ValidationCore::OCSP::SHA1); - ocsp.setDigestAlgorithmForRequest(ValidationCore::OCSP::SHA1); - - CertificateCollection collection; - collection.load(lOCSPCertificates); - RUNNER_ASSERT(collection.sort()); - CertificateList sorted = collection.getChain(); - - ocsp.setTrustedStore(sorted); - VerificationStatusSet status = ocsp.validateCertificateList(sorted); - - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_CONNECTION_FAILED), - "Caught OCSP connection error - check if " - "dpl-tests-vcore-ocsp-server.sh is running!"); - RUNNER_ASSERT_MSG(status.contains(VERIFICATION_STATUS_GOOD), - "Caught OCSP verification error exception"); - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_REVOKED), - "Caught OCSP verification error exception"); - RUNNER_ASSERT_MSG(status.contains(VERIFICATION_STATUS_VERIFICATION_ERROR), - "Caught OCSP verification error exception"); - RUNNER_ASSERT_MSG(!status.contains(VERIFICATION_STATUS_UNKNOWN), - "Caught OCSP verification error exception"); - - CertificateCacheDAO::clearCertificateCache(); -} - diff --git a/tests/vcore/TestEnv.cpp b/tests/vcore/TestEnv.cpp deleted file mode 100644 index b12c3e1..0000000 --- a/tests/vcore/TestEnv.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include - -#include - -#include "TestEnv.h" - -const char *storePath = "code-signing_wac"; - -int addCertToStore(const char* name){ - int result = cert_svc_add_certificate_to_store(name, storePath); - - if (CERT_SVC_ERR_NO_ERROR != result) { - LogError("Error adding certificate: " << name << " To: " << storePath); - } - return result; -} - -//long int removeCertFromStore(const char* subjectName, const char* issuerName) -//{ -// long int result = OPERATION_SUCCESS; -// /* Retrieve all the certificates from store */ -// certmgr_cert_id certId; -// certmgr_mem_buff certRetrieved; -// certmgr_ctx context; -// char storeId[CERTMGR_MAX_PLUGIN_ID_SIZE]; -// char type[CERTMGR_MAX_CERT_TYPE_SIZE]; -// unsigned char certBuff[CERTMGR_MAX_BUFFER_SIZE * 2]; -// -// certmgr_cert_descriptor descriptor; -// certId.storeId = storeId; -// certId.type = type; -// -// CERTMGR_INIT_CONTEXT((&context), (sizeof(certmgr_ctx))) -// std::string storeName("Operator"); -// strncpy(context.storeId, storeName.c_str(), storeName.size()); -// -// certRetrieved.data = certBuff; -// certRetrieved.size = CERTMGR_MAX_BUFFER_SIZE * 2; -// -// certRetrieved.firstFree = 0; -// -// for(certRetrieved.firstFree = 0; -// OPERATION_SUCCESS == -// (result = certmgr_retrieve_certificate_from_store( &context, &certRetrieved, &certId)); -// certRetrieved.firstFree = 0) -// { -// if(OPERATION_SUCCESS == -// certmgr_extract_certificate_data(&certRetrieved, &descriptor)){ -// LogDebug("The subject of this certificate is " << descriptor.mandatory.subject); -// LogDebug("The issuer of this certificate is " << descriptor.mandatory.issuer); -// } -// -// if(strcmp(descriptor.mandatory.subject, subjectName) == 0 && -// strcmp(descriptor.mandatory.issuer,issuerName) == 0 && -// OPERATION_SUCCESS == certmgr_remove_certificate_from_store(&certId)) -// { -// LogDebug("***Certificate has been REMOVED***"); -// return OPERATION_SUCCESS; -// } -// } -// -// if(ERR_NO_MORE_CERTIFICATES == result){ -// LogDebug("***THIS CERT IS NOT IN STORE***"); -// return OPERATION_SUCCESS; -// } -// -// return result; -//} - -int removeCertGivenByFilename(const char* name){ - int result = cert_svc_delete_certificate_from_store(name, storePath); - - if (CERT_SVC_ERR_NO_ERROR != result) { - LogError("Error removing certificate: " << name << " From: " << storePath); - } - - return result; -} - diff --git a/tests/vcore/TestEnv.h b/tests/vcore/TestEnv.h deleted file mode 100644 index 88c5d3a..0000000 --- a/tests/vcore/TestEnv.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef _TESTENV_H_ -#define _TESTENV_H_ - -int addCertToStore(const char *name); -long int removeCertFromStore(const char *subjectName, const char *issuerName); -int removeCertGivenByFilename(const char *name); - -#endif diff --git a/tests/vcore/certificate-generator/create_certs.sh b/tests/vcore/certificate-generator/create_certs.sh deleted file mode 100755 index 4d03927..0000000 --- a/tests/vcore/certificate-generator/create_certs.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -#Prerequisite to run script is to -#create root certificate and directory structure (demoCA) with command: -#/usr/lib/ssl/misc/CA.sh -newca -#for automated tests default structure is created in demoCA.init - -#make sure current dir has no files from previous generation -rm -r 1* 2* 3* ca* respcert* demoCA -cp -R demoCA.init demoCA -echo "01" > ./demoCA/crlnumber - -for index in 1 2 3 -do - #create certificate A - openssl genrsa -out ${index}second_level.key 1024 -passin pass:1234 -config ./openssl.cnf - openssl req -new -key ${index}second_level.key -out ${index}second_level.csr -passin pass:1234 -config ./openssl.cnf <zhl|$R*|yDUoYQ zkz1R>HeqskLxkdO=&bWO=XBmbzMt>q_j{hdp6839Lf1h+Aq*AT0)eR~+9a-v1ED}V z6tcri2mmWI1qwCfJM&BD~4WRvkE{U z5dfJA1}x~ge^hdObiup=OrB$+uuU?D7bi?@7H2XF6nvZ-@4NQ(<)Qk4%>{$eAw)1p zbp)4e?ai#M9wJPk4FjUkM-Xn2)^JbHS3&V~SI-}t=lHGCCuyRYUVh5_(O?S+d)M00 z;oG!_?!q_M3PbuCu`rYRI}?(~U@aZIT65*h_{l_-k%q&|8H)D84@ow_v_HP@sz(7m{*$UXGfYN=eYx+)2EC<1npfGi=h)75Y?b75x7E;}t}v*!vlwrd zb(1*aX&Zzelf^LM{5)-kcE^_}%93V{^0}jMn=>=TABgZjv3cDk6B_|6Mm8aHZ8iMv z^HdzJ3nxzzy3$0OWE=^pdlE4BaFo8eooh0(xw3%4wV%nJ$&#A9&PtYxRlj=U$VQhB zjXkGnvamGX7#3|Gb+2yivSW4LV^RvTR5YKETkN&ff8$#Poz#%Nm=S0wx)LNkI1+xs zSJOx2@Zf``@a?aM2Sr!Armhg;?}x=Ck7f-jqJJJ8BFzm3BaFAgKi{WUkV^$`}{LYqldXnf+4sCNzCB4-U!cbrNXBX>sc` zVkEwkvgvi?)VZP0wwYGPlenbdAfFX7fp&5~C!oz~rsYoF&rkcV8*1zVKVukXeRhD`DB7W9sQbO?E(EvR zlipM>RVZrvh*xLVO1@uXltO#q6@4H)BuRGMD5s+f#Z6$qgH@C%5$GHpf2N+stpQ~( zrI&ECLJfD(!jgV_YMd|kk(-cwLEs7xEX@U0zMedyUb-vrTcCJn1^oKH?GMBLlYaZ> z)Un1{nh~bik%b0nxASekusB_9ld~DjEJ9oJ$JORb+mK2fcxqurx9&v|t$Fw3e2V7{ z6KLf$T*7!vTIIP~l%1U}xl21o2qMHD+d14TX_^>f}S!zdjiE*zz) zhEJMa=Hlmol&qpD_tuz%CcOrePh*!PE0!_qu!?WD?$xv@@Lt*k0_Bq*96XL39=r1; zXnFp6y4NU7zaCa6lz4eNNFCgf^C8uZKm&3;?L2u#d;o@sp$fVGUt!RxLN;Kkkfk6# zEPx3_?7#IP3Ix%qAVKwjivH0mLcdzY6R}_FU8i~OuT}w5L1bbZ>MipRvrF3ZWq=em z&7xzVBVCh5a_N+-Wb`~oF86{h-7<(PX(yu3?7kT9ed*24D^dGOtJPVLBmFhd-=lRR z_)z^#_A0@QjI3)N#Pu5KFB>H8cBZwWo6i@HErTaigf*Wr3+`O?@2RTeh4QW`HjInB znP&KD$GnSiK5fNo2+`3t&ye{R{MKySzpAv{8)LAt6(Tk8`YQ4)?1wDXCilQ7a!9rP za{t*sSvyLG#Z3+E>QRMC#!oA55Mm_S0v^y8OIu=!)s-Rs3Q8)oe>u0X6Y&=PHIO%! z>8P(bZnwM^t*KX5*4pC+(xRuc2UCzCxDl} zYf?rt#}OMLoeCXesv}A5szn-$#_#3cz2@hxeor4RuMuN^Ntox6*&sx5qctZd=#=-q zLtvul2;+2;h_GE2G%-tK?PHznXO4r%T>{kjZ}rhW{Pd2ksB^65)>kQPp`nSaKKvm{ z@tY^+dzst=(tBSx;%dtoq%!UI2aRsBof4KhG?8be8uvB-v8%u|(xTaXHl^GZw zZ#*|WL6^V>Me?{+-w*46=nJt_;OK=O>^P@M*%K%v3UaNXYFIW37@ppTXswa}e5|#kp zD2rGM6|?_;&l)C;-3^vP>)^!PQL`n^Ao13MpMh5Ka(ikqr+zO0Gt590AD~T z;4B~<5F}s}AWY!T3v?jBN8kbkE>eI1fj%MNFu@)Qa8#f|1&Ro`Ai(*5pZ3LIF^U)% vL|6kM1dXx>p?B1Lw&a#HwUJ0;BIjpvXX_Yeb>+k#vvdo-i diff --git a/tests/vcore/test-cases/keys/root_cacert.pem b/tests/vcore/test-cases/keys/root_cacert.pem deleted file mode 100644 index 7aa429f..0000000 --- a/tests/vcore/test-cases/keys/root_cacert.pem +++ /dev/null @@ -1,64 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: - c7:4a:82:f6:9d:1b:f6:7d - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=PL, ST=Maz, O=Samsung, OU=SPRC, CN=Samsung/emailAddress=samsung@samsung.com - Validity - Not Before: Oct 5 11:52:36 2011 GMT - Not After : Oct 4 11:52:36 2014 GMT - Subject: C=PL, ST=Maz, O=Samsung, OU=SPRC, CN=Samsung/emailAddress=samsung@samsung.com - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (1024 bit) - Modulus (1024 bit): - 00:93:c2:12:8b:3e:b1:69:fe:c8:7e:f1:fa:b0:03: - d7:bd:25:03:bb:14:70:ab:65:ff:8f:e9:38:14:2b: - 92:02:d9:e7:b4:78:60:a0:ce:b1:b8:b6:78:c5:af: - b3:83:3c:47:58:3d:1e:a0:78:69:4d:56:dd:8c:d8: - 20:27:b2:0d:9f:bf:f1:d4:e1:39:0f:1b:6f:b8:cd: - ca:f4:0b:fd:d7:cb:64:09:c7:6d:1e:e8:dd:89:43: - 7f:72:85:3d:9a:54:6e:7c:55:a0:da:f5:e9:28:01: - ec:3a:da:5a:18:45:fc:28:b1:0e:43:2c:4c:26:5c: - ca:bc:44:d9:ce:7d:5a:f2:f3 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - 82:08:7F:DB:00:02:86:E8:53:2A:A5:FA:58:AE:67:7F:14:38:C8:60 - X509v3 Authority Key Identifier: - keyid:82:08:7F:DB:00:02:86:E8:53:2A:A5:FA:58:AE:67:7F:14:38:C8:60 - DirName:/C=PL/ST=Maz/O=Samsung/OU=SPRC/CN=Samsung/emailAddress=samsung@samsung.com - serial:C7:4A:82:F6:9D:1B:F6:7D - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha1WithRSAEncryption - 0f:cb:a3:cd:25:02:00:17:a9:c5:21:4a:6e:bb:ce:d9:14:74: - 23:29:c5:47:ff:02:91:5a:ee:a1:53:a7:e4:69:6f:f2:00:bc: - 09:87:80:f8:3b:a5:51:59:e9:20:1f:1d:5d:cb:91:eb:91:1e: - f4:79:bf:35:68:a5:ed:24:e5:28:dd:c9:1f:bf:53:f7:75:77: - 6c:fe:94:0c:de:9c:d9:8e:42:c6:7d:61:6b:5d:5d:ad:a7:6a: - e4:9b:53:2a:f7:85:9c:51:1d:72:5d:5c:2f:eb:f9:ff:80:4c: - 6d:46:e8:a0:2c:8a:6f:94:13:b2:00:47:2c:b0:b0:1c:12:fc: - a0:65 ------BEGIN CERTIFICATE----- -MIIDOjCCAqOgAwIBAgIJAMdKgvadG/Z9MA0GCSqGSIb3DQEBBQUAMHIxCzAJBgNV -BAYTAlBMMQwwCgYDVQQIEwNNYXoxEDAOBgNVBAoTB1NhbXN1bmcxDTALBgNVBAsT -BFNQUkMxEDAOBgNVBAMTB1NhbXN1bmcxIjAgBgkqhkiG9w0BCQEWE3NhbXN1bmdA -c2Ftc3VuZy5jb20wHhcNMTExMDA1MTE1MjM2WhcNMTQxMDA0MTE1MjM2WjByMQsw -CQYDVQQGEwJQTDEMMAoGA1UECBMDTWF6MRAwDgYDVQQKEwdTYW1zdW5nMQ0wCwYD -VQQLEwRTUFJDMRAwDgYDVQQDEwdTYW1zdW5nMSIwIAYJKoZIhvcNAQkBFhNzYW1z -dW5nQHNhbXN1bmcuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCTwhKL -PrFp/sh+8fqwA9e9JQO7FHCrZf+P6TgUK5IC2ee0eGCgzrG4tnjFr7ODPEdYPR6g -eGlNVt2M2CAnsg2fv/HU4TkPG2+4zcr0C/3Xy2QJx20e6N2JQ39yhT2aVG58VaDa -9ekoAew62loYRfwosQ5DLEwmXMq8RNnOfVry8wIDAQABo4HXMIHUMB0GA1UdDgQW -BBSCCH/bAAKG6FMqpfpYrmd/FDjIYDCBpAYDVR0jBIGcMIGZgBSCCH/bAAKG6FMq -pfpYrmd/FDjIYKF2pHQwcjELMAkGA1UEBhMCUEwxDDAKBgNVBAgTA01hejEQMA4G -A1UEChMHU2Ftc3VuZzENMAsGA1UECxMEU1BSQzEQMA4GA1UEAxMHU2Ftc3VuZzEi -MCAGCSqGSIb3DQEJARYTc2Ftc3VuZ0BzYW1zdW5nLmNvbYIJAMdKgvadG/Z9MAwG -A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAD8ujzSUCABepxSFKbrvO2RR0 -IynFR/8CkVruoVOn5Glv8gC8CYeA+DulUVnpIB8dXcuR65Ee9Hm/NWil7STlKN3J -H79T93V3bP6UDN6c2Y5Cxn1ha11dradq5JtTKveFnFEdcl1cL+v5/4BMbUbooCyK -b5QTsgBHLLCwHBL8oGU= ------END CERTIFICATE----- diff --git a/tests/vcore/test-cases/keys/root_cakey.pem b/tests/vcore/test-cases/keys/root_cakey.pem deleted file mode 100644 index ff33c13..0000000 --- a/tests/vcore/test-cases/keys/root_cakey.pem +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,D2942E015452A445 - -0M/tC+qVDqyhNsxZZB/dGLuNxsStSUA7TRDRiSBee9JsvcFZjq03D/VjBakNIeET -6efmKfAngomfvrWtxhped3RI4vasX05swfnr4qiUKjLPyftmNEepbNGeI8MaiD7a -fEOZuAacstyS5RMHRBXrktq+jtXW2meQTuvEMBJf1AeAIuaFNvr3OvvpCtDwRffi -1ijUVuG0ZQ6MpP7cGeqLYUZ9StTMxeiEesAPM4YrG7HIY13KaHwMr1ZRtENe7qZ8 -R8vwgW188FYkSSrcQjCVEuj/ztTg9eVuSKdTNgjfKzTWnlrjAzi8CKBsrkYoarwS -6Rv3TqVVnx4HHdo9RIUKZPeLOdcMD1OPK7aOUedPTAcht3Y7SQQphBQypLf6PLKB -DCo79B4TUA1W9MijT2d2GN7oJHqHax8zO2j+yCLkEcHF32JZsEFE63Bwss72FXMg -mTmpCwyzR+oN93687JDUBAP9zNVd76ZnpzwlMZirB6QTY/lrH+iXLH3R3PO6cl2R -0Jei4IQ1oB+SX6GOPt4tKGTqktUFhsJYbXyifj4O1ZyDVYTp0JafOLxJfU33oYTm -278yshFdyHRgfKIHvqctZ1xJN2ioVcWf+9DprHc5kGb6wUKRVfQpipTS2hgbMBz+ -UWRZWq+CUD5QkTz4cSQfhPWQF6TNWpTQc0dvAlo3Cmxrro1PriDItsCOeydeNWvn -Dyynx7ODp/F1rX5ekaXkVxsdGgD/HuNF+c7tEytD7U4/CmevytuXRIrFM0alj2OE -aBFTqKicBoKgDV9VUOTKwuFeNV7MSuVDUnngEBeYrinwGa7wuV7tzA== ------END RSA PRIVATE KEY----- diff --git a/tests/vcore/test-cases/widget/author-signature.xml b/tests/vcore/test-cases/widget/author-signature.xml deleted file mode 100644 index ff82da8..0000000 --- a/tests/vcore/test-cases/widget/author-signature.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - xUKQbov3HL7JD2/zVUKpPEVGc5C6VWDXwxoDHzDs9y0= - - - - cIE41PzyhMnF++EmhJ3Ptnd4ZqXyBlRJgiIqxlutbV8= - - - - - - - MH34nIMXxv0fMQQ8bTV1wZUNLOrXTmpnxpADlNzmQ/4= - - - fhh+VQq76Uodq4upHhvcC2tgbVY8bL9DiiSe9wn1O4YrIFKMnEEYqYmpQbL1puWU -Zbht0hXpvEFXg1010q5kOZQxknqcyFg3hyVUpFDPARkJs1XhRNbFWJJF7qNXVgt5 -NyFrdXFv4lVFjkv+chSykaWu6V22z43E8kJcg+zGVU8= - - - MIIETTCCA7agAwIBAgIJANaOuOCRgiz3MA0GCSqGSIb3DQEBBQUAMIG8MQswCQYD -VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTE9MDsGA1UEChM0WE1MIFNlY3Vy -aXR5IExpYnJhcnkgKGh0dHA6Ly93d3cuYWxla3NleS5jb20veG1sc2VjKTEeMBwG -A1UECxMVVGVzdCBSb290IENlcnRpZmljYXRlMRYwFAYDVQQDEw1BbGVrc2V5IFNh -bmluMSEwHwYJKoZIhvcNAQkBFhJ4bWxzZWNAYWxla3NleS5jb20wHhcNMDUwNzEw -MDIyOTAxWhcNMTUwNzA4MDIyOTAxWjCBvDELMAkGA1UEBhMCVVMxEzARBgNVBAgT -CkNhbGlmb3JuaWExPTA7BgNVBAoTNFhNTCBTZWN1cml0eSBMaWJyYXJ5IChodHRw -Oi8vd3d3LmFsZWtzZXkuY29tL3htbHNlYykxHjAcBgNVBAsTFVRlc3QgUm9vdCBD -ZXJ0aWZpY2F0ZTEWMBQGA1UEAxMNQWxla3NleSBTYW5pbjEhMB8GCSqGSIb3DQEJ -ARYSeG1sc2VjQGFsZWtzZXkuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB -gQDayaFajJxOdVU+8EjwO31S2XqNmYxxbHfiUJO3w2h57OPUkKAcKe5Gvt9hJbPT -b3C4blPScOke2RexKnXS7pAXXbxFlgUlZ0QK0K2pdl559OSmrtH3mPP9BJvvDMlx -kcNj9/EeD+yGd8GN/yT6PTDh8G/4lszOXL+tyKIkC4Ys/wIDAQABo4IBUzCCAU8w -DAYDVR0TBAUwAwEB/zAsBglghkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQg -Q2VydGlmaWNhdGUwHQYDVR0OBBYEFNpG6Wvmr9M9quUhS1LtymYo4P6FMIHxBgNV -HSMEgekwgeaAFNpG6Wvmr9M9quUhS1LtymYo4P6FoYHCpIG/MIG8MQswCQYDVQQG -EwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTE9MDsGA1UEChM0WE1MIFNlY3VyaXR5 -IExpYnJhcnkgKGh0dHA6Ly93d3cuYWxla3NleS5jb20veG1sc2VjKTEeMBwGA1UE -CxMVVGVzdCBSb290IENlcnRpZmljYXRlMRYwFAYDVQQDEw1BbGVrc2V5IFNhbmlu -MSEwHwYJKoZIhvcNAQkBFhJ4bWxzZWNAYWxla3NleS5jb22CCQDWjrjgkYIs9zAN -BgkqhkiG9w0BAQUFAAOBgQBUXbdOTQwArcNrbxavzARp2JGOnzo6WzTm+OFSXC0F -08YwT8jWbht97e8lNNVOBU4Y/38ReZqYC9OqFofG1/O9AdQ58WL/FWg8DgP5MJPT -T9kRU3FU01jUiX2+kbdnghZAOJm0ziRNxfNPwIIWPKYXyXEKQQzrnxyFey1hP7cg -6A== - - - - - - - - - - - - - - - - diff --git a/tests/vcore/test-cases/widget/config.xml b/tests/vcore/test-cases/widget/config.xml deleted file mode 100755 index 82b077b..0000000 --- a/tests/vcore/test-cases/widget/config.xml +++ /dev/null @@ -1,6 +0,0 @@ - - Widget Name OK - 1.2.3.4 - A short description of widget - Author Name - diff --git a/tests/vcore/test-cases/widget/index.html b/tests/vcore/test-cases/widget/index.html deleted file mode 100755 index c47b20a..0000000 --- a/tests/vcore/test-cases/widget/index.html +++ /dev/null @@ -1,4 +0,0 @@ - -Not tested - -

None

diff --git a/tests/vcore/test-cases/widget/signature1.xml b/tests/vcore/test-cases/widget/signature1.xml deleted file mode 100644 index 71a100b..0000000 --- a/tests/vcore/test-cases/widget/signature1.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - ZLhd8X2rzCIDGHkIvpDbCXq+dwq+DK7ZZaDD/fII8RU= - - - - xUKQbov3HL7JD2/zVUKpPEVGc5C6VWDXwxoDHzDs9y0= - - - - cIE41PzyhMnF++EmhJ3Ptnd4ZqXyBlRJgiIqxlutbV8= - - - - - - - ZxnfFPi1rAoxfpN98xSP3lv5tZg9ymJElAFdg3ejrXE= - - - Dwm15jQbvUxe7fa7p4RVRAUzYY6eGQmDJSWXnv2LBbouch163OMaXgjKXWOLU+ZA -MwwuUUXG44QvOIv5M3Kd/Pc6kwvyb9+xm8zqmFF/mhttmAHc7VjY5sfB+bYFt9/3 -8+upSqxiUGLXYzMD/9u4W9ociwAcLiOQytBF1/TCv/4= - - - MIIC4zCCAkygAwIBAgIJAMdKgvadG/Z+MA0GCSqGSIb3DQEBBQUAMHIxCzAJBgNV -BAYTAlBMMQwwCgYDVQQIEwNNYXoxEDAOBgNVBAoTB1NhbXN1bmcxDTALBgNVBAsT -BFNQUkMxEDAOBgNVBAMTB1NhbXN1bmcxIjAgBgkqhkiG9w0BCQEWE3NhbXN1bmdA -c2Ftc3VuZy5jb20wHhcNMTExMDA1MTIwMDUxWhcNMjExMDAyMTIwMDUxWjB4MQsw -CQYDVQQGEwJQTDEMMAoGA1UECBMDTUFaMQwwCgYDVQQHEwNMZWcxDDAKBgNVBAoT -A1NhbTENMAsGA1UECxMEU1BSQzEOMAwGA1UEAxMFRmlsaXAxIDAeBgkqhkiG9w0B -CQEWEWZpbGlwQHNhbXN1bmcuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB -gQDS/sS0wXSCb34ojN8bWFd4Pl9eTLHh18UNGsPpLpp4itdfuc/OgyqaSoDwBzVh -EWAVLCTxexUa4Ncva+41NbkW4RCsFzeGs0ktpu1+8Q+v0QEOGqVF2rQkgilzDF/o -O56Fxw9vG1OA+qdQd3yOAV2EqLNBPrEYB9K5GFyffrakSQIDAQABo3sweTAJBgNV -HRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZp -Y2F0ZTAdBgNVHQ4EFgQUeyy3iV75KtOkpPFd6mnR9dFGZMwwHwYDVR0jBBgwFoAU -ggh/2wAChuhTKqX6WK5nfxQ4yGAwDQYJKoZIhvcNAQEFBQADgYEADtv0CBrQ1QCM -H9jKFjpSpq7zFKMXQeVtb/Zie823//woicg8kxnP5sS4dJWNXNb1iMLdhgV80g1y -t3gTWPxTtFzprQyNiJHTmrbNWXLX1roRVGUE/I8Q4xexqpbNlJIW2Jjm/kqoKfnK -xORG6HNPXZV29NY2fDRPPOIYoFQzrXI= - - - - - - - - - - - - - - - - diff --git a/tests/vcore/test-cases/widget/signature22.xml b/tests/vcore/test-cases/widget/signature22.xml deleted file mode 100644 index 715a7cc..0000000 --- a/tests/vcore/test-cases/widget/signature22.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - ZLhd8X2rzCIDGHkIvpDbCXq+dwq+DK7ZZaDD/fII8RU= - - - - xUKQbov3HL7JD2/zVUKpPEVGc5C6VWDXwxoDHzDs9y0= - - - - cIE41PzyhMnF++EmhJ3Ptnd4ZqXyBlRJgiIqxlutbV8= - - - - - - - ZxnfFPi1rAoxfpN98xSP3lv5tZg9ymJElAFdg3ejrXE= - - - fV1J/120GG5L7qsxEkyH6fBvQh2atlpiGMbVM1+pb8Q6pHib5beV6A== - - - MIIEDzCCA3igAwIBAgIJAMdKgvadG/Z/MA0GCSqGSIb3DQEBBQUAMHIxCzAJBgNV -BAYTAlBMMQwwCgYDVQQIEwNNYXoxEDAOBgNVBAoTB1NhbXN1bmcxDTALBgNVBAsT -BFNQUkMxEDAOBgNVBAMTB1NhbXN1bmcxIjAgBgkqhkiG9w0BCQEWE3NhbXN1bmdA -c2Ftc3VuZy5jb20wHhcNMTExMDA1MTIxMTMzWhcNMjExMDAyMTIxMTMzWjCBijEL -MAkGA1UEBhMCUEwxFDASBgNVBAgTC01hem93aWVja2llMRIwEAYDVQQHEwlsZWdp -b25vd28xEDAOBgNVBAoTB3NhbXN1bmcxDTALBgNVBAsTBHNwcmMxDjAMBgNVBAMT -BW1hZ2RhMSAwHgYJKoZIhvcNAQkBFhFtYWdkYUBzYW1zdW5nLmNvbTCCAbcwggEr -BgcqhkjOOAQBMIIBHgKBgQC1PCOasFhlfMc1yjdcp7zkzXGiW+MpVuFlsdYwkAa9 -sIvNrQLi2ulxcnNBeCHKDbk7U+J3/QwO2XanapQMUqvfjfjL1QQ5Vf7ENUWPNP7c -Evx82Nb5jWdHyRfV//TciBZN8GLNEbfhtWlhI6CbDW1AaY0nPZ879rSIk7/aNKZ3 -FQIVALcr8uQAmnV+3DLIA5nTo0Bg0bjLAoGAJG7meUtQbMulRMdjzeCoya2FXdm+ -4acvInE9/+MybXTB3bFANMyw6WTvk4K9RK8tm52N95cykTjpAbxqTMaXwkdWbOFd -VKAKnyxi/UKtY9Q6NmwJB2hbA1GUzhPko8rEda66CGl0VbyM1lKMJjA+wp9pG110 -L0ov19Q9fvqKp5UDgYUAAoGBAKxAQg7MqCgkC0MJftYjNaKM5n1iZv4j1li49zKf -Y5nTLP+vYAvg0owLNYvJ5ncKfY1DACPU4/+tC7TTua95wgj5rwvAXnzgSyOGuSr0 -fK9DyrH6E0LfXT+WuIQHahm2iSbxqPrChlnp5/EXDTBaO6Qfdpq0BP48ClZebxcA -+TYFo3sweTAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVy -YXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUmSpShswvWtEABd+l3WxccRcCydUw -HwYDVR0jBBgwFoAUggh/2wAChuhTKqX6WK5nfxQ4yGAwDQYJKoZIhvcNAQEFBQAD -gYEAgfnAu/gMJRC/BFwkgvrHL0TV4ffPVAf7RSnZS6ib4IHGgrvXJvL+Qh7vHykv -ZIqD2L96nY2EaSNr0yXrT81YROndOQUJNx4Y/W8m6asu4hzANNZqWCbApPDIMK6V -cPA1wrKgZqbWp218WBqI2v9pXV0O+jpzxq1+GeQV2UsbRwc= - - - - - - - - - - - - - - - - diff --git a/tests/vcore/vcore_tests.cpp b/tests/vcore/vcore_tests.cpp deleted file mode 100644 index 02517fc..0000000 --- a/tests/vcore/vcore_tests.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file main.cpp - * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of main - */ -#include -#include - -#include // includes headers with g_type_init - -int main (int argc, char *argv[]) -{ - g_type_init(); - g_thread_init(NULL); - ValidationCore::AttachToThread(); - int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); - ValidationCore::DetachFromThread(); - - return status; -} - -- 2.7.4