-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
9 changed files
with
309 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
infra/prism-api/src/main/java/com/evolveum/midpoint/prism/crypto/SecretsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
infra/prism-api/src/main/java/com/evolveum/midpoint/prism/crypto/SecretsResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
83 changes: 83 additions & 0 deletions
83
...a/prism-api/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/ExternalDataType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.