From c1ab281c19cc2a59f09f228009bdc3e0531d4777 Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Mon, 7 Sep 2026 15:25:00 +0100 Subject: [PATCH 01/13] add support for oic oauth operations --- .../requestfilters/AuthTokenResponse.java | 53 +++++++ .../rest/requestfilters/HttpAuthType.java | 5 + .../rest/requestfilters/IDCSException.java | 62 ++++++++ .../IDCSOAuthTokenRetrievalException.java | 63 ++++++++ ...TOutputHttpClientCommonFilterSettings.java | 9 ++ ...ientNormalizedDataBasicRequestFilter.java} | 7 +- ...lientNormalizedDataOauthRequestFilter.java | 93 +++++++++++ ...ppedNormalizedDataBasicRequestFilter.java} | 8 +- ...appedNormalizedDataOAuthRequestFilter.java | 93 +++++++++++ .../OICOAuthApplicationTokenRetriever.java | 144 ++++++++++++++++++ .../OICOAuthTokenRequester.java | 58 +++++++ 11 files changed, 589 insertions(+), 6 deletions(-) create mode 100644 IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/AuthTokenResponse.java create mode 100644 IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/HttpAuthType.java create mode 100644 IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IDCSException.java create mode 100644 IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IDCSOAuthTokenRetrievalException.java rename IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/{IoTOutputHttpOICClientNormalizedDataRequestFilter.java => IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java} (93%) create mode 100644 IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java rename IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/{IoTOutputHttpOICClientWrappedNormalizedDataRequestFilter.java => IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java} (93%) create mode 100644 IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java create mode 100644 IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java create mode 100644 IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthTokenRequester.java diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/AuthTokenResponse.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/AuthTokenResponse.java new file mode 100644 index 0000000..a3dcf36 --- /dev/null +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/AuthTokenResponse.java @@ -0,0 +1,53 @@ +/*Copyright (c) 2025 Oracle and/or its affiliates. + +The Universal Permissive License (UPL), Version 1.0 + +Subject to the condition set forth below, permission is hereby granted to any +person obtaining a copy of this software, associated documentation and/or data +(collectively the "Software"), free of charge and under any and all copyright +rights in the Software, and any and all patent rights owned or freely +licensable by each licensor hereunder covering either (i) the unmodified +Software as contributed to or provided by such licensor, or (ii) the Larger +Works (as defined below), to deal in both + +(a) the Software, and +(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if +one is included with the Software (each a "Larger Work" to which the Software +is contributed by such licensors), + +without restriction, including without limitation the rights to copy, create +derivative works of, display, perform, and distribute the Software and make, +use, sell, offer for sale, import, export, have made, and have sold the +Software and the Larger Work(s), and to sublicense the foregoing rights on +either these or other terms. + +This license is subject to the following condition: +The above copyright notice and either this complete permission notice or at +a minimum a reference to the UPL must be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + */ +package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.micronaut.serde.annotation.Serdeable; +import lombok.Data; + +@Serdeable +@Data +public class AuthTokenResponse { + @JsonProperty(value = "access_token") + private String accessToken; + @JsonProperty(value = "expires_in") + private int expiresIn; + @JsonProperty(value = "token_type") + private String tokenType; +} diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/HttpAuthType.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/HttpAuthType.java new file mode 100644 index 0000000..2d56691 --- /dev/null +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/HttpAuthType.java @@ -0,0 +1,5 @@ +package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; + +public enum HttpAuthType { + BASIC, OAUTH2 +} diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IDCSException.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IDCSException.java new file mode 100644 index 0000000..211c629 --- /dev/null +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IDCSException.java @@ -0,0 +1,62 @@ +/*Copyright (c) 2025 Oracle and/or its affiliates. + +The Universal Permissive License (UPL), Version 1.0 + +Subject to the condition set forth below, permission is hereby granted to any +person obtaining a copy of this software, associated documentation and/or data +(collectively the "Software"), free of charge and under any and all copyright +rights in the Software, and any and all patent rights owned or freely +licensable by each licensor hereunder covering either (i) the unmodified +Software as contributed to or provided by such licensor, or (ii) the Larger +Works (as defined below), to deal in both + +(a) the Software, and +(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if +one is included with the Software (each a "Larger Work" to which the Software +is contributed by such licensors), + +without restriction, including without limitation the rights to copy, create +derivative works of, display, perform, and distribute the Software and make, +use, sell, offer for sale, import, export, have made, and have sold the +Software and the Larger Work(s), and to sublicense the foregoing rights on +either these or other terms. + +This license is subject to the following condition: +The above copyright notice and either this complete permission notice or at +a minimum a reference to the UPL must be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + */ +package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; + +public class IDCSException extends Exception { + + private static final long serialVersionUID = -1050267580395460202L; + + public IDCSException() { + } + + public IDCSException(String message) { + super(message); + } + + public IDCSException(Throwable cause) { + super(cause); + } + + public IDCSException(String message, Throwable cause) { + super(message, cause); + } + + public IDCSException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + +} diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IDCSOAuthTokenRetrievalException.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IDCSOAuthTokenRetrievalException.java new file mode 100644 index 0000000..e79024e --- /dev/null +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IDCSOAuthTokenRetrievalException.java @@ -0,0 +1,63 @@ +/*Copyright (c) 2025 Oracle and/or its affiliates. + +The Universal Permissive License (UPL), Version 1.0 + +Subject to the condition set forth below, permission is hereby granted to any +person obtaining a copy of this software, associated documentation and/or data +(collectively the "Software"), free of charge and under any and all copyright +rights in the Software, and any and all patent rights owned or freely +licensable by each licensor hereunder covering either (i) the unmodified +Software as contributed to or provided by such licensor, or (ii) the Larger +Works (as defined below), to deal in both + +(a) the Software, and +(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if +one is included with the Software (each a "Larger Work" to which the Software +is contributed by such licensors), + +without restriction, including without limitation the rights to copy, create +derivative works of, display, perform, and distribute the Software and make, +use, sell, offer for sale, import, export, have made, and have sold the +Software and the Larger Work(s), and to sublicense the foregoing rights on +either these or other terms. + +This license is subject to the following condition: +The above copyright notice and either this complete permission notice or at +a minimum a reference to the UPL must be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + */ +package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; + +public class IDCSOAuthTokenRetrievalException extends IDCSException { + + private static final long serialVersionUID = 8469421315662618744L; + + public IDCSOAuthTokenRetrievalException() { + } + + public IDCSOAuthTokenRetrievalException(String message) { + super(message); + } + + public IDCSOAuthTokenRetrievalException(Throwable cause) { + super(cause); + } + + public IDCSOAuthTokenRetrievalException(String message, Throwable cause) { + super(message, cause); + } + + public IDCSOAuthTokenRetrievalException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + +} diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpClientCommonFilterSettings.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpClientCommonFilterSettings.java index 2f2b0a2..7e501c4 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpClientCommonFilterSettings.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpClientCommonFilterSettings.java @@ -5,4 +5,13 @@ public class IoTOutputHttpClientCommonFilterSettings { public final static String USERNAME_PROPERTY = PREFIX + ".username"; public final static String PASSWORD_BASE64_PROPERTY = PREFIX + ".passwordbase64"; public final static String UNAUTHENTICATED_FILTER_ENABLED_PROPERTY = PREFIX + ".unauthenticated.filter.enabled"; + public final static String AUTH_TYPE = PREFIX + ".authtype"; + public final static String OAUTH = PREFIX + ".oauth"; + + public final static String OAUTH_PATH = OAUTH + ".path"; + public final static String OAUTH_CLIENT_ID = OAUTH + ".clientid"; + public final static String OAUTH_CLIENT_SECRET = OAUTH + ".clientsecret"; + public final static String OAUTH_GRANT_TYPE = OAUTH + ".granttype"; + public final static String OAUTH_CLIENT_SCOPE = OAUTH + ".scope"; + } \ No newline at end of file diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java similarity index 93% rename from IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataRequestFilter.java rename to IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java index 60e8044..b4004fd 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java @@ -51,11 +51,12 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on // enabled if sending to OIC @Requires(property = IoTOutputHttpOICClientNormalizedDataSimpleSettings.ENABLED_PROPERTY, value = "true", defaultValue = "false") +@Requires(property = IoTOutputHttpClientCommonFilterSettings.AUTH_TYPE, value = "BASIC", defaultValue = "BASIC") // needs a endpoint @ClientFilter(patterns = { "${" + IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_PROPERTY + ":" + IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_DEFAULT + "}/**" }) @Log -public class IoTOutputHttpOICClientNormalizedDataRequestFilter { +public class IoTOutputHttpOICClientNormalizedDataBasicRequestFilter { @Property(name = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_PROPERTY, defaultValue = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_DEFAULT + "/**") private String patternPath; @@ -63,7 +64,7 @@ public class IoTOutputHttpOICClientNormalizedDataRequestFilter { private final String password; @Inject - public IoTOutputHttpOICClientNormalizedDataRequestFilter( + public IoTOutputHttpOICClientNormalizedDataBasicRequestFilter( @Property(name = IoTOutputHttpOICClientNormalizedDataSimpleSettings.USERNAME_PROPERTY, defaultValue = "") String username, @Property(name = IoTOutputHttpOICClientNormalizedDataSimpleSettings.PASSWORD_BASE64_PROPERTY, defaultValue = "") String passwordBase64) { if ((username == null) || (username.length() == 0)) { @@ -94,7 +95,7 @@ public void doFilter(MutableHttpRequest request) { @PostConstruct public void postConstruct() { - log.info("Post Construct for IoTOutputHttpOICClientNormalizedDataRequestFilter username=" + this.username + log.info("Post Construct for IoTOutputHttpOICClientNormalizedDataBasicRequestFilter username=" + this.username + ", password=" + password + " pattern =" + patternPath); } } \ No newline at end of file diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java new file mode 100644 index 0000000..6303657 --- /dev/null +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java @@ -0,0 +1,93 @@ +/*Copyright (c) 2026 Oracle and/or its affiliates. + +The Universal Permissive License (UPL), Version 1.0 + +Subject to the condition set forth below, permission is hereby granted to any +person obtaining a copy of this software, associated documentation and/or data +(collectively the "Software"), free of charge and under any and all copyright +rights in the Software, and any and all patent rights owned or freely +licensable by each licensor hereunder covering either (i) the unmodified +Software as contributed to or provided by such licensor, or (ii) the Larger +Works (as defined below), to deal in both + +(a) the Software, and +(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if +one is included with the Software (each a "Larger Work" to which the Software +is contributed by such licensors), + +without restriction, including without limitation the rights to copy, create +derivative works of, display, perform, and distribute the Software and make, +use, sell, offer for sale, import, export, have made, and have sold the +Software and the Larger Work(s), and to sublicense the foregoing rights on +either these or other terms. + +This license is subject to the following condition: +The above copyright notice and either this complete permission notice or at +a minimum a reference to the UPL must be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + */ +package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; + +import com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.normalizeddata.oicsimple.IoTOutputHttpOICClientNormalizedDataSimpleSettings; + +import io.micronaut.context.annotation.Property; +import io.micronaut.context.annotation.Requires; +import io.micronaut.http.MutableHttpRequest; +import io.micronaut.http.annotation.ClientFilter; +import io.micronaut.http.annotation.RequestFilter; +import jakarta.annotation.PostConstruct; +import jakarta.inject.Inject; +import lombok.extern.java.Log; + +// enabled if sending to OIC +@Requires(property = IoTOutputHttpOICClientNormalizedDataSimpleSettings.ENABLED_PROPERTY, value = "true", defaultValue = "false") +@Requires(property = IoTOutputHttpClientCommonFilterSettings.AUTH_TYPE, value = "OAUTH2") +// needs a endpoint +@ClientFilter(patterns = { "${" + IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_PROPERTY + ":" + + IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_DEFAULT + "}/**" }) +@Log +public class IoTOutputHttpOICClientNormalizedDataOauthRequestFilter { + @Property(name = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_PROPERTY, defaultValue = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_DEFAULT + + "/**") + private String patternPath; + private final OICOAuthApplicationTokenRetriever oauthTokenRetriever; + + @Inject + public IoTOutputHttpOICClientNormalizedDataOauthRequestFilter( + OICOAuthApplicationTokenRetriever oauthTokenRetriever) { + this.oauthTokenRetriever = oauthTokenRetriever; + } + + @RequestFilter + public void doFilter(MutableHttpRequest request) throws IDCSOAuthTokenRetrievalException { + log.info("Filter authenticated"); + String token; + try { + token = oauthTokenRetriever.getToken(); + } catch (IDCSOAuthTokenRetrievalException e) { + log.severe("Unable to get OAuth token for OIC, " + e.getLocalizedMessage()); + throw e; + } + request.bearerAuth(token); + log.info(() -> "Added OAuth token"); + log.info(() -> "Request uri " + request.getUri().toASCIIString()); + log.info(() -> "Request path " + request.getPath()); + log.info(() -> "Request params = " + request.getParameters().asMap().toString()); + log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); + log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); + } + + @PostConstruct + public void postConstruct() { + log.info("Post Construct for IoTOutputHttpOICClientNormalizedDataBasicRequestFilter username=" + this.username + + ", password=" + password + " pattern =" + patternPath); + } +} \ No newline at end of file diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java similarity index 93% rename from IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataRequestFilter.java rename to IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java index e5453ff..a11e3c5 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java @@ -51,11 +51,13 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on // enabled if sending to OIC @Requires(property = IoTOutputHttpOICClientWrappedNormalizedDataSettings.ENABLED_PROPERTY, value = "true", defaultValue = "false") +@Requires(property = IoTOutputHttpClientCommonFilterSettings.AUTH_TYPE, value = "BASIC", defaultValue = "BASIC") + // needs a endpoint @ClientFilter(patterns = { "${" + IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_PROPERTY + ":" + IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_DEFAULT + "}/**" }) @Log -public class IoTOutputHttpOICClientWrappedNormalizedDataRequestFilter { +public class IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter { @Property(name = IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_PROPERTY, defaultValue = IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_DEFAULT + "/**") private String patternPath; @@ -63,7 +65,7 @@ public class IoTOutputHttpOICClientWrappedNormalizedDataRequestFilter { private final String password; @Inject - public IoTOutputHttpOICClientWrappedNormalizedDataRequestFilter( + public IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter( @Property(name = IoTOutputHttpOICClientWrappedNormalizedDataSettings.USERNAME_PROPERTY, defaultValue = "") String username, @Property(name = IoTOutputHttpOICClientWrappedNormalizedDataSettings.PASSWORD_BASE64_PROPERTY, defaultValue = "") String passwordBase64) { if ((username == null) || (username.length() == 0)) { @@ -94,7 +96,7 @@ public void doFilter(MutableHttpRequest request) { @PostConstruct public void postConstruct() { - log.info("Post Construct for IoTOutputHttpOICClientWrappedNormalizedDataRequestFilter username=" + this.username + log.info("Post Construct for IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter username=" + this.username + ", password=" + password + " pattern =" + patternPath); } } \ No newline at end of file diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java new file mode 100644 index 0000000..737b51a --- /dev/null +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java @@ -0,0 +1,93 @@ +/*Copyright (c) 2026 Oracle and/or its affiliates. + +The Universal Permissive License (UPL), Version 1.0 + +Subject to the condition set forth below, permission is hereby granted to any +person obtaining a copy of this software, associated documentation and/or data +(collectively the "Software"), free of charge and under any and all copyright +rights in the Software, and any and all patent rights owned or freely +licensable by each licensor hereunder covering either (i) the unmodified +Software as contributed to or provided by such licensor, or (ii) the Larger +Works (as defined below), to deal in both + +(a) the Software, and +(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if +one is included with the Software (each a "Larger Work" to which the Software +is contributed by such licensors), + +without restriction, including without limitation the rights to copy, create +derivative works of, display, perform, and distribute the Software and make, +use, sell, offer for sale, import, export, have made, and have sold the +Software and the Larger Work(s), and to sublicense the foregoing rights on +either these or other terms. + +This license is subject to the following condition: +The above copyright notice and either this complete permission notice or at +a minimum a reference to the UPL must be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + */ +package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; + +import com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.normalizeddata.oicwrappeddata.IoTOutputHttpOICClientWrappedNormalizedDataSettings; + +import io.micronaut.context.annotation.Property; +import io.micronaut.context.annotation.Requires; +import io.micronaut.http.MutableHttpRequest; +import io.micronaut.http.annotation.ClientFilter; +import io.micronaut.http.annotation.RequestFilter; +import jakarta.annotation.PostConstruct; +import jakarta.inject.Inject; +import lombok.extern.java.Log; + +// enabled if sending to OIC +@Requires(property = IoTOutputHttpOICClientWrappedNormalizedDataSettings.ENABLED_PROPERTY, value = "true", defaultValue = "false") +@Requires(property = IoTOutputHttpClientCommonFilterSettings.AUTH_TYPE, value = "OAUTH2") + +// needs a endpoint +@ClientFilter(patterns = { "${" + IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_PROPERTY + ":" + + IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_DEFAULT + "}/**" }) +@Log +public class IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter { + @Property(name = IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_PROPERTY, defaultValue = IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_DEFAULT + + "/**") + private String patternPath; + private final OICOAuthApplicationTokenRetriever oauthTokenRetriever; + + @Inject + public IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter( + OICOAuthApplicationTokenRetriever oauthTokenRetriever) { + this.oauthTokenRetriever = oauthTokenRetriever; + } + + @RequestFilter + public void doFilter(MutableHttpRequest request) throws IDCSOAuthTokenRetrievalException { + String token; + try { + token = oauthTokenRetriever.getToken(); + } catch (IDCSOAuthTokenRetrievalException e) { + log.severe("Unable to get OAuth token for OIC, " + e.getLocalizedMessage()); + throw e; + } + request.bearerAuth(token); + log.info(() -> "Added OAuth token"); + log.info(() -> "Request uri " + request.getUri().toASCIIString()); + log.info(() -> "Request path " + request.getPath()); + log.info(() -> "Request params = " + request.getParameters().asMap().toString()); + log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); + log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); + } + + @PostConstruct + public void postConstruct() { + log.info("Post Construct for IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter username=" + + this.username + ", password=" + password + " pattern =" + patternPath); + } +} \ No newline at end of file diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java new file mode 100644 index 0000000..0c1c235 --- /dev/null +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java @@ -0,0 +1,144 @@ +/*Copyright (c) 2026 Oracle and/or its affiliates. + +The Universal Permissive License (UPL), Version 1.0 + +Subject to the condition set forth below, permission is hereby granted to any +person obtaining a copy of this software, associated documentation and/or data +(collectively the "Software"), free of charge and under any and all copyright +rights in the Software, and any and all patent rights owned or freely +licensable by each licensor hereunder covering either (i) the unmodified +Software as contributed to or provided by such licensor, or (ii) the Larger +Works (as defined below), to deal in both + +(a) the Software, and +(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if +one is included with the Software (each a "Larger Work" to which the Software +is contributed by such licensors), + +without restriction, including without limitation the rights to copy, create +derivative works of, display, perform, and distribute the Software and make, +use, sell, offer for sale, import, export, have made, and have sold the +Software and the Larger Work(s), and to sublicense the foregoing rights on +either these or other terms. + +This license is subject to the following condition: +The above copyright notice and either this complete permission notice or at +a minimum a reference to the UPL must be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + */ +package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.Base64; + +import io.micronaut.context.annotation.Property; +import io.micronaut.context.annotation.Requires; +import io.micronaut.http.client.exceptions.HttpClientException; +import jakarta.annotation.PostConstruct; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; +import lombok.Getter; +import lombok.extern.java.Log; + +@Singleton +@Requires(property = IoTOutputHttpClientCommonFilterSettings.AUTH_TYPE, value = "OAUTH2") +@Requires(property = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_ID) +@Requires(property = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_SECRET) +@Requires(property = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_SCOPE) + +@Log +public class OICOAuthApplicationTokenRetriever { + // this basically automates the following request (the text below applies + // micronaut substitutions) + // curl -u 'client id:client secret' \ + // -X POST + // https://${micronaut.http.services.oicoauthtoken.url}/${messagehandler.output.iotoutputhttprestclient.filtersettings.oauth.path:/oauth2/v1/token} + // \ + // --data + // 'grant_type=client_credentials&scope=${messagehandler.output.iotoutputhttprestclient.filtersettings.oauth.scope}' + private final static String GRANT_TYPE_DEFAULT = "client_credentials"; + private final static String AUTH_BASIC = "BASIC"; + private final String oauthClientId; + private final String oauthClientSecret; + private final String oauthGrantType; + private final String oauthScope; + private final String credentialsBase64; + + @Inject + public OICOAuthApplicationTokenRetriever( + @Property(name = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_ID) String clientId, + @Property(name = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_SECRET) String clientSecret, + @Property(name = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_SCOPE) String scope, + @Property(name = IoTOutputHttpClientCommonFilterSettings.OAUTH_GRANT_TYPE, defaultValue = GRANT_TYPE_DEFAULT) String grantType) { + this.oauthClientId = clientId; + this.oauthClientSecret = clientSecret; + this.oauthScope = scope; + this.oauthGrantType = grantType; + String credentials = oauthClientId + ":" + oauthClientSecret; + credentialsBase64 = AUTH_BASIC + " " + Base64.getEncoder().encodeToString(credentials.getBytes()); + } + + @Getter + private LocalDateTime currentTokenRenewTime = null; + + private String currentToken = null; + @Getter + private String tokenType; + + @Inject + private OICOAuthTokenRequester authTokenRequester; + + /** + * for testing only + * + */ + public void deleteTokenDetails() { + this.currentToken = null; + this.currentTokenRenewTime = null; + this.tokenType = null; + } + + /** + * for testing only + * + */ + public void forceTokenRetrievalAfter(Duration expiryOffset) { + currentTokenRenewTime = LocalDateTime.now().plus(expiryOffset); + } + + public String getToken() throws IDCSOAuthTokenRetrievalException { + if ((currentToken == null) || (currentTokenRenewTime == null) + || LocalDateTime.now().isAfter(currentTokenRenewTime)) { + AuthTokenResponse atr; + try { + atr = authTokenRequester.getOAuthToken(credentialsBase64, oauthScope, oauthGrantType); + } catch (HttpClientException e) { + throw new IDCSOAuthTokenRetrievalException("Problem getting the OAuth token " + e.getLocalizedMessage(), + e); + } + this.currentToken = atr.getAccessToken(); + this.tokenType = atr.getTokenType(); + // get a new renewal time, allow 60 seconds for processing the renewal if we + // need to, yes we should probably allow for better control or retrieval times + // but this is a demo, and not supposed to be production. + this.currentTokenRenewTime = LocalDateTime.now().plusSeconds(atr.getExpiresIn() - 60); + } + // we have a current token and it is still valid + return currentToken; + } + + @PostConstruct + public void postConstruct() { + log.info("Startup event received for OICOAuthApplicationTokenRetriever scope=" + oauthScope + ", grantType=" + + oauthGrantType); + } +} \ No newline at end of file diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthTokenRequester.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthTokenRequester.java new file mode 100644 index 0000000..f0ae9a3 --- /dev/null +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthTokenRequester.java @@ -0,0 +1,58 @@ +/*Copyright (c) 2026 Oracle and/or its affiliates. + +The Universal Permissive License (UPL), Version 1.0 + +Subject to the condition set forth below, permission is hereby granted to any +person obtaining a copy of this software, associated documentation and/or data +(collectively the "Software"), free of charge and under any and all copyright +rights in the Software, and any and all patent rights owned or freely +licensable by each licensor hereunder covering either (i) the unmodified +Software as contributed to or provided by such licensor, or (ii) the Larger +Works (as defined below), to deal in both + +(a) the Software, and +(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if +one is included with the Software (each a "Larger Work" to which the Software +is contributed by such licensors), + +without restriction, including without limitation the rights to copy, create +derivative works of, display, perform, and distribute the Software and make, +use, sell, offer for sale, import, export, have made, and have sold the +Software and the Larger Work(s), and to sublicense the foregoing rights on +either these or other terms. + +This license is subject to the following condition: +The above copyright notice and either this complete permission notice or at +a minimum a reference to the UPL must be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + */ +package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; + +import static io.micronaut.http.HttpHeaders.USER_AGENT; + +import io.micronaut.http.MediaType; +import io.micronaut.http.annotation.Consumes; +import io.micronaut.http.annotation.Header; +import io.micronaut.http.annotation.Post; +import io.micronaut.http.annotation.Produces; +import io.micronaut.http.client.annotation.Client; +import io.micronaut.http.client.exceptions.HttpClientException; + +@Client(id = "oicoauthtoken") +@Header(name = USER_AGENT, value = "Micronaut HTTP Client") +public interface OICOAuthTokenRequester { + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_FORM_URLENCODED) + @Post(value = "${IoTOutputHttpClientCommonFilterSettings.OAUTH_PATH:/oauth2/v1/token}") + public AuthTokenResponse getOAuthToken(@Header String authorization, String scope, String grant_type) + throws HttpClientException; + +} From 71c7f5ae03a2a8638b7bf7d6d5ab1ef2075b8a16 Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Mon, 7 Sep 2026 15:36:26 +0100 Subject: [PATCH 02/13] fix post construct debug --- ...tputHttpOICClientNormalizedDataOauthRequestFilter.java | 7 +++++-- ...pOICClientWrappedNormalizedDataOAuthRequestFilter.java | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java index 6303657..4ea361e 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java @@ -36,6 +36,8 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on */ package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; +import java.time.format.DateTimeFormatter; + import com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.normalizeddata.oicsimple.IoTOutputHttpOICClientNormalizedDataSimpleSettings; import io.micronaut.context.annotation.Property; @@ -87,7 +89,8 @@ public void doFilter(MutableHttpRequest request) throws IDCSOAuthTokenRetriev @PostConstruct public void postConstruct() { - log.info("Post Construct for IoTOutputHttpOICClientNormalizedDataBasicRequestFilter username=" + this.username - + ", password=" + password + " pattern =" + patternPath); + log.info("Post Construct for IoTOutputHttpOICClientNormalizedDataOAuthRequestFilter token type=" + + oauthTokenRetriever.getTokenType() + ", renewal time=" + + oauthTokenRetriever.getCurrentTokenRenewTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); } } \ No newline at end of file diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java index 737b51a..fc42c8a 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java @@ -36,6 +36,8 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on */ package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; +import java.time.format.DateTimeFormatter; + import com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.normalizeddata.oicwrappeddata.IoTOutputHttpOICClientWrappedNormalizedDataSettings; import io.micronaut.context.annotation.Property; @@ -87,7 +89,9 @@ public void doFilter(MutableHttpRequest request) throws IDCSOAuthTokenRetriev @PostConstruct public void postConstruct() { - log.info("Post Construct for IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter username=" - + this.username + ", password=" + password + " pattern =" + patternPath); + log.info("Post Construct for IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter token type=" + + oauthTokenRetriever.getTokenType() + ", renewal time=" + + oauthTokenRetriever.getCurrentTokenRenewTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); + } } \ No newline at end of file From 9bdf9de98ec17c5ffa82de6967647c5e82201b1d Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Mon, 7 Sep 2026 16:43:02 +0100 Subject: [PATCH 03/13] seems to be an instantiation problem, set the oic oauth token injection to be delayed to the post construction --- .../OICOAuthApplicationTokenRetriever.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java index 0c1c235..e131124 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java @@ -38,8 +38,10 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import java.time.Duration; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Base64; +import io.micronaut.context.BeanProvider; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; import io.micronaut.http.client.exceptions.HttpClientException; @@ -73,12 +75,23 @@ public class OICOAuthApplicationTokenRetriever { private final String oauthScope; private final String credentialsBase64; + @Getter + private LocalDateTime currentTokenRenewTime = null; + + private String currentToken = null; + @Getter + private String tokenType; + private final BeanProvider authTokenRequesterProvider; + private OICOAuthTokenRequester authTokenRequester; + @Inject - public OICOAuthApplicationTokenRetriever( + public OICOAuthApplicationTokenRetriever(BeanProvider authTokenRequesterProvider, @Property(name = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_ID) String clientId, @Property(name = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_SECRET) String clientSecret, @Property(name = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_SCOPE) String scope, - @Property(name = IoTOutputHttpClientCommonFilterSettings.OAUTH_GRANT_TYPE, defaultValue = GRANT_TYPE_DEFAULT) String grantType) { + @Property(name = IoTOutputHttpClientCommonFilterSettings.OAUTH_GRANT_TYPE, defaultValue = GRANT_TYPE_DEFAULT) String grantType) + throws IllegalArgumentException { + this.authTokenRequesterProvider = authTokenRequesterProvider; this.oauthClientId = clientId; this.oauthClientSecret = clientSecret; this.oauthScope = scope; @@ -87,16 +100,6 @@ public OICOAuthApplicationTokenRetriever( credentialsBase64 = AUTH_BASIC + " " + Base64.getEncoder().encodeToString(credentials.getBytes()); } - @Getter - private LocalDateTime currentTokenRenewTime = null; - - private String currentToken = null; - @Getter - private String tokenType; - - @Inject - private OICOAuthTokenRequester authTokenRequester; - /** * for testing only * @@ -137,8 +140,19 @@ public String getToken() throws IDCSOAuthTokenRetrievalException { } @PostConstruct - public void postConstruct() { + public void postConstruct() throws IDCSOAuthTokenRetrievalException { + if (authTokenRequesterProvider.isPresent()) { + authTokenRequester = authTokenRequesterProvider.get(); + log.info("Retrieved token provider"); + } else { + log.severe("Could not get the OIC token retreiever http client, will not be able to add oauth credentials"); + throw new IllegalArgumentException( + "Could not get the OIC token retreiever http client, will not be able to add oauth credentials"); + } log.info("Startup event received for OICOAuthApplicationTokenRetriever scope=" + oauthScope + ", grantType=" + oauthGrantType); + log.info("Retrieving initial token"); + getToken(); + log.info("Token will expire at " + currentTokenRenewTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); } } \ No newline at end of file From 80cfdf3f6d75b5d81b29d23fac6a2e816b273154 Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Mon, 7 Sep 2026 17:22:35 +0100 Subject: [PATCH 04/13] try switching the request filter to be based on completable futures as per micronaut documentation --- ...ttpOICClientNormalizedDataOauthRequestFilter.java | 12 +++++++++--- ...lientWrappedNormalizedDataOAuthRequestFilter.java | 11 +++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java index 4ea361e..6a91773 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java @@ -37,11 +37,15 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; import java.time.format.DateTimeFormatter; +import java.util.concurrent.CompletableFuture; import com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.normalizeddata.oicsimple.IoTOutputHttpOICClientNormalizedDataSimpleSettings; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; +import io.micronaut.core.annotation.Nullable; +import io.micronaut.http.HttpResponse; +import io.micronaut.http.HttpStatus; import io.micronaut.http.MutableHttpRequest; import io.micronaut.http.annotation.ClientFilter; import io.micronaut.http.annotation.RequestFilter; @@ -69,14 +73,14 @@ public IoTOutputHttpOICClientNormalizedDataOauthRequestFilter( } @RequestFilter - public void doFilter(MutableHttpRequest request) throws IDCSOAuthTokenRetrievalException { - log.info("Filter authenticated"); + public CompletableFuture<@Nullable HttpResponse> doFilter(MutableHttpRequest request) { String token; try { token = oauthTokenRetriever.getToken(); } catch (IDCSOAuthTokenRetrievalException e) { log.severe("Unable to get OAuth token for OIC, " + e.getLocalizedMessage()); - throw e; + HttpResponse resp = HttpResponse.status(HttpStatus.FORBIDDEN, "Can't get oauth token"); + return CompletableFuture.completedFuture(resp); } request.bearerAuth(token); log.info(() -> "Added OAuth token"); @@ -85,6 +89,8 @@ public void doFilter(MutableHttpRequest request) throws IDCSOAuthTokenRetriev log.info(() -> "Request params = " + request.getParameters().asMap().toString()); log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); + // it all went OK, tell the code to carry on + return CompletableFuture.completedFuture(null); } @PostConstruct diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java index fc42c8a..a89538c 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java @@ -37,11 +37,15 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; import java.time.format.DateTimeFormatter; +import java.util.concurrent.CompletableFuture; import com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.normalizeddata.oicwrappeddata.IoTOutputHttpOICClientWrappedNormalizedDataSettings; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; +import io.micronaut.core.annotation.Nullable; +import io.micronaut.http.HttpResponse; +import io.micronaut.http.HttpStatus; import io.micronaut.http.MutableHttpRequest; import io.micronaut.http.annotation.ClientFilter; import io.micronaut.http.annotation.RequestFilter; @@ -70,13 +74,14 @@ public IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter( } @RequestFilter - public void doFilter(MutableHttpRequest request) throws IDCSOAuthTokenRetrievalException { + public CompletableFuture<@Nullable HttpResponse> doFilter(MutableHttpRequest request) { String token; try { token = oauthTokenRetriever.getToken(); } catch (IDCSOAuthTokenRetrievalException e) { log.severe("Unable to get OAuth token for OIC, " + e.getLocalizedMessage()); - throw e; + HttpResponse resp = HttpResponse.status(HttpStatus.FORBIDDEN, "Can't get oauth token"); + return CompletableFuture.completedFuture(resp); } request.bearerAuth(token); log.info(() -> "Added OAuth token"); @@ -85,6 +90,8 @@ public void doFilter(MutableHttpRequest request) throws IDCSOAuthTokenRetriev log.info(() -> "Request params = " + request.getParameters().asMap().toString()); log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); + // it all went OK, tell the code to carry on + return CompletableFuture.completedFuture(null); } @PostConstruct From 2e01dc1137055198c1a741cd9e9226e1d55fbe16 Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Tue, 8 Sep 2026 10:53:50 +0100 Subject: [PATCH 05/13] make filters singleton --- ...pOICClientNormalizedDataBasicRequestFilter.java | 2 ++ ...pOICClientNormalizedDataOauthRequestFilter.java | 3 +++ ...entWrappedNormalizedDataBasicRequestFilter.java | 7 +++++-- ...entWrappedNormalizedDataOAuthRequestFilter.java | 3 +++ ...utHttpRestClientAuthenticatedRequestFilter.java | 2 ++ ...IoTOutputHttpRestClientEnableRequestFilter.java | 14 ++++++++++++++ ...HttpRestClientUnauthenticatedRequestFilter.java | 3 +++ .../requestfilters/OICOAuthTokenRequester.java | 2 ++ 8 files changed, 34 insertions(+), 2 deletions(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java index b4004fd..a1c23a6 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java @@ -47,6 +47,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.http.annotation.RequestFilter; import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; +import jakarta.inject.Singleton; import lombok.extern.java.Log; // enabled if sending to OIC @@ -56,6 +57,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on @ClientFilter(patterns = { "${" + IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_PROPERTY + ":" + IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_DEFAULT + "}/**" }) @Log +@Singleton public class IoTOutputHttpOICClientNormalizedDataBasicRequestFilter { @Property(name = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_PROPERTY, defaultValue = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_DEFAULT + "/**") diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java index 6a91773..ca2b48c 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java @@ -51,6 +51,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.http.annotation.RequestFilter; import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; +import jakarta.inject.Singleton; import lombok.extern.java.Log; // enabled if sending to OIC @@ -60,6 +61,8 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on @ClientFilter(patterns = { "${" + IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_PROPERTY + ":" + IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_DEFAULT + "}/**" }) @Log +@Singleton + public class IoTOutputHttpOICClientNormalizedDataOauthRequestFilter { @Property(name = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_PROPERTY, defaultValue = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_DEFAULT + "/**") diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java index a11e3c5..8f83408 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java @@ -47,6 +47,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.http.annotation.RequestFilter; import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; +import jakarta.inject.Singleton; import lombok.extern.java.Log; // enabled if sending to OIC @@ -57,6 +58,8 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on @ClientFilter(patterns = { "${" + IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_PROPERTY + ":" + IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_DEFAULT + "}/**" }) @Log +@Singleton + public class IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter { @Property(name = IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_PROPERTY, defaultValue = IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_DEFAULT + "/**") @@ -96,7 +99,7 @@ public void doFilter(MutableHttpRequest request) { @PostConstruct public void postConstruct() { - log.info("Post Construct for IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter username=" + this.username - + ", password=" + password + " pattern =" + patternPath); + log.info("Post Construct for IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter username=" + + this.username + ", password=" + password + " pattern =" + patternPath); } } \ No newline at end of file diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java index a89538c..a52d134 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java @@ -51,6 +51,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.http.annotation.RequestFilter; import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; +import jakarta.inject.Singleton; import lombok.extern.java.Log; // enabled if sending to OIC @@ -61,6 +62,8 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on @ClientFilter(patterns = { "${" + IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_PROPERTY + ":" + IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_DEFAULT + "}/**" }) @Log +@Singleton + public class IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter { @Property(name = IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_PROPERTY, defaultValue = IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_DEFAULT + "/**") diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientAuthenticatedRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientAuthenticatedRequestFilter.java index 2e1bf52..a84925c 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientAuthenticatedRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientAuthenticatedRequestFilter.java @@ -49,6 +49,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.http.annotation.RequestFilter; import io.micronaut.runtime.event.annotation.EventListener; import jakarta.inject.Inject; +import jakarta.inject.Singleton; import lombok.extern.java.Log; // needs a endpoint @@ -59,6 +60,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on "${" + IoTOutputHttpRestClientRawDataSettings.TARGET_PATH_PROPERTY + ":" + IoTOutputHttpRestClientRawDataSettings.TARGET_PATH_DEFAULT + "}" + "/authenticated/**" }) @Log +@Singleton public class IoTOutputHttpRestClientAuthenticatedRequestFilter { private final String username; private final String password; diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientEnableRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientEnableRequestFilter.java index dd0d8ab..d4b615f 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientEnableRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientEnableRequestFilter.java @@ -5,11 +5,25 @@ import io.micronaut.context.condition.Condition; import io.micronaut.context.condition.ConditionContext; +import jakarta.annotation.PostConstruct; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import lombok.extern.java.Log; @Log +@Singleton public class IoTOutputHttpRestClientEnableRequestFilter implements Condition { + @Inject + public IoTOutputHttpRestClientEnableRequestFilter() { + log.info("IoTOutputHttpRestClientEnableRequestFilter In constructor"); + } + + @PostConstruct + public void postConstruct() { + log.info("IoTOutputHttpRestClientEnableRequestFilter In post construct"); + } + @Override public boolean matches(ConditionContext context) { boolean normDataEnabled = context diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientUnauthenticatedRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientUnauthenticatedRequestFilter.java index 1f9a2aa..3be69ce 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientUnauthenticatedRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientUnauthenticatedRequestFilter.java @@ -45,6 +45,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.http.annotation.ClientFilter; import io.micronaut.http.annotation.RequestFilter; import io.micronaut.runtime.event.annotation.EventListener; +import jakarta.inject.Singleton; import lombok.extern.java.Log; // only load if expressly enabled @@ -59,6 +60,8 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on "${" + IoTOutputHttpRestClientRawDataSettings.TARGET_PATH_PROPERTY + ":" + IoTOutputHttpRestClientRawDataSettings.TARGET_PATH_DEFAULT + "}" + "/unauthenticated/**" }) @Log +@Singleton + public class IoTOutputHttpRestClientUnauthenticatedRequestFilter { @RequestFilter diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthTokenRequester.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthTokenRequester.java index f0ae9a3..394e2fb 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthTokenRequester.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthTokenRequester.java @@ -45,9 +45,11 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.http.annotation.Produces; import io.micronaut.http.client.annotation.Client; import io.micronaut.http.client.exceptions.HttpClientException; +import jakarta.inject.Singleton; @Client(id = "oicoauthtoken") @Header(name = USER_AGENT, value = "Micronaut HTTP Client") +@Singleton public interface OICOAuthTokenRequester { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_FORM_URLENCODED) From 07286e0c5835bb956cb11d24cedb488da543e463 Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Tue, 8 Sep 2026 11:17:52 +0100 Subject: [PATCH 06/13] adjust the filter return for oauth apps --- ...putHttpOICClientNormalizedDataOauthRequestFilter.java | 9 +++------ ...OICClientWrappedNormalizedDataOAuthRequestFilter.java | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java index ca2b48c..3584613 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java @@ -37,13 +37,11 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; import java.time.format.DateTimeFormatter; -import java.util.concurrent.CompletableFuture; import com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.normalizeddata.oicsimple.IoTOutputHttpOICClientNormalizedDataSimpleSettings; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; -import io.micronaut.core.annotation.Nullable; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; import io.micronaut.http.MutableHttpRequest; @@ -76,14 +74,13 @@ public IoTOutputHttpOICClientNormalizedDataOauthRequestFilter( } @RequestFilter - public CompletableFuture<@Nullable HttpResponse> doFilter(MutableHttpRequest request) { + public HttpResponse doFilter(MutableHttpRequest request) { String token; try { token = oauthTokenRetriever.getToken(); } catch (IDCSOAuthTokenRetrievalException e) { log.severe("Unable to get OAuth token for OIC, " + e.getLocalizedMessage()); - HttpResponse resp = HttpResponse.status(HttpStatus.FORBIDDEN, "Can't get oauth token"); - return CompletableFuture.completedFuture(resp); + return HttpResponse.status(HttpStatus.FORBIDDEN, "Can't get oauth token"); } request.bearerAuth(token); log.info(() -> "Added OAuth token"); @@ -93,7 +90,7 @@ public IoTOutputHttpOICClientNormalizedDataOauthRequestFilter( log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); // it all went OK, tell the code to carry on - return CompletableFuture.completedFuture(null); + return null; } @PostConstruct diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java index a52d134..7775bf5 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java @@ -37,13 +37,11 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; import java.time.format.DateTimeFormatter; -import java.util.concurrent.CompletableFuture; import com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.normalizeddata.oicwrappeddata.IoTOutputHttpOICClientWrappedNormalizedDataSettings; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; -import io.micronaut.core.annotation.Nullable; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; import io.micronaut.http.MutableHttpRequest; @@ -77,14 +75,13 @@ public IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter( } @RequestFilter - public CompletableFuture<@Nullable HttpResponse> doFilter(MutableHttpRequest request) { + public HttpResponse doFilter(MutableHttpRequest request) { String token; try { token = oauthTokenRetriever.getToken(); } catch (IDCSOAuthTokenRetrievalException e) { log.severe("Unable to get OAuth token for OIC, " + e.getLocalizedMessage()); - HttpResponse resp = HttpResponse.status(HttpStatus.FORBIDDEN, "Can't get oauth token"); - return CompletableFuture.completedFuture(resp); + return HttpResponse.status(HttpStatus.FORBIDDEN, "Can't get oauth token"); } request.bearerAuth(token); log.info(() -> "Added OAuth token"); @@ -94,7 +91,7 @@ public IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter( log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); // it all went OK, tell the code to carry on - return CompletableFuture.completedFuture(null); + return null; } @PostConstruct From b2a48f3711e18d49dff908d1fa77c44cd3fa912f Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Tue, 8 Sep 2026 11:47:32 +0100 Subject: [PATCH 07/13] added default value to filter requirements --- .../IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java | 2 +- ...putHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java index 3584613..5c3a759 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java @@ -54,7 +54,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on // enabled if sending to OIC @Requires(property = IoTOutputHttpOICClientNormalizedDataSimpleSettings.ENABLED_PROPERTY, value = "true", defaultValue = "false") -@Requires(property = IoTOutputHttpClientCommonFilterSettings.AUTH_TYPE, value = "OAUTH2") +@Requires(property = IoTOutputHttpClientCommonFilterSettings.AUTH_TYPE, value = "OAUTH2", defaultValue = "BASIC") // needs a endpoint @ClientFilter(patterns = { "${" + IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_PROPERTY + ":" + IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_DEFAULT + "}/**" }) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java index 7775bf5..447b1c2 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java @@ -54,7 +54,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on // enabled if sending to OIC @Requires(property = IoTOutputHttpOICClientWrappedNormalizedDataSettings.ENABLED_PROPERTY, value = "true", defaultValue = "false") -@Requires(property = IoTOutputHttpClientCommonFilterSettings.AUTH_TYPE, value = "OAUTH2") +@Requires(property = IoTOutputHttpClientCommonFilterSettings.AUTH_TYPE, value = "OAUTH2", defaultValue = "BASIC") // needs a endpoint @ClientFilter(patterns = { "${" + IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_PROPERTY + ":" From de558827ba0422299260316ebe0f20eeb6e4c820 Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Tue, 8 Sep 2026 11:50:26 +0100 Subject: [PATCH 08/13] added default value to retriever @Requires --- .../rest/requestfilters/OICOAuthApplicationTokenRetriever.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java index e131124..6413ed8 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java @@ -52,7 +52,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import lombok.extern.java.Log; @Singleton -@Requires(property = IoTOutputHttpClientCommonFilterSettings.AUTH_TYPE, value = "OAUTH2") +@Requires(property = IoTOutputHttpClientCommonFilterSettings.AUTH_TYPE, value = "OAUTH2", defaultValue = "BASIC") @Requires(property = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_ID) @Requires(property = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_SECRET) @Requires(property = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_SCOPE) From 04403567fa07c08ac1e05ea27518bd6221e247fc Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Tue, 8 Sep 2026 12:02:00 +0100 Subject: [PATCH 09/13] make the oauth request filters use a bean provider to try and delay the instantiation to avoid loops in the injection process --- ...ClientNormalizedDataOauthRequestFilter.java | 18 +++++++++++++++--- ...rappedNormalizedDataOAuthRequestFilter.java | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java index 5c3a759..34edaa6 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java @@ -37,9 +37,11 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; import java.time.format.DateTimeFormatter; +import java.util.MissingResourceException; import com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.normalizeddata.oicsimple.IoTOutputHttpOICClientNormalizedDataSimpleSettings; +import io.micronaut.context.BeanProvider; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; import io.micronaut.http.HttpResponse; @@ -65,12 +67,13 @@ public class IoTOutputHttpOICClientNormalizedDataOauthRequestFilter { @Property(name = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_PROPERTY, defaultValue = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_DEFAULT + "/**") private String patternPath; - private final OICOAuthApplicationTokenRetriever oauthTokenRetriever; + private BeanProvider oauthTokenRetrieverProvider; + private OICOAuthApplicationTokenRetriever oauthTokenRetriever; @Inject public IoTOutputHttpOICClientNormalizedDataOauthRequestFilter( - OICOAuthApplicationTokenRetriever oauthTokenRetriever) { - this.oauthTokenRetriever = oauthTokenRetriever; + BeanProvider oauthTokenRetrieverProvider) { + this.oauthTokenRetrieverProvider = oauthTokenRetrieverProvider; } @RequestFilter @@ -95,6 +98,15 @@ public HttpResponse doFilter(MutableHttpRequest request) { @PostConstruct public void postConstruct() { + if (oauthTokenRetrieverProvider.isResolvable()) { + oauthTokenRetriever = oauthTokenRetrieverProvider.get(); + log.info("IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter retrieved oauthTokenRetriever"); + } else { + log.severe( + "IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter oauthTokenRetrieverProvider cannot be resolved, attempts to use the oauth will fail"); + throw new MissingResourceException("Can't locate the bean OICOAuthApplicationTokenRetriever", + OICOAuthApplicationTokenRetriever.class.getName(), null); + } log.info("Post Construct for IoTOutputHttpOICClientNormalizedDataOAuthRequestFilter token type=" + oauthTokenRetriever.getTokenType() + ", renewal time=" + oauthTokenRetriever.getCurrentTokenRenewTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java index 447b1c2..73346f5 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java @@ -37,9 +37,11 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters; import java.time.format.DateTimeFormatter; +import java.util.MissingResourceException; import com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.normalizeddata.oicwrappeddata.IoTOutputHttpOICClientWrappedNormalizedDataSettings; +import io.micronaut.context.BeanProvider; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; import io.micronaut.http.HttpResponse; @@ -66,12 +68,13 @@ public class IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter { @Property(name = IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_PROPERTY, defaultValue = IoTOutputHttpOICClientWrappedNormalizedDataSettings.TARGET_PATH_DEFAULT + "/**") private String patternPath; - private final OICOAuthApplicationTokenRetriever oauthTokenRetriever; + private BeanProvider oauthTokenRetrieverProvider; + private OICOAuthApplicationTokenRetriever oauthTokenRetriever; @Inject public IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter( - OICOAuthApplicationTokenRetriever oauthTokenRetriever) { - this.oauthTokenRetriever = oauthTokenRetriever; + BeanProvider oauthTokenRetrieverProvider) { + this.oauthTokenRetrieverProvider = oauthTokenRetrieverProvider; } @RequestFilter @@ -96,6 +99,15 @@ public HttpResponse doFilter(MutableHttpRequest request) { @PostConstruct public void postConstruct() { + if (oauthTokenRetrieverProvider.isResolvable()) { + oauthTokenRetriever = oauthTokenRetrieverProvider.get(); + log.info("IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter retrieved oauthTokenRetriever"); + } else { + log.severe( + "IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter oauthTokenRetrieverProvider cannot be resolved, attempts to use the oauth will fail"); + throw new MissingResourceException("Can't locate the bean OICOAuthApplicationTokenRetriever", + OICOAuthApplicationTokenRetriever.class.getName(), null); + } log.info("Post Construct for IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter token type=" + oauthTokenRetriever.getTokenType() + ", renewal time=" + oauthTokenRetriever.getCurrentTokenRenewTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); From 53ae56815ac1bd565a538b06a01c76fbf6acba70 Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Wed, 9 Sep 2026 10:41:47 +0100 Subject: [PATCH 10/13] switch setup to be startup listener, not post construct based (this may lead to race conditions though) --- ...putHttpOICClientNormalizedDataOauthRequestFilter.java | 8 ++++++++ ...OICClientWrappedNormalizedDataOAuthRequestFilter.java | 9 ++++++++- .../OICOAuthApplicationTokenRetriever.java | 8 ++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java index 34edaa6..0ea0af6 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java @@ -44,11 +44,13 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.context.BeanProvider; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; +import io.micronaut.context.event.StartupEvent; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; import io.micronaut.http.MutableHttpRequest; import io.micronaut.http.annotation.ClientFilter; import io.micronaut.http.annotation.RequestFilter; +import io.micronaut.runtime.event.annotation.EventListener; import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; import jakarta.inject.Singleton; @@ -74,6 +76,7 @@ public class IoTOutputHttpOICClientNormalizedDataOauthRequestFilter { public IoTOutputHttpOICClientNormalizedDataOauthRequestFilter( BeanProvider oauthTokenRetrieverProvider) { this.oauthTokenRetrieverProvider = oauthTokenRetrieverProvider; + log.info("IoTOutputHttpOICClientNormalizedDataOauthRequestFilter completed constructor"); } @RequestFilter @@ -98,6 +101,11 @@ public HttpResponse doFilter(MutableHttpRequest request) { @PostConstruct public void postConstruct() { + log.info("IoTOutputHttpOICClientNormalizedDataOauthRequestFilter completed postConstruct"); + } + + @EventListener + public void startUp(StartupEvent event) { if (oauthTokenRetrieverProvider.isResolvable()) { oauthTokenRetriever = oauthTokenRetrieverProvider.get(); log.info("IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter retrieved oauthTokenRetriever"); diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java index 73346f5..0392c59 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java @@ -44,11 +44,13 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.context.BeanProvider; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; +import io.micronaut.context.event.StartupEvent; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; import io.micronaut.http.MutableHttpRequest; import io.micronaut.http.annotation.ClientFilter; import io.micronaut.http.annotation.RequestFilter; +import io.micronaut.runtime.event.annotation.EventListener; import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; import jakarta.inject.Singleton; @@ -75,6 +77,7 @@ public class IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter { public IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter( BeanProvider oauthTokenRetrieverProvider) { this.oauthTokenRetrieverProvider = oauthTokenRetrieverProvider; + log.info("IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter completed constructor"); } @RequestFilter @@ -99,6 +102,11 @@ public HttpResponse doFilter(MutableHttpRequest request) { @PostConstruct public void postConstruct() { + log.info("IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter completed postConstruct"); + } + + @EventListener + public void startUp(StartupEvent event) { if (oauthTokenRetrieverProvider.isResolvable()) { oauthTokenRetriever = oauthTokenRetrieverProvider.get(); log.info("IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter retrieved oauthTokenRetriever"); @@ -111,6 +119,5 @@ public void postConstruct() { log.info("Post Construct for IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter token type=" + oauthTokenRetriever.getTokenType() + ", renewal time=" + oauthTokenRetriever.getCurrentTokenRenewTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); - } } \ No newline at end of file diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java index 6413ed8..03e07c4 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java @@ -44,8 +44,9 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.context.BeanProvider; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; +import io.micronaut.context.event.StartupEvent; import io.micronaut.http.client.exceptions.HttpClientException; -import jakarta.annotation.PostConstruct; +import io.micronaut.runtime.event.annotation.EventListener; import jakarta.inject.Inject; import jakarta.inject.Singleton; import lombok.Getter; @@ -56,7 +57,6 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on @Requires(property = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_ID) @Requires(property = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_SECRET) @Requires(property = IoTOutputHttpClientCommonFilterSettings.OAUTH_CLIENT_SCOPE) - @Log public class OICOAuthApplicationTokenRetriever { // this basically automates the following request (the text below applies @@ -139,8 +139,8 @@ public String getToken() throws IDCSOAuthTokenRetrievalException { return currentToken; } - @PostConstruct - public void postConstruct() throws IDCSOAuthTokenRetrievalException { + @EventListener + public void startup(StartupEvent event) throws IDCSOAuthTokenRetrievalException { if (authTokenRequesterProvider.isPresent()) { authTokenRequester = authTokenRequesterProvider.get(); log.info("Retrieved token provider"); From 5d20bd74bec1c5a307a2c1e7c6f0d4c97359c33f Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Wed, 9 Sep 2026 10:48:43 +0100 Subject: [PATCH 11/13] as expected the token retriever startup caused a race condition to switched that back to a post construct --- .../OICOAuthApplicationTokenRetriever.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java index 03e07c4..3ec8e7b 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/OICOAuthApplicationTokenRetriever.java @@ -44,9 +44,8 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.context.BeanProvider; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; -import io.micronaut.context.event.StartupEvent; import io.micronaut.http.client.exceptions.HttpClientException; -import io.micronaut.runtime.event.annotation.EventListener; +import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; import jakarta.inject.Singleton; import lombok.Getter; @@ -139,8 +138,20 @@ public String getToken() throws IDCSOAuthTokenRetrievalException { return currentToken; } - @EventListener - public void startup(StartupEvent event) throws IDCSOAuthTokenRetrievalException { + @PostConstruct + public void postConstruct() throws IDCSOAuthTokenRetrievalException { + getAuthTokenRequester(); + log.info("Startup event received for OICOAuthApplicationTokenRetriever scope=" + oauthScope + ", grantType=" + + oauthGrantType); + log.info("Retrieving initial token"); + getToken(); + log.info("Token will expire at " + currentTokenRenewTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); + } + + /** + * @throws IllegalArgumentException + */ + private void getAuthTokenRequester() throws IllegalArgumentException { if (authTokenRequesterProvider.isPresent()) { authTokenRequester = authTokenRequesterProvider.get(); log.info("Retrieved token provider"); @@ -149,10 +160,5 @@ public void startup(StartupEvent event) throws IDCSOAuthTokenRetrievalException throw new IllegalArgumentException( "Could not get the OIC token retreiever http client, will not be able to add oauth credentials"); } - log.info("Startup event received for OICOAuthApplicationTokenRetriever scope=" + oauthScope + ", grantType=" - + oauthGrantType); - log.info("Retrieving initial token"); - getToken(); - log.info("Token will expire at " + currentTokenRenewTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); } } \ No newline at end of file From fbecb3960b02b275844b408303d5ca3e8f2530b1 Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Wed, 9 Sep 2026 12:07:42 +0100 Subject: [PATCH 12/13] added better error handling for the OIC outputs --- .../NormalizedDataHttpOICSimpleOutput.java | 7 +++++++ .../WrappedNormalizedDataHttpOICOutput.java | 21 +++++++++++++------ ...appedNormalizedDataOAuthRequestFilter.java | 8 ++----- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/normalizeddata/oicsimple/NormalizedDataHttpOICSimpleOutput.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/normalizeddata/oicsimple/NormalizedDataHttpOICSimpleOutput.java index 70d2c53..e126458 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/normalizeddata/oicsimple/NormalizedDataHttpOICSimpleOutput.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/normalizeddata/oicsimple/NormalizedDataHttpOICSimpleOutput.java @@ -96,6 +96,13 @@ public NormalizedData[] processNormalizedData(NormalizedData input) throws Excep } catch (HttpClientException e) { log.warning( "HttpOICClient exception making call postNormalizedDataAsJsonToXXXX - " + e.getLocalizedMessage()); + e.printStackTrace(); + NormalizedData[] returnResp = new NormalizedData[1]; + returnResp[0] = input; + return returnResp; + } catch (Exception e) { + log.warning("Exception making call postNormalizedDataAsJsonToXXXX - " + e.getLocalizedMessage()); + e.printStackTrace(); NormalizedData[] returnResp = new NormalizedData[1]; returnResp[0] = input; return returnResp; diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/normalizeddata/oicwrappeddata/WrappedNormalizedDataHttpOICOutput.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/normalizeddata/oicwrappeddata/WrappedNormalizedDataHttpOICOutput.java index 07863d4..30861b4 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/normalizeddata/oicwrappeddata/WrappedNormalizedDataHttpOICOutput.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/normalizeddata/oicwrappeddata/WrappedNormalizedDataHttpOICOutput.java @@ -87,21 +87,30 @@ public WrappedNormalizedDataHttpOICOutput(WrappedNormalizedDataIoTOutputHttpOICC public NormalizedData[] processNormalizedData(NormalizedData input) throws Exception { log.info(() -> "NormalizedData is " + input); HttpResponse result; - NormalizedDataMetadataTransfer normalizedDataTransfer = NormalizedDataMetadataTransfer.buildTransfer(input, - deviceModelInstancesCache); + NormalizedDataMetadataTransfer normalizedDataWithMetadataTransfer = NormalizedDataMetadataTransfer + .buildTransfer(input, deviceModelInstancesCache); try { if (sendtojsonobject) { log.info(() -> "Making OIC call, Sending wrapped json to json object with content of " - + normalizedDataTransfer); - result = wrappedHttpOicClient.postWrappedNormalizedDataAsJsonToJsonObject(normalizedDataTransfer); + + normalizedDataWithMetadataTransfer); + result = wrappedHttpOicClient + .postWrappedNormalizedDataAsJsonToJsonObject(normalizedDataWithMetadataTransfer); } else { log.info(() -> "Making OIC call, Sending wrapped json to string with content of " - + normalizedDataTransfer); - result = wrappedHttpOicClient.postWrappedNormalizedDataAsJsonToString(normalizedDataTransfer); + + normalizedDataWithMetadataTransfer); + result = wrappedHttpOicClient + .postWrappedNormalizedDataAsJsonToString(normalizedDataWithMetadataTransfer); } } catch (HttpClientException e) { log.warning("HttpOICClient exception making call postWrappedNormalizedDataAsJsonToXXXX - " + e.getLocalizedMessage()); + e.printStackTrace(); + NormalizedData[] returnResp = new NormalizedData[1]; + returnResp[0] = input; + return returnResp; + } catch (Exception e) { + log.warning("Exception making call postWrappedNormalizedDataAsJsonToXXXX - " + e.getLocalizedMessage()); + e.printStackTrace(); NormalizedData[] returnResp = new NormalizedData[1]; returnResp[0] = input; return returnResp; diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java index 0392c59..02ecc25 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java @@ -45,8 +45,6 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; import io.micronaut.context.event.StartupEvent; -import io.micronaut.http.HttpResponse; -import io.micronaut.http.HttpStatus; import io.micronaut.http.MutableHttpRequest; import io.micronaut.http.annotation.ClientFilter; import io.micronaut.http.annotation.RequestFilter; @@ -81,13 +79,13 @@ public IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter( } @RequestFilter - public HttpResponse doFilter(MutableHttpRequest request) { + public void doFilter(MutableHttpRequest request) { String token; try { token = oauthTokenRetriever.getToken(); } catch (IDCSOAuthTokenRetrievalException e) { log.severe("Unable to get OAuth token for OIC, " + e.getLocalizedMessage()); - return HttpResponse.status(HttpStatus.FORBIDDEN, "Can't get oauth token"); + return; } request.bearerAuth(token); log.info(() -> "Added OAuth token"); @@ -96,8 +94,6 @@ public HttpResponse doFilter(MutableHttpRequest request) { log.info(() -> "Request params = " + request.getParameters().asMap().toString()); log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); - // it all went OK, tell the code to carry on - return null; } @PostConstruct From a4450cc6eee07bd0a3c1dfd1416b10f52fbf9cdf Mon Sep 17 00:00:00 2001 From: tim_graves <28924492+atimgraves@users.noreply.github.com> Date: Wed, 9 Sep 2026 14:00:11 +0100 Subject: [PATCH 13/13] set appropriate log levels --- ...tHttpOICClientNormalizedDataBasicRequestFilter.java | 10 +++++----- ...tHttpOICClientNormalizedDataOauthRequestFilter.java | 10 +++++----- ...CClientWrappedNormalizedDataBasicRequestFilter.java | 10 +++++----- ...CClientWrappedNormalizedDataOAuthRequestFilter.java | 10 +++++----- ...OutputHttpRestClientAuthenticatedRequestFilter.java | 10 +++++----- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java index a1c23a6..b4ef9dd 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataBasicRequestFilter.java @@ -88,11 +88,11 @@ public void doFilter(MutableHttpRequest request) { log.info(() -> "Adding user auth username=" + this.username); request.basicAuth(this.username, this.password); } - log.info(() -> "Request uri " + request.getUri().toASCIIString()); - log.info(() -> "Request path " + request.getPath()); - log.info(() -> "Request params = " + request.getParameters().asMap().toString()); - log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); - log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); + log.finer(() -> "Request uri " + request.getUri().toASCIIString()); + log.finer(() -> "Request path " + request.getPath()); + log.finer(() -> "Request params = " + request.getParameters().asMap().toString()); + log.finer(() -> "Request headers = " + request.getHeaders().asMap().toString()); + log.finer(() -> "Request body " + request.getBody(String.class).orElse("No body set")); } @PostConstruct diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java index 0ea0af6..744913e 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientNormalizedDataOauthRequestFilter.java @@ -90,11 +90,11 @@ public HttpResponse doFilter(MutableHttpRequest request) { } request.bearerAuth(token); log.info(() -> "Added OAuth token"); - log.info(() -> "Request uri " + request.getUri().toASCIIString()); - log.info(() -> "Request path " + request.getPath()); - log.info(() -> "Request params = " + request.getParameters().asMap().toString()); - log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); - log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); + log.finer(() -> "Request uri " + request.getUri().toASCIIString()); + log.finer(() -> "Request path " + request.getPath()); + log.finer(() -> "Request params = " + request.getParameters().asMap().toString()); + log.finer(() -> "Request headers = " + request.getHeaders().asMap().toString()); + log.finer(() -> "Request body " + request.getBody(String.class).orElse("No body set")); // it all went OK, tell the code to carry on return null; } diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java index 8f83408..ea70b0a 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataBasicRequestFilter.java @@ -90,11 +90,11 @@ public void doFilter(MutableHttpRequest request) { log.info(() -> "Adding user auth username=" + this.username); request.basicAuth(this.username, this.password); } - log.info(() -> "Request uri " + request.getUri().toASCIIString()); - log.info(() -> "Request path " + request.getPath()); - log.info(() -> "Request params = " + request.getParameters().asMap().toString()); - log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); - log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); + log.finer(() -> "Request uri " + request.getUri().toASCIIString()); + log.finer(() -> "Request path " + request.getPath()); + log.finer(() -> "Request params = " + request.getParameters().asMap().toString()); + log.finer(() -> "Request headers = " + request.getHeaders().asMap().toString()); + log.finer(() -> "Request body " + request.getBody(String.class).orElse("No body set")); } @PostConstruct diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java index 02ecc25..249dda8 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpOICClientWrappedNormalizedDataOAuthRequestFilter.java @@ -89,11 +89,11 @@ public void doFilter(MutableHttpRequest request) { } request.bearerAuth(token); log.info(() -> "Added OAuth token"); - log.info(() -> "Request uri " + request.getUri().toASCIIString()); - log.info(() -> "Request path " + request.getPath()); - log.info(() -> "Request params = " + request.getParameters().asMap().toString()); - log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); - log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); + log.finer(() -> "Request uri " + request.getUri().toASCIIString()); + log.finer(() -> "Request path " + request.getPath()); + log.finer(() -> "Request params = " + request.getParameters().asMap().toString()); + log.finer(() -> "Request headers = " + request.getHeaders().asMap().toString()); + log.finer(() -> "Request body " + request.getBody(String.class).orElse("No body set")); } @PostConstruct diff --git a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientAuthenticatedRequestFilter.java b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientAuthenticatedRequestFilter.java index a84925c..664646d 100644 --- a/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientAuthenticatedRequestFilter.java +++ b/IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/rest/requestfilters/IoTOutputHttpRestClientAuthenticatedRequestFilter.java @@ -88,11 +88,11 @@ public void doFilter(MutableHttpRequest request) { log.info(() -> "Adding user auth username=" + this.username); request.basicAuth(this.username, this.password); } - log.info(() -> "Request uri " + request.getUri().toASCIIString()); - log.info(() -> "Request path " + request.getPath()); - log.info(() -> "Request params = " + request.getParameters().asMap().toString()); - log.info(() -> "Request headers = " + request.getHeaders().asMap().toString()); - log.info(() -> "Request body " + request.getBody(String.class).orElse("No body set")); + log.finer(() -> "Request uri " + request.getUri().toASCIIString()); + log.finer(() -> "Request path " + request.getPath()); + log.finer(() -> "Request params = " + request.getParameters().asMap().toString()); + log.finer(() -> "Request headers = " + request.getHeaders().asMap().toString()); + log.finer(() -> "Request body " + request.getBody(String.class).orElse("No body set")); } @EventListener