Skip to content

Commit

Permalink
Adding a securitymanager now adds the object itself
Browse files Browse the repository at this point in the history
  • Loading branch information
joeljfischer committed Feb 22, 2016
1 parent f782e8d commit 334bc6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.h
Expand Up @@ -46,7 +46,7 @@

- (void)handleProtocolMessage:(SDLProtocolMessage *)msgData;

- (void)addSecurityManager:(Class)securityManagerClass forMake:(NSString *)vehicleMake;
- (void)addSecurityManager:(id<SDLSecurityType>)securityManager forMake:(NSString *)vehicleMake;

+ (void)enableSiphonDebug;
+ (void)disableSiphonDebug;
Expand Down
17 changes: 8 additions & 9 deletions SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m
Expand Up @@ -61,7 +61,7 @@ @interface SDLProxy () {

@property (strong, nonatomic) NSMutableSet *mutableProxyListeners;
@property (nonatomic, strong, readwrite) SDLStreamingMediaManager *streamingMediaManager;
@property (nonatomic, strong) NSMutableDictionary<SDLVehicleMake *, Class> *securityManagers;
@property (nonatomic, strong) NSMutableDictionary<SDLVehicleMake *, id<SDLSecurityType>> *securityManagers;

@end

Expand All @@ -76,6 +76,7 @@ - (instancetype)initWithTransport:(SDLAbstractTransport *)transport protocol:(SD
_alreadyDestructed = NO;

_mutableProxyListeners = [NSMutableSet setWithObject:theDelegate];
_securityManagers = [NSMutableDictionary dictionary];
_protocol = protocol;
_transport = transport;
_transport.delegate = protocol;
Expand Down Expand Up @@ -152,18 +153,16 @@ - (SDLStreamingMediaManager *)streamingMediaManager {

#pragma mark - SecurityManager

- (void)addSecurityManager:(Class)securityManagerClass forMake:(NSString *)vehicleMake {
if ([securityManagerClass conformsToProtocol:@protocol(SDLSecurityType)]) {
self.securityManagers[vehicleMake] = securityManagerClass;
} else {
@throw [NSException exceptionWithName:@"Unknown Security Manager" reason:@"A security manager was set that does not conform to the SDLSecurityType protocol" userInfo:nil];
}
- (void)addSecurityManager:(id<SDLSecurityType>)securityManager forMake:(NSString *)vehicleMake {
NSParameterAssert(securityManager != nil);
NSParameterAssert(vehicleMake != nil);

self.securityManagers[vehicleMake] = securityManager;
}

- (id<SDLSecurityType>)securityManagerForMake:(NSString *)make {
if ((make != nil) && (self.securityManagers[make] != nil)) {
Class securityManagerClass = self.securityManagers[make];
return [[securityManagerClass alloc] init];
return self.securityManagers[make];
}

return nil;
Expand Down

0 comments on commit 334bc6b

Please sign in to comment.