summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlapinskijw <jlapinski.dev@gmail.com>2020-06-22 13:46:13 -0400
committerlapinskijw <jlapinski.dev@gmail.com>2020-06-22 13:46:13 -0400
commit89c2b0e270072c05d83e554c8f8d5ff828265102 (patch)
treef57fce76574a6192c82d46b8194a6819bc79c6b0
parenteb95f59506b7ca40225ed2fa397fff8bf331cdc3 (diff)
downloadsdl_ios-89c2b0e270072c05d83e554c8f8d5ff828265102.tar.gz
added permission element and began updateing permission filter class
-rw-r--r--SmartDeviceLink-iOS.xcodeproj/project.pbxproj8
-rw-r--r--SmartDeviceLink/SDLPermissionConstants.h9
-rw-r--r--SmartDeviceLink/SDLPermissionElement.h43
-rw-r--r--SmartDeviceLink/SDLPermissionElement.m31
-rw-r--r--SmartDeviceLink/SDLPermissionFilter.h12
-rw-r--r--SmartDeviceLink/SDLPermissionFilter.m14
6 files changed, 117 insertions, 0 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
index 91b4f85a9..227e767d2 100644
--- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
+++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
@@ -38,6 +38,8 @@
00E22CED22C2F1B300BC6B08 /* SDLEncryptionConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 00E22CEB22C2F1B300BC6B08 /* SDLEncryptionConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
00EADD3322DFE54B0088B608 /* SDLEncryptionLifecycleManagerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 00EADD3222DFE54B0088B608 /* SDLEncryptionLifecycleManagerSpec.m */; };
00EADD3522DFE5670088B608 /* SDLEncryptionConfigurationSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 00EADD3422DFE5670088B608 /* SDLEncryptionConfigurationSpec.m */; };
+ 106412C6249FB80B0069A97A /* SDLPermissionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 106412C4249FB80B0069A97A /* SDLPermissionElement.h */; };
+ 106412C7249FB80B0069A97A /* SDLPermissionElement.m in Sources */ = {isa = PBXBuildFile; fileRef = 106412C5249FB80B0069A97A /* SDLPermissionElement.m */; };
10893C162417D78300BA347E /* SDLIconArchiveFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 10893C142417D78300BA347E /* SDLIconArchiveFile.h */; };
10893C172417D78300BA347E /* SDLIconArchiveFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 10893C152417D78300BA347E /* SDLIconArchiveFile.m */; };
10893C1A2418188600BA347E /* SDLCacheFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 10893C182418188600BA347E /* SDLCacheFileManager.h */; };
@@ -1755,6 +1757,8 @@
00E22CEB22C2F1B300BC6B08 /* SDLEncryptionConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLEncryptionConfiguration.h; sourceTree = "<group>"; };
00EADD3222DFE54B0088B608 /* SDLEncryptionLifecycleManagerSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLEncryptionLifecycleManagerSpec.m; sourceTree = "<group>"; };
00EADD3422DFE5670088B608 /* SDLEncryptionConfigurationSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLEncryptionConfigurationSpec.m; sourceTree = "<group>"; };
+ 106412C4249FB80B0069A97A /* SDLPermissionElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDLPermissionElement.h; sourceTree = "<group>"; };
+ 106412C5249FB80B0069A97A /* SDLPermissionElement.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLPermissionElement.m; sourceTree = "<group>"; };
10893C142417D78300BA347E /* SDLIconArchiveFile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDLIconArchiveFile.h; sourceTree = "<group>"; };
10893C152417D78300BA347E /* SDLIconArchiveFile.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLIconArchiveFile.m; sourceTree = "<group>"; };
10893C182418188600BA347E /* SDLCacheFileManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDLCacheFileManager.h; sourceTree = "<group>"; };
@@ -5581,6 +5585,8 @@
5D1665C71CF8CA3D00CC4CA1 /* SDLPermissionFilter.m */,
5D8204241BCEA8A600D0A41B /* SDLPermissionManager.h */,
5D8204251BCEA8A600D0A41B /* SDLPermissionManager.m */,
+ 106412C4249FB80B0069A97A /* SDLPermissionElement.h */,
+ 106412C5249FB80B0069A97A /* SDLPermissionElement.m */,
);
name = Permissions;
sourceTree = "<group>";
@@ -6590,6 +6596,7 @@
9FE2471522D77AD500F8D2FC /* SDLWindowType.h in Headers */,
9FE2471922D77AED00F8D2FC /* SDLPredefinedWindows.h in Headers */,
9FE2470D22D77A5A00F8D2FC /* SDLDeleteWindowResponse.h in Headers */,
+ 106412C6249FB80B0069A97A /* SDLPermissionElement.h in Headers */,
9FE2470922D77A3600F8D2FC /* SDLDeleteWindow.h in Headers */,
9FE2471122D77AA400F8D2FC /* SDLCreateWindowResponse.h in Headers */,
9FD334E022DC6E7500F62736 /* SDLCreateWindow.h in Headers */,
@@ -7745,6 +7752,7 @@
1E5AD0511F1F7BF10029B8AF /* SDLRadioBand.m in Sources */,
88B3BF9D20DA8BBC00943565 /* SDLFuelRange.m in Sources */,
5D61FDDC1A84238C00846EE7 /* SDLTriggerSource.m in Sources */,
+ 106412C7249FB80B0069A97A /* SDLPermissionElement.m in Sources */,
5DADA7761F4DFED60084D17D /* SDLRectangle.m in Sources */,
88EED83F1F33C5A400E6C42E /* SDLSendHapticData.m in Sources */,
5D16545B1D3E7A1600554D93 /* SDLLifecycleManager.m in Sources */,
diff --git a/SmartDeviceLink/SDLPermissionConstants.h b/SmartDeviceLink/SDLPermissionConstants.h
index 05b528bfd..1e452f29d 100644
--- a/SmartDeviceLink/SDLPermissionConstants.h
+++ b/SmartDeviceLink/SDLPermissionConstants.h
@@ -10,6 +10,7 @@
#import "NSNumber+NumberType.h"
#import "SDLRPCFunctionNames.h"
+#import "SDLPermissionElement.h"
NS_ASSUME_NONNULL_BEGIN
@@ -68,6 +69,14 @@ typedef NS_ENUM(NSUInteger, SDLPermissionGroupStatus) {
typedef void (^SDLPermissionsChangedHandler)(NSDictionary<SDLPermissionRPCName, NSNumber *> *_Nonnull change, SDLPermissionGroupStatus status);
/**
+ * The PermissionObserver is a block that is passed in to some methods that will be stored and called when specified permissions change.
+ *
+ * @param change A dictionary of permission changes containing <key(String): Permission Element, object(BOOL): YES if the RPC is allowed, NO if it is not allowed>
+ * @param status The change made to all of the RPCs in the changedDict. Allowed, if all RPCs are now allowed, Disallowed if all RPCs are now disallowed, or Mixed if some are allowed, and some are disallowed
+ */
+typedef void (^SDLPermissionElementsChangedHandler)(NSDictionary<SDLPermissionElement *, NSNumber *> *_Nonnull change, SDLPermissionGroupStatus status);
+
+/**
* The SDLObservedPermissionsChangedHandler is a block that is passed in to subscribeToRPCNames:groupType:withHandler: that will be stored and called when specified permissions change.
*
* @param change A dictionary of permission changes containing <key(SDLRPCFunctionName): RPC Name, object(BOOL): YES if the RPC is allowed, NO if it is not allowed>
diff --git a/SmartDeviceLink/SDLPermissionElement.h b/SmartDeviceLink/SDLPermissionElement.h
new file mode 100644
index 000000000..4db915a95
--- /dev/null
+++ b/SmartDeviceLink/SDLPermissionElement.h
@@ -0,0 +1,43 @@
+//
+// SDLPermissionElement.h
+// SmartDeviceLink
+//
+// Created by James Lapinski on 6/21/20.
+// Copyright © 2020 smartdevicelink. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import "SDLRPCFunctionNames.h"
+
+@class SDLParameterPermissions;
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface SDLPermissionElement : NSObject
+
+/**
+ Name of the individual RPC in the policy table.
+
+ Required
+ */
+@property (strong, nonatomic) SDLRPCFunctionName rpcName;
+
+/**
+ RPC parameters for the individual RPC
+
+ Required
+ */
+@property (strong, nonatomic) SDLParameterPermissions *parameterPermissions;
+
+
+
+- (instancetype)initWithRPCName:(SDLRPCFunctionName)rpcName parameterPermissions:(nullable SDLParameterPermissions *)parameterPermissions;
+
+- (SDLRPCFunctionName)getRPCName;
+
+- (SDLParameterPermissions*)getParameters;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLPermissionElement.m b/SmartDeviceLink/SDLPermissionElement.m
new file mode 100644
index 000000000..05f8db320
--- /dev/null
+++ b/SmartDeviceLink/SDLPermissionElement.m
@@ -0,0 +1,31 @@
+//
+// SDLPermissionElement.m
+// SmartDeviceLink
+//
+// Created by James Lapinski on 6/21/20.
+// Copyright © 2020 smartdevicelink. All rights reserved.
+//
+
+#import "SDLPermissionElement.h"
+
+@implementation SDLPermissionElement
+
+- (instancetype)initWithRPCName:(SDLRPCFunctionName)rpcName parameterPermissions:(SDLParameterPermissions *)parameterPermissions {
+ self = [super init];
+ if (!self) { return nil; }
+
+ self.rpcName = rpcName;
+ self.parameterPermissions = parameterPermissions;
+
+ return self;
+}
+
+- (SDLRPCFunctionName)getRPCName {
+ return self.rpcName;
+}
+
+- (SDLParameterPermissions *)getParameters {
+ return self.parameterPermissions;
+}
+
+@end
diff --git a/SmartDeviceLink/SDLPermissionFilter.h b/SmartDeviceLink/SDLPermissionFilter.h
index f31666bec..b69a7e6dc 100644
--- a/SmartDeviceLink/SDLPermissionFilter.h
+++ b/SmartDeviceLink/SDLPermissionFilter.h
@@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
#import "SDLPermissionConstants.h"
+#import "SDLPermissionElement.h"
NS_ASSUME_NONNULL_BEGIN
@@ -36,6 +37,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (copy, nonatomic, readonly) SDLPermissionsChangedHandler handler;
/**
+ * All of the permission elements in this filter group.
+ */
+@property (copy, nonatomic, readonly) NSArray<SDLPermissionElement *> *permissionElements;
+
+/**
* Create a new permission filter group.
*
* @param rpcNames The names of the RPCs to watch permissions of.
@@ -66,6 +72,12 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (BOOL)isEqualToFilter:(SDLPermissionFilter *)otherFilter;
+
+
+- (instancetype)initWithPermissionElements:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionElementsChangedHandler)handler NS_DESIGNATED_INITIALIZER;
+
++ (instancetype)filterWithPermissionElements:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionsChangedHandler)handler NS_SWIFT_UNAVAILABLE("Use the initializer");
+
@end
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLPermissionFilter.m b/SmartDeviceLink/SDLPermissionFilter.m
index 0d142b3a3..6d6f8ad10 100644
--- a/SmartDeviceLink/SDLPermissionFilter.m
+++ b/SmartDeviceLink/SDLPermissionFilter.m
@@ -41,6 +41,20 @@ NS_ASSUME_NONNULL_BEGIN
return [[self alloc] initWithRPCNames:rpcNames groupType:groupType observer:observer];
}
+- (instancetype)initWithPermissionElements:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionElementsChangedHandler)handler {
+
+ _identifier = [NSUUID UUID];
+ _permissionElements = rpcNames;
+ _groupType = groupType;
+ _handler = handler;
+
+ return self;
+}
+
++ (instancetype)filterWithPermissionElements:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionsChangedHandler)handler {
+ return [[self alloc] initWithPermissionElements:rpcNames groupType:groupType observer:handler];
+}
+
#pragma mark - NSCopying