javacommons/security/tsrc/javasrc/com/nokia/mj/impl/security/midp/authentication/AuthenticationModuleTests.java
branchRCL_3
changeset 83 26b2b12093af
parent 71 d5e927d5853b
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
   177         authenticationModule.removeSecurityData(session, appUID);
   177         authenticationModule.removeSecurityData(session, appUID);
   178         // 2. unsigned, install from JAR which does not exist
   178         // 2. unsigned, install from JAR which does not exist
   179         authenticationModule.removeSecurityData(session, appUID);
   179         authenticationModule.removeSecurityData(session, appUID);
   180         try
   180         try
   181         {
   181         {
   182             authenticationModule.authenticateJar(appUID,null,"somethingWhichDoesNotExist", false);
   182             authenticationModule.authenticateJar(session, appUID,null,"somethingWhichDoesNotExist", false);
   183             authenticationModule.addSecurityData(session, appUID, null);
       
   184             assertTrue(false);
   183             assertTrue(false);
   185         }
   184         }
   186         catch (InstallerSecurityException e)
   185         catch (InstallerSecurityException e)
   187         {
   186         {
   188             assertTrue("",
   187             assertTrue("",
   192                                                         new String[] {"Could not compute hash for somethingWhichDoesNotExist"})));
   191                                                         new String[] {"Could not compute hash for somethingWhichDoesNotExist"})));
   193         }
   192         }
   194         authenticationModule.removeSecurityData(session, appUID);
   193         authenticationModule.removeSecurityData(session, appUID);
   195         // 3. unsigned, install from JAR
   194         // 3. unsigned, install from JAR
   196         authenticationModule.removeSecurityData(session, appUID);
   195         authenticationModule.removeSecurityData(session, appUID);
   197         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp"  + System.getProperty("file.separator") + "app.jar", false);
   196         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp"  + System.getProperty("file.separator") + "app.jar", false);
   198         authenticationModule.addSecurityData(session, appUID, null);
       
   199         assertTrue(authenticationModule.getProtectionDomainCategory(session, appUID).equals(ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN)
   197         assertTrue(authenticationModule.getProtectionDomainCategory(session, appUID).equals(ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN)
   200                    && authenticationModule.getCertificatesDetails(session, appUID) == null);
   198                    && authenticationModule.getCertificatesDetails(session, appUID) == null);
   201         authenticationModule.removeSecurityData(session, appUID);
   199         authenticationModule.removeSecurityData(session, appUID);
   202         // 3.1. unsigned, install from JAR, no session provided to addSecurityData -> no authentication data stored to storage
   200         // 3.1. unsigned, install from JAR, no session provided to authenticateJar -> no authentication data stored to storage
   203         authenticationModule.removeSecurityData(session, appUID);
   201         authenticationModule.removeSecurityData(session, appUID);
   204         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp"  + System.getProperty("file.separator") + "app.jar", false);
   202         authenticationModule.authenticateJar(null, appUID,null,TEST_DATA_DIR + "security_tmp"  + System.getProperty("file.separator") + "app.jar", false);
   205         authenticationModule.addSecurityData(null, appUID, null);
       
   206         StorageEntry query = new StorageEntry();
   203         StorageEntry query = new StorageEntry();
   207         query.addAttribute(new StorageAttribute(
   204         query.addAttribute(new StorageAttribute(
   208                                StorageAttribute.ID,
   205                                StorageAttribute.ID,
   209                                appUID.getStringValue()));
   206                                appUID.getStringValue()));
   210         query.addAttribute(new StorageAttribute(
   207         query.addAttribute(new StorageAttribute(
   232         securityAttributes = new SecurityAttributes();
   229         securityAttributes = new SecurityAttributes();
   233         securityAttributes.addDescriptorAttributes(allAttributes);
   230         securityAttributes.addDescriptorAttributes(allAttributes);
   234         credentials = authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   231         credentials = authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   235         assertTrue(credentials != null && credentials.length == 1 && credentials[0].getProtectionDomainName().equals("UnidentifiedThirdParty")
   232         assertTrue(credentials != null && credentials.length == 1 && credentials[0].getProtectionDomainName().equals("UnidentifiedThirdParty")
   236                    && authenticationModule.getCertificatesDetails(session, appUID) == null);
   233                    && authenticationModule.getCertificatesDetails(session, appUID) == null);
   237         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp"  +  System.getProperty("file.separator") + "app.jar", false);
   234         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp"  +  System.getProperty("file.separator") + "app.jar", false);
   238         authenticationModule.addSecurityData(session, appUID, null);
       
   239         assertTrue(authenticationModule.getProtectionDomainCategory(session, appUID).equals(ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN));
   235         assertTrue(authenticationModule.getProtectionDomainCategory(session, appUID).equals(ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN));
   240         authenticationModule.removeSecurityData(session, appUID);
   236         authenticationModule.removeSecurityData(session, appUID);
   241         // 5. upgrade of authentication storage data
   237         // 5. upgrade of authentication storage data
   242         authenticationModule.removeSecurityData(session, appUID);
   238         authenticationModule.removeSecurityData(session, appUID);
   243         storage.writeAuthenticationStorageData(appUID, new AuthenticationStorageData("UnidentifiedThirdParty", ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN, "jarHash", "rootHash", new Vector()));
   239         storage.writeAuthenticationStorageData(appUID, new AuthenticationStorageData("UnidentifiedThirdParty", ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN, "jarHash", "rootHash", new Vector()));
   244         authenticationModule.authenticateJar(appUID,appUID,TEST_DATA_DIR + "security_tmp" + System.getProperty("file.separator") + "app.jar", false);
   240         authenticationModule.authenticateJar(session, appUID,appUID,TEST_DATA_DIR + "security_tmp" + System.getProperty("file.separator") + "app.jar", false);
   245         authenticationModule.addSecurityData(session, appUID, appUID);
       
   246         assertTrue(authenticationModule.getProtectionDomainCategory(session, appUID).equals(ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN)
   241         assertTrue(authenticationModule.getProtectionDomainCategory(session, appUID).equals(ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN)
   247                    && authenticationModule.getCertificatesDetails(session, appUID) == null);
   242                    && authenticationModule.getCertificatesDetails(session, appUID) == null);
   248         authenticationModule.removeSecurityData(session, appUID);
   243         authenticationModule.removeSecurityData(session, appUID);
   249         // 6. cert validation ok (2 certs succesfully validated)
   244         // 6. cert validation ok (2 certs succesfully validated)
   250         authenticationModule.removeSecurityData(session, appUID);
   245         authenticationModule.removeSecurityData(session, appUID);
   275                           "kwxpKeSSWSeSW5ieWCx9ARFD6Lrwabxk5t7Aas5FFVEtr89vslY1QIexKNiytQm51PTIRnCNhl6y+tcv7V7GRskV1VMlTHwbCVjK4rqoFFrcZrO3qHvkRh6K9wnHnw5PPtBsrMbg8lWKBrGaf4TYRYFW+CukmR+06R7u5zAZaL7CMhl69bCXd78Tz1Z4N5CxVFD8vGatp66TMBk+0YhZP7Lo1yIDu2XsojVtigAoV9sm8OF5/aXmgfFb2AUmANGxlaDAieUfOAm7RXvsOZgaPN72KEqya8XQW6r1/aGF6jMmJ62qgPqJV3TtJtbFSwH1suywAk1UDltVim4b/Ucw1A=="));
   270                           "kwxpKeSSWSeSW5ieWCx9ARFD6Lrwabxk5t7Aas5FFVEtr89vslY1QIexKNiytQm51PTIRnCNhl6y+tcv7V7GRskV1VMlTHwbCVjK4rqoFFrcZrO3qHvkRh6K9wnHnw5PPtBsrMbg8lWKBrGaf4TYRYFW+CukmR+06R7u5zAZaL7CMhl69bCXd78Tz1Z4N5CxVFD8vGatp66TMBk+0YhZP7Lo1yIDu2XsojVtigAoV9sm8OF5/aXmgfFb2AUmANGxlaDAieUfOAm7RXvsOZgaPN72KEqya8XQW6r1/aGF6jMmJ62qgPqJV3TtJtbFSwH1suywAk1UDltVim4b/Ucw1A=="));
   276         securityAttributes = new SecurityAttributes();
   271         securityAttributes = new SecurityAttributes();
   277         securityAttributes.addDescriptorAttributes(allAttributes);
   272         securityAttributes.addDescriptorAttributes(allAttributes);
   278         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   273         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   279         details = (SigningCertificate[])authenticationModule.getCertificatesDetails(session, appUID);
   274         details = (SigningCertificate[])authenticationModule.getCertificatesDetails(session, appUID);
   280         authenticationModule.authenticateJar(appUID, null,TEST_DATA_DIR + "security_tmp" + System.getProperty("file.separator") + "app.jar", false);
   275         authenticationModule.authenticateJar(session, appUID, null,TEST_DATA_DIR + "security_tmp" + System.getProperty("file.separator") + "app.jar", false);
   281         authenticationModule.addSecurityData(session, appUID, null);
       
   282         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   276         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   283         // this empties the cache as well
   277         // this empties the cache as well
   284         authenticationModule.removeSecurityData(session, appUID);
   278         authenticationModule.removeSecurityData(session, appUID);
   285         appPackageEntry = new StorageEntry();
   279         appPackageEntry = new StorageEntry();
   286         appPackageEntry.addAttribute(new StorageAttribute(
   280         appPackageEntry.addAttribute(new StorageAttribute(
   363         securityAttributes = new SecurityAttributes();
   357         securityAttributes = new SecurityAttributes();
   364         securityAttributes.addDescriptorAttributes(allAttributes);
   358         securityAttributes.addDescriptorAttributes(allAttributes);
   365         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   359         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   366         try
   360         try
   367         {
   361         {
   368             authenticationModule.authenticateJar(appUID, null,TEST_DATA_DIR + "security_tmp" + System.getProperty("file.separator") + "modified_app.jar", false);
   362             authenticationModule.authenticateJar(session, appUID, null,TEST_DATA_DIR + "security_tmp" + System.getProperty("file.separator") + "modified_app.jar", false);
   369         authenticationModule.addSecurityData(session, appUID, null);
       
   370             assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG, false);
   363             assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG, false);
   371         }
   364         }
   372         catch (InstallerSecurityException e)
   365         catch (InstallerSecurityException e)
   373         {
   366         {
   374             assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
   367             assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
   557         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   550         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   558                           "otIHquw4orxOi5bhejtnZGdWPHyJW+EQPhTgqoGFqQt8zNhAl1MNbBxZCaXBu84IWChcMbTj3ziogyUDeW+CmnP5T85z18/A0GanqAXYj7otaYiba/Si2CiHYQdEBvGgjATuDuVr9wsv/1qWGqmmnPo6+1OqulM38etWnB2/zGQ="));
   551                           "otIHquw4orxOi5bhejtnZGdWPHyJW+EQPhTgqoGFqQt8zNhAl1MNbBxZCaXBu84IWChcMbTj3ziogyUDeW+CmnP5T85z18/A0GanqAXYj7otaYiba/Si2CiHYQdEBvGgjATuDuVr9wsv/1qWGqmmnPo6+1OqulM38etWnB2/zGQ="));
   559         securityAttributes = new SecurityAttributes();
   552         securityAttributes = new SecurityAttributes();
   560         securityAttributes.addDescriptorAttributes(allAttributes);
   553         securityAttributes.addDescriptorAttributes(allAttributes);
   561         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   554         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   562         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   555         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   563         authenticationModule.addSecurityData(session, appUID, null);
       
   564         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   556         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   565         assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
   557         assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
   566         // 17. Developer Certificates/Manufacturer - sign to operator party domain
   558         // 17. Developer Certificates/Manufacturer - sign to operator party domain
   567         authenticationModule.removeSecurityData(session, appUID);
   559         authenticationModule.removeSecurityData(session, appUID);
   568         allAttributes.clear();
   560         allAttributes.clear();
   572         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   564         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   573                           "wXTAM75XDaBaBV89qlb/XnR/hRtQ2y8uVJmUJg/NY0JXD0g8o9mT3M7PGJbDIjUGE1zcdqN+NmWaDQtWo7yUX1G4nn8TEnXvupNo2hWqwhTMDM3wMgs7kgbK1W/lC/OZVuM9CXmbPw+/r8eRJmCspz1ocYonYS08ZQUQ943cRt0="));
   565                           "wXTAM75XDaBaBV89qlb/XnR/hRtQ2y8uVJmUJg/NY0JXD0g8o9mT3M7PGJbDIjUGE1zcdqN+NmWaDQtWo7yUX1G4nn8TEnXvupNo2hWqwhTMDM3wMgs7kgbK1W/lC/OZVuM9CXmbPw+/r8eRJmCspz1ocYonYS08ZQUQ943cRt0="));
   574         securityAttributes = new SecurityAttributes();
   566         securityAttributes = new SecurityAttributes();
   575         securityAttributes.addDescriptorAttributes(allAttributes);
   567         securityAttributes.addDescriptorAttributes(allAttributes);
   576         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   568         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   577         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   569         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   578         authenticationModule.addSecurityData(session, appUID, null);
       
   579         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   570         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   580         assertTrue(domainCategory.equals(ApplicationInfo.OPERATOR_DOMAIN));
   571         assertTrue(domainCategory.equals(ApplicationInfo.OPERATOR_DOMAIN));
   581         // 18. Developer Certificates/Manufacturer - sign to manufacturer domain
   572         // 18. Developer Certificates/Manufacturer - sign to manufacturer domain
   582         authenticationModule.removeSecurityData(session, appUID);
   573         authenticationModule.removeSecurityData(session, appUID);
   583         allAttributes.clear();
   574         allAttributes.clear();
   587         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   578         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   588                           "1ggIHsuOMDD+GeLcwZr3W3EnY9HD9g68WH7qe6fXLsCicGc+mEB3jqmvxIsMgv8zvv+fdAQsgQfXDqNWQ5EJ5pf5SKXIowpilwQu9Tvk2iRaqDXqAZIqp0en1ST4CZOEC1xEdBcXBBAaAMvAG2EJQtCeMtkdU27UfpFbdWy1eu4="));
   579                           "1ggIHsuOMDD+GeLcwZr3W3EnY9HD9g68WH7qe6fXLsCicGc+mEB3jqmvxIsMgv8zvv+fdAQsgQfXDqNWQ5EJ5pf5SKXIowpilwQu9Tvk2iRaqDXqAZIqp0en1ST4CZOEC1xEdBcXBBAaAMvAG2EJQtCeMtkdU27UfpFbdWy1eu4="));
   589         securityAttributes = new SecurityAttributes();
   580         securityAttributes = new SecurityAttributes();
   590         securityAttributes.addDescriptorAttributes(allAttributes);
   581         securityAttributes.addDescriptorAttributes(allAttributes);
   591         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   582         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   592         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   583         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   593         authenticationModule.addSecurityData(session, appUID, null);
       
   594         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   584         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   595         assertTrue(domainCategory.equals(ApplicationInfo.MANUFACTURER_DOMAIN));
   585         assertTrue(domainCategory.equals(ApplicationInfo.MANUFACTURER_DOMAIN));
   596         // 19. Developer Certificates/Operator - sign to trusted third party domain
   586         // 19. Developer Certificates/Operator - sign to trusted third party domain
   597         authenticationModule.removeSecurityData(session, appUID);
   587         authenticationModule.removeSecurityData(session, appUID);
   598         allAttributes.clear();
   588         allAttributes.clear();
   602         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   592         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   603                           "mQ5yJoXJK1Uc4KXGm8Gue+Yi8LzzFEaRSfYyUiZSROXzapVTHpfnCYJKvG1cQOv/aZ9gDQ8LQoBLYIuZEXIK6RzzEaBCY/RcEaCviaSVq3JB/OiXglLcTZ1e+mFBvQQ0LUuPKaCW1jv4EJy3BfNL9ckeh/7dNxXc1qRSe5lZWFk="));
   593                           "mQ5yJoXJK1Uc4KXGm8Gue+Yi8LzzFEaRSfYyUiZSROXzapVTHpfnCYJKvG1cQOv/aZ9gDQ8LQoBLYIuZEXIK6RzzEaBCY/RcEaCviaSVq3JB/OiXglLcTZ1e+mFBvQQ0LUuPKaCW1jv4EJy3BfNL9ckeh/7dNxXc1qRSe5lZWFk="));
   604         securityAttributes = new SecurityAttributes();
   594         securityAttributes = new SecurityAttributes();
   605         securityAttributes.addDescriptorAttributes(allAttributes);
   595         securityAttributes.addDescriptorAttributes(allAttributes);
   606         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   596         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   607         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   597         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   608         authenticationModule.addSecurityData(session, appUID, null);
       
   609         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   598         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   610         assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
   599         assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
   611         // 20. Developer Certificates/Operator - sign to operator party domain
   600         // 20. Developer Certificates/Operator - sign to operator party domain
   612         authenticationModule.removeSecurityData(session, appUID);
   601         authenticationModule.removeSecurityData(session, appUID);
   613         allAttributes.clear();
   602         allAttributes.clear();
   617         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   606         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   618                           "oTIYybIjUD9bop+tDyOkVKP6kUKnAYi1JTI561Atrm6jhobZlQyBksNv8hI76xs1VOU8wnY0EYozhAnMR0WzC9QLGihJE0l5npLyvBi/0Q4CuFIpLg+2xpbBQ4vF3s7rDknimPVzd3VIsxo5mz7qGVeGCDfoxf85W+qMrY9lsy4="));
   607                           "oTIYybIjUD9bop+tDyOkVKP6kUKnAYi1JTI561Atrm6jhobZlQyBksNv8hI76xs1VOU8wnY0EYozhAnMR0WzC9QLGihJE0l5npLyvBi/0Q4CuFIpLg+2xpbBQ4vF3s7rDknimPVzd3VIsxo5mz7qGVeGCDfoxf85W+qMrY9lsy4="));
   619         securityAttributes = new SecurityAttributes();
   608         securityAttributes = new SecurityAttributes();
   620         securityAttributes.addDescriptorAttributes(allAttributes);
   609         securityAttributes.addDescriptorAttributes(allAttributes);
   621         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   610         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   622         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   611         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   623         authenticationModule.addSecurityData(session, appUID, null);
       
   624         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   612         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   625         assertTrue(domainCategory.equals(ApplicationInfo.OPERATOR_DOMAIN));
   613         assertTrue(domainCategory.equals(ApplicationInfo.OPERATOR_DOMAIN));
   626         // 21. Developer Certificates/Operator - sign to manufacturer domain -> still the operator domain is used
   614         // 21. Developer Certificates/Operator - sign to manufacturer domain -> still the operator domain is used
   627         authenticationModule.removeSecurityData(session, appUID);
   615         authenticationModule.removeSecurityData(session, appUID);
   628         allAttributes.clear();
   616         allAttributes.clear();
   632         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   620         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   633                           "lLOY+UtDU4Edj2S8T3ERkDnwJvBDJgh6Y6ah/hTL6/njyWnnGUCXdu3UN2jayqP0xTNQvM5Xv0zc5lv0mpdwzpT+17xDG6t0xSu2QvI+xRgIqzS9ncxaSF9oa4aIFe8IE3kf2+LW+jRleKplC3d0rzOmOHJLCZspRr1Zrs2238M="));
   621                           "lLOY+UtDU4Edj2S8T3ERkDnwJvBDJgh6Y6ah/hTL6/njyWnnGUCXdu3UN2jayqP0xTNQvM5Xv0zc5lv0mpdwzpT+17xDG6t0xSu2QvI+xRgIqzS9ncxaSF9oa4aIFe8IE3kf2+LW+jRleKplC3d0rzOmOHJLCZspRr1Zrs2238M="));
   634         securityAttributes = new SecurityAttributes();
   622         securityAttributes = new SecurityAttributes();
   635         securityAttributes.addDescriptorAttributes(allAttributes);
   623         securityAttributes.addDescriptorAttributes(allAttributes);
   636         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   624         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   637         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   625         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   638         authenticationModule.addSecurityData(session, appUID, null);
       
   639         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   626         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   640         assertTrue(domainCategory.equals(ApplicationInfo.OPERATOR_DOMAIN));
   627         assertTrue(domainCategory.equals(ApplicationInfo.OPERATOR_DOMAIN));
   641         // 22. Developer Certificates/TrustedThirdParty - sign to manufacturer domain -> still the trusted third party domain is used
   628         // 22. Developer Certificates/TrustedThirdParty - sign to manufacturer domain -> still the trusted third party domain is used
   642         authenticationModule.removeSecurityData(session, appUID);
   629         authenticationModule.removeSecurityData(session, appUID);
   643         allAttributes.clear();
   630         allAttributes.clear();
   647         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   634         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   648                           "P80CAyaqrtCFH+c2vrXX1yJkwAo2NrFEboC/h5R/47W8D1dOfhUUWSkGmCSs3eQRgdgFXjIjZL/zmCQbNuZJ5mkE+o8Z3ptFNJEQCBlV9Nfh9D0YmdR81CJgSh0af7QNHJ4rlttKtTmvFEUD2Kc49g4FDXMjU+7ISp6ZbUhNk4Y="));
   635                           "P80CAyaqrtCFH+c2vrXX1yJkwAo2NrFEboC/h5R/47W8D1dOfhUUWSkGmCSs3eQRgdgFXjIjZL/zmCQbNuZJ5mkE+o8Z3ptFNJEQCBlV9Nfh9D0YmdR81CJgSh0af7QNHJ4rlttKtTmvFEUD2Kc49g4FDXMjU+7ISp6ZbUhNk4Y="));
   649         securityAttributes = new SecurityAttributes();
   636         securityAttributes = new SecurityAttributes();
   650         securityAttributes.addDescriptorAttributes(allAttributes);
   637         securityAttributes.addDescriptorAttributes(allAttributes);
   651         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   638         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   652         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   639         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   653         authenticationModule.addSecurityData(session, appUID, null);
       
   654         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   640         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   655         assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
   641         assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
   656         // 23. Developer Certificates/TrustedThirdParty - sign to operator domain -> still the trusted third party domain is used
   642         // 23. Developer Certificates/TrustedThirdParty - sign to operator domain -> still the trusted third party domain is used
   657         authenticationModule.removeSecurityData(session, appUID);
   643         authenticationModule.removeSecurityData(session, appUID);
   658         allAttributes.clear();
   644         allAttributes.clear();
   662         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   648         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   663                           "FVXATPVhIFWYUp7a/BcmQodZLHcuBi8L4gibaXVBFECjqIQG0TGqgzm00xw4nxCFikV+vqdCiF7qD/YJClc6DPxgcqd70QTaTouRJGMsitj0ax7CPISLcXkn22aYZREChMpm1qWegAa9OwGudln6hlFqJLqa8iyD8482NiVG2Z4="));
   649                           "FVXATPVhIFWYUp7a/BcmQodZLHcuBi8L4gibaXVBFECjqIQG0TGqgzm00xw4nxCFikV+vqdCiF7qD/YJClc6DPxgcqd70QTaTouRJGMsitj0ax7CPISLcXkn22aYZREChMpm1qWegAa9OwGudln6hlFqJLqa8iyD8482NiVG2Z4="));
   664         securityAttributes = new SecurityAttributes();
   650         securityAttributes = new SecurityAttributes();
   665         securityAttributes.addDescriptorAttributes(allAttributes);
   651         securityAttributes.addDescriptorAttributes(allAttributes);
   666         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   652         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   667         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   653         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   668         authenticationModule.addSecurityData(session, appUID, null);
       
   669         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   654         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   670         assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
   655         assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
   671         // 24. Developer Certificates - no domain info -> fail
   656         // 24. Developer Certificates - no domain info -> fail
   672         try
   657         try
   673         {
   658         {
   700         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   685         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
   701                           "sOpL9KbJMxvT8Cwtvlj9rLfJKSDVkWYm13rGWgU27djNP77+48d/VBN5WkUp1MW2XLmn3umA3sstFBk0YfLGOSe4N0TusvcdmQXwBovK82xJfX1yNXs23Z6eRvDFanxC85IEfKLXcuIw5tK6v0lAG94AbMaQPhB5olAamdtgzLc="));
   686                           "sOpL9KbJMxvT8Cwtvlj9rLfJKSDVkWYm13rGWgU27djNP77+48d/VBN5WkUp1MW2XLmn3umA3sstFBk0YfLGOSe4N0TusvcdmQXwBovK82xJfX1yNXs23Z6eRvDFanxC85IEfKLXcuIw5tK6v0lAG94AbMaQPhB5olAamdtgzLc="));
   702         securityAttributes = new SecurityAttributes();
   687         securityAttributes = new SecurityAttributes();
   703         securityAttributes.addDescriptorAttributes(allAttributes);
   688         securityAttributes.addDescriptorAttributes(allAttributes);
   704         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   689         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   705         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   690         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   706         authenticationModule.addSecurityData(session, appUID, null);
       
   707         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   691         domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
   708         assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
   692         assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
   709         // 26. Developer Certificates - empty IMEI list -> failure
   693         // 26. Developer Certificates - empty IMEI list -> failure
   710         try
   694         try
   711         {
   695         {
   821         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" , new Attribute("",
   805         allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" , new Attribute("",
   822                           "kwxpKeSSWSeSW5ieWCx9ARFD6Lrwabxk5t7Aas5FFVEtr89vslY1QIexKNiytQm51PTIRnCNhl6y+tcv7V7GRskV1VMlTHwbCVjK4rqoFFrcZrO3qHvkRh6K9wnHnw5PPtBsrMbg8lWKBrGaf4TYRYFW+CukmR+06R7u5zAZaL7CMhl69bCXd78Tz1Z4N5CxVFD8vGatp66TMBk+0YhZP7Lo1yIDu2XsojVtigAoV9sm8OF5/aXmgfFb2AUmANGxlaDAieUfOAm7RXvsOZgaPN72KEqya8XQW6r1/aGF6jMmJ62qgPqJV3TtJtbFSwH1suywAk1UDltVim4b/Ucw1A=="));
   806                           "kwxpKeSSWSeSW5ieWCx9ARFD6Lrwabxk5t7Aas5FFVEtr89vslY1QIexKNiytQm51PTIRnCNhl6y+tcv7V7GRskV1VMlTHwbCVjK4rqoFFrcZrO3qHvkRh6K9wnHnw5PPtBsrMbg8lWKBrGaf4TYRYFW+CukmR+06R7u5zAZaL7CMhl69bCXd78Tz1Z4N5CxVFD8vGatp66TMBk+0YhZP7Lo1yIDu2XsojVtigAoV9sm8OF5/aXmgfFb2AUmANGxlaDAieUfOAm7RXvsOZgaPN72KEqya8XQW6r1/aGF6jMmJ62qgPqJV3TtJtbFSwH1suywAk1UDltVim4b/Ucw1A=="));
   823         securityAttributes = new SecurityAttributes();
   807         securityAttributes = new SecurityAttributes();
   824         securityAttributes.addDescriptorAttributes(allAttributes);
   808         securityAttributes.addDescriptorAttributes(allAttributes);
   825         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   809         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   826         authenticationModule.authenticateJar(appUID, null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   810         authenticationModule.authenticateJar(session, appUID, null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   827         authenticationModule.addSecurityData(session, appUID, null);
       
   828         SigningInfo info = authenticationModule.getSigningInfo("appName","appVersion","appVendor");
   811         SigningInfo info = authenticationModule.getSigningInfo("appName","appVersion","appVendor");
   829         // app is unknown
   812         // app is unknown
   830         assertTrue(info == null);
   813         assertTrue(info == null);
   831         // make the application known
   814         // make the application known
   832         appPackageEntry = new StorageEntry();
   815         appPackageEntry = new StorageEntry();
   866         allAttributes.clear();
   849         allAttributes.clear();
   867         allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
   850         allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
   868         securityAttributes = new SecurityAttributes();
   851         securityAttributes = new SecurityAttributes();
   869         securityAttributes.addDescriptorAttributes(allAttributes);
   852         securityAttributes.addDescriptorAttributes(allAttributes);
   870         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   853         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
   871         authenticationModule.authenticateJar(appUID, null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   854         authenticationModule.authenticateJar(session, appUID, null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
   872         authenticationModule.addSecurityData(session, appUID, null);
       
   873         info = authenticationModule.getSigningInfo("appName","appVersion","appVendor");
   855         info = authenticationModule.getSigningInfo("appName","appVersion","appVendor");
   874         assertTrue(info.getProtectionDomain() != null
   856         assertTrue(info.getProtectionDomain() != null
   875                    && info.getProtectionDomain().getName() != null
   857                    && info.getProtectionDomain().getName() != null
   876                    && info.getProtectionDomain().getCategory() != null
   858                    && info.getProtectionDomain().getCategory() != null
   877                    && info.getSigningCertificate() == null
   859                    && info.getSigningCertificate() == null
   974         session.remove(StorageNames.APPLICATION_PACKAGE_TABLE, appUID);
   956         session.remove(StorageNames.APPLICATION_PACKAGE_TABLE, appUID);
   975         session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
   957         session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
   976         authenticationModule.removeSecurityData(session, appUID);
   958         authenticationModule.removeSecurityData(session, appUID);
   977         try
   959         try
   978         {
   960         {
   979             authenticationModule.authenticateJar(appUID, null, domain, TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar");
   961             authenticationModule.authenticateJar(session, appUID, null, domain, TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar");
   980         authenticationModule.addSecurityData(session, appUID, null);
       
   981             assertTrue(!expectToFail);
   962             assertTrue(!expectToFail);
   982         }
   963         }
   983         catch (InstallerSecurityException e)
   964         catch (InstallerSecurityException e)
   984         {
   965         {
   985             assertTrue(expectToFail);
   966             assertTrue(expectToFail);
  1063                         "jar_path"));
  1044                         "jar_path"));
  1064             assertTrue(false);
  1045             assertTrue(false);
  1065         }
  1046         }
  1066         catch (RuntimeSecurityException e)
  1047         catch (RuntimeSecurityException e)
  1067         {
  1048         {
  1068             assertTrue(e.getShortMessage().equals(securityErrorMessage.get(SecurityErrorMessage.JAR_NOT_FOUND, null))
  1049             assertTrue(e.getShortMessage().equals(securityErrorMessage.get(SecurityErrorMessage.JAR_TAMPERED, null))
  1069                        && e.getDetailedMessage().equals(securityDetailedErrorMessage.get(SecurityDetailedErrorMessage.JAR_NOT_FOUND, null)));
  1050                        && e.getDetailedMessage().equals(securityDetailedErrorMessage.get(SecurityDetailedErrorMessage.JAR_TAMPERED, null)));
  1070         }
  1051         }
  1071         // root not enabled
  1052         // root not enabled
  1072         try
  1053         try
  1073         {
  1054         {
  1074             authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
  1055             authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
  1217         securityAttributes.addDescriptorAttributes(allAttributes);
  1198         securityAttributes.addDescriptorAttributes(allAttributes);
  1218         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
  1199         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
  1219         allAttributes.clear();
  1200         allAttributes.clear();
  1220         allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
  1201         allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
  1221         securityAttributes.addManifestAttributes(allAttributes);
  1202         securityAttributes.addManifestAttributes(allAttributes);
  1222         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "HelloWorld.jar", false);
  1203         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "HelloWorld.jar", false);
  1223         authenticationModule.addSecurityData(session, appUID, null);
       
  1224         assertTrue(true);
  1204         assertTrue(true);
  1225         // PreInstallation: ocsp disabled, warning undefined, silent mode
  1205         // PreInstallation: ocsp disabled, warning undefined, silent mode
  1226         ocspSettings = new OcspSettings(OcspSettings.OCSP_MODE_DISABLED, OcspSettings.OCSP_WARNING_UNDEFINED, true, "0", "0");
  1206         ocspSettings = new OcspSettings(OcspSettings.OCSP_MODE_DISABLED, OcspSettings.OCSP_WARNING_UNDEFINED, true, "0", "0");
  1227         ocspUserPreferences.setOcspMode(0);
  1207         ocspUserPreferences.setOcspMode(0);
  1228         ocspUserPreferences.setOcspUrl(null);
  1208         ocspUserPreferences.setOcspUrl(null);
  1236         securityAttributes.addDescriptorAttributes(allAttributes);
  1216         securityAttributes.addDescriptorAttributes(allAttributes);
  1237         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
  1217         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
  1238         allAttributes.clear();
  1218         allAttributes.clear();
  1239         allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
  1219         allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
  1240         securityAttributes.addManifestAttributes(allAttributes);
  1220         securityAttributes.addManifestAttributes(allAttributes);
  1241         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "HelloWorld.jar", false);
  1221         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "HelloWorld.jar", false);
  1242         authenticationModule.addSecurityData(session, appUID, null);
       
  1243         assertTrue(true);
  1222         assertTrue(true);
  1244         // PreInstallation: ocsp enabled, warning ignore, silent mode, ocsp url not set
  1223         // PreInstallation: ocsp enabled, warning ignore, silent mode, ocsp url not set
  1245         ocspSettings = new OcspSettings(OcspSettings.OCSP_MODE_ENABLED, OcspSettings.OCSP_WARNING_IGNORE, true, "0", "0");
  1224         ocspSettings = new OcspSettings(OcspSettings.OCSP_MODE_ENABLED, OcspSettings.OCSP_WARNING_IGNORE, true, "0", "0");
  1246         ocspUserPreferences.setOcspMode(-1);
  1225         ocspUserPreferences.setOcspMode(-1);
  1247         ocspUserPreferences.setOcspUrl(null);
  1226         ocspUserPreferences.setOcspUrl(null);
  1255         securityAttributes.addDescriptorAttributes(allAttributes);
  1234         securityAttributes.addDescriptorAttributes(allAttributes);
  1256         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
  1235         authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
  1257         allAttributes.clear();
  1236         allAttributes.clear();
  1258         allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
  1237         allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
  1259         securityAttributes.addManifestAttributes(allAttributes);
  1238         securityAttributes.addManifestAttributes(allAttributes);
  1260         authenticationModule.authenticateJar(appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "HelloWorld.jar", false);
  1239         authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "HelloWorld.jar", false);
  1261         authenticationModule.addSecurityData(session, appUID, null);
       
  1262         assertTrue(true);
  1240         assertTrue(true);
  1263     }
  1241     }
  1264 
  1242 
  1265     private boolean checkCertificateDetails(SigningCertificate[] details)
  1243     private boolean checkCertificateDetails(SigningCertificate[] details)
  1266     {
  1244     {