Initialize Tizen 2.3 tizen_2.3 2.3a_release submit/tizen_2.3/20140531.103815
authorSehong Na <sehong.na@samsung.com>
Sat, 31 May 2014 03:56:48 +0000 (12:56 +0900)
committerSehong Na <sehong.na@samsung.com>
Sat, 31 May 2014 03:56:48 +0000 (12:56 +0900)
27 files changed:
.badaprj [new file with mode: 0644]
.cproject [new file with mode: 0644]
.project [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0755]
LICENSE.APLv2 [new file with mode: 0755]
NOTICE [new file with mode: 0755]
data/.readme [new file with mode: 0644]
icons/screen-density-xhigh/mainmenu.png [new file with mode: 0644]
inc/CertificateService.h [new file with mode: 0644]
inc/CertificateServiceStub.h [new file with mode: 0755]
inc/DrmService.h [new file with mode: 0644]
inc/DrmServiceDl.h [new file with mode: 0644]
inc/PrivilegeService.h [new file with mode: 0644]
inc/SecurityService.h [new file with mode: 0644]
manifest.xml [new file with mode: 0644]
osp-security-service.manifest [new file with mode: 0755]
packaging/osp-security-service.spec [new file with mode: 0755]
res/.readme [new file with mode: 0644]
src/CertificateService.cpp [new file with mode: 0644]
src/CertificateServiceStub.cpp [new file with mode: 0755]
src/DrmService.cpp [new file with mode: 0755]
src/PrivilegeService.cpp [new file with mode: 0644]
src/SecurityService.cpp [new file with mode: 0644]
src/SecurityServiceEntry.cpp [new file with mode: 0644]
src/SecurityServiceMessage.cpp [new file with mode: 0644]
system-service-export.ver [new file with mode: 0755]
tool/mk-cert-db.sh [new file with mode: 0755]

diff --git a/.badaprj b/.badaprj
new file mode 100644 (file)
index 0000000..68ca8f7
--- /dev/null
+++ b/.badaprj
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<bada>
+    <type>8</type>
+    <sdk>/home/vnc/SLP/SRC/Osp_Dev/sdk/Linux</sdk>
+    <platform>3.0.0</platform>
+    <properties>
+        <data0 key="PT CmdArgs Emulator-Debug" value=""/>
+        <data1 key="PT CmdArgs Target-Release" value=""/>
+        <data2 key="PT CertFile Target-Release" value="${project_loc}\.Target-Release\cert.cer"/>
+        <data3 key="PT CertFile Target-Debug" value="${project_loc}\.Target-Debug\cert.cer"/>
+        <data4 key="PT CmdArgs Target-Debug" value=""/>
+        <data5 key="PT Output Target-Release" value="${project_loc}\.Target-Release"/>
+        <data6 key="PT CertFile Emulator-Debug" value="${project_loc}\.Emulator-Debug\cert.cer"/>
+        <data7 key="PT Output Target-Debug" value="${project_loc}\.Target-Debug"/>
+        <data8 key="PT Output Emulator-Debug" value="${project_loc}\.Emulator-Debug"/>
+    </properties>
+    <libraries>
+        <library>FOsp</library>
+    </libraries>
+    <checklaunch>
+        <build>true</build>
+        <editing>true</editing>
+    </checklaunch>
+    <acheck>
+        <internal>false</internal>
+        <incompatible>false</incompatible>
+        <version>false</version>
+        <deprecated>false</deprecated>
+    </acheck>
+    <pcheck>
+        <violation>false</violation>
+        <unused>false</unused>
+    </pcheck>
+    <presets/>
+</bada>
diff --git a/.cproject b/.cproject
new file mode 100644 (file)
index 0000000..dece8b3
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+       <storageModule moduleId="org.eclipse.cdt.core.settings">
+               <cconfiguration id="cdt.managedbuild.config.osp.gnu.emulator.exe.debug.1357514215">
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.osp.gnu.emulator.exe.debug.1357514215" moduleId="org.eclipse.cdt.core.settings" name="Emulator-Debug">
+                               <externalSettings/>
+                               <extensions>
+                                       <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                               </extensions>
+                       </storageModule>
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                               <configuration artifactExtension="exe" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.osp.gnu.emulator.exe.debug.1357514215" name="Emulator-Debug" parent="cdt.managedbuild.config.osp.gnu.emulator.exe.debug">
+                                       <folderInfo id="cdt.managedbuild.config.osp.gnu.emulator.exe.debug.1357514215." name="/" resourcePath="">
+                                               <toolChain id="cdt.managedbuild.toolchain.osp.gnu.emulator.exe.debug.1752448411" name="bada GCC" superClass="cdt.managedbuild.toolchain.osp.gnu.emulator.exe.debug">
+                                                       <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.Cygwin_PE;org.eclipse.cdt.core.GNU_ELF;org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.osp.gnu.emulator.platform.exe.debug.1725378213" name="Emulator" osList="osp" superClass="cdt.managedbuild.target.osp.gnu.emulator.platform.exe.debug"/>
+                                                       <builder buildPath="${workspace_loc:/PrivilegeService/.Emulator-Debug}" command="make" id="cdt.managedbuild.target.osp.gnu.emulator.builder.exe.debug.747870417" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="bada Builder" superClass="cdt.managedbuild.target.osp.gnu.emulator.builder.exe.debug"/>
+                                                       <tool command="i386-linux-gnueabi-g++" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.osp.gnu.emulator.cpp.compiler.exe.debug.1285268571" name="bada C++ Compiler" superClass="cdt.managedbuild.tool.osp.gnu.emulator.cpp.compiler.exe.debug">
+                                                               <option id="osp.gnu.emulator.cpp.compiler.debug.exe.option.include.paths.241627767" name="Include paths (-I)" superClass="osp.gnu.emulator.cpp.compiler.debug.exe.option.include.paths" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="${SDK_ROOT_PATH}/Platforms/${PLATFORM_VERSION}/Include"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../target/build-system/rootstraps/bada-emulator.sb2/usr/include/glib-2.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../target/build-system/rootstraps/bada-emulator.sb2/usr/lib/glib-2.0/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../target/build-system/rootstraps/bada-emulator.sb2/usr/include/&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../osp/cpp-framework/FSecurity/inc&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../osp/cpp-framework/FIo/inc&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../osp/cpp-framework/FIo/import/chromium/&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../osp/cpp-framework/FBase/inc&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="${PROJECT_ROOT}/inc"/>
+                                                               </option>
+                                                               <option id="osp.gnu.emulator.cpp.compiler.exe.debug.option.other.other.900125648" name="Other flags" superClass="osp.gnu.emulator.cpp.compiler.exe.debug.option.other.other" value="-c -pie" valueType="string"/>
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.cpp.compiler.input.121786245" superClass="cdt.managedbuild.tool.osp.gnu.cpp.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.emulator.c.compiler.exe.debug.973367981" name="bada C Compiler" superClass="cdt.managedbuild.tool.osp.gnu.emulator.c.compiler.exe.debug">
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.c.compiler.input.1394890925" superClass="cdt.managedbuild.tool.osp.gnu.c.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.emulator.cpp.linker.exe.debug.1190526028" name="bada C++ Linker" superClass="cdt.managedbuild.tool.osp.gnu.emulator.cpp.linker.exe.debug">
+                                                               <option id="osp.gnu.emulator.cpp.link.debug.exe.option.libs.1029837295" name="Libraries (-l)" superClass="osp.gnu.emulator.cpp.link.debug.exe.option.libs" valueType="libs">
+                                                                       <listOptionValue builtIn="false" value="FOsp"/>
+                                                                       <listOptionValue builtIn="false" value="minizip"/>
+                                                                       <listOptionValue builtIn="false" value="chromium"/>
+                                                               </option>
+                                                               <option id="osp.gnu.cpp.link.option.flags.304165512" name="Linker flags" superClass="osp.gnu.cpp.link.option.flags" value="-Xlinker -pie" valueType="string"/>
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.cpp.linker.input.1394053813" superClass="cdt.managedbuild.tool.osp.gnu.cpp.linker.input">
+                                                                       <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+                                                                       <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+                                                               </inputType>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.emulator.c.linker.exe.debug.1216998664" name="bada C Linker" superClass="cdt.managedbuild.tool.osp.gnu.emulator.c.linker.exe.debug"/>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.emulator.assembler.exe.debug.1088416036" name="bada Assembler" superClass="cdt.managedbuild.tool.osp.gnu.emulator.assembler.exe.debug">
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.assembler.input.1948780002" superClass="cdt.managedbuild.tool.osp.gnu.assembler.input"/>
+                                                       </tool>
+                                               </toolChain>
+                                       </folderInfo>
+                                       <sourceEntries>
+                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
+                                       </sourceEntries>
+                               </configuration>
+                       </storageModule>
+                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+               </cconfiguration>
+               <cconfiguration id="cdt.managedbuild.config.osp.gnu.target.exe.debug.1827736511">
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.osp.gnu.target.exe.debug.1827736511" moduleId="org.eclipse.cdt.core.settings" name="Target-Debug">
+                               <externalSettings/>
+                               <extensions>
+                                       <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                               </extensions>
+                       </storageModule>
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                               <configuration artifactExtension="exe" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.osp.gnu.target.exe.debug.1827736511" name="Target-Debug" parent="cdt.managedbuild.config.osp.gnu.target.exe.debug">
+                                       <folderInfo id="cdt.managedbuild.config.osp.gnu.target.exe.debug.1827736511." name="/" resourcePath="">
+                                               <toolChain id="cdt.managedbuild.toolchain.osp.gnu.target.exe.debug.640596920" name="bada GCC" superClass="cdt.managedbuild.toolchain.osp.gnu.target.exe.debug">
+                                                       <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.Cygwin_PE;org.eclipse.cdt.core.GNU_ELF;org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.osp.gnu.target.platform.exe.debug.1693880580" name="Debug Platform" osList="osp" superClass="cdt.managedbuild.target.osp.gnu.target.platform.exe.debug"/>
+                                                       <builder buildPath="${workspace_loc:/PrivilegeService/.Target-Debug}" command="make" id="cdt.managedbuild.target.osp.gnu.target.builder.exe.debug.1404189698" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="bada Builder" superClass="cdt.managedbuild.target.osp.gnu.target.builder.exe.debug"/>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.target.cpp.compiler.exe.debug.793728178" name="bada C++ Compiler" superClass="cdt.managedbuild.tool.osp.gnu.target.cpp.compiler.exe.debug">
+                                                               <option id="osp.gnu.target.cpp.compiler.debug.exe.option.include.paths.1071226715" name="Include paths (-I)" superClass="osp.gnu.target.cpp.compiler.debug.exe.option.include.paths" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="${SDK_ROOT_PATH}/Platforms/${PLATFORM_VERSION}/Include"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../osp/cpp-framework/FSecurity/inc&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../osp/cpp-framework/FIo/inc&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../osp/cpp-framework/FIo/import/chromium/&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../osp/cpp-framework/FBase/inc&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../target/build-system/rootstraps/bada-emulator.sb2/usr/include/&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../target/build-system/rootstraps/bada-emulator.sb2/usr/include/glib-2.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SDK_ROOT_PATH}/../../target/build-system/rootstraps/bada-emulator.sb2/usr/lib/glib-2.0/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="${PROJECT_ROOT}/inc"/>
+                                                               </option>
+                                                               <option id="osp.gnu.target.cpp.compiler.exe.debug.option.other.other.994115096" superClass="osp.gnu.target.cpp.compiler.exe.debug.option.other.other" value="-c -pie" valueType="string"/>
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.cpp.compiler.input.1387097937" superClass="cdt.managedbuild.tool.osp.gnu.cpp.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.target.c.compiler.exe.debug.1460497756" name="bada C Compiler" superClass="cdt.managedbuild.tool.osp.gnu.target.c.compiler.exe.debug">
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.c.compiler.input.1054328934" superClass="cdt.managedbuild.tool.osp.gnu.c.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.target.cpp.linker.exe.debug.1179680503" name="bada C++ Linker" superClass="cdt.managedbuild.tool.osp.gnu.target.cpp.linker.exe.debug">
+                                                               <option id="osp.gnu.target.cpp.link.debug.exe.option.libs.246303707" name="Libraries (-l)" superClass="osp.gnu.target.cpp.link.debug.exe.option.libs" valueType="libs">
+                                                                       <listOptionValue builtIn="false" value="FOsp"/>
+                                                                       <listOptionValue builtIn="false" value="minizip"/>
+                                                                       <listOptionValue builtIn="false" value="chromium"/>
+                                                               </option>
+                                                               <option id="osp.gnu.cpp.link.option.flags.1986715892" superClass="osp.gnu.cpp.link.option.flags" value="-Xlinker -pie" valueType="string"/>
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.cpp.linker.input.6252509" superClass="cdt.managedbuild.tool.osp.gnu.cpp.linker.input">
+                                                                       <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+                                                                       <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+                                                               </inputType>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.target.c.linker.exe.debug.1281737187" name="bada C Linker" superClass="cdt.managedbuild.tool.osp.gnu.target.c.linker.exe.debug"/>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.target.assembler.exe.debug.413550623" name="bada Assembler" superClass="cdt.managedbuild.tool.osp.gnu.target.assembler.exe.debug">
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.assembler.input.1619087715" superClass="cdt.managedbuild.tool.osp.gnu.assembler.input"/>
+                                                       </tool>
+                                               </toolChain>
+                                       </folderInfo>
+                                       <sourceEntries>
+                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
+                                       </sourceEntries>
+                               </configuration>
+                       </storageModule>
+                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+               </cconfiguration>
+               <cconfiguration id="cdt.managedbuild.config.osp.gnu.target.exe.release.1220495112">
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.osp.gnu.target.exe.release.1220495112" moduleId="org.eclipse.cdt.core.settings" name="Target-Release">
+                               <externalSettings/>
+                               <extensions>
+                                       <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                               </extensions>
+                       </storageModule>
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                               <configuration artifactExtension="exe" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.osp.gnu.target.exe.release.1220495112" name="Target-Release" parent="cdt.managedbuild.config.osp.gnu.target.exe.release">
+                                       <folderInfo id="cdt.managedbuild.config.osp.gnu.target.exe.release.1220495112." name="/" resourcePath="">
+                                               <toolChain id="cdt.managedbuild.toolchain.osp.gnu.target.exe.release.279703747" name="bada GCC" superClass="cdt.managedbuild.toolchain.osp.gnu.target.exe.release">
+                                                       <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.Cygwin_PE;org.eclipse.cdt.core.GNU_ELF;org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.osp.gnu.target.platform.exe.release.263201223" name="Debug Platform" osList="osp" superClass="cdt.managedbuild.target.osp.gnu.target.platform.exe.release"/>
+                                                       <builder buildPath="${workspace_loc:/PrivilegeService/.Target-Release}" command="make" id="cdt.managedbuild.target.osp.gnu.target.builder.exe.release.207659820" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="bada Builder" superClass="cdt.managedbuild.target.osp.gnu.target.builder.exe.release"/>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.target.cpp.compiler.exe.release.2031031816" name="bada C++ Compiler" superClass="cdt.managedbuild.tool.osp.gnu.target.cpp.compiler.exe.release">
+                                                               <option id="osp.gnu.target.cpp.compiler.exe.release.option.other.other.1422508621" superClass="osp.gnu.target.cpp.compiler.exe.release.option.other.other" value="-c -pie" valueType="string"/>
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.cpp.compiler.input.301727413" superClass="cdt.managedbuild.tool.osp.gnu.cpp.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.target.c.compiler.exe.release.1605144569" name="bada C Compiler" superClass="cdt.managedbuild.tool.osp.gnu.target.c.compiler.exe.release">
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.c.compiler.input.44991364" superClass="cdt.managedbuild.tool.osp.gnu.c.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.target.cpp.linker.exe.release.1729568011" name="bada C++ Linker" superClass="cdt.managedbuild.tool.osp.gnu.target.cpp.linker.exe.release">
+                                                               <option id="osp.gnu.cpp.link.option.flags.1466888881" superClass="osp.gnu.cpp.link.option.flags" value="-Xlinker -pie" valueType="string"/>
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.cpp.linker.input.1762282035" superClass="cdt.managedbuild.tool.osp.gnu.cpp.linker.input">
+                                                                       <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+                                                                       <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+                                                               </inputType>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.target.c.linker.exe.release.1647910007" name="bada C Linker" superClass="cdt.managedbuild.tool.osp.gnu.target.c.linker.exe.release"/>
+                                                       <tool id="cdt.managedbuild.tool.osp.gnu.target.assembler.exe.release.2128480374" name="bada Assembler" superClass="cdt.managedbuild.tool.osp.gnu.target.assembler.exe.release">
+                                                               <inputType id="cdt.managedbuild.tool.osp.gnu.assembler.input.1249820392" superClass="cdt.managedbuild.tool.osp.gnu.assembler.input"/>
+                                                       </tool>
+                                               </toolChain>
+                                       </folderInfo>
+                                       <sourceEntries>
+                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
+                                       </sourceEntries>
+                               </configuration>
+                       </storageModule>
+                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+               </cconfiguration>
+       </storageModule>
+       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+               <project id="PrivilegeService.cdt.managedbuild.target.osp.gnu.arm.exe.1287412253" name="Executable" projectType="cdt.managedbuild.target.osp.gnu.arm.exe"/>
+       </storageModule>
+       <storageModule moduleId="scannerConfiguration">
+               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+       </storageModule>
+       <storageModule moduleId="refreshScope"/>
+</cproject>
diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..2e74b2b
--- /dev/null
+++ b/.project
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>osp-security-service</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>com.osp.ide.ospmakebuilder</name>
+                       <triggers>clean,full,incremental,</triggers>
+                       <arguments>
+                               <dictionary>
+                                       <key>?name?</key>
+                                       <value></value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.append_environment</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.buildArguments</key>
+                                       <value></value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.buildCommand</key>
+                                       <value>make</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.buildLocation</key>
+                                       <value>${workspace_loc:/PrivilegeService/.Emulator-Debug}</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+                                       <value>clean</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.contents</key>
+                                       <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+                                       <value>false</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.stopOnError</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+                                       <value>false</value>
+                               </dictionary>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+                       <triggers>full,incremental,</triggers>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.cdt.core.cnature</nature>
+               <nature>org.eclipse.cdt.core.ccnature</nature>
+               <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+               <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+               <nature>com.osp.ide.badaNature</nature>
+       </natures>
+</projectDescription>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..2bef2dd
--- /dev/null
@@ -0,0 +1,65 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET (this_target osp-security-service)
+SET (APPID q7097a278m)
+
+SET(CMAKE_EXECUTABLE_SUFFIX ".exe")
+SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/output")
+
+INCLUDE_DIRECTORIES (
+       inc
+       )
+
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+       osp-appfw-server
+       chromium
+       glib-2.0
+       osp-appfw
+       vconf
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET (${this_target}_SOURCE_FILES
+       src/SecurityService.cpp
+       src/SecurityServiceEntry.cpp
+       src/SecurityServiceMessage.cpp 
+## PrivilegeService
+       src/PrivilegeService.cpp
+## CertificateService
+       src/CertificateService.cpp
+       src/CertificateServiceStub.cpp
+## DrmService
+       src/DrmService.cpp
+       )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -pthread -g3 -fPIE" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+SET(CMAKE_SKIP_BUILD_RPATH FALSE)
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+SET(CMAKE_INSTALL_RPATH "/usr/lib/osp-server")
+SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
+
+## Create Library
+ADD_EXECUTABLE (${this_target} ${${this_target}_SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker --as-needed -pie)
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --version-script=${CMAKE_CURRENT_SOURCE_DIR}/system-service-export.ver)
+TARGET_LINK_LIBRARIES(${this_target} "-ldl" )
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+
+## Copy additional info
+INSTALL(TARGETS ${this_target} DESTINATION ../usr/apps/${APPID}/bin)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/manifest.xml DESTINATION ../usr/apps/${APPID}/info)
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100755 (executable)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT 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/NOTICE b/NOTICE
new file mode 100755 (executable)
index 0000000..cbdf92f
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
diff --git a/data/.readme b/data/.readme
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/icons/screen-density-xhigh/mainmenu.png b/icons/screen-density-xhigh/mainmenu.png
new file mode 100644 (file)
index 0000000..b0979b1
Binary files /dev/null and b/icons/screen-density-xhigh/mainmenu.png differ
diff --git a/inc/CertificateService.h b/inc/CertificateService.h
new file mode 100644 (file)
index 0000000..a117995
--- /dev/null
@@ -0,0 +1,113 @@
+//
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT 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               OspCerMgrServiceD.h
+ * @brief              This is the header file of the Certificate Manger daemon.
+ */
+
+#ifndef _CERTMGR_SERVICE_H_
+#define _CERTMGR_SERVICE_H_
+
+#include <FApp.h>
+#include <FIo.h>
+#include <FIoIFileEventListener.h>
+#include <FIoFileEventManager.h>
+
+namespace Tizen { namespace Security { namespace Cert
+{
+
+class _CertServiceStub;
+
+} } }
+
+//opt/share/cert-svc/certs/
+class FileEventListenerCerts
+       : public Tizen::Io::IFileEventListener
+{
+public:
+       virtual void OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId);
+};
+
+//opt/share/cert-svc/certs/sim/
+class FileEventListenerCertsSim
+       : public Tizen::Io::IFileEventListener
+{
+public:
+       virtual void OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId);
+};
+
+//opt/share/cert-svc/certs/sim/operator/
+class FileEventListenerCertsSimOperator
+       : public Tizen::Io::IFileEventListener
+{
+public:
+       virtual void OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId);
+};
+
+//opt/share/cert-svc/certs/sim/thirdparty/
+class FileEventListenerCertsSimThirdparty
+       : public Tizen::Io::IFileEventListener
+{
+public:
+       virtual void OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId);
+};
+
+//opt/share/cert-svc/certs/ssl/
+class FileEventListenerCertsSsl
+       : public Tizen::Io::IFileEventListener
+{
+public:
+       virtual void OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId);
+};
+
+//usr/share/cert-svc/ca-certs/
+class FileEventListenerUsrCaCerts
+       : public Tizen::Io::IFileEventListener
+{
+public:
+       virtual void OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId);
+};
+
+/**
+ * [CertificateService] Manages Certificate privilege API calls
+ */
+class CertificateService
+{
+public:
+       CertificateService();
+       ~CertificateService();
+       result Construct(void);
+
+private:
+       Tizen::Security::Cert::_CertServiceStub* __pCertMgrServer;
+       Tizen::Io::FileEventManager __fileEventManagerCerts;
+       Tizen::Io::FileEventManager __fileEventManagerCertsSim;
+       Tizen::Io::FileEventManager __fileEventManagerCertsSimOperator;
+       Tizen::Io::FileEventManager __fileEventManagerCertsSimThirdparty;
+       Tizen::Io::FileEventManager __fileEventManagerCertsSsl;
+       Tizen::Io::FileEventManager __fileEventManagerUsrCaCerts;
+       Tizen::Io::FileEventManager __fileEventManagerUsrCaCertsSsl;
+
+       FileEventListenerCerts* __pFileEventListenerCerts;
+       FileEventListenerCertsSim* __pFileEventListenerCertsSim;
+       FileEventListenerCertsSimOperator* __pFileEventListenerCertsSimOperator;
+       FileEventListenerCertsSimThirdparty* __pFileEventListenerCertsSimThirdparty;
+       FileEventListenerCertsSsl* __pFileEventListenerCertsSsl;
+       FileEventListenerUsrCaCerts* __pFileEventListenerUsrCaCerts;
+};
+
+#endif // _CERTMGR_SERVICE_H_
diff --git a/inc/CertificateServiceStub.h b/inc/CertificateServiceStub.h
new file mode 100755 (executable)
index 0000000..5d9d964
--- /dev/null
@@ -0,0 +1,115 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT 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 _CERTMGR_SERVICE_STUB_H_
+#define _CERTMGR_SERVICE_STUB_H_
+
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+
+#include "FIo_IIpcServerEventListener.h"
+#include "FIo_IpcCommonParamTraits.h"
+#include "FSecCert_CertTypes.h"
+
+namespace Tizen { namespace Io
+{
+class _IpcServer;
+} }
+
+namespace Tizen { namespace Security { namespace Cert
+{
+
+class _OSP_EXPORT_ _CertServiceStub
+       : public Tizen::Io::_IIpcServerEventListener
+       , public Tizen::Base::Object
+{
+public:
+       _CertServiceStub(void);
+
+       virtual ~_CertServiceStub(void);
+
+public:
+       // __IIPcServerEventListener interfaces
+       virtual result Construct(void);
+
+       virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server);
+
+       virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server);
+
+       virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId);
+
+       virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer& server, int clientId);
+
+       virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message);
+
+       //CertService handler method
+
+       bool OnGetName(result* pRet);
+
+       bool OnCloseCertificateStore(int certificateStoreCtx, result* pRet);
+
+       bool OnOpenCertificateStoreByType(int type, int* pCount, result* pRet);
+
+       bool OnGetCertificateCount(int type, int* pCertCount, result* pRet);
+
+       bool OnGetNextCertificate(int type, int curPos, int length, Tizen::Base::ByteBuffer* pCertBufferIpc, int* pNewPos, result* pRet);
+
+       bool OnUpdateRootCa(int type, Tizen::Io::_IpcBuffer certOldBufferIpc, Tizen::Io::_IpcBuffer certNewBufferIpc, result* pRet);
+
+       bool OnRemoveRootCa(int type, Tizen::Io::_IpcBuffer certBufferIpc, int bufLen, result* pRet);
+
+       bool OnUninstallUserRootCertificateByCertId(int certId, result* pRet);
+
+       bool OnInsertCaCertificate(int type, int format, Tizen::Io::_IpcBuffer certBuffer, long certLen, result* pRet);
+
+       bool OnInsertUserCaCertificate(int format, Tizen::Io::_IpcBuffer certBuffer, int certLen, result* pRet);
+
+       bool OnInstallUserRootCertificate(Tizen::Io::_IpcBuffer filePath, result* pRet);
+
+       bool OnInsertUserCertChainPrivateKey(Tizen::Io::_IpcBuffer certChainBufferIpc, int certSize, Tizen::Io::_IpcBuffer privateKeyBufferIpc, int userPriKeyLen, result* pRet);
+
+       bool OnInsertCertificateChainWithPrivateKey(Tizen::Io::_IpcBuffer certChainPrivateKeyBufferIpc, int certChainPrivateKeyLength, result* pRet);
+
+       bool OnInstallPkcs12Content(Tizen::Io::_IpcBuffer pkcs12FilePath, Tizen::Io::_IpcBuffer pkcs12ImportPassword, bool checkPrivilege, result* pRet);
+
+       bool OnDeleteUserCertChainByCertId(int certID, result* pRet);
+
+       bool OnGetUserCertChainByIssuerAndSubjectNameN(Tizen::Io::_IpcBuffer issuerBufferIpc, int issuerNameLen, Tizen::Io::_IpcBuffer subjectBufferIpc, int subNameLen, _CertificateListInfo* pCertList, result* pRet);
+
+       bool OnGetUserCertificateByCertIdN(int certId, int encodingType, _CertInfo* pUserCertificateList, result* pRet);
+
+       bool OnGetUserCertFieldInfoByCertId(int certId, _CertFieldInfos* pCertFieldInfos, result* pRet);
+       
+       bool OnRestoreRootCaIntegrity(void);
+
+       result UpdateCertStoreContext(void);
+
+private:
+       _CertServiceStub(const _CertServiceStub& rhs);
+
+       _CertServiceStub& operator =(const _CertServiceStub& rhs);
+
+private:
+       Tizen::Io::_IpcServer* __pIpcServer;
+       int __context;
+       int __refCount;
+}; // _CertServiceStub
+
+} } } // Tizen::Security::Cert
+
+#endif // _CERTMGR_SERVICE_STUB_H_
diff --git a/inc/DrmService.h b/inc/DrmService.h
new file mode 100644 (file)
index 0000000..5bb1633
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT  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               DrmService.h
+ * @brief              This is the header file of the DRM Service.
+ */
+
+#ifndef _DRM_SERVICE_H_
+#define _DRM_SERVICE_H_
+
+#include <FIo.h>
+#include <DrmServiceDl.h>
+
+#define DRM_SERVICE "TIZEN_DRM_SERVICE"
+
+namespace Tizen { namespace Base
+{
+       class String;
+}}
+
+namespace Tizen { namespace Io
+{
+       class IMessagePortListener;
+}}
+
+namespace Tizen { namespace Io
+{
+       class RemoteMessagePort;
+}}
+
+namespace Tizen { namespace Io
+{
+       class LocalMessagePort;
+}}
+
+namespace Tizen { namespace Base { namespace Collection
+{
+       class IMap;
+}}}
+
+class DrmService
+       : public Tizen::Io::IMessagePortListener
+{
+public :
+       static DrmService* GetInstance();
+       static void FreeInstance(void);
+       virtual void OnMessageReceivedN(Tizen::Io::RemoteMessagePort* pRemoteMessagePort, Tizen::Base::Collection::IMap* pMessage);
+
+private :
+       DrmService(void);
+       ~DrmService(void);
+
+       result Construct(void);
+       int DrmDlCall(void);
+
+       static DrmService *m_pInstance;
+       void *m_sapps_handle;
+       drm_sapps_func_t m_sapps_symbol;
+       bool m_isdlopened;
+
+       Tizen::Io::LocalMessagePort* __pLocalMessagePort;
+};
+
+#endif // _SAMPLE_MESSAGE_PORT_H_
diff --git a/inc/DrmServiceDl.h b/inc/DrmServiceDl.h
new file mode 100644 (file)
index 0000000..f21d732
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * DrmServiceDl.h
+ *
+ *  Created on: Mar 25, 2013
+ *      Author: manyfun
+ */
+
+#ifndef _DRMSERVICE_DL_H_
+#define _DRMSERVICE_DL_H_
+
+#define DLOPEN_FAILED  -1
+#define DLSYM_FAILED   -2
+#define SADC_SUCCESS   1
+
+#define DRM_SAPPS_SO_PATH      "/usr/lib/libdrm-service-core-tizen.so"
+
+/*Samsung Apps DRM*/
+typedef int (*DRM_OEM_SAPPS_GENERATE_LICENSE_REQUEST) (const char *pRespBuf, unsigned int respBufLen, char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl, unsigned int *pLicenseUrlLen);
+typedef int (*DRM_OEM_SAPPS_REGISTER_LICENSE) (const char *pRespBuf, unsigned int respBufLen);
+typedef int (*DRM_OEM_SAPPS_IS_DRM_FILE) (const char *pDcfPath, int dcfPathLen);
+typedef int (*DRM_OEM_SAPPS_DECRYPT_PACKAGE) (const char *pSADCFilepath, int sadcFileLen, const char *pDecryptedFile, int decryptedFileLen);
+typedef int (*DRM_OEM_SAPPS_GENERATE_PURCHASE_REQUEST) (const char *pSADCFilepath, char *pReqBuf, unsigned int *pReqBufLen, char *pLicenseUrl, unsigned int *pLicenseUrlLen);
+
+/*Samsung Apps function start*/
+typedef enum {
+       FUNC_DRM_OEM_SAPPS_GENERATE_LICENSE_REQUEST = 0,
+       FUNC_DRM_OEM_SAPPS_REGISTER_LICENSE,
+       FUNC_DRM_OEM_SAPPS_IS_DRM_FILE,
+       FUNC_DRM_OEM_SAPPS_DECRYPT_PACKAGE,
+       FUNC_DRM_OEM_SAPPS_GENERATE_PURCHASE_REQUEST,
+       FUNC_DRM_SAPPS_MAX
+} drm_sapps_enum_t;
+
+typedef struct {
+       DRM_OEM_SAPPS_GENERATE_LICENSE_REQUEST drm_oem_sapps_generate_license_request;
+       DRM_OEM_SAPPS_REGISTER_LICENSE drm_oem_sapps_register_license;
+       DRM_OEM_SAPPS_IS_DRM_FILE drm_oem_sapps_is_drm_file;
+       DRM_OEM_SAPPS_DECRYPT_PACKAGE drm_oem_sapps_decrypt_package;
+       DRM_OEM_SAPPS_GENERATE_PURCHASE_REQUEST drm_oem_sapps_generate_purchase_request;
+} drm_sapps_func_t;
+
+#endif
diff --git a/inc/PrivilegeService.h b/inc/PrivilegeService.h
new file mode 100644 (file)
index 0000000..be7e163
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT  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               PrivilegeService.h
+ * @brief              This is the header file of the Privilege Manger daemon.
+ */
+
+#ifndef _PRIVILEGE_SERVICE_H_
+#define _PRIVILEGE_SERVICE_H_
+
+#include <FIo_IIpcServerEventListener.h>
+
+#define OSP_SECURITY_SERVICE   "osp-security-service"
+
+namespace Tizen { namespace Io
+{
+       class _IpcServer;
+}}
+
+namespace IPC
+{
+       class Message;
+}
+
+namespace Tizen { namespace Base
+{
+       class String;
+}}
+
+namespace Tizen { namespace Base { namespace Collection
+{
+       template<typename T>
+       class ArrayListT;
+}}}
+
+class _OSP_EXPORT_ PrivilegeService
+       : public Tizen::Io::_IIpcServerEventListener
+{
+
+public:
+       PrivilegeService(void);
+       ~PrivilegeService(void);
+       result Construct(void);
+
+public:
+
+       virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server);
+       virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server);
+       virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId);
+       virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer& server, int clientId);
+       virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message);
+
+       bool RetrievePrivilege(Tizen::Base::String* pEncryptedBitwise, Tizen::Base::String* pHmac, Tizen::Base::Collection::ArrayListT < Tizen::Base::String >* pPrivilegeList, result* pRes);
+       bool RetrieveVisibility(Tizen::Base::String* pEncryptedVisibility, Tizen::Base::String* pHmac, result* pRes);
+
+private:
+       Tizen::Io::_IpcServer* __pIpcServer;
+}; // PrivilegeService
+
+#endif // _PRIVILEGE_SERVICE_H_
diff --git a/inc/SecurityService.h b/inc/SecurityService.h
new file mode 100644 (file)
index 0000000..35ccc29
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT  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               SecurityService.h
+ * @brief              This is the header file of the Security service.
+ */
+
+#ifndef _SECURITY_SERVICE_H_
+#define _SECURITY_SERVICE_H_
+
+#include <FAppServiceApp.h>
+#include <vconf.h>
+
+namespace Tizen { namespace App
+{
+       class AppRegistry;
+}}
+
+namespace Tizen { namespace Base { namespace Collection
+{
+       class IList;
+}}}
+
+class PrivilegeService;
+class CertificateService;
+class DrmService;
+
+class _OSP_EXPORT_ SecurityService
+       : public Tizen::App::Service
+{
+public:
+       static Tizen::App::Service* CreateInstance(void);
+
+public:
+       SecurityService(void);
+       ~SecurityService(void);
+
+public:
+       bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
+       bool OnAppInitialized(void);
+       bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
+       void OnLowMemory(void);
+       void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList *pArgs);
+
+private:
+       static void OnChannelServiceLaunched(keynode_t* node, void* userData);
+
+       PrivilegeService* __pPrivilegeService;
+       CertificateService* __pCertificateService;
+}; // SecurityService
+
+#endif // _SECURITY_SERVICE_H_
diff --git a/manifest.xml b/manifest.xml
new file mode 100644 (file)
index 0000000..fba3367
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<Manifest xmlns="http://schemas.tizen.org/2012/06/manifest">
+       <Id>q7097a278m</Id>
+       <Version>1.0.0</Version>
+       <Type>C++App</Type>
+       <Vendors>
+               <Vendor Locale="eng-GB">Samsung Electronics</Vendor>
+               <Vendor Locale="kor-KR">삼성전자</Vendor>
+       </Vendors>
+       <Descriptions>
+               <Description Locale="eng-US">Security service.</Description>
+       </Descriptions>
+       <Apps>
+               <Secret>AA43CFC79D2AF5A3F7064553C8BF2B2F</Secret>
+               <Privileges/>
+               <ApiVersion>2.1</ApiVersion>
+               <ServiceApp SystemService="True" ExecutableName="osp-security-service" Default="True" AutoRestart="True">
+                       <Names>
+                               <Name Locale="eng-GB">Native Security Service</Name>
+                       </Names>
+                       <Icons/>
+                       <AppControls/>
+                       <LaunchConditions/>
+                       <Notifications/>
+               </ServiceApp>
+       </Apps>
+</Manifest>
diff --git a/osp-security-service.manifest b/osp-security-service.manifest
new file mode 100755 (executable)
index 0000000..f0a9ce7
--- /dev/null
@@ -0,0 +1,26 @@
+<manifest>
+       <define>
+               <domain name="q7097a278m"/>
+               <provide>
+                       <label name="q7097a278m::usercert"/>
+               </provide>
+               <request>
+                       <smack request="q7097a278m::usercert" type="rwxat"/>
+                       <smack request="cert-svc" type="x"/>
+                       <smack request="_" type="rxt"/>
+               </request>
+               <permit>
+                       <smack permit="org.tizen.setting" type="rwxat"/>
+               </permit>
+       </define>
+       <request>
+               <domain name="q7097a278m"/>
+       </request>
+       <assign>
+               <filesystem path="/usr/share/license/osp-security-service" label="_"/>
+               <filesystem path="/opt/usr/share/certs" label="_" type="transmutable"/>
+               <filesystem path="/opt/usr/share/certs/rootcert" label="_" type="transmutable"/>
+               <filesystem path="/opt/usr/share/certs/usercert" label="q7097a278m::usercert" type="transmutable"/>
+               <filesystem path="/opt/usr/share/certs/usercert/key" label="q7097a278m::usercert" type="transmutable"/>
+       </assign>
+</manifest>
diff --git a/packaging/osp-security-service.spec b/packaging/osp-security-service.spec
new file mode 100755 (executable)
index 0000000..ddac719
--- /dev/null
@@ -0,0 +1,104 @@
+Name:          osp-security-service
+Summary:       osp security service
+Version:       1.2.2.1
+Release:       1
+Group:         TO_BE/FILLED_IN
+License:       Apache-2.0
+Source0:       %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(chromium)
+BuildRequires:  pkgconfig(capi-system-media-key)
+BuildRequires:  pkgconfig(capi-network-bluetooth)
+BuildRequires:  pkgconfig(pkgmgr)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(osp-appfw)
+
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(vconf-internal-keys)
+
+BuildRequires:  osp-appfw-internal-devel
+BuildRequires:  hash-signer
+
+# pre-script for certificate db
+BuildRequires:  coreutils
+BuildRequires:  vim-common
+BuildRequires:  sed
+BuildRequires:  bash
+BuildRequires:  sqlite
+BuildRequires:  openssl
+BuildRequires:  ca-certificates
+
+# smack domain requires
+Requires(post):        org.tizen.setting
+Requires(post):        cert-svc
+
+# runtime requires
+Requires: osp-appfw
+Requires: osp-installer
+Requires: osp-app-service
+Requires: osp-channel-service
+Requires: libcryptsvc
+
+%description
+osp security service
+
+%prep
+%setup -q
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+
+%ifarch %{ix86}
+       ARCH=x86
+       CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_"
+       %if 0%{?simulator}
+               CXXFLAGS="$CXXFLAGS -D_OSP_EMUL_"
+       %endif
+%else
+       ARCH=arm
+       CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_"
+%endif
+
+%if 0%{?tizen_build_binary_release_type_eng}
+       CXXFLAGS="$CXXFLAGS -D_SECURE_LOG"
+%endif
+
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=${ARCH}
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2  %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%{_builddir}/%{name}-%{version}/tool/mk-cert-db.sh
+mkdir -p %{buildroot}/opt/usr/share
+cp %{_builddir}/%{name}-%{version}/certs   %{buildroot}/opt/usr/share/ -rf
+cp %{_builddir}/%{name}-%{version}/dbspace %{buildroot}/opt/usr/ -rf
+
+###### for package signing step ######
+PKG_ID=q7097a278m
+%define tizen_sign 1
+%define tizen_sign_base /usr/apps/${PKG_ID}
+%define tizen_sign_level public
+%define tizen_author_sign 1
+%define tizen_dist_sign 1
+
+%post
+/bin/rm -fr /opt/apps/q7097a278m
+/usr/etc/package-manager/backend/tpk -i /usr/apps/q7097a278m
+
+%files
+%dir %attr(0711, root, root) /opt/usr/share/certs
+%dir %attr(0711, root, root) /opt/usr/share/certs/rootcert
+%dir %attr(0755, root, root) /opt/usr/share/certs/usercert
+%dir %attr(0755, root, root) /opt/usr/share/certs/usercert/key
+%manifest osp-security-service.manifest
+/usr/share/license/%{name}
+/usr/apps/*
+/opt/usr/share/certs/*
+/opt/usr/dbspace/.security*
diff --git a/res/.readme b/res/.readme
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/CertificateService.cpp b/src/CertificateService.cpp
new file mode 100644 (file)
index 0000000..6a6e437
--- /dev/null
@@ -0,0 +1,422 @@
+//
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT 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               CertificateService.cpp
+ * @brief              This is the implementation file for CertificateService class.
+ */
+
+#include <new>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <error.h>
+#include <memory.h>
+#include <malloc.h>
+#include <unique_ptr.h>
+#include <sys/stat.h>
+#include <assert.h>
+#include <FOspConfig.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FBaseRt_EventDispatcher.h>
+#include <FIo_IpcServer.h>
+#include <CertificateServiceStub.h>
+#include "FSecCert_CertServer.h"
+#include <FIo_DirectoryImpl.h>
+
+#include "CertificateService.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Security::Cert;
+
+const String __CERT_MGR_DIR_CERTS__(L"/opt/share/cert-svc/certs/");
+const String __CERT_MGR_DIR_CERTS_SIM__(L"/opt/share/cert-svc/certs/sim/");
+const String __CERT_MGR_DIR_CERTS_SIM_OPERATOR__(L"/opt/share/cert-svc/certs/sim/operator/");
+const String __CERT_MGR_DIR_CERTS_SIM_THIRDPARTY__(L"/opt/share/cert-svc/certs/sim/thirdparty/");
+const String __CERT_MGR_DIR_CERTS_SSL__(L"/opt/share/cert-svc/certs/ssl/");
+const String __CERT_MGR_DIR_CA_CERTS__(L"/usr/share/cert-svc/ca-certs/");
+
+CertificateService::CertificateService()
+       : __pCertMgrServer(null)
+       , __pFileEventListenerCerts(null)
+       , __pFileEventListenerCertsSim(null)
+       , __pFileEventListenerCertsSimOperator(null)
+       , __pFileEventListenerCertsSimThirdparty(null)
+       , __pFileEventListenerCertsSsl(null)
+       , __pFileEventListenerUsrCaCerts(null)
+{
+}
+result
+CertificateService::Construct()
+{
+       result r = E_SUCCESS;
+       String certsDir(__CERT_MGR_DIR_CERTS__);
+       String certsSimDir(__CERT_MGR_DIR_CERTS_SIM__);
+       String certsSimOperatorDir(__CERT_MGR_DIR_CERTS_SIM_OPERATOR__);
+       String certsSimThirdPartyDir(__CERT_MGR_DIR_CERTS_SIM_THIRDPARTY__);
+       String certsSslDir(__CERT_MGR_DIR_CERTS_SSL__);
+       String caCertsDir(__CERT_MGR_DIR_CA_CERTS__);
+
+       __pCertMgrServer = new (std::nothrow) Tizen::Security::Cert::_CertServiceStub();
+       TryReturnResult(__pCertMgrServer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to initialize cert mgr server.");
+
+       r = __pCertMgrServer->Construct();
+       if (IsFailed(r))
+       {
+               delete __pCertMgrServer;
+               __pCertMgrServer = null;
+
+               TryReturnResult(false, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed constructed certificate manager service.");
+       }
+
+       __pFileEventListenerCerts = new (std::nothrow) FileEventListenerCerts();
+       TryCatchResult(__pFileEventListenerCerts != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+       __pFileEventListenerCertsSim = new (std::nothrow) FileEventListenerCertsSim();
+       TryCatchResult(__pFileEventListenerCertsSim != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+       __pFileEventListenerCertsSimOperator = new (std::nothrow) FileEventListenerCertsSimOperator();
+       TryCatchResult(__pFileEventListenerCertsSimOperator != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+       __pFileEventListenerCertsSimThirdparty = new (std::nothrow) FileEventListenerCertsSimThirdparty();
+       TryCatchResult(__pFileEventListenerCertsSimThirdparty != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+       __pFileEventListenerCertsSsl = new (std::nothrow) FileEventListenerCertsSsl();
+       TryCatchResult(__pFileEventListenerCertsSsl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+       __pFileEventListenerUsrCaCerts = new (std::nothrow) FileEventListenerUsrCaCerts();
+       TryCatchResult(__pFileEventListenerUsrCaCerts != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+       r = __fileEventManagerCerts.Construct(*__pFileEventListenerCerts);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed constructed file event manager.");
+
+       r = __fileEventManagerCerts.AddPath(certsDir, FILE_EVENT_TYPE_CLOSE_WRITE);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed add path in file event manager.");
+
+       r = __fileEventManagerCertsSim.Construct(*__pFileEventListenerCertsSim);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed constructed file event manager.");
+
+       r = __fileEventManagerCertsSim.AddPath(certsSimDir, FILE_EVENT_TYPE_CLOSE_WRITE);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed add path in file event manager.");
+
+       r = __fileEventManagerCertsSimOperator.Construct(*__pFileEventListenerCertsSimOperator);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed constructed file event manager.");
+
+       r = __fileEventManagerCertsSimOperator.AddPath(certsSimOperatorDir, FILE_EVENT_TYPE_CLOSE_WRITE);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed add path in file event manager.");
+
+       r = __fileEventManagerCertsSimThirdparty.Construct(*__pFileEventListenerCertsSimThirdparty);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed constructed file event manager.");
+
+       r = __fileEventManagerCertsSimThirdparty.AddPath(certsSimThirdPartyDir, FILE_EVENT_TYPE_CLOSE_WRITE);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed add path in file event manager.");
+
+       r = __fileEventManagerCertsSsl.Construct(*__pFileEventListenerCertsSsl);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed constructed file event manager.");
+
+       r = __fileEventManagerCertsSsl.AddPath(certsSslDir, FILE_EVENT_TYPE_CLOSE_WRITE);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed add path in file event manager.");
+
+       r = __fileEventManagerUsrCaCerts.Construct(*__pFileEventListenerUsrCaCerts);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed constructed file event manager.");
+
+       r = __fileEventManagerUsrCaCerts.AddPath(caCertsDir, FILE_EVENT_TYPE_CLOSE_WRITE);
+       TryCatchResult(!(IsFailed(r) && r != E_FILE_NOT_FOUND), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed add path in file event manager.");
+
+CATCH:
+       return r;
+}
+CertificateService::~CertificateService()
+{
+       delete __pFileEventListenerCerts;
+       delete __pFileEventListenerCertsSim;
+       delete __pFileEventListenerCertsSimOperator;
+       delete __pFileEventListenerCertsSimThirdparty;
+       delete __pFileEventListenerCertsSsl;
+       delete __pFileEventListenerUsrCaCerts;
+       delete __pCertMgrServer;
+}
+
+
+void
+FileEventListenerCerts::OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId)
+{
+       result r = E_SUCCESS;
+       String fileName(path);
+       String dirPath;
+       FileAttributes attr;
+       File file;
+       long long size;
+       int readCnt;
+       int certBuffLength = 0;
+
+       dirPath.Append(__CERT_MGR_DIR_CERTS__);
+       dirPath.Append(fileName);
+
+       r = file.Construct(dirPath, L"r");
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to construct file.");
+
+       r = File::GetAttributes(dirPath, attr);
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to get file attributes.");
+
+       size = attr.GetFileSize();
+
+       std::unique_ptr< byte[] > pCertBuffer(new (std::nothrow) byte[size]);
+       TryReturnVoidResult(pCertBuffer != null, E_SYSTEM, "[E_SYSTEM] Failed to allocate buffer.");
+
+       readCnt = file.Read(pCertBuffer.get(), size);
+       r = GetLastResult();
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to read file.");
+
+       certBuffLength = static_cast< int >(readCnt);
+       TryReturnVoidResult(certBuffLength > 0, E_SYSTEM, "[E_SYSTEM] Failed to read file.");
+
+       switch (events)
+       {
+       case FILE_EVENT_TYPE_CLOSE_WRITE:
+               r = _CertServer::InsertCaCertificate(_CERT_TYPE_ROOT_CA, _CERT_X509, pCertBuffer.get(), certBuffLength);
+               TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to insert root certificate.");
+               break;
+
+       default:
+               break;
+       }
+}
+
+void
+FileEventListenerCertsSim::OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId)
+{
+       result r = E_SUCCESS;
+       String fileName(path);
+       String dirPath;
+       FileAttributes attr;
+       File file;
+       long long size;
+       int readCnt;
+       int certBuffLength = 0;
+
+       dirPath.Append(__CERT_MGR_DIR_CERTS_SIM__);
+       dirPath.Append(fileName);
+
+       r = file.Construct(dirPath, L"r");
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to construct file.");
+
+       r = File::GetAttributes(dirPath, attr);
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to get file attributes.");
+
+       size = attr.GetFileSize();
+
+       std::unique_ptr< byte[] > pCertBuffer(new (std::nothrow) byte[size]);
+       TryReturnVoidResult(pCertBuffer != null, E_SYSTEM, "[E_SYSTEM] Failed to allocate buffer.");
+
+       readCnt = file.Read(pCertBuffer.get(), size);
+       r = GetLastResult();
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to read file.");
+
+       certBuffLength = static_cast< int >(readCnt);
+
+       switch (events)
+       {
+       case FILE_EVENT_TYPE_CLOSE_WRITE:
+               r = _CertServer::InsertCaCertificate(_CERT_TYPE_ROOT_CA, _CERT_X509, pCertBuffer.get(), certBuffLength);
+               TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to insert root certificate.");
+               break;
+
+       default:
+               break;
+       }
+}
+
+void
+FileEventListenerCertsSimOperator::OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId)
+{
+       result r = E_SUCCESS;
+       String fileName(path);
+       String dirPath;
+       FileAttributes attr;
+       File file;
+       long long size;
+       int readCnt;
+       int certBuffLength = 0;
+
+       dirPath.Append(__CERT_MGR_DIR_CERTS_SIM_OPERATOR__);
+       dirPath.Append(fileName);
+
+       r = file.Construct(dirPath, L"r");
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to construct file.");
+
+       r = File::GetAttributes(dirPath, attr);
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to get file attributes.");
+
+       size = attr.GetFileSize();
+
+       std::unique_ptr< byte[] > pCertBuffer(new (std::nothrow) byte[size]);
+       TryReturnVoidResult(pCertBuffer != null, E_SYSTEM, "[E_SYSTEM] Failed to allocate buffer.");
+
+       readCnt = file.Read(pCertBuffer.get(), size);
+       r = GetLastResult();
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to read file.");
+
+       certBuffLength = static_cast< int >(readCnt);
+
+       switch (events)
+       {
+       case FILE_EVENT_TYPE_CLOSE_WRITE:
+               r = _CertServer::InsertCaCertificate(_CERT_TYPE_ROOT_CA, _CERT_X509, pCertBuffer.get(), certBuffLength);
+               TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to insert root certificate.");
+               break;
+
+       default:
+               break;
+       }
+}
+
+void
+FileEventListenerCertsSimThirdparty::OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId)
+{
+       result r = E_SUCCESS;
+       String fileName(path);
+       String dirPath;
+       FileAttributes attr;
+       File file;
+       long long size;
+       int readCnt;
+       int certBuffLength = 0;
+
+       dirPath.Append(__CERT_MGR_DIR_CERTS_SIM_THIRDPARTY__);
+       dirPath.Append(fileName);
+
+       r = file.Construct(dirPath, L"r");
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to construct file.");
+
+       r = File::GetAttributes(dirPath, attr);
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to get file attributes.");
+
+       size = attr.GetFileSize();
+
+       std::unique_ptr< byte[] > pCertBuffer(new (std::nothrow) byte[size]);
+       TryReturnVoidResult(pCertBuffer != null, E_SYSTEM, "[E_SYSTEM] Failed to allocate buffer.");
+
+       readCnt = file.Read(pCertBuffer.get(), size);
+       r = GetLastResult();
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to read file.");
+
+       certBuffLength = static_cast< int >(readCnt);
+
+       switch (events)
+       {
+       case FILE_EVENT_TYPE_CLOSE_WRITE:
+               r = _CertServer::InsertCaCertificate(_CERT_TYPE_ROOT_CA, _CERT_X509, pCertBuffer.get(), certBuffLength);
+               TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to insert root certificate.");
+               break;
+
+       default:
+               break;
+       }
+}
+
+void
+FileEventListenerCertsSsl::OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId)
+{
+       result r = E_SUCCESS;
+       String fileName(path);
+       String dirPath;
+       FileAttributes attr;
+       File file;
+       long long size;
+       int readCnt;
+       int certBuffLength = 0;
+
+       dirPath.Append(__CERT_MGR_DIR_CERTS_SSL__);
+       dirPath.Append(fileName);
+
+       r = file.Construct(dirPath, L"r");
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to construct file.");
+
+       r = File::GetAttributes(dirPath, attr);
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to get file attributes.");
+
+       size = attr.GetFileSize();
+
+       std::unique_ptr< byte[] > pCertBuffer(new (std::nothrow) byte[size]);
+       TryReturnVoidResult(pCertBuffer != null, E_SYSTEM, "[E_SYSTEM] Failed to allocate buffer.");
+
+       readCnt = file.Read(pCertBuffer.get(), size);
+       r = GetLastResult();
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to read file.");
+
+       certBuffLength = static_cast< int >(readCnt);
+
+       switch (events)
+       {
+       case FILE_EVENT_TYPE_CLOSE_WRITE:
+               r = _CertServer::InsertCaCertificate(_CERT_TYPE_ROOT_CA, _CERT_X509, pCertBuffer.get(), certBuffLength);
+               TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to insert root certificate.");
+               break;
+
+       default:
+               break;
+       }
+}
+
+void
+FileEventListenerUsrCaCerts::OnFileEventOccured(const unsigned long events, const Tizen::Base::String& path, const unsigned int eventId)
+{
+       result r = E_SUCCESS;
+       String fileName(path);
+       String dirPath;
+       FileAttributes attr;
+       File file;
+       long long size;
+       int readCnt;
+       int certBuffLength = 0;
+
+       dirPath.Append(__CERT_MGR_DIR_CA_CERTS__);
+       dirPath.Append(fileName);
+
+       r = file.Construct(dirPath, L"r");
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to construct file.");
+
+       r = File::GetAttributes(dirPath, attr);
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to get file attributes.");
+
+       size = attr.GetFileSize();
+
+       std::unique_ptr< byte[] > pCertBuffer(new (std::nothrow) byte[size]);
+       TryReturnVoidResult(pCertBuffer != null, E_SYSTEM, "[E_SYSTEM] Failed to allocate buffer.");
+
+       readCnt = file.Read(pCertBuffer.get(), size);
+       r = GetLastResult();
+       TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to read file.");
+
+       certBuffLength = static_cast< int >(readCnt);
+
+       switch (events)
+       {
+       case FILE_EVENT_TYPE_CLOSE_WRITE:
+               r = _CertServer::InsertCaCertificate(_CERT_TYPE_ROOT_CA, _CERT_X509, pCertBuffer.get(), certBuffLength);
+               TryReturnVoidResult(!IsFailed(r), E_SYSTEM, "[E_SYSTEM] Failed to insert root certificate.");
+               break;
+
+       default:
+               break;
+       }
+}
diff --git a/src/CertificateServiceStub.cpp b/src/CertificateServiceStub.cpp
new file mode 100755 (executable)
index 0000000..aa53b1a
--- /dev/null
@@ -0,0 +1,508 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT 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 <unique_ptr.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <error.h>
+#include <memory.h>
+#include <new>
+#include <sys/stat.h>
+#include <assert.h>
+#include <dirent.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include <FBaseRt_EventDispatcher.h>
+#include <FIo_IpcServer.h>
+#include <FSec_AccessController.h>
+#include <FSec_AccessControlTypes.h>
+#include <FApp_AppInfo.h>
+#include <CertificateServiceStub.h>
+#include <FSecCert_CertMgrMessages.h>
+#include <FSecCert_CertServer.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::App;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Security { namespace Cert
+{
+
+_CertServiceStub::_CertServiceStub(void)
+       : __pIpcServer(null)
+       , __context(0)
+       , __refCount(0)
+{
+}
+
+_CertServiceStub::~_CertServiceStub(void)
+{
+       if (__pIpcServer != null)
+       {
+               __pIpcServer->Stop();
+               delete __pIpcServer;
+       }
+}
+
+result
+_CertServiceStub::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       std::unique_ptr< _IpcServer > pIpcServer(new (std::nothrow) _IpcServer());
+       TryReturnResult(pIpcServer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = pIpcServer->Construct(L"osp.security.ipcserver.certmanager", *this);
+       TryReturnResult(!IsFailed(r), r, r, "[%s] Failed to create IPC server(%s)", GetErrorMessage(r), "CertService");
+
+       __pIpcServer = pIpcServer.release();
+
+       // It was replaced into the script due to N_SE-53394 (mk-cert-db.sh)
+       // _CertServer::InitializeDb();
+
+       return r;
+}
+
+bool
+_CertServiceStub::OnUpdateRootCa(int type, Tizen::Io::_IpcBuffer certOldBufferIpc, Tizen::Io::_IpcBuffer certNewBufferIpc, result* pRet)
+{
+       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_CERTIFICATE_WRITE);
+       TryCatchResult(!IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       *pRet = _CertServer::UpdateCaCertificate(static_cast< _CaCertType >(type), static_cast< char* >(certOldBufferIpc.pBuffer), certOldBufferIpc.size,
+                                                                                        static_cast< char* >(certNewBufferIpc.pBuffer), certNewBufferIpc.size);
+
+CATCH:
+       return true;
+}
+
+bool
+_CertServiceStub::OnRemoveRootCa(int type, Tizen::Io::_IpcBuffer certBufferIpc, int bufLen, result* pRet)
+{
+       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_CERTIFICATE_WRITE);
+       TryCatchResult(!IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       *pRet = _CertServer::RemoveCaCertificate(static_cast< _CaCertType >(type), static_cast< char* >(certBufferIpc.pBuffer), bufLen);
+
+CATCH:
+       return true;
+}
+
+bool
+_CertServiceStub::OnInsertCaCertificate(int type, int format, Tizen::Io::_IpcBuffer pCert, long certLen, result* pRet)
+{
+       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_CERTIFICATE_WRITE);
+       TryCatchResult(!IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       *pRet = _CertServer::InsertCaCertificate(static_cast< _CaCertType >(type), static_cast< _CertFormat >(format), static_cast< byte* >(pCert.pBuffer), certLen);
+
+CATCH:
+       return true;
+}
+
+bool
+_CertServiceStub::OnInsertUserCaCertificate(int format, Tizen::Io::_IpcBuffer pCert, int certLen, result* pRet)
+{
+       *pRet = _CertServer::InsertUserCaCertificate(static_cast< _CertFormat >(format), static_cast< char* >(pCert.pBuffer), certLen);
+
+       return true;
+}
+
+bool
+_CertServiceStub::OnInstallUserRootCertificate(Tizen::Io::_IpcBuffer filePath, result* pRet)
+{
+       *pRet = _CertServer::InsertUserCaCertificate(static_cast< byte* >(filePath.pBuffer));
+
+       return true;
+}
+
+//User Certificate APIs
+bool
+_CertServiceStub::OnInsertUserCertChainPrivateKey(Tizen::Io::_IpcBuffer certChainBufferIpc, int certSize, Tizen::Io::_IpcBuffer privateKeyBufferIpc, int userPriKeyLen, result* pRet)
+{
+       result r = E_SUCCESS;
+
+       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_CERTIFICATE_WRITE);
+       TryCatchResult(!IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       *pRet = _CertServer::InsertUserCertChainPrivateKey(static_cast< char* >(certChainBufferIpc.pBuffer), certSize, static_cast< char* >(privateKeyBufferIpc.pBuffer), userPriKeyLen);
+
+       r = UpdateCertStoreContext();
+       TryCatchResult(!IsFailed(r), , r, "[%s] Failed to update certificate store context.", GetErrorMessage(r), "_CertServer");
+
+CATCH:
+       return true;
+}
+
+bool
+_CertServiceStub::OnInsertCertificateChainWithPrivateKey(Tizen::Io::_IpcBuffer certChainPrivateKeyBufferIpc, int certChainPrivateKeyLength, result* pRet)
+{
+       *pRet = _CertServer::InsertCertificateChainWithPrivateKey(static_cast< char* >(certChainPrivateKeyBufferIpc.pBuffer), certChainPrivateKeyLength);
+
+       return true;
+}
+
+bool
+_CertServiceStub::OnInstallPkcs12Content(Tizen::Io::_IpcBuffer pkcs12FilePath, Tizen::Io::_IpcBuffer pkcs12ImportPassword, bool checkPrivilege, result* pRet)
+{
+       result r = E_SUCCESS;
+
+       if (checkPrivilege == true)
+       {
+               *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_CERTIFICATE_WRITE);
+               TryCatchResult(!IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+       }
+
+       *pRet = _CertServer::InsertPkcs12Content(static_cast< char* >(pkcs12FilePath.pBuffer), static_cast< char* >(pkcs12ImportPassword.pBuffer));
+
+       r = UpdateCertStoreContext();
+       TryCatchResult(!IsFailed(r), , r, "[%s] Failed to update certificate store context.", GetErrorMessage(r), "_CertServer");
+
+CATCH:
+       return true;
+}
+
+bool
+_CertServiceStub::OnDeleteUserCertChainByCertId(int certId, result* pRet)
+{
+       result r = E_SUCCESS;
+
+       *pRet = _CertServer::RemoveUserCertChainByCertId(certId);
+
+       r = UpdateCertStoreContext();
+       TryCatchResult(!IsFailed(r), , r, "[%s] Failed to update certificate store context.", GetErrorMessage(r), "_CertServer");
+
+CATCH:
+       return true;
+}
+
+bool
+_CertServiceStub::OnUninstallUserRootCertificateByCertId(int certId, result* pRet)
+{
+       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_CERTIFICATE_WRITE);
+       TryCatchResult(!IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       *pRet = _CertServer::RemoveUserCaCertificateByCertId(certId);
+
+CATCH:
+       return true;
+}
+
+bool
+_CertServiceStub::OnGetUserCertChainByIssuerAndSubjectNameN(Tizen::Io::_IpcBuffer issuerBufferIpc, int issuerNameLen, Tizen::Io::_IpcBuffer subjectBufferIpc, int subNameLen, _CertificateListInfo* pCertList, result* pRet)
+{
+       _CertificateListInfo* pCertListIpc = null;
+
+       *pRet = _CertServer::GetUserCertChainByIssuerAndSubjectNameN(static_cast< char* >(issuerBufferIpc.pBuffer), issuerNameLen, static_cast< char* >(subjectBufferIpc.pBuffer), subNameLen, pCertListIpc);
+
+       if (pCertListIpc != null)
+       {
+               std::unique_ptr< _CertificateListInfo > pCertListAuto(pCertListIpc);
+
+               pCertList->certFileId = pCertListIpc->certFileId;
+
+               pCertList->format = pCertListIpc->format;
+               pCertList->certType = pCertListIpc->certType;
+               pCertList->length = pCertListIpc->length;
+               pCertList->priKeyLen = pCertListIpc->priKeyLen;
+
+               memcpy(pCertList->certificate, pCertListIpc->certificate, _MAX_CERTIFICATE_SIZE);
+               memcpy(pCertList->privatekey, pCertListIpc->privatekey, _MAX_CERT_PRIVATE_KEY_SIZE);
+
+               pCertList->pNext = pCertListIpc->pNext;
+       }
+       else
+       {
+               memset(pCertList, 0, sizeof(*pCertList));
+       }
+
+       return true;
+}
+
+bool
+_CertServiceStub::OnGetUserCertificateByCertIdN(int certId, int encodingType, _CertInfo* pUserCertificateList, result* pRet)
+{
+       _CertInfo* pUserCertificateInfoIpc = null;
+
+       *pRet = _CertServer::GetUserCertificateByCertIdN(certId, static_cast< _CertEncodingType >(encodingType), pUserCertificateInfoIpc);
+
+       if (pUserCertificateInfoIpc != null)
+       {
+               std::unique_ptr< _CertInfo > pCertInfoAuto(pUserCertificateInfoIpc);
+
+               pUserCertificateList->certId = pUserCertificateInfoIpc->certId;
+               pUserCertificateList->certFormat = pUserCertificateInfoIpc->certFormat;
+               pUserCertificateList->certType = pUserCertificateInfoIpc->certType;
+               pUserCertificateList->certLength = pUserCertificateInfoIpc->certLength;
+               pUserCertificateList->privateKeyLen = pUserCertificateInfoIpc->privateKeyLen;
+
+               memcpy(pUserCertificateList->certificate, pUserCertificateInfoIpc->certificate, _MAX_CERTIFICATE_SIZE);
+               memcpy(pUserCertificateList->privatekey, pUserCertificateInfoIpc->privatekey, _MAX_CERT_PRIVATE_KEY_SIZE);
+       }
+       else
+       {
+               memset(pUserCertificateList, 0, sizeof(*pUserCertificateList));
+       }
+       return true;
+}
+
+bool
+_CertServiceStub::OnGetUserCertFieldInfoByCertId(int certId, _CertFieldInfos* pCertInfoBufferIpc, result* pRet)
+{
+       _CertFieldInfos certInfo;
+
+       *pRet = _CertServer::GetUserCertFieldInfoByCertId(certId, &certInfo);
+
+       if (!IsFailed(*pRet))
+       {
+               pCertInfoBufferIpc->certType = certInfo.certType;
+               pCertInfoBufferIpc->certFileId = certInfo.certFileId;
+
+               memcpy(pCertInfoBufferIpc->serialNo, certInfo.serialNo, _MAX_SERIAL_NUMBER_SIZE + 1);
+               memcpy(pCertInfoBufferIpc->sigAlgorithm, certInfo.sigAlgorithm, _MAX_CERT_ALGORITHM_SIZE + 1);
+               memcpy(pCertInfoBufferIpc->validityFrom, certInfo.validityFrom, _MAX_CERT_VALIDITY_SIZE + 1);
+               memcpy(pCertInfoBufferIpc->validityTo, certInfo.validityTo, _MAX_CERT_VALIDITY_SIZE + 1);
+               memcpy(pCertInfoBufferIpc->subjectName, certInfo.subjectName, _MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
+               memcpy(pCertInfoBufferIpc->issuerName, certInfo.issuerName, _MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
+               memcpy(pCertInfoBufferIpc->fingerPrint, certInfo.fingerPrint, _MAX_CERT_FINGERPRINT_SIZE + 1);
+
+               pCertInfoBufferIpc->fingerPrintLen = certInfo.fingerPrintLen;
+
+               memcpy(pCertInfoBufferIpc->publicKey, certInfo.publicKey, _MAX_CERT_PUBLIC_KEY_SIZE + 1);
+               memcpy(static_cast< void* >(pCertInfoBufferIpc->certTypeFormat), static_cast< const void* >(certInfo.certTypeFormat), _MAX_CERT_TYPE_SIZE + 1);
+
+               pCertInfoBufferIpc->certVersion = certInfo.certVersion;
+
+               memcpy(pCertInfoBufferIpc->certTitle, certInfo.certTitle, _MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
+               memcpy(pCertInfoBufferIpc->certSubTitle, certInfo.certSubTitle, _MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
+
+       }
+       else
+       {
+               memset(pCertInfoBufferIpc, 0, sizeof(*pCertInfoBufferIpc));
+       }
+       return true;
+}
+
+
+bool
+_CertServiceStub::OnGetName(result* pRet)
+{
+       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_CERTIFICATE_READ);
+       TryCatchResult(!IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       *pRet = E_SUCCESS;
+
+CATCH:
+       return true;
+}
+
+bool
+_CertServiceStub::OnCloseCertificateStore(int type, result* pRet)
+{
+       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_CERTIFICATE_READ);
+       TryCatchResult(!IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       TryCatchResult(type == _CERT_TYPE_USER_CERT, *pRet = E_SYSTEM, E_SYSTEM, "The cert is not user cert.");
+
+       if (__refCount > 0)
+       {
+               __refCount -= 1;
+
+               if (__refCount == 0 && __context != 0)
+               {
+                       *pRet = _CertServer::CloseCertificateStore(reinterpret_cast< CertificateStoreCtx >(__context));
+                       __context = 0;
+               }
+       }
+
+       *pRet = E_SUCCESS;
+
+CATCH:
+       return true;
+}
+
+bool
+_CertServiceStub::OnOpenCertificateStoreByType(int type, int* pCount, result* pRet)
+{
+       void* pCertList = null;
+
+       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_CERTIFICATE_READ);
+       TryCatchResult(!IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       TryCatchResult(type == _CERT_TYPE_USER_CERT, *pRet = E_SYSTEM, E_SYSTEM, "The cert is not user cert.");
+
+       if (__context == 0)
+       {
+               *pCount = 0;
+               pCertList = _CertServer::OpenCertificateStoreByType(static_cast< _CaCertType >(type), pCount);
+
+               __context = reinterpret_cast< int >(pCertList);
+       }
+       else
+       {
+               *pCount = _CertServer::GetCertificateCount(reinterpret_cast< CertificateStoreCtx >(__context));
+       }
+
+       __refCount += 1;
+
+       *pRet = E_SUCCESS;
+
+CATCH:
+       return true;
+}
+
+bool
+_CertServiceStub::OnGetCertificateCount(int type, int* pCertCount, result* pRet)
+{
+       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_CERTIFICATE_READ);
+       TryCatchResult(!IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       TryCatchResult(type == _CERT_TYPE_USER_CERT, *pRet = E_SYSTEM, E_SYSTEM, "The cert is not user cert.");
+
+       *pCertCount = _CertServer::GetCertificateCount(reinterpret_cast< CertificateStoreCtx >(__context));
+
+       *pRet = E_SUCCESS;
+
+CATCH:
+       return true;
+}
+
+bool
+_CertServiceStub::OnGetNextCertificate(int type, int curPos, int length, Tizen::Base::ByteBuffer* pCertBufferIpc, int* pNewPos, result* pRet)
+{
+       char* pBuffer = null;
+
+       *pRet = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_CERTIFICATE_READ);
+       TryCatchResult(!IsFailed(*pRet), *pRet = E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       TryCatchResult(type == _CERT_TYPE_USER_CERT, *pRet = E_SYSTEM, E_SYSTEM, "The cert is not user cert.");
+
+       pBuffer = new (std::nothrow) char[length];
+       TryCatchResult(pBuffer, *pRet = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]Allocation failed");
+
+       *pRet = _CertServer::GetNextCertificate(reinterpret_cast< CertificateStoreCtx >(__context), curPos, pBuffer, &length);
+       *pNewPos = curPos;
+
+CATCH:
+       if (!IsFailed(*pRet))
+       {
+               pCertBufferIpc->Construct(length);
+               pCertBufferIpc->SetArray(reinterpret_cast<const byte*>(pBuffer), 0, length);
+               pCertBufferIpc->Flip();
+       }
+       else
+       {
+               SysLog(NID_SEC_CERT, "GetNextCertificate failed");
+       }
+       delete[] pBuffer;
+
+       return true;
+}
+
+bool
+_CertServiceStub::OnRestoreRootCaIntegrity(void)
+{
+       _CertServer::RestoreRootCaIntegrity();
+       ClearLastResult();
+       return true;
+}
+
+result
+_CertServiceStub::UpdateCertStoreContext(void)
+{
+       result r = E_SUCCESS;
+       CertificateStoreCtx certList = null;
+       
+       int count = 0;
+
+       if (__refCount > 0)
+       {
+               if (__context != 0)
+               {
+                       r = _CertServer::CloseCertificateStore(reinterpret_cast< CertificateStoreCtx >(__context));
+                       TryReturnResult(!IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
+                       __context = NULL;
+               }
+               certList = _CertServer::OpenCertificateStoreByType(_CERT_TYPE_USER_CERT, &count);
+               r = GetLastResult();
+               SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_SYSTEM, "Failed to open certificate store.");
+               __context = reinterpret_cast< int >(certList);
+
+       }
+       return r;
+}
+
+void
+_CertServiceStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message)
+{
+       IPC_BEGIN_MESSAGE_MAP(_CertServiceStub, message)
+       IPC_MESSAGE_HANDLER_EX(CertServer_GetName, &server, OnGetName)
+       IPC_MESSAGE_HANDLER_EX(CertServer_CloseCertificateStore, &server, OnCloseCertificateStore)
+       IPC_MESSAGE_HANDLER_EX(CertServer_OpenCertificateStoreByType, &server, OnOpenCertificateStoreByType)
+       IPC_MESSAGE_HANDLER_EX(CertServer_GetCertificateCount, &server, OnGetCertificateCount)
+       IPC_MESSAGE_HANDLER_EX(CertServer_GetNextCertificate, &server, OnGetNextCertificate)
+       IPC_MESSAGE_HANDLER_EX(CertServer_UpdateRootCa, &server, OnUpdateRootCa)
+       IPC_MESSAGE_HANDLER_EX(CertServer_RemoveRootCa, &server, OnRemoveRootCa)
+       IPC_MESSAGE_HANDLER_EX(CertServer_UninstallUserRootCertificateByCertId, &server, OnUninstallUserRootCertificateByCertId)
+       IPC_MESSAGE_HANDLER_EX(CertServer_InsertCaCertificate, &server, OnInsertCaCertificate)
+       IPC_MESSAGE_HANDLER_EX(CertServer_InsertUserCaCertificate, &server, OnInsertUserCaCertificate)
+       IPC_MESSAGE_HANDLER_EX(CertServer_InstallUserRootCertificate, &server, OnInstallUserRootCertificate)
+
+       //User Certificates API
+       IPC_MESSAGE_HANDLER_EX(CertServer_InsertUserCertChainPrivateKey, &server, OnInsertUserCertChainPrivateKey)
+       IPC_MESSAGE_HANDLER_EX(CertServer_InsertCertificateChainWithPrivateKey, &server, OnInsertCertificateChainWithPrivateKey)
+       IPC_MESSAGE_HANDLER_EX(CertServer_InstallPkcs12Content, &server, OnInstallPkcs12Content)
+       IPC_MESSAGE_HANDLER_EX(CertServer_DeleteUserCertChainByCertId, &server, OnDeleteUserCertChainByCertId)
+       IPC_MESSAGE_HANDLER_EX(CertServer_GetUserCertChainByIssuerAndSubjectNameN, &server, OnGetUserCertChainByIssuerAndSubjectNameN)
+       IPC_MESSAGE_HANDLER_EX(CertServer_GetUserCertificateByCertIdN, &server, OnGetUserCertificateByCertIdN)
+       IPC_MESSAGE_HANDLER_EX(CertServer_GetUserCertFieldInfoByCertId, &server, OnGetUserCertFieldInfoByCertId)
+
+       IPC_MESSAGE_HANDLER_EX(CertServer_RestoreRootCaIntegrity, &server, OnRestoreRootCaIntegrity)
+
+       IPC_END_MESSAGE_MAP_EX();
+}
+
+
+void
+_CertServiceStub::OnIpcServerStarted(const _IpcServer& server)
+{
+
+}
+
+void
+_CertServiceStub::OnIpcServerStopped(const _IpcServer& server)
+{
+
+}
+
+void
+_CertServiceStub::OnIpcClientConnected(const _IpcServer& server, int clientId)
+{
+
+}
+
+void
+_CertServiceStub::OnIpcClientDisconnected(const _IpcServer& server, int clientId)
+{
+
+}
+
+} } }
diff --git a/src/DrmService.cpp b/src/DrmService.cpp
new file mode 100755 (executable)
index 0000000..6c093a1
--- /dev/null
@@ -0,0 +1,321 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT 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               DrmService.cpp
+ * @brief              This is the implementation file for DrmService class.
+ */
+
+#include "DrmService.h"
+#include "DrmServiceDl.h"
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <vconf.h>
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FIo.h>
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+DrmService* DrmService::m_pInstance = null;
+
+const char *DRM_SAPPS_API[] = {
+       "drm_oem_sapps_generate_license_request",
+       "drm_oem_sapps_register_license",
+       "drm_oem_sapps_is_drm_file",
+       "drm_oem_sapps_decrypt_package",
+       "drm_oem_sapps_generate_purchase_request",
+       "\0"
+};
+
+DrmService::DrmService(void)
+       : m_sapps_handle(null)
+       , m_isdlopened(false)
+       , __pLocalMessagePort(null)
+{
+}
+
+DrmService::~DrmService(void)
+{
+}
+
+DrmService*
+DrmService::GetInstance(void)
+{
+       if (m_pInstance == null)
+       {
+               m_pInstance = new (std::nothrow) DrmService();
+
+               if (m_pInstance == null)
+               {
+                       AppLogException("DrmService : Creating DrmService m_pInstance failed.");
+
+                       return m_pInstance;
+               }
+
+               m_pInstance->Construct();
+               AppLog("DrmService : m_pInstance is created.");
+       }
+
+       return m_pInstance;
+}
+
+void
+DrmService::FreeInstance(void)
+{
+       if (m_pInstance != null)
+       {
+               delete m_pInstance;
+               m_pInstance = null;
+       }
+}
+
+result
+DrmService::Construct(void)
+{
+       static const wchar_t* LOCAL_MESSAGE_PORT_NAME = L"SAPPS_DRM_SERVER_PORT";
+
+       result r = E_SUCCESS;
+
+       AppLog("DrmService::Construct is called.");
+
+       __pLocalMessagePort = MessagePortManager::RequestLocalMessagePort(LOCAL_MESSAGE_PORT_NAME);
+       r = GetLastResult();
+       TryCatchTag(DRM_SERVICE, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] DrmService failed to get LocalMessagePort instance, %s", GetErrorMessage(r));
+       AppLog("DrmService::RequestLocalMessagePort successfully called.");
+
+       __pLocalMessagePort->AddMessagePortListener(*this);
+       r = GetLastResult();
+       TryCatchTag(DRM_SERVICE, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] DrmService failed to run AddMessagePortListner, %s", GetErrorMessage(r));
+       AppLog("DrmService : LocalMessagePort is ready.");
+
+CATCH:
+       if (__pLocalMessagePort == null)
+       {
+               AppLogException("DrmService : RequestLocalMessagePort failed.");
+               FreeInstance();
+       }
+
+       return r;
+}
+
+void
+DrmService::OnMessageReceivedN(RemoteMessagePort* pRemoteMessagePort, IMap* pMessage)
+{
+       result r = E_SUCCESS;
+       String *pData = NULL;
+
+       HashMap *pMap = new HashMap(SingleObjectDeleter);
+
+       TryCatchTag(DRM_SERVICE, pMessage != NULL, r = E_INVALID_ARG, "DrmService : OnMessageReceivedN() failed. pMessage is invalid.");
+       TryCatchTag(DRM_SERVICE, pMap != NULL, r = E_OUT_OF_MEMORY, "DrmService : OnMessageReceivedN() failed. pMap is NULL.");
+
+       pMap->Construct();
+
+       pData = static_cast<String *>(pMessage->GetValue(String(L"CLIENT_NAME")));
+       r = GetLastResult();
+
+       if (r == E_OBJ_NOT_FOUND)
+       {
+               AppLogException("Osp-Security-Service : [E_OBJ_NOT_FOUND] Failed to get CLIENT_NAME value.");
+               pMap->Add(new String(L"RESULT"), new String(L"CLIENT_NAME_NULL"));
+               goto CATCH;
+       }
+
+       if (m_isdlopened != true)
+       {
+               int retDrmDlCall = 0;
+
+               retDrmDlCall = DrmDlCall();
+
+               if (retDrmDlCall == DLOPEN_FAILED)
+               {
+                       AppLogException("Osp-Security-Service : [DLOPEN_FAILED] Failed to load DRM-ENGINE");
+                       pMap->Add(new String(L"RESULT"), new String(L"DLOPEN_FAILED"));
+                       goto CATCH;
+               }
+
+               if (retDrmDlCall == DLSYM_FAILED)
+               {
+                       AppLogException("Osp-Security-Service : [DLSYM_FAILED] Failed to load DRM-ENGINE.");
+                       pMap->Add(new String(L"RESULT"), new String(L"DLSYM_FAILED"));
+                       goto CATCH;
+               }
+       }
+
+       AppLog("Osp-Security-Service : Received length=%d, data=%ls", pData->GetLength(), pData->GetPointer());
+
+       if (pData->CompareTo(L"STORE_CLIENT") == 0)
+       {
+               int result = 0;
+               char respBuf[1024*8] = {0,};
+               unsigned int respBufLen = sizeof(respBuf);
+               char reqBuf[1024] = {0,};
+               unsigned int reqBufLen = sizeof(reqBuf);
+               char licenseUrl[1024] = {0,};
+               unsigned int licenseUrlLen = sizeof(licenseUrl);
+               int count = 0;
+
+               String *pDataAPI = static_cast<String *>(pMessage->GetValue(String(L"REQUEST_API")));
+               r = GetLastResult();
+
+               if (r == E_OBJ_NOT_FOUND)
+               {
+                       AppLogException("DrmService : Failed to get REQUEST_API field.");
+                       pMap->Add(new String(L"RESULT"), new String(L"LICENSE_REQUEST_PROTOCOL_INVALID"));
+                       goto CATCH;
+               }
+
+               if (pDataAPI->CompareTo(L"GENERATE_DRM_LICENSE_REQUEST") == 0)
+               {
+                       String *pInputParam = static_cast<String *>(pMessage->GetValue(String(L"INPUT_PARAM")));
+                       r = GetLastResult();
+                       if (r == E_OBJ_NOT_FOUND)
+                       {
+                               AppLogException("DrmService : [GENERATE_DRM_LICENSE_REQUEST] Failed to get INPUT_PARAM.");
+                               pMap->Add(new String(L"RESULT"), new String(L"LICENSE_REQUEST_INPUT_PARAM_NULL"));
+                               goto CATCH;
+                       }
+
+                       AppLog("API : %ls, INPUT_PARAM : %ls", pDataAPI->GetPointer(), pInputParam->GetPointer());
+                       count = wcstombs(respBuf, pInputParam->GetPointer(), pInputParam->GetLength());
+
+                       if (count != pInputParam->GetLength() || (int)strlen(respBuf) != count)
+                       {
+                               AppLogException("DrmService : [GENERATE_DRM_LICENSE_REQUEST] Failed to get the argument.");
+                               pMap->Add(new String(L"RESULT"), new String(L"LICENSE_REQUEST_INPUT_PARAM_INVALID"));
+                               goto CATCH;
+                       }
+
+                       respBufLen = count;
+                       result = m_sapps_symbol.drm_oem_sapps_generate_license_request(respBuf, respBufLen, reqBuf, &reqBufLen, licenseUrl, &licenseUrlLen);
+
+                       if (result != SADC_SUCCESS)
+                       {
+                               AppLogException("DrmService : [GENERATE_DRM_LICENSE_REQUEST] drm_oem_sapps_generate_license_request() failed. ret=%x", result);
+                               pMap->Add(new String(L"RESULT"), new String(L"LICENSE_REQUEST_INTERNAL_ERROR"));
+                               goto CATCH;
+                       }
+
+                       pMap->Add(new String(L"RESULT"), new String(L"LICENSE_REQUEST_SUCCESS"));
+                       pMap->Add(new String(L"LICENSE_MSG"), new String(reqBuf));
+                       pMap->Add(new String(L"LICENSE_URL"), new String(licenseUrl));
+               }
+               else if (pDataAPI->CompareTo(L"WRITE_DRM_LICESE") == 0)
+               {
+                       String *pInputParam = static_cast<String *>(pMessage->GetValue(String(L"INPUT_PARAM")));
+                       r = GetLastResult();
+                       if (r == E_OBJ_NOT_FOUND)
+                       {
+                               AppLogException("DrmService : [WRITE_DRM_LICESE] Failed to get INPUT_PARAM.");
+                               pMap->Add(new String(L"RESULT"), new String(L"LICENSE_WRITE_INPUT_PARAM_NULL"));
+                               goto CATCH;
+                       }
+
+                       AppLog("DrmService : API=%ls, INPUT_PARAM_Length=%d, INPUT_PARAM=%ls", pDataAPI->GetPointer(), pInputParam->GetLength() , pInputParam->GetPointer());
+                       count = wcstombs(respBuf, pInputParam->GetPointer(), pInputParam->GetLength());
+
+                       if (count != pInputParam->GetLength())
+                       {
+                               AppLogException("DrmService : [WRITE_DRM_LICESE] Failed to get the argument.");
+                               pMap->Add(new String(L"RESULT"), new String(L"LICENSE_WRITE_INPUT_PARAM_INVALID"));
+                               goto CATCH;
+                       }
+
+                       respBufLen = count;
+                       result = m_sapps_symbol.drm_oem_sapps_register_license(respBuf, respBufLen);
+
+                       if (result != SADC_SUCCESS)
+                       {
+                               AppLogException("DrmService : [WRITE_DRM_LICESE] drm_oem_sapps_register_license() failed. ret=%x", result);
+                               pMap->Add(new String(L"RESULT"), new String(L"LICENSE_WRITE_INTERNAL_ERROR"));
+                               goto CATCH;
+                       }
+
+                       pMap->Add(new String(L"RESULT"), new String(L"LICENSE_WRITE_SUCCESS"));
+               }
+               else
+               {
+                       AppLogException("DrmService : UNSURPPORTED_API requested.");
+                       pMap->Add(new String(L"RESULT"), new String(L"UNSURPPORTED_API"));
+                       goto CATCH;
+               }
+       }
+       else
+       {
+               AppLogException("DrmService : Unauthorized client called.");
+               pMap->Add(new String(L"RESULT"), new String(L"UNAUTHORIZED_CLIENT"));
+               goto CATCH;
+       }
+
+CATCH:
+       pRemoteMessagePort->SendMessage(__pLocalMessagePort, pMap);
+       r = GetLastResult();
+       AppLogExceptionIf(r != E_SUCCESS, "DrmService : [E_SYSTEM] DrmService failed to SendMessage(), %s", GetErrorMessage(r));
+
+       if (pMap != NULL)
+       {
+               delete pMap;
+       }
+       if (pMessage != NULL)
+       {
+               delete pMessage;
+       }
+}
+
+int
+DrmService::DrmDlCall(void)
+{
+       void *handle = NULL;
+       int     ret = SADC_SUCCESS;
+       char *error = NULL;
+       void *sappshandle[FUNC_DRM_SAPPS_MAX] = {0,};
+
+       AppLog("DrmService : DrmDlCall is called.");
+
+       m_sapps_handle = dlopen(DRM_SAPPS_SO_PATH, RTLD_LAZY);
+       error = dlerror();
+       TryCatchTag(DRM_SERVICE, error == NULL, ret = DLOPEN_FAILED, "DrmService : dlopen() failed. err=%s", error);
+       AppLog("Osp-Security-Service : dlopen success.");
+
+       for (int i = 0; i < FUNC_DRM_SAPPS_MAX ; i++)
+       {
+               handle = dlsym(m_sapps_handle, DRM_SAPPS_API[i]);
+               error = dlerror();
+
+               TryCatchTag(DRM_SERVICE, error == NULL, ret = DLSYM_FAILED, "DrmService : dlsym() failed. err=%s", error);
+               AppLog("DrmService : drm_sapps_api is loaded : dlsym(%d)\n", i);
+
+               sappshandle[i] = handle;
+       }
+
+       memcpy(&m_sapps_symbol, sappshandle, sizeof(sappshandle));
+       m_isdlopened = true;
+
+       AppLog("DrmService : DrmDlCall is totally success.");
+
+CATCH:
+       return ret;
+}
diff --git a/src/PrivilegeService.cpp b/src/PrivilegeService.cpp
new file mode 100644 (file)
index 0000000..69993c3
--- /dev/null
@@ -0,0 +1,127 @@
+//
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT  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               PrivilegeService.cpp
+ * @brief              This is the implementation file for PrivilegeService class.
+ */
+
+#include <FIo_IpcServer.h>
+#include <FIo_IIpcServerEventListener.h>
+#include <FIo_IpcCommonDataTypes.h>
+#include <FBaseSysLog.h>
+#include <FSec_PrivilegeManagerServer.h>
+#include <FSec_PrivilegeManagerMessage.h>
+#include <FAppPkg_PackageInfoImpl.h>
+
+#include "PrivilegeService.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::App;
+using namespace Tizen::App::Package;
+using namespace Tizen::Io;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+PrivilegeService::PrivilegeService(void)
+       : __pIpcServer(null)
+{
+
+}
+
+PrivilegeService::~PrivilegeService(void)
+{
+       AppLogTag(OSP_SECURITY_SERVICE, "Entered.");
+
+       __pIpcServer->Stop();
+       delete __pIpcServer;
+
+       AppLogTag(OSP_SECURITY_SERVICE, "Leaved.");
+}
+
+result
+PrivilegeService::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       AppLogTag(OSP_SECURITY_SERVICE, "Entered.");
+
+       __pIpcServer = new (std::nothrow) _IpcServer();
+       TryReturnResultTag(OSP_SECURITY_SERVICE, __pIpcServer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = __pIpcServer->Construct("osp.security.ipcserver.privilegemanager", *this, false);
+       TryReturnResultTag(OSP_SECURITY_SERVICE, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+       AppLogTag(OSP_SECURITY_SERVICE, "Leaved.");
+       return r;
+}
+
+void
+PrivilegeService::OnIpcServerStarted(const _IpcServer& server)
+{
+
+}
+
+void
+PrivilegeService::OnIpcServerStopped(const _IpcServer& server)
+{
+
+}
+
+void
+PrivilegeService::OnIpcClientConnected(const _IpcServer& server, int clientId)
+{
+
+}
+
+void
+PrivilegeService::OnIpcClientDisconnected(const _IpcServer&server, int clientId)
+{
+
+}
+
+bool
+PrivilegeService::RetrievePrivilege(String* pEncryptedBitwise, String* pHmac, ArrayListT < String >* pPrivilegeList, result* pRes)
+{
+       AppId appId;
+       __pIpcServer->GetClientPackageId().SubString(0, MAX_APP_ID_SIZE, appId);
+
+       *pRes = _PrivilegeManagerServer::RetrievePrivilege(appId, pEncryptedBitwise, pHmac, pPrivilegeList);
+
+       return true;
+}
+
+bool
+PrivilegeService::RetrieveVisibility(String* pEncryptedVisibility, String* pHmac, result* pRes)
+{
+       AppId appId;
+       __pIpcServer->GetClientPackageId().SubString(0, MAX_APP_ID_SIZE, appId);
+
+       *pRes = _PrivilegeManagerServer::GenerateVisibilityString(appId, pEncryptedVisibility, pHmac);
+
+       return true;
+}
+
+void
+PrivilegeService::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message)
+{
+       IPC_BEGIN_MESSAGE_MAP(PrivilegeService, message)
+                               IPC_MESSAGE_HANDLER_EX(PrivilegeManagerMsg_retrieve, &server, RetrievePrivilege)
+                               IPC_MESSAGE_HANDLER_EX(PrivilegeManagerMsg_retrieveEx, &server, RetrieveVisibility)
+       IPC_END_MESSAGE_MAP()
+}
+
diff --git a/src/SecurityService.cpp b/src/SecurityService.cpp
new file mode 100644 (file)
index 0000000..f2efb70
--- /dev/null
@@ -0,0 +1,216 @@
+//
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT  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               SecurityService.cpp
+ * @brief              This is the implementation file for SecurityService class.
+ */
+
+#include <FAppAppRegistry.h>
+#include <FBaseLog.h>
+
+#include "SecurityService.h"
+#include "PrivilegeService.h"
+#include "CertificateService.h"
+#include "DrmService.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base::Collection;
+
+#define VCONFKEY_APPSERVICE_STATUS "memory/appservice/status"
+
+static SecurityService* __pSecurityService = null;
+
+SecurityService::SecurityService(void)
+       : __pPrivilegeService(null)
+       , __pCertificateService(null)
+{
+
+}
+
+SecurityService::~SecurityService(void)
+{
+
+}
+
+Service*
+SecurityService::CreateInstance(void)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       if (__pSecurityService == null)
+       {
+               __pSecurityService = new (std::nothrow) SecurityService();
+               if (__pSecurityService == null)
+               {
+                       AppLogException("[E_OUT_OF_MEMORY] The memory is insufficient.");
+                       r = E_OUT_OF_MEMORY;
+               }
+       }
+
+       SetLastResult(r);
+
+       return __pSecurityService;
+}
+
+bool
+SecurityService::OnAppInitializing(AppRegistry& appRegistry)
+{
+       result r = E_SUCCESS;
+       bool ret = true;
+
+       int errorCode = 0;
+       int channelStatus = 0;
+
+       AppLog("Enter");
+
+       __pPrivilegeService = new (std::nothrow) PrivilegeService();
+       TryCatchTag(OSP_SECURITY_SERVICE, __pPrivilegeService != null, r = E_OUT_OF_MEMORY; ret = false, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = __pPrivilegeService->Construct();
+       TryCatchTag(OSP_SECURITY_SERVICE, r == E_SUCCESS, r = E_SYSTEM; ret = false, "[E_SYSTEM] An unexpected system error occurred.");
+
+#if 0
+       __pCertificateService = new (std::nothrow) CertificateService();        //return true even if error occured
+                                                                                                                                               //because privilege must be running.
+       TryCatchTag(OSP_SECURITY_SERVICE, __pCertificateService != null, r = E_OUT_OF_MEMORY; ret = true, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = __pCertificateService->Construct();
+       TryCatchTag(OSP_SECURITY_SERVICE, r == E_SUCCESS, r = E_SYSTEM; ret = true, "[E_SYSTEM] An unexpected system error occurred.");
+#endif
+
+       errorCode = vconf_get_int(VCONFKEY_APPSERVICE_STATUS, &channelStatus);
+       TryCatchTag(OSP_SECURITY_SERVICE, errorCode == 0, r = E_SYSTEM; ret = true, "[E_SYSTEM] It is failed to get the VCONF_APPSERVICE_STATUS vconf.");
+
+       AppLog("Channel IPC Server init started... VCONF_APPSERVICE_STATUS = %d", errorCode);
+
+       if (channelStatus == 2)
+       {
+               AppLog("Channel Service already launched. DRM IPC Server started.");
+               DrmService* pDrmService = DrmService::GetInstance();
+               TryCatchTag(OSP_SECURITY_SERVICE, pDrmService != null, r = E_OUT_OF_MEMORY; ret = true, "[E_OUT_OF_MEMORY] DrmService::GetInstance() failed.");
+
+               errorCode = vconf_ignore_key_changed(VCONFKEY_APPSERVICE_STATUS, OnChannelServiceLaunched);
+               if (errorCode != 0)
+               {
+                       AppLogException("[E_SYSTEM] It is failed to unregister event listener for vconf change.");
+               }
+       }
+       else
+       {
+               AppLog("Channel Service has not been launched. Wait for launching channel service.");
+               errorCode = vconf_notify_key_changed(VCONFKEY_APPSERVICE_STATUS, OnChannelServiceLaunched, null);
+               TryCatchTag(OSP_SECURITY_SERVICE, errorCode == 0, r = E_SYSTEM; ret = true, "[E_SYSTEM] Failed to register event listener of VCONF_APPSERVICE_STATUS.");
+       }
+
+       AppLog("Exit");
+
+       return ret;
+
+CATCH:
+
+       SetLastResult(r);
+
+       AppLog("Exit");
+       return ret;
+}
+
+bool
+SecurityService::OnAppInitialized(void)
+{
+       result r = E_SUCCESS;
+       bool ret = true;
+
+       AppLog("Enter");
+
+       __pCertificateService = new (std::nothrow) CertificateService();        //return true even if error occured
+                                                                                                                                               //because privilege must be running.
+       TryCatchTag(OSP_SECURITY_SERVICE, __pCertificateService != null, r = E_OUT_OF_MEMORY; ret = true, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       r = __pCertificateService->Construct();
+       TryCatchTag(OSP_SECURITY_SERVICE, r == E_SUCCESS, r = E_SYSTEM; ret = true, "[E_SYSTEM] An unexpected system error occurred.");
+
+       AppLog("Exit");
+       return ret;
+
+CATCH:
+       SetLastResult(r);
+
+       AppLog("Exit");
+       return ret;
+}
+
+bool
+SecurityService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
+{
+       AppLog("Enter");
+
+       delete __pPrivilegeService;
+       delete __pCertificateService;
+       DrmService::FreeInstance();
+
+       AppLog("Exit");
+       return true;
+}
+
+void
+SecurityService::OnLowMemory(void)
+{
+
+}
+
+void
+SecurityService::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList *pArgs)
+{
+
+}
+
+void
+SecurityService::OnChannelServiceLaunched(keynode_t* node, void* userData)
+{
+       result r = E_SUCCESS;
+
+       int channelStatus = 0;
+       int errorCode = 0;
+
+       AppLog("OnChannelServiceLaunched started. - vconf changed.");
+
+    if(strcmp(VCONFKEY_APPSERVICE_STATUS, vconf_keynode_get_name(node)) == 0)
+    {
+       errorCode = vconf_get_int(VCONFKEY_APPSERVICE_STATUS, &channelStatus);
+       TryCatchTag(OSP_SECURITY_SERVICE, errorCode == 0, r = E_SYSTEM, "[E_SYSTEM] Failed to get the VCONF_APPSERVICE_STATUS.");
+
+       if (channelStatus == 2)
+       {
+               AppLog("Channel Service launched. DRM IPC Server will be started.");
+
+               DrmService* pDrmService = DrmService::GetInstance();
+                       TryCatchTag(OSP_SECURITY_SERVICE, pDrmService != null, r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] DrmService::GetInstance() failed.");
+
+                       AppLog("DRM IPC Server succesfully launched.");
+
+                       errorCode = vconf_ignore_key_changed(VCONFKEY_APPSERVICE_STATUS, OnChannelServiceLaunched);
+                       if (errorCode != 0)
+                       {
+                               AppLogException("[E_SYSTEM] It is failed to unregister event listener for vconf change.");
+                       }
+       }
+    }
+CATCH:
+       SetLastResult(r);
+}
diff --git a/src/SecurityServiceEntry.cpp b/src/SecurityServiceEntry.cpp
new file mode 100644 (file)
index 0000000..6992dbd
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT  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               SecurirtyServiceEntry.cpp
+ * @brief              This is the implementation file for SecurirtyService entry point.
+ */
+
+#include <FOspConfig.h>
+#include <FBaseSysLog.h>
+#include <FBaseColArrayList.h>
+
+#include "SecurityService.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // __cplusplus
+
+_OSP_EXPORT_ int OspMain(int argc, char *pArgv[]);
+#ifdef _PROFILE
+extern void start_profile (void);
+extern void end_profile (void);
+#else
+#define start_profile(void)
+#define end_profile(void)
+#endif
+
+
+/**
+ * The entry function of Tizen application called by the operating system.
+ */
+int
+OspMain(int argc, char *pArgv[])
+{
+       result r = E_SUCCESS;
+
+       AppLog("Application started.");
+       ArrayList* pArgs = new ArrayList();
+       pArgs->Construct();
+       for (int i = 0; i < argc; i++)
+       {
+               pArgs->Add(*(new String(pArgv[i])));
+       }
+
+       start_profile();
+       r = Tizen::App::ServiceApp::Execute(SecurityService::CreateInstance, pArgs);
+       if (IsFailed(r))
+       {
+               AppLogException("Application execution failed-[%s].", GetErrorMessage(r));
+               r &= 0x0000FFFF;
+       }
+       end_profile();
+
+       pArgs->RemoveAll(true);
+       delete pArgs;
+       AppLog("Application finished.");
+
+       return static_cast<int>(r);
+}
+#ifdef __cplusplus
+}
+#endif // __cplusplus
diff --git a/src/SecurityServiceMessage.cpp b/src/SecurityServiceMessage.cpp
new file mode 100644 (file)
index 0000000..fd8471f
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT  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       PrivilegeServiceMessage.cpp
+ * @brief      This is the message type of the IPC communication of PrivilegeService daemon.
+ */
+
+#define IPC_MESSAGE_IMPL
+#include <FSec_PrivilegeManagerMessage.h>
+
+// Generate constructors.
+#include <ipc/struct_constructor_macros.h>
+#include <FSec_PrivilegeManagerMessage.h>
+// Generate destructors.
+
+#include <ipc/struct_destructor_macros.h>
+#include <FSec_PrivilegeManagerMessage.h>
+
+// Generate param traits write methods.
+#include <ipc/param_traits_write_macros.h>
+namespace IPC {
+#include <FSec_PrivilegeManagerMessage.h>
+}  // namespace IPC
+
+// Generate param traits read methods.
+#include <ipc/param_traits_read_macros.h>
+namespace IPC {
+#include <FSec_PrivilegeManagerMessage.h>
+}  // namespace IPC
diff --git a/system-service-export.ver b/system-service-export.ver
new file mode 100755 (executable)
index 0000000..68c06a8
--- /dev/null
@@ -0,0 +1,6 @@
+{
+global:
+       OspMain;
+local:
+       *;
+};
diff --git a/tool/mk-cert-db.sh b/tool/mk-cert-db.sh
new file mode 100755 (executable)
index 0000000..c5d4449
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+SRC_PATH=/opt/etc/ssl/certs
+CRT=certs/ca-certificate.crt
+DBSPACE_DIR=dbspace
+USERCERT_DIR=certs/usercert/key
+ROOTCERT_DIR=certs/rootcert
+ROOTCERT_PATH=/opt/usr/share/$ROOTCERT_DIR
+ROOTCERT_DB=$DBSPACE_DIR/.security-rootcert.db
+USERCERT_DB=$DBSPACE_DIR/.security-usercert.db
+
+check_error()
+{
+error_code=$?
+if [ "$error_code" != "0" ]
+then
+       exit $error_code
+fi
+}
+
+mkdir -p $ROOTCERT_DIR
+check_error
+mkdir -p $USERCERT_DIR
+check_error
+mkdir -p $DBSPACE_DIR
+check_error
+
+sqlite3 -line $ROOTCERT_DB 'CREATE TABLE IF NOT EXISTS rootcert (certId INTEGER PRIMARY KEY AUTOINCREMENT, certType SMALLINT DEFAULT 0, certFormat SMALLINT DEFAULT 0, fileName VARCHAR, subjectNameLen SMALLINT DEFAULT 20, subjectName VARCHAR, issuerNameLen SMALLINT DEFAULT 20, issuerName VARCHAR, parentCa SMALLINT, installed VARCHAR, serialNo VARCHAR, serialNoLen SMALLINT DEFAULT 20)'
+check_error
+
+sqlite3 -line $USERCERT_DB 'CREATE TABLE IF NOT EXISTS usercert (certId INTEGER PRIMARY KEY AUTOINCREMENT, certPubKeyHash VARCHAR DEFAULT null, certFormat SMALLINT DEFAULT 0, fileName VARCHAR, subjectNameLen SMALLINT DEFAULT 20, subjectName VARCHAR, issuerNameLen SMALLINT DEFAULT 20, issuerName VARCHAR, prvKeyPath VARCHAR DEFAULT null, prvKeyLen SMALLINT DEFAULT 0, parentCa SMALLINT DEFAULT 0, installed VARCHAR, serialNo VARCHAR, serialNoLen SMALLINT DEFAULT 20)'
+check_error
+
+echo "Insert certificates ..."
+let CNT=1
+for NAME in `find $SRC_PATH -type f`
+do
+       CNT_STR=`printf '%03d' $CNT`
+       PEM=$NAME
+       DER=$ROOTCERT_DIR/$CNT_STR.cert
+
+       echo "[$CNT_STR.cert] "
+
+       openssl x509 -in $PEM -inform PEM -out $DER -outform DER
+       check_error
+
+       SUBJECT_NAME=`openssl x509 -in $DER -inform DER -noout -subject | sed "s#^subject=[ \t]*##"`
+       check_error
+       SUBJECT_NAME_LEN=`echo -n "$SUBJECT_NAME" | wc -c`
+       check_error
+       let SUBJECT_NAME_LEN=($SUBJECT_NAME_LEN+2)/3*4
+       check_error
+       SUBJECT_NAME=`echo -n "$SUBJECT_NAME" | base64 -w 0`
+       check_error
+
+       ISSUER_NAME=`openssl x509 -in $DER -inform DER -noout -issuer | sed "s#^issuer=[ \t]*##"`
+       check_error
+       ISSUER_NAME_LEN=`echo -n "$ISSUER_NAME" | wc -c`
+       check_error
+       let ISSUER_NAME_LEN=($ISSUER_NAME_LEN+2)/3*4
+       check_error
+       ISSUER_NAME=`echo -n "$ISSUER_NAME" | base64 -w 0`
+       check_error
+
+       SERIAL_NO_LEN=`openssl x509 -in $DER -inform DER -noout -serial | sed "s#^serial=[ \t]*##" | xxd -r -p | wc -c`
+       check_error
+       let SERIAL_NO_LEN=($SERIAL_NO_LEN+2)/3*4
+       check_error
+       SERIAL_NO=`openssl x509 -in $DER -inform DER -noout -serial | sed "s#^serial=[ \t]*##" | xxd -r -p | base64 -w 0`
+       check_error
+
+       openssl x509 -in $DER -inform DER -outform PEM >> $CRT
+       check_error
+
+       sqlite3 -line $ROOTCERT_DB "INSERT INTO rootcert (certId, certType, certFormat, fileName, subjectNameLen, subjectName, issuerNameLen, issuerName, parentCa, installed, serialNo, serialNoLen) VALUES ($CNT, 4, 1, '$ROOTCERT_PATH/$CNT_STR.cert', $SUBJECT_NAME_LEN, '$SUBJECT_NAME', $ISSUER_NAME_LEN, '$ISSUER_NAME', $CNT, 'T', '$SERIAL_NO', $SERIAL_NO_LEN)"
+       check_error
+
+       let CNT=$CNT+1
+done
+echo "Insert certificates ... done"