224 AuthenticationCredentials[] authCredentials = null; |
231 AuthenticationCredentials[] authCredentials = null; |
225 Hashtable allAttributes = new Hashtable(); |
232 Hashtable allAttributes = new Hashtable(); |
226 MIDPPermission[] jadPermissions; |
233 MIDPPermission[] jadPermissions; |
227 MIDPPermission[] jarPermissions; |
234 MIDPPermission[] jarPermissions; |
228 MIDPPermission[] allPermissions; |
235 MIDPPermission[] allPermissions; |
229 assertTrue(permissionGranter != null); |
236 assertWithTrace(permissionGranter != null); |
230 // test the null values |
237 // test the null values |
231 permissionGranter.removeSecurityData(session, appUID); |
238 permissionGranter.removeSecurityData(session, appUID); |
232 permissionGranter.grantJarPermissions(null, null, null, (PermissionAttribute[])null); |
239 permissionGranter.grantJarPermissions(null, null, (PermissionAttribute[])null, null); |
233 grantedPermissions = storage.readGrantedPermissions(appUID); |
240 grantedPermissions = storage.readGrantedPermissions(appUID); |
234 assertTrue(grantedPermissions == null); |
241 assertWithTrace(grantedPermissions == null); |
235 // populate the storage |
242 // populate the storage |
236 storage.removeAuthenticationStorageData(appUID); |
243 storage.removeAuthenticationStorageData(appUID); |
237 permissionGranter.removeSecurityData(session, appUID); |
244 permissionGranter.removeSecurityData(session, appUID); |
238 AuthenticationStorageData authStorageData = new AuthenticationStorageData("protDomain", "category", "jarHash", "certHash", null, null); |
245 AuthenticationStorageData authStorageData = new AuthenticationStorageData("protDomain", "category", "jarHash", "certHash", null, null); |
239 storage.writeAuthenticationStorageData(appUID, authStorageData); |
246 storage.writeAuthenticationStorageData(appUID, authStorageData); |
257 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
264 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
258 allAttributes.clear(); |
265 allAttributes.clear(); |
259 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_DATAGRAM_PERMISSION + COMMA + " " + MIDP2_COMM_PERMISSION)); |
266 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_DATAGRAM_PERMISSION + COMMA + " " + MIDP2_COMM_PERMISSION)); |
260 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_SOCKET_PERMISSION + COMMA + MIDP2_HTTP_PERMISSION)); |
267 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_SOCKET_PERMISSION + COMMA + MIDP2_HTTP_PERMISSION)); |
261 securityAttributes.addManifestAttributes(allAttributes); |
268 securityAttributes.addManifestAttributes(allAttributes); |
262 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
269 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
263 grantedPermissions = storage.readGrantedPermissions(appUID); |
270 permissionGranter.addSecurityData(session, appUID, null); |
264 assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Manufacturer", new String[] |
271 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
272 assertWithTrace(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Manufacturer", new String[] |
265 { |
273 { |
266 INTERNAL_DATAGRAM_PERMISSION, INTERNAL_COMM_PERMISSION, INTERNAL_SOCKET_PERMISSION,INTERNAL_HTTP_PERMISSION,"javax.microedition.PropertyPermission","javax.microedition.midlet.AutoStartPermission" |
274 INTERNAL_DATAGRAM_PERMISSION, INTERNAL_COMM_PERMISSION, INTERNAL_SOCKET_PERMISSION,INTERNAL_HTTP_PERMISSION,"javax.microedition.PropertyPermission","javax.microedition.midlet.AutoStartPermission" |
267 }), |
275 }), |
268 getDefaultPermissions())); |
276 getDefaultPermissions())); |
269 // 1.1 Legacy, signed: P1, P2 requested in the JAD, P3, P4 requested in the JAR -> grant the requested permissions filled in with right targets/actions from the policy |
277 // 1.1 Legacy, signed: P1, P2 requested in the JAD, P3, P4 requested in the JAR -> grant the requested permissions filled in with right targets/actions from the policy |
285 allAttributes.clear(); |
293 allAttributes.clear(); |
286 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
294 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
287 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_DATAGRAM_PERMISSION + COMMA + " " + MIDP2_COMM_PERMISSION)); |
295 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_DATAGRAM_PERMISSION + COMMA + " " + MIDP2_COMM_PERMISSION)); |
288 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_SOCKET_PERMISSION + COMMA + MIDP2_HTTP_PERMISSION)); |
296 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_SOCKET_PERMISSION + COMMA + MIDP2_HTTP_PERMISSION)); |
289 securityAttributes.addManifestAttributes(allAttributes); |
297 securityAttributes.addManifestAttributes(allAttributes); |
290 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
298 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
291 grantedPermissions = storage.readGrantedPermissions(appUID); |
299 permissionGranter.addSecurityData(session, appUID, null); |
292 assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("IdentifiedThirdParty", |
300 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
301 assertWithTrace(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("IdentifiedThirdParty", |
293 new String[] {INTERNAL_DATAGRAM_PERMISSION, INTERNAL_COMM_PERMISSION, INTERNAL_SOCKET_PERMISSION,INTERNAL_HTTP_PERMISSION}), |
302 new String[] {INTERNAL_DATAGRAM_PERMISSION, INTERNAL_COMM_PERMISSION, INTERNAL_SOCKET_PERMISSION,INTERNAL_HTTP_PERMISSION}), |
294 getAssignedPermissions("IdentifiedThirdParty"))); |
303 getAssignedPermissions("IdentifiedThirdParty"))); |
295 // 1.2 One of the requested mandatory permission is not available in the domain -> fail |
304 // 1.2 One of the requested mandatory permission is not available in the domain -> fail |
296 try |
305 try |
297 { |
306 { |
312 allAttributes.clear(); |
321 allAttributes.clear(); |
313 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
322 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
314 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1", new Attribute("",MIDP3_DATAGRAM_PERMISSION)); |
323 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1", new Attribute("",MIDP3_DATAGRAM_PERMISSION)); |
315 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1", new Attribute("",MIDP3_RUNTIME_PERMISSION + " name")); |
324 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1", new Attribute("",MIDP3_RUNTIME_PERMISSION + " name")); |
316 securityAttributes.addManifestAttributes(allAttributes); |
325 securityAttributes.addManifestAttributes(allAttributes); |
317 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
326 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
318 assertTrue(INVALID_PERMISSION_VALUE_MSG, false); |
327 permissionGranter.addSecurityData(session, appUID, null); |
|
328 assertWithTrace(false); |
319 } |
329 } |
320 catch (InvalidAttributeException e) |
330 catch (InvalidAttributeException e) |
321 { |
331 { |
322 assertTrue(INVALID_PERMISSION_VALUE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
332 assertWithTrace( |
323 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
333 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
324 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
334 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
325 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
335 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
326 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
336 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
327 } |
337 } |
341 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
351 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
342 allAttributes.clear(); |
352 allAttributes.clear(); |
343 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
353 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
344 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1", new Attribute("",MIDP3_RUNTIME_PERMISSION + " name")); |
354 allAttributes.put(PermissionAttribute.OPTIONAL_ATTRIBUTE_PREFIX + "1", new Attribute("",MIDP3_RUNTIME_PERMISSION + " name")); |
345 securityAttributes.addManifestAttributes(allAttributes); |
355 securityAttributes.addManifestAttributes(allAttributes); |
346 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
356 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
347 grantedPermissions = storage.readGrantedPermissions(appUID); |
357 permissionGranter.addSecurityData(session, appUID, null); |
348 assertTrue(checkGrantedPermissions(grantedPermissions, getAssignedPermissions("IdentifiedThirdParty"), true)); |
358 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
359 assertWithTrace(checkGrantedPermissions(grantedPermissions, getAssignedPermissions("IdentifiedThirdParty"), true)); |
349 // 2. Legacy, signed : permissions NOT requested in JAD & permissions requested in JAR -> grant the requested permissions filled in with right |
360 // 2. Legacy, signed : permissions NOT requested in JAD & permissions requested in JAR -> grant the requested permissions filled in with right |
350 // targets/actions from the policy plus the assigned ones |
361 // targets/actions from the policy plus the assigned ones |
351 storage.removeAuthenticationStorageData(appUID); |
362 storage.removeAuthenticationStorageData(appUID); |
352 permissionGranter.removeSecurityData(session, appUID); |
363 permissionGranter.removeSecurityData(session, appUID); |
353 authData = new AuthenticationStorageData("Operator", "OPD", null, null, null, null); |
364 authData = new AuthenticationStorageData("Operator", "OPD", null, null, null, null); |
363 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
374 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
364 allAttributes.clear(); |
375 allAttributes.clear(); |
365 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
376 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
366 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_SOCKET_PERMISSION + COMMA + MIDP2_HTTP_PERMISSION)); |
377 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_SOCKET_PERMISSION + COMMA + MIDP2_HTTP_PERMISSION)); |
367 securityAttributes.addManifestAttributes(allAttributes); |
378 securityAttributes.addManifestAttributes(allAttributes); |
368 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
379 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
369 grantedPermissions = storage.readGrantedPermissions(appUID); |
380 permissionGranter.addSecurityData(session, appUID, null); |
370 assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Operator", new String[] |
381 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
382 assertWithTrace(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Operator", new String[] |
371 { |
383 { |
372 INTERNAL_SOCKET_PERMISSION, INTERNAL_HTTP_PERMISSION,"javax.microedition.PropertyPermission","javax.microedition.midlet.AutoStartPermission" |
384 INTERNAL_SOCKET_PERMISSION, INTERNAL_HTTP_PERMISSION,"javax.microedition.PropertyPermission","javax.microedition.midlet.AutoStartPermission" |
373 }), |
385 }), |
374 getDefaultPermissions())); |
386 getDefaultPermissions())); |
375 // 3. Legacy, signed : permissions NOT requested in JAD & permissions NOT requested in JAR -> grant only the "assigned" permissions |
387 // 3. Legacy, signed : permissions NOT requested in JAD & permissions NOT requested in JAR -> grant only the "assigned" permissions |
387 authCredentials[0] = new AuthenticationCredentials("IdentifiedThirdParty", "ITDP"); |
399 authCredentials[0] = new AuthenticationCredentials("IdentifiedThirdParty", "ITDP"); |
388 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
400 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
389 allAttributes.clear(); |
401 allAttributes.clear(); |
390 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
402 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
391 securityAttributes.addManifestAttributes(allAttributes); |
403 securityAttributes.addManifestAttributes(allAttributes); |
392 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
404 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
393 grantedPermissions = storage.readGrantedPermissions(appUID); |
405 permissionGranter.addSecurityData(session, appUID, null); |
394 assertTrue(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, getAssignedPermissions("IdentifiedThirdParty"), true)); |
406 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
407 assertWithTrace(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, getAssignedPermissions("IdentifiedThirdParty"), true)); |
395 // same for a domain which has one assigned permissions -> only the assigned + default permissions are granted |
408 // same for a domain which has one assigned permissions -> only the assigned + default permissions are granted |
396 storage.removeAuthenticationStorageData(appUID); |
409 storage.removeAuthenticationStorageData(appUID); |
397 permissionGranter.removeSecurityData(session, appUID); |
410 permissionGranter.removeSecurityData(session, appUID); |
398 authData = new AuthenticationStorageData("Operator", "OPD", null, null, null, null); |
411 authData = new AuthenticationStorageData("Operator", "OPD", null, null, null, null); |
399 storage.writeAuthenticationStorageData(appUID, authData); |
412 storage.writeAuthenticationStorageData(appUID, authData); |
407 authCredentials[0] = new AuthenticationCredentials("Operator", "OPD"); |
420 authCredentials[0] = new AuthenticationCredentials("Operator", "OPD"); |
408 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
421 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
409 allAttributes.clear(); |
422 allAttributes.clear(); |
410 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
423 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
411 securityAttributes.addManifestAttributes(allAttributes); |
424 securityAttributes.addManifestAttributes(allAttributes); |
412 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
425 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
413 grantedPermissions = storage.readGrantedPermissions(appUID); |
426 permissionGranter.addSecurityData(session, appUID, null); |
414 assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Operator", new String[] {"javax.microedition.PropertyPermission","javax.microedition.midlet.AutoStartPermission"}), |
427 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
428 assertWithTrace(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Operator", new String[] {"javax.microedition.PropertyPermission","javax.microedition.midlet.AutoStartPermission"}), |
415 getDefaultPermissions())); |
429 getDefaultPermissions())); |
416 // 4. Legacy, unsigned : permissions requested in JAD & permissions requested in JAR -> ignore requested permissions and |
430 // 4. Legacy, unsigned : permissions requested in JAD & permissions requested in JAR -> ignore requested permissions and |
417 // grant all the permissions available in the policy for untrusted MIDlets |
431 // grant all the permissions available in the policy for untrusted MIDlets |
418 storage.removeAuthenticationStorageData(appUID); |
432 storage.removeAuthenticationStorageData(appUID); |
419 permissionGranter.removeSecurityData(session, appUID); |
433 permissionGranter.removeSecurityData(session, appUID); |
432 allAttributes.clear(); |
446 allAttributes.clear(); |
433 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
447 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
434 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("","MyOwnOptionalPermission")); |
448 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("","MyOwnOptionalPermission")); |
435 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("","MyOwnMandatoryPermission")); |
449 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("","MyOwnMandatoryPermission")); |
436 securityAttributes.addManifestAttributes(allAttributes); |
450 securityAttributes.addManifestAttributes(allAttributes); |
437 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
451 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
438 grantedPermissions = storage.readGrantedPermissions(appUID); |
452 permissionGranter.addSecurityData(session, appUID, null); |
439 assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("UnidentifiedThirdParty"))); |
453 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
454 assertWithTrace(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("UnidentifiedThirdParty"))); |
440 // 5. Legacy, unsigned : permissions requested in JAD & permissions NOT requested in JAR -> ignore requested permissions and, |
455 // 5. Legacy, unsigned : permissions requested in JAD & permissions NOT requested in JAR -> ignore requested permissions and, |
441 // grant all the permissions available in the policy for untrusted MIDlets |
456 // grant all the permissions available in the policy for untrusted MIDlets |
442 storage.removeAuthenticationStorageData(appUID); |
457 storage.removeAuthenticationStorageData(appUID); |
443 permissionGranter.removeSecurityData(session, appUID); |
458 permissionGranter.removeSecurityData(session, appUID); |
444 authData = new AuthenticationStorageData("UnidentifiedThirdParty", "UTPD", null, null, null, null); |
459 authData = new AuthenticationStorageData("UnidentifiedThirdParty", "UTPD", null, null, null, null); |
453 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "ITDP"); |
468 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "ITDP"); |
454 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
469 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
455 allAttributes.clear(); |
470 allAttributes.clear(); |
456 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
471 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
457 securityAttributes.addManifestAttributes(allAttributes); |
472 securityAttributes.addManifestAttributes(allAttributes); |
458 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
473 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
459 grantedPermissions = storage.readGrantedPermissions(appUID); |
474 permissionGranter.addSecurityData(session, appUID, null); |
460 assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("UnidentifiedThirdParty"))); |
475 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
476 assertWithTrace(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("UnidentifiedThirdParty"))); |
461 // 6. Legacy, unsigned : permissions NOT requested in JAD & permissions requested in JAR -> ignore requested permissions and |
477 // 6. Legacy, unsigned : permissions NOT requested in JAD & permissions requested in JAR -> ignore requested permissions and |
462 // grant all the permissions available in the policy for untrusted MIDlets |
478 // grant all the permissions available in the policy for untrusted MIDlets |
463 storage.removeAuthenticationStorageData(appUID); |
479 storage.removeAuthenticationStorageData(appUID); |
464 permissionGranter.removeSecurityData(session, appUID); |
480 permissionGranter.removeSecurityData(session, appUID); |
465 authData = new AuthenticationStorageData("UnidentifiedThirdParty", "UTDP", null, null, null, null); |
481 authData = new AuthenticationStorageData("UnidentifiedThirdParty", "UTDP", null, null, null, null); |
474 allAttributes.clear(); |
490 allAttributes.clear(); |
475 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
491 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
476 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("","MyOwnOptionalPermission")); |
492 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("","MyOwnOptionalPermission")); |
477 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("","MyOwnMandatoryPermission")); |
493 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("","MyOwnMandatoryPermission")); |
478 securityAttributes.addManifestAttributes(allAttributes); |
494 securityAttributes.addManifestAttributes(allAttributes); |
479 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
495 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
480 grantedPermissions = storage.readGrantedPermissions(appUID); |
496 permissionGranter.addSecurityData(session, appUID, null); |
481 assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("UnidentifiedThirdParty"))); |
497 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
498 assertWithTrace(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("UnidentifiedThirdParty"))); |
482 // 7. Legacy, unsigned : permissions NOT requested in JAD & permissions NOT requested in JAR -> grant all the permissions available in the policy for untrusted MIDlets |
499 // 7. Legacy, unsigned : permissions NOT requested in JAD & permissions NOT requested in JAR -> grant all the permissions available in the policy for untrusted MIDlets |
483 storage.removeAuthenticationStorageData(appUID); |
500 storage.removeAuthenticationStorageData(appUID); |
484 permissionGranter.removeSecurityData(session, appUID); |
501 permissionGranter.removeSecurityData(session, appUID); |
485 authData = new AuthenticationStorageData("UnidentifiedThirdParty", "UTDP", null, null, null, null); |
502 authData = new AuthenticationStorageData("UnidentifiedThirdParty", "UTDP", null, null, null, null); |
486 storage.writeAuthenticationStorageData(appUID, authData); |
503 storage.writeAuthenticationStorageData(appUID, authData); |
492 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
509 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
493 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
510 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
494 allAttributes.clear(); |
511 allAttributes.clear(); |
495 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
512 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
496 securityAttributes.addManifestAttributes(allAttributes); |
513 securityAttributes.addManifestAttributes(allAttributes); |
497 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
514 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
498 grantedPermissions = storage.readGrantedPermissions(appUID); |
515 permissionGranter.addSecurityData(session, appUID, null); |
499 assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("UnidentifiedThirdParty"))); |
516 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
517 assertWithTrace(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("UnidentifiedThirdParty"))); |
500 // 8. MIDP3 unsigned, unknown mandatory permission in JAD file -> failure |
518 // 8. MIDP3 unsigned, unknown mandatory permission in JAD file -> failure |
501 permissionGranter.removeSecurityData(session, appUID); |
519 permissionGranter.removeSecurityData(session, appUID); |
502 try |
520 try |
503 { |
521 { |
504 allAttributes.clear(); |
522 allAttributes.clear(); |
507 securityAttributes = new SecurityAttributes(); |
525 securityAttributes = new SecurityAttributes(); |
508 securityAttributes.addDescriptorAttributes(allAttributes); |
526 securityAttributes.addDescriptorAttributes(allAttributes); |
509 authCredentials = new AuthenticationCredentials[1]; |
527 authCredentials = new AuthenticationCredentials[1]; |
510 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
528 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
511 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
529 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
512 assertTrue(UNKNOWN_PERMISSION_MSG, false); |
530 assertWithTrace(false); |
513 } |
531 } |
514 catch (InvalidAttributeException e) |
532 catch (InvalidAttributeException e) |
515 { |
533 { |
516 assertTrue(UNKNOWN_PERMISSION_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
534 assertWithTrace( |
517 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
535 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
518 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
536 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
519 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
537 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
520 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
538 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
521 } |
539 } |
526 allAttributes.clear(); |
544 allAttributes.clear(); |
527 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
545 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
528 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3")); |
546 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3")); |
529 securityAttributes = new SecurityAttributes(); |
547 securityAttributes = new SecurityAttributes(); |
530 securityAttributes.addManifestAttributes(allAttributes); |
548 securityAttributes.addManifestAttributes(allAttributes); |
531 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
549 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
532 assertTrue(UNKNOWN_PERMISSION_MSG, false); |
550 permissionGranter.addSecurityData(session, appUID, null); |
|
551 assertWithTrace(false); |
533 } |
552 } |
534 catch (InvalidAttributeException e) |
553 catch (InvalidAttributeException e) |
535 { |
554 { |
536 assertTrue(UNKNOWN_PERMISSION_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
555 assertWithTrace( |
537 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
556 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
538 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
557 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
539 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
558 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
540 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
559 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
541 } |
560 } |
553 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
572 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
554 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
573 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
555 allAttributes.clear(); |
574 allAttributes.clear(); |
556 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
575 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
557 securityAttributes.addManifestAttributes(allAttributes); |
576 securityAttributes.addManifestAttributes(allAttributes); |
558 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
577 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
559 grantedPermissions = storage.readGrantedPermissions(appUID); |
578 permissionGranter.addSecurityData(session, appUID, null); |
560 assertTrue(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, getAssignedPermissions("UnidentifiedThirdParty"), true)); |
579 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
580 assertWithTrace(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, getAssignedPermissions("UnidentifiedThirdParty"), true)); |
561 // 9.1. MIDP3 unsigned, P1, unknown optional P2 requested in JAD -> unknown permission is ignored, grant only P1 plus the assigned permissions |
581 // 9.1. MIDP3 unsigned, P1, unknown optional P2 requested in JAD -> unknown permission is ignored, grant only P1 plus the assigned permissions |
562 storage.removeAuthenticationStorageData(appUID); |
582 storage.removeAuthenticationStorageData(appUID); |
563 permissionGranter.removeSecurityData(session, appUID); |
583 permissionGranter.removeSecurityData(session, appUID); |
564 authData = new AuthenticationStorageData("UnidentifiedThirdParty", "UTDP", null, null, null, null); |
584 authData = new AuthenticationStorageData("UnidentifiedThirdParty", "UTDP", null, null, null, null); |
565 storage.writeAuthenticationStorageData(appUID, authData); |
585 storage.writeAuthenticationStorageData(appUID, authData); |
573 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
593 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
574 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
594 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
575 allAttributes.clear(); |
595 allAttributes.clear(); |
576 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
596 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
577 securityAttributes.addManifestAttributes(allAttributes); |
597 securityAttributes.addManifestAttributes(allAttributes); |
578 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
598 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
579 grantedPermissions = storage.readGrantedPermissions(appUID); |
599 permissionGranter.addSecurityData(session, appUID, null); |
580 assertTrue(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, |
600 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
601 assertWithTrace(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, |
581 new MIDPPermission[] {new MIDPPermission(INTERNAL_SOCKET_PERMISSION,"socket://")},getAssignedPermissions("UnidentifiedThirdParty"))); |
602 new MIDPPermission[] {new MIDPPermission(INTERNAL_SOCKET_PERMISSION,"socket://")},getAssignedPermissions("UnidentifiedThirdParty"))); |
582 // 10. MIDP3 unsigned MIDlet, unknown mandatory permission in JAR file -> failure |
603 // 10. MIDP3 unsigned MIDlet, unknown mandatory permission in JAR file -> failure |
583 permissionGranter.removeSecurityData(session, appUID); |
604 permissionGranter.removeSecurityData(session, appUID); |
584 try |
605 try |
585 { |
606 { |
586 allAttributes.clear(); |
607 allAttributes.clear(); |
587 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
608 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
588 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3")); |
609 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3")); |
589 securityAttributes = new SecurityAttributes(); |
610 securityAttributes = new SecurityAttributes(); |
590 securityAttributes.addManifestAttributes(allAttributes); |
611 securityAttributes.addManifestAttributes(allAttributes); |
591 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
612 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
592 assertTrue(UNKNOWN_PERMISSION_MSG, false); |
613 permissionGranter.addSecurityData(session, appUID, null); |
|
614 assertWithTrace(false); |
593 } |
615 } |
594 catch (InvalidAttributeException e) |
616 catch (InvalidAttributeException e) |
595 { |
617 { |
596 assertTrue(UNKNOWN_PERMISSION_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
618 assertWithTrace( |
597 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
619 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
598 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
620 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
599 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
621 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
600 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
622 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
601 } |
623 } |
609 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert1")); |
631 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert1")); |
610 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
632 allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-2", new Attribute("","cert2")); |
611 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","signature")); |
633 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","signature")); |
612 securityAttributes = new SecurityAttributes(); |
634 securityAttributes = new SecurityAttributes(); |
613 securityAttributes.addManifestAttributes(allAttributes); |
635 securityAttributes.addManifestAttributes(allAttributes); |
614 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
636 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
615 assertTrue(UNKNOWN_PERMISSION_MSG, false); |
637 permissionGranter.addSecurityData(session, appUID, null); |
|
638 assertWithTrace(false); |
616 } |
639 } |
617 catch (InvalidAttributeException e) |
640 catch (InvalidAttributeException e) |
618 { |
641 { |
619 assertTrue(UNKNOWN_PERMISSION_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
642 assertWithTrace( |
620 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
643 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
621 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
644 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
622 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
645 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
623 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
646 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
624 } |
647 } |
633 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","signature")); |
656 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","signature")); |
634 securityAttributes = new SecurityAttributes(); |
657 securityAttributes = new SecurityAttributes(); |
635 securityAttributes.addDescriptorAttributes(allAttributes); |
658 securityAttributes.addDescriptorAttributes(allAttributes); |
636 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3")); |
659 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3")); |
637 securityAttributes.addManifestAttributes(allAttributes); |
660 securityAttributes.addManifestAttributes(allAttributes); |
638 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
661 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
639 assertTrue(UNKNOWN_PERMISSION_MSG, false); |
662 permissionGranter.addSecurityData(session, appUID, null); |
|
663 assertWithTrace(false); |
640 } |
664 } |
641 catch (InvalidAttributeException e) |
665 catch (InvalidAttributeException e) |
642 { |
666 { |
643 assertTrue(UNKNOWN_PERMISSION_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
667 assertWithTrace( |
644 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
668 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
645 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
669 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
646 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
670 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
647 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
671 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
648 } |
672 } |
657 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","signature")); |
681 allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1", new Attribute("","signature")); |
658 securityAttributes = new SecurityAttributes(); |
682 securityAttributes = new SecurityAttributes(); |
659 securityAttributes.addDescriptorAttributes(allAttributes); |
683 securityAttributes.addDescriptorAttributes(allAttributes); |
660 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3")); |
684 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1",new Attribute("","MyMandatoryClass MyMandatoryTarget MyMandatoryAction1,MyMandatoryAction2,MyMandatoryAction3")); |
661 securityAttributes.addManifestAttributes(allAttributes); |
685 securityAttributes.addManifestAttributes(allAttributes); |
662 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
686 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
663 assertTrue(UNKNOWN_PERMISSION_MSG, false); |
687 permissionGranter.addSecurityData(session, appUID, null); |
|
688 assertWithTrace(false); |
664 } |
689 } |
665 catch (InvalidAttributeException e) |
690 catch (InvalidAttributeException e) |
666 { |
691 { |
667 assertTrue(UNKNOWN_PERMISSION_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
692 assertWithTrace( |
668 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
693 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
669 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
694 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
670 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
695 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
671 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
696 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "1"}))); |
672 } |
697 } |
689 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
714 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
690 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
715 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
691 allAttributes.clear(); |
716 allAttributes.clear(); |
692 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
717 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3)); |
693 securityAttributes.addManifestAttributes(allAttributes); |
718 securityAttributes.addManifestAttributes(allAttributes); |
694 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
719 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
695 grantedPermissions = storage.readGrantedPermissions(appUID); |
720 permissionGranter.addSecurityData(session, appUID, null); |
696 assertTrue(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, |
721 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
722 assertWithTrace(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, |
697 new MIDPPermission[] |
723 new MIDPPermission[] |
698 { |
724 { |
699 new MIDPPermission(INTERNAL_SOCKET_PERMISSION,"socket://50"), |
725 new MIDPPermission(INTERNAL_SOCKET_PERMISSION,"socket://50"), |
700 new MIDPPermission(INTERNAL_HTTP_PERMISSION,"http://www.google.com"), |
726 new MIDPPermission(INTERNAL_HTTP_PERMISSION,"http://www.google.com"), |
701 new MIDPPermission(INTERNAL_HTTPS_PERMISSION,"https://www.myurl.com/mypage"), |
727 new MIDPPermission(INTERNAL_HTTPS_PERMISSION,"https://www.myurl.com/mypage"), |
723 securityAttributes = new SecurityAttributes(); |
749 securityAttributes = new SecurityAttributes(); |
724 securityAttributes.addDescriptorAttributes(allAttributes); |
750 securityAttributes.addDescriptorAttributes(allAttributes); |
725 authCredentials = new AuthenticationCredentials[1]; |
751 authCredentials = new AuthenticationCredentials[1]; |
726 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
752 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
727 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
753 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
728 assertTrue(INVALID_PERMISSION_VALUE_MSG, false); |
754 assertWithTrace(false); |
729 } |
755 } |
730 catch (InvalidAttributeException e) |
756 catch (InvalidAttributeException e) |
731 { |
757 { |
732 assertTrue(INVALID_PERMISSION_VALUE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(), |
758 assertWithTrace( |
733 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
759 e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE |
734 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
760 && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_CORRUPT_PKG, null)) |
735 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
761 && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_UNSUPPORTED, |
736 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "7"}))); |
762 new String[] {PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "7"}))); |
737 } |
763 } |
763 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "3",new Attribute("",MIDP3_HTTPS_PERMISSION + " https://www.myurl.com/mypage")); |
789 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "3",new Attribute("",MIDP3_HTTPS_PERMISSION + " https://www.myurl.com/mypage")); |
764 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "4",new Attribute("",MIDP3_SSL_PERMISSION + " ssl://*.sun.com")); |
790 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "4",new Attribute("",MIDP3_SSL_PERMISSION + " ssl://*.sun.com")); |
765 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "5",new Attribute("",MIDP3_DATAGRAM_PERMISSION + " datagram://12345")); |
791 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "5",new Attribute("",MIDP3_DATAGRAM_PERMISSION + " datagram://12345")); |
766 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "6",new Attribute("",MIDP3_COMM_PERMISSION + " comm:123")); |
792 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "6",new Attribute("",MIDP3_COMM_PERMISSION + " comm:123")); |
767 securityAttributes.addManifestAttributes(allAttributes); |
793 securityAttributes.addManifestAttributes(allAttributes); |
768 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
794 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
769 grantedPermissions = storage.readGrantedPermissions(appUID); |
795 permissionGranter.addSecurityData(session, appUID, null); |
770 assertTrue(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, |
796 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
797 assertWithTrace(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, |
771 new MIDPPermission[] |
798 new MIDPPermission[] |
772 { |
799 { |
773 new MIDPPermission(INTERNAL_SOCKET_PERMISSION,"socket://50"), |
800 new MIDPPermission(INTERNAL_SOCKET_PERMISSION,"socket://50"), |
774 new MIDPPermission(INTERNAL_HTTP_PERMISSION,"http://www.google.com"), |
801 new MIDPPermission(INTERNAL_HTTP_PERMISSION,"http://www.google.com"), |
775 new MIDPPermission(INTERNAL_HTTPS_PERMISSION,"https://www.myurl.com/mypage"), |
802 new MIDPPermission(INTERNAL_HTTPS_PERMISSION,"https://www.myurl.com/mypage"), |
808 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "3",new Attribute("",MIDP3_HTTPS_PERMISSION + " https://www.myurl.com/mypage")); |
835 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "3",new Attribute("",MIDP3_HTTPS_PERMISSION + " https://www.myurl.com/mypage")); |
809 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "4",new Attribute("",MIDP3_SSL_PERMISSION + " ssl://*.sun.com")); |
836 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "4",new Attribute("",MIDP3_SSL_PERMISSION + " ssl://*.sun.com")); |
810 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "5",new Attribute("",MIDP3_DATAGRAM_PERMISSION + " datagram://12345")); |
837 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "5",new Attribute("",MIDP3_DATAGRAM_PERMISSION + " datagram://12345")); |
811 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "6",new Attribute("",MIDP3_COMM_PERMISSION + " comm:123")); |
838 allAttributes.put(PermissionAttribute.MANDATORY_ATTRIBUTE_PREFIX + "6",new Attribute("",MIDP3_COMM_PERMISSION + " comm:123")); |
812 securityAttributes.addManifestAttributes(allAttributes); |
839 securityAttributes.addManifestAttributes(allAttributes); |
813 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
840 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
814 grantedPermissions = storage.readGrantedPermissions(appUID); |
841 permissionGranter.addSecurityData(session, appUID, null); |
815 assertTrue(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, |
842 grantedPermissions = storage.readGrantedPermissions(appUID); |
|
843 assertWithTrace(grantedPermissions != null && checkGrantedPermissions(grantedPermissions, |
816 new MIDPPermission[] |
844 new MIDPPermission[] |
817 { |
845 { |
818 new MIDPPermission(INTERNAL_SOCKET_PERMISSION,"socket://50"), |
846 new MIDPPermission(INTERNAL_SOCKET_PERMISSION,"socket://50"), |
819 new MIDPPermission(INTERNAL_HTTP_PERMISSION,"http://www.google.com"), |
847 new MIDPPermission(INTERNAL_HTTP_PERMISSION,"http://www.google.com"), |
820 new MIDPPermission(INTERNAL_HTTPS_PERMISSION,"https://www.myurl.com/mypage"), |
848 new MIDPPermission(INTERNAL_HTTPS_PERMISSION,"https://www.myurl.com/mypage"), |
825 getAssignedPermissions("IdentifiedThirdParty"))); |
853 getAssignedPermissions("IdentifiedThirdParty"))); |
826 // 19. getBlanketPermissions - null appUID |
854 // 19. getBlanketPermissions - null appUID |
827 storage.removeAuthenticationStorageData(appUID); |
855 storage.removeAuthenticationStorageData(appUID); |
828 permissionGranter.removeSecurityData(session, appUID); |
856 permissionGranter.removeSecurityData(session, appUID); |
829 blanketPermissions = permissionGranter.getBlanketPermissions(null); |
857 blanketPermissions = permissionGranter.getBlanketPermissions(null); |
830 assertTrue(blanketPermissions == null); |
858 assertWithTrace(blanketPermissions == null); |
831 // 20. getBlanketPermissions - unknown appUID |
859 // 20. getBlanketPermissions - unknown appUID |
832 storage.removeAuthenticationStorageData(appUID); |
860 storage.removeAuthenticationStorageData(appUID); |
833 permissionGranter.removeSecurityData(session, appUID); |
861 permissionGranter.removeSecurityData(session, appUID); |
834 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
862 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
835 assertTrue(blanketPermissions == null); |
863 assertWithTrace(blanketPermissions == null); |
836 // 21. getBlanketPermissions - unsigned suite |
864 // 21. getBlanketPermissions - unsigned suite |
837 storage.removeAuthenticationStorageData(appUID); |
865 storage.removeAuthenticationStorageData(appUID); |
838 permissionGranter.removeSecurityData(session, appUID); |
866 permissionGranter.removeSecurityData(session, appUID); |
839 authData = new AuthenticationStorageData("UnidentifiedThirdParty", "UTDP", null, null, null, null); |
867 authData = new AuthenticationStorageData("UnidentifiedThirdParty", "UTDP", null, null, null, null); |
840 storage.writeAuthenticationStorageData(appUID, authData); |
868 storage.writeAuthenticationStorageData(appUID, authData); |
846 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
874 authCredentials[0] = new AuthenticationCredentials("UnidentifiedThirdParty", "UIDP"); |
847 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
875 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
848 allAttributes.clear(); |
876 allAttributes.clear(); |
849 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
877 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
850 securityAttributes.addManifestAttributes(allAttributes); |
878 securityAttributes.addManifestAttributes(allAttributes); |
851 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
879 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
852 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
880 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
853 assertTrue(blanketPermissions == null); |
881 permissionGranter.addSecurityData(session, appUID, null); |
|
882 assertWithTrace(blanketPermissions == null); |
854 // 22. getBlanketPermissions - one of the requested permissions does not allow Blanket |
883 // 22. getBlanketPermissions - one of the requested permissions does not allow Blanket |
855 permissionGranter.removeSecurityData(session, appUID); |
884 permissionGranter.removeSecurityData(session, appUID); |
856 storage.removeAuthenticationStorageData(appUID); |
885 storage.removeAuthenticationStorageData(appUID); |
857 permissionGranter.removeSecurityData(session, appUID); |
886 permissionGranter.removeSecurityData(session, appUID); |
858 authData = new AuthenticationStorageData("IdentifiedThirdParty", "ITDP", null, null, null, null); |
887 authData = new AuthenticationStorageData("IdentifiedThirdParty", "ITDP", null, null, null, null); |
870 allAttributes.clear(); |
899 allAttributes.clear(); |
871 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
900 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
872 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_DATAGRAM_PERMISSION + COMMA + " " + MIDP2_SMS_SEND_PERMISSION)); |
901 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_DATAGRAM_PERMISSION + COMMA + " " + MIDP2_SMS_SEND_PERMISSION)); |
873 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_SOCKET_PERMISSION + COMMA + MIDP2_HTTP_PERMISSION)); |
902 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_SOCKET_PERMISSION + COMMA + MIDP2_HTTP_PERMISSION)); |
874 securityAttributes.addManifestAttributes(allAttributes); |
903 securityAttributes.addManifestAttributes(allAttributes); |
875 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
904 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
876 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
905 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
877 assertTrue(blanketPermissions == null); |
906 permissionGranter.addSecurityData(session, appUID, null); |
|
907 assertWithTrace(blanketPermissions == null); |
878 // 23. getBlanketPermissions - request one permissions which is already in Blanket |
908 // 23. getBlanketPermissions - request one permissions which is already in Blanket |
879 permissionGranter.removeSecurityData(session, appUID); |
909 permissionGranter.removeSecurityData(session, appUID); |
880 storage.removeAuthenticationStorageData(appUID); |
910 storage.removeAuthenticationStorageData(appUID); |
881 permissionGranter.removeSecurityData(session, appUID); |
911 permissionGranter.removeSecurityData(session, appUID); |
882 authData = new AuthenticationStorageData("IdentifiedThirdParty", "ITDP", null, null, null, null); |
912 authData = new AuthenticationStorageData("IdentifiedThirdParty", "ITDP", null, null, null, null); |
893 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
923 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
894 allAttributes.clear(); |
924 allAttributes.clear(); |
895 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
925 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
896 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_HTTP_PERMISSION)); |
926 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_HTTP_PERMISSION)); |
897 securityAttributes.addManifestAttributes(allAttributes); |
927 securityAttributes.addManifestAttributes(allAttributes); |
898 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
928 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
899 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
929 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
900 assertTrue(blanketPermissions == null); |
930 permissionGranter.addSecurityData(session, appUID, null); |
|
931 assertWithTrace(blanketPermissions == null); |
901 // 24. getBlanketPermissions - request Auto Invocation and Net Access -> mutually exclusive permissions |
932 // 24. getBlanketPermissions - request Auto Invocation and Net Access -> mutually exclusive permissions |
902 permissionGranter.removeSecurityData(session, appUID); |
933 permissionGranter.removeSecurityData(session, appUID); |
903 storage.removeAuthenticationStorageData(appUID); |
934 storage.removeAuthenticationStorageData(appUID); |
904 permissionGranter.removeSecurityData(session, appUID); |
935 permissionGranter.removeSecurityData(session, appUID); |
905 authData = new AuthenticationStorageData("IdentifiedThirdParty", "ITDP", null, null, null, null); |
936 authData = new AuthenticationStorageData("IdentifiedThirdParty", "ITDP", null, null, null, null); |
916 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
947 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
917 allAttributes.clear(); |
948 allAttributes.clear(); |
918 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
949 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
919 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_PUSH_REGISTRY_PERMISSION + COMMA + MIDP2_HTTP_PERMISSION)); |
950 allAttributes.put(PermissionAttribute.OPTIONAL_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_PUSH_REGISTRY_PERMISSION + COMMA + MIDP2_HTTP_PERMISSION)); |
920 securityAttributes.addManifestAttributes(allAttributes); |
951 securityAttributes.addManifestAttributes(allAttributes); |
921 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
952 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
922 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
953 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
923 assertTrue(blanketPermissions == null); |
954 permissionGranter.addSecurityData(session, appUID, null); |
|
955 assertWithTrace(blanketPermissions == null); |
924 // 25. getBlanketPermissions - manufacturer signed MIDlet |
956 // 25. getBlanketPermissions - manufacturer signed MIDlet |
925 permissionGranter.removeSecurityData(session, appUID); |
957 permissionGranter.removeSecurityData(session, appUID); |
926 storage.removeAuthenticationStorageData(appUID); |
958 storage.removeAuthenticationStorageData(appUID); |
927 permissionGranter.removeSecurityData(session, appUID); |
959 permissionGranter.removeSecurityData(session, appUID); |
928 authData = new AuthenticationStorageData("Manufacturer", "MFD", null, null, null, null); |
960 authData = new AuthenticationStorageData("Manufacturer", "MFD", null, null, null, null); |
939 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
971 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
940 allAttributes.clear(); |
972 allAttributes.clear(); |
941 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
973 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
942 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_HTTP_PERMISSION + COMMA + MIDP2_SMS_SEND_PERMISSION + COMMA + MIDP2_MMS_OPEN_PERMISSION + COMMA + MIDP2_COMM_PERMISSION)); |
974 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_HTTP_PERMISSION + COMMA + MIDP2_SMS_SEND_PERMISSION + COMMA + MIDP2_MMS_OPEN_PERMISSION + COMMA + MIDP2_COMM_PERMISSION)); |
943 securityAttributes.addManifestAttributes(allAttributes); |
975 securityAttributes.addManifestAttributes(allAttributes); |
944 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
976 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
945 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
977 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
946 assertTrue(blanketPermissions == null); |
978 permissionGranter.addSecurityData(session, appUID, null); |
|
979 assertWithTrace(blanketPermissions == null); |
947 // 26. getBlanketPermissions - request Messaging, Net Access and Local connectivity. Since Messaging and Net Access have the current interaction mode set to Blanket, only Local connectivity is returned |
980 // 26. getBlanketPermissions - request Messaging, Net Access and Local connectivity. Since Messaging and Net Access have the current interaction mode set to Blanket, only Local connectivity is returned |
948 permissionGranter.removeSecurityData(session, appUID); |
981 permissionGranter.removeSecurityData(session, appUID); |
949 storage.removeAuthenticationStorageData(appUID); |
982 storage.removeAuthenticationStorageData(appUID); |
950 permissionGranter.removeSecurityData(session, appUID); |
983 permissionGranter.removeSecurityData(session, appUID); |
951 authData = new AuthenticationStorageData("IdentifiedThirdParty", "ITDP", null, null, null, null); |
984 authData = new AuthenticationStorageData("IdentifiedThirdParty", "ITDP", null, null, null, null); |
962 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
995 permissionGranter.grantJadPermissions(appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
963 allAttributes.clear(); |
996 allAttributes.clear(); |
964 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
997 allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2)); |
965 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_HTTP_PERMISSION + COMMA + MIDP2_SMS_SEND_PERMISSION + COMMA + MIDP2_MMS_OPEN_PERMISSION + COMMA + MIDP2_COMM_PERMISSION)); |
998 allAttributes.put(PermissionAttribute.MANDATORY_LEGACY_ATTRIBUTE_NAME, new Attribute("",MIDP2_HTTP_PERMISSION + COMMA + MIDP2_SMS_SEND_PERMISSION + COMMA + MIDP2_MMS_OPEN_PERMISSION + COMMA + MIDP2_COMM_PERMISSION)); |
966 securityAttributes.addManifestAttributes(allAttributes); |
999 securityAttributes.addManifestAttributes(allAttributes); |
967 permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes()); |
1000 permissionGranter.grantJarPermissions( appUID, null, securityAttributes.getPermissionAttributes(), authCredentials); |
968 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
1001 blanketPermissions = permissionGranter.getBlanketPermissions(appUID); |
969 assertTrue(blanketPermissions != null && blanketPermissions.length == 1 && blanketPermissions[0].equals(UserSecuritySettingsImpl.getLocalizedName(UserSecuritySettings.LOCAL_CONNECTIVITY_SETTINGS))); |
1002 permissionGranter.addSecurityData(session, appUID, null); |
|
1003 assertWithTrace(blanketPermissions != null && blanketPermissions.length == 1 && blanketPermissions[0].equals(UserSecuritySettingsImpl.getLocalizedName(UserSecuritySettings.LOCAL_CONNECTIVITY_SETTINGS))); |
970 permissionGranter.setPermissionsToBlanket(session, appUID); |
1004 permissionGranter.setPermissionsToBlanket(session, appUID); |
971 grantedPermissions = storage.readGrantedPermissions(appUID); |
1005 grantedPermissions = storage.readGrantedPermissions(appUID); |
972 for (int i=0; i<grantedPermissions.size(); i++) |
1006 for (int i=0; i<grantedPermissions.size(); i++) |
973 { |
1007 { |
974 PolicyBasedPermission permission = |
1008 PolicyBasedPermission permission = |
975 ((PolicyBasedPermission)grantedPermissions.elementAt(i)); |
1009 ((PolicyBasedPermission)grantedPermissions.elementAt(i)); |
976 UserSecuritySettings settings = |
1010 UserSecuritySettings settings = |
977 permission.getUserSecuritySettings(); |
1011 permission.getUserSecuritySettings(); |
978 if (settings != null && settings.getName() == UserSecuritySettings.LOCAL_CONNECTIVITY_SETTINGS) |
1012 if (settings != null && settings.getName() == UserSecuritySettings.LOCAL_CONNECTIVITY_SETTINGS) |
979 { |
1013 { |
980 assertTrue(settings.getCurrentInteractionMode() == UserSecuritySettings.BLANKET_INTERACTION_MODE); |
1014 assertWithTrace(settings.getCurrentInteractionMode() == UserSecuritySettings.BLANKET_INTERACTION_MODE); |
981 } |
1015 } |
982 } |
1016 } |
983 // grantAllPermissions - null values |
1017 // grantAllPermissions - null values |
984 permissionGranter.removeSecurityData(session, appUID); |
1018 permissionGranter.removeSecurityData(session, appUID); |
985 storage.removeAuthenticationStorageData(appUID); |
1019 storage.removeAuthenticationStorageData(appUID); |
986 permissionGranter.grantJarPermissions(session, null, null, (ProtectionDomain)null); |
1020 permissionGranter.grantJarPermissions(null, null, (ProtectionDomain)null); |
987 permissionGranter.removeSecurityData(session, appUID); |
1021 permissionGranter.addSecurityData(session, null, null); |
988 storage.removeAuthenticationStorageData(appUID); |
1022 permissionGranter.removeSecurityData(session, appUID); |
989 permissionGranter.grantJarPermissions(session, appUID, null, (ProtectionDomain)null); |
1023 storage.removeAuthenticationStorageData(appUID); |
990 grantedPermissions = storage.readGrantedPermissions(appUID); |
1024 permissionGranter.grantJarPermissions(appUID, null, (ProtectionDomain)null); |
991 permissionGranter.removeSecurityData(session, appUID); |
1025 permissionGranter.addSecurityData(session, appUID, null); |
992 storage.removeAuthenticationStorageData(appUID); |
1026 grantedPermissions = storage.readGrantedPermissions(appUID); |
993 assertTrue(grantedPermissions == null); |
1027 permissionGranter.removeSecurityData(session, appUID); |
|
1028 storage.removeAuthenticationStorageData(appUID); |
|
1029 assertWithTrace(grantedPermissions == null); |
994 // grantAllPermissions - operator domain |
1030 // grantAllPermissions - operator domain |
995 grantAllPermissions(ProtectionDomain.getOperatorDomain()); |
1031 grantAllPermissions(ProtectionDomain.getOperatorDomain()); |
996 // grantAllPermissions - manufacturer domain |
1032 // grantAllPermissions - manufacturer domain |
997 grantAllPermissions(ProtectionDomain.getManufacturerDomain()); |
1033 grantAllPermissions(ProtectionDomain.getManufacturerDomain()); |
998 // grantAllPermissions - identified third party domain |
1034 // grantAllPermissions - identified third party domain |
1006 |
1042 |
1007 private void grantAllPermissions(ProtectionDomain domain) |
1043 private void grantAllPermissions(ProtectionDomain domain) |
1008 { |
1044 { |
1009 permissionGranter.removeSecurityData(session, appUID); |
1045 permissionGranter.removeSecurityData(session, appUID); |
1010 storage.removeAuthenticationStorageData(appUID); |
1046 storage.removeAuthenticationStorageData(appUID); |
1011 permissionGranter.grantJarPermissions(session, appUID, null, domain); |
1047 permissionGranter.grantJarPermissions(appUID, null, domain); |
1012 grantedPermissions = storage.readGrantedPermissions(appUID); |
1048 permissionGranter.addSecurityData(session, appUID, null); |
1013 permissionGranter.removeSecurityData(session, appUID); |
1049 grantedPermissions = storage.readGrantedPermissions(appUID); |
1014 storage.removeAuthenticationStorageData(appUID); |
1050 permissionGranter.removeSecurityData(session, appUID); |
1015 assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions(domain.getName()))); |
1051 storage.removeAuthenticationStorageData(appUID); |
|
1052 assertWithTrace(checkGrantedPermissions(grantedPermissions, getPolicyPermissions(domain.getName()))); |
1016 } |
1053 } |
1017 |
1054 |
1018 private static MIDPPermission[] getPolicyPermissions(String policyName, String[] permissionNameFilter, String permissionTypeFilter) |
1055 private static MIDPPermission[] getPolicyPermissions(String policyName, String[] permissionNameFilter, String permissionTypeFilter) |
1019 { |
1056 { |
1020 Vector vPermissions = new Vector(); |
1057 Vector vPermissions = new Vector(); |