Exemplo n.º 1
0
 private Exception checkChecksum(
     IInputSource source, String entryName, InputStream stream, Throwable ex) {
   if (stream instanceof IChecksumStream) {
     if (manifest == null) {
       throw new InternalError("Manifest should not be encrypted"); // $NON-NLS-1$
     }
     IEncryptionData encData = manifest.getEncryptionData(entryName);
     if (encData != null) {
       String expectedChecksum = encData.getChecksum();
       if (expectedChecksum != null) {
         String actualChecksum;
         try {
           actualChecksum = ((IChecksumStream) stream).getChecksum();
           if (actualChecksum == null || !expectedChecksum.equals(actualChecksum)) {
             if (ex == null) return new CoreException(Core.ERROR_WRONG_PASSWORD);
             return new CoreException(Core.ERROR_WRONG_PASSWORD, ex);
           }
         } catch (IOException e) {
         }
       }
     }
   }
   if (ex == null) return null;
   if (ex instanceof IOException) return (IOException) ex;
   return new CoreException(Core.ERROR_FAIL_PARSING_XML, ex);
 }
Exemplo n.º 2
0
  private InputStream getInputStream(IInputSource source, String entryPath) throws CoreException {
    if (!source.hasEntry(entryPath)) return null;

    InputStream in = source.getEntryStream(entryPath);
    if (in == null) return null;

    if (manifest != null) {
      IEncryptionData encData = manifest.getEncryptionData(entryPath);
      if (encData != null) {
        in = createDecryptedStream(in, encData);
      }
    }

    return in;
  }