javacommons/security/tsrc/javasrc/com/nokia/mj/impl/security/midp/authorization/PermissionGranterTests.java
branchRCL_3
changeset 25 9ac0a0a7da70
parent 24 0fd27995241b
child 46 4376525cdefb
child 64 0ea12c182930
equal deleted inserted replaced
24:0fd27995241b 25:9ac0a0a7da70
   260         securityAttributes.addManifestAttributes(allAttributes);
   260         securityAttributes.addManifestAttributes(allAttributes);
   261         permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes());
   261         permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes());
   262         grantedPermissions = storage.readGrantedPermissions(appUID);
   262         grantedPermissions = storage.readGrantedPermissions(appUID);
   263         assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Manufacturer", new String[]
   263         assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Manufacturer", new String[]
   264                                            {
   264                                            {
   265                                                INTERNAL_DATAGRAM_PERMISSION, INTERNAL_COMM_PERMISSION, INTERNAL_SOCKET_PERMISSION,INTERNAL_HTTP_PERMISSION,"javax.microedition.PropertyPermission"
   265                                                INTERNAL_DATAGRAM_PERMISSION, INTERNAL_COMM_PERMISSION, INTERNAL_SOCKET_PERMISSION,INTERNAL_HTTP_PERMISSION,"javax.microedition.PropertyPermission","javax.microedition.midlet.AutoStartPermission"
   266                                            }),
   266                                            }),
   267                                            getDefaultPermissions()));
   267                                            getDefaultPermissions()));
   268         // 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
   268         // 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         permissionGranter.removeSecurityData(session, appUID);
   269         permissionGranter.removeSecurityData(session, appUID);
   270         storage.removeAuthenticationStorageData(appUID);
   270         storage.removeAuthenticationStorageData(appUID);
   366         securityAttributes.addManifestAttributes(allAttributes);
   366         securityAttributes.addManifestAttributes(allAttributes);
   367         permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes());
   367         permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes());
   368         grantedPermissions = storage.readGrantedPermissions(appUID);
   368         grantedPermissions = storage.readGrantedPermissions(appUID);
   369         assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Operator", new String[]
   369         assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Operator", new String[]
   370                                            {
   370                                            {
   371                                                INTERNAL_SOCKET_PERMISSION, INTERNAL_HTTP_PERMISSION,"javax.microedition.PropertyPermission"
   371                                                INTERNAL_SOCKET_PERMISSION, INTERNAL_HTTP_PERMISSION,"javax.microedition.PropertyPermission","javax.microedition.midlet.AutoStartPermission"
   372                                            }),
   372                                            }),
   373                                            getDefaultPermissions()));
   373                                            getDefaultPermissions()));
   374         // 3. Legacy, signed : permissions NOT requested in JAD & permissions NOT requested in JAR -> grant only the "assigned" permissions
   374         // 3. Legacy, signed : permissions NOT requested in JAD & permissions NOT requested in JAR -> grant only the "assigned" permissions
   375         storage.removeAuthenticationStorageData(appUID);
   375         storage.removeAuthenticationStorageData(appUID);
   376         permissionGranter.removeSecurityData(session, appUID);
   376         permissionGranter.removeSecurityData(session, appUID);
   408         allAttributes.clear();
   408         allAttributes.clear();
   409         allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
   409         allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
   410         securityAttributes.addManifestAttributes(allAttributes);
   410         securityAttributes.addManifestAttributes(allAttributes);
   411         permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes());
   411         permissionGranter.grantJarPermissions(session, appUID, null, securityAttributes.getPermissionAttributes());
   412         grantedPermissions = storage.readGrantedPermissions(appUID);
   412         grantedPermissions = storage.readGrantedPermissions(appUID);
   413         assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Operator", new String[] {"javax.microedition.PropertyPermission"}),
   413         assertTrue(checkGrantedPermissions(grantedPermissions, getPolicyPermissions("Operator", new String[] {"javax.microedition.PropertyPermission","javax.microedition.midlet.AutoStartPermission"}),
   414                                            getDefaultPermissions()));
   414                                            getDefaultPermissions()));
   415         // 4. Legacy, unsigned : permissions requested in JAD & permissions requested in JAR -> ignore requested permissions and
   415         // 4. Legacy, unsigned : permissions requested in JAD & permissions requested in JAR -> ignore requested permissions and
   416         //    grant all the permissions available in the policy for untrusted MIDlets
   416         //    grant all the permissions available in the policy for untrusted MIDlets
   417         storage.removeAuthenticationStorageData(appUID);
   417         storage.removeAuthenticationStorageData(appUID);
   418         permissionGranter.removeSecurityData(session, appUID);
   418         permissionGranter.removeSecurityData(session, appUID);
   773                        new MIDPPermission(INTERNAL_HTTP_PERMISSION,"http://www.google.com"),
   773                        new MIDPPermission(INTERNAL_HTTP_PERMISSION,"http://www.google.com"),
   774                        new MIDPPermission(INTERNAL_HTTPS_PERMISSION,"https://www.myurl.com/mypage"),
   774                        new MIDPPermission(INTERNAL_HTTPS_PERMISSION,"https://www.myurl.com/mypage"),
   775                        new MIDPPermission(INTERNAL_SSL_PERMISSION,"ssl://*.sun.com"),
   775                        new MIDPPermission(INTERNAL_SSL_PERMISSION,"ssl://*.sun.com"),
   776                        new MIDPPermission(INTERNAL_DATAGRAM_PERMISSION,"datagram://12345"),
   776                        new MIDPPermission(INTERNAL_DATAGRAM_PERMISSION,"datagram://12345"),
   777                        new MIDPPermission(INTERNAL_COMM_PERMISSION, "comm:123"),
   777                        new MIDPPermission(INTERNAL_COMM_PERMISSION, "comm:123"),
   778                        new MIDPPermission("javax.microedition.PropertyPermission", "mobinfo.msisdn", "read")
   778                        new MIDPPermission("javax.microedition.PropertyPermission", "mobinfo.msisdn", "read"),
       
   779                        new MIDPPermission("javax.microedition.midlet.AutoStartPermission", null)
   779                    },
   780                    },
   780                    getDefaultPermissions()));
   781                    getDefaultPermissions()));
   781         // 18. identified third party (some assigned permissions exist)
   782         // 18. identified third party (some assigned permissions exist)
   782         storage.removeAuthenticationStorageData(appUID);
   783         storage.removeAuthenticationStorageData(appUID);
   783         permissionGranter.removeSecurityData(session, appUID);
   784         permissionGranter.removeSecurityData(session, appUID);