IOSAD-180 Rename passphrase cache accessor

IOSAD-180
Dirk Zimmermann 2 years ago
parent 430349bb45
commit 2d23c3aeaa
  1. 2
      pEpObjCAdapter/PEPInternalSession.m
  2. 4
      pEpObjCAdapter/PEPObjCAdapter.m
  3. 4
      pEpObjCAdapter/PEPPassphraseCache.h
  4. 2
      pEpObjCAdapter/PEPPassphraseCache.m
  5. 12
      pEpObjCAdapter/PEPPassphraseUtil.m
  6. 2
      pEpObjCTests/PEPSessionTest.m

@ -1162,7 +1162,7 @@ static NSDictionary *stringToRating;
- (PEPPassphraseCache * _Nonnull)passphraseCache
{
return [PEPPassphraseCache passphraseCache];
return [PEPPassphraseCache sharedInstance];
}
@end

@ -72,7 +72,7 @@ static id<PEPPassphraseProviderProtocol> s_passphraseProvider = nil;
{
if (passphrase == nil) {
s_passphraseForNewKeys = nil;
[[PEPPassphraseCache passphraseCache] setStoredPassphrase:passphrase];
[[PEPPassphraseCache sharedInstance] setStoredPassphrase:passphrase];
return YES;
} else {
@ -83,7 +83,7 @@ static id<PEPPassphraseProviderProtocol> s_passphraseProvider = nil;
}
s_passphraseForNewKeys = normalizedPassphrase;
[[PEPPassphraseCache passphraseCache] setStoredPassphrase:passphrase];
[[PEPPassphraseCache sharedInstance] setStoredPassphrase:passphrase];
return YES;
}

@ -32,8 +32,8 @@ extern const NSUInteger PEPPassphraseCacheMaxNumberOfPassphrases;
/// should be reset.
- (void)resetTimeoutForPassphrase:(NSString *)passphrase;
/// Get the (global) passphrase cache
+ (PEPPassphraseCache * _Nonnull)passphraseCache;
/// Get the (singleton) passphrase cache
+ (PEPPassphraseCache * _Nonnull)sharedInstance;
@end

@ -158,7 +158,7 @@ PEPPassphraseCache * _Nullable g_passphraseCache;
[self.mutablePassphraseEntries addObjectsFromArray:resultingPassphrases];
}
+ (PEPPassphraseCache * _Nonnull)passphraseCache
+ (PEPPassphraseCache * _Nonnull)sharedInstance
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{

@ -22,11 +22,11 @@
PEP_STATUS lastStatus = PEP_UNKNOWN_ERROR;
NSMutableArray *passphrases = [NSMutableArray
arrayWithArray:[[PEPPassphraseCache passphraseCache] passphrases]];
arrayWithArray:[[PEPPassphraseCache sharedInstance] passphrases]];
[passphrases insertObject:@"" atIndex:0];
if ([[PEPPassphraseCache passphraseCache] storedPassphrase]) {
[passphrases insertObject:[[PEPPassphraseCache passphraseCache] storedPassphrase] atIndex:1];
if ([[PEPPassphraseCache sharedInstance] storedPassphrase]) {
[passphrases insertObject:[[PEPPassphraseCache sharedInstance] storedPassphrase] atIndex:1];
}
for (NSString *passphrase in passphrases) {
@ -40,7 +40,7 @@
if (lastStatus != PEP_PASSPHRASE_REQUIRED && lastStatus != PEP_WRONG_PASSPHRASE) {
// The passphrase worked, so reset its timeout
[[PEPPassphraseCache passphraseCache] resetTimeoutForPassphrase:passphrase];
[[PEPPassphraseCache sharedInstance] resetTimeoutForPassphrase:passphrase];
return (PEPStatus) lastStatus;
}
@ -90,7 +90,7 @@
NSString *normalizedPassphrase = [lastPassphrase normalizedPassphraseWithError:nil];
//Add the new passphrase to our cache to not having to bother the client again.
[[PEPPassphraseCache passphraseCache] addPassphrase:normalizedPassphrase];
[[PEPPassphraseCache sharedInstance] addPassphrase:normalizedPassphrase];
if (normalizedPassphrase == nil) {
// Assume excessively long passphrase means PEP_WRONG_PASSPHRASE
@ -113,7 +113,7 @@
if (lastPassphraseProviderStatus != PEP_PASSPHRASE_REQUIRED &&
lastPassphraseProviderStatus != PEP_WRONG_PASSPHRASE) {
// The passphrase worked, so reset its timeout
[[PEPPassphraseCache passphraseCache] resetTimeoutForPassphrase:lastPassphrase];
[[PEPPassphraseCache sharedInstance] resetTimeoutForPassphrase:lastPassphrase];
return (PEPStatus) lastPassphraseProviderStatus;
}

@ -1647,7 +1647,7 @@
XCTAssertTrue([session mySelf:identMe error:&error]);
XCTAssertNil(error);
[[PEPPassphraseCache passphraseCache] setStoredPassphrase:nil];
[[PEPPassphraseCache sharedInstance] setStoredPassphrase:nil];
PEPPassphraseProviderMock *mock = [[PEPPassphraseProviderMock alloc] initWithPassphrases:@[]];
[PEPObjCAdapter setPassphraseProvider:mock];

Loading…
Cancel
Save