Commit 1aaf0b1c authored by Ricardo Calheiros de Miranda Cosme's avatar Ricardo Calheiros de Miranda Cosme
Browse files

[OPENBUS-1047]

[OPENBUS-1077]

+ SDK C++
  - Aplicando modificações necessárias para compilação Windows 
    na versão 1.5.0.
    


git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/sdk/cpp/tags/OB_SDK_CPP_MICO_MT_v1_05_00_2010_08_11@112853 ae0415b3-e90b-0410-900d-d0be9363c56b
parent e01e73fc
#
# Variveis que devem ser definidas pelo usurio:
#
# VISUAL_STUDIO_VERSION
# OPENBUS_HOME
# MICO_HOME
# PTHREADS_WIN32_INC
#
VISUAL_STUDIO_VERSION= vc9
OPENBUS_HOME= z:\work\openbus\install\trunk
OPENBUS_INC= $(OPENBUS_HOME)\incpath
OPENBUS_LIB= $(OPENBUS_HOME)\libpath\$(VISUAL_STUDIO_VERSION)
MICO_HOME= Z:\tools\mico\mico-2.3.13\release\multithread
MICO_BIN= $(MICO_HOME)\bin\$(VISUAL_STUDIO_VERSION)
MICO_INC= $(MICO_HOME)\include
MICO_LIB= $(MICO_HOME)\lib\$(VISUAL_STUDIO_VERSION)\libmico.lib
MICO_PTHREAD_LIB= $(MICO_HOME)\lib\$(VISUAL_STUDIO_VERSION)\pthreads.lib
PTHREADS_WIN32_INC= z:\builds\mico\mico-2.3.13\contrib\pthreads
INCLUDE= $(INCLUDE).;stubs\mico\;$(MICO_INC);$(PTHREADS_WIN32_INC);$(OPENBUS_INC)\logger;$(OPENBUS_INC)\scs;$(OPENBUS_INC)\lua5.1.3;$(OPENBUS_INC)\openssl-0.9.9
CFLAGS= /nologo /EHsc /DMULTITHREAD /DHAVE_THREADS /DHAVE_PTHREADS
IDLS= $(OPENBUS_HOME)/idlpath/v1_05/core.idl \
$(OPENBUS_HOME)/idlpath/v1_05/scs.idl \
$(OPENBUS_HOME)/idlpath/v1_05/access_control_service.idl \
$(OPENBUS_HOME)/idlpath/v1_05/registry_service.idl \
$(OPENBUS_HOME)/idlpath/v1_05/fault_tolerance.idl \
$(OPENBUS_HOME)/idlpath/v1_05/session_service.idl
STUBS= stubs/mico/core.h stubs/mico/core.cc \
stubs/mico/scs.h stubs/mico/scs.cc \
stubs/mico/access_control_service.h stubs/mico/access_control_service.cc \
stubs/mico/registry_service.h stubs/mico/registry_service.cc \
stubs/mico/fault_tolerance.h stubs/mico/fault_tolerance.cc \
stubs/mico/session_service.h stubs/mico/session_service.cc
SRC= openbus/interceptors/ClientInterceptor.cpp \
openbus/interceptors/ServerInterceptor.cpp \
openbus/interceptors/ORBInitializerImpl.cpp \
stubs/mico/access_control_service.cc \
stubs/mico/registry_service.cc \
stubs/mico/session_service.cc \
stubs/mico/fault_tolerance.cc \
stubs/mico/core.cc \
stubs/mico/scs.cc \
openbus.cpp \
openbus/util/Helper.cpp \
FaultToleranceManager.cpp
OBJ= obj\mico\$(VISUAL_STUDIO_VERSION)\ClientInterceptor.obj \
obj\mico\$(VISUAL_STUDIO_VERSION)\ServerInterceptor.obj \
obj\mico\$(VISUAL_STUDIO_VERSION)\ORBInitializerImpl.obj \
obj\mico\$(VISUAL_STUDIO_VERSION)\access_control_service.obj \
obj\mico\$(VISUAL_STUDIO_VERSION)\registry_service.obj \
obj\mico\$(VISUAL_STUDIO_VERSION)\session_service.obj \
obj\mico\$(VISUAL_STUDIO_VERSION)\fault_tolerance.obj \
obj\mico\$(VISUAL_STUDIO_VERSION)\core.obj \
obj\mico\$(VISUAL_STUDIO_VERSION)\scs.obj \
obj\mico\$(VISUAL_STUDIO_VERSION)\openbus.obj \
obj\mico\$(VISUAL_STUDIO_VERSION)\Helper.obj \
obj\mico\$(VISUAL_STUDIO_VERSION)\FaultToleranceManager.obj
SLIB= lib\$(VISUAL_STUDIO_VERSION)\openbusmico.lib
DLL= lib\$(VISUAL_STUDIO_VERSION)\openbusmico.dll
all: genstubs $(OBJ) $(SLIB) $(DLL)
$(STUBS): $(IDLS)
-mkdir stubs\mico
cd stubs\mico
$(MICO_BIN)\idl --no-paths $(OPENBUS_HOME)/idlpath/v1_05/core.idl
$(MICO_BIN)\idl --no-paths $(OPENBUS_HOME)/idlpath/v1_05/scs.idl
$(MICO_BIN)\idl --no-paths --any --typecode $(OPENBUS_HOME)/idlpath/v1_05/access_control_service.idl
$(MICO_BIN)\idl --no-paths $(OPENBUS_HOME)/idlpath/v1_05/registry_service.idl
$(MICO_BIN)\idl --no-paths $(OPENBUS_HOME)/idlpath/v1_05/fault_tolerance.idl
$(MICO_BIN)\idl --no-paths $(OPENBUS_HOME)/idlpath/v1_05/session_service.idl
cd ..\..\
genstubs: $(STUBS)
$(OBJ): $(SRC)
-mkdir obj\mico\$(VISUAL_STUDIO_VERSION)
CL /c /Foobj\mico\$(VISUAL_STUDIO_VERSION)\ $(CFLAGS) $(SRC)
$(SLIB): $(OBJ)
-mkdir lib\$(VISUAL_STUDIO_VERSION)
LIB /nologo /OUT:$(SLIB) $(OBJ)
$(DLL): $(OBJ)
LINK /nologo /DLL /OUT:$(DLL) $(OBJ) $(MICO_LIB) $(MICO_PTHREAD_LIB) $(OPENBUS_LIB)\logger.lib $(OPENBUS_LIB)\lua5.1.lib $(OPENBUS_LIB)\libeay32.lib $(OPENBUS_LIB)/scsmico.lib wsock32.lib
clean:
rmdir /S /Q stubs
rmdir /S /Q obj\mico\$(VISUAL_STUDIO_VERSION)
rmdir /S /Q lib\$(VISUAL_STUDIO_VERSION)
\ No newline at end of file
#
# Variveis que devem ser definidas pelo usurio:
#
# VISUAL_STUDIO_VERSION
# OPENBUS_HOME
# MICO_HOME
#
VISUAL_STUDIO_VERSION= vc9
OPENBUS_HOME= z:\work\openbus\install\trunk
OPENBUS_INC= $(OPENBUS_HOME)\incpath
OPENBUS_LIB= $(OPENBUS_HOME)\libpath\$(VISUAL_STUDIO_VERSION)
MICO_HOME= Z:\tools\mico\mico-2.3.13\release\multithread
MICO_BIN= $(MICO_HOME)\bin\$(VISUAL_STUDIO_VERSION)
MICO_INC= $(MICO_HOME)\include
MICO_LIB= $(MICO_HOME)\lib\$(VISUAL_STUDIO_VERSION)\libmico.lib
MICO_PTHREAD_LIB= $(MICO_HOME)\lib\$(VISUAL_STUDIO_VERSION)\pthreads.lib
INCLUDE= $(INCLUDE).;stubs;$(MICO_INC);$(OPENBUS_INC)\openbus\cpp;$(OPENBUS_INC)\openbus\cpp\stubs\mico;$(OPENBUS_INC)\logger;$(OPENBUS_INC)\scs;$(OPENBUS_INC)\lua5.1.3;$(OPENBUS_INC)\openssl-0.9.9
CFLAGS= /nologo /EHsc
IDLS= ..\idl\hello.idl
STUBS= stubs\hello.cc
SRC= server.cpp \
client.cpp \
stubs/hello.cc
OBJ= obj\$(VISUAL_STUDIO_VERSION)\server.obj \
obj\$(VISUAL_STUDIO_VERSION)\client.obj \
obj\$(VISUAL_STUDIO_VERSION)\hello.obj
SLIB= lib\$(VISUAL_STUDIO_VERSION)\openbusmico.lib
DLL= lib\$(VISUAL_STUDIO_VERSION)\openbusmico.dll
all: genstubs server.exe client.exe
$(STUBS): $(IDLS)
-mkdir stubs
cd stubs
$(MICO_BIN)\idl --poa ..\..\idl\hello.idl
cd ..\..\
genstubs: $(STUBS)
$(OBJ): $(SRC)
-mkdir obj\$(VISUAL_STUDIO_VERSION)
CL /c /Foobj\$(VISUAL_STUDIO_VERSION)\ $(CFLAGS) $(SRC)
server.exe: $(OBJ)
-mkdir lib\$(VISUAL_STUDIO_VERSION)
LINK /nologo -out:server.exe obj\$(VISUAL_STUDIO_VERSION)\server.obj obj\$(VISUAL_STUDIO_VERSION)\hello.obj $(MICO_LIB) $(MICO_PTHREAD_LIB) $(OPENBUS_LIB)\logger.lib $(OPENBUS_LIB)\lua5.1.lib $(OPENBUS_LIB)\libeay32.lib $(OPENBUS_LIB)\scsmico.lib $(OPENBUS_LIB)\openbusmico.lib wsock32.lib
client.exe: $(OBJ)
-mkdir lib\$(VISUAL_STUDIO_VERSION)
LINK /nologo -out:client.exe obj\$(VISUAL_STUDIO_VERSION)\client.obj obj\$(VISUAL_STUDIO_VERSION)\hello.obj $(MICO_LIB) $(MICO_PTHREAD_LIB) $(OPENBUS_LIB)\logger.lib $(OPENBUS_LIB)\lua5.1.lib $(OPENBUS_LIB)\libeay32.lib $(OPENBUS_LIB)\scsmico.lib $(OPENBUS_LIB)\openbusmico.lib wsock32.lib
clean:
-rmdir /S /Q stubs
-rmdir /S /Q obj\$(VISUAL_STUDIO_VERSION)
-del /Q server.exe client.exe
\ No newline at end of file
......@@ -10,7 +10,9 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef OPENBUS_ORBIX
#include <omg/orb.hh>
......@@ -69,7 +71,11 @@ namespace openbus {
#ifdef OPENBUS_ORBIX
IT_CurrentThread::sleep(1000);
#else
#ifndef _WIN32
::sleep(1);
#else
_sleep(1);
#endif
#endif
}
}
......@@ -93,7 +99,11 @@ namespace openbus {
msg << "sleep [" << timeRenewing <<"]s ...";
logger->log(INFO, msg.str());
msg.str("");
#if _WIN32
this->sleep(timeRenewing * 100);
#else
this->sleep(timeRenewing);
#endif
mutex.lock();
if (bus) {
......@@ -700,8 +710,8 @@ namespace openbus {
unsigned char* challenge = octetSeq->get_buffer();
/* Leitura da chave privada da entidade. */
FILE* fp = fopen(privateKeyFilename, "r");
if (fp == 0) {
BIO* bio = BIO_new( BIO_s_file() );
if (BIO_read_filename( bio, privateKeyFilename ) <= 0) {
stringstream filename;
filename << "No foi possvel abrir o arquivo: " <<
privateKeyFilename;
......@@ -711,8 +721,7 @@ namespace openbus {
throw SECURITY_EXCEPTION(
"No foi possvel abrir o arquivo que armazena a chave privada.");
}
EVP_PKEY* privateKey = PEM_read_PrivateKey(fp, 0, 0, 0);
fclose(fp);
EVP_PKEY* privateKey = PEM_read_bio_PrivateKey( bio, NULL, NULL, 0 );
if (privateKey == 0) {
logger->log(WARNING, "No foi possvel obter a chave privada da entidade.");
logger->log(ERROR, "Throwing SECURITY_EXCEPTION...");
......@@ -721,7 +730,7 @@ namespace openbus {
throw SECURITY_EXCEPTION(
"No foi possvel obter a chave privada da entidade.");
}
int RSAModulusSize = EVP_PKEY_size(privateKey);
/* Decifrando o desafio. */
......@@ -732,26 +741,22 @@ namespace openbus {
RSA_private_decrypt(RSAModulusSize, challenge, challengePlainText,
privateKey->pkey.rsa, RSA_PKCS1_PADDING);
/* Leitura do certificado do ACS. */
FILE* certificateFile = fopen(ACSCertificateFilename, "rb");
if (certificateFile == 0) {
free(challengePlainText);
bio = BIO_new( BIO_s_file() );
if (BIO_read_filename( bio, ACSCertificateFilename ) <= 0) {
stringstream filename;
filename << "No foi possvel abrir o arquivo: " <<
ACSCertificateFilename;
logger->log(WARNING, filename.str());
logger->log(ERROR, "Throwing SECURITY_EXCEPTION...");
logger->dedent(INFO, "Openbus::connect() END");
EVP_PKEY_free(privateKey);
throw SECURITY_EXCEPTION(
"No foi possvel abrir o arquivo que armazena o certificado ACS.");
}
EVP_PKEY_free(privateKey);
X509* x509 = d2i_X509_fp(certificateFile, 0);
fclose(certificateFile);
X509* x509 = d2i_X509_bio(bio, 0);
/* Obteno da chave pblica do ACS. */
EVP_PKEY* publicKey = X509_get_pubkey(x509);
if (publicKey == 0) {
......
......@@ -69,6 +69,7 @@ namespace openbus {
{
Openbus::logger->log(INFO,
"ServerInterceptor::CredentialsValidationCallback() BEGIN");
#ifndef _WIN32
Openbus::logger->indent();
openbus::Openbus* bus = openbus::Openbus::getInstance();
access_control_service::IAccessControlService* iAccessControlService =
......@@ -97,6 +98,7 @@ namespace openbus {
stringstream str;
str << "Prxima validao em: " << validationTime << "ms" << endl;
Openbus::logger->log(INFO, str.str());
#endif
Openbus::logger->dedent(INFO,
"ServerInterceptor::CredentialsValidationCallback() END");
}
......
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