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

org.apache.nifi.properties.SensitivePropertyProvider Maven / Gradle / Ivy

There is a newer version: 2.0.0-M3
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.nifi.properties;

/**
 * Sensitive Property Provider abstracts persistence and retrieval of properties that require additional protection
 */
public interface SensitivePropertyProvider {
    /**
     * Returns the key used to identify the provider implementation in {@code nifi.properties}.
     *
     * @return the key to persist in the sibling property
     */
    String getIdentifierKey();

    /**
     * Returns whether this SensitivePropertyProvider is supported with the current system
     * configuration.
     * @return Whether this SensitivePropertyProvider is supported
     */
    boolean isSupported();

    /**
     * Returns the "protected" form of this value. This is a form which can safely be persisted in the {@code nifi.properties} file without compromising the value.
     * An encryption-based provider would return a cipher text, while a remote-lookup provider could return a unique ID to retrieve the secured value.
     *
     * @param unprotectedValue the sensitive value
     * @param context The context of the value
     * @return the value to persist in the {@code nifi.properties} file
     */
    String protect(String unprotectedValue, ProtectedPropertyContext context) throws SensitivePropertyProtectionException;

    /**
     * Returns the "unprotected" form of this value. This is the raw sensitive value which is used by the application logic.
     * An encryption-based provider would decrypt a cipher text and return the plaintext, while a remote-lookup provider could retrieve the secured value.
     *
     * @param protectedValue the protected value read from the {@code nifi.properties} file
     * @param context The context of the value
     * @return the raw value to be used by the application
     */
    String unprotect(String protectedValue, ProtectedPropertyContext context) throws SensitivePropertyProtectionException;

    /**
     * Cleans up resources that may have been allocated/used by an SPP implementation
     */
    void cleanUp();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy