javacommons/security/javasrc/com/nokia/mj/impl/security/midp/authentication/AuthenticationModule.java
changeset 48 e0d6e9bd3ca7
parent 21 2a9601315dfc
child 64 0ea12c182930
--- a/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/authentication/AuthenticationModule.java	Wed Jun 23 18:07:10 2010 +0300
+++ b/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/authentication/AuthenticationModule.java	Tue Jul 06 14:10:26 2010 +0300
@@ -277,7 +277,11 @@
         try
         {
             Vector allAuthCredentials = (Vector)iAuthCredentials.get(msUID);
-            String jarHash = _computeHash(appJARPath);
+            String jarHash = null;
+            try
+            {
+                jarHash = _computeHash(appJARPath);
+            }catch(AuthenticationException e) {}
             if (jarHash == null || jarHash.length() == 0)
             {
                 // could not compute hash for the given application
@@ -410,7 +414,11 @@
                 new String[] {"Unknown protection domain " + protectionDomain},
                 OtaStatusCode.INTERNAL_ERROR);
         }
-        String jarHash = _computeHash(appJARPath);
+        String jarHash = null;
+        try
+        {
+            jarHash = _computeHash(appJARPath);
+        }catch(AuthenticationException e) {}
         if (jarHash == null || jarHash.length() == 0)
         {
             // could not compute hash for the given application
@@ -825,7 +833,23 @@
                 && authStorageData.getJarHashValue().length() > 0)
         {
             Logger.log("  Doing tamper detection");
-            String computedJarHash = _computeHash(authStorageData.getJarPath());
+            String computedJarHash = null;            
+            try
+            {
+                computedJarHash = _computeHash(authStorageData.getJarPath());
+            }catch(AuthenticationException e) 
+            {
+                if (e.getErrorCode() 
+                    == AuthenticationException.JAR_NOT_FOUND)
+                {
+                    Logger.logWarning("    Jar not found while trying to compute hash");
+                    throw new RuntimeSecurityException(
+                        SecurityErrorMessage.JAR_NOT_FOUND,
+                        null, /* no params for short msg */
+                        SecurityDetailedErrorMessage.JAR_NOT_FOUND,
+                        null /* no params for detailed msg */);
+                }
+            }
             // do the tampering check: compute the hash and compare it with the stored hash
             if (computedJarHash == null || !computedJarHash.equals(
                         authStorageData.getJarHashValue()))
@@ -1120,6 +1144,7 @@
     private boolean isDriveProtected(int aMediaId)
     {
         DriveInfo[] allDrives = DriveUtilities.getAllDrives();
+        boolean driveFound = false;
         if (allDrives != null)
         {
             for (int i=0; i<allDrives.length; i++)
@@ -1134,11 +1159,11 @@
                     {
                         return false;
                     }
-                    return true;
+                    driveFound = true;
                 }
             }
         }
-        return false;
+        return driveFound;
     }
 
     private Credentials selectCredentials(String selectedJarHash, Vector allAuthCredentials, Vector validatedChainIndexes)