IOSAD-172 Internally use passphrase entries IOSAD-172
authorDirk Zimmermann <dz@pep.security>
Fri, 26 Jun 2020 16:54:34 +0200
branchIOSAD-172
changeset 146734c00ddf4c4c
parent 1466 b3046c44f00b
child 1468 488cc5514ac7
IOSAD-172 Internally use passphrase entries
pEpObjCAdapter/PEPPassphraseCache.m
     1.1 --- a/pEpObjCAdapter/PEPPassphraseCache.m	Fri Jun 26 16:54:34 2020 +0200
     1.2 +++ b/pEpObjCAdapter/PEPPassphraseCache.m	Fri Jun 26 16:54:34 2020 +0200
     1.3 @@ -8,13 +8,15 @@
     1.4  
     1.5  #import "PEPPassphraseCache.h"
     1.6  
     1.7 +#import "PEPPassphraseCacheEntry.h"
     1.8 +
     1.9  static NSUInteger s_maxNumberOfPassphrases = 20;
    1.10  static NSUInteger s_defaultTimeoutInSeconds = 10 * 60;
    1.11  
    1.12  @interface PEPPassphraseCache ()
    1.13  
    1.14  @property (nonatomic) dispatch_queue_t queue;
    1.15 -@property (nonatomic) NSMutableArray *mutablePassphrases;
    1.16 +@property (nonatomic) NSMutableArray<PEPPassphraseCacheEntry *> *mutablePassphrases;
    1.17  
    1.18  @end
    1.19  
    1.20 @@ -40,8 +42,10 @@
    1.21  
    1.22  - (void)addPassphrase:(NSString *)passphrase
    1.23  {
    1.24 +    PEPPassphraseCacheEntry *entry = [[PEPPassphraseCacheEntry alloc]
    1.25 +                                      initWithPassphrase:passphrase];
    1.26      dispatch_sync(self.queue, ^{
    1.27 -        [self.mutablePassphrases addObject:passphrase];
    1.28 +        [self.mutablePassphrases addObject:entry];
    1.29          if (self.mutablePassphrases.count > s_maxNumberOfPassphrases) {
    1.30              [self.mutablePassphrases removeObjectAtIndex:0];
    1.31          }
    1.32 @@ -54,8 +58,8 @@
    1.33                                              arrayWithCapacity:s_maxNumberOfPassphrases + 1];
    1.34      [resultingPassphrases addObject:@""];
    1.35      dispatch_sync(self.queue, ^{
    1.36 -        for (NSString *passphrase in self.mutablePassphrases) {
    1.37 -            [resultingPassphrases addObject:passphrase];
    1.38 +        for (PEPPassphraseCacheEntry *entry in self.mutablePassphrases) {
    1.39 +            [resultingPassphrases addObject:entry.passphrase];
    1.40          }
    1.41      });
    1.42      return [NSArray arrayWithArray:resultingPassphrases];