This commit is contained in:
Ren RenJuan 2014-01-09 01:35:37 +00:00
parent 445472e185
commit 5cd7a46f09
6 changed files with 116 additions and 86 deletions

116
.cproject
View File

@ -55,25 +55,8 @@
<storageModule moduleId="refreshScope"/> <storageModule moduleId="refreshScope"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"> <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
<buildTargets> <buildTargets>
<target name="ACTK" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>ACTK</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> <target name="clean" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand> <buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget> <buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError> <stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand> <useDefaultCommand>true</useDefaultCommand>
@ -81,7 +64,6 @@
</target> </target>
<target name="all" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> <target name="all" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand> <buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>all</buildTarget> <buildTarget>all</buildTarget>
<stopOnError>true</stopOnError> <stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand> <useDefaultCommand>true</useDefaultCommand>
@ -89,14 +71,61 @@
</target> </target>
<target name="tests" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> <target name="tests" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand> <buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>tests</buildTarget> <buildTarget>tests</buildTarget>
<stopOnError>true</stopOnError> <stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand> <useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders> <runAllBuilders>true</runAllBuilders>
</target> </target>
<target name="libACTK1_0.so" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>libACTK1_0.so</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="tests" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>tests</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="dirs" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>dirs</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="dclean" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>dclean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="all" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="APIG" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> <target name="clean" path="APIG" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand> <buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget> <buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError> <stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand> <useDefaultCommand>true</useDefaultCommand>
@ -104,36 +133,13 @@
</target> </target>
<target name="cliever" path="APIG" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> <target name="cliever" path="APIG" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand> <buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>cliever</buildTarget> <buildTarget>cliever</buildTarget>
<stopOnError>true</stopOnError> <stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand> <useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders> <runAllBuilders>true</runAllBuilders>
</target> </target>
<target name="AusRegEPPTK.so" path="AusRegEPPTK" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="tests" path="AusRegEPPTK" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>tests</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="AusRegEPPTK" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="cliever" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> <target name="cliever" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand> <buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>cliever</buildTarget> <buildTarget>cliever</buildTarget>
<stopOnError>true</stopOnError> <stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand> <useDefaultCommand>true</useDefaultCommand>
@ -141,6 +147,7 @@
</target> </target>
<target name="clean" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> <target name="clean" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand> <buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget> <buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError> <stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand> <useDefaultCommand>true</useDefaultCommand>
@ -148,11 +155,36 @@
</target> </target>
<target name="distclean" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> <target name="distclean" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand> <buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>distclean</buildTarget> <buildTarget>distclean</buildTarget>
<stopOnError>true</stopOnError> <stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand> <useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders> <runAllBuilders>true</runAllBuilders>
</target> </target>
<target name="AusRegEPPTK.so" path="AusRegEPPTK" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="tests" path="AusRegEPPTK" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>tests</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="AusRegEPPTK" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
</buildTargets> </buildTargets>
</storageModule> </storageModule>
</cproject> </cproject>

View File

@ -1,25 +1,31 @@
################################################## ##################################################
# Makefile for building lib and main test routine# # Makefile for building lib and main test routine#
################################################## ##################################################
# operating system LOCATION=authoring
SYSTEM = $(shell uname -s) SYSTEM = $(shell uname -s)
CXX = g++ CXX = g++
CC = gcc CC = gcc
#SHARED_CXXFLAGS += -O2 #PRODORDEV += -O2
SHARED_CXXFLAGS += -g PRODORDEV += -ggdb3
CXXFLAGS = $(SHARED_CXXFLAGS) -Wall -Wpointer-arith -Wcast-qual -D_REENTRANT -fPIC CXXFLAGS = $(PRODORDEV) -Wall -Wpointer-arith -Wcast-qual -D_REENTRANT -fPIC
CPPFLAGS = -fPIC -D_GNU_SOURCE CPPFLAGS = -fPIC -D_GNU_SOURCE
CXXFLAGS += -D_GNU_SOURCE -O0 CXXFLAGS += -D_GNU_SOURCE -O0
#XERCES_HOME = /usr/local/xerces-c-src_2_7_0 ifeq ($(LOCATION),authoring)
#XERCES_LIB_DIR = ${XERCES_HOME}/lib XALAN_LIB_DIR = /usr/lib/x86_64-linux-gnu/
#XERCES_LIB = xerces-c2_7_0 endif
ifeq ($(LOCATION),production)
#XALAN_HOME = /usr/local/xalan-c_1_10_0 XALAN_LIB_DIR = /usr/lib/
#XALAN_LIB_DIR = $(XALAN_HOME)/lib endif
XALAN_LIB = xalan-c
XALAN_INC_DIR = /usr/include/xalanc
XERCES_LIB_DIR = /usr/lib/
XERCES_LIB = xerces-c
XERCES_INC_DIR = /usr/include/xercesc/
include xml-deps.mk include xml-deps.mk
@ -48,7 +54,7 @@ test_execs = $(subst .o,,$(test_objs))
calc_deps = \ calc_deps = \
$(CC) -MT '$(build_obj_dir)/$(basename $(notdir $@)).o $@' -MF $@ -MM $(CPPFLAGS) $(INCLUDE_DIR) $< $(CC) -MT '$(build_obj_dir)/$(basename $(notdir $@)).o $@' -MF $@ -MM $(CPPFLAGS) $(INCLUDE_DIR) $<
all: dirs $(objs) $(BUILD_LIB_DIR)/libACTK1_3_2.so all: dirs $(objs) $(BUILD_LIB_DIR)/libACTK1_0.so
%.d: %.c %.d: %.c
$(calc_deps) $(calc_deps)
@ -78,8 +84,8 @@ $(BUILD_OBJ_DIR)/%.o: %.c
$(CC) $(CPPFLAGS) -c -o $@ $(INCLUDE_DIR) $< $(CC) $(CPPFLAGS) -c -o $@ $(INCLUDE_DIR) $<
LDFLAGS_TESTS = -L$(BUILD_LIB_DIR) -lACTK1_3_2 \ LDFLAGS_TESTS = -L$(BUILD_LIB_DIR) -lACTK1_0 \
-L$(XALAN_LIB_DIR) -lxalan-c -lxalanMsg\ -L$(XALAN_LIB_DIR) -lxalan-c -lxalanMsg -licuuc -licudata \
-L$(XERCES_LIB_DIR) -lxerces-c \ -L$(XERCES_LIB_DIR) -lxerces-c \
-lssl \ -lssl \
-lrt -lrt
@ -90,7 +96,7 @@ $(BUILD_OBJ_DIR)/%: $(BUILD_OBJ_DIR)/%.o
.PHONY: doc clean dclean .PHONY: doc clean dclean
####### Build rules ####### Build rules
#libACTK1_3_2.a: $(OBJECTS) #libAusreg_EPP_toolkit.a: $(OBJECTS)
# $(LIB_ARCHIVER) $(LIB_FLAGS) $(BUILD_LIB_DIR)/$@ $^ # $(LIB_ARCHIVER) $(LIB_FLAGS) $(BUILD_LIB_DIR)/$@ $^
@ -103,15 +109,15 @@ dirs:
-mkdir -p $(BUILD_LIB_DIR) -mkdir -p $(BUILD_LIB_DIR)
-mkdir -p $(BUILD_OBJ_DIR) -mkdir -p $(BUILD_OBJ_DIR)
libACTK1_3_2.so: libACTK1_0.so:
$(BUILD_LIB_DIR)/libACTK1_3_2.so: $(objs) $(BUILD_LIB_DIR)/libACTK1_0.so: $(objs)
$(CXX) $(LDFLAGS) $(SHARED_CXXFLAGS) -shared $^ -o $@ $(CXX) $(LDFLAGS) $(PRODORDEV) -shared $^ -o $@
doc: doc:
doxygen etc/Doxyfile doxygen etc/Doxyfile
clean: clean:
$(RM) $(objs) $(BUILD_LIB_DIR)/libACTK1_3_2.so *~ $(RM) $(objs) $(BUILD_LIB_DIR)/libACTK1_0.so *~
$(RM) -r $(BUILD_OBJ_DIR) $(RM) -r $(BUILD_OBJ_DIR)
$(RM) -r $(BUILD_LIB_DIR) $(RM) -r $(BUILD_LIB_DIR)

View File

@ -8,14 +8,6 @@
#include <unistd.h> #include <unistd.h>
#include <sys/socket.h> #include <sys/socket.h>
#if (PRODUCTION==1)
#define sslCast
#define sslUncast
#else
#define sslCast const
#define sslUncast (SSL_CTX *)
#endif
using namespace std; using namespace std;
namespace { namespace {
@ -41,36 +33,36 @@ TLSContext::TLSContext(const string& private_key_file,
SSL_load_error_strings(); SSL_load_error_strings();
SSL_library_init(); SSL_library_init();
sslCast SSL_METHOD *meth = TLSv1_client_method(); SSL_METHOD *meth = TLSv1_client_method();
if (meth == NULL) if (meth == NULL)
throw SSLException("Error initialising SSL method"); throw SSLException("Error initialising SSL method");
// SSL Context // SSL Context
sslCast SSL_CTX *local_ctx = SSL_CTX_new(meth); SSL_CTX *local_ctx = SSL_CTX_new(meth);
if (local_ctx == NULL) if (local_ctx == NULL)
{ {
throw SSLException ("Error initialising SSL context"); throw SSLException ("Error initialising SSL context");
} }
// SSL Ciphers // SSL Ciphers
int i = SSL_CTX_set_cipher_list( sslUncast local_ctx, "TLSv1"); int i = SSL_CTX_set_cipher_list( local_ctx, "TLSv1");
if (i == -1) if (i == -1)
{ {
SSL_CTX_free( sslUncast local_ctx); SSL_CTX_free( local_ctx);
throw SSLException( throw SSLException(
"There was a problem initialising the SSL cipher list"); "There was a problem initialising the SSL cipher list");
} }
SSL_CTX_set_default_passwd_cb_userdata( sslUncast local_ctx, SSL_CTX_set_default_passwd_cb_userdata( local_ctx,
static_cast<void*>(const_cast<char*>(password.c_str()))); static_cast<void*>(const_cast<char*>(password.c_str())));
SSL_CTX_set_default_passwd_cb( sslUncast local_ctx, getPassword); SSL_CTX_set_default_passwd_cb( local_ctx, getPassword);
i = SSL_CTX_use_PrivateKey_file( sslUncast local_ctx, i = SSL_CTX_use_PrivateKey_file( local_ctx,
private_key_file.c_str(), private_key_file.c_str(),
SSL_FILETYPE_PEM); SSL_FILETYPE_PEM);
if (i == -1) if (i == -1)
{ {
SSL_CTX_free( sslUncast local_ctx); SSL_CTX_free( local_ctx);
throw SSLException( throw SSLException(
"There was a problem initialising SSL the private key '" "There was a problem initialising SSL the private key '"
+ private_key_file + "'"); + private_key_file + "'");
@ -78,23 +70,23 @@ TLSContext::TLSContext(const string& private_key_file,
// Load the public certificate for our key. // Load the public certificate for our key.
// Replace with // Replace with
i = SSL_CTX_use_certificate_chain_file( sslUncast local_ctx, cert_file.c_str()); i = SSL_CTX_use_certificate_chain_file( local_ctx, cert_file.c_str());
if (i == -1) if (i == -1)
{ {
SSL_CTX_free( sslUncast local_ctx); SSL_CTX_free( local_ctx);
throw SSLException("Error loading cert_file '" + cert_file + "'"); throw SSLException("Error loading cert_file '" + cert_file + "'");
} }
// Load the CA certificate(s) // Load the CA certificate(s)
i = SSL_CTX_load_verify_locations ( sslUncast local_ctx, ca_file.c_str(), NULL); i = SSL_CTX_load_verify_locations ( local_ctx, ca_file.c_str(), NULL);
if (i == -1) if (i == -1)
{ {
SSL_CTX_free( sslUncast local_ctx); SSL_CTX_free( local_ctx);
throw EPPException ("Could not load CA file '" + ca_file +"'"); throw EPPException ("Could not load CA file '" + ca_file +"'");
} }
ctx = sslUncast local_ctx; ctx = local_ctx;
} }

View File

@ -40,7 +40,7 @@ TLSSocket::TLSSocket(SSL_CTX* ctx, int sock, const string& host,
if ((ret = SSL_get_verify_result(ssl)) != X509_V_OK) if ((ret = SSL_get_verify_result(ssl)) != X509_V_OK)
{ {
SSLException e("Certificate verify failed", ssl, ret); SSLException e("Certificate Verify failed", ssl, ret);
SSL_shutdown(ssl); SSL_shutdown(ssl);
throw e; throw e;
} }

View File

@ -40,7 +40,7 @@ TLSSocket::TLSSocket(SSL_CTX* ctx, int sock, const string& host,
if ((ret = SSL_get_verify_result(ssl)) != X509_V_OK) if ((ret = SSL_get_verify_result(ssl)) != X509_V_OK)
{ {
SSLException e("Certificate verify failed", ssl, ret); SSLException e("Certificate Verify failed", ssl, ret);
SSL_shutdown(ssl); SSL_shutdown(ssl);
throw e; throw e;
} }