Skip to content

Commit

Permalink
Merge branch 'master' into g_master
Browse files Browse the repository at this point in the history
  • Loading branch information
qingcuilu committed Nov 18, 2024
2 parents 7b298ea + a19134e commit 72b8c37
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion soter-client-sdk/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# org.gradle.parallel=true
#Tue May 09 20:42:37 CST 2017
org.gradle.internal.publish.checksums.insecure=true
VERSION_NAME_PREFIX=2.1.14
VERSION_NAME_PREFIX=2.1.15
VERSION_NAME_SUFFIX=
#VERSION_NAME_SUFFIX=-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.util.Log;

import com.tencent.soter.core.SoterCore;
import com.tencent.soter.core.model.CertUtil;
import com.tencent.soter.core.model.ConstantsSoter;
import com.tencent.soter.core.model.ISoterLogger;
import com.tencent.soter.core.model.SLogger;
Expand Down Expand Up @@ -194,28 +195,32 @@ private String getCompatDistinguishSalt(@NonNull String previousSalt) {

// check if there's any keys invalid and need to be deleted
private void removeAbnormalKeys() {
SharedPreferences preferences = SoterDataCenter.getInstance().getStatusSharedPreference();
int askStatus = preferences.getInt(SoterCoreData.getInstance().getAskName(), ConstantsSoterProcess.KeyStatus.KEY_STATUS_UNDEFINED);
SLogger.d(TAG, "soter: ask status: %d", askStatus);
if(isKeyStatusInvalid(askStatus) && SoterCore.hasAppGlobalSecureKey()) {
SLogger.i(TAG, "invalid ask, remove all key");
SoterCore.removeAppGlobalSecureKey();
for (int scene : scenes) {
String keyName = SoterDataCenter.getInstance().getAuthKeyNames().get(scene, "");
SoterCore.removeAuthKey(keyName, false);
}
} else {
for (int scene : scenes) {
String keyName = SoterDataCenter.getInstance().getAuthKeyNames().get(scene, "");
if(!SoterCoreUtil.isNullOrNil(keyName)) {
int keyStatus = preferences.getInt(keyName, ConstantsSoterProcess.KeyStatus.KEY_STATUS_NORMAL);
SLogger.d(TAG, "soter: %s status: %d", keyName, keyStatus);
if(isKeyStatusInvalid(keyStatus) && SoterCore.hasAuthKey(keyName)) {
SLogger.i(TAG, "remove invalid ask: %s", keyName);
SoterCore.removeAuthKey(keyName, false);
try{
SharedPreferences preferences = SoterDataCenter.getInstance().getStatusSharedPreference();
int askStatus = preferences.getInt(SoterCoreData.getInstance().getAskName(), ConstantsSoterProcess.KeyStatus.KEY_STATUS_UNDEFINED);
SLogger.d(TAG, "soter: ask status: %d", askStatus);
if(isKeyStatusInvalid(askStatus) && SoterCore.hasAppGlobalSecureKey()) {
SLogger.i(TAG, "invalid ask, remove all key");
SoterCore.removeAppGlobalSecureKey();
for (int scene : scenes) {
String keyName = SoterDataCenter.getInstance().getAuthKeyNames().get(scene, "");
SoterCore.removeAuthKey(keyName, false);
}
} else {
for (int scene : scenes) {
String keyName = SoterDataCenter.getInstance().getAuthKeyNames().get(scene, "");
if(!SoterCoreUtil.isNullOrNil(keyName)) {
int keyStatus = preferences.getInt(keyName, ConstantsSoterProcess.KeyStatus.KEY_STATUS_NORMAL);
SLogger.d(TAG, "soter: %s status: %d", keyName, keyStatus);
if(isKeyStatusInvalid(keyStatus) && SoterCore.hasAuthKey(keyName)) {
SLogger.i(TAG, "remove invalid ask: %s", keyName);
SoterCore.removeAuthKey(keyName, false);
}
}
}
}
}catch (Exception e){
SLogger.printErrStackTrace(TAG, e, "soter: removeAbnormalKeys failed");
}
}

Expand Down

0 comments on commit 72b8c37

Please sign in to comment.