-
Notifications
You must be signed in to change notification settings - Fork 245
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
22 changed files
with
912 additions
and
23 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
59 changes: 59 additions & 0 deletions
59
...s-api/src/main/java/org/eclipse/edc/connector/api/sts/SecureTokenServiceApiExtension.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,59 @@ | ||
/* | ||
* 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.connector.api.sts; | ||
|
||
import org.eclipse.edc.connector.api.sts.configuration.StsApiConfiguration; | ||
import org.eclipse.edc.connector.api.sts.controller.SecureTokenServiceApiController; | ||
import org.eclipse.edc.connector.api.sts.validation.StsTokenRequestValidator; | ||
import org.eclipse.edc.iam.identitytrust.sts.service.StsClientService; | ||
import org.eclipse.edc.iam.identitytrust.sts.service.StsClientTokenGeneratorService; | ||
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.edc.web.spi.WebService; | ||
|
||
@Extension(SecureTokenServiceApiExtension.NAME) | ||
public class SecureTokenServiceApiExtension implements ServiceExtension { | ||
|
||
public static final String NAME = "Secure Token Service API"; | ||
|
||
|
||
@Inject | ||
private StsApiConfiguration stsApiConfiguration; | ||
|
||
@Inject | ||
private StsClientService clientService; | ||
|
||
@Inject | ||
private StsClientTokenGeneratorService tokenService; | ||
|
||
@Inject | ||
private Monitor monitor; | ||
|
||
@Inject | ||
private WebService webService; | ||
|
||
@Override | ||
public String name() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public void initialize(ServiceExtensionContext context) { | ||
webService.registerResource(stsApiConfiguration.getContextAlias(), new SecureTokenServiceApiController(clientService, tokenService, new StsTokenRequestValidator())); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...sts-api/src/main/java/org/eclipse/edc/connector/api/sts/StsApiConfigurationExtension.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,59 @@ | ||
/* | ||
* 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.connector.api.sts; | ||
|
||
import org.eclipse.edc.connector.api.sts.configuration.StsApiConfiguration; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Extension; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Inject; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Provides; | ||
import org.eclipse.edc.spi.system.ServiceExtension; | ||
import org.eclipse.edc.spi.system.ServiceExtensionContext; | ||
import org.eclipse.edc.web.spi.WebServer; | ||
import org.eclipse.edc.web.spi.configuration.WebServiceConfigurer; | ||
import org.eclipse.edc.web.spi.configuration.WebServiceSettings; | ||
|
||
@Extension(value = StsApiConfigurationExtension.NAME) | ||
@Provides({ StsApiConfiguration.class }) | ||
public class StsApiConfigurationExtension implements ServiceExtension { | ||
|
||
public static final String NAME = "Secure Token Service API configuration"; | ||
public static final String STS_CONTEXT_ALIAS = "sts"; | ||
private static final String WEB_SERVICE_NAME = "STS API"; | ||
private static final int DEFAULT_STS_API_PORT = 9292; | ||
private static final String DEFAULT_STS_API_CONTEXT_PATH = "/api/v1/sts"; | ||
public static final WebServiceSettings SETTINGS = WebServiceSettings.Builder.newInstance() | ||
.apiConfigKey("web.http." + STS_CONTEXT_ALIAS) | ||
.contextAlias(STS_CONTEXT_ALIAS) | ||
.defaultPath(DEFAULT_STS_API_CONTEXT_PATH) | ||
.defaultPort(DEFAULT_STS_API_PORT) | ||
.useDefaultContext(true) | ||
.name(WEB_SERVICE_NAME) | ||
.build(); | ||
@Inject | ||
private WebServer webServer; | ||
@Inject | ||
private WebServiceConfigurer configurator; | ||
|
||
@Override | ||
public String name() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public void initialize(ServiceExtensionContext context) { | ||
var config = configurator.configure(context, webServer, SETTINGS); | ||
context.registerService(StsApiConfiguration.class, new StsApiConfiguration(config)); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...pi/src/main/java/org/eclipse/edc/connector/api/sts/configuration/StsApiConfiguration.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,26 @@ | ||
/* | ||
* 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.connector.api.sts.configuration; | ||
|
||
import org.eclipse.edc.web.spi.configuration.WebServiceConfiguration; | ||
|
||
public class StsApiConfiguration extends WebServiceConfiguration { | ||
|
||
public StsApiConfiguration(WebServiceConfiguration webServiceConfiguration) { | ||
this.contextAlias = webServiceConfiguration.getContextAlias(); | ||
this.path = webServiceConfiguration.getPath(); | ||
this.port = webServiceConfiguration.getPort(); | ||
} | ||
} |
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
Oops, something went wrong.