Skip to content

Commit

Permalink
moving files for refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
open-license-manager committed Sep 14, 2014
1 parent 1922d8c commit 345c7b7
Show file tree
Hide file tree
Showing 40 changed files with 491 additions and 195 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ SET(LICENSECC_INT_VERSION "${LICENSECC_MAJOR_VERSION}${LICENSECC_MINOR_VERSION}$
SET(LICENSECC_VERSION "${LICENSECC_MAJOR_VERSION}.${LICENSECC_MINOR_VERSION}.${LICENSECC_PATCH_VERSION}")
SET(LICENSECC_SHORT_LICENSE "BSD Software License")

# add this options before PROJECT keyword
SET(CMAKE_DISABLE_SOURCE_CHANGES OFF)
SET(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
SET(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "CMake verbose" FORCE)
Expand Down
4 changes: 1 addition & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
add_subdirectory("bootstrap")
add_subdirectory("library")
add_subdirectory("pc-identifier")
add_subdirectory("license-generator")
add_subdirectory("tools")


25 changes: 0 additions & 25 deletions src/bootstrap/win/CryptoHelper.h

This file was deleted.

125 changes: 0 additions & 125 deletions src/bootstrap/win/Main.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/library/LicenseReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* LicenseReader.cpp
*
* Created on: Mar 30, 2014
* Author: devel
*
*/

#ifdef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion src/library/LicenseReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* LicenseReader.h
*
* Created on: Mar 30, 2014
* Author: devel
*
*/

#ifndef LICENSEREADER_H_
Expand Down
2 changes: 1 addition & 1 deletion src/library/base/EventRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* EventRegistry.cpp
*
* Created on: Mar 30, 2014
* Author: devel
*
*/

#include "EventRegistry.h"
Expand Down
2 changes: 1 addition & 1 deletion src/library/base/EventRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* EventRegistry.h
*
* Created on: Mar 30, 2014
* Author: devel
*
*/

#ifndef EVENTREGISTRY_H_
Expand Down
2 changes: 1 addition & 1 deletion src/library/base/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* StringUtils.cpp
*
* Created on: Apr 8, 2014
* Author: devel
*
*/

#include <cctype> //toupper
Expand Down
2 changes: 1 addition & 1 deletion src/library/base/StringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* StringUtils.h
*
* Created on: Apr 8, 2014
* Author: devel
*
*/

#ifndef STRINGUTILS_H_
Expand Down
4 changes: 2 additions & 2 deletions src/library/os/linux/os-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static int ifname_position(char *ifnames, char * ifname, int ifnames_max) {

}

FUNCTION_RETURN getAdapterInfos(AdapterInfo * adapterInfos,
FUNCTION_RETURN getAdapterInfos(OsAdapterInfo * adapterInfos,
size_t * adapter_info_size) {

FUNCTION_RETURN f_return = FUNC_RET_OK;
Expand All @@ -64,7 +64,7 @@ FUNCTION_RETURN getAdapterInfos(AdapterInfo * adapterInfos,
}

if (adapterInfos != NULL) {
memset(adapterInfos, 0, (*adapter_info_size) * sizeof(AdapterInfo));
memset(adapterInfos, 0, (*adapter_info_size) * sizeof(OsAdapterInfo));
}

/* count the maximum number of interfaces */
Expand Down
2 changes: 1 addition & 1 deletion src/library/os/os-cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* os-dependent.hpp
*
* Created on: Mar 29, 2014
* Author: devel
*
*/

#ifndef OS_DEPENDENT_CPP_
Expand Down
2 changes: 1 addition & 1 deletion src/library/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* os-dependent.hpp
*
* Created on: Mar 29, 2014
* Author: devel
*
*/

#ifndef OS_DEPENDENT_HPP_
Expand Down
2 changes: 1 addition & 1 deletion src/library/pc-identifiers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* pc-identifiers.c
*
* Created on: Apr 16, 2014
* Author: devel
*
*/

#include "os/os.h"
Expand Down
2 changes: 1 addition & 1 deletion src/library/pc-identifiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* pc-identifiers.h
*
* Created on: Apr 16, 2014
* Author: devel
*
*/

#ifndef PC_IDENTIFIERS_H_
Expand Down
7 changes: 7 additions & 0 deletions src/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable_language(CXX)
add_subdirectory("base_lib")
add_subdirectory("bootstrap")
add_subdirectory("pc-identifier")
add_subdirectory("license-generator")


19 changes: 19 additions & 0 deletions src/tools/base_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

if(WIN32)
ADD_LIBRARY(
tools_base STATIC
CryptoHelper.cpp
win/CryptoHelperWindows.cpp
)
else(WIN32)
ADD_LIBRARY(
tools_base STATIC
CryptoHelper.cpp
linux/CryptoHelperLinux.cpp
)
ENDIF(WIN32)

target_link_libraries(
tools_base
${EXTERNAL_LIBS}
)
20 changes: 20 additions & 0 deletions src/tools/base_lib/CryptoHelper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <memory>
#include "CryptoHelper.h"
#ifdef __unix__
#include"linux/CryptoHelperLinux.h"
#else
#include"win/CryptoHelperWindows.h"
#endif

using namespace std;
namespace license {

unique_ptr<CryptoHelper> CryptoHelper::getInstance() {
#ifdef __unix__
unique_ptr<CryptoHelper> ptr((CryptoHelper*) new CryptoHelperLinux());
#else
unique_ptr<CryptoHelper> ptr((CryptoHelper*) new CryptpHelperWindows());
#endif
return ptr;
}
}
36 changes: 36 additions & 0 deletions src/tools/base_lib/CryptoHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef CRYPTPHELPER_H_
#define CRYPTPHELPER_H_

#include <memory>
#include <cstddef>

namespace license {
using namespace std;
/**
* Helper class definition to generate and export Public/Private keys
* for Asymmetric encryption.
*
* <p>Since this part relies heavily on operating system libraries this class
* provides a common facade to the cryptographic functions. The two implementing
* subclasses are chosen in the factory method #getInstance(). This is to avoid
* to clutter the code with many "ifdef". (extreme performance is not an issue here)</p>
*<p> *it is shared by bootstrap and license-generator projects.</p>
*/

class CryptoHelper {

protected:
CryptoHelper();

public:
virtual void generateKeyPair() = 0;
virtual const string exportPrivateKey() const = 0;
virtual const string exportPublicKey() const = 0;

virtual const string signString(const unsigned char* privateKey,
size_t pklen, const string& license) const = 0;
static unique_ptr<CryptoHelper> getInstance();
virtual ~CryptoHelper();
};
}
#endif
3 changes: 3 additions & 0 deletions src/tools/base_lib/README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is the base library for the tools projects.
It contains cryptographic functions (that are very different from Linux and
Windows operating systems)
Loading

0 comments on commit 345c7b7

Please sign in to comment.