Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/8581_icat_use_specified_…
Browse files Browse the repository at this point in the history
…endpoint'
  • Loading branch information
martyngigg committed Dec 11, 2013
2 parents 17145a0 + a73f524 commit 6ca4ece
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 217 deletions.
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/ICat/inc/MantidICat/ICat3/ICat3Helper.h
Expand Up @@ -132,6 +132,12 @@ namespace Mantid
/// Builds search query based on user input and stores query in related ICAT class.
ICat3::ns1__advancedSearchDetails* buildSearchQuery(const CatalogSearchParam& inputs);

// Defines the SSL authentication scheme.
void setSSLContext(ICat3::ICATPortBindingProxy& icat);

// Sets the soap-endpoint & SSL context for the proxy being returned.
ICat3::ICATPortBindingProxy getICATProxy();

/** This is a template method to save data to table workspace
* @param input :: pointer to input value
* @param t :: table row reference
Expand Down
Expand Up @@ -86,6 +86,9 @@ namespace Mantid
std::string bytesToString(int64_t &fileSize);
// Helper method that formats a given timestamp.
std::string formatDateTime(const time_t &timestamp, const std::string &format);
// Sets the soap-endpoint & SSL context for the proxy being returned.
ICat4::ICATPortBindingProxy getICATProxy();

// Reference to the logger class.
Kernel::Logger& g_log;

Expand Down
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/ICat/inc/MantidICat/Session.h
Expand Up @@ -45,6 +45,10 @@ namespace Mantid
const std::string & getUserName() const { return m_userName; }
///set username
void setUserName(const std::string& userName) { m_userName=userName; }
/// Get the soap end-point.
const std::string & getSoapEndPoint() const { return m_soapEndPoint; }
/// Set the soap end-point.
void setSoapEndPoint(const std::string& soapEndPoint) { m_soapEndPoint = soapEndPoint; }

private:
/// used to create singleton
Expand All @@ -61,6 +65,8 @@ namespace Mantid
std::string m_sessionId;
/// user name
std::string m_userName;
/// Cache soap end-point
std::string m_soapEndPoint;
};

#ifdef _WIN32
Expand Down
12 changes: 9 additions & 3 deletions Code/Mantid/Framework/ICat/src/CatalogLogin.cpp
Expand Up @@ -8,6 +8,7 @@ This algorithm connects the logged in user to the information catalog.
#include "MantidICat/CatalogAlgorithmHelper.h"
#include "MantidKernel/MandatoryValidator.h"
#include "MantidKernel/MaskedProperty.h"
#include "MantidKernel/ListValidator.h"

namespace Mantid
{
Expand All @@ -29,17 +30,22 @@ namespace Mantid
declareProperty("Username","", requireValue,"The username to log into the catalog.");
declareProperty(new Kernel::MaskedProperty<std::string>("Password","", requireValue),
"The password of the related username to use.");
declareProperty("FacilityName",Mantid::Kernel::ConfigService::Instance().getFacility().name(),
boost::make_shared<Kernel::StringListValidator>(Kernel::ConfigService::Instance().getFacilityNames()),
"Select a facility to log in to.");
}

/// execute the algorithm
void CatalogLogin::exec()
{
std::string username = getProperty("Username");
std::string password = getProperty("Password");
// Obtain the soapEndPoint based on the name of the facility the user has selected.
std::string soapEndPoint = Kernel::ConfigService::Instance().getFacility(getProperty("FacilityName")).catalogInfo().soapEndPoint();
if (soapEndPoint.empty()) throw std::runtime_error("There is no soap end-point for the facility you have selected.");

g_log.notice() << "Attempting to verify user credentials against " <<
Mantid::Kernel::ConfigService::Instance().getFacility().catalogInfo().catalogName() << std::endl;
progress(0.5, "Verifying user credentials...");
CatalogAlgorithmHelper().createCatalog()->login(username, password, "");
CatalogAlgorithmHelper().createCatalog()->login(getProperty("Username"), getProperty("Password"), soapEndPoint);
}

}
Expand Down

0 comments on commit 6ca4ece

Please sign in to comment.