Examples of Decryptor


Examples of org.apache.hadoop.hbase.io.crypto.Decryptor

    Encryption.Context cryptoContext = fileContext.getEncryptionContext();
    if (cryptoContext != Encryption.Context.NONE) {

      Cipher cipher = cryptoContext.getCipher();
      Decryptor decryptor = cipher.getDecryptor();
      decryptor.setKey(cryptoContext.getKey());

      // Encrypted block format:
      // +--------------------------+
      // | byte iv length           |
      // +--------------------------+
      // | iv data ...              |
      // +--------------------------+
      // | encrypted block data ... |
      // +--------------------------+

      int ivLength = in.read();
      if (ivLength > 0) {
        byte[] iv = new byte[ivLength];
        IOUtils.readFully(in, iv);
        decryptor.setIv(iv);
        // All encrypted blocks will have a nonzero IV length. If we see an IV
        // length of zero, this means the encoding context had 0 bytes of
        // plaintext to encode.
        decryptor.reset();
        in = decryptor.createDecryptionStream(in);
      }
      onDiskSizeWithoutHeader -= Bytes.SIZEOF_BYTE + ivLength;
    }

    Compression.Algorithm compression = fileContext.getCompression();
View Full Code Here

Examples of org.apache.hadoop.hbase.io.crypto.Decryptor

  public InputStream createDecryptionStream(InputStream in, Context context, byte[] iv)
      throws IOException {
    Preconditions.checkNotNull(context);
    Preconditions.checkState(context.getKey() != null, "Context does not have a key");
    Preconditions.checkNotNull(iv);
    Decryptor d = getDecryptor();
    d.setKey(context.getKey());
    d.setIv(iv);
    return d.createDecryptionStream(in);
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.io.crypto.Decryptor

  public InputStream createDecryptionStream(InputStream in, Context context, byte[] iv)
      throws IOException {
    Preconditions.checkNotNull(context);
    Preconditions.checkState(context.getKey() != null, "Context does not have a key");
    Preconditions.checkNotNull(iv);
    Decryptor d = getDecryptor();
    d.setKey(context.getKey());
    d.setIv(iv);
    return d.createDecryptionStream(in);
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.io.crypto.Decryptor

    Encryption.Context cryptoContext = fileContext.getEncryptionContext();
    if (cryptoContext != Encryption.Context.NONE) {

      Cipher cipher = cryptoContext.getCipher();
      Decryptor decryptor = cipher.getDecryptor();
      decryptor.setKey(cryptoContext.getKey());

      // Encrypted block format:
      // +--------------------------+
      // | byte iv length           |
      // +--------------------------+
      // | iv data ...              |
      // +--------------------------+
      // | encrypted block data ... |
      // +--------------------------+

      int ivLength = in.read();
      if (ivLength > 0) {
        byte[] iv = new byte[ivLength];
        IOUtils.readFully(in, iv);
        decryptor.setIv(iv);
        // All encrypted blocks will have a nonzero IV length. If we see an IV
        // length of zero, this means the encoding context had 0 bytes of
        // plaintext to encode.
        decryptor.reset();
        in = decryptor.createDecryptionStream(in);
      }
      onDiskSizeWithoutHeader -= Bytes.SIZEOF_BYTE + ivLength;
    }

    Compression.Algorithm compression = fileContext.getCompression();
View Full Code Here

Examples of org.apache.hadoop.hbase.io.crypto.Decryptor

  public InputStream createDecryptionStream(InputStream in, Context context, byte[] iv)
      throws IOException {
    Preconditions.checkNotNull(context);
    Preconditions.checkState(context.getKey() != null, "Context does not have a key");
    Preconditions.checkNotNull(iv);
    Decryptor d = getDecryptor();
    d.setKey(context.getKey());
    d.setIv(iv);
    return d.createDecryptionStream(in);
  }
View Full Code Here

Examples of org.apache.poi.poifs.crypt.Decryptor

           extractor.parse(xhtml, metadata);
           break;
        case ENCRYPTED:
           EncryptionInfo info = new EncryptionInfo(root);
           Decryptor d = Decryptor.getInstance(info);

           try {
              // By default, use the default Office Password
              String password = Decryptor.DEFAULT_PASSWORD;
             
              // If they supplied a Password Provider, ask that for the password,
              //  and use the provider given one if available (stick with default if not)
              PasswordProvider passwordProvider = context.get(PasswordProvider.class);
              if (passwordProvider != null) {
                 String suppliedPassword = passwordProvider.getPassword(metadata);
                 if (suppliedPassword != null) {
                     password = suppliedPassword;
                 }
              }
             
              // Check if we've the right password or not
              if (!d.verifyPassword(password)) {
                 throw new EncryptedDocumentException();
              }

              // Decrypt the OLE2 stream, and delegate the resulting OOXML
              //  file to the regular OOXML parser for normal handling
              OOXMLParser parser = new OOXMLParser();

              parser.parse(d.getDataStream(root), new EmbeddedContentHandler(
                    new BodyContentHandler(xhtml)),
                    metadata, context);
           } catch (GeneralSecurityException ex) {
              throw new EncryptedDocumentException(ex);
           }
View Full Code Here

Examples of org.apache.poi.poifs.crypt.Decryptor

                        extractor.parse(xhtml, metadata);
                    }
                    break;
                case ENCRYPTED:
                    EncryptionInfo info = new EncryptionInfo(filesystem);
                    Decryptor d = new Decryptor(info);

                    try {
                        if (!d.verifyPassword(Decryptor.DEFAULT_PASSWORD)) {
                            throw new TikaException("Unable to process: document is encrypted");
                        }

                        OOXMLParser parser = new OOXMLParser();

                        parser.parse(d.getDataStream(filesystem), new EmbeddedContentHandler(
                                        new BodyContentHandler(xhtml)),
                                        metadata, context);
                    } catch (GeneralSecurityException ex) {
                        throw new TikaException("Unable to process encrypted document", ex);
                    }
View Full Code Here

Examples of org.apache.poi.poifs.crypt.Decryptor

           extractor.parse(xhtml, metadata);
           break;
        case ENCRYPTED:
           EncryptionInfo info = new EncryptionInfo(root);
           Decryptor d = Decryptor.getInstance(info);

           try {
              // By default, use the default Office Password
              String password = Decryptor.DEFAULT_PASSWORD;
             
              // If they supplyed a Password Provider, ask that for the password
              PasswordProvider passwordProvider = context.get(PasswordProvider.class);
              if (passwordProvider != null) {
                 password = passwordProvider.getPassword(metadata);
              }
             
              // Check if we've the right password or not
              if (!d.verifyPassword(password)) {
                 throw new EncryptedDocumentException();
              }

              // Decrypt the OLE2 stream, and delegate the resulting OOXML
              //  file to the regular OOXML parser for normal handling
              OOXMLParser parser = new OOXMLParser();

              parser.parse(d.getDataStream(root), new EmbeddedContentHandler(
                    new BodyContentHandler(xhtml)),
                    metadata, context);
           } catch (GeneralSecurityException ex) {
              throw new EncryptedDocumentException(ex);
           }
View Full Code Here

Examples of org.apache.poi.poifs.crypt.Decryptor

        assertEquals(128, info.getHeader().getKeySize());
        assertEquals(CipherAlgorithm.aes128, info.getHeader().getCipherAlgorithm());
        assertEquals(HashAlgorithm.sha1, info.getHeader().getHashAlgorithmEx());

        // Check it can be decoded
        Decryptor d = Decryptor.getInstance(info);   
        assertTrue("Unable to process: document is encrypted", d.verifyPassword("solrcell"));

        // Check we can read the word document in that
        InputStream dataStream = d.getDataStream(filesystem);
        OPCPackage opc = OPCPackage.open(dataStream);
        XWPFDocument doc = new XWPFDocument(opc);
        XWPFWordExtractor ex = new XWPFWordExtractor(doc);
        String text = ex.getText();
        assertNotNull(text);
View Full Code Here

Examples of org.apache.poi.poifs.crypt.Decryptor

        assertEquals(256, info.getHeader().getKeySize());
        assertEquals(CipherAlgorithm.aes256, info.getHeader().getCipherAlgorithm());
        assertEquals(HashAlgorithm.sha1, info.getHeader().getHashAlgorithmEx());

        // Check it can be decoded
        Decryptor d = Decryptor.getInstance(info);   
        assertTrue("Unable to process: document is encrypted", d.verifyPassword("pass"));

        // Check we can read the word document in that
        InputStream dataStream = d.getDataStream(filesystem);
        OPCPackage opc = OPCPackage.open(dataStream);
        XWPFDocument doc = new XWPFDocument(opc);
        XWPFWordExtractor ex = new XWPFWordExtractor(doc);
        String text = ex.getText();
        assertNotNull(text);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.