Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members

jssecuritypolicy.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 
00003 /*
00004  *  Copyright (C) 2001-2003, Richard J. Moore <rich@kde.org>
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Library General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Library General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Library General Public License
00017  *  along with this library; see the file COPYING.LIB.  If not, write to
00018  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  *  Boston, MA 02111-1307, USA.
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 } // namespace KJSEmbed
00152 
00153 #endif // KJSEMBEDSECURITYPOLICY_H

Generated on Sat May 29 03:13:07 2004 for KJSEmbed by doxygen 1.3.2