mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2026-01-01 14:15:46 +03:00
JNI calls for log
This commit is contained in:
committed by
Felipe Zimmerle
parent
c18fe9ea8a
commit
455cbbac9e
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
#undef inline
|
#undef inline
|
||||||
#define inline __inline //__ for C
|
#define inline __inline
|
||||||
|
|
||||||
//#include <stdio.h>
|
//#include <stdio.h>
|
||||||
#include "org_modsecurity_ModSecurity.h"
|
#include "org_modsecurity_ModSecurity.h"
|
||||||
@@ -8,30 +7,30 @@
|
|||||||
#include "api.h"
|
#include "api.h"
|
||||||
|
|
||||||
|
|
||||||
//#define MODSECURITY_JAVACLASS "org/modsecurity/ModSecurity"
|
#define MODSECURITY_JAVACLASS "org/modsecurity/ModSecurity"
|
||||||
//
|
|
||||||
//#define MODSECURITY_LOGMETHOD "log"
|
|
||||||
//#define MODSECURITY_LOGSIG "(ILjava/lang/String;)V"
|
|
||||||
|
|
||||||
//JavaVM *jvm;
|
#define MODSECURITY_LOGMETHOD "log"
|
||||||
//jobject modSecurityInstance;
|
#define MODSECURITY_LOGSIG "(ILjava/lang/String;)V"
|
||||||
//jclass modSecurityClass;
|
|
||||||
|
JavaVM *jvm;
|
||||||
|
jobject modSecurityInstance;
|
||||||
|
jclass modSecurityClass;
|
||||||
//
|
//
|
||||||
void logSec(void *obj, int level, char *str)
|
void logSec(void *obj, int level, char *str)
|
||||||
{
|
{
|
||||||
// //JNIEnv *env;
|
JNIEnv *env;
|
||||||
// //jstring jStr;
|
jstring jStr;
|
||||||
// //jmethodID logMethod;
|
jmethodID logMethod;
|
||||||
// // (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL);
|
(*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL);
|
||||||
//
|
|
||||||
// //jStr = (*env)->NewStringUTF(env, str);
|
jStr = (*env)->NewStringUTF(env, str);
|
||||||
// //
|
|
||||||
// //logMethod = (*env)->GetMethodID(env, modSecurityClass, MODSECURITY_LOGMETHOD, MODSECURITY_LOGSIG);
|
logMethod = (*env)->GetMethodID(env, modSecurityClass, MODSECURITY_LOGMETHOD, MODSECURITY_LOGSIG);
|
||||||
// //(*env)->CallVoidMethod(env, modSecurityInstance, logMethod, level, jStr);
|
(*env)->CallVoidMethod(env, modSecurityInstance, logMethod, level, jStr);
|
||||||
// //
|
|
||||||
// //(*env)->ReleaseStringUTFChars(env, jStr, str);
|
(*env)->ReleaseStringUTFChars(env, jStr, str);
|
||||||
//
|
|
||||||
// //(*jvm)->DetachCurrentThread(jvm);
|
(*jvm)->DetachCurrentThread(jvm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -57,12 +56,12 @@ apr_status_t WriteResponseCallback(request_rec *r, char *buf, unsigned int lengt
|
|||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_modsecurity_ModSecurity_initialize(JNIEnv *env, jobject obj)
|
JNIEXPORT jint JNICALL Java_org_modsecurity_ModSecurity_initialize(JNIEnv *env, jobject obj)
|
||||||
{
|
{
|
||||||
//jclass localCls;
|
jclass localCls;
|
||||||
//(*env)->GetJavaVM(env, &jvm);
|
(*env)->GetJavaVM(env, &jvm);
|
||||||
//modSecurityInstance = (*env)->NewGlobalRef(env, obj);
|
modSecurityInstance = (*env)->NewGlobalRef(env, obj);
|
||||||
//localCls = (*env)->FindClass(env, MODSECURITY_JAVACLASS);
|
localCls = (*env)->FindClass(env, MODSECURITY_JAVACLASS);
|
||||||
//modSecurityClass = (jclass) (*env)->NewGlobalRef(env, localCls);
|
modSecurityClass = (jclass) (*env)->NewGlobalRef(env, localCls);
|
||||||
//(*env)->DeleteLocalRef(env, localCls);
|
(*env)->DeleteLocalRef(env, localCls);
|
||||||
|
|
||||||
modsecSetLogHook(NULL, logSec);
|
modsecSetLogHook(NULL, logSec);
|
||||||
|
|
||||||
@@ -76,7 +75,7 @@ JNIEXPORT jint JNICALL Java_org_modsecurity_ModSecurity_initialize(JNIEnv *env,
|
|||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_modsecurity_ModSecurity_destroy(JNIEnv *env, jobject obj)
|
JNIEXPORT jint JNICALL Java_org_modsecurity_ModSecurity_destroy(JNIEnv *env, jobject obj)
|
||||||
{
|
{
|
||||||
// //(*env)->DeleteGlobalRef(env, modSecurityInstance);
|
(*env)->DeleteGlobalRef(env, modSecurityInstance);
|
||||||
// //(*env)->DeleteGlobalRef(env, modSecurityClass);
|
(*env)->DeleteGlobalRef(env, modSecurityClass);
|
||||||
return APR_SUCCESS;
|
return APR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user