コード例 #1
0
  /**
   * Gets the decrypted literal string value of the data using the key provided by the security
   * manager.
   *
   * @param securityManager security manager associated with parent document.
   */
  public String getDecryptedLiteralString(SecurityManager securityManager) {
    // get the security manager instance
    if (securityManager != null && reference != null) {
      // get the key
      byte[] key = securityManager.getDecryptionKey();

      // convert string to bytes.
      byte[] textBytes = Utils.convertByteCharSequenceToByteArray(stringData);

      // Decrypt String
      textBytes = securityManager.decrypt(reference, key, textBytes);

      // convert back to a string
      return Utils.convertByteArrayToByteString(textBytes);
    }
    return getLiteralString();
  }
コード例 #2
0
ファイル: ICCBased.java プロジェクト: CyberReveal/icepdf511
  public synchronized void init() {
    if (inited) {
      return;
    }

    byte[] in;
    try {
      stream.init();
      in = stream.getDecodedStreamBytes(0);
      if (logger.isLoggable(Level.FINEST)) {
        String content = Utils.convertByteArrayToByteString(in);
        logger.finest("Content = " + content);
      }
      if (in != null) {
        ICC_Profile profile = ICC_Profile.getInstance(in);
        colorSpace = new ICC_ColorSpace(profile);
      }
    } catch (Exception e) {
      logger.log(Level.FINE, "Error Processing ICCBased Colour Profile", e);
    }
    inited = true;
  }
コード例 #3
0
  public FlateDecode(Library library, Hashtable props, InputStream input) {
    super();
    originalInputKeptSolelyForDebugging = input;
    width = 0;
    numComponents = 0;
    bitsPerComponent = 0;
    bpp = 1;

    int intermediateBufferSize = 4096;

    // get decode parameters from stream properties
    Hashtable decodeParmsDictionary = library.getDictionary(props, "DecodeParms");
    predictor = library.getInt(decodeParmsDictionary, "Predictor");
    if (predictor != LZW_FLATE_PREDICTOR_NONE
        && predictor != LZW_FLATE_PREDICTOR_TIFF_2
        && predictor != LZW_FLATE_PREDICTOR_PNG_NONE
        && predictor != LZW_FLATE_PREDICTOR_PNG_SUB
        && predictor != LZW_FLATE_PREDICTOR_PNG_UP
        && predictor != LZW_FLATE_PREDICTOR_PNG_AVG
        && predictor != LZW_FLATE_PREDICTOR_PNG_PAETH
        && predictor != LZW_FLATE_PREDICTOR_PNG_OPTIMUM) {
      predictor = LZW_FLATE_PREDICTOR_NONE;
    }
    // System.out.println("predictor: " + predictor);
    if (predictor != LZW_FLATE_PREDICTOR_NONE) {
      Number widthNumber = library.getNumber(props, "Width");
      if (widthNumber != null) width = widthNumber.intValue();
      else width = library.getInt(decodeParmsDictionary, "Columns");
      // System.out.println("Width: " + width);
      // int height = (int) library.getFloat(entries, "Height");

      // Since DecodeParms.BitsPerComponent has a default value, I don't think we'd
      //   look at entries.ColorSpace to know the number of components. But, here's the info:
      //   /ColorSpace /DeviceGray: 1 comp, /DeviceRBG: 3 comps, /DeviceCMYK: 4 comps, /DeviceN: N
      // comps
      // I'm going to extend that to mean I won't look at entries.BitsPerComponent either

      numComponents = 1; // DecodeParms.Colors: 1,2,3,4  Default=1
      bitsPerComponent = 8; // DecodeParms.BitsPerComponent: 1,2,4,8,16  Default=8

      Object numComponentsDecodeParmsObj = library.getObject(decodeParmsDictionary, "Colors");
      if (numComponentsDecodeParmsObj instanceof Number) {
        numComponents = ((Number) numComponentsDecodeParmsObj).intValue();
        // System.out.println("numComponents: " + numComponents);
      }
      Object bitsPerComponentDecodeParmsObj =
          library.getObject(decodeParmsDictionary, "BitsPerComponent");
      if (bitsPerComponentDecodeParmsObj instanceof Number) {
        bitsPerComponent = ((Number) bitsPerComponentDecodeParmsObj).intValue();
        // System.out.println("bitsPerComponent: " + bitsPerComponent);
      }

      bpp = Math.max(1, Utils.numBytesToHoldBits(numComponents * bitsPerComponent));
      // System.out.println("bpp: " + bpp);

      // Make buffer exactly large enough for one row of data (without predictor)
      intermediateBufferSize = Utils.numBytesToHoldBits(width * numComponents * bitsPerComponent);
      // System.out.println("intermediateBufferSize: " + intermediateBufferSize);
    }

    // Create the inflater input stream which will do the encoding
    setInputStream(new InflaterInputStream(input));
    setBufferSize(intermediateBufferSize);
    aboveBuffer = new byte[intermediateBufferSize];
  }