Skip to content

Commit 5392271

Browse files
James CharlesonJames Charleson
authored andcommitted
HttpsURLConn quickstart now includes installation message signing in line with updates to HttpsURLConn service layer. V5 endpoint tested successfully. Instructional files within quickstart require further updates. Reverted quickstart to original V1 state with installation message signing changes commented out.
1 parent 3f87394 commit 5392271

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

shapes-app/app/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ android {
44
compileSdkVersion 31
55
defaultConfig {
66
applicationId "io.approov.shapes"
7-
minSdkVersion 21
7+
minSdkVersion 23
88
targetSdkVersion 31
99
versionCode 3
1010
versionName "3.0"
@@ -32,6 +32,8 @@ android {
3232
}
3333

3434
dependencies {
35+
// implementation 'androidx.annotation:annotation:1.8.2'
3536
implementation fileTree(dir: 'libs', include: ['*.jar'])
3637
implementation 'androidx.appcompat:appcompat:1.4.1'
38+
implementation project(':approov-service')
3739
}

shapes-app/app/src/main/java/io/approov/shapes/MainActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ public void run() {
205205
URL url = new URL(getResources().getString(R.string.shapes_url));
206206
connection = (HttpsURLConnection) url.openConnection();
207207
connection.setRequestMethod("GET");
208+
// Keep the originally signed request target unchanged (redirects can invalidate signatures).
209+
connection.setInstanceFollowRedirects(false);
208210
connection.addRequestProperty("Api-Key", getResources().getString(R.string.shapes_api_key));
209211

210212
// *** UNCOMMENT THE LINE BELOW FOR APPROOV USING SECRETS PROTECTION ***
@@ -214,6 +216,7 @@ public void run() {
214216
//ApproovService.addApproov(connection);
215217

216218
connection.connect();
219+
217220
msg = "Http status code " + connection.getResponseCode();
218221
if (connection.getResponseCode() == 200)
219222
imgId = readShapesResponse(connection);

shapes-app/app/src/main/java/io/approov/shapes/ShapesApp.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,23 @@
2222
// *** UNCOMMENT THE LINE BELOW FOR APPROOV ***
2323
//import io.approov.service.httpsurlconn.ApproovService;
2424

25+
// *** UNCOMMENT THE LINE BELOW FOR APPROOV WITH INSTALLATION MESSAGE SIGNING ***
26+
//import io.approov.service.httpsurlconn.ApproovDefaultMessageSigning;
27+
2528

2629
public class ShapesApp extends Application {
2730
@Override
2831
public void onCreate() {
2932
super.onCreate();
3033

3134
// *** UNCOMMENT THE LINE BELOW FOR APPROOV ***
32-
//ApproovService.initialize(getApplicationContext(), "<enter-your-config-string-here>");
35+
//ApproovService.initialize(getApplicationContext(), "#199896#cjjyY5WNuuhkdzTDYV49eGZfXOYbnQrL16nzxoYqWbc=");
36+
37+
// *** UNCOMMENT THE LINES BELOW FOR APPROOV WITH INSTALLATION MESSAGE SIGNING ***
38+
// ApproovService.setServiceMutator(
39+
// new ApproovDefaultMessageSigning()
40+
// .setDefaultFactory(ApproovDefaultMessageSigning.generateDefaultSignatureParametersFactory())
41+
// );
42+
3343
}
3444
}

shapes-app/settings.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
include ':approov-sdk'
1+
//include ':approov-sdk'
22
include ':app'
3+
include ':approov-service'
4+
project(':approov-service').projectDir = new File('/Users/charlesoj/Developer/Quickstarts/approov-service-httpsurlconn/approov-service')

0 commit comments

Comments
 (0)