Commits

Tuukka Norri  committed 68e2173

Groundwork for permission metadata

AM Dependencies/PGTS/Framework/PGTSRoleDescription.h
AM Dependencies/PGTS/Framework/PGTSRoleDescription.m
- A class for describing a PostgreSQL role (a user or a group)

M Dependencies/PGTS/Framework/Sources/PGTSDatabaseInfo.h
M Dependencies/PGTS/Framework/Sources/PGTSDatabaseInfo.m
- The roles will be stored here.

AM Dependencies/PGTS/Framework/PGTSACLItem.h
AM Dependencies/PGTS/Framework/PGTSACLItem.m
- A class for associating a role with privileges.

M Dependencies/PGTS/Framework/Sources/PGTSAbstractClassInfo.h
M Dependencies/PGTS/Framework/Sources/PGTSAbstractClassInfo.m
- PostgreSQL classes may have privileges.

M Dependencies/PGTS/Framework/Sources/PGTSConstants.h
- Added an enum for privileges.

AM Dependencies/PGTS/Framework/PGTSAbstractObjectDescription.h
AM Dependencies/PGTS/Framework/PGTSAbstractObjectDescription.m
- Also made a small change in the class hierarchy.

  • Participants
  • Parent commits 3fa4c08
  • Branches PGTS

Comments (0)

Files changed (12)

File Framework/Framework.xcodeproj/project.pbxproj

 		530323C5088062270024E7EF /* NDRunLoopMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 530323C3088062270024E7EF /* NDRunLoopMessenger.h */; };
 		530323C6088062270024E7EF /* NDRunLoopMessenger.m in Sources */ = {isa = PBXBuildFile; fileRef = 530323C4088062270024E7EF /* NDRunLoopMessenger.m */; };
 		531746A7095C07E00098D3D5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
+		53298DE00B3307A800DE7CC8 /* PGTSRoleDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = 53298DDE0B3307A800DE7CC8 /* PGTSRoleDescription.h */; };
+		53298DE10B3307A800DE7CC8 /* PGTSRoleDescription.m in Sources */ = {isa = PBXBuildFile; fileRef = 53298DDF0B3307A800DE7CC8 /* PGTSRoleDescription.m */; };
+		53298DF20B330B6F00DE7CC8 /* PGTSAbstractObjectDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = 53298DF00B330B6F00DE7CC8 /* PGTSAbstractObjectDescription.h */; };
+		53298DF30B330B6F00DE7CC8 /* PGTSAbstractObjectDescription.m in Sources */ = {isa = PBXBuildFile; fileRef = 53298DF10B330B6F00DE7CC8 /* PGTSAbstractObjectDescription.m */; };
+		53298E0F0B330EFB00DE7CC8 /* PGTSACLItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 53298E0D0B330EFB00DE7CC8 /* PGTSACLItem.h */; };
+		53298E100B330EFB00DE7CC8 /* PGTSACLItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 53298E0E0B330EFB00DE7CC8 /* PGTSACLItem.m */; };
 		532BF12E0A3717BA002E6BFE /* postgresql in Headers */ = {isa = PBXBuildFile; fileRef = 5325EAD70A1B2EF600FEA842 /* postgresql */; settings = {ATTRIBUTES = (Public, ); }; };
 		532C9B4B09DDAEDD00E42701 /* PGTSModificationNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 532C9B4909DDAEDD00E42701 /* PGTSModificationNotifier.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		532C9B4C09DDAEDD00E42701 /* PGTSModificationNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 532C9B4A09DDAEDD00E42701 /* PGTSModificationNotifier.m */; };
 			isa = PBXContainerItemProxy;
 			containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
 			proxyType = 1;
-			remoteGlobalIDString = 5361BC280B319D6600C9F387 /* PostgreSQL-8.2.0 */;
+			remoteGlobalIDString = 5361BC280B319D6600C9F387;
 			remoteInfo = "PostgreSQL-8.2.0";
 		};
 		53BD9A070A5C7CB4001C950C /* PBXContainerItemProxy */ = {
 		5304E3FC09575374004D0C0F /* TSDataTypes.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = TSDataTypes.xcodeproj; path = ../Dependencies/TSDataTypes/TSDataTypes.xcodeproj; sourceTree = SOURCE_ROOT; };
 		531740DA0958AB340098D3D5 /* JaguarCompatibility.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = JaguarCompatibility.xcodeproj; path = ../JaguarCompatibility/JaguarCompatibility.xcodeproj; sourceTree = SOURCE_ROOT; };
 		5325EAD70A1B2EF600FEA842 /* postgresql */ = {isa = PBXFileReference; lastKnownFileType = folder; name = postgresql; path = "PGTS-PostgreSQL/postgresql"; sourceTree = BUILT_PRODUCTS_DIR; };
+		53298DDE0B3307A800DE7CC8 /* PGTSRoleDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PGTSRoleDescription.h; sourceTree = "<group>"; };
+		53298DDF0B3307A800DE7CC8 /* PGTSRoleDescription.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PGTSRoleDescription.m; sourceTree = "<group>"; };
+		53298DF00B330B6F00DE7CC8 /* PGTSAbstractObjectDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PGTSAbstractObjectDescription.h; sourceTree = "<group>"; };
+		53298DF10B330B6F00DE7CC8 /* PGTSAbstractObjectDescription.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PGTSAbstractObjectDescription.m; sourceTree = "<group>"; };
+		53298E0D0B330EFB00DE7CC8 /* PGTSACLItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PGTSACLItem.h; sourceTree = "<group>"; };
+		53298E0E0B330EFB00DE7CC8 /* PGTSACLItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PGTSACLItem.m; sourceTree = "<group>"; };
 		532C9B4909DDAEDD00E42701 /* PGTSModificationNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSModificationNotifier.h; path = Sources/PGTSModificationNotifier.h; sourceTree = "<group>"; };
 		532C9B4A09DDAEDD00E42701 /* PGTSModificationNotifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PGTSModificationNotifier.m; path = Sources/PGTSModificationNotifier.m; sourceTree = "<group>"; };
 		53353A400896D05A003EE146 /* PGTSDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSDataSource.h; path = Sources/PGTSDataSource.h; sourceTree = "<group>"; };
 			children = (
 				53F923BC08B1372F00759909 /* PGTSAbstractInfo.h */,
 				53F923BD08B1372F00759909 /* PGTSAbstractInfo.m */,
+				53298DF00B330B6F00DE7CC8 /* PGTSAbstractObjectDescription.h */,
+				53298DF10B330B6F00DE7CC8 /* PGTSAbstractObjectDescription.m */,
 				53D9B38808B5256700ADB959 /* PGTSAbstractClassInfo.h */,
 				53D9B38908B5256700ADB959 /* PGTSAbstractClassInfo.m */,
 				5359784E08AF669B000CAC2B /* PGTSDatabaseInfo.h */,
 				53B870910A0A218F007315BC /* PGTSForeignKeyDescription.m */,
 				5359557C0A514DEE0008793A /* PGTSSchemaDescriptor.h */,
 				5359557D0A514DEE0008793A /* PGTSSchemaDescriptor.m */,
+				53298DDE0B3307A800DE7CC8 /* PGTSRoleDescription.h */,
+				53298DDF0B3307A800DE7CC8 /* PGTSRoleDescription.m */,
+				53298E0D0B330EFB00DE7CC8 /* PGTSACLItem.h */,
+				53298E0E0B330EFB00DE7CC8 /* PGTSACLItem.m */,
 			);
 			name = Metadata;
 			sourceTree = "<group>";
 				536B892F0A518E4A00379C00 /* PGTSExceptions.h in Headers */,
 				537FB1F80A76218E00441E2E /* TSRunloopMessenger.h in Headers */,
 				5335671D0ABA015A00F3EE1D /* PGTSWriteDelegateProtocol.h in Headers */,
+				53298DE00B3307A800DE7CC8 /* PGTSRoleDescription.h in Headers */,
+				53298DF20B330B6F00DE7CC8 /* PGTSAbstractObjectDescription.h in Headers */,
+				53298E0F0B330EFB00DE7CC8 /* PGTSACLItem.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 				5359557F0A514DEE0008793A /* PGTSSchemaDescriptor.m in Sources */,
 				536B89300A518E4A00379C00 /* PGTSExceptions.m in Sources */,
 				537FB1F90A76218E00441E2E /* TSRunloopMessenger.m in Sources */,
+				53298DE10B3307A800DE7CC8 /* PGTSRoleDescription.m in Sources */,
+				53298DF30B330B6F00DE7CC8 /* PGTSAbstractObjectDescription.m in Sources */,
+				53298E100B330EFB00DE7CC8 /* PGTSACLItem.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

File Framework/PGTSACLItem.h

+//
+// PGTSACLItem.h
+// BaseTen
+//
+// Copyright (C) 2006 Marko Karppinen & Co. LLC.
+//
+// Before using this software, please review the available licensing options
+// by visiting http://www.karppinen.fi/baseten/licensing/ or by contacting
+// us at sales@karppinen.fi. Without an additional license, this software
+// may be distributed only in compliance with the GNU General Public License.
+//
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0,
+// as published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+// $Id$
+//
+
+@class PGTSRoleDescription;
+
+#import <Foundation/Foundation.h>
+#import <PGTS/PGTSConstants.h>
+
+@interface PGTSACLItem : NSObject 
+{
+    PGTSRoleDescription* role;
+    enum PGTSACLItemPrivilege privileges;
+}
+
+- (enum PGTSACLItemPrivilege) privileges;
+- (PGTSRoleDescription *) role;
+- (void) setRole: (PGTSRoleDescription *) aRole;
+
+@end

File Framework/PGTSACLItem.m

+//
+// PGTSACLItem.m
+// BaseTen
+//
+// Copyright (C) 2006 Marko Karppinen & Co. LLC.
+//
+// Before using this software, please review the available licensing options
+// by visiting http://www.karppinen.fi/baseten/licensing/ or by contacting
+// us at sales@karppinen.fi. Without an additional license, this software
+// may be distributed only in compliance with the GNU General Public License.
+//
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0,
+// as published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+// $Id$
+//
+
+#import "PGTSACLItem.h"
+
+
+@implementation PGTSACLItem
+
+- (id) init
+{
+    if ((self = [super init]))
+    {
+        privileges = kPGTSPrivilegeNone;
+    }
+    return self;
+}
+
+- (void) dealloc
+{
+    [role release];
+    [super dealloc];
+}
+
+- (PGTSRoleDescription *) role
+{
+    return role; 
+}
+
+- (void) setRole: (PGTSRoleDescription *) aRole
+{
+    if (role != aRole) {
+        [role release];
+        role = [aRole retain];
+    }
+}
+
+@end

File Framework/PGTSAbstractObjectDescription.h

+//
+// PGTSAbstractObjectDescription.h
+// BaseTen
+//
+// Copyright (C) 2006 Marko Karppinen & Co. LLC.
+//
+// Before using this software, please review the available licensing options
+// by visiting http://www.karppinen.fi/baseten/licensing/ or by contacting
+// us at sales@karppinen.fi. Without an additional license, this software
+// may be distributed only in compliance with the GNU General Public License.
+//
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0,
+// as published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+// $Id$
+//
+
+#import <Foundation/Foundation.h>
+#import <PGTS/PGTSAbstractInfo.h>
+
+
+@interface PGTSAbstractObjectDescription : PGTSAbstractInfo 
+{
+    Oid oid;
+}
+
+- (Oid)  oid;
+- (void) setOid: (Oid) anOid;
+
+@end

File Framework/PGTSAbstractObjectDescription.m

+//
+// PGTSAbstractObjectDescription.m
+// BaseTen
+//
+// Copyright (C) 2006 Marko Karppinen & Co. LLC.
+//
+// Before using this software, please review the available licensing options
+// by visiting http://www.karppinen.fi/baseten/licensing/ or by contacting
+// us at sales@karppinen.fi. Without an additional license, this software
+// may be distributed only in compliance with the GNU General Public License.
+//
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0,
+// as published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+// $Id$
+//
+
+#import "PGTSAbstractObjectDescription.h"
+
+
+@implementation PGTSAbstractObjectDescription
+
+- (id) init
+{
+    if ((self = [super init]))
+    {
+        oid = InvalidOid;
+    }
+    return self;
+}
+
+- (Oid) oid
+{
+    return oid;
+}
+
+- (void) setOid: (Oid) anOid
+{
+    oid = anOid;
+}
+
+@end

File Framework/PGTSRoleDescription.h

+//
+// PGTSRoleDescription.h
+// BaseTen
+//
+// Copyright (C) 2006 Marko Karppinen & Co. LLC.
+//
+// Before using this software, please review the available licensing options
+// by visiting http://www.karppinen.fi/baseten/licensing/ or by contacting
+// us at sales@karppinen.fi. Without an additional license, this software
+// may be distributed only in compliance with the GNU General Public License.
+//
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0,
+// as published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+// $Id$
+//
+
+#import <Foundation/Foundation.h>
+#import <PGTS/PGTSAbstractInfo.h>
+
+
+@interface PGTSRoleDescription : PGTSAbstractObjectDescription
+{
+    TSIndexDictionary* roles;
+}
+
+- (void) addRole: (PGTSRoleDescription *) aRole;
+- (BOOL) hasMember: (PGTSRoleDescription *) aRole;
+
+@end

File Framework/PGTSRoleDescription.m

+//
+// PGTSRoleDescription.m
+// BaseTen
+//
+// Copyright (C) 2006 Marko Karppinen & Co. LLC.
+//
+// Before using this software, please review the available licensing options
+// by visiting http://www.karppinen.fi/baseten/licensing/ or by contacting
+// us at sales@karppinen.fi. Without an additional license, this software
+// may be distributed only in compliance with the GNU General Public License.
+//
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0,
+// as published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+// $Id$
+//
+
+#import "PGTSRoleDescription.h"
+
+
+@implementation PGTSRoleDescription
+
+- (id) init
+{
+    if ((self = [super init]))
+    {
+        roles = [[TSIndexDictionary alloc] init];
+    }
+    return self;
+}
+
+- (void) dealloc
+{
+    [roles release];
+    [super dealloc];
+}
+
+- (void) addRole: (PGTSRoleDescription *) aRole
+{
+    [roles setObject: aRole atIndex: [aRole oid]];
+}
+
+- (BOOL) hasMember: (PGTSRoleDescription *) aRole
+{
+    BOOL rval = NO;
+    if (NSNotFound != [roles objectAtIndex: [aRole oid]])
+        rval = YES;
+    else
+    {
+        TSEnumerate (currentRole, e, [roles objectEnumerator])
+        {
+            rval = [currentRole hasMember: aRole];
+            if (YES == rval)
+                break;
+        }
+    }
+    return rval;
+}
+
+@end

File Framework/Sources/PGTSAbstractClassInfo.h

 #import <PGTS/postgresql/libpq-fe.h> 
 
 
-@interface PGTSAbstractClassInfo : PGTSAbstractInfo
+@interface PGTSAbstractClassInfo : PGTSAbstractObjectDescription
 {
-    Oid oid;
     Oid schemaOid;
     NSString* schemaName;
+    TSIndexDictionary* aclItems;
 }
-- (Oid)  oid;
-- (void) setOid: (Oid) anOid;
-
 - (void) setSchemaOid: (Oid) anOid;
 - (void) setSchemaName: (NSString *) anString;
 

File Framework/Sources/PGTSAbstractClassInfo.m

 {
     if ((self = [super initWithConnection: aConn]))
     {
-        oid = InvalidOid;
         schemaOid = InvalidOid;
+        aclItems = [[TSIndexDictionary alloc] init];
     }
     return self;
 }
 
 - (void) dealloc
 {
+    [aclItems release];
     [schemaName release];
     [super dealloc];
 }
 
-- (Oid) oid
-{
-    return oid;
-}
-
-- (void) setOid: (Oid) anOid
-{
-    oid = anOid;
-}
-
 - (Oid) schemaOid
 {
     return schemaOid;

File Framework/Sources/PGTSConstants.h

     kPGTSUnsuccessfulQueryError = 1
 };
 /* See PGTSConnectionDelegate.h */
+
+enum PGTSACLItemPrivilege
+{
+    kPGTSPrivilegeNone            = 0,
+    kPGTSPrivilegeSelect          = 1 << 1,
+    kPGTSPrivilegeSelectGrant     = 1 << 2,
+    kPGTSPrivilegeUpdate          = 1 << 3,
+    kPGTSPrivilegeUpdateGrant     = 1 << 4,
+    kPGTSPrivilegeInsert          = 1 << 5,
+    kPGTSPrivilegeInsertGrant     = 1 << 6,
+    kPGTSPrivilegeDelete          = 1 << 7,
+    kPGTSPrivilegeDeleteGrant     = 1 << 8,
+    kPGTSPrivilegeReferences      = 1 << 9,
+    kPGTSPrivilegeReferencesGrant = 1 << 10,
+    kPGTSPrivilegeTrigger         = 1 << 11,
+    kPGTSPrivilegeTriggerGrant    = 1 << 12,
+    kPGTSPrivilegeExecute         = 1 << 13,
+    kPGTSPrivilegeExecuteGrant    = 1 << 14,
+    kPGTSPrivilegeUsage           = 1 << 15,
+    kPGTSPrivilegeUsageGrant      = 1 << 16,
+    kPGTSPrivilegeCreate          = 1 << 17,
+    kPGTSPrivilegeCreateGrant     = 1 << 18,
+    kPGTSPrivilegeConnect         = 1 << 19,
+    kPGTSPrivilegeConnectGrant    = 1 << 20,
+    kPGTSPrivilegeTemporary       = 1 << 21,
+    kPGTSPrivilegeTemporaryGrant  = 1 << 22
+};

File Framework/Sources/PGTSDatabaseInfo.h

     NSMutableDictionary* schemas;
     PGTSConnectionPoolItem* poolItem;
     NSString* connectionPoolKey;
+    NSMutableDictionary* roles;
 }
 
 - (PGTSTableInfo *) tableInfoForTableWithOid: (Oid) anOid;

File Framework/Sources/PGTSDatabaseInfo.m

         tables = [[TSIndexDictionary alloc] init];
         types  = [[TSIndexDictionary alloc] init];
         schemas = [[NSMutableDictionary alloc] init];
+        roles = [[NSMutableDictionary alloc] init];
     }
     return self;
 }
     [types release];
     [schemas release];
     [connectionPoolKey release];
+    [roles release];
     [super dealloc];
 }