Package com.alibaba.otter.node.etl.common.io

Examples of com.alibaba.otter.node.etl.common.io.EncryptedData


        key.setDataType(PipeDataType.DB_BATCH);
        key.setIdentity(rowBatch.getIdentity());
        Pipeline pipeline = configClientService.findPipeline(rowBatch.getIdentity().getPipelineId());
        if (pipeline.getParameters().getUseFileEncrypt()) {
            // 加密处理
            EncryptedData encryptedData = encryptFile(file);
            key.setKey(encryptedData.getKey());
            key.setCrc(encryptedData.getCrc());
        }

        return key;
    }
View Full Code Here


        }, DEFAULT_PERIOD, DEFAULT_PERIOD, TimeUnit.MILLISECONDS);
    }

    protected EncryptedData encryptFile(File file) {
        // 构造校验对象,这里考虑性能只将file path做为加密源
        EncryptedData encryptedData = null;
        try {
            encryptedData = EncryptUtils.encrypt(file.getPath().getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            // ignore
        }

        // 写入校验信息
        RandomAccessFile raf = null;
        try {
            raf = new RandomAccessFile(file, "rw");
            long origLength = file.length();
            int keyLength = ByteUtils.stringToBytes(encryptedData.getKey()).length;
            int crcLength = ByteUtils.stringToBytes(encryptedData.getCrc()).length;
            long totalLength = origLength + crcLength + keyLength;
            raf.setLength(totalLength);
            raf.seek(origLength);
            raf.write(ByteUtils.stringToBytes(encryptedData.getKey()), 0, keyLength);
            raf.seek(origLength + keyLength);
            raf.write(ByteUtils.stringToBytes(encryptedData.getCrc()), 0, crcLength);
        } catch (Exception e) {
            throw new PipeException("write_encrypted_error", e);
        } finally {
            IOUtils.closeQuietly(raf);
        }
View Full Code Here

        key.setUrl(remoteUrlBuilder.getUrl(fileBatch.getIdentity().getPipelineId(), filename));
        key.setDataType(PipeDataType.FILE_BATCH);
        key.setIdentity(fileBatch.getIdentity());
        if (encrypt || pipeline.getParameters().getUseFileEncrypt()) {
            // 加密处理
            EncryptedData encryptedData = encryptFile(file);
            key.setKey(encryptedData.getKey());
            key.setCrc(encryptedData.getCrc());
        }
        return key;
    }
View Full Code Here

        key.setDataType(PipeDataType.DB_BATCH);
        key.setIdentity(rowBatch.getIdentity());
        Pipeline pipeline = configClientService.findPipeline(rowBatch.getIdentity().getPipelineId());
        if (pipeline.getParameters().getUseFileEncrypt()) {
            // 加密处理
            EncryptedData encryptedData = encryptFile(file);
            key.setKey(encryptedData.getKey());
            key.setCrc(encryptedData.getCrc());
        }

        return key;
    }
View Full Code Here

        key.setDataType(PipeDataType.DB_BATCH);
        key.setIdentity(rowBatch.getIdentity());
        Pipeline pipeline = configClientService.findPipeline(rowBatch.getIdentity().getPipelineId());
        if (pipeline.getParameters().getUseFileEncrypt()) {
            // 加密处理
            EncryptedData encryptedData = encryptFile(file);
            key.setKey(encryptedData.getKey());
            key.setCrc(encryptedData.getCrc());
        }

        return key;
    }
View Full Code Here

TOP

Related Classes of com.alibaba.otter.node.etl.common.io.EncryptedData

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.