All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opensearch.common.crypto.DecryptedRangedStreamProvider Maven / Gradle / Ivy

/*
 * SPDX-License-Identifier: Apache-2.0
 *
 * The OpenSearch Contributors require contributions made to
 * this file be licensed under the Apache-2.0 license or a
 * compatible open source license.
 */

package org.opensearch.common.crypto;

import java.io.InputStream;
import java.util.function.UnaryOperator;

/**
 * Contains adjusted range of partial encrypted content which needs to be used for decryption.
 */
public class DecryptedRangedStreamProvider {

    /** Adjusted range of partial encrypted content which needs to be used for decryption. */
    private final long[] adjustedRange;
    /** Stream provider for decryption and range re-adjustment. */
    private final UnaryOperator decryptedStreamProvider;

    /**
     * To construct adjusted encrypted range.
     * @param adjustedRange range of partial encrypted content which needs to be used for decryption.
     * @param decryptedStreamProvider stream provider for decryption and range re-adjustment.
     */
    public DecryptedRangedStreamProvider(long[] adjustedRange, UnaryOperator decryptedStreamProvider) {
        this.adjustedRange = adjustedRange;
        this.decryptedStreamProvider = decryptedStreamProvider;
    }

    /**
     * Adjusted range of partial encrypted content which needs to be used for decryption.
     * @return adjusted range
     */
    public long[] getAdjustedRange() {
        return adjustedRange;
    }

    /**
     * A utility stream provider which supplies the stream responsible for decrypting the content and reading the
     * desired range of decrypted content by skipping extra content which got decrypted as a result of range adjustment.
     * @return stream provider for decryption and supplying the desired range of content.
     */
    public UnaryOperator getDecryptedStreamProvider() {
        return decryptedStreamProvider;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy