Browse Source

IOSAD-180 Rename passphrase cache accessor

IOSAD-180
Dirk Zimmermann 2 years ago
parent
commit
2d23c3aeaa
6 changed files with 13 additions and 13 deletions
  1. +1
    -1
      pEpObjCAdapter/PEPInternalSession.m
  2. +2
    -2
      pEpObjCAdapter/PEPObjCAdapter.m
  3. +2
    -2
      pEpObjCAdapter/PEPPassphraseCache.h
  4. +1
    -1
      pEpObjCAdapter/PEPPassphraseCache.m
  5. +6
    -6
      pEpObjCAdapter/PEPPassphraseUtil.m
  6. +1
    -1
      pEpObjCTests/PEPSessionTest.m

+ 1
- 1
pEpObjCAdapter/PEPInternalSession.m View File

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

+ 2
- 2
pEpObjCAdapter/PEPObjCAdapter.m View File

@ -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;
}


+ 2
- 2
pEpObjCAdapter/PEPPassphraseCache.h View File

@ -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


+ 1
- 1
pEpObjCAdapter/PEPPassphraseCache.m View File

@ -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, ^{


+ 6
- 6
pEpObjCAdapter/PEPPassphraseUtil.m View File

@ -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;
}


+ 1
- 1
pEpObjCTests/PEPSessionTest.m View File

@ -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