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