|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include <string.h> |
|
18 |
|
19 #include "javacertstorehandler.h" |
|
20 |
|
21 #include "comms.h" |
|
22 #include "commsclientendpoint.h" |
|
23 #include "commsmessage.h" |
|
24 #include "securitycommsmessagedefs.h" |
|
25 |
|
26 using namespace std; |
|
27 using namespace java::security; |
|
28 using namespace java::comms; |
|
29 |
|
30 void JavaCertStoreHandler::retrieveRootProtDomainInfo(const char rootHash[], |
|
31 string& protDomainName, |
|
32 string& protDomainCategory) |
|
33 { |
|
34 CommsClientEndpoint cli_conn; |
|
35 if (cli_conn.connect(IPC_ADDRESS_JAVA_CAPTAIN_C) != 0) |
|
36 { |
|
37 return; |
|
38 } |
|
39 CommsMessage s_msg; |
|
40 CommsMessage r_msg; |
|
41 s_msg.setModuleId(PLUGIN_ID_JAVA_CERT_STORE_EXTENSION_C); |
|
42 s_msg.setMessageId(JAVA_CERT_STORE_MSG_ID_REQUEST); |
|
43 s_msg << JAVA_CERT_STORE_OPERATION_QUERY_CERTS; |
|
44 // add filter |
|
45 s_msg << JAVA_CERT_STORE_FILTER_ID_STATE << JAVA_CERT_STORE_STATE_ENABLED; |
|
46 s_msg << JAVA_CERT_STORE_FILTER_ID_HASH << rootHash; |
|
47 // add the query ID |
|
48 s_msg << JAVA_CERT_STORE_QUERY_ID_PROTECTION_DOMAIN; |
|
49 if (cli_conn.sendReceive(s_msg,r_msg,10) != 0) |
|
50 { |
|
51 return; |
|
52 } |
|
53 r_msg >> protDomainName; |
|
54 if (strcmp(protDomainName.c_str(),"")) |
|
55 { |
|
56 r_msg >> protDomainCategory; |
|
57 } |
|
58 cli_conn.disconnect(); |
|
59 } |
|
60 |
|
61 void JavaCertStoreHandler::retrieveRootsContents(std::vector<std::string>& aRootsContents) |
|
62 { |
|
63 CommsClientEndpoint cli_conn; |
|
64 if (cli_conn.connect(IPC_ADDRESS_JAVA_CAPTAIN_C) != 0) |
|
65 { |
|
66 return; |
|
67 } |
|
68 CommsMessage s_msg; |
|
69 CommsMessage r_msg; |
|
70 s_msg.setModuleId(PLUGIN_ID_JAVA_CERT_STORE_EXTENSION_C); |
|
71 // operation |
|
72 s_msg.setMessageId(JAVA_CERT_STORE_MSG_ID_REQUEST); |
|
73 s_msg << JAVA_CERT_STORE_OPERATION_QUERY_CERTS; |
|
74 // add filter |
|
75 s_msg << JAVA_CERT_STORE_FILTER_ID_STATE << JAVA_CERT_STORE_STATE_ENABLED; |
|
76 // add the query ID |
|
77 s_msg << JAVA_CERT_STORE_QUERY_ID_CERT_CONTENT; |
|
78 if (cli_conn.sendReceive(s_msg,r_msg,10) != 0) |
|
79 { |
|
80 return; |
|
81 } |
|
82 long long tmp; |
|
83 r_msg >> tmp; |
|
84 while (tmp != 0) |
|
85 { |
|
86 string rootContent; |
|
87 r_msg >> rootContent; |
|
88 aRootsContents.push_back(rootContent); |
|
89 r_msg >> tmp; |
|
90 } |
|
91 cli_conn.disconnect(); |
|
92 } |
|
93 |
|
94 void JavaCertStoreHandler::retrieveRootContent(wstring& rootHash, |
|
95 long long* len, |
|
96 string& rootContent) |
|
97 { |
|
98 CommsClientEndpoint cli_conn; |
|
99 if (cli_conn.connect(IPC_ADDRESS_JAVA_CAPTAIN_C) != 0) |
|
100 { |
|
101 return; |
|
102 } |
|
103 CommsMessage s_msg; |
|
104 CommsMessage r_msg; |
|
105 s_msg.setModuleId(PLUGIN_ID_JAVA_CERT_STORE_EXTENSION_C); |
|
106 // operation |
|
107 s_msg.setMessageId(JAVA_CERT_STORE_MSG_ID_REQUEST); |
|
108 s_msg << JAVA_CERT_STORE_OPERATION_QUERY_CERTS; |
|
109 // add filter |
|
110 s_msg << JAVA_CERT_STORE_FILTER_ID_STATE << JAVA_CERT_STORE_STATE_ENABLED; |
|
111 s_msg << JAVA_CERT_STORE_FILTER_ID_HASH << rootHash; |
|
112 // add the query ID |
|
113 s_msg << JAVA_CERT_STORE_QUERY_ID_CERT_CONTENT; |
|
114 if (cli_conn.sendReceive(s_msg,r_msg,10) != 0) |
|
115 { |
|
116 return; |
|
117 } |
|
118 long long tmp; |
|
119 r_msg >> tmp; |
|
120 *len = tmp; |
|
121 if (tmp == 0) |
|
122 { |
|
123 return; |
|
124 } |
|
125 r_msg >> rootContent; |
|
126 cli_conn.disconnect(); |
|
127 } |