Skip to content

Commit

Permalink
secrets provider: custom non-bundled connectors support, some javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Feb 7, 2024
1 parent 60e2a1b commit 951ff81
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,44 @@

import org.jetbrains.annotations.NotNull;

/**
* Interface for component that can resolve secrets from external secrets managers (e.g. instead of decrypting them).
*/
public interface SecretsProvider {

/**
* Post-construction initialization.
* Called before the provider is added to the list of usable providers.
*/
default void init() {
}

/**
* This method can be used to clean-up resources of secret provider.
* Called after provider was removed from the list of usable providers.
*/
default void destroy() {
}

/**
* Returns unique identifier of the provider.
*/
@NotNull String getIdentifier();

/**
* Returns secret {@link String} for given key.
* Returns null if the secret does not exist.
*
* @throws EncryptionException if the secret cannot be resolved (e.g. due to network problems)
*/
String getSecretString(@NotNull String key) throws EncryptionException;

/**
* Returns secret {@link ByteBuffer} for given key.
* Returns null if the secret does not exist.
*
* @throws EncryptionException if the secret cannot be resolved (e.g. due to network problems)
*/
default ByteBuffer getSecretBinary(@NotNull String key) throws EncryptionException {
String secretString = getSecretString(key);
if (secretString == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2010-2024 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.prism.crypto;

import java.util.List;

import org.jetbrains.annotations.NotNull;

/**
* Interface for component that can use initialized secret providers to resolve secrets (e.g. instead of decrypting them).
*/
public interface SecretsProviderConsumer {

/**
* @param provider Initialized provider to be added to the list of usable providers.
*/
void addSecretsProvider(@NotNull SecretsProvider provider);

/**
* @param provider Initialized provider to be removed from the list of usable providers.
*/
void removeSecretsProvider(@NotNull SecretsProvider provider);

/**
* @return List of usable secret providers.
*/
@NotNull List<SecretsProvider> getSecretsProviders();
}

0 comments on commit 951ff81

Please sign in to comment.