00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KJSEMBEDSECURITYPOLICY_H
00023 #define KJSEMBEDSECURITYPOLICY_H
00024
00025 #include <kjsembed/jsobjectproxy.h>
00026
00027 namespace KJSEmbed {
00028
00029 class JSObjectProxy;
00030
00064 class JSSecurityPolicy
00065 {
00066 public:
00067 JSSecurityPolicy( uint capabilities = 0 );
00068 virtual ~JSSecurityPolicy();
00069
00074 enum Capabilities {
00075 CapabilityTree = 0x0001,
00076 CapabilityGetProperties = 0x0002,
00077 CapabilitySetProperties = 0x0004,
00078 CapabilitySlots = 0x0008,
00079 CapabilityFactory = 0x0010,
00080 CapabilityTopLevel = 0x0020,
00081 CapabilityCustom = 0x4000,
00082
00083 CapabilityNone = 0x0000,
00084 CapabilityReadOnly = CapabilityTree | CapabilityGetProperties,
00085 CapabilityReadWrite = CapabilityReadOnly | CapabilitySetProperties | CapabilitySlots,
00086 CapabilityAll = 0xffff
00087 };
00088
00092 bool hasCapability( uint cap ) const { return (cap & caps) ? true : false; }
00093
00097 void setCapability( uint cap ) { caps = caps | cap; }
00098
00102 void clearCapability( uint cap ) { caps = caps | (CapabilityAll & cap); }
00103
00107 virtual bool isInterpreterAllowed( const JSObjectProxy *prx, const KJS::Interpreter *interp ) const;
00108
00112 virtual bool isObjectAllowed( const JSObjectProxy *prx, const QObject *obj ) const;
00113
00117 virtual bool isPropertyAllowed( const JSObjectProxy *prx, const QObject *obj, const char *prop ) const;
00118
00122 virtual bool isCreateAllowed( const JSObjectProxy *prx, const QObject *parent,
00123 const QString &clazz, const QString &name ) const;
00124
00128 static JSSecurityPolicy *defaultPolicy();
00129
00133 static void setDefaultPolicy( JSSecurityPolicy *pol );
00134
00138 static void setDefaultPolicy( uint capabilities );
00139
00143 static void deleteDefaultPolicy();
00144
00145 private:
00146 static JSSecurityPolicy *policy;
00147 uint caps;
00148 class JSSecurityPolicyPrivate *d;
00149 };
00150
00151 }
00152
00153 #endif // KJSEMBEDSECURITYPOLICY_H