SL2_SecurityManager.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  * @file SL2_SecurityManager.h
00006  *
00007  * $Id: SL2_SecurityManager.h 78854 2007-07-12 17:10:11Z mesnier_p $
00008  *
00009  * @author Chris Cleeland <cleeland@ociweb.com>
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef TAO_SL2_SECURITY_MANAGER_H
00015 #define TAO_SL2_SECURITY_MANAGER_H
00016 
00017 #include /**/ "ace/pre.h"
00018 #include "orbsvcs/Security/security_export.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "orbsvcs/SecurityC.h"
00025 #include "orbsvcs/SecurityLevel2C.h"
00026 
00027 #include "tao/LocalObject.h"
00028 #include "tao/PortableServer/PS_ForwardC.h"
00029 
00030 #include "ace/Hash_Map_Manager_T.h"
00031 #include "ace/Null_Mutex.h"
00032 
00033 #if defined(_MSC_VER)
00034 #pragma warning(push)
00035 #pragma warning(disable:4250)
00036 #endif /* _MSC_VER */
00037 
00038 
00039 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00040 
00041 namespace TAO
00042 {
00043   // would prefer SL2, but all the other SL2 stuff is in the Security namespace
00044   namespace Security
00045   {
00046     // This should move out of here probably, but it's easier to stick it
00047     // here for the moment...(CJC)
00048     /**
00049      * @class AccessDecision
00050      *
00051      * @brief
00052      */
00053     class AccessDecision
00054       : public virtual TAO::SL2::AccessDecision,
00055         public virtual TAO_Local_RefCounted_Object
00056     {
00057     public:
00058       /*! Constructor */
00059       AccessDecision (/* not yet known */);
00060       ~AccessDecision (void);
00061 
00062       virtual ::CORBA::Boolean access_allowed (
00063         const ::SecurityLevel2::CredentialsList & cred_list,
00064         ::CORBA::Object_ptr target,
00065         const char * operation_name,
00066         const char * target_interface_name
00067                                                );
00068 
00069       virtual ::CORBA::Boolean access_allowed_ex (
00070           const char * orb_id,
00071           const ::CORBA::OctetSeq & adapter_id,
00072           const ::CORBA::OctetSeq & object_id,
00073           const ::SecurityLevel2::CredentialsList & cred_list,
00074           const char * operation_name);
00075 
00076       virtual ::CORBA::Boolean default_decision (void);
00077       virtual void default_decision (::CORBA::Boolean d);
00078 
00079       virtual void add_object (const char * orbid,
00080                                const ::CORBA::OctetSeq & adapter_id,
00081                                const ::CORBA::OctetSeq & object_id,
00082                                ::CORBA::Boolean allow_insecure_access);
00083 
00084       virtual void remove_object (const char * orbid,
00085                                   const ::CORBA::OctetSeq & adapter_id,
00086                                   const ::CORBA::OctetSeq & object_id);
00087 
00088     private:
00089       /*!
00090        * This is the default value that's returned from access_allowed()
00091        * when the access table doesn't contain an entry for the reference.
00092        */
00093       ::CORBA::Boolean default_allowance_decision_;
00094 
00095       /*!
00096        * Map containing references and their designated insecure access.
00097        */
00098       // What sorts of maps are available in ACE?  We'll be mapping
00099       // an object reference to a boolean, basically.  Looks like for
00100       // now we'll map a stringified IOR to the boolean, and provide some
00101       // (for now) simple keys and functions for comparing them.
00102       //
00103       // Locking on this needs to be exclusive to add_object,
00104       // remove_object, and access_allowed.  I think that the lock on the
00105       // map itself will be sufficient, but we'll model this after the
00106       // Active Object map in the POA...so whatever way that goes, so, too,
00107       // will this.
00108       struct ReferenceKeyType
00109       {
00110         PortableServer::ObjectId_var oid_;
00111         CORBA::OctetSeq_var adapter_id_;
00112         CORBA::String_var orbid_;
00113 
00114         // operations/methods necessary for functors in HashMap; might
00115         // need to add operator< if we decide to use an RB_Tree
00116         bool operator== (const ReferenceKeyType& other) const;
00117         CORBA::ULong hash() const;
00118 
00119         // operator kind of like a "toString()" for debug statements
00120         operator const char * () const;
00121       };
00122       typedef ReferenceKeyType OBJECT_KEY;
00123       // This is typedef'd because we might try to do something fancier
00124       // where, rather than having just a string as the key, we have a
00125       // structure and the structure precomputes some of the information
00126       // for the actual key.  Thus, we could then customize the hash and
00127       // comparison functors so that they use the precomputed information
00128       // rather than computing it each time.  For now, though, I want to
00129       // make this easy to get things working.
00130       typedef ACE_Hash_Map_Manager_Ex<OBJECT_KEY,
00131                                       CORBA::Boolean, // access_allowed?
00132                                       ACE_Hash<OBJECT_KEY>,
00133                                       ACE_Equal_To<OBJECT_KEY>,
00134                                       ACE_Null_Mutex> // not sure this is right
00135       ACCESS_MAP_TYPE;
00136 
00137       ACCESS_MAP_TYPE access_map_;
00138 
00139       // Lock for accessing the map.  It may be possible to get away with
00140       // just using a lock directly in the map, but I'm not sure, so I'll err
00141       // conservatively.
00142       TAO_SYNCH_MUTEX map_lock_;
00143 
00144     private:
00145       /*!
00146        * @brief Encapsulates a TAO-specific way to do object_to_string() without having an ORB reference handy.
00147        *
00148        * @note If OBJECT_KEY changes as described above, this should change
00149        * so that it generates an OBJECT_KEY.
00150        */
00151       OBJECT_KEY map_key_from_objref (CORBA::Object_ptr obj);
00152 
00153       //
00154       // This is the private implementation that is common to both
00155       // access_allowed and access_allowed_ex.
00156       ::CORBA::Boolean access_allowed_i (OBJECT_KEY& key,
00157                                          const char *operation_name);
00158 
00159     };
00160 
00161     /**
00162      * @class SecurityManager
00163      *
00164      * @brief
00165      *
00166      */
00167     class SecurityManager
00168       : public virtual SecurityLevel2::SecurityManager,
00169         public virtual TAO_Local_RefCounted_Object
00170     {
00171     public:
00172 
00173       /// Constructor
00174       SecurityManager (/* not sure what's needed yet */);
00175 
00176       /**
00177        * @name SecurityLevel2::SecurityManager Methods
00178        *
00179        * Methods required by the SecurityLevel2::SecurityManager
00180        * interface.
00181        */
00182       //@{
00183       virtual ::Security::MechandOptionsList* supported_mechanisms ();
00184       virtual SecurityLevel2::CredentialsList* own_credentials ();
00185       virtual SecurityLevel2::RequiredRights_ptr required_rights_object ();
00186       virtual SecurityLevel2::PrincipalAuthenticator_ptr principal_authenticator ();
00187       virtual SecurityLevel2::AccessDecision_ptr access_decision ();
00188       virtual SecurityLevel2::AuditDecision_ptr audit_decision ();
00189       virtual SecurityLevel2::TargetCredentials_ptr get_target_credentials (CORBA::Object_ptr o);
00190       virtual void remove_own_credentials (SecurityLevel2::Credentials_ptr creds);
00191       virtual CORBA::Policy_ptr get_security_policy (CORBA::PolicyType policy_type);
00192       //@}
00193 
00194     protected:
00195 
00196       /// Destructor
00197       /**
00198        * Protected destructor to enforce proper memory management
00199        * through the reference counting mechanism.
00200        */
00201       virtual ~SecurityManager (void);
00202 
00203     private:
00204 
00205       /// The ORB-specific SecurityLevel2::PrincipalAuthenticator
00206       /// reference.
00207       // Except we're not going to have one of these right now
00208       SecurityLevel2::PrincipalAuthenticator_var principal_authenticator_;
00209 
00210       // AccessDecision instance
00211       SecurityLevel2::AccessDecision_var access_decision_;
00212     };
00213 
00214   } // End SL3 namespace
00215 }  // End TAO namespace
00216 
00217 TAO_END_VERSIONED_NAMESPACE_DECL
00218 
00219 
00220 #if defined(_MSC_VER)
00221 #pragma warning(pop)
00222 #endif /* _MSC_VER */
00223 
00224 #include /**/ "ace/post.h"
00225 
00226 #endif  /* TAO_SL2_SECURITY_MANAGER_H */

Generated on Sun Jan 27 16:09:36 2008 for TAO_Security by doxygen 1.3.6