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 = 1,
00076 CapabilityGetProperties = 2,
00077 CapabilitySetProperties = 4,
00078 CapabilitySlots = 8,
00079 CapabilityFactory = 16,
00080 CapabilityTopLevel = 32,
00081 CapabilityCustom = 1024,
00082
00083 CapabilityNone = 0,
00084 CapabilityReadOnly = CapabilityTree | CapabilityGetProperties,
00085 CapabilityReadWrite = CapabilityReadOnly | CapabilitySetProperties | CapabilitySlots,
00086 CapabilityAll = -1
00087 };
00088
00092 bool hasCapability( uint cap ) const { return (cap & caps) ? true : false; }
00093
00097 void setCapability( uint f ) { caps = caps | f; }
00098
00102 void clearCapability( uint f ) { caps = caps | (CapabilityAll & f); }
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 Private *d;
00149 };
00150
00151 };
00152
00153 #endif // KJSEMBEDSECURITYPOLICY_H