Package org.apache.accumulo.core.security.crypto

Examples of org.apache.accumulo.core.security.crypto.CryptoModuleParameters


      // additional parameters it needs from the underlying stream.
      String cryptoModuleClassname = input.readUTF();
      CryptoModule cryptoModule = CryptoModuleFactory.getCryptoModule(cryptoModuleClassname);

      // Create the parameters and set the input stream into those parameters
      CryptoModuleParameters params = CryptoModuleFactory.createParamsObjectFromAccumuloConfiguration(conf);
      params.setEncryptedInputStream(input);

      // Create the plaintext input stream from the encrypted one
      params = cryptoModule.getDecryptingInputStream(params);

      if (params.getPlaintextInputStream() instanceof DataInputStream) {
        decryptingInput = (DataInputStream) params.getPlaintextInputStream();
      } else {
        decryptingInput = new DataInputStream(params.getPlaintextInputStream());
      }
    } else {
      input.seek(0);
      byte[] magicV2 = DfsLogger.LOG_FILE_HEADER_V2.getBytes();
      byte[] magicBufferV2 = new byte[magicV2.length];
      input.readFully(magicBufferV2);

      if (Arrays.equals(magicBufferV2, magicV2)) {
        // Log files from 1.5 dump their options in raw to the logger files. Since we don't know the class
        // that needs to read those files, we can make a couple of basic assumptions. Either it's going to be
        // the NullCryptoModule (no crypto) or the DefaultCryptoModule.

        // If it's null, we won't have any parameters whatsoever. First, let's attempt to read
        // parameters
        Map<String,String> opts = new HashMap<String,String>();
        int count = input.readInt();
        for (int i = 0; i < count; i++) {
          String key = input.readUTF();
          String value = input.readUTF();
          opts.put(key, value);
        }

        if (opts.size() == 0) {
          // NullCryptoModule, we're done
          decryptingInput = input;
        } else {

          // The DefaultCryptoModule will want to read the parameters from the underlying file, so we will put the file back to that spot.
          org.apache.accumulo.core.security.crypto.CryptoModule cryptoModule = org.apache.accumulo.core.security.crypto.CryptoModuleFactory
              .getCryptoModule(DefaultCryptoModule.class.getName());

          CryptoModuleParameters params = CryptoModuleFactory.createParamsObjectFromAccumuloConfiguration(conf);

          input.seek(0);
          input.readFully(magicBufferV2);
          params.setEncryptedInputStream(input);

          params = cryptoModule.getDecryptingInputStream(params);
          if (params.getPlaintextInputStream() instanceof DataInputStream) {
            decryptingInput = (DataInputStream) params.getPlaintextInputStream();
          } else {
            decryptingInput = new DataInputStream(params.getPlaintextInputStream());
          }
        }

      } else {
View Full Code Here


          .getConfiguration().get(Property.CRYPTO_MODULE_CLASS));

      // Initialize the log file with a header and the crypto params used to set up this log file.
      logFile.write(LOG_FILE_HEADER_V3.getBytes(Constants.UTF8));

      CryptoModuleParameters params = CryptoModuleFactory.createParamsObjectFromAccumuloConfiguration(conf.getConfiguration());

      NoFlushOutputStream nfos = new NoFlushOutputStream(logFile);
      params.setPlaintextOutputStream(nfos);

      // In order to bootstrap the reading of this file later, we have to record the CryptoModule that was used to encipher it here,
      // so that that crypto module can re-read its own parameters.

      logFile.writeUTF(conf.getConfiguration().get(Property.CRYPTO_MODULE_CLASS));

      params = cryptoModule.getEncryptingOutputStream(params);
      OutputStream encipheringOutputStream = params.getEncryptedOutputStream();

      // If the module just kicks back our original stream, then just use it, don't wrap it in
      // another data OutputStream.
      if (encipheringOutputStream == nfos) {
        log.debug("No enciphering, using raw output stream");
View Full Code Here

      // additional parameters it needs from the underlying stream.
      String cryptoModuleClassname = input.readUTF();
      CryptoModule cryptoModule = CryptoModuleFactory.getCryptoModule(cryptoModuleClassname);

      // Create the parameters and set the input stream into those parameters
      CryptoModuleParameters params = CryptoModuleFactory.createParamsObjectFromAccumuloConfiguration(conf);
      params.setEncryptedInputStream(input);

      // Create the plaintext input stream from the encrypted one
      params = cryptoModule.getDecryptingInputStream(params);

      if (params.getPlaintextInputStream() instanceof DataInputStream) {
        decryptingInput = (DataInputStream) params.getPlaintextInputStream();
      } else {
        decryptingInput = new DataInputStream(params.getPlaintextInputStream());
      }
    } else {
      input.seek(0);
      byte[] magicV2 = DfsLogger.LOG_FILE_HEADER_V2.getBytes();
      byte[] magicBufferV2 = new byte[magic.length];
      input.readFully(magicBufferV2);

      if (Arrays.equals(magicBufferV2, magicV2)) {
        // Log files from 1.5 dump their options in raw to the logger files. Since we don't know the class
        // that needs to read those files, we can make a couple of basic assumptions. Either it's going to be
        // the NullCryptoModule (no crypto) or the DefaultCryptoModule.

        // If it's null, we won't have any parameters whatsoever. First, let's attempt to read
        // parameters
        Map<String,String> opts = new HashMap<String,String>();
        int count = input.readInt();
        for (int i = 0; i < count; i++) {
          String key = input.readUTF();
          String value = input.readUTF();
          opts.put(key, value);
        }

        if (opts.size() == 0) {
          // NullCryptoModule, we're done
          decryptingInput = input;
        } else {

          // The DefaultCryptoModule will want to read the parameters from the underlying file, so we will put the file back to that spot.
          org.apache.accumulo.core.security.crypto.CryptoModule cryptoModule = org.apache.accumulo.core.security.crypto.CryptoModuleFactory
              .getCryptoModule(DefaultCryptoModule.class.getName());

          CryptoModuleParameters params = CryptoModuleFactory.createParamsObjectFromAccumuloConfiguration(conf);

          input.seek(0);
          input.readFully(magicBuffer);
          params.setEncryptedInputStream(input);

          params = cryptoModule.getDecryptingInputStream(params);
          if (params.getPlaintextInputStream() instanceof DataInputStream) {
            decryptingInput = (DataInputStream) params.getPlaintextInputStream();
          } else {
            decryptingInput = new DataInputStream(params.getPlaintextInputStream());
          }
        }

      } else {
View Full Code Here

          .getConfiguration().get(Property.CRYPTO_MODULE_CLASS));

      // Initialize the log file with a header and the crypto params used to set up this log file.
      logFile.write(LOG_FILE_HEADER_V3.getBytes(Constants.UTF8));

      CryptoModuleParameters params = CryptoModuleFactory.createParamsObjectFromAccumuloConfiguration(conf.getConfiguration());

      NoFlushOutputStream nfos = new NoFlushOutputStream(logFile);
      params.setPlaintextOutputStream(nfos);

      // In order to bootstrap the reading of this file later, we have to record the CryptoModule that was used to encipher it here,
      // so that that crypto module can re-read its own parameters.

      logFile.writeUTF(conf.getConfiguration().get(Property.CRYPTO_MODULE_CLASS));

      params = cryptoModule.getEncryptingOutputStream(params);
      OutputStream encipheringOutputStream = params.getEncryptedOutputStream();

      // If the module just kicks back our original stream, then just use it, don't wrap it in
      // another data OutputStream.
      if (encipheringOutputStream == nfos) {
        log.debug("No enciphering, using raw output stream");
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.security.crypto.CryptoModuleParameters

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.