-
Notifications
You must be signed in to change notification settings - Fork 0
httpsurlconn service message-signing integration #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cb68ebc
Added installation message signing functinality through service mutat…
692f522
Update approov-service/src/main/java/io/approov/service/httpsurlconn/…
charlesoj6205 582ef33
Update approov-service/src/main/java/io/approov/service/httpsurlconn/…
charlesoj6205 49171d4
Update approov-service/src/main/java/io/approov/service/httpsurlconn/…
charlesoj6205 50b5a6b
Update approov-service/src/main/java/io/approov/service/httpsurlconn/…
charlesoj6205 7f50bde
Update approov-service/src/main/java/io/approov/service/httpsurlconn/…
charlesoj6205 ce29811
Update approov-service/src/main/java/io/approov/service/httpsurlconn/…
charlesoj6205 4ceb5be
Update approov-service/src/main/java/io/approov/service/httpsurlconn/…
charlesoj6205 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
661 changes: 661 additions & 0 deletions
661
...v-service/src/main/java/io/approov/service/httpsurlconn/ApproovDefaultMessageSigning.java
Large diffs are not rendered by default.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
...ov-service/src/main/java/io/approov/service/httpsurlconn/ApproovFetchStatusException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // | ||
| // MIT License | ||
| // | ||
| // Copyright (c) 2016-present, Approov Ltd. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files | ||
| // (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, | ||
| // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | ||
| // subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall 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 io.approov.service.httpsurlconn; | ||
|
|
||
| import com.criticalblue.approovsdk.Approov; | ||
|
|
||
| /** | ||
| * Exception raised when an Approov token fetch returns a status other than success. | ||
| */ | ||
| public class ApproovFetchStatusException extends ApproovException { | ||
|
|
||
| private final Approov.TokenFetchStatus tokenFetchStatus; | ||
|
|
||
| /** | ||
| * Constructs a token fetch status exception with the provided status. | ||
| * | ||
| * @param status status returned by the Approov SDK, may be {@code null} if unavailable | ||
| * @param message information describing the exception cause | ||
| */ | ||
| public ApproovFetchStatusException(Approov.TokenFetchStatus status, String message) { | ||
| super(message); | ||
| this.tokenFetchStatus = status; | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves the token fetch status associated with this exception. | ||
| * | ||
| * @return the status returned by the Approov SDK, or {@code null} if not provided | ||
| */ | ||
| public Approov.TokenFetchStatus getTokenFetchStatus() { | ||
| return tokenFetchStatus; | ||
| } | ||
| } |
59 changes: 59 additions & 0 deletions
59
...v-service/src/main/java/io/approov/service/httpsurlconn/ApproovInterceptorExtensions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // | ||
| // MIT License | ||
| // | ||
| // Copyright (c) 2016-present, Approov Ltd. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files | ||
| // (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, | ||
| // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | ||
| // subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall 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 io.approov.service.httpsurlconn; | ||
|
|
||
| import java.net.URL; | ||
| import java.net.HttpURLConnection; | ||
|
|
||
| import javax.net.ssl.HttpsURLConnection; | ||
|
|
||
| /** | ||
| * ApproovInterceptorExtensions provides an interface for handling callbacks during | ||
| * the processing of network requests by Approov. It allows further modifications | ||
| * to requests after Approov has applied its changes. | ||
| * | ||
| * @deprecated Replace implementations of this interface with ApproovServiceMutator | ||
| * while changing the name of the ApproovInterceptorExtensions.processedRequest | ||
| * method to ApproovServiceMutator.handleInterceptorProcessedRequest. | ||
| */ | ||
| @Deprecated | ||
| public interface ApproovInterceptorExtensions extends ApproovServiceMutator{ | ||
|
|
||
| /** | ||
| * Replace the default implementation of ApproovServiceMutator.handleInterceptorProcessedRequest | ||
| * to call the now deprecated ApproovInterceptorExtensions.processedRequest method. | ||
| * | ||
| * @param request the processed request | ||
| * @param changes the mutations applied to the request by Approov | ||
| * @return the final request to use to complete the Approov interceptor step. | ||
| * @throws ApproovException if there is an error during processing | ||
| */ | ||
| default HttpsURLConnection handleInterceptorProcessedRequest(HttpsURLConnection request, ApproovRequestMutations changes) throws ApproovException { | ||
| // call the deprecated method to maintain backwards compatibility | ||
| return processedRequest(request, changes); | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated Use ApproovServiceMutator.handleInterceptorProcessedRequest instead. | ||
| */ | ||
| @Deprecated | ||
| default HttpsURLConnection processedRequest(HttpsURLConnection request, ApproovRequestMutations changes) throws ApproovException { | ||
| // No further changes to the request are required | ||
| return request; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
approov-service/src/main/java/io/approov/service/httpsurlconn/ApproovRequestMutations.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // | ||
| // MIT License | ||
| // | ||
| // Copyright (c) 2016-present, Approov Ltd. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files | ||
| // (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, | ||
| // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | ||
| // subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall 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 io.approov.service.httpsurlconn; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * ApproovRequestMutations stores information about changes made to a network request | ||
| * during Approov processing, such as token headers, substituted headers, and query parameters. | ||
| */ | ||
| public class ApproovRequestMutations { | ||
| private String tokenHeaderKey; | ||
| private List<String> substitutionHeaderKeys; | ||
| private String originalURL; | ||
| private List<String> substitutionQueryParamKeys; | ||
| private String traceIDHeaderKey; | ||
|
|
||
|
|
||
| /** | ||
| * Gets the header key used for the Approov token. | ||
| * | ||
| * @return the Approov token header key | ||
| */ | ||
| public String getTokenHeaderKey() { | ||
| return tokenHeaderKey; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the header key used for the Approov token. | ||
| * | ||
| * @param tokenHeaderKey the Approov token header key | ||
| */ | ||
| public void setTokenHeaderKey(String tokenHeaderKey) { | ||
| this.tokenHeaderKey = tokenHeaderKey; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the list of headers that were substituted with secure strings. | ||
| * | ||
| * @return the list of substituted header keys | ||
| */ | ||
| public List<String> getSubstitutionHeaderKeys() { | ||
| return substitutionHeaderKeys; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the list of headers that were substituted with secure strings. | ||
| * | ||
| * @param substitutionHeaderKeys the list of substituted header keys | ||
| */ | ||
| public void setSubstitutionHeaderKeys(List<String> substitutionHeaderKeys) { | ||
| this.substitutionHeaderKeys = substitutionHeaderKeys; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the original URL before any query parameter substitutions. | ||
| * | ||
| * @return the original URL | ||
| */ | ||
| public String getOriginalURL() { | ||
| return originalURL; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the list of query parameter keys that were substituted with secure strings. | ||
| * | ||
| * @return the list of substituted query parameter keys | ||
| */ | ||
| public List<String> getSubstitutionQueryParamKeys() { | ||
| return substitutionQueryParamKeys; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the results of query parameter substitutions, including the original URL and the keys of substituted parameters. | ||
| * | ||
| * @param originalURL the original URL before substitutions | ||
| * @param substitutionQueryParamKeys the list of substituted query parameter keys | ||
| */ | ||
| public void setSubstitutionQueryParamResults(String originalURL, List<String> substitutionQueryParamKeys) { | ||
| this.originalURL = originalURL; | ||
| this.substitutionQueryParamKeys = substitutionQueryParamKeys; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the header key used for the optional Approov TraceID debug header. | ||
| * | ||
| * @return the Approov TraceID header key. Null if the TraceID header was not used. | ||
| */ | ||
| public String getTraceIDHeaderKey() { | ||
| return traceIDHeaderKey; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the header key used for the optional Approov TraceID debug header. | ||
| * | ||
| * @param traceIDHeaderKey the Approov TraceID header key | ||
| */ | ||
| public void setTraceIDHeaderKey(String traceIDHeaderKey) { | ||
| this.traceIDHeaderKey = traceIDHeaderKey; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compileSdkVersion(30) is lower thantargetSdkVersion(34), which is likely to fail Android build/tooling checks. Align these values (typically setcompileSdkVersion>=targetSdkVersion), and confirm whether raisingminSdkVersionfrom 21 to 23 is intended (it’s a breaking change for library consumers).