-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from bci-oss/feature/self-registration-to-disco…
…very-Finder Self-registration-Implementation
- Loading branch information
Showing
28 changed files
with
993 additions
and
50 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
46 changes: 46 additions & 0 deletions
46
backend/src/main/java/org/eclipse/tractusx/bpndiscovery/ApplicationReadyEventListener.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,46 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.bpndiscovery; | ||
|
||
import org.eclipse.tractusx.bpndiscovery.service.RegisterService; | ||
import org.springframework.boot.context.event.ApplicationReadyEvent; | ||
import org.springframework.context.ApplicationListener; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Component; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Profile( "!test" ) | ||
@Component | ||
@Slf4j | ||
public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> { | ||
|
||
private final RegisterService registerService; | ||
|
||
public ApplicationReadyEventListener( RegisterService registerService ) { | ||
this.registerService = registerService; | ||
} | ||
|
||
@Override | ||
public void onApplicationEvent( ApplicationReadyEvent event ) { | ||
registerService.registerAfterStartup(); | ||
} | ||
|
||
} |
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
60 changes: 60 additions & 0 deletions
60
...d/src/main/java/org/eclipse/tractusx/bpndiscovery/DiscoveryFinderClientConfiguration.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,60 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.bpndiscovery; | ||
|
||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.oauth2.client.AuthorizedClientServiceOAuth2AuthorizedClientManager; | ||
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager; | ||
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientProvider; | ||
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientProviderBuilder; | ||
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService; | ||
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; | ||
import org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties( DiscoveryFinderClientProperties.class ) | ||
public class DiscoveryFinderClientConfiguration { | ||
|
||
@Bean | ||
WebClient webClient( OAuth2AuthorizedClientManager auth2AuthorizedClientManager, DiscoveryFinderClientProperties discoveryFinderProperties ) { | ||
|
||
ServletOAuth2AuthorizedClientExchangeFilterFunction oauth = new ServletOAuth2AuthorizedClientExchangeFilterFunction( auth2AuthorizedClientManager ); | ||
oauth.setDefaultClientRegistrationId( "discoveryfinder-client" ); | ||
return WebClient.builder().baseUrl( discoveryFinderProperties.getBaseUrl() ).apply( oauth.oauth2Configuration() ).build(); | ||
} | ||
|
||
@Bean | ||
OAuth2AuthorizedClientManager auth2AuthorizedClientManager( ClientRegistrationRepository clientRegistrationRepository, | ||
OAuth2AuthorizedClientService oAuth2AuthorizedClientService ) { | ||
|
||
OAuth2AuthorizedClientProvider auth2AuthorizedClientProvider = OAuth2AuthorizedClientProviderBuilder.builder() | ||
.authorizationCode().refreshToken().clientCredentials().build(); | ||
|
||
AuthorizedClientServiceOAuth2AuthorizedClientManager authorizedClientManager = | ||
new AuthorizedClientServiceOAuth2AuthorizedClientManager( clientRegistrationRepository, oAuth2AuthorizedClientService ); | ||
|
||
authorizedClientManager.setAuthorizedClientProvider( auth2AuthorizedClientProvider ); | ||
|
||
return authorizedClientManager; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
backend/src/main/java/org/eclipse/tractusx/bpndiscovery/DiscoveryFinderClientProperties.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,34 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.bpndiscovery; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.validation.annotation.Validated; | ||
|
||
import jakarta.validation.constraints.NotEmpty; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Validated | ||
@ConfigurationProperties( prefix = "discoveryfinder-client" ) | ||
public class DiscoveryFinderClientProperties { | ||
@NotEmpty( message = "baseUrl must not be empty" ) | ||
private String baseUrl; | ||
} |
50 changes: 50 additions & 0 deletions
50
...rc/main/java/org/eclipse/tractusx/bpndiscovery/dto/discoveryfinder/DiscoveryEndpoint.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 Robert Bosch Manufacturing Solutions GmbH | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.bpndiscovery.dto.discoveryfinder; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@Builder | ||
@AllArgsConstructor | ||
public class DiscoveryEndpoint { | ||
|
||
@JsonProperty( "type" ) | ||
private String type; | ||
|
||
@JsonProperty( "description" ) | ||
private String description; | ||
|
||
@JsonProperty( "endpointAddress" ) | ||
private String endpointAddress; | ||
|
||
@JsonProperty( "documentation" ) | ||
private String documentation; | ||
|
||
@JsonProperty( "resourceId" ) | ||
private String resourceId; | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...va/org/eclipse/tractusx/bpndiscovery/dto/discoveryfinder/DiscoveryEndpointCollection.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,47 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.bpndiscovery.dto.discoveryfinder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class DiscoveryEndpointCollection { | ||
|
||
@JsonProperty( "endpoints" ) | ||
private List<DiscoveryEndpoint> endpoints; | ||
|
||
public DiscoveryEndpointCollection addEndpointsItem( DiscoveryEndpoint endpointsItem ) { | ||
if ( this.endpoints == null ) { | ||
this.endpoints = new ArrayList<>(); | ||
} | ||
this.endpoints.add( endpointsItem ); | ||
return this; | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...nd/src/main/java/org/eclipse/tractusx/bpndiscovery/dto/discoveryfinder/SearchRequest.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,45 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.bpndiscovery.dto.discoveryfinder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import jakarta.validation.Valid; | ||
|
||
public class SearchRequest { | ||
|
||
@JsonProperty( "types" ) | ||
@Valid | ||
private List<String> types = new ArrayList<>(); | ||
|
||
public SearchRequest types( List<String> types ) { | ||
this.types = types; | ||
return this; | ||
} | ||
|
||
public SearchRequest addTypesItem( String typesItem ) { | ||
this.types.add( typesItem ); | ||
return this; | ||
} | ||
} | ||
|
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.