Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,30 @@ public WrappedNormalizedDataHttpOICOutput(WrappedNormalizedDataIoTOutputHttpOICC
public NormalizedData[] processNormalizedData(NormalizedData input) throws Exception {
log.info(() -> "NormalizedData is " + input);
HttpResponse<Void> 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.oracle.demo.timg.iot.iotdbjdbc.messagehandler.outputs.http.rest.requestfilters;

public enum HttpAuthType {
BASIC, OAUTH2
}
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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";

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,26 @@ 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
@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 {
@Singleton
public class IoTOutputHttpOICClientNormalizedDataBasicRequestFilter {
@Property(name = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_PROPERTY, defaultValue = IoTOutputHttpOICClientNormalizedDataSimpleSettings.TARGET_PATH_DEFAULT
+ "/**")
private String patternPath;
private final String username;
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)) {
Expand All @@ -85,16 +88,16 @@ 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
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);
}
}
Loading