| | |
| | | import com.runt.open.mvi.utils.GsonUtils; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | |
| | | private final TypeAdapter<T> adapter; |
| | | private final Charset UTF_8 = Charset.forName("UTF-8"); |
| | | private final boolean transHump;//驼峰转换 |
| | | private final String ENCRYPT = "encrypt"; |
| | | private final String ENCRYPT = "body"; |
| | | |
| | | public DecryptGsonResponseBodyConverter(Gson gson, TypeAdapter<T> adapter, boolean transHump) { |
| | | this.gson = gson; |
| | |
| | | if(TextUtils.isEmpty(body)){ |
| | | |
| | | }else if(body.indexOf("{") == 0) { |
| | | JSONObject json = new JSONObject(body); |
| | | body = RSAUtils.decrypt(json.getString(ENCRYPT), RSAUtils.getPublicKey(RSAUtils.PUBLIC_KEY));// |
| | | //Log.e("Converter", "decryptJsonStr body:" + body); |
| | | body = RSAUtils.decryptVerify(body,ENCRYPT); |
| | | } |
| | | return transHump? GsonUtils.toHumpJson(body):body; |
| | | } |