use of com.microsoft.identity.common.internal.util.GzipUtil.compressString in project microsoft-authentication-library-common-for-android by AzureAD.
the class MsalBrokerResultAdapter method bundleFromAccounts.
@NonNull
public Bundle bundleFromAccounts(@NonNull final List<ICacheRecord> cacheRecords, @Nullable final String negotiatedProtocolVersion) {
final Bundle resultBundle = new Bundle();
final String jsonString = JsonExtensions.getJsonStringFromICacheRecordList(cacheRecords);
if (BrokerProtocolVersionUtil.canCompressBrokerPayloads(negotiatedProtocolVersion)) {
try {
byte[] bytes = GzipUtil.compressString(jsonString);
Logger.info(TAG, "Get accounts, raw payload size :" + jsonString.getBytes().length + " compressed size " + bytes.length);
resultBundle.putByteArray(BROKER_ACCOUNTS_COMPRESSED, bytes);
} catch (IOException e) {
Logger.error(TAG, " Failed to compress account list to bytes, sending as jsonString", e);
resultBundle.putString(BROKER_ACCOUNTS, jsonString);
}
} else {
Logger.info(TAG, "Broker protocol version: " + negotiatedProtocolVersion + " lower than compression changes, sending as string");
resultBundle.putString(BROKER_ACCOUNTS, jsonString);
}
return resultBundle;
}
Aggregations