Skip to content

Commit 24010af

Browse files
authored
Merge pull request #550 from AzureAD/release/1.3.2
Merge release 1.3.2 into master
2 parents 4212aad + 8f1ba44 commit 24010af

File tree

51 files changed

+1013
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1013
-155
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode10.2
2+
osx_image: xcode11
33

44
# Set up our rubygems (slather and xcpretty, namely)
55
install:

IdentityCore/IdentityCore.xcodeproj/project.pbxproj

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,12 @@
304304
23DADC1120B8BF4F005D7389 /* MSIDAadAuthorityCacheRecord.m in Sources */ = {isa = PBXBuildFile; fileRef = 23DADC0F20B8BF4F005D7389 /* MSIDAadAuthorityCacheRecord.m */; };
305305
23F32F251FFDAF1900B2905E /* MSIDTestBrokerResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = B2D81BBD1FF5C7460093859A /* MSIDTestBrokerResponse.m */; };
306306
23F32F261FFDAF1A00B2905E /* MSIDTestBrokerResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = B2D81BBD1FF5C7460093859A /* MSIDTestBrokerResponse.m */; };
307+
23F9FD4622EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 23F9FD4422EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.h */; };
308+
23F9FD4722EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 23F9FD4522EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.m */; };
309+
23F9FD4822EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 23F9FD4522EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.m */; };
310+
23F9FD4B22EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 23F9FD4922EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.h */; };
311+
23F9FD4C22EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 23F9FD4A22EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.m */; };
312+
23F9FD4D22EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 23F9FD4A22EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.m */; };
307313
23FB5C20225516FB002BF1EB /* MSIDClaimsRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FB5C1F225516FA002BF1EB /* MSIDClaimsRequestTests.m */; };
308314
23FB5C21225516FB002BF1EB /* MSIDClaimsRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FB5C1F225516FA002BF1EB /* MSIDClaimsRequestTests.m */; };
309315
23FB5C2A225517AA002BF1EB /* MSIDClaimsRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FB5C24225517AA002BF1EB /* MSIDClaimsRequest.m */; };
@@ -1060,6 +1066,9 @@
10601066
B2DD5BBF204799DC0084313F /* MSIDMacTokenCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2335EFB3203BB07600C342D0 /* MSIDMacTokenCacheTests.m */; };
10611067
B2DD5BC120479AA80084313F /* MSIDCacheItemJsonSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 231CE9C91FE8D79A00E95D3E /* MSIDCacheItemJsonSerializerTests.m */; };
10621068
B2DD5BC320479D9D0084313F /* MSIDKeyedArchiverSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2321531D1FDA1AF100C6960D /* MSIDKeyedArchiverSerializerTests.m */; };
1069+
B2DFA56E231E0642006F9EF8 /* MSIDKeychainTokenCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 9641B51F1FCF3ECE00AFA0EC /* MSIDKeychainTokenCache.m */; };
1070+
B2DFA56F231E0649006F9EF8 /* MSIDKeychainTokenCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 9641B51E1FCF3ECE00AFA0EC /* MSIDKeychainTokenCache.h */; };
1071+
B2DFA570231E064D006F9EF8 /* MSIDKeychainTokenCache+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2353747E22140466002436FC /* MSIDKeychainTokenCache+Internal.h */; };
10631072
B2E7698E206096A7000F3F2B /* MSIDTelemetryCacheEventTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B2E7698D206096A7000F3F2B /* MSIDTelemetryCacheEventTests.m */; };
10641073
B2E7698F206096A7000F3F2B /* MSIDTelemetryCacheEventTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B2E7698D206096A7000F3F2B /* MSIDTelemetryCacheEventTests.m */; };
10651074
B2EB3ADF22F7C74000FA400E /* MSIDBrokerInvocationOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = B2968C8422F3C3E8005AFC33 /* MSIDBrokerInvocationOptions.m */; };
@@ -1446,6 +1455,10 @@
14461455
23DADC0F20B8BF4F005D7389 /* MSIDAadAuthorityCacheRecord.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDAadAuthorityCacheRecord.m; sourceTree = "<group>"; };
14471456
23F32F151FF72CE400B2905E /* MSIDMacTokenCacheIntegrationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSIDMacTokenCacheIntegrationTests.m; sourceTree = "<group>"; };
14481457
23F32F221FFDAB9D00B2905E /* MSIDTokenCacheDataSourceIntegrationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSIDTokenCacheDataSourceIntegrationTests.m; sourceTree = "<group>"; };
1458+
23F9FD4422EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSKeyedUnarchiver+MSIDExtensions.h"; sourceTree = "<group>"; };
1459+
23F9FD4522EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSKeyedUnarchiver+MSIDExtensions.m"; sourceTree = "<group>"; };
1460+
23F9FD4922EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSKeyedArchiver+MSIDExtensions.h"; sourceTree = "<group>"; };
1461+
23F9FD4A22EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSKeyedArchiver+MSIDExtensions.m"; sourceTree = "<group>"; };
14491462
23FB5C1F225516FA002BF1EB /* MSIDClaimsRequestTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDClaimsRequestTests.m; sourceTree = "<group>"; };
14501463
23FB5C24225517AA002BF1EB /* MSIDClaimsRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSIDClaimsRequest.m; sourceTree = "<group>"; };
14511464
23FB5C25225517AA002BF1EB /* MSIDIndividualClaimRequestAdditionalInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSIDIndividualClaimRequestAdditionalInfo.h; sourceTree = "<group>"; };
@@ -2650,8 +2663,6 @@
26502663
96891A942190F15E00D7F437 /* MSIDWPJChallengeHandler.h */,
26512664
96891A952190F15E00D7F437 /* MSIDWPJChallengeHandler.m */,
26522665
962EA0442190D7F50049C4C8 /* MSIDCertAuthHandler.h */,
2653-
606830032098ACC100CCA6AB /* MSIDNegotiateHandler.h */,
2654-
606830042098ACED00CCA6AB /* MSIDNegotiateHandler.m */,
26552666
6068303720A33A7400CCA6AB /* MSIDPKeyAuthHandler.h */,
26562667
6068303820A33A9000CCA6AB /* MSIDPKeyAuthHandler.m */,
26572668
);
@@ -2671,6 +2682,8 @@
26712682
isa = PBXGroup;
26722683
children = (
26732684
962EA03C2190D4930049C4C8 /* MSIDCertAuthHandler.m */,
2685+
606830032098ACC100CCA6AB /* MSIDNegotiateHandler.h */,
2686+
606830042098ACED00CCA6AB /* MSIDNegotiateHandler.m */,
26742687
);
26752688
path = mac;
26762689
sourceTree = "<group>";
@@ -2688,6 +2701,9 @@
26882701
232153191FDA101900C6960D /* MSIDUserInformation.m */,
26892702
9641B5221FCF3EEF00AFA0EC /* MSIDMacTokenCache.h */,
26902703
9641B5231FCF3EEF00AFA0EC /* MSIDMacTokenCache.m */,
2704+
9641B51E1FCF3ECE00AFA0EC /* MSIDKeychainTokenCache.h */,
2705+
9641B51F1FCF3ECE00AFA0EC /* MSIDKeychainTokenCache.m */,
2706+
2353747E22140466002436FC /* MSIDKeychainTokenCache+Internal.h */,
26912707
B220AC1D22680D6000423359 /* mac */,
26922708
B211580B202B84B2005CE586 /* key */,
26932709
9641B5261FCF3F2600AFA0EC /* serializers */,
@@ -2699,9 +2715,6 @@
26992715
9641B51D1FCF3EB800AFA0EC /* ios */ = {
27002716
isa = PBXGroup;
27012717
children = (
2702-
9641B51E1FCF3ECE00AFA0EC /* MSIDKeychainTokenCache.h */,
2703-
9641B51F1FCF3ECE00AFA0EC /* MSIDKeychainTokenCache.m */,
2704-
2353747E22140466002436FC /* MSIDKeychainTokenCache+Internal.h */,
27052718
);
27062719
path = ios;
27072720
sourceTree = "<group>";
@@ -3467,6 +3480,10 @@
34673480
1E5B2A852294F5CA003C579D /* MSIDKeychainUtil+Internal.h */,
34683481
B27CCDCF229E205B00CAD565 /* NSJSONSerialization+MSIDExtensions.h */,
34693482
B27CCDD0229E205B00CAD565 /* NSJSONSerialization+MSIDExtensions.m */,
3483+
23F9FD4422EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.h */,
3484+
23F9FD4522EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.m */,
3485+
23F9FD4922EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.h */,
3486+
23F9FD4A22EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.m */,
34703487
);
34713488
path = util;
34723489
sourceTree = "<group>";
@@ -3962,6 +3979,7 @@
39623979
238E19C02086FC38004DF483 /* MSIDHttpResponseSerializer.h in Headers */,
39633980
238E19C32086FC38004DF483 /* MSIDResponseSerialization.h in Headers */,
39643981
B28D90A0218FBBA200E230D6 /* MSIDTokenResponseValidator.h in Headers */,
3982+
23F9FD4B22EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.h in Headers */,
39653983
B2C7B3B3213C681F009FFCC1 /* MSIDErrorConverter.h in Headers */,
39663984
2338ECD6208A7B3200809B9E /* MSIDTestContext.h in Headers */,
39673985
B2C7B3B7213C6839009FFCC1 /* MSIDErrorConverting.h in Headers */,
@@ -3979,6 +3997,7 @@
39793997
05566D102204BB8A002DBA40 /* MSIDMacKeychainTokenCache.h in Headers */,
39803998
B210F4311FDDE7EB005A8F76 /* MSIDTokenResponse.h in Headers */,
39813999
B2B1D57220425DFD00DD81F0 /* MSIDAccountCacheItem.h in Headers */,
4000+
B2DFA570231E064D006F9EF8 /* MSIDKeychainTokenCache+Internal.h in Headers */,
39824001
1E33F4A021711C1100919E9C /* MSIDAppMetadataCacheItem.h in Headers */,
39834002
B2C708B3219A620B00D917B8 /* MSIDBrokerKeyProvider.h in Headers */,
39844003
23B39ABC209BD47D000AA905 /* MSIDB2CAuthorityResolver.h in Headers */,
@@ -3992,6 +4011,7 @@
39924011
B2EF143A1FF2F225005DC1C0 /* MSIDAADV2TokenResponse.h in Headers */,
39934012
9641B5011FCF3E2700AFA0EC /* MSIDTokenCacheDataSource.h in Headers */,
39944013
233E96F122652B8B007FCE2A /* MSIDDefaultDispatcher+Internal.h in Headers */,
4014+
23F9FD4622EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.h in Headers */,
39954015
B227035E22A367A000030ADC /* MSIDMaskedHashableLogParameter.h in Headers */,
39964016
235480D420DDF88200246F72 /* MSIDAADAuthority.h in Headers */,
39974017
238E19CC2086FC87004DF483 /* MSIDRequestSerialization.h in Headers */,
@@ -4036,6 +4056,7 @@
40364056
96090D9820E59B2000E42B37 /* MSIDNotifications.h in Headers */,
40374057
96F94A3320817C1A0034676C /* MSIDNTLMHandler.h in Headers */,
40384058
B297E1E620A12BDE00F370EC /* MSIDDefaultAccountCacheKey.h in Headers */,
4059+
B2DFA56F231E0649006F9EF8 /* MSIDKeychainTokenCache.h in Headers */,
40394060
B2C7088D2198E48E00D917B8 /* NSData+AES.h in Headers */,
40404061
B251CC3B2041058D005E0179 /* MSIDRefreshToken.h in Headers */,
40414062
B28BDA84217E9676003E5670 /* MSIDB2CIdTokenClaims.h in Headers */,
@@ -4708,6 +4729,7 @@
47084729
2338ECCC208A675D00809B9E /* MSIDAADRequestErrorHandler.m in Sources */,
47094730
96F94A2A20816B870034676C /* MSIDWebAADAuthResponse.m in Sources */,
47104731
B28D90AC218FD1F800E230D6 /* MSIDDefaultTokenResponseValidator.m in Sources */,
4732+
23F9FD4D22EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.m in Sources */,
47114733
B2C7089421991CED00D917B8 /* MSIDAADV1BrokerResponse.m in Sources */,
47124734
B2AF1D3A218BCF140080C1A0 /* MSIDRequestControllerFactory.m in Sources */,
47134735
B28BDAC1221F7F230055FFE6 /* MSIDCBAWebAADAuthResponse.m in Sources */,
@@ -4762,6 +4784,7 @@
47624784
B297E1E320A1272600F370EC /* MSIDLegacyTokenCacheQuery.m in Sources */,
47634785
B2C7B3B5213C681F009FFCC1 /* MSIDErrorConverter.m in Sources */,
47644786
B20657B11FC91FD100412B7D /* MSIDTelemetryEventStrings.m in Sources */,
4787+
B2DFA56E231E0642006F9EF8 /* MSIDKeychainTokenCache.m in Sources */,
47654788
B2C708A7219A593C00D917B8 /* MSIDLegacyTokenRequestProvider.m in Sources */,
47664789
B2675684228BAD23000F01D7 /* NSURL+MSIDAADUtils.m in Sources */,
47674790
1E33F4A121711C1400919E9C /* MSIDAppMetadataCacheItem.m in Sources */,
@@ -4854,6 +4877,7 @@
48544877
B28BDA86217E9676003E5670 /* MSIDB2CIdTokenClaims.m in Sources */,
48554878
B2B1D57A204369D600DD81F0 /* MSIDAccountType.m in Sources */,
48564879
B210F4571FDDFA7B005A8F76 /* MSIDBrokerResponse.m in Sources */,
4880+
23F9FD4822EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.m in Sources */,
48574881
23B39AC8209BF9F2000AA905 /* MSIDOpenIdConfigurationInfoRequest.m in Sources */,
48584882
23D7447A2097B2DA00210C51 /* MSIDAADV1AuthorizationCodeRequest.m in Sources */,
48594883
23642AB8218805B000F97009 /* MSIDIntuneMAMResourcesCache.m in Sources */,
@@ -5128,6 +5152,7 @@
51285152
B2C7086E2198C41300D917B8 /* MSIDDefaultBrokerResponseHandler.m in Sources */,
51295153
239DF9AE20DED6F7002D428B /* MSIDConstants.m in Sources */,
51305154
233E96F722652D3A007FCE2A /* MSIDAggregatedDispatcher.m in Sources */,
5155+
23F9FD4C22EC097600DAB65D /* NSKeyedArchiver+MSIDExtensions.m in Sources */,
51315156
B20657AA1FC91ECC00412B7D /* MSIDTelemetry.m in Sources */,
51325157
B2C708892198DE3900D917B8 /* MSIDBrokerCryptoProvider.m in Sources */,
51335158
B25A35701FC4D70300C7FD43 /* MSIDLogger.m in Sources */,
@@ -5275,6 +5300,7 @@
52755300
B2CDB57E1FE33EC5003A4B5C /* MSIDIdTokenClaims.m in Sources */,
52765301
B2000C7920EC47860092790A /* NSData+JWT.m in Sources */,
52775302
B27CCDD2229E205C00CAD565 /* NSJSONSerialization+MSIDExtensions.m in Sources */,
5303+
23F9FD4722EC08D800DAB65D /* NSKeyedUnarchiver+MSIDExtensions.m in Sources */,
52785304
B2C708A6219A593C00D917B8 /* MSIDLegacyTokenRequestProvider.m in Sources */,
52795305
B2C708AB219A5A3D00D917B8 /* MSIDLegacySilentTokenRequest.m in Sources */,
52805306
96F21B3220A65896002B87C3 /* MSIDWebviewAuthorization.m in Sources */,

IdentityCore/src/cache/ios/MSIDKeychainTokenCache+Internal.h renamed to IdentityCore/src/cache/MSIDKeychainTokenCache+Internal.h

File renamed without changes.
File renamed without changes.

IdentityCore/src/cache/ios/MSIDKeychainTokenCache.m renamed to IdentityCore/src/cache/MSIDKeychainTokenCache.m

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#import "MSIDExtendedCacheItemSerializing.h"
3434
#import "MSIDAccountCacheItem.h"
3535
#import "MSIDAppMetadataCacheItem.h"
36+
#import "NSKeyedUnarchiver+MSIDExtensions.h"
37+
#import "NSKeyedArchiver+MSIDExtensions.h"
3638

3739
NSString *const MSIDAdalKeychainGroup = @"com.microsoft.adalcache";
3840
static NSString *const s_wipeLibraryString = @"Microsoft.ADAL.WipeAll.1";
@@ -139,9 +141,19 @@ - (nullable instancetype)initWithGroup:(nullable NSString *)keychainGroup error:
139141
return nil;
140142
}
141143

142-
self.defaultKeychainQuery = [@{(id)kSecClass : (id)kSecClassGenericPassword,
143-
(id)kSecAttrAccessGroup : self.keychainGroup} mutableCopy];
144+
NSMutableDictionary *defaultKeychainQuery = [@{(id)kSecClass : (id)kSecClassGenericPassword,
145+
(id)kSecAttrAccessGroup : self.keychainGroup} mutableCopy];
144146

147+
#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
148+
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101500
149+
if (@available(macOS 10.15, *)) {
150+
defaultKeychainQuery[(id)kSecUseDataProtectionKeychain] = @YES;
151+
}
152+
#endif
153+
#endif
154+
155+
self.defaultKeychainQuery = defaultKeychainQuery;
156+
145157
self.defaultWipeQuery = @{(id)kSecClass : (id)kSecClassGenericPassword,
146158
(id)kSecAttrGeneric : [s_wipeLibraryString dataUsingEncoding:NSUTF8StringEncoding],
147159
(id)kSecAttrAccessGroup : self.keychainGroup,
@@ -532,7 +544,7 @@ - (BOOL)saveWipeInfoWithContext:(id<MSIDRequestContext>)context
532544

533545
MSID_LOG_WITH_CTX_PII(MSIDLogLevelInfo, context, @"Full wipe info: %@", MSID_PII_LOG_MASKABLE(wipeInfo));
534546

535-
NSData *wipeData = [NSKeyedArchiver archivedDataWithRootObject:wipeInfo];
547+
NSData *wipeData = [NSKeyedArchiver msidArchivedDataWithRootObject:wipeInfo requiringSecureCoding:YES error:nil];
536548

537549
MSID_LOG_WITH_CTX(MSIDLogLevelVerbose, context, @"Trying to update wipe info...");
538550
MSID_LOG_WITH_CTX_PII(MSIDLogLevelVerbose, context, @"Wipe query: %@", MSID_PII_LOG_MASKABLE(self.defaultWipeQuery));
@@ -588,9 +600,18 @@ - (NSDictionary *)wipeInfo:(id<MSIDRequestContext>)context
588600
return nil;
589601
}
590602

591-
NSDictionary *wipeData = [NSKeyedUnarchiver unarchiveObjectWithData:(__bridge NSData *)(data)];
603+
NSError *localError;
604+
__auto_type classes = [[NSSet alloc] initWithArray:@[NSDictionary.class, NSString.class, NSDate.class]];
605+
NSDictionary *wipeData = [NSKeyedUnarchiver msidUnarchivedObjectOfClasses:classes
606+
fromData:(__bridge NSData *)(data)
607+
error:&localError];
592608
CFRelease(data);
593609

610+
if (localError)
611+
{
612+
MSID_LOG_WITH_CTX_PII(MSIDLogLevelError, context, @"Failed to unarchive wipeData, error: %@", MSID_PII_LOG_MASKABLE(localError));
613+
}
614+
594615
return wipeData;
595616
}
596617

IdentityCore/src/cache/MSIDMacTokenCache.m

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#import "MSIDCacheItemSerializing.h"
2828
#import "MSIDAccountCacheItem.h"
2929
#import "MSIDUserInformation.h"
30+
#import "NSKeyedArchiver+MSIDExtensions.h"
31+
#import "NSKeyedUnarchiver+MSIDExtensions.h"
3032

3133
#define CURRENT_WRAPPER_CACHE_VERSION 1.0
3234

@@ -90,17 +92,13 @@ - (nullable NSData *)serialize
9092

9193
@try
9294
{
93-
NSMutableData *data = [NSMutableData data];
94-
95-
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
96-
// Maintain backward compatibility with ADAL.
97-
[archiver setClassName:@"ADTokenCacheKey" forClass:MSIDLegacyTokenCacheKey.class];
98-
[archiver setClassName:@"ADTokenCacheStoreItem" forClass:MSIDLegacyTokenCacheItem.class];
99-
[archiver setClassName:@"ADUserInformation" forClass:MSIDUserInformation.class];
100-
[archiver encodeObject:wrapper forKey:NSKeyedArchiveRootObjectKey];
101-
[archiver finishEncoding];
102-
103-
result = data;
95+
result = [NSKeyedArchiver msidEncodeObject:wrapper usingBlock:^(NSKeyedArchiver *archiver)
96+
{
97+
// Maintain backward compatibility with ADAL.
98+
[archiver setClassName:@"ADTokenCacheKey" forClass:MSIDLegacyTokenCacheKey.class];
99+
[archiver setClassName:@"ADTokenCacheStoreItem" forClass:MSIDLegacyTokenCacheItem.class];
100+
[archiver setClassName:@"ADUserInformation" forClass:MSIDUserInformation.class];
101+
}];
104102
}
105103
@catch (id exception)
106104
{
@@ -119,17 +117,20 @@ - (BOOL)deserialize:(nullable NSData*)data
119117

120118
@try
121119
{
122-
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
120+
NSKeyedUnarchiver *unarchiver = [NSKeyedUnarchiver msidCreateForReadingFromData:data error:error];
121+
123122
// Maintain backward compatibility with ADAL.
124123
[unarchiver setClass:MSIDLegacyTokenCacheKey.class forClassName:@"ADTokenCacheKey"];
125124
[unarchiver setClass:MSIDLegacyTokenCacheItem.class forClassName:@"ADTokenCacheStoreItem"];
126125
[unarchiver setClass:MSIDUserInformation.class forClassName:@"ADUserInformation"];
127-
cache = [unarchiver decodeObjectOfClass:NSDictionary.class forKey:NSKeyedArchiveRootObjectKey];
126+
__auto_type allowedClasses = [NSSet setWithObjects:NSDictionary.class, MSIDLegacyTokenCacheKey.class, MSIDLegacyTokenCacheItem.class, MSIDUserInformation.class, nil];
127+
cache = [unarchiver decodeObjectOfClasses:allowedClasses forKey:NSKeyedArchiveRootObjectKey];
128128
[unarchiver finishDecoding];
129129
}
130130
@catch (id exception)
131131
{
132-
if (error) {
132+
if (error)
133+
{
133134
*error = MSIDCreateError(MSIDErrorDomain, MSIDErrorCacheBadFormat, @"Failed to unarchive data blob from -deserialize!", nil, nil, nil, nil, nil);
134135
}
135136
}

IdentityCore/src/cache/accessor/MSIDAccountCredentialCache.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ - (BOOL)removeCredetialsWithQuery:(nonnull MSIDDefaultCredentialCacheQuery *)cac
296296
}
297297

298298
NSArray<MSIDCredentialCacheItem *> *matchedCredentials = [self getCredentialsWithQuery:cacheQuery context:context error:error];
299+
300+
if (!matchedCredentials) return NO;
299301

300302
return [self removeAllCredentials:matchedCredentials
301303
context:context

0 commit comments

Comments
 (0)