Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Feb 8, 2024
2 parents b7e970c + 3f4ccd0 commit 2881750
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.evolveum.midpoint.prism.crypto;

import com.evolveum.prism.xml.ns._public.types_3.EncryptedDataType;
import com.evolveum.prism.xml.ns._public.types_3.ExternalDataType;
import com.evolveum.prism.xml.ns._public.types_3.HashedDataType;

/**
Expand All @@ -30,6 +31,10 @@ public interface ProtectedData<T> {

void setEncryptedData(EncryptedDataType encryptedDataType);

ExternalDataType getExternalData();

void setExternalData(ExternalDataType externalDataType);

boolean isEncrypted();

HashedDataType getHashedDataType();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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.nio.ByteBuffer;

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<C> {

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

/**
* 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 list of providers that this provider depends on.
* The provider will be initialized after all dependencies are available and initialized.
*/
@NotNull String[] getDependencies();

/**
* Returns configuration of the provider.
*/
C getConfiguration();

/**
* 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) {
return null;
}
return ByteBuffer.wrap(secretString.getBytes());
}
}
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 SecretsResolver {

/**
* @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();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.02.04 at 01:34:24 PM CET
//

package com.evolveum.prism.xml.ns._public.types_3;

import java.io.Serializable;
import java.util.Objects;

import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlType;

import com.evolveum.midpoint.prism.JaxbVisitable;
import com.evolveum.midpoint.prism.JaxbVisitor;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ExternalDataType", propOrder = {
"provider",
"key",
})
public class ExternalDataType implements Serializable, Cloneable, JaxbVisitable {

protected String provider;
protected String key;

public String getProvider() {
return provider;
}

public void setProvider(String value) {
this.provider = value;
}

public String getKey() {
return key;
}

public void setKey(String value) {
this.key = value;
}

@Override
public boolean equals(Object o) {
if (this == o) {return true;}
if (o == null || getClass() != o.getClass()) {return false;}
ExternalDataType that = (ExternalDataType) o;
return Objects.equals(provider, that.provider) && Objects.equals(key, that.key);
}

@Override
public int hashCode() {
return Objects.hash(provider, key);
}

@Override
public String toString() {
return "ExternalDataType(provider=" + provider + ", key=" + key + ")";
}

@Override
public ExternalDataType clone() {
ExternalDataType cloned = new ExternalDataType();
cloned.setProvider(getProvider());
cloned.setKey(getKey());
return cloned;
}

@Override
public void accept(JaxbVisitor visitor) {
visitor.visit(this);
}
}

0 comments on commit 2881750

Please sign in to comment.