Skip to content

Commit 874ef41

Browse files
Resolves comments
1 parent ff30974 commit 874ef41

13 files changed

+216
-88
lines changed

appcheck/firebase-appcheck-recaptchaenterprise/firebase-appcheck-recaptchaenterprise.gradle

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 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+
115
plugins {
216
id 'firebase-library'
317
}
@@ -32,14 +46,10 @@ android {
3246
}
3347

3448
dependencies {
35-
javadocClasspath libs.autovalue.annotations
36-
3749
api project(':appcheck:firebase-appcheck')
38-
api libs.firebase.annotations
39-
api libs.firebase.common.v2200
40-
api libs.firebase.common.ktx
41-
api libs.firebase.components.v1800
42-
api libs.recaptcha.v1871
50+
api 'com.google.firebase:firebase-common'
51+
api 'com.google.firebase:firebase-components'
52+
api 'com.google.android.recaptcha:recaptcha:18.7.1'
4353

4454
testImplementation(project(":integ-testing")) {
4555
exclude group: 'com.google.firebase', module: 'firebase-common'
@@ -48,6 +58,6 @@ dependencies {
4858
testImplementation libs.androidx.test.core
4959
testImplementation libs.truth
5060
testImplementation libs.junit
51-
testImplementation libs.mockito.core.v5120
61+
testImplementation libs.mockito.core
5262
testImplementation libs.robolectric
5363
}

appcheck/firebase-appcheck-recaptchaenterprise/src/main/AndroidManifest.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?><!-- Copyright 2025 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. -->
214

315
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
416

appcheck/firebase-appcheck-recaptchaenterprise/src/main/java/com/google/firebase/appcheck/recaptchaenterprise/FirebaseAppCheckRecaptchaEnterpriseRegistrar.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1+
// Copyright 2025 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+
115
package com.google.firebase.appcheck.recaptchaenterprise;
216

317
import android.app.Application;
4-
import android.content.Context;
518
import com.google.android.gms.common.annotation.KeepForSdk;
19+
import com.google.firebase.FirebaseApp;
620
import com.google.firebase.annotations.concurrent.Blocking;
721
import com.google.firebase.annotations.concurrent.Lightweight;
822
import com.google.firebase.appcheck.recaptchaenterprise.internal.FirebaseExecutors;
@@ -33,11 +47,11 @@ public List<Component<?>> getComponents() {
3347
return Arrays.asList(
3448
Component.builder(Application.class)
3549
.name(LIBRARY_NAME)
36-
.add(Dependency.required(Context.class))
50+
.add(Dependency.required(FirebaseApp.class))
3751
.factory(
3852
container -> {
39-
Context context = container.get(Context.class);
40-
return (Application) context.getApplicationContext();
53+
FirebaseApp firebaseApp = container.get(FirebaseApp.class);
54+
return (Application) firebaseApp.getApplicationContext();
4155
})
4256
.build(),
4357
Component.builder(FirebaseExecutors.class)

appcheck/firebase-appcheck-recaptchaenterprise/src/main/java/com/google/firebase/appcheck/recaptchaenterprise/RecaptchaEnterpriseAppCheckProviderFactory.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 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+
115
package com.google.firebase.appcheck.recaptchaenterprise;
216

317
import android.app.Application;

appcheck/firebase-appcheck-recaptchaenterprise/src/main/java/com/google/firebase/appcheck/recaptchaenterprise/internal/ExchangeRecaptchaEnterpriseTokenRequest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 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+
115
package com.google.firebase.appcheck.recaptchaenterprise.internal;
216

317
import androidx.annotation.NonNull;

appcheck/firebase-appcheck-recaptchaenterprise/src/main/java/com/google/firebase/appcheck/recaptchaenterprise/internal/FirebaseExecutors.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 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+
115
package com.google.firebase.appcheck.recaptchaenterprise.internal;
216

317
import com.google.firebase.annotations.concurrent.Blocking;

appcheck/firebase-appcheck-recaptchaenterprise/src/main/java/com/google/firebase/appcheck/recaptchaenterprise/internal/RecaptchaEnterpriseAppCheckProvider.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 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+
115
package com.google.firebase.appcheck.recaptchaenterprise.internal;
216

317
import android.app.Application;
@@ -21,6 +35,18 @@
2135
import java.util.Objects;
2236
import java.util.concurrent.Executor;
2337

38+
/**
39+
* An implementation of {@link AppCheckProvider} that uses reCAPTCHA Enterprise for device
40+
* attestation.
41+
*
42+
* <p>This class orchestrates the flow:
43+
*
44+
* <ol>
45+
* <li>Obtain a reCAPTCHA token via {@code RecaptchaTasksClient}.
46+
* <li>Exchange the reCAPTCHA token with the Firebase App Check backend using {@link
47+
* NetworkClient} to receive a Firebase App Check token.
48+
* </ol>
49+
*/
2450
public class RecaptchaEnterpriseAppCheckProvider implements AppCheckProvider {
2551

2652
private final RecaptchaAction recaptchaAction = RecaptchaAction.custom("fire_app_check");
@@ -93,7 +119,7 @@ private Task<String> getRecaptchaEnterpriseAttestation() {
93119
return client.executeTask(recaptchaAction);
94120
} else {
95121
Log.w(TAG, "Recaptcha task failed", task.getException());
96-
throw Objects.requireNonNull(task.getException());
122+
return Tasks.forException((Objects.requireNonNull(task.getException())));
97123
}
98124
});
99125
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1+
// Copyright 2025 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+
115
/** @hide */
216
package com.google.firebase.appcheck.recaptchaenterprise.internal;

appcheck/firebase-appcheck-recaptchaenterprise/src/test/java/com/google/firebase/appcheck/recaptchaenterprise/FirebaseAppCheckRecaptchaEnterpriseRegistrarTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 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+
115
package com.google.firebase.appcheck.recaptchaenterprise;
216

317
import static com.google.common.truth.Truth.assertThat;

appcheck/firebase-appcheck-recaptchaenterprise/src/test/java/com/google/firebase/appcheck/recaptchaenterprise/RecaptchaEnterpriseAppCheckProviderFactoryTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 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+
115
package com.google.firebase.appcheck.recaptchaenterprise;
216

317
import static com.google.common.truth.Truth.assertThat;

0 commit comments

Comments
 (0)