Browse Source

IOSAD-191 Add securecoding PEPMessage category.

IOSAD-191
David Alarcon 2 years ago
parent
commit
40ca06d4c6
3 changed files with 123 additions and 0 deletions
  1. +17
    -0
      PEPObjCAdapterTypes/PublicHeaders/PEPMessage+SecureCoding.h
  2. +98
    -0
      PEPObjCAdapterTypes/src/PEPMessage+SecureCoding.m
  3. +8
    -0
      pEpObjCAdapter.xcodeproj/project.pbxproj

+ 17
- 0
PEPObjCAdapterTypes/PublicHeaders/PEPMessage+SecureCoding.h View File

@ -0,0 +1,17 @@
//
// PEPMessage+SecureCoding.h
// PEPObjCAdapterTypes_macOS
//
// Created by David Alarcon on 25/1/21.
// Copyright © 2021 pp. All rights reserved.
//
#import "PEPMessage.h"
NS_ASSUME_NONNULL_BEGIN
@interface PEPMessage (SecureCoding) <NSSecureCoding>
@end
NS_ASSUME_NONNULL_END

+ 98
- 0
PEPObjCAdapterTypes/src/PEPMessage+SecureCoding.m View File

@ -0,0 +1,98 @@
//
// PEPMessage+SecureCoding.m
// PEPObjCAdapterTypes_macOS
//
// Created by David Alarcon on 25/1/21.
// Copyright © 2021 pp. All rights reserved.
//
#import "PEPMessage+SecureCoding.h"
#import "PEPIdentity.h"
#import "PEPAttachment.h"
@implementation PEPMessage (SecureCoding)
- (void)encodeWithCoder:(nonnull NSCoder *)coder {
[coder encodeObject:self.messageID forKey:@"messageID"];
[coder encodeObject:self.from forKey:@"from"];
[coder encodeObject:self.to forKey:@"to"];
[coder encodeObject:self.cc forKey:@"cc"];
[coder encodeObject:self.bcc forKey:@"bcc"];
[coder encodeObject:self.shortMessage forKey:@"shortMessage"];
[coder encodeObject:self.longMessage forKey:@"longMessage"];
[coder encodeObject:self.longMessageFormatted forKey:@"longMessageFormatted"];
[coder encodeObject:self.replyTo forKey:@"replyTo"];
[coder encodeObject:self.inReplyTo forKey:@"inReplyTo"];
[coder encodeObject:self.references forKey:@"references"];
[coder encodeObject:self.sentDate forKey:@"sentDate"];
[coder encodeObject:self.receivedDate forKey:@"receivedDate"];
[coder encodeObject:self.attachments forKey:@"attachments"];
[coder encodeObject:self.optionalFields forKey:@"optionalFields"];
[coder encodeObject:self.keywords forKey:@"keywords"];
[coder encodeObject:self.receivedBy forKey:@"receivedBy"];
[coder encodeInt:self.direction forKey:@"direction"];
}
- (nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder {
if (self = [self init]) {
self.messageID = [decoder decodeObjectOfClass:[NSString class] forKey:@"messageID"];
self.from = [decoder decodeObjectOfClass:[PEPIdentity class] forKey:@"userID"];
self.to = [decoder decodeObjectOfClasses:[NSSet setWithArray:
@[[NSArray class], [PEPIdentity class]]]
forKey:@"to"];
self.cc = [decoder decodeObjectOfClasses:[NSSet setWithArray:
@[[NSArray class], [PEPIdentity class]]]
forKey:@"cc"];
self.bcc = [decoder decodeObjectOfClasses:[NSSet setWithArray:
@[[NSArray class], [PEPIdentity class]]]
forKey:@"bcc"];
self.shortMessage = [decoder decodeObjectOfClass:[NSString class]
forKey:@"shortMessage"];
self.longMessage = [decoder decodeObjectOfClass:[NSString class] forKey:@"longMessage"];
self.longMessageFormatted = [decoder decodeObjectOfClass:[NSString class]
forKey:@"longMessageFormatted"];
self.replyTo = [decoder decodeObjectOfClasses:[NSSet setWithArray:
@[[NSArray class], [PEPIdentity class]]]
forKey:@"replyTo"];
self.inReplyTo = [decoder decodeObjectOfClasses:[NSSet setWithArray:
@[[NSArray class], [NSString class]]]
forKey:@"inReplyTo"];
self.references = [decoder decodeObjectOfClasses:[NSSet setWithArray:
@[[NSArray class], [NSString class]]]
forKey:@"references"];
self.sentDate = [decoder decodeObjectOfClass:[NSDate class] forKey:@"sentDate"];
self.receivedDate = [decoder decodeObjectOfClass:[NSDate class] forKey:@"receivedDate"];
self.attachments = [decoder decodeObjectOfClasses:[NSSet setWithArray:
@[[NSArray class], [PEPAttachment class]]]
forKey:@"attachments"];
self.optionalFields = [decoder decodeObjectOfClasses:[NSSet setWithArray:
@[[NSArray class], [NSString class]]]
forKey:@"optionalFields"];
self.keywords = [decoder decodeObjectOfClasses:[NSSet setWithArray:
@[[NSArray class], [NSString class]]]
forKey:@"keywords"];
self.receivedBy = [decoder decodeObjectOfClass:[PEPIdentity class] forKey:@"receivedBy"];
self.direction = [decoder decodeIntForKey:@"direction"];;
}
return self;
}
+ (BOOL)supportsSecureCoding {
return YES;
}
@end

+ 8
- 0
pEpObjCAdapter.xcodeproj/project.pbxproj View File

@ -178,6 +178,8 @@
4396CECB2187220200FDD398 /* PEPInternalSessionTestSendMessageDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4396CEC8218721F900FDD398 /* PEPInternalSessionTestSendMessageDelegate.m */; };
43E02A201C71F65B008F05E9 /* A3FC7F0A_sec.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43E02A1C1C71F65B008F05E9 /* A3FC7F0A_sec.asc */; };
43E02A211C71F65B008F05E9 /* A3FC7F0A.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43E02A1D1C71F65B008F05E9 /* A3FC7F0A.asc */; };
4E58698325BF2FA900779EAD /* PEPMessage+SecureCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E58698125BF2FA900779EAD /* PEPMessage+SecureCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };
4E58698425BF2FA900779EAD /* PEPMessage+SecureCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E58698225BF2FA900779EAD /* PEPMessage+SecureCoding.m */; };
4EA9B51F25BF20EA0048427E /* PEPIdentity+SecureCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 4EA9B43D25BEE0990048427E /* PEPIdentity+SecureCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };
4EA9B54D25BF20FD0048427E /* PEPIdentity+SecureCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EA9B43E25BEE0990048427E /* PEPIdentity+SecureCoding.m */; };
4EA9B58425BF278B0048427E /* PEPLanguage+SecureCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 4EA9B56425BF277F0048427E /* PEPLanguage+SecureCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -383,6 +385,8 @@
43ECE9C725407FF2005F1925 /* PEPMessage+Engine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PEPMessage+Engine.m"; sourceTree = "<group>"; };
43ECE9C825407FF3005F1925 /* PEPMessage+Engine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PEPMessage+Engine.h"; sourceTree = "<group>"; };
43F73BE92166248E00AB4524 /* PEPSync.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPSync.m; sourceTree = "<group>"; };
4E58698125BF2FA900779EAD /* PEPMessage+SecureCoding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PEPMessage+SecureCoding.h"; sourceTree = "<group>"; };
4E58698225BF2FA900779EAD /* PEPMessage+SecureCoding.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "PEPMessage+SecureCoding.m"; sourceTree = "<group>"; };
4EA9B43D25BEE0990048427E /* PEPIdentity+SecureCoding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PEPIdentity+SecureCoding.h"; sourceTree = "<group>"; };
4EA9B43E25BEE0990048427E /* PEPIdentity+SecureCoding.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "PEPIdentity+SecureCoding.m"; sourceTree = "<group>"; };
4EA9B56425BF277F0048427E /* PEPLanguage+SecureCoding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PEPLanguage+SecureCoding.h"; sourceTree = "<group>"; };
@ -520,6 +524,7 @@
4EA9B43E25BEE0990048427E /* PEPIdentity+SecureCoding.m */,
4EA9B56525BF277F0048427E /* PEPLanguage+SecureCoding.m */,
4EA9B5A625BF2A9A0048427E /* PEPAttachment+SecureCoding.m */,
4E58698225BF2FA900779EAD /* PEPMessage+SecureCoding.m */,
15B109FA2575510300D06C34 /* NSObject+Extension.h */,
15B109FB2575510300D06C34 /* NSObject+Extension.m */,
15B109E625754F8800D06C34 /* PEPSessionProtocol.m */,
@ -544,6 +549,7 @@
4EA9B43D25BEE0990048427E /* PEPIdentity+SecureCoding.h */,
4EA9B56425BF277F0048427E /* PEPLanguage+SecureCoding.h */,
4EA9B5A525BF2A9A0048427E /* PEPAttachment+SecureCoding.h */,
4E58698125BF2FA900779EAD /* PEPMessage+SecureCoding.h */,
);
path = PublicHeaders;
sourceTree = "<group>";
@ -749,6 +755,7 @@
1552D92325765EC900A92F71 /* NSObject+Extension.h in Headers */,
150E8FB525755B6900AE2198 /* PEPObjCAdapterTypes_macOS.h in Headers */,
1552D92E25765EDC00A92F71 /* PEPAttachment.h in Headers */,
4E58698325BF2FA900779EAD /* PEPMessage+SecureCoding.h in Headers */,
4EA9B58425BF278B0048427E /* PEPLanguage+SecureCoding.h in Headers */,
1552D92A25765EDC00A92F71 /* PEPEngineTypes.h in Headers */,
4EA9B51F25BF20EA0048427E /* PEPIdentity+SecureCoding.h in Headers */,
@ -1088,6 +1095,7 @@
files = (
150E8FB725755B6900AE2198 /* PEPObjCAdapterTypes_macOS.m in Sources */,
150E8FBF25755B7200AE2198 /* PEPMessage.m in Sources */,
4E58698425BF2FA900779EAD /* PEPMessage+SecureCoding.m in Sources */,
4EA9B54D25BF20FD0048427E /* PEPIdentity+SecureCoding.m in Sources */,
150E8FC425755B7200AE2198 /* PEPAttachment.m in Sources */,
4EA9B59425BF27920048427E /* PEPLanguage+SecureCoding.m in Sources */,


Loading…
Cancel
Save