andya 2004/04/29 10:05:17
Modified: jk/native2/server/dsapi Makefile.in jk_dsapi_plugin.c
jk_logger_domino.c config.h
Log:
Added code to lookup the real Notes username for authenticated users and pass that
as the request username.
Revision Changes Path
1.2 +10 -4 jakarta-tomcat-connectors/jk/native2/server/dsapi/Makefile.in
Index: Makefile.in
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/dsapi/Makefile.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile.in 26 Mar 2004 13:53:06 -0000 1.1
+++ Makefile.in 29 Apr 2004 17:05:17 -0000 1.2
@@ -7,6 +7,7 @@
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
@@ -20,6 +21,10 @@
JAVA_LIB=-L ${JAVA_HOME}/jre/lib/${ARCH} -L ${JAVA_HOME}/lib/${ARCH}/native_threads
endif
+NOTES_INCL=-I ${NOTESAPI}/include
+NOTES_OBJS=${NOTESAPI}/lib/linux/notes0.o
+NOTES_CFLAGS=-DUNIX -DLINUX
+
JK_DIR := ../..
BUILD_DIR = ${JK_DIR}/../build/jk2/dsapi
@@ -30,13 +35,14 @@
INCLUDES= -I${JK_DIR}/include \
${APR_INCL} \
${DOMINO_INCL} \
- ${JAVA_INCL}
+ ${JAVA_INCL} \
+ ${NOTES_INCL}
JK_CFLAGS=-DCHUNK_SIZE=4096 @APR_CFLAGS@ -DHAVE_MMAP @HAVE_JNI@ @HAS_PCRE@
JK_LDFLAGS=-lcrypt ${APR_LDFLAGS} @PCRE_LIBS@
###### Based on rules.mk ##########################################
-ALL_CFLAGS = $(EXTRA_CFLAGS) $(NOTEST_CFLAGS) $(CFLAGS)
+ALL_CFLAGS = $(EXTRA_CFLAGS) $(NOTEST_CFLAGS) $(NOTES_CFLAGS) $(CFLAGS)
ALL_CPPFLAGS = $(DEFS) $(EXTRA_CPPFLAGS) $(NOTEST_CPPFLAGS) $(CPPFLAGS)
ALL_LDFLAGS = $(EXTRA_LDFLAGS) $(NOTEST_LDFLAGS) $(LDFLAGS)
ALL_LIBS = $(EXTRA_LIBS) $(NOTEST_LIBS) $(LIBS)
@@ -93,13 +99,13 @@
#all: prepare ${BUILD_DIR}/libtomcat2.so ${BUILD_DIR}/libjkjni.so
all: prepare ${BUILD_DIR}/libtomcat2.so
-${BUILD_DIR}/libtomcat2.la: ${COMMON_LO_FILES} ${DSAPI_LO_FILES}
+${BUILD_DIR}/libtomcat2.la: ${COMMON_LO_FILES} ${DSAPI_LO_FILES} ${NOTES_OBJS}
${MOD_LINK} -o $@ $^ ${JK_LDFLAGS}
${BUILD_DIR}/libtomcat2.so: ${BUILD_DIR}/libtomcat2.la
$(MOD_INSTALL) $^ `pwd`/${BUILD_DIR}
-#${BUILD_DIR}/libjkjni.la: ${JNI_LO_FILES} ${COMMON_LO_FILES}
+#${BUILD_DIR}/libjkjni.la: ${JNI_LO_FILES} ${COMMON_LO_FILES} ${NOTES_OBJS}
# $(MOD_LINK) -o $@ $(JK_LDFLAGS) $^
#${BUILD_DIR}/libjkjni.so: ${BUILD_DIR}/libjkjni.la
1.11 +123 -6
jakarta-tomcat-connectors/jk/native2/server/dsapi/jk_dsapi_plugin.c
Index: jk_dsapi_plugin.c
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-connectors/jk/native2/server/dsapi/jk_dsapi_plugin.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- jk_dsapi_plugin.c 29 Apr 2004 12:22:38 -0000 1.10
+++ jk_dsapi_plugin.c 29 Apr 2004 17:05:17 -0000 1.11
@@ -50,7 +50,11 @@
#include "apr_general.h"
/* Domino DSAPI filter definitions */
-#include "dsapifilter.h"
+#include <global.h>
+#include <addin.h>
+#include <dsapi.h>
+#include <osmem.h>
+#include <lookup.h>
int JK_METHOD jk2_logger_domino_factory(jk_env_t *env, jk_pool_t *pool, jk_bean_t
*result, const char *type, const char *name);
@@ -78,6 +82,7 @@
static int tomcatTimeout = TOMCAT_STARTSTOP_TO;
static const char *crlf = "\r\n";
+static const char *filterdesc = FILTERDESC;
#define WORKPOOL globalPool
@@ -641,6 +646,108 @@
return kFilterHandledRequest;
}
+/* Get the info from the lookup buffer
+ */
+static int getLookupInfo(FilterContext *context, char *pMatch, int itemNumber, char
**pInfo, int *pInfoLen) {
+ unsigned int reserved = 0;
+ unsigned int errID;
+ char *pValue = NULL;
+ WORD lValue, type;
+ STATUS error;
+
+ if (NULL == pMatch || NULL == pInfo || NULL == pInfoLen || (itemNumber < 0)) {
+ return -1;
+ }
+
+ /* Initialize output */
+ *pInfo = NULL;
+ *pInfoLen = 0;
+
+ /* Check the type and length of the info */
+ pValue = (char *) NAMELocateItem(pMatch, itemNumber, &type, &lValue);
+
+ if (NULL == pValue || lValue == 0) {
+ return -1;
+ }
+
+ lValue -= sizeof(WORD); /* remove datatype word included in the list length */
+
+ /* check the value type */
+ if (type != TYPE_TEXT_LIST && type != TYPE_TEXT) {
+ return -1;
+ }
+
+ /* Allocate space for the info. This memory will be freed automatically when
the thread terminates */
+ if (*pInfo = context->AllocMem(context, lValue+1, reserved, &errID), NULL ==
*pInfo) {
+ return -1;
+ }
+
+ /* Get the info */
+ if (error = NAMEGetTextItem(pMatch, itemNumber, 0, *pInfo, lValue + 1), !error)
{
+ *pInfoLen = lValue + 1;
+ return 0;
+ }
+
+ return -1;
+}
+
+/* Lookup the user and return the user's full name
+ */
+static int getUserName(FilterContext *context, char *userName, char **pUserName,
int *pUserNameLen) {
+ STATUS error = NOERROR;
+ HANDLE hLookup = NULLHANDLE;
+ unsigned short nMatches = 0;
+ char *pLookup = NULL;
+ char *pName = NULL;
+ char *pMatch = NULL;
+ int rc = -1;
+
+ if (NULL == userName || NULL == pUserName || NULL == pUserNameLen) {
+ return rc;
+ }
+
+ /* Initializae output */
+ *pUserName = NULL;
+ *pUserNameLen = 0;
+
+ /* do the name lookup */
+ error = NAMELookup(NULL, 0, 1, "$Users", 1, userName, 2, "FullName", &hLookup);
+
+ if (error || (NULLHANDLE == hLookup)) {
+ goto done;
+ }
+
+ pLookup = (char *) OSLockObject(hLookup);
+
+ /* Get pointer to our entry. */
+ pName = (char *) NAMELocateNextName(pLookup, NULL, &nMatches);
+
+ /* If we didn't find the entry, the quit */
+ if (NULL == pName || nMatches <= 0) {
+ goto done;
+ }
+
+ if (pMatch = (char *) NAMELocateNextMatch(pLookup, pName, NULL), NULL ==
pMatch) {
+ goto done;
+ }
+
+ /* Get the full name from the info we got back */
+ if (getLookupInfo(context, pMatch, 0, pUserName, pUserNameLen)) {
+ goto done;
+ }
+
+ rc = 0;
+
+done:
+ if(NULLHANDLE != hLookup) {
+ if (NULL != pLookup) {
+ OSUnlock(hLookup);
+ }
+ OSMemFree(hLookup);
+ }
+ return rc;
+}
+
/* Given all the HTTP headers as a single string parse them into individual
* name, value pairs.
*/
@@ -740,6 +847,13 @@
GETVARIABLE("AUTH_TYPE", &s->auth_type, "");
GETVARIABLE("REMOTE_USER", &s->remote_user, "");
+
+ /* If the REMOTE_USER CGI variable doesn't work try asking Domino */
+ if (s->remote_user[0] == '\0' && fr->userName[0] != '\0') {
+ int len;
+ getUserName(ws->context, fr->userName, &s->remote_user, &len);
+ }
+
GETVARIABLE("SERVER_PROTOCOL", &s->protocol, "");
GETVARIABLE("REMOTE_HOST", &s->remote_host, "");
GETVARIABLE("REMOTE_ADDR", &s->remote_addr, "");
@@ -939,7 +1053,9 @@
s.afterRequest = cbAfterRequest;
if (workerEnv->options == JK_OPT_FWDURICOMPATUNPARSED) {
- s.req_uri = env->globalPool->pstrdup(env, rPool, uri);
+ size_t sz = strlen(uri) + 1;
+ s.req_uri = context->AllocMem(context, sz, 0, &errID);
+ memcpy(s.req_uri, uri, sz);
/* Find the query string again in the original URI */
if (qp = strchr(s.req_uri, '?'), NULL != qp) {
*qp++ = '\0';
@@ -968,6 +1084,7 @@
ws.reqSize = context->GetRequestContents(context,
&ws.reqBuffer, &errID);
rc = processRequest(env, &s, worker, &fr);
+
if (JK_OK == rc) {
rc = worker->service(env, uriEnv->worker, &s);
}
@@ -1058,7 +1175,7 @@
}
#endif
- AddInLogMessageText(FILTERDESC " unloaded", NOERROR);
+ AddInLogMessageText("%s unloaded", NOERROR, filterdesc);
apr_pool_destroy(jk_globalPool);
@@ -1148,7 +1265,7 @@
filterInitData->appFilterVersion = kInterfaceVersion;
filterInitData->eventFlags = kFilterParsedRequest;
- strncpy(filterInitData->filterDesc, FILTERDESC,
sizeof(filterInitData->filterDesc));
+ strncpy(filterInitData->filterDesc, filterdesc,
sizeof(filterInitData->filterDesc));
isInited = JK_TRUE;
/* Display banner
@@ -1158,7 +1275,7 @@
return kFilterHandledEvent;
initFailed:
- AddInLogMessageText("Error loading %s", NOERROR, FILTERDESC);
+ AddInLogMessageText("Error loading %s", NOERROR, filterdesc);
return kFilterError;
}
1.2 +3 -2
jakarta-tomcat-connectors/jk/native2/server/dsapi/jk_logger_domino.c
Index: jk_logger_domino.c
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-connectors/jk/native2/server/dsapi/jk_logger_domino.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- jk_logger_domino.c 28 Apr 2004 15:07:14 -0000 1.1
+++ jk_logger_domino.c 29 Apr 2004 17:05:17 -0000 1.2
@@ -26,7 +26,8 @@
#include "jk_map.h"
#include "jk_logger.h"
-#include "dsapifilter.h"
+#include <global.h>
+#include <addin.h>
static int JK_METHOD jk2_logger_domino_log(jk_env_t *env, jk_logger_t *l,
int level, const char *what) {
1.10 +2 -2 jakarta-tomcat-connectors/jk/native2/server/dsapi/config.h
Index: config.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/dsapi/config.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- config.h 29 Apr 2004 12:23:08 -0000 1.9
+++ config.h 29 Apr 2004 17:05:17 -0000 1.10
@@ -62,7 +62,7 @@
#define TOMCAT_START_TAG "tomcatStart"
#define TOMCAT_STOP_TAG "tomcatStop"
#define TOMCAT_TIMEOUT_TAG "tomcatTimeout"
-#define VERSION "2.0.4"
+#define VERSION "2.0.5"
#define VERSION_STRING "Jakarta/DSAPI/" VERSION
#define FILTERDESC "Apache Tomcat Interceptor (" VERSION_STRING ")"
#define SERVERDFLT "Lotus Domino"
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]