Browse Source

IOSAD-180 Make the passphrase cache own itself

IOSAD-180
Dirk Zimmermann 2 years ago
parent
commit
f9d0be6145
5 changed files with 19 additions and 19 deletions
  1. +1
    -4
      pEpObjCAdapter/PEPInternalSession.h
  2. +1
    -13
      pEpObjCAdapter/PEPInternalSession.m
  3. +2
    -2
      pEpObjCAdapter/PEPObjCAdapter.m
  4. +3
    -0
      pEpObjCAdapter/PEPPassphraseCache.h
  5. +12
    -0
      pEpObjCAdapter/PEPPassphraseCache.m

+ 1
- 4
pEpObjCAdapter/PEPInternalSession.h View File

@ -38,10 +38,7 @@
*/
- (void)configUnEncryptedSubjectEnabled:(BOOL)enabled;
/// Get the (global) passphrase cache
/// Get the (global) passphrase cache, convenience method.
- (PEPPassphraseCache * _Nonnull)passphraseCache;
/// Get the (global) passphrase cache
+ (PEPPassphraseCache * _Nonnull)passphraseCache;
@end

+ 1
- 13
pEpObjCAdapter/PEPInternalSession.m View File

@ -33,8 +33,6 @@
#import "key_reset.h"
PEPPassphraseCache * _Nullable g_passphraseCache;
@implementation PEPInternalSession
- (_Nullable instancetype)init
@ -1164,17 +1162,7 @@ static NSDictionary *stringToRating;
- (PEPPassphraseCache * _Nonnull)passphraseCache
{
return [PEPInternalSession passphraseCache];
}
+ (PEPPassphraseCache * _Nonnull)passphraseCache
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
g_passphraseCache = [[PEPPassphraseCache alloc] init];
});
return g_passphraseCache;
return [PEPPassphraseCache passphraseCache];
}
@end

+ 2
- 2
pEpObjCAdapter/PEPObjCAdapter.m View File

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


+ 3
- 0
pEpObjCAdapter/PEPPassphraseCache.h View File

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

+ 12
- 0
pEpObjCAdapter/PEPPassphraseCache.m View File

@ -17,6 +17,8 @@ const NSUInteger PEPPassphraseCacheMaxNumberOfPassphrases = 20;
static NSTimeInterval s_defaultTimeoutInSeconds = 10 * 60;
static NSTimeInterval s_defaultCheckExpiryInterval = 60;
PEPPassphraseCache * _Nullable g_passphraseCache;
/// Extension for internals
@interface PEPPassphraseCache ()
@ -156,6 +158,16 @@ static NSTimeInterval s_defaultCheckExpiryInterval = 60;
[self.mutablePassphraseEntries addObjectsFromArray:resultingPassphrases];
}
+ (PEPPassphraseCache * _Nonnull)passphraseCache
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
g_passphraseCache = [[PEPPassphraseCache alloc] init];
});
return g_passphraseCache;
}
#pragma mark - Helpers
- (BOOL)isExpiredPassphraseEntry:(PEPPassphraseCacheEntry *)passphraseEntry


Loading…
Cancel
Save