-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java: Fetch user data based on yaml/properties configuration in Sprin…
…g Boot applications (#1147)
- Loading branch information
1 parent
f606ac9
commit e29887a
Showing
29 changed files
with
878 additions
and
267 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
41 changes: 41 additions & 0 deletions
41
packages/java/examples/OwlTestApp/src/main/resources/application.yaml
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,41 @@ | ||
readme: | ||
readmeApiKey: ${README_API_KEY} | ||
userdata: | ||
apiKey: | ||
source: header | ||
fieldName: X-User-Name | ||
email: | ||
source: header | ||
fieldName: X-User-Email | ||
label: | ||
source: header | ||
fieldName: X-User-Id | ||
|
||
#readme: | ||
# readmeApiKey: ${README_API_KEY} | ||
# userdata: | ||
# apiKey: | ||
# source: jsonBody | ||
# fieldName: /owl-creator/name | ||
# email: | ||
# source: jsonBody | ||
# fieldName: /owl-creator/contacts/email | ||
# label: | ||
# source: jsonBody | ||
# fieldName: owl-creator/label | ||
|
||
#readme: | ||
# readmeApiKey: ${README_API_KEY} | ||
# userdata: | ||
# apiKey: | ||
# source: jwt | ||
# fieldName: name | ||
# email: | ||
# source: jwt | ||
# fieldName: aud | ||
# label: | ||
# source: jwt | ||
# fieldName: user_id | ||
|
||
|
||
|
13 changes: 0 additions & 13 deletions
13
...es/java/examples/OwlTestApp/src/test/java/com/readme/example/ExampleApplicationTests.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
43 changes: 43 additions & 0 deletions
43
...boot-starter/src/main/java/com/readme/starter/config/DataCollectionAutoConfiguration.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,43 @@ | ||
package com.readme.starter.config; | ||
|
||
import com.readme.dataextraction.RequestDataCollector; | ||
import com.readme.dataextraction.UserDataCollector; | ||
import com.readme.starter.datacollection.DataCollectionFilter; | ||
import com.readme.starter.datacollection.ServletDataPayloadAdapter; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.Ordered; | ||
|
||
/** | ||
* Configuration class for registering and initializing the JakartaDataCollectionFilter | ||
* along with its dependencies in a Spring Boot application. | ||
* <p> | ||
* This configuration provides the following: | ||
* <ul> | ||
* <li>Instantiates the {@link DataCollectionFilter} with required collectors.</li> | ||
* <li>Registers the filter using {@link FilterRegistrationBean} for servlet-based applications.</li> | ||
* <li>Sets up default implementations for collecting request and user data.</li> | ||
* </ul> | ||
*/ | ||
@Configuration | ||
@ConditionalOnClass({UserDataProperties.class}) | ||
@ComponentScan(basePackages = {"com.readme.starter"}) | ||
@AllArgsConstructor | ||
public class DataCollectionAutoConfiguration { | ||
|
||
@Bean | ||
public FilterRegistrationBean<DataCollectionFilter> metricsFilter( | ||
RequestDataCollector<ServletDataPayloadAdapter> requestDataCollector, | ||
UserDataCollector<ServletDataPayloadAdapter> userDataCollector) { | ||
FilterRegistrationBean<DataCollectionFilter> registrationBean = new FilterRegistrationBean<>(); | ||
registrationBean.setFilter(new DataCollectionFilter(requestDataCollector, userDataCollector)); | ||
registrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); | ||
registrationBean.addUrlPatterns("/*"); | ||
return registrationBean; | ||
} | ||
|
||
} |
70 changes: 0 additions & 70 deletions
70
...ing-boot-starter/src/main/java/com/readme/starter/config/JakartaDataCollectionConfig.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
...g-boot-starter/src/main/java/com/readme/starter/config/ReadmeConfigurationProperties.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,14 @@ | ||
package com.readme.starter.config; | ||
|
||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Data | ||
@Component | ||
@ConfigurationProperties(prefix = "readme") | ||
public class ReadmeConfigurationProperties { | ||
|
||
private String readmeApiKey; | ||
|
||
} |
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.