Continued development of AuthenticationToken Validation Service.
This commit is contained in:
parent
307ed2444c
commit
6ab8fe3080
@ -157,6 +157,11 @@ IpcClientSubmitReq(
|
|||||||
// pointer to the buffer containing the data
|
// pointer to the buffer containing the data
|
||||||
// received from the server.
|
// received from the server.
|
||||||
//
|
//
|
||||||
|
// The returned buffer always contains a NULL after the
|
||||||
|
// data indicated. You may be able to leverage this to
|
||||||
|
// treat the data as a NULL terminated string in cases
|
||||||
|
// where the request consists of ASCII characters.
|
||||||
|
//
|
||||||
// pServerDataLen - Pointer to variable that will receive the
|
// pServerDataLen - Pointer to variable that will receive the
|
||||||
// length of the data received from the server.
|
// length of the data received from the server.
|
||||||
//
|
//
|
||||||
@ -165,7 +170,10 @@ IpcClientSubmitReq(
|
|||||||
//
|
//
|
||||||
// Abstract: Method to submit a request.
|
// Abstract: Method to submit a request.
|
||||||
//
|
//
|
||||||
// Note: The routine blocks until the request completes.
|
// Notes: The routine blocks until the request completes.
|
||||||
|
//
|
||||||
|
// The buffer returned with the server data must be released
|
||||||
|
// by the calling application by calling free().
|
||||||
//
|
//
|
||||||
//=======================================================================--
|
//=======================================================================--
|
||||||
|
|
||||||
|
@ -89,6 +89,11 @@ IpcServerGetRequestData(
|
|||||||
// Notes: The returned buffer SHOULD NOT be released by the calling
|
// Notes: The returned buffer SHOULD NOT be released by the calling
|
||||||
// application.
|
// application.
|
||||||
//
|
//
|
||||||
|
// The returned buffer always contains a NULL after the
|
||||||
|
// data indicated. You may be able to leverage this to
|
||||||
|
// treat the data as a NULL terminated string in cases
|
||||||
|
// where the request consists of ASCII characters.
|
||||||
|
//
|
||||||
//=======================================================================--
|
//=======================================================================--
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ ROOT = ../../../..
|
|||||||
|
|
||||||
LIBDIR = $(ROOT)/$(LIB)
|
LIBDIR = $(ROOT)/$(LIB)
|
||||||
BINDIR = $(ROOT)/$(BIN)
|
BINDIR = $(ROOT)/$(BIN)
|
||||||
|
JAVA_LIBDIR = /usr/lib/jvm/java-1.5.0-sun-1.5.0_07/jre/lib/i386/server
|
||||||
|
|
||||||
# handle Mono secondary dependencies
|
# handle Mono secondary dependencies
|
||||||
export MONO_PATH := $(MONO_PATH)
|
export MONO_PATH := $(MONO_PATH)
|
||||||
@ -56,8 +57,8 @@ RESOURCES =
|
|||||||
DEFINES += -Wno-format-extra-args -fno-strict-aliasing -fshort-wchar
|
DEFINES += -Wno-format-extra-args -fno-strict-aliasing -fshort-wchar
|
||||||
CFLAGS += $(INCLUDES) $(DEFINES)
|
CFLAGS += $(INCLUDES) $(DEFINES)
|
||||||
CPPFLAGS += -fPIC $(INCLUDES) $(DEFINES)
|
CPPFLAGS += -fPIC $(INCLUDES) $(DEFINES)
|
||||||
LIBS = -lpthread -lcasa_s_ipc
|
LIBS = -lpthread -lcasa_s_ipc -ljvm
|
||||||
LDFLAGS = -L$(LIBDIR)/$(TARGET_CFG)
|
LDFLAGS = -L$(LIBDIR)/$(TARGET_CFG) -L$(JAVA_LIBDIR)
|
||||||
|
|
||||||
OBJDIR = ./$(TARGET_CFG)/$(LIB)
|
OBJDIR = ./$(TARGET_CFG)/$(LIB)
|
||||||
OBJS = $(addprefix $(OBJDIR)/, $(CFILES:%.c=%.o)) $(addprefix $(OBJDIR)/, $(CPPFILES:%.cpp=%.o))
|
OBJS = $(addprefix $(OBJDIR)/, $(CFILES:%.c=%.o)) $(addprefix $(OBJDIR)/, $(CPPFILES:%.cpp=%.o))
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
//===[ Include files ]=====================================================
|
//===[ Include files ]=====================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
//===[ External data ]=====================================================
|
//===[ External data ]=====================================================
|
||||||
|
|
||||||
@ -54,10 +55,12 @@ int beginThreads = 5;
|
|||||||
int growThreads = 5;
|
int growThreads = 5;
|
||||||
int maxThreads = 4096;
|
int maxThreads = 4096;
|
||||||
int minWaitingThreads = beginThreads;
|
int minWaitingThreads = beginThreads;
|
||||||
|
int maxWaitingThreads = beginThreads * 4;
|
||||||
|
|
||||||
// Worker thread pool operating parameters
|
// Worker thread pool operating parameters
|
||||||
double numThreads = 0;
|
double numThreads = 0;
|
||||||
double numBusyThreads = 0;
|
double numBusyThreads = 0;
|
||||||
|
double numPerishingThreads = 0;
|
||||||
|
|
||||||
// Listen Port Number
|
// Listen Port Number
|
||||||
int listenPortNumber = 5000;
|
int listenPortNumber = 5000;
|
||||||
@ -85,6 +88,16 @@ pthread_cond_t serverCondition;
|
|||||||
// Operating parameters
|
// Operating parameters
|
||||||
bool terminating = false;
|
bool terminating = false;
|
||||||
|
|
||||||
|
// Java parameters
|
||||||
|
JavaVM *g_jvm = NULL;
|
||||||
|
JNIEnv *g_env = NULL;
|
||||||
|
|
||||||
|
// Java AuthenticationToken Class and method name
|
||||||
|
//char authTokenClassName[] = "jtest";
|
||||||
|
//char authTokenClassValidateMethodName[] = "test4";
|
||||||
|
char authTokenClassName[] = "com.novell.casa.authtoksvc.AuthToken";
|
||||||
|
char authTokenClassValidateMethodName[] = "validate";
|
||||||
|
|
||||||
|
|
||||||
//++=======================================================================
|
//++=======================================================================
|
||||||
void
|
void
|
||||||
@ -188,12 +201,17 @@ WorkerThreadWaiting(void)
|
|||||||
// Acquire our mutex
|
// Acquire our mutex
|
||||||
pthread_mutex_lock(&serverMutex);
|
pthread_mutex_lock(&serverMutex);
|
||||||
|
|
||||||
// Decrement the numBusyThread count and determine if there are
|
// Decrement the numBusyThread count
|
||||||
// too many of us laying around.
|
|
||||||
numBusyThreads --;
|
numBusyThreads --;
|
||||||
if ((numThreads - numBusyThreads) > minWaitingThreads
|
|
||||||
&& ((numBusyThreads + growThreads) / numThreads) < 0.33 )
|
// Check if we have too many idle workers
|
||||||
|
if ((numThreads - numBusyThreads - numPerishingThreads) > maxWaitingThreads
|
||||||
|
&& numThreads > beginThreads)
|
||||||
|
{
|
||||||
|
// We want to let this worker perish
|
||||||
|
numPerishingThreads ++;
|
||||||
retValue = true;
|
retValue = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
retValue = false;
|
retValue = false;
|
||||||
|
|
||||||
@ -222,11 +240,28 @@ WorkerThread(void*)
|
|||||||
// L0
|
// L0
|
||||||
//=======================================================================--
|
//=======================================================================--
|
||||||
{
|
{
|
||||||
|
bool perishingThread = false;
|
||||||
|
|
||||||
DbgTrace(1, "WorkerThread- Start\n", 0);
|
DbgTrace(1, "WorkerThread- Start\n", 0);
|
||||||
|
|
||||||
// Set the thread in the detached state so that it is cleaned up when it exits
|
// Set the thread in the detached state so that it is cleaned up when it exits
|
||||||
pthread_detach(pthread_self());
|
pthread_detach(pthread_self());
|
||||||
|
|
||||||
|
// Attach the thread to the JVM
|
||||||
|
JNIEnv *env;
|
||||||
|
if (g_jvm->AttachCurrentThread((void**) &env, NULL) >= 0)
|
||||||
|
{
|
||||||
|
// We are now attached to the JVM, find the helper class that
|
||||||
|
// we need.
|
||||||
|
jclass helperClass = env->FindClass(authTokenClassName);
|
||||||
|
if (helperClass)
|
||||||
|
{
|
||||||
|
// Helper class found, now get the id of the method that we invoke
|
||||||
|
jmethodID mId = env->GetStaticMethodID(helperClass,
|
||||||
|
authTokenClassValidateMethodName,
|
||||||
|
"(Ljava/lang/String;)Ljava/lang/String;");
|
||||||
|
if (mId)
|
||||||
|
{
|
||||||
// Loop until told to terminate
|
// Loop until told to terminate
|
||||||
while (!terminating)
|
while (!terminating)
|
||||||
{
|
{
|
||||||
@ -243,14 +278,54 @@ WorkerThread(void*)
|
|||||||
// Indicate that we are now busy
|
// Indicate that we are now busy
|
||||||
WorkerThreadBusy();
|
WorkerThreadBusy();
|
||||||
|
|
||||||
// Just echo the data back as the reply
|
// Lets push the jvm local frame to allow us to clean up our local
|
||||||
IpcServerCompleteRequest(requestId, pReqData);
|
// references later.
|
||||||
|
env->PushLocalFrame(10);
|
||||||
|
|
||||||
|
jstring inString = env->NewStringUTF(pReqData);
|
||||||
|
if (inString)
|
||||||
|
{
|
||||||
|
// Invoke our helper method
|
||||||
|
jstring outString = (jstring) env->CallStaticObjectMethod(helperClass, mId, inString);
|
||||||
|
if (outString)
|
||||||
|
{
|
||||||
|
// The helper method succeded, complete the request.
|
||||||
|
const char *pOutChars = env->GetStringUTFChars(outString, NULL);
|
||||||
|
if (pOutChars)
|
||||||
|
{
|
||||||
|
IpcServerCompleteRequest(requestId, (char*) pOutChars);
|
||||||
|
env->ReleaseStringUTFChars(outString, pOutChars);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(0, "WorkerThread- Unable to get UTF characters\n", 0);
|
||||||
|
IpcServerAbortRequest(requestId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The helper method failed, just abort the request.
|
||||||
|
IpcServerAbortRequest(requestId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(0, "WorkerThread- UTF String allocation failure\n", 0);
|
||||||
|
IpcServerAbortRequest(requestId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pop the jvm local frame to clean up our local references
|
||||||
|
env->PopLocalFrame(NULL);
|
||||||
|
|
||||||
// Indicate that we are no longer busy and get indication of
|
// Indicate that we are no longer busy and get indication of
|
||||||
// whether or not we should continue to try to process requests.
|
// whether or not we should continue to try to process requests.
|
||||||
if (WorkerThreadWaiting() == true)
|
if (WorkerThreadWaiting() == true)
|
||||||
{
|
{
|
||||||
DbgTrace(1, "WorkerThread- Requested to terminate\n", 0);
|
DbgTrace(1, "WorkerThread- Requested to terminate\n", 0);
|
||||||
|
|
||||||
|
// Remember that we are a perishing thread so that we can reduce the
|
||||||
|
// count as we exit.
|
||||||
|
perishingThread = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,13 +341,36 @@ WorkerThread(void*)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(0, "WorkerThread- Failed to get method id\n", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(0, "WorkerThread- Failed to find helper class\n", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detach from the JVM
|
||||||
|
g_jvm->DetachCurrentThread();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(0, "WorkerThread- Failed to attach to JVM\n", 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Decrement the number of worker threads and signal our main thread
|
// Decrement the number of worker threads and signal our main thread
|
||||||
// to terminate itself if we are the last worker thread.
|
// to terminate itself if we are the last worker thread.
|
||||||
pthread_mutex_lock(&serverMutex);
|
pthread_mutex_lock(&serverMutex);
|
||||||
|
|
||||||
|
if (perishingThread)
|
||||||
|
numPerishingThreads --;
|
||||||
|
|
||||||
numThreads --;
|
numThreads --;
|
||||||
if (numThreads == 0)
|
if (numThreads == 0)
|
||||||
pthread_cond_signal(&serverCondition);
|
pthread_cond_signal(&serverCondition);
|
||||||
|
|
||||||
pthread_mutex_unlock(&serverMutex);
|
pthread_mutex_unlock(&serverMutex);
|
||||||
|
|
||||||
DbgTrace(1, "WorkerThread- End\n", 0);
|
DbgTrace(1, "WorkerThread- End\n", 0);
|
||||||
@ -314,6 +412,78 @@ SigTermHandler(
|
|||||||
} /*-- SigTermHandler() --*/
|
} /*-- SigTermHandler() --*/
|
||||||
|
|
||||||
|
|
||||||
|
//++=======================================================================
|
||||||
|
int
|
||||||
|
InitJavaInvoke(void)
|
||||||
|
//
|
||||||
|
// Arguments:
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
//
|
||||||
|
// Abstract:
|
||||||
|
//
|
||||||
|
// Notes:
|
||||||
|
//
|
||||||
|
// L0
|
||||||
|
//=======================================================================--
|
||||||
|
{
|
||||||
|
int retStatus = -1;
|
||||||
|
|
||||||
|
DbgTrace(1, "InitJavaInvoke- Start\n", 0);
|
||||||
|
|
||||||
|
//JavaVMOption options[1];
|
||||||
|
//options[0].optionString = "-Djava.class.path=.";
|
||||||
|
JavaVMOption options[1];
|
||||||
|
options[0].optionString = "-Djava.class.path=/usr/share/java:/etc/CASA/authtoken";
|
||||||
|
JavaVMInitArgs vm_args;
|
||||||
|
vm_args.version = JNI_VERSION_1_4;
|
||||||
|
vm_args.options = options;
|
||||||
|
vm_args.nOptions = 1;
|
||||||
|
vm_args.ignoreUnrecognized = true;
|
||||||
|
if (JNI_CreateJavaVM(&g_jvm, (void**)&g_env, &vm_args) >= 0)
|
||||||
|
{
|
||||||
|
// Success
|
||||||
|
retStatus = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(0, "InitJavaInvoke- Error creating Java VM\n", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
DbgTrace(1, "InitJavaInvoke- End, retStatus = %08X\n", retStatus);
|
||||||
|
|
||||||
|
return retStatus;
|
||||||
|
|
||||||
|
} /*-- InitJavaInvoke() --*/
|
||||||
|
|
||||||
|
|
||||||
|
//++=======================================================================
|
||||||
|
void
|
||||||
|
UnInitJavaInvoke(void)
|
||||||
|
//
|
||||||
|
// Arguments:
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
//
|
||||||
|
// Abstract:
|
||||||
|
//
|
||||||
|
// Notes:
|
||||||
|
//
|
||||||
|
// L0
|
||||||
|
//=======================================================================--
|
||||||
|
{
|
||||||
|
DbgTrace(1, "UnInitJavaInvoke- Start\n", 0);
|
||||||
|
|
||||||
|
// Destroy the jvm
|
||||||
|
g_jvm->DestroyJavaVM();
|
||||||
|
g_jvm = NULL;
|
||||||
|
g_env = NULL;
|
||||||
|
|
||||||
|
DbgTrace(1, "UnInitJavaInvoke- End\n", 0);
|
||||||
|
|
||||||
|
} /*-- UnInitJavaInvoke() --*/
|
||||||
|
|
||||||
|
|
||||||
//++=======================================================================
|
//++=======================================================================
|
||||||
void
|
void
|
||||||
DaemonInit(
|
DaemonInit(
|
||||||
@ -572,6 +742,9 @@ main(
|
|||||||
pthread_mutex_init(&interlockedMutex, NULL);
|
pthread_mutex_init(&interlockedMutex, NULL);
|
||||||
pthread_mutex_init(&serverMutex, NULL);
|
pthread_mutex_init(&serverMutex, NULL);
|
||||||
|
|
||||||
|
// Initialize the JVM
|
||||||
|
if (InitJavaInvoke() == 0)
|
||||||
|
{
|
||||||
// Initialize the condition that we will use to wait
|
// Initialize the condition that we will use to wait
|
||||||
// for the exit of all of our worker threads.
|
// for the exit of all of our worker threads.
|
||||||
if (pthread_cond_init(&serverCondition, NULL) == 0)
|
if (pthread_cond_init(&serverCondition, NULL) == 0)
|
||||||
@ -604,6 +777,8 @@ main(
|
|||||||
|
|
||||||
// Release our mutex
|
// Release our mutex
|
||||||
pthread_mutex_unlock(&serverMutex);
|
pthread_mutex_unlock(&serverMutex);
|
||||||
|
|
||||||
|
DbgTrace(0, "main- Exiting, numThreads = %d\n", numThreads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -620,6 +795,13 @@ main(
|
|||||||
{
|
{
|
||||||
DbgTrace(0, "main- Condition initialization failed\n", 0);
|
DbgTrace(0, "main- Condition initialization failed\n", 0);
|
||||||
}
|
}
|
||||||
|
// Un-initialize JVM
|
||||||
|
UnInitJavaInvoke();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(0, "main- JVM initialization failed\n", 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <micasa_types.h>
|
#include <micasa_types.h>
|
||||||
#include <casa_status.h>
|
#include <casa_status.h>
|
||||||
#include <casa_s_authtoken.h>
|
#include <casa_s_authtoken.h>
|
||||||
|
#include <casa_c_ipc.h>
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "list_entry.h"
|
#include "list_entry.h"
|
||||||
#include "config_if.h"
|
#include "config_if.h"
|
||||||
|
@ -46,7 +46,6 @@ MODULE_NAME = libcasa_s_authtoken
|
|||||||
MODULE_EXT = so
|
MODULE_EXT = so
|
||||||
|
|
||||||
CFILES = ../config.c \
|
CFILES = ../config.c \
|
||||||
../authtoken.c \
|
|
||||||
../principal.c \
|
../principal.c \
|
||||||
../util.c \
|
../util.c \
|
||||||
../validate.c \
|
../validate.c \
|
||||||
@ -58,8 +57,8 @@ INCLUDES = -I. -I.. -I$(CASAINCLUDE) -I../../../include
|
|||||||
RESOURCES =
|
RESOURCES =
|
||||||
DEFINES = -Wno-format-extra-args -fno-strict-aliasing
|
DEFINES = -Wno-format-extra-args -fno-strict-aliasing
|
||||||
CFLAGS += $(INCLUDES) $(DEFINES)
|
CFLAGS += $(INCLUDES) $(DEFINES)
|
||||||
LIBS = -lpthread -ldl -lexpat
|
LIBS = -lpthread -ldl -lexpat -lcasa_c_ipc
|
||||||
LDFLAGS = -Bsymbolic -shared -Wl,-soname=$(MODULE_NAME).$(MODULE_EXT)
|
LDFLAGS = -Bsymbolic -shared -Wl,-soname=$(MODULE_NAME).$(MODULE_EXT) -L$(ROOT)/lib/$(TARGET_CFG)
|
||||||
|
|
||||||
OBJDIR = ./$(TARGET_CFG)/$(LIB)
|
OBJDIR = ./$(TARGET_CFG)/$(LIB)
|
||||||
OBJS = $(addprefix $(OBJDIR)/, $(CFILES:%.c=%.o))
|
OBJS = $(addprefix $(OBJDIR)/, $(CFILES:%.c=%.o))
|
||||||
|
@ -41,6 +41,10 @@ int DebugLevel = 0;
|
|||||||
static
|
static
|
||||||
bool g_moduleInitialized = false;
|
bool g_moduleInitialized = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// IPC Client Sub-system variables
|
||||||
|
//
|
||||||
|
uint32_t atvsEndPointHandle; // Authentication Token Validation Service endpoint handle
|
||||||
|
|
||||||
//++=======================================================================
|
//++=======================================================================
|
||||||
CasaStatus SSCS_CALL
|
CasaStatus SSCS_CALL
|
||||||
@ -125,11 +129,40 @@ ValidateAuthToken(
|
|||||||
// Initialize the IdenToken complex
|
// Initialize the IdenToken complex
|
||||||
retStatus = IdenTokenInit();
|
retStatus = IdenTokenInit();
|
||||||
if (CASA_SUCCESS(retStatus))
|
if (CASA_SUCCESS(retStatus))
|
||||||
|
{
|
||||||
|
// Initialize the Client Ipc Subsystem
|
||||||
|
if (IpcClientInit("CASA_AuthTokenValidate",
|
||||||
|
true,
|
||||||
|
DebugLevel,
|
||||||
|
false) == 0)
|
||||||
|
{
|
||||||
|
// Open endpoint for the Authentication Token Validation Service
|
||||||
|
if (IpcClientOpenInetRemoteEndPoint(5000,
|
||||||
|
0x7F000001,
|
||||||
|
0,
|
||||||
|
&atvsEndPointHandle) == 0)
|
||||||
{
|
{
|
||||||
// Success
|
// Success
|
||||||
g_moduleInitialized = true;
|
g_moduleInitialized = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(0, "-ValidateAuthToken- Failed to open remote endpoint\n", 0);
|
||||||
|
IpcClientShutdown();
|
||||||
|
IdenTokenUninit();
|
||||||
|
PrincipalIfUninit();
|
||||||
|
ConfigIfUninit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(0, "-ValidateAuthToken- Ipc subsystem initialization failed\n", 0);
|
||||||
|
IdenTokenUninit();
|
||||||
|
PrincipalIfUninit();
|
||||||
|
ConfigIfUninit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
PrincipalIfUninit();
|
PrincipalIfUninit();
|
||||||
ConfigIfUninit();
|
ConfigIfUninit();
|
||||||
@ -157,21 +190,27 @@ ValidateAuthToken(
|
|||||||
&decodedTokenBufLen);
|
&decodedTokenBufLen);
|
||||||
if (CASA_SUCCESS(retStatus))
|
if (CASA_SUCCESS(retStatus))
|
||||||
{
|
{
|
||||||
AuthToken *pAuthToken;
|
char *pIdenTokenData;
|
||||||
|
int idenTokenDataLen;
|
||||||
|
|
||||||
// Token was decoded successfully, now create an authentication token object with it.
|
// Token was decoded successfully, now submit the authentication token to the
|
||||||
retStatus = CreateAuthToken(pDecodedTokenBuf, decodedTokenBufLen, &pAuthToken);
|
// authentication token validation service.
|
||||||
if (CASA_SUCCESS(retStatus))
|
if (IpcClientSubmitReq(atvsEndPointHandle,
|
||||||
|
pDecodedTokenBuf,
|
||||||
|
decodedTokenBufLen,
|
||||||
|
&pIdenTokenData,
|
||||||
|
&idenTokenDataLen) == 0)
|
||||||
{
|
{
|
||||||
// Now check the validity of the token
|
// The submit succeeded, make sure that we got some identity data back.
|
||||||
retStatus = CheckAuthToken(pAuthToken, pServiceName);
|
if (pIdenTokenData)
|
||||||
if (CASA_SUCCESS(retStatus))
|
{
|
||||||
|
if (idenTokenDataLen != 0)
|
||||||
{
|
{
|
||||||
IdenTokenProviderIf *pIdenTokenProviderIf;
|
IdenTokenProviderIf *pIdenTokenProviderIf;
|
||||||
|
|
||||||
// The token was validated, now
|
// The authentication token was validated, now obtain
|
||||||
// Obtain Identity Token Provider interface
|
// Identity Token Provider interface.
|
||||||
retStatus = GetIdenTokenProviderInterface(pAuthToken->pIdenTokenType,
|
retStatus = GetIdenTokenProviderInterface("CasaIdentityToken", // tbd - Hard code until we enhance the protocol with the atvs to also return this information.
|
||||||
&pIdenTokenProviderIf);
|
&pIdenTokenProviderIf);
|
||||||
if (CASA_SUCCESS(retStatus))
|
if (CASA_SUCCESS(retStatus))
|
||||||
{
|
{
|
||||||
@ -179,8 +218,8 @@ ValidateAuthToken(
|
|||||||
|
|
||||||
// Use the Identity Token Provider to get an Identity Token Interface instance
|
// Use the Identity Token Provider to get an Identity Token Interface instance
|
||||||
retStatus = pIdenTokenProviderIf->getIdentityTokenIf(pIdenTokenProviderIf,
|
retStatus = pIdenTokenProviderIf->getIdentityTokenIf(pIdenTokenProviderIf,
|
||||||
pAuthToken->pIdenToken,
|
pIdenTokenData,
|
||||||
pAuthToken->idenTokenLen,
|
idenTokenDataLen,
|
||||||
&pIdenTokenIf);
|
&pIdenTokenIf);
|
||||||
if (CASA_SUCCESS(retStatus))
|
if (CASA_SUCCESS(retStatus))
|
||||||
{
|
{
|
||||||
@ -213,14 +252,24 @@ ValidateAuthToken(
|
|||||||
DbgTrace(0, "-ValidateAuthToken- Failed to obtain identity token provider interface\n", 0);
|
DbgTrace(0, "-ValidateAuthToken- Failed to obtain identity token provider interface\n", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(0, "-ValidateAuthToken- ValidateAuthToken submit did not return identity token data\n", 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Free the AuthToken object
|
// Free the buffer containing the identity token data
|
||||||
RelAuthToken(pAuthToken);
|
free(pIdenTokenData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DbgTrace(0, "-ValidateAuthToken- Failed to create authentication token object\n", 0);
|
DbgTrace(0, "-ValidateAuthToken- ValidateAuthToken submit did not return identity token data buffer\n", 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgTrace(1, "-ValidateAuthToken- ValidateAuthToken submit failed\n", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Free the decoded token buffer
|
// Free the decoded token buffer
|
||||||
free(pDecodedTokenBuf);
|
free(pDecodedTokenBuf);
|
||||||
|
@ -447,10 +447,12 @@ CChannel::connectionThread(
|
|||||||
|
|
||||||
DbgTrace(2, "CChannel::connectionThread- Processing Request Data Packet, Obj = %08X\n", pCChannel);
|
DbgTrace(2, "CChannel::connectionThread- Processing Request Data Packet, Obj = %08X\n", pCChannel);
|
||||||
|
|
||||||
// Allocate a buffer big enough to receive the payload
|
// Allocate a buffer big enough to receive the payload. Allow space to NULL terminate.
|
||||||
pRecvBuff = (char*) malloc(payloadLength);
|
pRecvBuff = (char*) malloc(payloadLength + 1);
|
||||||
if (pRecvBuff != NULL)
|
if (pRecvBuff != NULL)
|
||||||
{
|
{
|
||||||
|
pRecvBuff[payloadLength] = '\0';
|
||||||
|
|
||||||
// Buffer allocated, receive the request payload.
|
// Buffer allocated, receive the request payload.
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -380,6 +380,11 @@ IpcClientSubmitReq(
|
|||||||
// pointer to the buffer containing the data
|
// pointer to the buffer containing the data
|
||||||
// received from the server.
|
// received from the server.
|
||||||
//
|
//
|
||||||
|
// The returned buffer always contains a NULL after the
|
||||||
|
// data indicated. You may be able to leverage this to
|
||||||
|
// treat the data as a NULL terminated string in cases
|
||||||
|
// where the request consists of ASCII characters.
|
||||||
|
//
|
||||||
// pServerDataLen - Pointer to variable that will receive the
|
// pServerDataLen - Pointer to variable that will receive the
|
||||||
// length of the data received from the server.
|
// length of the data received from the server.
|
||||||
//
|
//
|
||||||
@ -388,7 +393,10 @@ IpcClientSubmitReq(
|
|||||||
//
|
//
|
||||||
// Abstract: Method to submit a request.
|
// Abstract: Method to submit a request.
|
||||||
//
|
//
|
||||||
// Note: The routine blocks until the request completes.
|
// Notes: The routine blocks until the request completes.
|
||||||
|
//
|
||||||
|
// The buffer returned with the server data must be released
|
||||||
|
// by the calling application by calling free().
|
||||||
//
|
//
|
||||||
// L0
|
// L0
|
||||||
//=======================================================================--
|
//=======================================================================--
|
||||||
|
@ -157,7 +157,7 @@ ExecuteTests(void)
|
|||||||
// Initialize the Client Ipc Subsystem
|
// Initialize the Client Ipc Subsystem
|
||||||
if (IpcClientInit("TestClient",
|
if (IpcClientInit("TestClient",
|
||||||
true,
|
true,
|
||||||
3,
|
DebugLevel,
|
||||||
false) == 0)
|
false) == 0)
|
||||||
{
|
{
|
||||||
// Set the server listen address
|
// Set the server listen address
|
||||||
@ -235,6 +235,7 @@ main(
|
|||||||
bool doneScanning = false;
|
bool doneScanning = false;
|
||||||
bool invalidOption = false;
|
bool invalidOption = false;
|
||||||
int option;
|
int option;
|
||||||
|
int initialCount;
|
||||||
|
|
||||||
printf("**** Ipc Client test ****\n");
|
printf("**** Ipc Client test ****\n");
|
||||||
|
|
||||||
@ -284,7 +285,9 @@ main(
|
|||||||
{
|
{
|
||||||
printf("submitReqCount = %d\n", submitReqCount);
|
printf("submitReqCount = %d\n", submitReqCount);
|
||||||
printf("submitThreadCount = %d\n", submitThreadCount);
|
printf("submitThreadCount = %d\n", submitThreadCount);
|
||||||
|
initialCount = submitReqCount;
|
||||||
ExecuteTests();
|
ExecuteTests();
|
||||||
|
printf("Submits issued = %d\n", initialCount - submitReqCount);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -69,25 +69,16 @@ extern pthread_mutex_t interlockedMutex;
|
|||||||
//
|
//
|
||||||
#define MAX_FORMAT_STRING_LEN 1024
|
#define MAX_FORMAT_STRING_LEN 1024
|
||||||
#define DbgTrace(LEVEL, X, Y) { \
|
#define DbgTrace(LEVEL, X, Y) { \
|
||||||
if (LEVEL == 0) { \
|
if (LEVEL == 0 || DebugLevel >= LEVEL) { \
|
||||||
|
if (UseSyslog) \
|
||||||
|
syslog(LOG_USER | LOG_INFO, X, Y); \
|
||||||
|
else { \
|
||||||
char *pFormatString = new char[MAX_FORMAT_STRING_LEN]; \
|
char *pFormatString = new char[MAX_FORMAT_STRING_LEN]; \
|
||||||
if (pFormatString) { \
|
if (pFormatString) { \
|
||||||
snprintf(pFormatString, MAX_FORMAT_STRING_LEN, X, Y); \
|
snprintf(pFormatString, MAX_FORMAT_STRING_LEN, X, Y); \
|
||||||
if (UseSyslog) \
|
|
||||||
syslog(LOG_USER | LOG_INFO, "%s -%s", pAppName, pFormatString); \
|
|
||||||
else \
|
|
||||||
fprintf(stderr, "%s -%s", pAppName, pFormatString); \
|
fprintf(stderr, "%s -%s", pAppName, pFormatString); \
|
||||||
delete[] pFormatString; \
|
delete[] pFormatString; \
|
||||||
} \
|
} \
|
||||||
} else if (DebugLevel >= LEVEL) { \
|
|
||||||
char *pFormatString = new char[MAX_FORMAT_STRING_LEN]; \
|
|
||||||
if (pFormatString) { \
|
|
||||||
snprintf(pFormatString, MAX_FORMAT_STRING_LEN, X, Y); \
|
|
||||||
if (UseSyslog) \
|
|
||||||
syslog(LOG_USER | LOG_DEBUG, "%s -%s", pAppName, pFormatString); \
|
|
||||||
else \
|
|
||||||
fprintf(stderr, "%s -%s", pAppName, pFormatString); \
|
|
||||||
delete[] pFormatString; \
|
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
@ -291,10 +291,12 @@ SChannel::connectionThread(
|
|||||||
|
|
||||||
DbgTrace(2, "SChannel::connectionThread- Processing Request Data Packet, Obj = %08X\n", pSChannel);
|
DbgTrace(2, "SChannel::connectionThread- Processing Request Data Packet, Obj = %08X\n", pSChannel);
|
||||||
|
|
||||||
// Allocate a buffer big enough to receive the payload
|
// Allocate a buffer big enough to receive the payload. Allow space to NULL terminate.
|
||||||
pRecvBuff = new char[payloadLength];
|
pRecvBuff = new char[payloadLength + 1];
|
||||||
if (pRecvBuff != NULL)
|
if (pRecvBuff != NULL)
|
||||||
{
|
{
|
||||||
|
pRecvBuff[payloadLength] = '\0';
|
||||||
|
|
||||||
// Buffer allocated, receive the Req payload.
|
// Buffer allocated, receive the Req payload.
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -830,6 +830,10 @@ IpcServerGetRequestData(
|
|||||||
// Notes: The returned buffer SHOULD NOT be released by the calling
|
// Notes: The returned buffer SHOULD NOT be released by the calling
|
||||||
// application.
|
// application.
|
||||||
//
|
//
|
||||||
|
// The returned buffer always contains a NULL after the
|
||||||
|
// data indicated. You may be able to leverage this to
|
||||||
|
// treat the data as a NULL terminated string in cases
|
||||||
|
// where the request consists of ASCII characters.
|
||||||
// L1
|
// L1
|
||||||
//=======================================================================--
|
//=======================================================================--
|
||||||
{
|
{
|
||||||
|
@ -166,7 +166,7 @@ ExecuteTests(void)
|
|||||||
|
|
||||||
// Initialize the Svc Ipc Subsystem
|
// Initialize the Svc Ipc Subsystem
|
||||||
if (IpcServerInit("TestServer",
|
if (IpcServerInit("TestServer",
|
||||||
3,
|
DebugLevel,
|
||||||
false) == 0)
|
false) == 0)
|
||||||
{
|
{
|
||||||
// Set the server listen address
|
// Set the server listen address
|
||||||
|
Loading…
Reference in New Issue
Block a user