在Android中使用按键实现Play Integrity

问题描述 投票:0回答:1

到目前为止我一直在使用 SafetyNet 进行 Playstore 密钥验证,但现在我们无法使用 SafetyNet。所以我对代码进行了更改。我面临的问题是,我无法测试实施是否正确。任何人都可以指导我如何进行测试。下面我写了代码。 注:下面提到的按键是splash key,使用的是splash page。

String str ="BYY1Mzk3NTAxMjYbcqu2NTM5NzUwMTI5SCv=";
         byte[] strBytes = android.util.Base64.decode(str, android.util.Base64.DEFAULT);
        byte[] encoded = android.util.Base64.encode(
                strBytes, android.util.Base64.URL_SAFE | android.util.Base64.NO_PADDING | android.util.Base64.NO_WRAP);
        String nonce =  new String(encoded);   
     RootBeer rootBeer = new RootBeer(this);
        if (rootBeer.isRooted()) {
            android.os.Process.killProcess(android.os.Process.myPid());
        } else {
            if (rootBeer.isRootedWithBusyBoxCheck()) {
                android.os.Process.killProcess(android.os.Process.myPid());
            } else {
                IntegrityManager integrityManager =
                        IntegrityManagerFactory.create(getApplicationContext());
                if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this)
                        == ConnectionResult.SUCCESS) {
                    Task<IntegrityTokenResponse> integrityTokenResponse =
                            integrityManager
                                    .requestIntegrityToken(
                                            IntegrityTokenRequest.builder().setNonce(nonce).build());
                    integrityTokenResponse.addOnSuccessListener(new OnSuccessListener<IntegrityTokenResponse>() {
                                                                    @Override
                                                                    public void onSuccess(IntegrityTokenResponse integrityTokenResponse) {
                                                                       });
                            integrityTokenResponse.addOnFailureListener(new OnFailureListener() {
                                @Override
                                public void onFailure(@NonNull Exception e) {
                                    });

                } else {
                    android.os.Process.killProcess(android.os.Process.myPid());
                }}}}

我实现了相同的内容并测试了 apk,但有了它我就可以登录,以防万一因为我使用了错误的启动键而失败。

android google-play-services safetynet google-play-integrity-api google-play-internal-testing
1个回答
0
投票

您是否已将其链接到云(Firebase)项目?一般来说,它是您用于 Crashlytics 的那个。您需要发送项目 ID(在构建原始请求时将其添加为参数)...获得令牌后,您将需要解密。如果您是“由 google 签名”,则应将其发送到 Firebase 进行解密,如果您尚未由 google 签名,则需要在 Play 商店门户中创建并注册密钥,并使用该密钥对对其进行解密...结果 JSON 在令牌中希望有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.