76 midp2PermissionTargets.put(INTERNAL_SOCKET_PERMISSION, "socket://*"); |
77 midp2PermissionTargets.put(INTERNAL_SOCKET_PERMISSION, "socket://*"); |
77 midp2PermissionTargets.put(INTERNAL_HTTP_PERMISSION, "http://*"); |
78 midp2PermissionTargets.put(INTERNAL_HTTP_PERMISSION, "http://*"); |
78 midp2PermissionTargets.put(INTERNAL_HTTPS_PERMISSION, "https://*"); |
79 midp2PermissionTargets.put(INTERNAL_HTTPS_PERMISSION, "https://*"); |
79 midp2PermissionTargets.put(INTERNAL_SSL_PERMISSION, "ssl://*"); |
80 midp2PermissionTargets.put(INTERNAL_SSL_PERMISSION, "ssl://*"); |
80 midp2PermissionTargets.put(INTERNAL_DATAGRAM_PERMISSION,"datagram://*"); |
81 midp2PermissionTargets.put(INTERNAL_DATAGRAM_PERMISSION,"datagram://*"); |
81 midp2PermissionTargets.put(INTERNAL_COMM_PERMISSION, "comm://*"); |
82 midp2PermissionTargets.put(INTERNAL_COMM_PERMISSION, "comm:*"); |
82 midp2PermissionTargets.put(INTERNAL_PUSH_REGISTRY_PERMISSION, "*"); |
83 midp2PermissionTargets.put(INTERNAL_PUSH_REGISTRY_PERMISSION, "*"); |
83 } |
84 } |
84 |
85 |
85 // data being tested |
86 // data being tested |
86 protected SecurityAttributes securityAttributes; |
87 protected SecurityAttributes securityAttributes; |
162 protected void testAuthenticationAttributes() |
163 protected void testAuthenticationAttributes() |
163 { |
164 { |
164 // no attributes |
165 // no attributes |
165 allAttributes.clear(); |
166 allAttributes.clear(); |
166 authAttributes = securityAttributes.getAuthenticationAttributes(); |
167 authAttributes = securityAttributes.getAuthenticationAttributes(); |
167 assertTrue((authAttributes == null) || (authAttributes.length == 0)); |
168 assertWithTrace((authAttributes == null) || (authAttributes.length == 0)); |
168 // empty certificate attribute |
169 // empty certificate attribute |
169 try |
170 try |
170 { |
171 { |
171 allAttributes.clear(); |
172 allAttributes.clear(); |
172 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("", "")); |
173 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("", "")); |
173 securityAttributes = new SecurityAttributes(); |
174 securityAttributes = new SecurityAttributes(); |
174 securityAttributes.addDescriptorAttributes(allAttributes); |
175 securityAttributes.addDescriptorAttributes(allAttributes); |
175 assertTrue(EMPTY_CERTIFICATE_MSG, false); |
176 assertWithTrace(false); |
176 } |
177 } |
177 catch (InvalidAttributeException e) |
178 catch (InvalidAttributeException e) |
178 { |
179 { |
179 assertTrue(EMPTY_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
180 assertWithTrace( |
180 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
181 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
181 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
182 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
182 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
183 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
183 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1"}))); |
184 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1"}))); |
184 } |
185 } |
187 { |
188 { |
188 allAttributes.clear(); |
189 allAttributes.clear(); |
189 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","?%cert")); |
190 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","?%cert")); |
190 securityAttributes = new SecurityAttributes(); |
191 securityAttributes = new SecurityAttributes(); |
191 securityAttributes.addDescriptorAttributes(allAttributes); |
192 securityAttributes.addDescriptorAttributes(allAttributes); |
192 assertTrue(INVALID_CERTIFICATE_MSG, false); |
193 assertWithTrace(false); |
193 } |
194 } |
194 catch (InvalidAttributeException e) |
195 catch (InvalidAttributeException e) |
195 { |
196 { |
196 assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
197 assertWithTrace( |
197 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
198 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
198 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
199 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
199 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
200 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
200 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1"}))); |
201 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1"}))); |
201 } |
202 } |
202 // missing signature attribute |
203 // missing signature attribute |
203 allAttributes.clear(); |
204 allAttributes.clear(); |
204 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
205 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
205 securityAttributes = new SecurityAttributes(); |
206 securityAttributes = new SecurityAttributes(); |
206 securityAttributes.addDescriptorAttributes(allAttributes); |
207 securityAttributes.addDescriptorAttributes(allAttributes); |
207 assertTrue(securityAttributes.getAuthenticationAttributes() == null); |
208 assertWithTrace(securityAttributes.getAuthenticationAttributes() == null); |
208 // missing certificate attribute |
209 // missing certificate attribute |
209 try |
210 try |
210 { |
211 { |
211 allAttributes.clear(); |
212 allAttributes.clear(); |
212 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
213 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
213 securityAttributes = new SecurityAttributes(); |
214 securityAttributes = new SecurityAttributes(); |
214 securityAttributes.addDescriptorAttributes(allAttributes); |
215 securityAttributes.addDescriptorAttributes(allAttributes); |
215 assertTrue(MISSING_CERTIFICATE_ATTRIBUTE_MSG, false); |
216 assertWithTrace(false); |
216 } |
217 } |
217 catch (InvalidAttributeException e) |
218 catch (InvalidAttributeException e) |
218 { |
219 { |
219 assertTrue(MISSING_CERTIFICATE_ATTRIBUTE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
220 assertWithTrace( |
220 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
221 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
221 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
222 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
222 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_MISSING, |
223 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_MISSING, |
223 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1"}))); |
224 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1"}))); |
224 } |
225 } |
228 allAttributes.clear(); |
229 allAttributes.clear(); |
229 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
230 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
230 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","?signature")); |
231 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","?signature")); |
231 securityAttributes = new SecurityAttributes(); |
232 securityAttributes = new SecurityAttributes(); |
232 securityAttributes.addDescriptorAttributes(allAttributes); |
233 securityAttributes.addDescriptorAttributes(allAttributes); |
233 assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG, false); |
234 assertWithTrace(false); |
234 } |
235 } |
235 catch (InvalidAttributeException e) |
236 catch (InvalidAttributeException e) |
236 { |
237 { |
237 assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
238 assertWithTrace( |
238 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
239 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
239 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
240 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
240 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
241 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
241 new String[] {AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME}))); |
242 new String[] {AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME}))); |
242 } |
243 } |
247 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
248 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
248 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
249 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
249 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","?signature")); |
250 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","?signature")); |
250 securityAttributes = new SecurityAttributes(); |
251 securityAttributes = new SecurityAttributes(); |
251 securityAttributes.addDescriptorAttributes(allAttributes); |
252 securityAttributes.addDescriptorAttributes(allAttributes); |
252 assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG, false); |
253 assertWithTrace(false); |
253 } |
254 } |
254 catch (InvalidAttributeException e) |
255 catch (InvalidAttributeException e) |
255 { |
256 { |
256 assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
257 assertWithTrace( |
257 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
258 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
258 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
259 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
259 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
260 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
260 new String[] {AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1"}))); |
261 new String[] {AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1"}))); |
261 } |
262 } |
266 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
267 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
267 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
268 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
268 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "2", new Attribute("","signature")); |
269 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "2", new Attribute("","signature")); |
269 securityAttributes = new SecurityAttributes(); |
270 securityAttributes = new SecurityAttributes(); |
270 securityAttributes.addDescriptorAttributes(allAttributes); |
271 securityAttributes.addDescriptorAttributes(allAttributes); |
271 assertTrue(MISSING_CERTIFICATE_ATTRIBUTE_MSG, false); |
272 assertWithTrace(false); |
272 } |
273 } |
273 catch (InvalidAttributeException e) |
274 catch (InvalidAttributeException e) |
274 { |
275 { |
275 assertTrue(MISSING_CERTIFICATE_ATTRIBUTE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
276 assertWithTrace( |
276 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
277 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
277 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
278 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
278 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_MISSING, |
279 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_MISSING, |
279 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "2-1"}))); |
280 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "2-1"}))); |
280 } |
281 } |
284 allAttributes.clear(); |
285 allAttributes.clear(); |
285 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
286 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
286 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","signature")); |
287 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","signature")); |
287 securityAttributes = new SecurityAttributes(); |
288 securityAttributes = new SecurityAttributes(); |
288 securityAttributes.addDescriptorAttributes(allAttributes); |
289 securityAttributes.addDescriptorAttributes(allAttributes); |
289 assertTrue(MIDP3_ATTRIBUTE_NOT_ALLOWED_MSG, false); |
290 assertWithTrace(false); |
290 } |
291 } |
291 catch (InvalidAttributeException e) |
292 catch (InvalidAttributeException e) |
292 { |
293 { |
293 assertTrue(MIDP3_ATTRIBUTE_NOT_ALLOWED_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
294 assertWithTrace( |
294 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
295 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
295 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
296 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
296 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
297 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
297 new String[] {AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1"}))); |
298 new String[] {AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1"}))); |
298 } |
299 } |
303 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
304 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
304 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
305 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
305 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
306 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
306 securityAttributes = new SecurityAttributes(); |
307 securityAttributes = new SecurityAttributes(); |
307 securityAttributes.addDescriptorAttributes(allAttributes); |
308 securityAttributes.addDescriptorAttributes(allAttributes); |
308 assertTrue(MIDP2_SIGNATURE_NOT_ALLOWED_MSG, false); |
309 assertWithTrace(false); |
309 } |
310 } |
310 catch (InvalidAttributeException e) |
311 catch (InvalidAttributeException e) |
311 { |
312 { |
312 assertTrue(MIDP2_SIGNATURE_NOT_ALLOWED_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
313 assertWithTrace( |
313 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
314 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
314 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
315 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
315 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
316 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
316 new String[] {AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME}))); |
317 new String[] {AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME}))); |
317 } |
318 } |
324 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
325 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert")); |
325 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","signature")); |
326 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","signature")); |
326 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
327 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
327 securityAttributes = new SecurityAttributes(); |
328 securityAttributes = new SecurityAttributes(); |
328 securityAttributes.addDescriptorAttributes(allAttributes); |
329 securityAttributes.addDescriptorAttributes(allAttributes); |
329 assertTrue(MIDP2_SIGNATURE_NOT_ALLOWED_MSG, false); |
330 assertWithTrace(false); |
330 } |
331 } |
331 catch (InvalidAttributeException e) |
332 catch (InvalidAttributeException e) |
332 { |
333 { |
333 assertTrue(MIDP2_SIGNATURE_NOT_ALLOWED_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
334 assertWithTrace( |
334 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
335 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
335 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
336 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
336 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
337 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
337 new String[] {AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME}))); |
338 new String[] {AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME}))); |
338 } |
339 } |
342 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
343 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
343 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
344 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
344 securityAttributes = new SecurityAttributes(); |
345 securityAttributes = new SecurityAttributes(); |
345 securityAttributes.addDescriptorAttributes(allAttributes); |
346 securityAttributes.addDescriptorAttributes(allAttributes); |
346 authAttributes = securityAttributes.getAuthenticationAttributes(); |
347 authAttributes = securityAttributes.getAuthenticationAttributes(); |
347 assertTrue(authAttributes != null |
348 assertWithTrace(authAttributes != null |
348 && authAttributes.length == 1 |
349 && authAttributes.length == 1 |
349 && checkChainsAndSignatures(authAttributes, |
350 && checkChainsAndSignatures(authAttributes, |
350 new String[] {"cert1", "cert2"}, |
351 new String[] {"cert1", "cert2"}, |
351 new String[] {"signature"})); |
352 new String[] {"signature"})); |
352 // 2 identical certificate chains and 1 signature -> only one chain and signature returned (duplicates ignored) |
353 // 2 identical certificate chains and 1 signature -> only one chain and signature returned (duplicates ignored) |
358 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "2-2", new Attribute("","cert2")); |
359 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "2-2", new Attribute("","cert2")); |
359 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
360 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
360 securityAttributes = new SecurityAttributes(); |
361 securityAttributes = new SecurityAttributes(); |
361 securityAttributes.addDescriptorAttributes(allAttributes); |
362 securityAttributes.addDescriptorAttributes(allAttributes); |
362 authAttributes = securityAttributes.getAuthenticationAttributes(); |
363 authAttributes = securityAttributes.getAuthenticationAttributes(); |
363 assertTrue(authAttributes != null |
364 assertWithTrace(authAttributes != null |
364 && authAttributes.length == 1 |
365 && authAttributes.length == 1 |
365 && checkChainsAndSignatures(authAttributes, |
366 && checkChainsAndSignatures(authAttributes, |
366 new String[] {"cert1", "cert2"}, |
367 new String[] {"cert1", "cert2"}, |
367 new String[] {"signature"})); |
368 new String[] {"signature"})); |
368 // 2 identical certificate chains and 2 signatures -> only one chain and signature returned (duplicates ignored) |
369 // 2 identical certificate chains and 2 signatures -> only one chain and signature returned (duplicates ignored) |
375 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "2-2", new Attribute("","cert2")); |
376 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "2-2", new Attribute("","cert2")); |
376 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "2", new Attribute("","signature")); |
377 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "2", new Attribute("","signature")); |
377 securityAttributes = new SecurityAttributes(); |
378 securityAttributes = new SecurityAttributes(); |
378 securityAttributes.addDescriptorAttributes(allAttributes); |
379 securityAttributes.addDescriptorAttributes(allAttributes); |
379 authAttributes = securityAttributes.getAuthenticationAttributes(); |
380 authAttributes = securityAttributes.getAuthenticationAttributes(); |
380 assertTrue(authAttributes != null |
381 assertWithTrace(authAttributes != null |
381 && authAttributes.length == 1 |
382 && authAttributes.length == 1 |
382 && checkChainsAndSignatures(authAttributes, |
383 && checkChainsAndSignatures(authAttributes, |
383 new String[] {"cert1", "cert2"}, |
384 new String[] {"cert1", "cert2"}, |
384 new String[] {"signature"})); |
385 new String[] {"signature"})); |
385 // one certificate chain with 2 certificates and signature |
386 // one certificate chain with 2 certificates and signature |
389 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-4", new Attribute("","cert4")); |
390 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-4", new Attribute("","cert4")); |
390 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
391 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
391 securityAttributes = new SecurityAttributes(); |
392 securityAttributes = new SecurityAttributes(); |
392 securityAttributes.addDescriptorAttributes(allAttributes); |
393 securityAttributes.addDescriptorAttributes(allAttributes); |
393 authAttributes = securityAttributes.getAuthenticationAttributes(); |
394 authAttributes = securityAttributes.getAuthenticationAttributes(); |
394 assertTrue(authAttributes != null |
395 assertWithTrace(authAttributes != null |
395 && authAttributes.length == 1 |
396 && authAttributes.length == 1 |
396 && checkChainsAndSignatures(authAttributes, |
397 && checkChainsAndSignatures(authAttributes, |
397 new String[] {"cert1", "cert2"}, |
398 new String[] {"cert1", "cert2"}, |
398 new String[] {"signature"})); |
399 new String[] {"signature"})); |
399 // two certificate chains with missing one signature -> pick up the valid certificate and ignore the invalid one |
400 // two certificate chains with missing one signature -> pick up the valid certificate and ignore the invalid one |
408 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "4-2", new Attribute("","cert42")); |
409 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "4-2", new Attribute("","cert42")); |
409 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" , new Attribute("","signature1")); |
410 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" , new Attribute("","signature1")); |
410 securityAttributes = new SecurityAttributes(); |
411 securityAttributes = new SecurityAttributes(); |
411 securityAttributes.addDescriptorAttributes(allAttributes); |
412 securityAttributes.addDescriptorAttributes(allAttributes); |
412 authAttributes = securityAttributes.getAuthenticationAttributes(); |
413 authAttributes = securityAttributes.getAuthenticationAttributes(); |
413 assertTrue(authAttributes != null |
414 assertWithTrace(authAttributes != null |
414 && authAttributes.length == 1 |
415 && authAttributes.length == 1 |
415 && checkChainsAndSignatures(authAttributes, |
416 && checkChainsAndSignatures(authAttributes, |
416 new String[] {"cert11", "cert12"}, |
417 new String[] {"cert11", "cert12"}, |
417 new String[] {"signature1"})); |
418 new String[] {"signature1"})); |
418 // two invalid certificate chains: first one with missing signature, the second one invalid certificate -> signal the invalid certificate |
419 // two invalid certificate chains: first one with missing signature, the second one invalid certificate -> signal the invalid certificate |
428 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "4-1", new Attribute("","cert41")); |
429 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "4-1", new Attribute("","cert41")); |
429 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "4-2", new Attribute("","cert42")); |
430 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "4-2", new Attribute("","cert42")); |
430 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "2" , new Attribute("","signature2")); |
431 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "2" , new Attribute("","signature2")); |
431 securityAttributes = new SecurityAttributes(); |
432 securityAttributes = new SecurityAttributes(); |
432 securityAttributes.addDescriptorAttributes(allAttributes); |
433 securityAttributes.addDescriptorAttributes(allAttributes); |
433 assertTrue(CERTIFICATE_WITHOUT_SIGNATURE_MSG, false); |
434 assertWithTrace(false); |
434 } |
435 } |
435 catch (InvalidAttributeException e) |
436 catch (InvalidAttributeException e) |
436 { |
437 { |
437 assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
438 assertWithTrace( |
438 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
439 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
439 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
440 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
440 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
441 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
441 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "2-2"}))); |
442 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "2-2"}))); |
442 } |
443 } |
450 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert11")); |
451 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert11")); |
451 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","*cert12")); |
452 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","*cert12")); |
452 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" , new Attribute("","signature1")); |
453 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" , new Attribute("","signature1")); |
453 securityAttributes = new SecurityAttributes(); |
454 securityAttributes = new SecurityAttributes(); |
454 securityAttributes.addDescriptorAttributes(allAttributes); |
455 securityAttributes.addDescriptorAttributes(allAttributes); |
455 assertTrue(INVALID_CERTIFICATE_MSG, false); |
456 assertWithTrace(false); |
456 } |
457 } |
457 catch (InvalidAttributeException e) |
458 catch (InvalidAttributeException e) |
458 { |
459 { |
459 assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
460 assertWithTrace( |
460 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
461 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
461 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
462 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
462 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
463 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
463 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2"}))); |
464 new String[] {AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2"}))); |
464 } |
465 } |
477 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "2" , new Attribute("","signature2")); |
478 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "2" , new Attribute("","signature2")); |
478 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "5" , new Attribute("","signature5")); |
479 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "5" , new Attribute("","signature5")); |
479 securityAttributes = new SecurityAttributes(); |
480 securityAttributes = new SecurityAttributes(); |
480 securityAttributes.addDescriptorAttributes(allAttributes); |
481 securityAttributes.addDescriptorAttributes(allAttributes); |
481 authAttributes = securityAttributes.getAuthenticationAttributes(); |
482 authAttributes = securityAttributes.getAuthenticationAttributes(); |
482 assertTrue(authAttributes != null |
483 assertWithTrace(authAttributes != null |
483 && authAttributes.length == 2 |
484 && authAttributes.length == 2 |
484 && checkChainsAndSignatures(authAttributes, |
485 && checkChainsAndSignatures(authAttributes, |
485 new String[] {"cert11", "cert12", "cert21", "cert22", "cert23"}, |
486 new String[] {"cert11", "cert12", "cert21", "cert22", "cert23"}, |
486 new String[] {"signature1", "signature2"})); |
487 new String[] {"signature1", "signature2"})); |
487 // 100 certificate chains (10 certificates each) with 100 signatures |
488 // 100 certificate chains (10 certificates each) with 100 signatures |
496 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + i , new Attribute("","signature" + i)); |
497 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + i , new Attribute("","signature" + i)); |
497 } |
498 } |
498 securityAttributes = new SecurityAttributes(); |
499 securityAttributes = new SecurityAttributes(); |
499 securityAttributes.addDescriptorAttributes(allAttributes); |
500 securityAttributes.addDescriptorAttributes(allAttributes); |
500 authAttributes = securityAttributes.getAuthenticationAttributes(); |
501 authAttributes = securityAttributes.getAuthenticationAttributes(); |
501 assertTrue(authAttributes != null && authAttributes.length == 100); |
502 assertWithTrace(authAttributes != null && authAttributes.length == 100); |
502 for (int i=0; i<100; i++) |
503 for (int i=0; i<100; i++) |
503 { |
504 { |
504 // make sure we have 10 certs in each chain and a corresponding signature |
505 // make sure we have 10 certs in each chain and a corresponding signature |
505 assertTrue(authAttributes[i].getCertChain() != null |
506 assertWithTrace(authAttributes[i].getCertChain() != null |
506 && authAttributes[i].getSignature() != null |
507 && authAttributes[i].getSignature() != null |
507 && authAttributes[i].getCertChain().length == 10 |
508 && authAttributes[i].getCertChain().length == 10 |
508 && authAttributes[i].getSignature().equals("signature" + (i+1))); |
509 && authAttributes[i].getSignature().equals("signature" + (i+1))); |
509 // check each chain |
510 // check each chain |
510 for (int j=0; j<10; j++) |
511 for (int j=0; j<10; j++) |
511 { |
512 { |
512 assertTrue((authAttributes[i].getCertChain())[j] |
513 assertWithTrace((authAttributes[i].getCertChain())[j] |
513 .equals("cert" + (i+1) + "" + (j+1))); |
514 .equals("cert" + (i+1) + "" + (j+1))); |
514 } |
515 } |
515 } |
516 } |
516 } |
517 } |
517 |
518 |
524 allAttributes.clear(); |
525 allAttributes.clear(); |
525 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
526 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
526 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("","Perm1, Perm2")); |
527 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("","Perm1, Perm2")); |
527 securityAttributes = new SecurityAttributes(); |
528 securityAttributes = new SecurityAttributes(); |
528 securityAttributes.addDescriptorAttributes(allAttributes); |
529 securityAttributes.addDescriptorAttributes(allAttributes); |
529 assertTrue(LEGACY_NOT_ALLOWED_MSG, false); |
530 assertWithTrace(false); |
530 } |
531 } |
531 catch (InvalidAttributeException e) |
532 catch (InvalidAttributeException e) |
532 { |
533 { |
533 assertTrue(LEGACY_NOT_ALLOWED_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
534 assertWithTrace( |
534 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
535 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
535 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
536 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
536 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
537 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
537 new String[] {PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME}))); |
538 new String[] {PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME}))); |
538 } |
539 } |
542 allAttributes.clear(); |
543 allAttributes.clear(); |
543 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
544 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
544 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("","Perm1, Perm2")); |
545 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("","Perm1, Perm2")); |
545 securityAttributes = new SecurityAttributes(); |
546 securityAttributes = new SecurityAttributes(); |
546 securityAttributes.addDescriptorAttributes(allAttributes); |
547 securityAttributes.addDescriptorAttributes(allAttributes); |
547 assertTrue(LEGACY_NOT_ALLOWED_MSG, false); |
548 assertWithTrace(false); |
548 } |
549 } |
549 catch (InvalidAttributeException e) |
550 catch (InvalidAttributeException e) |
550 { |
551 { |
551 assertTrue(LEGACY_NOT_ALLOWED_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
552 assertWithTrace( |
552 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
553 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
553 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
554 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
554 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
555 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
555 new String[] {PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME}))); |
556 new String[] {PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME}))); |
556 } |
557 } |
561 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
562 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
562 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1", |
563 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1", |
563 new Attribute("","PermissionClassName TargetName ActionList")); |
564 new Attribute("","PermissionClassName TargetName ActionList")); |
564 securityAttributes = new SecurityAttributes(); |
565 securityAttributes = new SecurityAttributes(); |
565 securityAttributes.addDescriptorAttributes(allAttributes); |
566 securityAttributes.addDescriptorAttributes(allAttributes); |
566 assertTrue(MIDP3_ATTRIBUTE_NOT_ALLOWED_MSG, false); |
567 assertWithTrace(false); |
567 } |
568 } |
568 catch (InvalidAttributeException e) |
569 catch (InvalidAttributeException e) |
569 { |
570 { |
570 assertTrue(MIDP3_ATTRIBUTE_NOT_ALLOWED_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
571 assertWithTrace( |
571 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
572 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
572 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
573 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
573 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
574 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
574 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
575 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
575 } |
576 } |
580 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
581 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
581 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1", |
582 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1", |
582 new Attribute("","PermissionClassName TargetName ActionList")); |
583 new Attribute("","PermissionClassName TargetName ActionList")); |
583 securityAttributes = new SecurityAttributes(); |
584 securityAttributes = new SecurityAttributes(); |
584 securityAttributes.addDescriptorAttributes(allAttributes); |
585 securityAttributes.addDescriptorAttributes(allAttributes); |
585 assertTrue(MIDP3_ATTRIBUTE_NOT_ALLOWED_MSG, false); |
586 assertWithTrace(false); |
586 } |
587 } |
587 catch (InvalidAttributeException e) |
588 catch (InvalidAttributeException e) |
588 { |
589 { |
589 assertTrue(MIDP3_ATTRIBUTE_NOT_ALLOWED_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
590 assertWithTrace( |
590 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
591 e.getOtaStatusCode() == OtaStatusCode.INVALID_DESCRIPTOR |
591 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
592 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
592 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
593 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
593 new String[] {PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1"}))); |
594 new String[] {PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1"}))); |
594 } |
595 } |
599 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, |
600 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, |
600 new Attribute("","PermissionClassName TargetName ActionList")); |
601 new Attribute("","PermissionClassName TargetName ActionList")); |
601 securityAttributes = new SecurityAttributes(); |
602 securityAttributes = new SecurityAttributes(); |
602 securityAttributes.addDescriptorAttributes(allAttributes); |
603 securityAttributes.addDescriptorAttributes(allAttributes); |
603 permissionAttributes = securityAttributes.getPermissionAttributes(); |
604 permissionAttributes = securityAttributes.getPermissionAttributes(); |
604 assertTrue(permissionAttributes != null |
605 assertWithTrace(permissionAttributes != null |
605 && permissionAttributes.length == 1 |
606 && permissionAttributes.length == 1 |
606 && permissionAttributes[0].isLegacyAttribute()); |
607 && permissionAttributes[0].isLegacyAttribute()); |
607 // MIDP2 mandatory permissions handling - invalid permission value |
608 // MIDP2 mandatory permissions handling - invalid permission value |
608 try |
609 try |
609 { |
610 { |
614 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert1")); |
615 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert1")); |
615 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
616 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
616 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
617 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
617 securityAttributes = new SecurityAttributes(); |
618 securityAttributes = new SecurityAttributes(); |
618 securityAttributes.addDescriptorAttributes(allAttributes); |
619 securityAttributes.addDescriptorAttributes(allAttributes); |
619 assertTrue(UNKNOWN_PERMISSION_MSG, false); |
620 assertWithTrace(false); |
620 } |
621 } |
621 catch (InvalidAttributeException e) |
622 catch (InvalidAttributeException e) |
622 { |
623 { |
623 assertTrue(UNKNOWN_PERMISSION_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
624 assertWithTrace( |
624 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
625 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
625 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
626 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
626 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
627 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
627 new String[] {PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME}))); |
628 new String[] {PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME}))); |
628 } |
629 } |
638 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert1")); |
639 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert1")); |
639 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
640 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
640 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
641 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
641 securityAttributes = new SecurityAttributes(); |
642 securityAttributes = new SecurityAttributes(); |
642 securityAttributes.addDescriptorAttributes(allAttributes); |
643 securityAttributes.addDescriptorAttributes(allAttributes); |
643 assertTrue(UNKNOWN_PERMISSION_MSG, false); |
644 assertWithTrace(false); |
644 } |
645 } |
645 catch (InvalidAttributeException e) |
646 catch (InvalidAttributeException e) |
646 { |
647 { |
647 assertTrue(UNKNOWN_PERMISSION_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
648 assertWithTrace( |
648 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
649 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
649 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
650 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
650 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
651 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
651 new String[] {PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME}))); |
652 new String[] {PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME}))); |
652 } |
653 } |
661 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
662 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
662 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
663 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
663 securityAttributes = new SecurityAttributes(); |
664 securityAttributes = new SecurityAttributes(); |
664 securityAttributes.addDescriptorAttributes(allAttributes); |
665 securityAttributes.addDescriptorAttributes(allAttributes); |
665 permissionAttributes = securityAttributes.getPermissionAttributes(); |
666 permissionAttributes = securityAttributes.getPermissionAttributes(); |
666 assertTrue(permissionAttributes != null |
667 assertWithTrace(permissionAttributes != null |
667 && permissionAttributes.length == 2 |
668 && permissionAttributes.length == 2 |
668 && checkImportance(permissionAttributes, 0, 2) |
669 && checkImportance(permissionAttributes, 0, 2) |
669 && checkNamesAndTargets(permissionAttributes, |
670 && checkNamesAndTargets(permissionAttributes, |
670 new String[] {INTERNAL_SOCKET_PERMISSION, INTERNAL_HTTP_PERMISSION}) |
671 new String[] {INTERNAL_SOCKET_PERMISSION, INTERNAL_HTTP_PERMISSION}) |
671 && checkActionLists(permissionAttributes)); |
672 && checkActionLists(permissionAttributes)); |
679 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
680 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
680 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
681 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
681 securityAttributes = new SecurityAttributes(); |
682 securityAttributes = new SecurityAttributes(); |
682 securityAttributes.addDescriptorAttributes(allAttributes); |
683 securityAttributes.addDescriptorAttributes(allAttributes); |
683 permissionAttributes = securityAttributes.getPermissionAttributes(); |
684 permissionAttributes = securityAttributes.getPermissionAttributes(); |
684 assertTrue(permissionAttributes != null |
685 assertWithTrace(permissionAttributes != null |
685 && permissionAttributes.length == 1 |
686 && permissionAttributes.length == 1 |
686 && checkImportance(permissionAttributes, 0, 1) |
687 && checkImportance(permissionAttributes, 0, 1) |
687 && checkNamesAndTargets(permissionAttributes, |
688 && checkNamesAndTargets(permissionAttributes, |
688 new String[] {INTERNAL_SSL_PERMISSION}) |
689 new String[] {INTERNAL_SSL_PERMISSION}) |
689 && checkActionLists(permissionAttributes)); |
690 && checkActionLists(permissionAttributes)); |
696 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert1")); |
697 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert1")); |
697 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
698 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
698 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
699 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
699 securityAttributes = new SecurityAttributes(); |
700 securityAttributes = new SecurityAttributes(); |
700 securityAttributes.addDescriptorAttributes(allAttributes); |
701 securityAttributes.addDescriptorAttributes(allAttributes); |
701 assertTrue(UNKNOWN_PERMISSION_MSG, true); |
702 assertWithTrace(true); |
702 } |
703 } |
703 catch (InvalidAttributeException e) |
704 catch (InvalidAttributeException e) |
704 { |
705 { |
705 assertTrue(UNKNOWN_PERMISSION_MSG, false); |
706 assertWithTrace(false); |
706 } |
707 } |
707 // MIDP2 optional permissions handling - unknown permission value |
708 // MIDP2 optional permissions handling - unknown permission value |
708 try |
709 try |
709 { |
710 { |
710 allAttributes.clear(); |
711 allAttributes.clear(); |
714 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert1")); |
715 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert1")); |
715 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
716 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
716 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
717 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
717 securityAttributes = new SecurityAttributes(); |
718 securityAttributes = new SecurityAttributes(); |
718 securityAttributes.addDescriptorAttributes(allAttributes); |
719 securityAttributes.addDescriptorAttributes(allAttributes); |
719 assertTrue(UNKNOWN_PERMISSION_MSG, true); |
720 assertWithTrace(true); |
720 } |
721 } |
721 catch (InvalidAttributeException e) |
722 catch (InvalidAttributeException e) |
722 { |
723 { |
723 assertTrue(UNKNOWN_PERMISSION_MSG, false); |
724 assertWithTrace(false); |
724 } |
725 } |
725 // MIDP2 optional permissions handling - known permission value |
726 // MIDP2 optional permissions handling - known permission value |
726 allAttributes.clear(); |
727 allAttributes.clear(); |
727 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
728 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
728 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, |
729 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, |
732 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
733 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
733 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
734 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
734 securityAttributes = new SecurityAttributes(); |
735 securityAttributes = new SecurityAttributes(); |
735 securityAttributes.addDescriptorAttributes(allAttributes); |
736 securityAttributes.addDescriptorAttributes(allAttributes); |
736 permissionAttributes = securityAttributes.getPermissionAttributes(); |
737 permissionAttributes = securityAttributes.getPermissionAttributes(); |
737 assertTrue(permissionAttributes != null |
738 assertWithTrace(permissionAttributes != null |
738 && permissionAttributes.length == 2 |
739 && permissionAttributes.length == 2 |
739 && checkImportance(permissionAttributes, 2, 0) |
740 && checkImportance(permissionAttributes, 2, 0) |
740 && checkNamesAndTargets(permissionAttributes, |
741 && checkNamesAndTargets(permissionAttributes, |
741 new String[] |
742 new String[] |
742 { |
743 { |
754 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
755 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
755 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
756 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
756 securityAttributes = new SecurityAttributes(); |
757 securityAttributes = new SecurityAttributes(); |
757 securityAttributes.addDescriptorAttributes(allAttributes); |
758 securityAttributes.addDescriptorAttributes(allAttributes); |
758 permissionAttributes = securityAttributes.getPermissionAttributes(); |
759 permissionAttributes = securityAttributes.getPermissionAttributes(); |
759 assertTrue(permissionAttributes != null |
760 assertWithTrace(permissionAttributes != null |
760 && permissionAttributes.length == 1 |
761 && permissionAttributes.length == 1 |
761 && checkImportance(permissionAttributes, 1, 0) |
762 && checkImportance(permissionAttributes, 1, 0) |
762 && checkNamesAndTargets(permissionAttributes, |
763 && checkNamesAndTargets(permissionAttributes, |
763 new String[] {INTERNAL_PUSH_REGISTRY_PERMISSION}) |
764 new String[] {INTERNAL_PUSH_REGISTRY_PERMISSION}) |
764 && checkActionLists(permissionAttributes)); |
765 && checkActionLists(permissionAttributes)); |
775 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
776 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
776 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
777 allAttributes.put(AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME, new Attribute("","signature")); |
777 securityAttributes = new SecurityAttributes(); |
778 securityAttributes = new SecurityAttributes(); |
778 securityAttributes.addDescriptorAttributes(allAttributes); |
779 securityAttributes.addDescriptorAttributes(allAttributes); |
779 permissionAttributes = securityAttributes.getPermissionAttributes(); |
780 permissionAttributes = securityAttributes.getPermissionAttributes(); |
780 assertTrue(permissionAttributes != null |
781 assertWithTrace(permissionAttributes != null |
781 && permissionAttributes.length == 4 |
782 && permissionAttributes.length == 4 |
782 && checkImportance(permissionAttributes, 2, 2) |
783 && checkImportance(permissionAttributes, 2, 2) |
783 && checkNamesAndTargets(permissionAttributes, |
784 && checkNamesAndTargets(permissionAttributes, |
784 new String[] |
785 new String[] |
785 { |
786 { |
795 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass")); |
796 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass")); |
796 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1",new Attribute("","MyOptionalClass")); |
797 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1",new Attribute("","MyOptionalClass")); |
797 securityAttributes = new SecurityAttributes(); |
798 securityAttributes = new SecurityAttributes(); |
798 securityAttributes.addDescriptorAttributes(allAttributes); |
799 securityAttributes.addDescriptorAttributes(allAttributes); |
799 permissionAttributes = securityAttributes.getPermissionAttributes(); |
800 permissionAttributes = securityAttributes.getPermissionAttributes(); |
800 assertTrue(permissionAttributes != null |
801 assertWithTrace(permissionAttributes != null |
801 && permissionAttributes.length == 2 |
802 && permissionAttributes.length == 2 |
802 && checkImportance(permissionAttributes, 1, 1) |
803 && checkImportance(permissionAttributes, 1, 1) |
803 && checkNamesAndTargets(permissionAttributes, |
804 && checkNamesAndTargets(permissionAttributes, |
804 new String[] {"MyMandatoryClass", "MyOptionalClass"}, new String[] {null, null}) |
805 new String[] {"MyMandatoryClass", "MyOptionalClass"}, new String[] {null, null}) |
805 && checkActionLists(permissionAttributes)); |
806 && checkActionLists(permissionAttributes)); |
809 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget")); |
810 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget")); |
810 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1",new Attribute("","MyOptionalClass MyOptionalTarget")); |
811 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1",new Attribute("","MyOptionalClass MyOptionalTarget")); |
811 securityAttributes = new SecurityAttributes(); |
812 securityAttributes = new SecurityAttributes(); |
812 securityAttributes.addDescriptorAttributes(allAttributes); |
813 securityAttributes.addDescriptorAttributes(allAttributes); |
813 permissionAttributes = securityAttributes.getPermissionAttributes(); |
814 permissionAttributes = securityAttributes.getPermissionAttributes(); |
814 assertTrue(permissionAttributes != null |
815 assertWithTrace(permissionAttributes != null |
815 && permissionAttributes.length == 2 |
816 && permissionAttributes.length == 2 |
816 && checkImportance(permissionAttributes, 1, 1) |
817 && checkImportance(permissionAttributes, 1, 1) |
817 && checkNamesAndTargets(permissionAttributes, |
818 && checkNamesAndTargets(permissionAttributes, |
818 new String[] {"MyMandatoryClass", "MyOptionalClass"}, new String[] {"MyMandatoryTarget","MyOptionalTarget"}) |
819 new String[] {"MyMandatoryClass", "MyOptionalClass"}, new String[] {"MyMandatoryTarget","MyOptionalTarget"}) |
819 && checkActionLists(permissionAttributes)); |
820 && checkActionLists(permissionAttributes)); |
823 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3")); |
824 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3")); |
824 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1",new Attribute("","MyOptionalClass MyOptionalTarget MyOptionalAction")); |
825 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1",new Attribute("","MyOptionalClass MyOptionalTarget MyOptionalAction")); |
825 securityAttributes = new SecurityAttributes(); |
826 securityAttributes = new SecurityAttributes(); |
826 securityAttributes.addDescriptorAttributes(allAttributes); |
827 securityAttributes.addDescriptorAttributes(allAttributes); |
827 permissionAttributes = securityAttributes.getPermissionAttributes(); |
828 permissionAttributes = securityAttributes.getPermissionAttributes(); |
828 assertTrue(permissionAttributes != null |
829 assertWithTrace(permissionAttributes != null |
829 && permissionAttributes.length == 2 |
830 && permissionAttributes.length == 2 |
830 && checkImportance(permissionAttributes, 1, 1) |
831 && checkImportance(permissionAttributes, 1, 1) |
831 && checkNamesAndTargets(permissionAttributes, |
832 && checkNamesAndTargets(permissionAttributes, |
832 new String[] {"MyMandatoryClass", "MyOptionalClass"}, new String[] {"MyMandatoryTarget","MyOptionalTarget"}) |
833 new String[] {"MyMandatoryClass", "MyOptionalClass"}, new String[] {"MyMandatoryTarget","MyOptionalTarget"}) |
833 && checkActionLists(permissionAttributes, new String[] {"MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3", "MyOptionalAction"})); |
834 && checkActionLists(permissionAttributes, new String[] {"MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3", "MyOptionalAction"})); |
839 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1",new Attribute("","MyOptionalClass MyOptionalTarget MyOptionalAction")); |
840 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1",new Attribute("","MyOptionalClass MyOptionalTarget MyOptionalAction")); |
840 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "2",new Attribute("","MyOptionalClass MyOptionalTarget MyOptionalAction")); |
841 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "2",new Attribute("","MyOptionalClass MyOptionalTarget MyOptionalAction")); |
841 securityAttributes = new SecurityAttributes(); |
842 securityAttributes = new SecurityAttributes(); |
842 securityAttributes.addDescriptorAttributes(allAttributes); |
843 securityAttributes.addDescriptorAttributes(allAttributes); |
843 permissionAttributes = securityAttributes.getPermissionAttributes(); |
844 permissionAttributes = securityAttributes.getPermissionAttributes(); |
844 assertTrue(permissionAttributes != null |
845 assertWithTrace(permissionAttributes != null |
845 && permissionAttributes.length == 2 |
846 && permissionAttributes.length == 2 |
846 && checkImportance(permissionAttributes, 1, 1) |
847 && checkImportance(permissionAttributes, 1, 1) |
847 && checkNamesAndTargets(permissionAttributes, |
848 && checkNamesAndTargets(permissionAttributes, |
848 new String[] {"MyMandatoryClass", "MyOptionalClass"}, new String[] {"MyMandatoryTarget","MyOptionalTarget"}) |
849 new String[] {"MyMandatoryClass", "MyOptionalClass"}, new String[] {"MyMandatoryTarget","MyOptionalTarget"}) |
849 && checkActionLists(permissionAttributes, new String[] {"MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3", "MyOptionalAction"})); |
850 && checkActionLists(permissionAttributes, new String[] {"MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3", "MyOptionalAction"})); |
853 allAttributes.clear(); |
854 allAttributes.clear(); |
854 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
855 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
855 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1 MyMandatoryAction2")); |
856 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1 MyMandatoryAction2")); |
856 securityAttributes = new SecurityAttributes(); |
857 securityAttributes = new SecurityAttributes(); |
857 securityAttributes.addDescriptorAttributes(allAttributes); |
858 securityAttributes.addDescriptorAttributes(allAttributes); |
858 assertTrue(INVALID_PERMISSION_VALUE_MSG, false); |
859 assertWithTrace(false); |
859 } |
860 } |
860 catch (InvalidAttributeException e) |
861 catch (InvalidAttributeException e) |
861 { |
862 { |
862 assertTrue(INVALID_PERMISSION_VALUE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
863 assertWithTrace( |
863 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
864 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
864 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
865 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
865 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
866 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
866 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
867 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
867 } |
868 } |
871 allAttributes.clear(); |
872 allAttributes.clear(); |
872 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
873 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
873 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1 MyMandatoryAction2")); |
874 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1 MyMandatoryAction2")); |
874 securityAttributes = new SecurityAttributes(); |
875 securityAttributes = new SecurityAttributes(); |
875 securityAttributes.addDescriptorAttributes(allAttributes); |
876 securityAttributes.addDescriptorAttributes(allAttributes); |
876 assertTrue(INVALID_PERMISSION_VALUE_MSG, false); |
877 assertWithTrace(false); |
877 } |
878 } |
878 catch (InvalidAttributeException e) |
879 catch (InvalidAttributeException e) |
879 { |
880 { |
880 assertTrue(INVALID_PERMISSION_VALUE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
881 assertWithTrace( |
881 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
882 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE |
882 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
883 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
883 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
884 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED, |
884 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
885 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
885 } |
886 } |
888 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
889 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
889 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1",new Attribute(""," MyMandatoryClass MyMandatoryTarget MyMandatoryAction ")); |
890 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1",new Attribute(""," MyMandatoryClass MyMandatoryTarget MyMandatoryAction ")); |
890 securityAttributes = new SecurityAttributes(); |
891 securityAttributes = new SecurityAttributes(); |
891 securityAttributes.addDescriptorAttributes(allAttributes); |
892 securityAttributes.addDescriptorAttributes(allAttributes); |
892 permissionAttributes = securityAttributes.getPermissionAttributes(); |
893 permissionAttributes = securityAttributes.getPermissionAttributes(); |
893 assertTrue(permissionAttributes != null |
894 assertWithTrace(permissionAttributes != null |
894 && permissionAttributes.length == 1 |
895 && permissionAttributes.length == 1 |
895 && checkImportance(permissionAttributes, 1, 0) |
896 && checkImportance(permissionAttributes, 1, 0) |
896 && checkNamesAndTargets(permissionAttributes, |
897 && checkNamesAndTargets(permissionAttributes, |
897 new String[] {"MyMandatoryClass"}, new String[] {"MyMandatoryTarget"}) |
898 new String[] {"MyMandatoryClass"}, new String[] {"MyMandatoryTarget"}) |
898 && checkActionLists(permissionAttributes, new String[] {"MyMandatoryAction"})); |
899 && checkActionLists(permissionAttributes, new String[] {"MyMandatoryAction"})); |