-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement PresentationGenerator (#172)
* feat: implement PresentationGenerator for JWT-VP and LDP-VP * cleanup * checkstyle * DEPENDENCIES * added tests, and some cleamup * add presentation submission context * Update core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationCreator.java Co-authored-by: Enrico Risa <enrico.risa@gmail.com> --------- Co-authored-by: Enrico Risa <enrico.risa@gmail.com>
- Loading branch information
1 parent
ffb40a0
commit 3d5c122
Showing
29 changed files
with
2,770 additions
and
28 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
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
51 changes: 51 additions & 0 deletions
51
...-core/src/main/java/org/eclipse/edc/identityhub/core/PresentationCreatorRegistryImpl.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,51 @@ | ||
/* | ||
* Copyright (c) 2023 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.identityhub.core; | ||
|
||
import org.eclipse.edc.identityhub.spi.generator.PresentationCreator; | ||
import org.eclipse.edc.identityhub.spi.generator.PresentationCreatorRegistry; | ||
import org.eclipse.edc.identitytrust.model.CredentialFormat; | ||
import org.eclipse.edc.identitytrust.model.VerifiableCredentialContainer; | ||
import org.eclipse.edc.spi.EdcException; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static java.util.Optional.ofNullable; | ||
|
||
public class PresentationCreatorRegistryImpl implements PresentationCreatorRegistry { | ||
|
||
private final Map<CredentialFormat, PresentationCreator<?>> creators = new HashMap<>(); | ||
private final Map<CredentialFormat, String> keyIds = new HashMap<>(); | ||
|
||
@Override | ||
public void addCreator(PresentationCreator<?> creator, CredentialFormat format) { | ||
creators.put(format, creator); | ||
} | ||
|
||
@Override | ||
public <T> T createPresentation(List<VerifiableCredentialContainer> credentials, CredentialFormat format) { | ||
var creator = ofNullable(creators.get(format)).orElseThrow(() -> new EdcException("No PresentationCreator was found for CredentialFormat %s".formatted(format))); | ||
var keyId = ofNullable(keyIds.get(format)).orElseThrow(() -> new EdcException("No key ID was registered for CredentialFormat %s".formatted(format))); | ||
|
||
return (T) creator.createPresentation(credentials, keyId); | ||
} | ||
|
||
@Override | ||
public void addKeyId(String keyId, CredentialFormat format) { | ||
keyIds.put(format, keyId); | ||
} | ||
} |
Oops, something went wrong.