// ThreadCredential.h #ifndef dset__ThreadCredential_H #define dset__ThreadCredential_H #include #include #include class PThreadMutex; namespace dset { class GssCredentialManager; class CredentialSelectionCatalog; } // Holds the name of the credential owner for the current thread. // Data is filled by GssCredentialManager. class ThreadCredential { friend class dset::GssCredentialManager; friend class dset::CredentialSelectionCatalog; public: // typedefs typedef std::string Name; #ifndef __CINT__ typedef std::map NameMap; #endif // Function to return owner given credential name. typedef Name (*FunPtr) (Name credname); private: // Hidden methods. ThreadCredential(const ThreadCredential&); ThreadCredential& operator=(const ThreadCredential&); private: // Methods to share with friends. #ifndef __CINT__ // Return the map of credential names indexed by thread. NameMap& names(); #endif // Register the function to be used to lookup owners for credential // names. int register_owner_locator(FunPtr pfun); public: // Public methods. // Constructor. // Locks the mutex. ThreadCredential(); // Destructor. // Unlocks the mutex. ~ThreadCredential(); // Set the default owner. // Used for threads with no name. int set_default_owner(Name owner); // Return the default owner. Name default_owner() const; // Return the credential name for the current thread. // For GSI, this is the DN. // Blank if no name is defined. Name name() const; // Return the owner for the current thread. // This is the owner corresponding to the credential name. Name owner() const; // Return the owner for any cred name. Name owner(Name credname) const; // Return the mutex for inspection. const PThreadMutex& mutex(); // Output stream. std::ostream& ostr(std::ostream& lhs) const; }; // Output stream. std::ostream& operator<<(std::ostream& lhs, const ThreadCredential& rhs); #endif