]> err.no Git - sope/blob - sope-appserver/NGObjWeb/SoObjects/SoClassSecurityInfo.h
bump version numbers for Xcode build
[sope] / sope-appserver / NGObjWeb / SoObjects / SoClassSecurityInfo.h
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #ifndef __SoObjects_SoClassSecurityInfo_H__
24 #define __SoObjects_SoClassSecurityInfo_H__
25
26 #import <Foundation/NSObject.h>
27
28 @class NSString, NSMutableSet, NSMutableDictionary, NSArray;
29
30 /*
31   SoClassSecurityInfo
32
33   Storing security info for a SoClass.
34
35   Declaring Roles: mapping permissions to roles is the task of the system
36   administrator. Programmers should only declare default roles for:
37   - Anonymous
38   - Manager
39   - Owner
40   
41   TODO: default access (this is done in the meantime ?)
42   
43   Adding security information to a class
44   ======================================
45   
46   Per default classes are protected from outside access. Defining incorrect
47   protections is one of the most common problems when writing SOPE applications
48   since "security is hard" (Jim Fulton) ;-)
49   
50   Because of that, we provide some user-defaults to control logging of
51   security:
52     SoSecurityManagerDebugEnabled (bool) - debugging access
53     SoLogSecurityDeclarations     (bool) - track information
54   
55   To declare security information on an Objective-C class which you are using
56   as a SoClass, it's based to implemented the +initialize method:
57   
58     + (void)initialize {
59       // to mark the object public (not restricted to a user/role)
60       [[self soClassSecurityInfo] declareObjectPublic];
61       
62       // to allow public access to all contained objects (subkeys)
63       [[self soClassSecurityInfo] setDefaultAccess:@"allow"];
64
65       // to protect a specific object
66       [[self soClassSecurityInfo] 
67              declareProtected:SoPerm_View:@"test.html",nil];
68     }
69   
70   For products it's much easier to declare the products' SoClasses and
71   their protections in the "product.plist" file.
72 */
73
74 @class SoClass;
75
76 @interface SoClassSecurityInfo : NSObject
77 {
78   NSMutableSet        *publicNames;
79   NSMutableSet        *privateNames;
80   NSMutableDictionary *nameToPerm;
81   NSMutableDictionary *defRoles;
82   NSString            *defaultAccess;
83   
84   NSString *objectPermission;
85   BOOL     isObjectPublic;
86   BOOL     isObjectPrivate;
87   
88   NSString *className;
89 }
90
91 - (id)initWithSoClass:(SoClass *)_class;
92
93 /* attribute security */
94
95 - (BOOL)hasProtectionsForKey:(NSString *)_key;
96 - (BOOL)isKeyPrivate:(NSString *)_key;
97 - (BOOL)isKeyPublic:(NSString *)_key;
98 - (NSString *)permissionRequiredForKey:(NSString *)_key;
99
100 - (void)setDefaultAccess:(NSString *)_access;
101 - (NSString *)defaultAccess;
102 - (BOOL)hasDefaultAccessDeclaration;
103 - (void)declarePublic:(NSString *)_firstName, ...;
104 - (void)declarePrivate:(NSString *)_firstName, ...;
105 - (void)declareProtected:(NSString *)_perm:(NSString *)_firstName, ...;
106
107 /* object security */
108
109 - (BOOL)hasObjectProtections;
110 - (BOOL)isObjectPublic;
111 - (BOOL)isObjectPrivate;
112 - (NSString *)permissionRequiredForObject;
113 - (void)declareObjectPublic;
114 - (void)declareObjectPrivate;
115 - (void)declareObjectProtected:(NSString *)_perm;
116
117 /* default role mappings */
118
119 - (BOOL)hasDefaultRoleForPermission:(NSString *)_p;
120
121 - (void)declareRole:(NSString *)_role  asDefaultForPermission:(NSString *)_p;
122 - (void)declareRoles:(NSArray *)_roles asDefaultForPermission:(NSString *)_p;
123 - (NSArray *)defaultRolesForPermission:(NSString *)_p;
124
125 - (void)declareRole:(NSString *)_role 
126   asDefaultForPermissions:(NSString *)_firstPerm,...;
127
128 @end
129
130 @interface NSObject(ObjCClassSecurityInfo)
131
132 + (SoClassSecurityInfo *)soClassSecurityInfo;
133
134 @end
135
136 #endif /* __SoObjects_SoClassSecurityInfo_H__ */