275 { |
275 { |
276 AuthenticationStorageData data = null; |
276 AuthenticationStorageData data = null; |
277 try |
277 try |
278 { |
278 { |
279 Vector allAuthCredentials = (Vector)iAuthCredentials.get(msUID); |
279 Vector allAuthCredentials = (Vector)iAuthCredentials.get(msUID); |
280 String jarHash = _computeHash(appJARPath); |
280 String jarHash = null; |
|
281 try |
|
282 { |
|
283 jarHash = _computeHash(appJARPath); |
|
284 }catch(AuthenticationException e) {} |
281 if (jarHash == null || jarHash.length() == 0) |
285 if (jarHash == null || jarHash.length() == 0) |
282 { |
286 { |
283 // could not compute hash for the given application |
287 // could not compute hash for the given application |
284 Logger.logWarning("Could not compute hash for " + appJARPath); |
288 Logger.logWarning("Could not compute hash for " + appJARPath); |
285 throw new InstallerSecurityException( |
289 throw new InstallerSecurityException( |
408 null, /* no params for short msg */ |
412 null, /* no params for short msg */ |
409 InstallerDetailedErrorMessage.INTERNAL_ERROR, |
413 InstallerDetailedErrorMessage.INTERNAL_ERROR, |
410 new String[] {"Unknown protection domain " + protectionDomain}, |
414 new String[] {"Unknown protection domain " + protectionDomain}, |
411 OtaStatusCode.INTERNAL_ERROR); |
415 OtaStatusCode.INTERNAL_ERROR); |
412 } |
416 } |
413 String jarHash = _computeHash(appJARPath); |
417 String jarHash = null; |
|
418 try |
|
419 { |
|
420 jarHash = _computeHash(appJARPath); |
|
421 }catch(AuthenticationException e) {} |
414 if (jarHash == null || jarHash.length() == 0) |
422 if (jarHash == null || jarHash.length() == 0) |
415 { |
423 { |
416 // could not compute hash for the given application |
424 // could not compute hash for the given application |
417 Logger.logWarning("Could not compute hash for " + appJARPath); |
425 Logger.logWarning("Could not compute hash for " + appJARPath); |
418 throw new InstallerSecurityException( |
426 throw new InstallerSecurityException( |
823 // do the tamper detection |
831 // do the tamper detection |
824 if (authStorageData.getJarHashValue() != null |
832 if (authStorageData.getJarHashValue() != null |
825 && authStorageData.getJarHashValue().length() > 0) |
833 && authStorageData.getJarHashValue().length() > 0) |
826 { |
834 { |
827 Logger.log(" Doing tamper detection"); |
835 Logger.log(" Doing tamper detection"); |
828 String computedJarHash = _computeHash(authStorageData.getJarPath()); |
836 String computedJarHash = null; |
|
837 try |
|
838 { |
|
839 computedJarHash = _computeHash(authStorageData.getJarPath()); |
|
840 }catch(AuthenticationException e) |
|
841 { |
|
842 if (e.getErrorCode() |
|
843 == AuthenticationException.JAR_NOT_FOUND) |
|
844 { |
|
845 Logger.logWarning(" Jar not found while trying to compute hash"); |
|
846 throw new RuntimeSecurityException( |
|
847 SecurityErrorMessage.JAR_NOT_FOUND, |
|
848 null, /* no params for short msg */ |
|
849 SecurityDetailedErrorMessage.JAR_NOT_FOUND, |
|
850 null /* no params for detailed msg */); |
|
851 } |
|
852 } |
829 // do the tampering check: compute the hash and compare it with the stored hash |
853 // do the tampering check: compute the hash and compare it with the stored hash |
830 if (computedJarHash == null || !computedJarHash.equals( |
854 if (computedJarHash == null || !computedJarHash.equals( |
831 authStorageData.getJarHashValue())) |
855 authStorageData.getJarHashValue())) |
832 { |
856 { |
833 Logger.logWarning(" Application has been tampered"); |
857 Logger.logWarning(" Application has been tampered"); |
1118 } |
1142 } |
1119 |
1143 |
1120 private boolean isDriveProtected(int aMediaId) |
1144 private boolean isDriveProtected(int aMediaId) |
1121 { |
1145 { |
1122 DriveInfo[] allDrives = DriveUtilities.getAllDrives(); |
1146 DriveInfo[] allDrives = DriveUtilities.getAllDrives(); |
|
1147 boolean driveFound = false; |
1123 if (allDrives != null) |
1148 if (allDrives != null) |
1124 { |
1149 { |
1125 for (int i=0; i<allDrives.length; i++) |
1150 for (int i=0; i<allDrives.length; i++) |
1126 { |
1151 { |
1127 if (aMediaId == allDrives[i].iId) |
1152 if (aMediaId == allDrives[i].iId) |