Commit f0cd014e authored by Eric Cano's avatar Eric Cano
Browse files

Removed the duplicate SecurityIdentity

parent 36766a60
......@@ -102,7 +102,6 @@ set (COMMON_LIB_SRC_FILES
utils/strerror_r_wrapper.cpp
CreationLog.cpp
Configuration.cpp
SecurityIdentity.cpp
TapePool.cpp
Timer.cpp
UserIdentity.cpp
......
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/SecurityIdentity.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::SecurityIdentity::SecurityIdentity() {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::SecurityIdentity::SecurityIdentity(const UserIdentity &user,
const std::string &host): m_user(user), m_host(host) {
}
//------------------------------------------------------------------------------
// getUser
//------------------------------------------------------------------------------
const cta::UserIdentity &cta::SecurityIdentity::getUser() const throw() {
return m_user;
}
//------------------------------------------------------------------------------
// getHost
//------------------------------------------------------------------------------
const std::string &cta::SecurityIdentity::getHost() const throw() {
return m_host;
}
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/UserIdentity.hpp"
#include <string>
namespace cta {
/**
* Class containing the security information necessary to authorise a user
* submitting a requests from a specific host.
*/
struct SecurityIdentity {
/**
* Constructor.
*/
SecurityIdentity();
/**
* Constructor.
*/
SecurityIdentity(const UserIdentity &user, const std::string &host);
/**
* Returns The identity of the user.
*
* @return The identity of the user.
*/
const UserIdentity &getUser() const throw();
/**
* Returns the network name of the host from which they are submitting a
* request.
*
* @return The network name of the host from which they are submitting a
* request.
*/
const std::string &getHost() const throw();
private:
/**
* The identity of the user.
*/
UserIdentity m_user;
/**
* The network name of the host from which they are submitting a request.
*/
std::string m_host;
}; // struct SecurityIdentity
} // namespace cta
......@@ -19,7 +19,7 @@
#pragma once
#include "common/archiveNS/ArchiveFileStatus.hpp"
#include "common/SecurityIdentity.hpp"
#include "common/dataStructures/SecurityIdentity.hpp"
#include "nameserver/NameServerTapeFile.hpp"
#include <list>
......@@ -48,7 +48,7 @@ public:
* @param nameServerTapeFile The tape file entry.
*/
virtual void addTapeFile(
const SecurityIdentity &cliIdentity,
const common::dataStructures::SecurityIdentity &cliIdentity,
const std::string &path,
const NameServerTapeFile &tapeFile) = 0;
......
......@@ -27,5 +27,5 @@ cta::MockNameServer::~MockNameServer() {
//------------------------------------------------------------------------------
// addTapeFile
//------------------------------------------------------------------------------
void cta::MockNameServer::addTapeFile(const SecurityIdentity &cliIdentity, const std::string &path, const NameServerTapeFile &tapeFile) {
void cta::MockNameServer::addTapeFile(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &path, const NameServerTapeFile &tapeFile) {
}
......@@ -20,7 +20,7 @@
#include "common/UserIdentity.hpp"
#include "nameserver/NameServer.hpp"
#include "common/SecurityIdentity.hpp"
#include "common/dataStructures/SecurityIdentity.hpp"
// The header file for atomic was is actually called cstdatomic in gcc 4.4
#if __GNUC__ == 4 && (__GNUC_MINOR__ == 4)
......@@ -56,7 +56,7 @@ public:
* @param nameServerTapeFile The tape file entry.
*/
void addTapeFile(
const SecurityIdentity &cliIdentity,
const common::dataStructures::SecurityIdentity &cliIdentity,
const std::string &path,
const NameServerTapeFile &tapeFile);
......
......@@ -17,7 +17,7 @@
*/
#include "OStoreDB.hpp"
#include "common/SecurityIdentity.hpp"
#include "common/dataStructures/SecurityIdentity.hpp"
#include "objectstore/RootEntry.hpp"
#include "objectstore/ArchiveQueue.hpp"
#include "objectstore/RetrieveQueue.hpp"
......@@ -362,7 +362,7 @@ void OStoreDB::queue(const cta::common::dataStructures::ArchiveRequest &request,
}
}
void OStoreDB::deleteArchiveRequest(const SecurityIdentity& requester,
void OStoreDB::deleteArchiveRequest(const common::dataStructures::SecurityIdentity& requester,
uint64_t fileId) {
// First of, find the archive request form all the tape pools.
objectstore::RootEntry re(m_objectStore);
......@@ -411,7 +411,7 @@ void OStoreDB::deleteArchiveRequest(const SecurityIdentity& requester,
}
std::unique_ptr<SchedulerDatabase::ArchiveToFileRequestCancelation>
OStoreDB::markArchiveRequestForDeletion(const SecurityIdentity& requester,
OStoreDB::markArchiveRequestForDeletion(const common::dataStructures::SecurityIdentity& requester,
uint64_t fileId) {
assertAgentSet();
// Construct the return value immediately
......@@ -800,7 +800,7 @@ std::map<cta::Tape, std::list<RetrieveRequestDump> > OStoreDB::getRetrieveReques
// return ret;
}
void OStoreDB::deleteRetrieveRequest(const SecurityIdentity& requester,
void OStoreDB::deleteRetrieveRequest(const common::dataStructures::SecurityIdentity& requester,
const std::string& remoteFile) {
throw exception::Exception("Not Implemented");
}
......
......@@ -156,7 +156,7 @@ public:
CTA_GENERATE_EXCEPTION_CLASS(NoSuchArchiveRequest);
CTA_GENERATE_EXCEPTION_CLASS(ArchiveRequestAlreadyDeleted);
virtual void deleteArchiveRequest(const SecurityIdentity& requester, uint64_t fileId) override;
virtual void deleteArchiveRequest(const common::dataStructures::SecurityIdentity& requester, uint64_t fileId) override;
class ArchiveToFileRequestCancelation:
public SchedulerDatabase::ArchiveToFileRequestCancelation {
public:
......@@ -173,7 +173,7 @@ public:
bool m_closed;
friend class OStoreDB;
};
std::unique_ptr<SchedulerDatabase::ArchiveToFileRequestCancelation> markArchiveRequestForDeletion(const SecurityIdentity &cliIdentity, uint64_t fileId) override;
std::unique_ptr<SchedulerDatabase::ArchiveToFileRequestCancelation> markArchiveRequestForDeletion(const common::dataStructures::SecurityIdentity &cliIdentity, uint64_t fileId) override;
std::map<std::string, std::list<common::dataStructures::ArchiveJob> > getArchiveJobs() const override;
......@@ -191,7 +191,7 @@ public:
std::map<Tape, std::list<RetrieveRequestDump> > getRetrieveRequests() const override;
void deleteRetrieveRequest(const SecurityIdentity& requester,
void deleteRetrieveRequest(const common::dataStructures::SecurityIdentity& requester,
const std::string& remoteFile) override;
/* === Drive state handling ============================================== */
......
......@@ -23,6 +23,7 @@
#include "common/archiveNS/StorageClass.hpp"
#include "common/TapePool.hpp"
#include "common/archiveNS/Tape.hpp"
#include "common/dataStructures/SecurityIdentity.hpp"
#include "scheduler/LogicalLibrary.hpp"
#include "scheduler/RetrieveRequestDump.hpp"
#include "objectstore/RootEntry.hpp"
......@@ -57,15 +58,15 @@ public:
}
void deleteArchiveRequest(const SecurityIdentity& cliIdentity, uint64_t archiveFileId) override {
void deleteArchiveRequest(const common::dataStructures::SecurityIdentity& cliIdentity, uint64_t archiveFileId) override {
m_OStoreDB.deleteArchiveRequest(cliIdentity, archiveFileId);
}
virtual std::unique_ptr<cta::SchedulerDatabase::ArchiveToFileRequestCancelation> markArchiveRequestForDeletion(const SecurityIdentity &cliIdentity, uint64_t fileId) override {
virtual std::unique_ptr<cta::SchedulerDatabase::ArchiveToFileRequestCancelation> markArchiveRequestForDeletion(const common::dataStructures::SecurityIdentity &cliIdentity, uint64_t fileId) override {
return m_OStoreDB.markArchiveRequestForDeletion(cliIdentity, fileId);
}
virtual void deleteRetrieveRequest(const SecurityIdentity& cliIdentity, const std::string& remoteFile) override {
virtual void deleteRetrieveRequest(const common::dataStructures::SecurityIdentity& cliIdentity, const std::string& remoteFile) override {
m_OStoreDB.deleteRetrieveRequest(cliIdentity, remoteFile);
}
......
......@@ -74,7 +74,8 @@ void cta::Scheduler::queueRetrieve(
// deleteArchive
//------------------------------------------------------------------------------
void cta::Scheduler::deleteArchive(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const cta::common::dataStructures::DeleteArchiveRequest &request) {
throw cta::exception::Exception(std::string("Not implemented: ") + __PRETTY_FUNCTION__);
m_catalogue.deleteArchiveFile(request.archiveFileID);
m_db.deleteArchiveRequest(cliIdentity, request.archiveFileID);
}
//------------------------------------------------------------------------------
......
......@@ -65,7 +65,6 @@ class LogicalLibrary;
class RetrieveRequestDump;
class RetrieveToFileRequest;
class SchedulerDatabase;
class SecurityIdentity;
class StorageClass;
class Tape;
class TapeMount;
......@@ -122,12 +121,11 @@ public:
/**
* Deletes the specified archive request.
*
* @param requester The identity of the requester.
* @param archiveFile The ID of the destination file within the
* archive catalogue.
*/
virtual void deleteArchiveRequest(
const SecurityIdentity &cliIdentity,
const common::dataStructures::SecurityIdentity &cliIdentity,
uint64_t archiveFileId) = 0;
/*
......@@ -153,7 +151,7 @@ public:
* @param fileId Id of the destination file within the archive catalogue.
*/
virtual std::unique_ptr<ArchiveToFileRequestCancelation> markArchiveRequestForDeletion(
const SecurityIdentity &cliIdentity,
const common::dataStructures::SecurityIdentity &cliIdentity,
uint64_t fileId) = 0;
/*============ Archive management: tape server side =======================*/
......@@ -243,7 +241,7 @@ public:
* @param remoteFile The URL of the destination file.
*/
virtual void deleteRetrieveRequest(
const SecurityIdentity &cliIdentity,
const common::dataStructures::SecurityIdentity &cliIdentity,
const std::string &remoteFile) = 0;
/*============ Retrieve management: tape server side ======================*/
......
......@@ -22,11 +22,9 @@
#include "common/archiveRoutes/ArchiveRoute.hpp"
#include "scheduler/ArchiveRequest.hpp"
#include "scheduler/RetrieveToFileRequest.hpp"
//#include "scheduler/mockDB/MockSchedulerDatabase.hpp"
//#include "scheduler/mockDB/MockSchedulerDatabaseFactory.hpp"
#include "scheduler/SchedulerDatabase.hpp"
#include "scheduler/SchedulerDatabaseFactory.hpp"
#include "common/SecurityIdentity.hpp"
#include "common/dataStructures/SecurityIdentity.hpp"
#include "OStoreDB/OStoreDBFactory.hpp"
#include "objectstore/BackendRados.hpp"
......@@ -88,17 +86,17 @@ public:
static const std::string s_adminHost;
static const std::string s_userHost;
static const cta::UserIdentity s_system;
static const cta::UserIdentity s_admin;
static const cta::UserIdentity s_user;
static const std::string s_system;
static const std::string s_admin;
static const std::string s_user;
static const cta::SecurityIdentity s_systemOnSystemHost;
static const cta::common::dataStructures::SecurityIdentity s_systemOnSystemHost;
static const cta::SecurityIdentity s_adminOnAdminHost;
static const cta::SecurityIdentity s_adminOnUserHost;
static const cta::common::dataStructures::SecurityIdentity s_adminOnAdminHost;
static const cta::common::dataStructures::SecurityIdentity s_adminOnUserHost;
static const cta::SecurityIdentity s_userOnAdminHost;
static const cta::SecurityIdentity s_userOnUserHost;
static const cta::common::dataStructures::SecurityIdentity s_userOnAdminHost;
static const cta::common::dataStructures::SecurityIdentity s_userOnUserHost;
private:
......@@ -116,17 +114,17 @@ const std::string SchedulerDatabaseTest::s_systemHost = "systemhost";
const std::string SchedulerDatabaseTest::s_adminHost = "adminhost";
const std::string SchedulerDatabaseTest::s_userHost = "userhost";
const cta::UserIdentity SchedulerDatabaseTest::s_system(1111, 1111);
const cta::UserIdentity SchedulerDatabaseTest::s_admin(2222, 2222);
const cta::UserIdentity SchedulerDatabaseTest::s_user(3333, 3333);
const std::string SchedulerDatabaseTest::s_system = "systemuser";
const std::string SchedulerDatabaseTest::s_admin = "adminuser";
const std::string SchedulerDatabaseTest::s_user = "user";
const cta::SecurityIdentity SchedulerDatabaseTest::s_systemOnSystemHost(SchedulerDatabaseTest::s_system, SchedulerDatabaseTest::s_systemHost);
const cta::common::dataStructures::SecurityIdentity SchedulerDatabaseTest::s_systemOnSystemHost(SchedulerDatabaseTest::s_system, SchedulerDatabaseTest::s_systemHost);
const cta::SecurityIdentity SchedulerDatabaseTest::s_adminOnAdminHost(SchedulerDatabaseTest::s_admin, SchedulerDatabaseTest::s_adminHost);
const cta::SecurityIdentity SchedulerDatabaseTest::s_adminOnUserHost(SchedulerDatabaseTest::s_admin, SchedulerDatabaseTest::s_userHost);
const cta::common::dataStructures::SecurityIdentity SchedulerDatabaseTest::s_adminOnAdminHost(SchedulerDatabaseTest::s_admin, SchedulerDatabaseTest::s_adminHost);
const cta::common::dataStructures::SecurityIdentity SchedulerDatabaseTest::s_adminOnUserHost(SchedulerDatabaseTest::s_admin, SchedulerDatabaseTest::s_userHost);
const cta::SecurityIdentity SchedulerDatabaseTest::s_userOnAdminHost(SchedulerDatabaseTest::s_user, SchedulerDatabaseTest::s_adminHost);
const cta::SecurityIdentity SchedulerDatabaseTest::s_userOnUserHost(SchedulerDatabaseTest::s_user, SchedulerDatabaseTest::s_userHost);
const cta::common::dataStructures::SecurityIdentity SchedulerDatabaseTest::s_userOnAdminHost(SchedulerDatabaseTest::s_user, SchedulerDatabaseTest::s_adminHost);
const cta::common::dataStructures::SecurityIdentity SchedulerDatabaseTest::s_userOnUserHost(SchedulerDatabaseTest::s_user, SchedulerDatabaseTest::s_userHost);
#undef TEST_MOCK_DB
#ifdef TEST_MOCK_DB
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment