-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
14 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
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
48 changes: 48 additions & 0 deletions
48
...ver/src/main/java/org/eclipse/edc/iam/identitytrust/sts/server/StsVaultSeedExtension.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,48 @@ | ||
/* | ||
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.iam.identitytrust.sts.server; | ||
|
||
import org.eclipse.edc.runtime.metamodel.annotation.Inject; | ||
import org.eclipse.edc.spi.security.Vault; | ||
import org.eclipse.edc.spi.system.ServiceExtension; | ||
import org.eclipse.edc.spi.system.ServiceExtensionContext; | ||
|
||
import java.util.Map; | ||
|
||
public class StsVaultSeedExtension implements ServiceExtension { | ||
|
||
|
||
public static final String VAULT_TESTING_PREFIX = "edc.sts.server.vaults"; | ||
|
||
public static final String VAULT_TESTING_KEY = "key"; | ||
public static final String VAULT_TESTING_VALUE = "value"; | ||
|
||
@Inject | ||
private Vault vault; | ||
|
||
|
||
@Override | ||
public void initialize(ServiceExtensionContext context) { | ||
|
||
var config = context.getConfig(VAULT_TESTING_PREFIX); | ||
var secrets = config.partition().map((partition) -> { | ||
var key = partition.getString(VAULT_TESTING_KEY); | ||
var value = partition.getString(VAULT_TESTING_VALUE); | ||
return Map.entry(key, value); | ||
}).toList(); | ||
|
||
secrets.forEach(secret -> vault.storeSecret(secret.getKey(), secret.getValue())); | ||
} | ||
} |
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