Skip to content

Commit

Permalink
Merge branch 'feature/8581_icat_use_specified_endpoint' into develop.…
Browse files Browse the repository at this point in the history
… Refs #8581.

Conflicts:
	Code/Mantid/Framework/ICat/inc/MantidICat/ICat4/ICat4Catalog.h
  • Loading branch information
jawrainey committed Dec 10, 2013
2 parents f6848ea + b8a1ee3 commit 706b603
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 27 deletions.
Expand Up @@ -90,6 +90,9 @@ namespace Mantid
std::string formatDateTime(const time_t &timestamp, const std::string &format);
// Search the archive & obtain the dataset ID based on the filename
int64_t getDatasetIdFromFileName(std::string &fileName);
// 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
11 changes: 8 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,21 @@ 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", "", 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
49 changes: 26 additions & 23 deletions Code/Mantid/Framework/ICat/src/ICat4/ICat4Catalog.cpp
Expand Up @@ -28,11 +28,10 @@ namespace Mantid
*/
void ICat4Catalog::login(const std::string& username, const std::string& password, const std::string& url)
{
UNUSED_ARG(url)
ICat4::ICATPortBindingProxy icat;

// Define ssl authentication scheme
setSSLContext(icat);
// Store the soap end-point in the session for use later.
ICat::Session::Instance().setSoapEndPoint(url);
// Obtain the ICAT proxy that has been securely set, including soap-endpoint.
ICat4::ICATPortBindingProxy icat = getICATProxy();

// Used to authenticate the user.
ns1__login login;
Expand Down Expand Up @@ -86,8 +85,7 @@ namespace Mantid
*/
void ICat4Catalog::logout()
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__logout request;
ns1__logoutResponse response;
Expand Down Expand Up @@ -257,8 +255,7 @@ namespace Mantid

g_log.debug() << "ICat4Catalog::search -> Query is: { " << query << " }" << std::endl;

ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -287,8 +284,7 @@ namespace Mantid
*/
int64_t ICat4Catalog::getNumberOfSearchResults(const CatalogSearchParam& inputs)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -330,8 +326,7 @@ namespace Mantid
*/
void ICat4Catalog::myData(Mantid::API::ITableWorkspace_sptr& outputws)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -436,8 +431,7 @@ namespace Mantid
*/
void ICat4Catalog::getDataSets(const long long& investigationId, Mantid::API::ITableWorkspace_sptr& outputws)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -505,8 +499,7 @@ namespace Mantid
*/
void ICat4Catalog::getDataFiles(const long long& investigationId, Mantid::API::ITableWorkspace_sptr& outputws)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -586,8 +579,7 @@ namespace Mantid
*/
void ICat4Catalog::listInstruments(std::vector<std::string>& instruments)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -627,8 +619,7 @@ namespace Mantid
*/
void ICat4Catalog::listInvestigationTypes(std::vector<std::string>& invstTypes)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -669,8 +660,7 @@ namespace Mantid
*/
void ICat4Catalog::getFileLocation(const long long & fileID, std::string & fileLocation)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__get request;
ns1__getResponse response;
Expand Down Expand Up @@ -889,5 +879,18 @@ namespace Mantid
return (dateTime.toFormattedString(format));
}

/**
* Sets the soap-endpoint & SSL context for the proxy being returned.
* @return ICATPortBindingProxy :: The proxy with set endpoint & SSL context.
*/
ICat4::ICATPortBindingProxy ICat4Catalog::getICATProxy()
{
ICat4::ICATPortBindingProxy icat;
// Set the soap-endpoint of the catalog we want to use.
icat.soap_endpoint = ICat::Session::Instance().getSoapEndPoint().c_str();
// Sets SSL authentication scheme
setSSLContext(icat);
return icat;
}
}
}
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/ICat/test/ICatTestHelper.cpp
Expand Up @@ -10,6 +10,8 @@ namespace ICatTestHelper
loginobj.initialize();
loginobj.setPropertyValue("Username", "mantid_test");
loginobj.setPropertyValue("Password", "mantidtestuser");
loginobj.setPropertyValue("FacilityName", "ISIS");

loginobj.execute();
if (!loginobj.isExecuted())
{
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/instrument/Facilities.xml
Expand Up @@ -7,7 +7,7 @@
</archive>

<catalog name="ICat4Catalog">
<soapendpoint url="https://icatisis.esc.rl.ac.uk/ICATService/ICAT"></soapendpoint>
<soapendpoint url="https://icatisis.esc.rl.ac.uk/ICATService/ICAT"></soapendpoint>
<externaldownload url="https://isisicatds.stfc.ac.uk/idsbeta/"></externaldownload>
<filelocation>
<prefix regex="\\\\isis\\inst\$\\Instruments\$"></prefix>
Expand Down

0 comments on commit 706b603

Please sign in to comment.