interreality.org [VOS]
[Home] [About]
[Screenshots]
[Download]
[News]
[Community]
[Documentation] [Manual]
[Bugs & Requests] [Wiki]

/home/tetron/hack/vos/libs/vos/vos/identity.hh

Go to the documentation of this file.
00001 #ifndef _IDENTITY_HH_
00002 #define _IDENTITY_HH_
00003 
00004 #include <vos/vos/metaobject.hh>
00005 #include <vos/vos/site.hh>
00006 
00007 #ifndef VOS_EXPORTS
00008 IMPORT_METAOBJECT_FACTORIES(IdentityStuff)
00009 #endif
00010 
00011 namespace VOS {
00012         class IdentityChangeListener;
00013         class IdentityChanged;
00014 
00015     /** @class Identity identity.hh vos/vos/identity.hh
00016         @ingroup libvos
00017 
00018         Identity is the basic unit for determining access control.  By
00019         performing some authentication protocol (for example see
00020         LocalPasswordAuth and RemotePasswordAuth) a remote site may
00021         take on an Identity.  Once this is done, requests from the
00022         remote site will use that Identity in conjunction with a
00023         Vobject's access control lists to determine what access
00024         control policy to apply (see
00025         VOS::AccessControlState::getPolicy for details).
00026     */
00027     class VOS_API Identity : public MetaObject
00028     {
00029     private:
00030         Identity(VobjectBase* vb);
00031         VUtil::ListenerBase<IdentityChangeListener, IdentityChanged> listeners;
00032 
00033         friend class Site;
00034 
00035     public:
00036         /** Constructor used for metaobject factory.  Never call this directly. */
00037         static MetaObject* new_Identity(VobjectBase* vb, const std::string& type);
00038 
00039         /** @return "core:identity" */
00040         virtual const std::string getVOSType();
00041 
00042         /** Register a callback to be made when a remote site takes on
00043             this Identity.  This is only meaningful if this identity
00044             object is local!
00045 
00046             @param icl the IdentityChangeListener object to be called
00047          */
00048         void addListener (IdentityChangeListener *icl);
00049     };
00050 
00051     /** @class Group identity.hh vos/vos/identity.hh
00052         @ingroup libvos
00053 
00054         A Group of Identity objects.  This allows you to set access
00055         control policies that apply to a group of Identities rather
00056         than having to specify each Identity individually.  In
00057         general, Groups can be used to add capabilities, but not take
00058         them away, so you should design your permissions to start with
00059         restrictive defaults and then add permissions selectively via
00060         group membership.
00061     */
00062     class VOS_API Group : public MetaObject
00063     {
00064     private:
00065         Group(VobjectBase* vb);
00066     public:
00067         /** Constructor used for metaobject factory.  Never call this directly. */
00068         static MetaObject* new_Group(VobjectBase* vb, const std::string& type);
00069 
00070         /** @return "core:group" */
00071         virtual const std::string getVOSType();
00072 
00073         /** Convenience function to add an identity to this group.
00074             This method is equivilent to
00075             @code
00076             insertChild(-1, "core:member", id);
00077             @endcode
00078             @param id the identity to add to this group
00079          */
00080         virtual void addIdentity(Identity* id);
00081     };
00082 
00083     /** @class IdentityChangeListener identity.hh vos/vos/identity.hh
00084         @ingroup libvos
00085         Abstract interface for accepting identity change events.
00086     */
00087     class VOS_API IdentityChangeListener
00088     {
00089     public:
00090         /** Destructor */
00091         virtual ~IdentityChangeListener () { };
00092 
00093         /** Called to notify that remote site "peer" has taken
00094             on identity "id".
00095             @param id the identity that has been authenticated
00096             @param peer the remote site that has been granted the identity
00097         */
00098         virtual void notifyIdentityChange (Identity *id, Site *peer) = 0;
00099     };
00100 
00101     /** @class IdentityChanged identity.hh vos/vos/identity.hh
00102         @ingroup libvos
00103         This class stores information used by the notifyEventChanged
00104         listener event.
00105     */
00106     class VOS_API IdentityChanged : public VUtil::RefCounted
00107     {
00108     public:
00109         /** Constructor
00110             @param id the identity taken on by the peer
00111             @param peer a remote site that has just been granted the identity
00112          */
00113         IdentityChanged (Identity *id, Site *peer);
00114 
00115         /** Calls notifyIdentityChange on icl.  Used by the Listener
00116             template.
00117             @param icl the listener to call
00118          */
00119         void deliverTo (IdentityChangeListener *icl);
00120 
00121     private:
00122         VUtil::vRef<Identity> identity;
00123         VUtil::vRef<Site> peer;
00124     };
00125 };
00126 
00127 
00128 #endif