// Gsoap.cxx #include #include #include "dataset_util/PThreadMutex.h" #include "dataset_util/FileStatus.h" #include "dataset_credential/Gsoap.h" #include "gsoap_gsi/gsi.h" using std::string; using std::ostream; using std::cerr; using std::endl; using dset::GssCredential; using dset::Gsoap; //********************************************************************** // Member functions. //********************************************************************** // Gsoap constructor. Gsoap::Gsoap(soap& rsoap) : m_psoap(&rsoap) { } //********************************************************************** // Non-const methods. //********************************************************************** // Release soap credential. int Gsoap::release_credential() { if ( ! is_valid() ) return 1; // Construct a mangaging credential to release the old GSS credential // held by the soap struct. GssCredential oldcred(credential().gss_handle(), true); // Zero the credential in the soap struct. struct gsi_plugin_data* pgsidata = (struct gsi_plugin_data*) soap_lookup_plugin(m_psoap, GSI_PLUGIN_ID); if ( pgsidata == 0 ) { return 3; } pgsidata->credential = 0; return 0; } //********************************************************************** // Set soap credential. int Gsoap::set_credential(const GssCredential& cred) { if ( ! is_valid() ) return 1; if ( ! cred.is_valid() ) return 2; // Release the current soap_credential. release_credential(); // Construct a new managing credential to copy the new GSS credential. GssCredential newcred(cred, true); // Assign new credential to soap struct. struct gsi_plugin_data* pgsidata = (struct gsi_plugin_data*) soap_lookup_plugin(m_psoap, GSI_PLUGIN_ID); if ( pgsidata == 0 ) { return 3; } pgsidata->credential = newcred.release_gss_handle(); return 0; } //********************************************************************** // Const methods. //********************************************************************** // Validity. bool Gsoap::is_valid() const { return m_psoap != 0; } //********************************************************************** // Fetch the credential. GssCredential Gsoap::credential() const { struct gsi_plugin_data* pgsidata = (struct gsi_plugin_data*) soap_lookup_plugin(m_psoap, GSI_PLUGIN_ID); if ( pgsidata == 0 ) { // Return invalid credential. return GssCredential(0); } return GssCredential(pgsidata->credential); } //********************************************************************** // Fetch the delegated credential. GssCredential Gsoap::delegated_credential() const { struct gsi_plugin_data* pgsidata = (struct gsi_plugin_data*) soap_lookup_plugin(m_psoap, GSI_PLUGIN_ID); if ( pgsidata == 0 ) { // Return invalid credential. return GssCredential(0); } return GssCredential(pgsidata->delegated_credential); } //********************************************************************** // Free functions. //********************************************************************** // Output stream. ostream& operator<<(ostream& lhs, const Gsoap& rhs) { lhs << "Gsoap-gsi object:"; lhs << "\n credential: " << rhs.credential(); lhs << "\n delegate: " << rhs.delegated_credential(); return lhs; } //**********************************************************************