diff options
| author | Emmanuel Raviart <eraviart@entrouvert.com> | 2004-07-25 19:29:26 +0000 |
|---|---|---|
| committer | Emmanuel Raviart <eraviart@entrouvert.com> | 2004-07-25 19:29:26 +0000 |
| commit | 5c73b6167694372c9722401c3f05c8df15382065 (patch) | |
| tree | fb41bdb13a6a94345fef83151d92296db6ff11cb /java/src/c | |
| parent | 614ac78aa0bda9d7fcf1ef534bdf069777b84065 (diff) | |
| download | lasso-5c73b6167694372c9722401c3f05c8df15382065.tar.gz lasso-5c73b6167694372c9722401c3f05c8df15382065.tar.xz lasso-5c73b6167694372c9722401c3f05c8df15382065.zip | |
Java unit test is again similar to Python.
Corrected Java binding to pass the unit test both with Kaffe and Sun JRE.
Added a small new test in Python unit test.
Diffstat (limited to 'java/src/c')
| -rw-r--r-- | java/src/c/com_entrouvert_lasso_LassoAuthnRequest.c | 1 | ||||
| -rw-r--r-- | java/src/c/com_entrouvert_lasso_LassoLogin.c | 12 | ||||
| -rw-r--r-- | java/src/c/com_entrouvert_lasso_LassoLogout.c | 67 | ||||
| -rw-r--r-- | java/src/c/com_entrouvert_lasso_LassoProfileContext.c | 84 |
4 files changed, 105 insertions, 59 deletions
diff --git a/java/src/c/com_entrouvert_lasso_LassoAuthnRequest.c b/java/src/c/com_entrouvert_lasso_LassoAuthnRequest.c index a71af821..31239ef3 100644 --- a/java/src/c/com_entrouvert_lasso_LassoAuthnRequest.c +++ b/java/src/c/com_entrouvert_lasso_LassoAuthnRequest.c @@ -30,6 +30,7 @@ JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoAuthnRequest_init (JNIEnv * env, jobject this, jstring _providerID){ LassoNode * request; char * providerID; + providerID = (char*)(*env)->GetStringUTFChars(env, _providerID, NULL); request = lasso_authn_request_new(providerID); diff --git a/java/src/c/com_entrouvert_lasso_LassoLogin.c b/java/src/c/com_entrouvert_lasso_LassoLogin.c index 5da86e00..7824cd5d 100644 --- a/java/src/c/com_entrouvert_lasso_LassoLogin.c +++ b/java/src/c/com_entrouvert_lasso_LassoLogin.c @@ -293,18 +293,6 @@ JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoLogin_getAssertionArtif return (*env)->NewStringUTF(env, result); } -JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoLogin_getNameIdentifier -(JNIEnv * env, jobject this){ - LassoLogin * login; - char *result; - - login = getCObject(env, this); - - result = login->nameIdentifier; - - return (*env)->NewStringUTF(env, result); -} - JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_getProtocolProfile (JNIEnv * env, jobject this){ LassoLogin * login; diff --git a/java/src/c/com_entrouvert_lasso_LassoLogout.c b/java/src/c/com_entrouvert_lasso_LassoLogout.c index 62f34020..5601a6ce 100644 --- a/java/src/c/com_entrouvert_lasso_LassoLogout.c +++ b/java/src/c/com_entrouvert_lasso_LassoLogout.c @@ -28,23 +28,20 @@ #include <lasso/lasso.h> JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoLogout_init -(JNIEnv * env, jobject this, jobject _server, - jobject _user, - jint _providerType){ +(JNIEnv * env, jobject this, jint _providerType, jobject _server, jobject _user){ LassoLogout *logout; LassoServer* server; - LassoUser* user; + LassoUser* user = NULL; server = (LassoServer*)getCObject(env, _server); - user = (LassoUser*)getCObject(env, _user); + if (_user != NULL) + user = (LassoUser*)getCObject(env, _user); - logout = lasso_logout_new(server, user, _providerType); + logout = lasso_logout_new(_providerType, server, user); storeCObject(env, this, logout); } - - JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_buildRequestMsg (JNIEnv * env, jobject this){ int result; @@ -56,7 +53,6 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_buildRequestMsg return result; } - JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_buildResponseMsg (JNIEnv * env, jobject this){ int result; @@ -68,6 +64,18 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_buildResponseMsg return result; } +JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoLogout_getNameIdentifier +(JNIEnv * env, jobject this){ + LassoLogout * logout; + char *result; + + logout = getCObject(env, this); + + result = logout->nameIdentifier; + if (result == NULL) + return NULL; + return (*env)->NewStringUTF(env, result); +} JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoLogout_getNextProviderId (JNIEnv * env, jobject this){ @@ -81,7 +89,6 @@ JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoLogout_getNextProviderI return (*env)->NewStringUTF(env, result); } - JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_initRequest (JNIEnv * env, jobject this, jstring _providerID){ int result; @@ -100,9 +107,8 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_initRequest return result; } -JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_processRequestMsg -(JNIEnv * env, jobject this, jstring _requestMsg, - jint _requestMethod){ +JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_loadRequestMsg +(JNIEnv * env, jobject this, jstring _requestMsg, jint _requestMethod){ int result; LassoLogout* logout; char *requestMsg; @@ -110,18 +116,39 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_processRequestMsg requestMsg = (char*)(*env)->GetStringUTFChars(env, _requestMsg, NULL); logout = getCObject(env, this); - result = lasso_logout_process_request_msg(logout, - requestMsg, - _requestMethod); + result = lasso_logout_load_request_msg(logout, requestMsg, _requestMethod); (*env)->ReleaseStringUTFChars(env, _requestMsg, requestMsg); return result; } +JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_loadUserDump +(JNIEnv * env, jobject this, jstring _userDump){ + int result; + LassoLogout* logout; + char *userDump; + + userDump = (char*)(*env)->GetStringUTFChars(env, _userDump, NULL); + + logout = getCObject(env, this); + result = lasso_logout_load_user_dump(logout, userDump); + + (*env)->ReleaseStringUTFChars(env, _userDump, userDump); + + return result; +} + +JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_processRequest +(JNIEnv * env, jobject this){ + LassoLogout* logout; + + logout = getCObject(env, this); + return lasso_logout_process_request(logout); +} + JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_processResponseMsg -(JNIEnv * env, jobject this, jstring _responseMsg, - jint _responseMethod){ +(JNIEnv * env, jobject this, jstring _responseMsg, jint _responseMethod){ int result; LassoLogout* logout; char *responseMsg; @@ -129,9 +156,7 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_processResponseMsg responseMsg = (char*)(*env)->GetStringUTFChars(env, _responseMsg, NULL); logout = getCObject(env, this); - result = lasso_logout_process_response_msg(logout, - responseMsg, - _responseMethod); + result = lasso_logout_process_response_msg(logout, responseMsg, _responseMethod); (*env)->ReleaseStringUTFChars(env, _responseMsg, responseMsg); diff --git a/java/src/c/com_entrouvert_lasso_LassoProfileContext.c b/java/src/c/com_entrouvert_lasso_LassoProfileContext.c index 4ac339a0..932c167c 100644 --- a/java/src/c/com_entrouvert_lasso_LassoProfileContext.c +++ b/java/src/c/com_entrouvert_lasso_LassoProfileContext.c @@ -26,80 +26,85 @@ #include <lasso/lasso.h> #include <com_entrouvert_lasso_LassoProfileContext.h> -JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfileContext_getProviderID +JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfileContext_getMsgBody (JNIEnv * env, jobject this){ LassoProfileContext * profileContext; char * result; profileContext = getCObject(env, this); - result = profileContext->remote_providerID; + result = profileContext->msg_body; return (*env)->NewStringUTF(env, result); } -JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfileContext_getMsgUrl +JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfileContext_getMsgRelayState (JNIEnv * env, jobject this){ LassoProfileContext * profileContext; char * result; profileContext = getCObject(env, this); - result = profileContext->msg_url; + result = profileContext->msg_relayState; return (*env)->NewStringUTF(env, result); } -JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfileContext_getMsgBody +JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfileContext_getMsgUrl (JNIEnv * env, jobject this){ LassoProfileContext * profileContext; char * result; profileContext = getCObject(env, this); - result = profileContext->msg_body; + result = profileContext->msg_url; return (*env)->NewStringUTF(env, result); } -JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfileContext_getMsgRelayState +JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfileContext_getNameIdentifier +(JNIEnv * env, jobject this){ + LassoProfileContext * profileContext; + char *result; + + profileContext = getCObject(env, this); + + result = profileContext->nameIdentifier; + if (result == NULL) + return NULL; + return (*env)->NewStringUTF(env, result); +} + +JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfileContext_getProviderID (JNIEnv * env, jobject this){ LassoProfileContext * profileContext; char * result; profileContext = getCObject(env, this); - result = profileContext->msg_relayState; + result = profileContext->remote_providerID; return (*env)->NewStringUTF(env, result); } -JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfileContext_initServerField +JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoProfileContext_getRequestType (JNIEnv * env, jobject this){ LassoProfileContext * profileContext; - char * fieldName = "server"; - char * fieldType = "Lcom/entrouvert/lasso/LassoServer;"; - char * javaObjectClassName = "com/entrouvert/lasso/LassoServer"; - LassoServer *cObject; + char * result; profileContext = getCObject(env, this); - cObject = profileContext->server; - checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, cObject); + return profileContext->request_type; } -JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfileContext_initUserField +JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoProfileContext_getResponseType (JNIEnv * env, jobject this){ LassoProfileContext * profileContext; - char * fieldName = "user"; - char * fieldType = "Lcom/entrouvert/lasso/LassoUser;"; - char * javaObjectClassName = "com/entrouvert/lasso/LassoUser"; - LassoUser *cObject; + char * result; profileContext = getCObject(env, this); - cObject = profileContext->user; - checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, cObject); + return profileContext->response_type; } JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfileContext_initRequestField @@ -113,14 +118,13 @@ JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfileContext_initRequest profileContext = getCObject(env, this); cObject = profileContext->request; - if(profileContext->request_type == lassoMessageTypeAuthnRequest){ + if (profileContext->request_type == lassoMessageTypeAuthnRequest) { javaObjectClassName = "com/entrouvert/lasso/LassoAuthnRequest"; - }else if(profileContext->request_type == lassoMessageTypeRequest){ + } else if(profileContext->request_type == lassoMessageTypeRequest) { javaObjectClassName = "com/entrouvert/lasso/LassoRequest"; - }else{ + } else { /* FIXME: Throw error */ } - checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, cObject); } @@ -146,3 +150,31 @@ JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfileContext_initRespons checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, cObject); } +JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfileContext_initServerField +(JNIEnv * env, jobject this){ + LassoProfileContext * profileContext; + char * fieldName = "server"; + char * fieldType = "Lcom/entrouvert/lasso/LassoServer;"; + char * javaObjectClassName = "com/entrouvert/lasso/LassoServer"; + LassoServer *cObject; + + profileContext = getCObject(env, this); + cObject = profileContext->server; + + checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, cObject); +} + +JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfileContext_initUserField +(JNIEnv * env, jobject this){ + LassoProfileContext * profileContext; + char * fieldName = "user"; + char * fieldType = "Lcom/entrouvert/lasso/LassoUser;"; + char * javaObjectClassName = "com/entrouvert/lasso/LassoUser"; + LassoUser *cObject; + + profileContext = getCObject(env, this); + cObject = profileContext->user; + + checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, cObject); +} + |
