-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ssi): add credential issuer and credential subject id validation…
… rules (#548) * feat(Ssi): add credential issuer and credential subject id validation rules * fix after review * fix helm tests
- Loading branch information
Showing
30 changed files
with
837 additions
and
160 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
97 changes: 0 additions & 97 deletions
97
...c/test/java/org/eclipse/tractusx/edc/iam/ssi/identity/extractor/fixtures/Credentials.java
This file was deleted.
Oops, something went wrong.
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
63 changes: 63 additions & 0 deletions
63
...ient/src/main/java/org/eclipse/tractusx/edc/iam/ssi/miw/SsiMiwConfigurationExtension.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,63 @@ | ||
/* | ||
* 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.tractusx.edc.iam.ssi.miw; | ||
|
||
import org.eclipse.edc.runtime.metamodel.annotation.Extension; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Provider; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Setting; | ||
import org.eclipse.edc.spi.system.ServiceExtension; | ||
import org.eclipse.edc.spi.system.ServiceExtensionContext; | ||
import org.eclipse.tractusx.edc.iam.ssi.miw.config.SsiMiwConfiguration; | ||
|
||
import java.net.URI; | ||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import static java.lang.String.format; | ||
|
||
|
||
@Extension(SsiMiwConfigurationExtension.EXTENSION_NAME) | ||
public class SsiMiwConfigurationExtension implements ServiceExtension { | ||
|
||
|
||
@Setting(value = "MIW API base url") | ||
public static final String MIW_BASE_URL = "tx.ssi.miw.url"; | ||
@Setting(value = "MIW Authority ID") | ||
public static final String MIW_AUTHORITY_ID = "tx.ssi.miw.authority.id"; | ||
@Setting(value = "MIW Authority Issuer") | ||
public static final String MIW_AUTHORITY_ISSUER = "tx.ssi.miw.authority.issuer"; | ||
public static final String AUTHORITY_ID_TEMPLATE = "did:web:%s:%s"; | ||
protected static final String EXTENSION_NAME = "SSI Miw configuration extension"; | ||
|
||
@Provider | ||
public SsiMiwConfiguration miwConfiguration(ServiceExtensionContext context) { | ||
var baseUrl = context.getConfig().getString(MIW_BASE_URL); | ||
var authorityId = context.getConfig().getString(MIW_AUTHORITY_ID); | ||
var authorityIssuer = authorityIssuer(context, baseUrl, authorityId); | ||
|
||
return SsiMiwConfiguration.Builder.newInstance() | ||
.url(baseUrl) | ||
.authorityId(authorityId) | ||
.authorityIssuer(authorityIssuer) | ||
.build(); | ||
} | ||
|
||
|
||
private String authorityIssuer(ServiceExtensionContext context, String baseUrl, String authorityId) { | ||
var uri = URI.create(baseUrl); | ||
var defaultAuthorityIssuer = format(AUTHORITY_ID_TEMPLATE, URLEncoder.encode(uri.getAuthority(), StandardCharsets.UTF_8), authorityId); | ||
return context.getConfig().getString(MIW_AUTHORITY_ISSUER, defaultAuthorityIssuer); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...ent/src/main/java/org/eclipse/tractusx/edc/iam/ssi/miw/SsiMiwValidationRuleExtension.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,50 @@ | ||
/* | ||
* 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.tractusx.edc.iam.ssi.miw; | ||
|
||
import org.eclipse.edc.runtime.metamodel.annotation.Extension; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Inject; | ||
import org.eclipse.edc.spi.monitor.Monitor; | ||
import org.eclipse.edc.spi.system.ServiceExtension; | ||
import org.eclipse.edc.spi.system.ServiceExtensionContext; | ||
import org.eclipse.tractusx.edc.iam.ssi.miw.config.SsiMiwConfiguration; | ||
import org.eclipse.tractusx.edc.iam.ssi.miw.rule.SsiCredentialIssuerValidationRule; | ||
import org.eclipse.tractusx.edc.iam.ssi.miw.rule.SsiCredentialSubjectIdValidationRule; | ||
import org.eclipse.tractusx.edc.iam.ssi.spi.SsiValidationRuleRegistry; | ||
|
||
@Extension(SsiMiwValidationRuleExtension.EXTENSION_NAME) | ||
public class SsiMiwValidationRuleExtension implements ServiceExtension { | ||
|
||
protected static final String EXTENSION_NAME = "SSI MIW validation rules extension"; | ||
@Inject | ||
private SsiValidationRuleRegistry registry; | ||
|
||
@Inject | ||
private Monitor monitor; | ||
|
||
@Inject | ||
private SsiMiwConfiguration miwConfiguration; | ||
|
||
@Override | ||
public String name() { | ||
return EXTENSION_NAME; | ||
} | ||
|
||
@Override | ||
public void initialize(ServiceExtensionContext context) { | ||
registry.addRule(new SsiCredentialSubjectIdValidationRule(monitor)); | ||
registry.addRule(new SsiCredentialIssuerValidationRule(miwConfiguration.getAuthorityIssuer(), monitor)); | ||
} | ||
} |
Oops, something went wrong.