summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatbir Tanda <satbirtanda@gmail.com>2019-09-16 13:57:32 -0700
committerSatbir Tanda <satbirtanda@gmail.com>2019-09-16 13:57:32 -0700
commit76f8c63092414144dc4eb93fc10b99f26333214b (patch)
tree2c30a48348ff696fa195c932ac9b9df3850ab1b7
parentee52f63f0733fabdc56aca4f3f770ab869ca8124 (diff)
downloadsdl_ios-76f8c63092414144dc4eb93fc10b99f26333214b.tar.gz
Make recommended fixes
-rw-r--r--SmartDeviceLink-iOS.xcodeproj/project.pbxproj2
-rw-r--r--SmartDeviceLink/SDLEncryptionLifecycleManager.m17
-rw-r--r--SmartDeviceLink/SDLPermissionManager.h2
-rw-r--r--SmartDeviceLink/SDLPermissionManager.m18
-rw-r--r--SmartDeviceLink/SDLStreamingMediaConfiguration.h8
-rw-r--r--SmartDeviceLink/SDLStreamingMediaConfiguration.m4
6 files changed, 27 insertions, 24 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
index bb1164d49..298a7e558 100644
--- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
+++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
@@ -3420,8 +3420,8 @@
00E22CE822C2F19700BC6B08 /* Encryption */ = {
isa = PBXGroup;
children = (
- 001A08B22321ACE90078A31E /* Delegates */,
00E22CE922C2F1A400BC6B08 /* Configuration */,
+ 001A08B22321ACE90078A31E /* Delegates */,
005DF3BE22C590FB006E01A9 /* Lifecycle */,
005DF3C722C62DDA006E01A9 /* Utilities */,
);
diff --git a/SmartDeviceLink/SDLEncryptionLifecycleManager.m b/SmartDeviceLink/SDLEncryptionLifecycleManager.m
index 8eae4259e..931b5c2ea 100644
--- a/SmartDeviceLink/SDLEncryptionLifecycleManager.m
+++ b/SmartDeviceLink/SDLEncryptionLifecycleManager.m
@@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic, readwrite) SDLStateMachine *encryptionStateMachine;
@property (copy, nonatomic, nullable) SDLHMILevel currentHMILevel;
@property (strong, nonatomic, nullable) NSMutableDictionary<SDLPermissionRPCName, SDLPermissionItem *> *permissions;
-@property (assign, nonatomic, nullable) NSNumber *requiresEncryption;
+@property (assign, nonatomic) BOOL requiresEncryption;
@property (weak, nonatomic, nullable) id<SDLServiceEncryptionDelegate> delegate;
@end
@@ -227,20 +227,15 @@ NS_ASSUME_NONNULL_BEGIN
if (![notification isNotificationMemberOfClass:[SDLOnPermissionsChange class]]) {
return;
}
-
+
SDLOnPermissionsChange *onPermissionChange = notification.notification;
-
- if (onPermissionChange.requireEncryption == nil) {
- self.requiresEncryption = nil;
- } else {
- self.requiresEncryption = [NSNumber numberWithBool:onPermissionChange.requireEncryption.boolValue];
- }
-
NSArray<SDLPermissionItem *> *permissionItems = onPermissionChange.permissionItem;
-
+
for (SDLPermissionItem *item in permissionItems) {
self.permissions[item.rpcName] = item;
}
+
+ self.requiresEncryption = (onPermissionChange.requireEncryption != nil) ? onPermissionChange.requireEncryption.boolValue : [self sdl_containsAtLeastOneRPCThatRequiresEncryption];
// if startWithProtocol has not been called yet, abort here
if (!self.protocol) { return; }
@@ -251,7 +246,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (BOOL)sdl_appRequiresEncryption {
- if ((self.requiresEncryption == nil || self.requiresEncryption.boolValue) && [self sdl_containsAtLeastOneRPCThatRequiresEncryption]) {
+ if (self.requiresEncryption && [self sdl_containsAtLeastOneRPCThatRequiresEncryption]) {
return YES;
}
return NO;
diff --git a/SmartDeviceLink/SDLPermissionManager.h b/SmartDeviceLink/SDLPermissionManager.h
index a3e312b54..90dcb8680 100644
--- a/SmartDeviceLink/SDLPermissionManager.h
+++ b/SmartDeviceLink/SDLPermissionManager.h
@@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Flag indicating if the app requires an encryption service to be active.
*/
-@property (assign, nonatomic, nullable, readonly) NSNumber *requiresEncryption;
+@property (assign, nonatomic, readonly) BOOL requiresEncryption;
/**
* Start the manager with a completion block that will be called when startup completes. This is used internally. To use an SDLPermissionManager, you should use the manager found on `SDLManager`.
diff --git a/SmartDeviceLink/SDLPermissionManager.m b/SmartDeviceLink/SDLPermissionManager.m
index 74a22d5d6..cdb08e135 100644
--- a/SmartDeviceLink/SDLPermissionManager.m
+++ b/SmartDeviceLink/SDLPermissionManager.m
@@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic) NSMutableDictionary<SDLPermissionRPCName, SDLPermissionItem *> *permissions;
@property (strong, nonatomic) NSMutableArray<SDLPermissionFilter *> *filters;
@property (copy, nonatomic, nullable) SDLHMILevel currentHMILevel;
-@property (assign, nonatomic, nullable) NSNumber *requiresEncryption;
+@property (assign, nonatomic) BOOL requiresEncryption;
@end
@@ -44,7 +44,6 @@ NS_ASSUME_NONNULL_BEGIN
_currentHMILevel = nil;
_permissions = [NSMutableDictionary<SDLPermissionRPCName, SDLPermissionItem *> dictionary];
_filters = [NSMutableArray<SDLPermissionFilter *> array];
- _requiresEncryption = nil;
// Set up SDL status notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_permissionsDidChange:) name:SDLDidChangePermissionsNotification object:nil];
@@ -61,7 +60,6 @@ NS_ASSUME_NONNULL_BEGIN
_permissions = [NSMutableDictionary<SDLPermissionRPCName, SDLPermissionItem *> dictionary];
_filters = [NSMutableArray<SDLPermissionFilter *> array];
_currentHMILevel = nil;
- _requiresEncryption = nil;
}
@@ -185,8 +183,7 @@ NS_ASSUME_NONNULL_BEGIN
}
SDLOnPermissionsChange *onPermissionChange = notification.notification;
- self.requiresEncryption = onPermissionChange.requireEncryption;
-
+
NSArray<SDLPermissionItem *> *newPermissionItems = [onPermissionChange.permissionItem copy];
NSArray<SDLPermissionFilter *> *currentFilters = [self.filters copy];
@@ -222,6 +219,8 @@ NS_ASSUME_NONNULL_BEGIN
for (SDLPermissionFilter *filter in filtersToCall) {
[self sdl_callFilterObserver:filter];
}
+
+ self.requiresEncryption = (onPermissionChange.requireEncryption != nil) ? onPermissionChange.requireEncryption.boolValue : [self sdl_containsAtLeastOneRPCThatRequiresEncryption];
}
- (void)sdl_hmiLevelDidChange:(SDLRPCNotificationNotification *)notification {
@@ -359,6 +358,15 @@ NS_ASSUME_NONNULL_BEGIN
return [modifiedPermissions copy];
}
+- (BOOL)sdl_containsAtLeastOneRPCThatRequiresEncryption {
+ for (SDLPermissionItem *item in self.permissions.allValues) {
+ if (item.requireEncryption) {
+ return YES;
+ }
+ }
+ return NO;
+}
+
- (BOOL)rpcRequiresEncryption:(SDLPermissionRPCName)rpcName {
if (self.permissions[rpcName].requireEncryption != nil) {
return self.permissions[rpcName].requireEncryption.boolValue;
diff --git a/SmartDeviceLink/SDLStreamingMediaConfiguration.h b/SmartDeviceLink/SDLStreamingMediaConfiguration.h
index 81206c549..b000b6ba8 100644
--- a/SmartDeviceLink/SDLStreamingMediaConfiguration.h
+++ b/SmartDeviceLink/SDLStreamingMediaConfiguration.h
@@ -97,7 +97,7 @@ typedef NS_ENUM(NSUInteger, SDLCarWindowRenderingType) {
@return The configuration
*/
-- (instancetype)initWithSecureEncryptionFlag;
++ (instancetype)secureConfiguration;
/**
Manually set all the properties to the streaming media configuration
@@ -126,7 +126,7 @@ typedef NS_ENUM(NSUInteger, SDLCarWindowRenderingType) {
@param securityManagers The security managers to be used. The encryption flag will be set to AuthenticateAndEncrypt if any security managers are set.
@return The configuration
*/
-- (instancetype)initWithSecurityManagers:(NSArray<Class<SDLSecurityType>> *)securityManagers __deprecated_msg("Use initWithSecureEncryptionFlag instead");
+- (instancetype)initWithSecurityManagers:(NSArray<Class<SDLSecurityType>> *)securityManagers __deprecated_msg("Use secureConfiguration instead");
/**
Create a secure configuration for each of the security managers provided.
@@ -134,7 +134,7 @@ typedef NS_ENUM(NSUInteger, SDLCarWindowRenderingType) {
@param securityManagers The security managers to be used. The encryption flag will be set to AuthenticateAndEncrypt if any security managers are set.
@return The configuration
*/
-+ (instancetype)secureConfigurationWithSecurityManagers:(NSArray<Class<SDLSecurityType>> *)securityManagers NS_SWIFT_UNAVAILABLE("Use an initializer instead");
++ (instancetype)secureConfigurationWithSecurityManagers:(NSArray<Class<SDLSecurityType>> *)securityManagers NS_SWIFT_UNAVAILABLE("Use an initializer instead") __deprecated_msg("Use secureConfiguration instead");
/**
Create an insecure video streaming configuration. No security managers will be provided and the encryption flag will be set to None. If you'd like custom video encoder settings, you can set the property manually. This is equivalent to `init`.
@@ -161,7 +161,7 @@ typedef NS_ENUM(NSUInteger, SDLCarWindowRenderingType) {
+ (instancetype)autostreamingSecureConfigurationWithSecurityManagers:(NSArray<Class<SDLSecurityType>> *)securityManagers initialViewController:(UIViewController *)initialViewController __deprecated_msg("Use autostreamingSecureConfigurationWithInitialViewController: instead");
/**
- Create a CarWindow secure configuration with a view controller and security managers
+ Create a CarWindow secure configuration with a view controller.
@param initialViewController The initial view controller that will be streamed, this can be a basic `UIViewController` if you need to set your actual streaming view controller at a later time on `SDLManager.streamingManager.rootViewController`.
@return The configuration
diff --git a/SmartDeviceLink/SDLStreamingMediaConfiguration.m b/SmartDeviceLink/SDLStreamingMediaConfiguration.m
index 7eb791ebd..4c82ddcfd 100644
--- a/SmartDeviceLink/SDLStreamingMediaConfiguration.m
+++ b/SmartDeviceLink/SDLStreamingMediaConfiguration.m
@@ -22,8 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
#pragma clang diagnostic pop
}
-- (instancetype)initWithSecureEncryptionFlag {
- return [self initWithEncryptionFlag:SDLStreamingEncryptionFlagAuthenticateAndEncrypt videoSettings:nil dataSource:nil rootViewController:nil];
++ (instancetype)secureConfiguration {
+ return [[self alloc] initWithEncryptionFlag:SDLStreamingEncryptionFlagAuthenticateAndEncrypt videoSettings:nil dataSource:nil rootViewController:nil];
}
+ (instancetype)insecureConfiguration {