(feat) can now associate certificate (PEM format) on mail account

pull/239/head
Ludovic Marcotte 2017-12-23 04:53:41 -05:00
parent 979ec2c3a1
commit 8a4ebe2c60
2 changed files with 27 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2009-2016 Inverse inc.
Copyright (C) 2009-2017 Inverse inc.
This file is part of SOGo.
@ -126,6 +126,10 @@ typedef enum {
- (void) addDelegates: (NSArray *) newDelegates;
- (void) removeDelegates: (NSArray *) oldDelegates;
/* S/MIME certificate */
- (NSData *) certificate;
- (void) setCertificate: (NSData *) theData;
@end
#endif /* __Mailer_SOGoMailAccount_H__ */

View File

@ -26,6 +26,7 @@
#import <NGObjWeb/NSException+HTTP.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <NGExtensions/NGBase64Coding.h>
#import <NGExtensions/NSNull+misc.h>
#import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NSString+misc.h>
@ -1184,4 +1185,25 @@ static NSString *inboxFolderName = @"INBOX";
return [[self _mailAccount] objectForKey: @"name"];
}
- (NSData *) certificate
{
SOGoUserDefaults *ud;
ud = [[context activeUser] userDefaults];
return [[ud stringForKey: @"SOGoMailCertificate"] dataByDecodingBase64];
}
- (void) setCertificate: (NSData *) theData
{
SOGoUserDefaults *ud;
ud = [[context activeUser] userDefaults];
if ([theData length])
[ud setObject: [theData stringByEncodingBase64] forKey: @"SOGoMailCertificate"];
else
[ud removeObjectForKey: @"SOGoMailCertificate"];
}
@end /* SOGoMailAccount */