Package org.odftoolkit.odfdom.pkg.manifest

Examples of org.odftoolkit.odfdom.pkg.manifest.EncryptionDataElement


  }

  private boolean isEncrypted(String aEntryName, Logger aLogger) {
    OdfFileEntry aFileEntry = getPackage(aLogger).getFileEntry(aEntryName);
    if (aFileEntry != null) {
      EncryptionDataElement aEncData = aFileEntry.getEncryptionData();
      if (aEncData != null) {
        aLogger.logFatalError("stream content is encrypted. Validataion of encrypted content is not supported.");
        return true;
      }
    }
View Full Code Here


        ze.setCompressedSize(data.length);
      } else {
        if (fileEntry != null) {
          fileEntry.setSize(null);
          FileEntryElement fileEntryEle = fileEntry.getOdfElement();
          EncryptionDataElement encryptionDataElement = OdfElement.findFirstChildNode(EncryptionDataElement.class, fileEntryEle);
          while (encryptionDataElement != null) {
            fileEntryEle.removeChild(encryptionDataElement);
            encryptionDataElement = OdfElement.findFirstChildNode(EncryptionDataElement.class, fileEntryEle);
          }
        }
View Full Code Here

            StreamHelper.transformStream(inputStream, out);
            data = out.toByteArray();
            // decrypt data as needed
            if (!(internalPath.equals(OdfFile.MEDIA_TYPE.getPath()) || internalPath.equals(OdfFile.MANIFEST.getPath()))) {
              OdfFileEntry manifestEntry = getManifestEntries().get(internalPath);
              EncryptionDataElement encryptionDataElement = manifestEntry.getEncryptionData();
              if (encryptionDataElement != null) {
                data = decryptData(data, manifestEntry, encryptionDataElement);
              }
            }
            // store for further usage; do not care about manifest:
View Full Code Here

      encryptedData = cipher.doFinal(compressedData, 0, compressedDataLength);
     
      // 9.update file entry encryption data.
      String checksum = new Base64Binary(checksumBytes).toString();
      FileEntryElement fileEntryElement = fileEntry.getOdfElement();
      EncryptionDataElement encryptionDataElement = OdfElement.findFirstChildNode(EncryptionDataElement.class, fileEntryElement);
      if (encryptionDataElement != null) {
        fileEntryElement.removeChild(encryptionDataElement);
      }
      encryptionDataElement = fileEntryElement.newEncryptionDataElement(checksum, "SHA1/1K");
      String initialisationVector = new Base64Binary(iv).toString();
      AlgorithmElement algorithmElement = OdfElement.findFirstChildNode(AlgorithmElement.class, encryptionDataElement);
      if (algorithmElement != null) {
        encryptionDataElement.removeChild(algorithmElement);
      }
      algorithmElement = encryptionDataElement.newAlgorithmElement("Blowfish CFB", initialisationVector);
      String saltStr = new Base64Binary(salt).toString();
      KeyDerivationElement keyDerivationElement = OdfElement.findFirstChildNode(KeyDerivationElement.class, encryptionDataElement);
      if (keyDerivationElement != null) {
        encryptionDataElement.removeChild(keyDerivationElement);
      }
      keyDerivationElement = encryptionDataElement.newKeyDerivationElement(1024, "PBKDF2", saltStr);
      StartKeyGenerationElement startKeyGenerationElement = OdfElement.findFirstChildNode(StartKeyGenerationElement.class, encryptionDataElement);
      if (startKeyGenerationElement != null) {
        encryptionDataElement.removeChild(startKeyGenerationElement);
      }
      encryptionDataElement.newStartKeyGenerationElement("SHA1").setKeySizeAttribute(20);
     
      // System.out.println("full-path=\""+ path +"\"");
      // System.out.println("size=\""+ data.length +"\"");
      // System.out.println("checksum=\""+ checksum +"\"");
      // System.out.println("compressedData ="+compressedDataLength);
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.pkg.manifest.EncryptionDataElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.