Skip to content

Commit af391ae

Browse files
committed
Merge remote-tracking branch 'origin/master' into m1-mac-fixes
2 parents 5c5dcdb + 20da1e7 commit af391ae

File tree

47 files changed

+1342
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1342
-197
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=16.0.0-beta06
1+
version=16.0.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=16.0.0-beta06
1+
version=16.0.0

appcheck/firebase-appcheck-debug/src/test/java/com/google/firebase/appcheck/debug/internal/DebugAppCheckProviderTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
public class DebugAppCheckProviderTest {
5151

5252
private static final String DEBUG_SECRET = "debugSecret";
53-
private static final String ATTESTATION_TOKEN = "token";
53+
private static final String APP_CHECK_TOKEN = "appCheckToken";
5454
private static final String TIME_TO_LIVE = "3600s";
5555
private static final String API_KEY = "apiKey";
5656
private static final String APP_ID = "appId";
@@ -128,7 +128,7 @@ public void exchangeDebugToken_onSuccess_setsTaskResult() throws Exception {
128128
when(mockNetworkClient.exchangeAttestationForAppCheckToken(
129129
any(), eq(NetworkClient.DEBUG), eq(mockRetryManager)))
130130
.thenReturn(mockAppCheckTokenResponse);
131-
when(mockAppCheckTokenResponse.getAttestationToken()).thenReturn(ATTESTATION_TOKEN);
131+
when(mockAppCheckTokenResponse.getToken()).thenReturn(APP_CHECK_TOKEN);
132132
when(mockAppCheckTokenResponse.getTimeToLive()).thenReturn(TIME_TO_LIVE);
133133

134134
DebugAppCheckProvider provider =
@@ -141,7 +141,7 @@ public void exchangeDebugToken_onSuccess_setsTaskResult() throws Exception {
141141

142142
AppCheckToken token = task.getResult();
143143
assertThat(token).isInstanceOf(DefaultAppCheckToken.class);
144-
assertThat(token.getToken()).isEqualTo(ATTESTATION_TOKEN);
144+
assertThat(token.getToken()).isEqualTo(APP_CHECK_TOKEN);
145145
}
146146

147147
@Test
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.0.0-beta06
2-
latestReleasedVersion=16.0.0-beta05
1+
version=16.0.0
2+
latestReleasedVersion=16.0.0-beta06
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
plugins {
16+
id 'firebase-library'
17+
}
18+
19+
firebaseLibrary {
20+
publishSources = true
21+
}
22+
23+
android {
24+
adbOptions {
25+
timeOutInMs 60 * 1000
26+
}
27+
28+
compileSdkVersion project.targetSdkVersion
29+
defaultConfig {
30+
targetSdkVersion project.targetSdkVersion
31+
minSdkVersion project.minSdkVersion
32+
versionName version
33+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
34+
}
35+
compileOptions {
36+
sourceCompatibility JavaVersion.VERSION_1_8
37+
targetCompatibility JavaVersion.VERSION_1_8
38+
}
39+
40+
testOptions.unitTests.includeAndroidResources = false
41+
}
42+
43+
dependencies {
44+
implementation project(':firebase-common')
45+
implementation project(':firebase-components')
46+
implementation project(':appcheck:firebase-appcheck')
47+
implementation 'com.google.android.gms:play-services-base:18.0.1'
48+
implementation 'com.google.android.gms:play-services-tasks:18.0.1'
49+
implementation 'com.google.android.play:integrity:1.0.1'
50+
51+
testImplementation 'junit:junit:4.13.2'
52+
testImplementation 'org.mockito:mockito-core:3.4.6'
53+
testImplementation "com.google.truth:truth:$googleTruthVersion"
54+
testImplementation "org.robolectric:robolectric:$robolectricVersion"
55+
testImplementation 'androidx.test:core:1.4.0'
56+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=16.0.0
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2022 Google LLC -->
3+
<!-- -->
4+
<!-- Licensed under the Apache License, Version 2.0 (the "License"); -->
5+
<!-- you may not use this file except in compliance with the License. -->
6+
<!-- You may obtain a copy of the License at -->
7+
<!-- -->
8+
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
9+
<!-- -->
10+
<!-- Unless required by applicable law or agreed to in writing, software -->
11+
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
12+
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
13+
<!-- See the License for the specific language governing permissions and -->
14+
<!-- limitations under the License. -->
15+
16+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
17+
package="com.google.firebase.appcheck.playintegrity">
18+
<!--Although the *SdkVersion is captured in gradle build files, this is required for non gradle builds-->
19+
<!--<uses-sdk android:minSdkVersion="16"/>-->
20+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.appcheck.playintegrity;
16+
17+
import androidx.annotation.NonNull;
18+
import com.google.firebase.FirebaseApp;
19+
import com.google.firebase.appcheck.AppCheckProvider;
20+
import com.google.firebase.appcheck.AppCheckProviderFactory;
21+
import com.google.firebase.appcheck.playintegrity.internal.PlayIntegrityAppCheckProvider;
22+
23+
/**
24+
* Implementation of an {@link AppCheckProviderFactory} that builds {@link
25+
* PlayIntegrityAppCheckProvider}s. This is the default implementation.
26+
*/
27+
public class PlayIntegrityAppCheckProviderFactory implements AppCheckProviderFactory {
28+
29+
private static final PlayIntegrityAppCheckProviderFactory instance =
30+
new PlayIntegrityAppCheckProviderFactory();
31+
32+
/**
33+
* Gets an instance of this class for installation into a {@link
34+
* com.google.firebase.appcheck.FirebaseAppCheck} instance.
35+
*/
36+
@NonNull
37+
public static PlayIntegrityAppCheckProviderFactory getInstance() {
38+
return instance;
39+
}
40+
41+
@NonNull
42+
@Override
43+
public AppCheckProvider create(@NonNull FirebaseApp firebaseApp) {
44+
return new PlayIntegrityAppCheckProvider(firebaseApp);
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.appcheck.playintegrity.internal;
16+
17+
import androidx.annotation.NonNull;
18+
import androidx.annotation.VisibleForTesting;
19+
import org.json.JSONException;
20+
import org.json.JSONObject;
21+
22+
/**
23+
* Client-side model of the ExchangePlayIntegrityTokenRequest payload from the Firebase App Check
24+
* Token Exchange API.
25+
*/
26+
class ExchangePlayIntegrityTokenRequest {
27+
28+
@VisibleForTesting static final String PLAY_INTEGRITY_TOKEN_KEY = "playIntegrityToken";
29+
30+
private final String playIntegrityToken;
31+
32+
public ExchangePlayIntegrityTokenRequest(@NonNull String playIntegrityToken) {
33+
this.playIntegrityToken = playIntegrityToken;
34+
}
35+
36+
@NonNull
37+
public String toJsonString() throws JSONException {
38+
JSONObject jsonObject = new JSONObject();
39+
jsonObject.put(PLAY_INTEGRITY_TOKEN_KEY, playIntegrityToken);
40+
41+
return jsonObject.toString();
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.appcheck.playintegrity.internal;
16+
17+
import androidx.annotation.NonNull;
18+
import org.json.JSONObject;
19+
20+
/**
21+
* Client-side model of the GeneratePlayIntegrityChallengeRequest payload from the Firebase App
22+
* Check Token Exchange API.
23+
*/
24+
class GeneratePlayIntegrityChallengeRequest {
25+
26+
public GeneratePlayIntegrityChallengeRequest() {}
27+
28+
@NonNull
29+
public String toJsonString() {
30+
JSONObject jsonObject = new JSONObject();
31+
32+
// GeneratePlayIntegrityChallenge takes an empty POST body since the app ID is in the URL.
33+
return jsonObject.toString();
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.appcheck.playintegrity.internal;
16+
17+
import static com.google.android.gms.common.internal.Preconditions.checkNotNull;
18+
import static com.google.android.gms.common.util.Strings.emptyToNull;
19+
20+
import androidx.annotation.NonNull;
21+
import androidx.annotation.VisibleForTesting;
22+
import com.google.firebase.FirebaseException;
23+
import org.json.JSONException;
24+
import org.json.JSONObject;
25+
26+
/**
27+
* Client-side model of the GeneratePlayIntegrityChallengeResponse payload from the Firebase App
28+
* Check Token Exchange API.
29+
*/
30+
class GeneratePlayIntegrityChallengeResponse {
31+
32+
@VisibleForTesting static final String CHALLENGE_KEY = "challenge";
33+
@VisibleForTesting static final String TIME_TO_LIVE_KEY = "ttl";
34+
35+
private String challenge;
36+
private String timeToLive;
37+
38+
@NonNull
39+
public static GeneratePlayIntegrityChallengeResponse fromJsonString(@NonNull String jsonString)
40+
throws FirebaseException, JSONException {
41+
JSONObject jsonObject = new JSONObject(jsonString);
42+
String challenge = emptyToNull(jsonObject.optString(CHALLENGE_KEY));
43+
String timeToLive = emptyToNull(jsonObject.optString(TIME_TO_LIVE_KEY));
44+
if (challenge == null || timeToLive == null) {
45+
throw new FirebaseException("Unexpected server response.");
46+
}
47+
return new GeneratePlayIntegrityChallengeResponse(challenge, timeToLive);
48+
}
49+
50+
private GeneratePlayIntegrityChallengeResponse(
51+
@NonNull String challenge, @NonNull String timeToLive) {
52+
checkNotNull(challenge);
53+
checkNotNull(timeToLive);
54+
this.challenge = challenge;
55+
this.timeToLive = timeToLive;
56+
}
57+
58+
@NonNull
59+
public String getChallenge() {
60+
return challenge;
61+
}
62+
63+
@NonNull
64+
public String getTimeToLive() {
65+
return timeToLive;
66+
}
67+
}

0 commit comments

Comments
 (0)