-
Notifications
You must be signed in to change notification settings - Fork 244
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
7 changed files
with
289 additions
and
1 deletion.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
extensions/common/iam/identity-trust/identity-trust-sts-api/build.gradle.kts
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) 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 | ||
* | ||
*/ | ||
|
||
plugins { | ||
`java-library` | ||
`maven-publish` | ||
id("io.swagger.core.v3.swagger-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
api(project(":spi:common:web-spi")) | ||
|
||
implementation(libs.jakarta.rsApi) | ||
implementation(libs.swagger.annotations.jakarta) | ||
|
||
testImplementation(libs.jersey.common) | ||
testImplementation(libs.jersey.server) | ||
|
||
testImplementation(project(":core:common:junit")) | ||
testImplementation(testFixtures(project(":extensions:common:http:jersey-core"))) | ||
} | ||
|
42 changes: 42 additions & 0 deletions
42
...-trust-sts-api/src/main/java/org/eclipse/edc/connector/api/sts/SecureTokenServiceApi.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,42 @@ | ||
/* | ||
* 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 io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.ArraySchema; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.ws.rs.BeanParam; | ||
import org.eclipse.edc.connector.api.sts.model.StsAccessToken; | ||
import org.eclipse.edc.connector.api.sts.model.StsTokenRequest; | ||
import org.eclipse.edc.connector.api.sts.model.StsTokenRequestError; | ||
|
||
@OpenAPIDefinition | ||
@Tag(name = "Secure Token Service Api") | ||
public interface SecureTokenServiceApi { | ||
|
||
|
||
@Operation(description = "", | ||
responses = { | ||
@ApiResponse(responseCode = "200", description = "The Self-Issued ID token", | ||
content = @Content(schema = @Schema(implementation = StsAccessToken.class))), | ||
@ApiResponse(responseCode = "400", description = "Invalid Request", | ||
content = @Content(array = @ArraySchema(schema = @Schema(implementation = StsTokenRequestError.class)))) | ||
}) | ||
StsAccessToken token(@BeanParam StsTokenRequest request); | ||
} |
38 changes: 38 additions & 0 deletions
38
...in/java/org/eclipse/edc/connector/api/sts/controller/SecureTokenServiceApiController.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,38 @@ | ||
/* | ||
* 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.controller; | ||
|
||
import jakarta.ws.rs.BeanParam; | ||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
import org.eclipse.edc.connector.api.sts.SecureTokenServiceApi; | ||
import org.eclipse.edc.connector.api.sts.model.StsAccessToken; | ||
import org.eclipse.edc.connector.api.sts.model.StsTokenRequest; | ||
|
||
@Path("/") | ||
public class SecureTokenServiceApiController implements SecureTokenServiceApi { | ||
|
||
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED }) | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
@Path("token") | ||
@POST | ||
@Override | ||
public StsAccessToken token(@BeanParam StsTokenRequest request) { | ||
return null; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...y-trust-sts-api/src/main/java/org/eclipse/edc/connector/api/sts/model/StsAccessToken.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,42 @@ | ||
/* | ||
* 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.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class StsAccessToken { | ||
|
||
@JsonProperty("access_token") | ||
private String accessToken; | ||
|
||
@JsonProperty("tokenType") | ||
private String tokenType = "Bearer"; | ||
|
||
@JsonProperty("expires_in") | ||
private long expiresIn; | ||
|
||
|
||
public long getExpiresIn() { | ||
return expiresIn; | ||
} | ||
|
||
public String getAccessToken() { | ||
return accessToken; | ||
} | ||
|
||
public String getTokenType() { | ||
return tokenType; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...-trust-sts-api/src/main/java/org/eclipse/edc/connector/api/sts/model/StsTokenRequest.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,56 @@ | ||
/* | ||
* 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.model; | ||
|
||
import jakarta.ws.rs.FormParam; | ||
|
||
public class StsTokenRequest { | ||
|
||
@FormParam("grant_type") | ||
private String grantType; | ||
|
||
@FormParam("client_id") | ||
private String clientId; | ||
|
||
@FormParam("client_secret") | ||
private String clientSecret; | ||
|
||
@FormParam("bearer_access_scope") | ||
private String bearerAccessScope; | ||
|
||
@FormParam("access_token") | ||
private String accessToken; | ||
|
||
public String getGrantType() { | ||
return grantType; | ||
} | ||
|
||
|
||
public String getClientId() { | ||
return clientId; | ||
} | ||
|
||
public String getClientSecret() { | ||
return clientSecret; | ||
} | ||
|
||
public String getBearerAccessScope() { | ||
return bearerAccessScope; | ||
} | ||
|
||
public String getAccessToken() { | ||
return accessToken; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...t-sts-api/src/main/java/org/eclipse/edc/connector/api/sts/model/StsTokenRequestError.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,77 @@ | ||
/* | ||
* Copyright (c) 2022 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.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
|
||
public class StsTokenRequestError { | ||
|
||
@JsonProperty | ||
private String error; | ||
@JsonProperty | ||
private String errorDescription; | ||
@JsonProperty | ||
private String errorUri; | ||
|
||
private StsTokenRequestError() { | ||
|
||
} | ||
|
||
public String getError() { | ||
return error; | ||
} | ||
|
||
public String getErrorDescription() { | ||
return errorDescription; | ||
} | ||
|
||
public String getErrorUri() { | ||
return errorUri; | ||
} | ||
|
||
|
||
public static class Builder { | ||
|
||
private final StsTokenRequestError apiError = new StsTokenRequestError(); | ||
|
||
private Builder() { | ||
} | ||
|
||
public static Builder newInstance() { | ||
return new Builder(); | ||
} | ||
|
||
public Builder error(String message) { | ||
apiError.error = message; | ||
return this; | ||
} | ||
|
||
public Builder errorDescription(String type) { | ||
apiError.errorDescription = type; | ||
return this; | ||
} | ||
|
||
public Builder errorUri(String path) { | ||
apiError.errorUri = path; | ||
return this; | ||
} | ||
|
||
|
||
public StsTokenRequestError build() { | ||
return apiError; | ||
} | ||
} | ||
} |
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