summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorEmmanuel Raviart <eraviart@entrouvert.com>2004-07-31 16:44:00 +0000
committerEmmanuel Raviart <eraviart@entrouvert.com>2004-07-31 16:44:00 +0000
commited561ce190fb10c4dc35e8c23c39c7292f14e5bc (patch)
treef3f2e37541b79d9cdbde16e9b59474f315fdba3d /java
parent956bee8886799f8c4a90d3c4620a763d8448f911 (diff)
downloadlasso-ed561ce190fb10c4dc35e8c23c39c7292f14e5bc.tar.gz
lasso-ed561ce190fb10c4dc35e8c23c39c7292f14e5bc.tar.xz
lasso-ed561ce190fb10c4dc35e8c23c39c7292f14e5bc.zip
Updated Java binding and unit test.
Diffstat (limited to 'java')
-rw-r--r--java/src/c/com_entrouvert_lasso_LassoAuthnRequest.c2
-rw-r--r--java/src/c/com_entrouvert_lasso_LassoAuthnResponse.c2
-rw-r--r--java/src/c/com_entrouvert_lasso_LassoIdentity.c61
-rw-r--r--java/src/c/com_entrouvert_lasso_LassoLogin.c57
-rw-r--r--java/src/c/com_entrouvert_lasso_LassoLogout.c15
-rw-r--r--java/src/c/com_entrouvert_lasso_LassoProfile.c190
-rw-r--r--java/src/c/com_entrouvert_lasso_LassoRequest.c2
-rw-r--r--java/src/c/com_entrouvert_lasso_LassoResponse.c2
-rw-r--r--java/src/c/com_entrouvert_lasso_LassoServer.c4
-rw-r--r--java/src/c/com_entrouvert_lasso_LassoSession.c (renamed from java/src/c/com_entrouvert_lasso_LassoUser.c)34
-rw-r--r--java/src/c/helper.c93
-rw-r--r--java/src/c/helper.h46
-rw-r--r--java/src/java/com/entrouvert/lasso/LassoIdentity.java44
-rw-r--r--java/src/java/com/entrouvert/lasso/LassoLogin.java12
-rw-r--r--java/src/java/com/entrouvert/lasso/LassoLogout.java2
-rw-r--r--java/src/java/com/entrouvert/lasso/LassoProfile.java54
-rw-r--r--java/src/java/com/entrouvert/lasso/LassoSession.java (renamed from java/src/java/com/entrouvert/lasso/LassoUser.java)8
-rw-r--r--java/tests/LoginTest.java54
18 files changed, 424 insertions, 258 deletions
diff --git a/java/src/c/com_entrouvert_lasso_LassoAuthnRequest.c b/java/src/c/com_entrouvert_lasso_LassoAuthnRequest.c
index 31239ef3..4a1016bd 100644
--- a/java/src/c/com_entrouvert_lasso_LassoAuthnRequest.c
+++ b/java/src/c/com_entrouvert_lasso_LassoAuthnRequest.c
@@ -37,7 +37,7 @@ JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoAuthnRequest_init
(*env)->ReleaseStringUTFChars(env, _providerID, providerID);
- storeCObject(env, this, request);
+ setCObject(env, this, request);
}
/* From LassoLibAuthnRequest */
diff --git a/java/src/c/com_entrouvert_lasso_LassoAuthnResponse.c b/java/src/c/com_entrouvert_lasso_LassoAuthnResponse.c
index a2915d1b..e324fb2d 100644
--- a/java/src/c/com_entrouvert_lasso_LassoAuthnResponse.c
+++ b/java/src/c/com_entrouvert_lasso_LassoAuthnResponse.c
@@ -39,7 +39,7 @@ JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoAuthnResponse_init
(*env)->ReleaseStringUTFChars(env, _providerID, providerID);
- storeCObject(env, this, response);
+ setCObject(env, this, response);
}
JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoAuthnResponse_getStatus
diff --git a/java/src/c/com_entrouvert_lasso_LassoIdentity.c b/java/src/c/com_entrouvert_lasso_LassoIdentity.c
new file mode 100644
index 00000000..b689d083
--- /dev/null
+++ b/java/src/c/com_entrouvert_lasso_LassoIdentity.c
@@ -0,0 +1,61 @@
+/*
+ * JLasso -- Java bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Benjamin Poussin <poussin@codelutin.com>
+ * Emmanuel Raviart <eraviart@entrouvert.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <helper.h>
+#include <com_entrouvert_lasso_LassoIdentity.h>
+#include <lasso/lasso.h>
+
+JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoIdentity_init
+(JNIEnv * env, jobject this){
+ LassoIdentity *identity;
+
+ identity = lasso_identity_new();
+
+ setCObject(env, this, identity);
+}
+
+JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoIdentity_initFromDump
+(JNIEnv * env, jobject this, jstring _dump){
+ LassoIdentity *identity;
+ char *dump;
+
+ dump = (char*)(*env)->GetStringUTFChars(env, _dump, NULL);
+ identity = lasso_identity_new_from_dump(dump);
+
+ (*env)->ReleaseStringUTFChars(env, _dump, dump);
+
+ setCObject(env, this, identity);
+}
+
+JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoIdentity_dump
+(JNIEnv * env, jobject this){
+ LassoIdentity *identity;
+ char* result;
+
+ identity = (LassoIdentity*)getCObject(env, this);
+ result = lasso_identity_dump(identity);
+
+ return (*env)->NewStringUTF(env, result);
+}
+
diff --git a/java/src/c/com_entrouvert_lasso_LassoLogin.c b/java/src/c/com_entrouvert_lasso_LassoLogin.c
index e720de79..dd9d3aeb 100644
--- a/java/src/c/com_entrouvert_lasso_LassoLogin.c
+++ b/java/src/c/com_entrouvert_lasso_LassoLogin.c
@@ -27,41 +27,37 @@
#include <com_entrouvert_lasso_LassoLogin.h>
JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoLogin_init
-(JNIEnv * env, jobject this, jobject _server){
+(JNIEnv * env, jobject this, jobject _server) {
LassoLogin *login;
LassoServer* server;
server = (LassoServer*)getCObject(env, _server);
login = LASSO_LOGIN(lasso_login_new(server));
- storeCObject(env, this, login);
+ setCObject(env, this, login);
}
JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoLogin_initFromDump
-(JNIEnv * env, jobject this, jobject _server,
- jobject _user,
- jstring _dump){
+(JNIEnv * env, jobject this, jobject _server, jobject _identity, jstring _dump) {
LassoLogin *login;
LassoServer* server;
char *dump;
- LassoUser* user = NULL;
+ LassoIdentity* identity = NULL;
server = (LassoServer*)getCObject(env, _server);
- if(_user != NULL){
- user = (LassoUser*)getCObject(env, _user);
+ if(_identity != NULL){
+ identity = (LassoIdentity*)getCObject(env, _identity);
}
dump = (char*)(*env)->GetStringUTFChars(env, _dump, NULL);
- login = LASSO_LOGIN(lasso_login_new_from_dump(server, user, dump));
+ login = LASSO_LOGIN(lasso_login_new_from_dump(server, identity, dump));
(*env)->ReleaseStringUTFChars(env, _dump, dump);
- storeCObject(env, this, login);
+ setCObject(env, this, login);
}
JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_buildArtifactMsg
-(JNIEnv * env, jobject this, jboolean _authenticationResult,
- jstring _authenticationMethod,
- jstring _reauthenticateOnOrAfter,
- jint _method){
+(JNIEnv * env, jobject this, jboolean _authenticationResult, jstring _authenticationMethod,
+ jstring _reauthenticateOnOrAfter, jint _method) {
int result;
LassoLogin* login;
char *authenticationMethod;
@@ -129,20 +125,13 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_buildRequestMsg
return result;
}
-JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_createUser
-(JNIEnv * env, jobject this, jstring _userDump){
+JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_acceptSso
+(JNIEnv * env, jobject this){
LassoLogin* login;
int result;
- char *userDump = NULL;
-
- if (_userDump)
- userDump = (char*)(*env)->GetStringUTFChars(env, _userDump, NULL);
login = getCObject(env, this);
- result = lasso_login_create_user(login, userDump);
-
- if (_userDump)
- (*env)->ReleaseStringUTFChars(env, _userDump, userDump);
+ result = lasso_login_accept_sso(login);
return result;
}
@@ -175,8 +164,7 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_initAuthnRequest
}
JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_initFromAuthnRequestMsg
-(JNIEnv * env, jobject this, jstring _authnRequestMsg,
- jint _authnRequestMethod){
+(JNIEnv * env, jobject this, jstring _authnRequestMsg, jint _authnRequestMethod) {
int result;
LassoLogin* login;
char *authnRequestMsg;
@@ -194,8 +182,7 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_initFromAuthnRequest
}
JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_initRequest
-(JNIEnv * env, jobject this, jstring _responseMsg,
- jint _responseMethod){
+(JNIEnv * env, jobject this, jstring _responseMsg, jint _responseMethod) {
int result;
LassoLogin* login;
char *responseMsg;
@@ -213,7 +200,7 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_initRequest
}
JNIEXPORT jboolean JNICALL Java_com_entrouvert_lasso_LassoLogin_mustAuthenticate
-(JNIEnv * env, jobject this){
+(JNIEnv * env, jobject this) {
int result;
LassoLogin* login;
@@ -224,7 +211,7 @@ JNIEXPORT jboolean JNICALL Java_com_entrouvert_lasso_LassoLogin_mustAuthenticate
}
JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_processAuthnResponseMsg
-(JNIEnv * env, jobject this, jstring _authnResponseMsg){
+(JNIEnv * env, jobject this, jstring _authnResponseMsg) {
int result;
LassoLogin* login;
char *authnResponseMsg;
@@ -241,7 +228,7 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_processAuthnResponse
}
JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_processRequestMsg
-(JNIEnv * env, jobject this, jstring _requestMsg){
+(JNIEnv * env, jobject this, jstring _requestMsg) {
int result;
LassoLogin* login;
char *requestMsg;
@@ -258,7 +245,7 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_processRequestMsg
}
JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_processResponseMsg
-(JNIEnv * env, jobject this, jstring _responseMsg){
+(JNIEnv * env, jobject this, jstring _responseMsg) {
int result;
LassoLogin* login;
char *responseMsg;
@@ -275,7 +262,7 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_processResponseMsg
}
JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoLogin_getAssertionArtifact
-(JNIEnv * env, jobject this){
+(JNIEnv * env, jobject this) {
LassoLogin * login;
char *result;
@@ -287,7 +274,7 @@ JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoLogin_getAssertionArtif
}
JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_getProtocolProfile
-(JNIEnv * env, jobject this){
+(JNIEnv * env, jobject this) {
LassoLogin * login;
int result;
@@ -299,7 +286,7 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogin_getProtocolProfile
}
JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoLogin_getResponseDump
-(JNIEnv * env, jobject this){
+(JNIEnv * env, jobject this) {
LassoLogin * login;
char *result;
diff --git a/java/src/c/com_entrouvert_lasso_LassoLogout.c b/java/src/c/com_entrouvert_lasso_LassoLogout.c
index 7d4326ce..fef9c212 100644
--- a/java/src/c/com_entrouvert_lasso_LassoLogout.c
+++ b/java/src/c/com_entrouvert_lasso_LassoLogout.c
@@ -35,7 +35,7 @@ JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoLogout_init
server = (LassoServer*)getCObject(env, _server);
logout = lasso_logout_new(server, _providerType);
- storeCObject(env, this, logout);
+ setCObject(env, this, logout);
}
JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoLogout_buildRequestMsg
@@ -60,19 +60,6 @@ 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 = LASSO_PROFILE_CONTEXT(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){
char* result;
diff --git a/java/src/c/com_entrouvert_lasso_LassoProfile.c b/java/src/c/com_entrouvert_lasso_LassoProfile.c
index 8f1cb94c..970b17cb 100644
--- a/java/src/c/com_entrouvert_lasso_LassoProfile.c
+++ b/java/src/c/com_entrouvert_lasso_LassoProfile.c
@@ -26,8 +26,90 @@
#include <lasso/lasso.h>
#include <com_entrouvert_lasso_LassoProfile.h>
+JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfile_getCIdentity
+(JNIEnv *env, jobject this) {
+ LassoProfile * profile;
+ char * fieldName = "identity";
+ char * fieldType = "Lcom/entrouvert/lasso/LassoIdentity;";
+ char * javaObjectClassName = "com/entrouvert/lasso/LassoIdentity";
+ LassoIdentity *identity;
+
+ profile = getCObject(env, this);
+ identity = lasso_profile_get_identity(profile);
+ checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, identity);
+}
+
+JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfile_getCRequest
+(JNIEnv *env, jobject this) {
+ LassoProfile * profile;
+ char * fieldName = "request";
+ char * fieldType = "Lcom/entrouvert/lasso/LassoNode;";
+ char * javaObjectClassName = "com/entrouvert/lasso/LassoNode";
+ LassoNode *request;
+
+ profile = getCObject(env, this);
+ request = profile->request;
+
+ if (profile->request_type == lassoMessageTypeAuthnRequest) {
+ javaObjectClassName = "com/entrouvert/lasso/LassoAuthnRequest";
+ } else if (profile->request_type == lassoMessageTypeRequest) {
+ javaObjectClassName = "com/entrouvert/lasso/LassoRequest";
+ } else {
+ /* FIXME: Throw error */
+ }
+ checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, request);
+}
+
+JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfile_getCResponse
+(JNIEnv *env, jobject this) {
+ LassoProfile * profile;
+ char * fieldName = "response";
+ char * fieldType = "Lcom/entrouvert/lasso/LassoNode;";
+ char * javaObjectClassName = "com/entrouvert/lasso/LassoNode";
+ LassoNode *response;
+
+ profile = getCObject(env, this);
+ response = profile->response;
+
+ if (profile->response_type == lassoMessageTypeAuthnResponse) {
+ javaObjectClassName = "com/entrouvert/lasso/LassoAuthnResponse";
+ } else if (profile->response_type == lassoMessageTypeResponse) {
+ javaObjectClassName = "com/entrouvert/lasso/LassoResponse";
+ } else {
+ /* FIXME: Throw error */
+ }
+ checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, response);
+}
+
+JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfile_getCServer
+(JNIEnv *env, jobject this) {
+ LassoProfile * profile;
+ char * fieldName = "server";
+ char * fieldType = "Lcom/entrouvert/lasso/LassoServer;";
+ char * javaObjectClassName = "com/entrouvert/lasso/LassoServer";
+ LassoServer *server;
+
+ profile = getCObject(env, this);
+ server = profile->server;
+ checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, server);
+}
+
+JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfile_getCSession
+(JNIEnv *env, jobject this) {
+ LassoProfile * profile;
+ char * fieldName = "session";
+ char * fieldType = "Lcom/entrouvert/lasso/LassoSession;";
+ char * javaObjectClassName = "com/entrouvert/lasso/LassoSession";
+ LassoSession *session;
+
+ profile = getCObject(env, this);
+ session = lasso_profile_get_session(profile);
+
+ checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, session);
+}
+
JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfile_getMsgBody
-(JNIEnv * env, jobject this){
+(JNIEnv *env, jobject this) {
LassoProfile * profile;
char * result;
@@ -39,7 +121,7 @@ JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfile_getMsgBody
}
JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfile_getMsgRelayState
-(JNIEnv * env, jobject this){
+(JNIEnv *env, jobject this) {
LassoProfile * profile;
char * result;
@@ -51,7 +133,7 @@ JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfile_getMsgRelayStat
}
JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfile_getMsgUrl
-(JNIEnv * env, jobject this){
+(JNIEnv *env, jobject this) {
LassoProfile * profile;
char * result;
@@ -63,7 +145,7 @@ JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfile_getMsgUrl
}
JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfile_getNameIdentifier
-(JNIEnv * env, jobject this){
+(JNIEnv *env, jobject this) {
LassoProfile * profile;
char *result;
@@ -76,7 +158,7 @@ JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfile_getNameIdentifi
}
JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfile_getProviderID
-(JNIEnv * env, jobject this){
+(JNIEnv *env, jobject this) {
LassoProfile * profile;
char * result;
@@ -88,7 +170,7 @@ JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoProfile_getProviderID
}
JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoProfile_getRequestType
-(JNIEnv * env, jobject this){
+(JNIEnv *env, jobject this) {
LassoProfile * profile;
char * result;
@@ -98,7 +180,7 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoProfile_getRequestType
}
JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoProfile_getResponseType
-(JNIEnv * env, jobject this){
+(JNIEnv *env, jobject this) {
LassoProfile * profile;
char * result;
@@ -107,86 +189,56 @@ JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoProfile_getResponseType
return profile->response_type;
}
-JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfile_initRequestField
-(JNIEnv * env, jobject this){
- LassoProfile * profile;
- char * fieldName = "request";
- char * fieldType = "Lcom/entrouvert/lasso/LassoNode;";
- char * javaObjectClassName = "com/entrouvert/lasso/LassoNode";
- LassoNode *cObject;
-
- profile = getCObject(env, this);
- cObject = profile->request;
-
- if (profile->request_type == lassoMessageTypeAuthnRequest) {
- javaObjectClassName = "com/entrouvert/lasso/LassoAuthnRequest";
- } else if(profile->request_type == lassoMessageTypeRequest) {
- javaObjectClassName = "com/entrouvert/lasso/LassoRequest";
- } else {
- /* FIXME: Throw error */
- }
- checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, cObject);
-}
-
-JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfile_initResponseField
-(JNIEnv * env, jobject this){
- LassoProfile * profile;
- char * fieldName = "response";
- char * fieldType = "Lcom/entrouvert/lasso/LassoNode;";
- char * javaObjectClassName = "com/entrouvert/lasso/LassoNode";
- LassoNode *cObject;
+JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoProfile_setCIdentity
+(JNIEnv *env, jobject this) {
+ char *fieldName = "identity";
+ char *fieldType = "Lcom/entrouvert/lasso/LassoIdentity;";
+ jobject _identity;
+ LassoIdentity *identity;
+ LassoProfile *profile;
profile = getCObject(env, this);
- cObject = profile->response;
-
- if(profile->response_type == lassoMessageTypeAuthnResponse){
- javaObjectClassName = "com/entrouvert/lasso/LassoAuthnResponse";
- }else if(profile->response_type == lassoMessageTypeResponse){
- javaObjectClassName = "com/entrouvert/lasso/LassoResponse";
- }else{
- /* FIXME: Throw error */
- }
-
- checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, cObject);
+ _identity = getJavaObjectField(env, this, fieldName, fieldType);
+ identity = getCObject(env, _identity);
+ return lasso_profile_set_identity(profile, identity);
}
-JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfile_initServerField
-(JNIEnv * env, jobject this){
- LassoProfile * profile;
- char * fieldName = "server";
- char * fieldType = "Lcom/entrouvert/lasso/LassoServer;";
- char * javaObjectClassName = "com/entrouvert/lasso/LassoServer";
- LassoServer *cObject;
+JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoProfile_setCSession
+(JNIEnv *env, jobject this) {
+ char *fieldName = "session";
+ char *fieldType = "Lcom/entrouvert/lasso/LassoSession;";
+ jobject _session;
+ LassoSession *session;
+ LassoProfile *profile;
profile = getCObject(env, this);
- cObject = profile->server;
-
- checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, cObject);
+ _session = getJavaObjectField(env, this, fieldName, fieldType);
+ session = getCObject(env, _session);
+ return lasso_profile_set_session(profile, session);
}
-JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoProfile_initUserField
-(JNIEnv * env, jobject this){
- LassoProfile * profile;
- char * fieldName = "user";
- char * fieldType = "Lcom/entrouvert/lasso/LassoUser;";
- char * javaObjectClassName = "com/entrouvert/lasso/LassoUser";
- LassoUser *cObject;
+JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoProfile_setIdentityFromDump
+(JNIEnv *env, jobject this, jstring _dump) {
+ int result;
+ LassoProfile *profile;
+ char *dump;
profile = getCObject(env, this);
- cObject = profile->user;
-
- checkAndSetField(env, this, fieldName, fieldType, javaObjectClassName, cObject);
+ dump = (char*)(*env)->GetStringUTFChars(env, _dump, NULL);
+ result = lasso_profile_set_identity_from_dump(profile, dump);
+ (*env)->ReleaseStringUTFChars(env, _dump, dump);
+ return result;
}
-JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoProfile_setUserFromDump
-(JNIEnv * env, jobject this, jstring _dump) {
+JNIEXPORT jint JNICALL Java_com_entrouvert_lasso_LassoProfile_setSessionFromDump
+(JNIEnv *env, jobject this, jstring _dump) {
int result;
LassoProfile *profile;
char *dump;
profile = getCObject(env, this);
dump = (char*)(*env)->GetStringUTFChars(env, _dump, NULL);
- result = lasso_profile_set_user_from_dump(profile, dump);
+ result = lasso_profile_set_session_from_dump(profile, dump);
(*env)->ReleaseStringUTFChars(env, _dump, dump);
return result;
}
diff --git a/java/src/c/com_entrouvert_lasso_LassoRequest.c b/java/src/c/com_entrouvert_lasso_LassoRequest.c
index 7c905cf0..d625a9c2 100644
--- a/java/src/c/com_entrouvert_lasso_LassoRequest.c
+++ b/java/src/c/com_entrouvert_lasso_LassoRequest.c
@@ -37,6 +37,6 @@ JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoRequest_init
(*env)->ReleaseStringUTFChars(env, _assertionArtifact, assertionArtifact);
- storeCObject(env, this, request);
+ setCObject(env, this, request);
}
diff --git a/java/src/c/com_entrouvert_lasso_LassoResponse.c b/java/src/c/com_entrouvert_lasso_LassoResponse.c
index 1cb0b69c..b2d0ea23 100644
--- a/java/src/c/com_entrouvert_lasso_LassoResponse.c
+++ b/java/src/c/com_entrouvert_lasso_LassoResponse.c
@@ -32,5 +32,5 @@ JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoResponse_init
response = lasso_response_new();
- storeCObject(env, this, response);
+ setCObject(env, this, response);
}
diff --git a/java/src/c/com_entrouvert_lasso_LassoServer.c b/java/src/c/com_entrouvert_lasso_LassoServer.c
index 57f911ca..45cd8615 100644
--- a/java/src/c/com_entrouvert_lasso_LassoServer.c
+++ b/java/src/c/com_entrouvert_lasso_LassoServer.c
@@ -52,7 +52,7 @@ JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoServer_init
(*env)->ReleaseStringUTFChars(env, _privateKey, privateKey);
(*env)->ReleaseStringUTFChars(env, _certificate, certificate);
- storeCObject(env, this, server);
+ setCObject(env, this, server);
}
JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoServer_initFromDump
@@ -65,7 +65,7 @@ JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoServer_initFromDump
(*env)->ReleaseStringUTFChars(env, _dump, dump);
- storeCObject(env, this, server);
+ setCObject(env, this, server);
}
JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoServer_addProvider
diff --git a/java/src/c/com_entrouvert_lasso_LassoUser.c b/java/src/c/com_entrouvert_lasso_LassoSession.c
index 8881b41e..cfd78d11 100644
--- a/java/src/c/com_entrouvert_lasso_LassoUser.c
+++ b/java/src/c/com_entrouvert_lasso_LassoSession.c
@@ -23,53 +23,53 @@
*/
#include <helper.h>
-#include <com_entrouvert_lasso_LassoUser.h>
+#include <com_entrouvert_lasso_LassoSession.h>
#include <lasso/lasso.h>
-JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoUser_init
+JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoSession_init
(JNIEnv * env, jobject this){
- LassoUser *user;
+ LassoSession *session;
- user = lasso_user_new();
+ session = lasso_session_new();
- storeCObject(env, this, user);
+ setCObject(env, this, session);
}
-JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoUser_initFromDump
+JNIEXPORT void JNICALL Java_com_entrouvert_lasso_LassoSession_initFromDump
(JNIEnv * env, jobject this, jstring _dump){
- LassoUser *user;
+ LassoSession *session;
char *dump;
dump = (char*)(*env)->GetStringUTFChars(env, _dump, NULL);
- user = lasso_user_new_from_dump(dump);
+ session = lasso_session_new_from_dump(dump);
(*env)->ReleaseStringUTFChars(env, _dump, dump);
- storeCObject(env, this, user);
+ setCObject(env, this, session);
}
-JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoUser_dump
+JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoSession_dump
(JNIEnv * env, jobject this){
- LassoUser *user;
+ LassoSession *session;
char* result;
- user = (LassoUser*)getCObject(env, this);
- result = lasso_user_dump(user);
+ session = (LassoSession*)getCObject(env, this);
+ result = lasso_session_dump(session);
return (*env)->NewStringUTF(env, result);
}
-JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoUser_getAuthenticationMethod
+JNIEXPORT jstring JNICALL Java_com_entrouvert_lasso_LassoSession_getAuthenticationMethod
(JNIEnv * env, jobject this, jstring _remoteProviderId){
char *remoteProviderId = NULL;
char *result;
- LassoUser* user;
+ LassoSession* session;
if (_remoteProviderId)
remoteProviderId = (char*)(*env)->GetStringUTFChars(env, _remoteProviderId, NULL);
- user = getCObject(env, this);
- result = lasso_user_get_authentication_method(user, remoteProviderId);
+ session = getCObject(env, this);
+ result = lasso_session_get_authentication_method(session, remoteProviderId);
if (_remoteProviderId)
(*env)->ReleaseStringUTFChars(env, _remoteProviderId, remoteProviderId);
diff --git a/java/src/c/helper.c b/java/src/c/helper.c
index b2e147d1..17e555c1 100644
--- a/java/src/c/helper.c
+++ b/java/src/c/helper.c
@@ -24,41 +24,33 @@
#include <helper.h>
-void * getObjectRef(JNIEnv * env, jobject this, const char * name){
- jclass clazz;
- jfieldID fid;
- jlong result;
-
- clazz = (*env)->GetObjectClass(env, this);
- fid = (*env)->GetFieldID(env, clazz, name, "J");
-
- result = (*env)->GetLongField(env, this, fid);
- return (void*)(long)result;
-}
-
-void setObjectRef(JNIEnv * env, jobject this, const char * name, void * objectRef){
- jclass clazz;
- jfieldID fid;
- jlong ref;
-
- clazz = (*env)->GetObjectClass(env, this);
- fid = (*env)->GetFieldID(env, clazz, name, "J");
+void checkAndSetField(JNIEnv *env, jobject this, char *fieldName,
+ char *fieldType, char *javaObjectClassName, void *cObject) {
+ jobject javaObject;
- ref = (jlong)(long)objectRef;
- (*env)->SetLongField(env, this, fid, ref);
-}
+ /* check if changes are made */
+ javaObject = getJavaObjectField(env, this, fieldName, fieldType);
+ if(isSameObject(env, javaObject, cObject)){
+ /* no change made, do nothing */
+ return;
+ }
+ javaObject = instantiate(env, javaObjectClassName);
+ if(javaObject == NULL){
+ return; /* exception thrown */
+ }
-void storeCObject(JNIEnv * env, jobject this, void * cobject){
- setObjectRef(env, this, "c_lasso_object", cobject);
+ /* associate C object with JavaObject */
+ setCObject(env, javaObject, cObject);
+ setJavaObjectField(env, this, fieldName, fieldType, javaObject);
}
-void* getCObject(JNIEnv * env, jobject this){
+void * getCObject(JNIEnv * env, jobject this) {
return getObjectRef(env, this, "c_lasso_object");
}
-
-jobject getJavaObjectField(JNIEnv * env, jobject this, const char * fieldName, const char * fieldType){
+jobject getJavaObjectField(JNIEnv * env, jobject this, const char * fieldName,
+ const char * fieldType) {
jclass clazz;
jfieldID fid;
jobject result;
@@ -70,17 +62,19 @@ jobject getJavaObjectField(JNIEnv * env, jobject this, const char * fieldName, c
return result;
}
-void setJavaObjectField(JNIEnv * env, jobject this, const char * fieldName, const char * fieldType, jobject value){
+void * getObjectRef(JNIEnv * env, jobject this, const char * name) {
jclass clazz;
jfieldID fid;
+ jlong result;
clazz = (*env)->GetObjectClass(env, this);
- fid = (*env)->GetFieldID(env, clazz, fieldName, fieldType);
+ fid = (*env)->GetFieldID(env, clazz, name, "J");
- (*env)->SetObjectField(env, this, fid, value);
+ result = (*env)->GetLongField(env, this, fid);
+ return (void*)(long)result;
}
-jobject instanciate(JNIEnv * env, const char * className){
+jobject instantiate(JNIEnv * env, const char * className){
jclass clazz;
jmethodID constructor;
jobject result;
@@ -104,23 +98,28 @@ int isSameObject(JNIEnv * env, jobject javaObject, void* cObject){
return javaObject != NULL && cObject == getCObject(env, javaObject);
}
-void checkAndSetField(JNIEnv * env, jobject this, char * fieldName,
-char * fieldType, char * javaObjectClassName, void * cObject){
- jobject javaObject;
+void setCObject(JNIEnv * env, jobject this, void * cobject) {
+ setObjectRef(env, this, "c_lasso_object", cobject);
+}
- /* check if change are made */
- javaObject = getJavaObjectField(env, this, fieldName, fieldType);
- if(isSameObject(env, javaObject, cObject)){
- /* no change made, do nothing */
- return;
- }
+void setJavaObjectField(JNIEnv * env, jobject this, const char * fieldName, const char * fieldType, jobject value){
+ jclass clazz;
+ jfieldID fid;
- javaObject = instanciate(env, javaObjectClassName);
- if(javaObject == NULL){
- return; /* exception thrown */
- }
+ clazz = (*env)->GetObjectClass(env, this);
+ fid = (*env)->GetFieldID(env, clazz, fieldName, fieldType);
- /* associate C object with JavaObject */
- storeCObject(env, javaObject, cObject);
- setJavaObjectField(env, this, fieldName, fieldType, javaObject);
+ (*env)->SetObjectField(env, this, fid, value);
+}
+
+void setObjectRef(JNIEnv * env, jobject this, const char * name, void * objectRef) {
+ jclass clazz;
+ jfieldID fid;
+ jlong ref;
+
+ clazz = (*env)->GetObjectClass(env, this);
+ fid = (*env)->GetFieldID(env, clazz, name, "J");
+
+ ref = (jlong)(long)objectRef;
+ (*env)->SetLongField(env, this, fid, ref);
}
diff --git a/java/src/c/helper.h b/java/src/c/helper.h
index 4f84387e..346574a1 100644
--- a/java/src/c/helper.h
+++ b/java/src/c/helper.h
@@ -28,54 +28,56 @@
#include <jni.h>
/**
-* Store C object in Java object
+* If field in Java object don't represent C object, then create new Java
+* object representation for this C object and set java field.
*/
-void storeCObject(JNIEnv * env, jobject this, void * cobject);
+void checkAndSetField(JNIEnv * env, jobject this, char * fieldName,
+ char * fieldType, char * javaObjectClassName, void * cObject);
/**
* Get C object from Java object
*/
-void* getCObject(JNIEnv * env, jobject this);
+void *getCObject(JNIEnv * env, jobject this);
/**
-* Get pointer object stored in java field
-* @param name name of field used to store pointer
-* @return object pointer
+* Get value of attribute, attribute must be Java object
*/
-void * getObjectRef(JNIEnv * env, jobject this, const char * name);
+jobject getJavaObjectField(JNIEnv * env, jobject this, const char * fieldName,
+ const char * fieldType);
/**
-* Store object pointer in java field
+* Get pointer object stored in java field
* @param name name of field used to store pointer
-* @param objectRef pointer to store
+* @return object pointer
*/
-void setObjectRef(JNIEnv * env, jobject this, const char * name, void * objectRef);
+void *getObjectRef(JNIEnv * env, jobject this, const char * name);
/**
-* Get value of attribute, attribute must be Java object
+* Instantiate a new object. Default constructor used
*/
-jobject getJavaObjectField(JNIEnv * env, jobject this, const char * fieldName, const char * fieldType);
+jobject instantiate(JNIEnv * env, const char * className);
/**
-* Store new value for Java object attribute, attribute must be Java object
+* Check if Java object store the C object passed in parameter
*/
-void setJavaObjectField(JNIEnv * env, jobject this, const char * name, const char * fieldType, jobject value);
+int isSameObject(JNIEnv * env, jobject javaObject, void* cObject);
/**
-* Instanciate a new object. Default constructor used
+* Store C object in Java object
*/
-jobject instanciate(JNIEnv * env, const char * className);
+void setCObject(JNIEnv * env, jobject this, void * cobject);
/**
-* Check if Java object store the C object passed in parameter
+* Store new value for Java object attribute, attribute must be Java object
*/
-int isSameObject(JNIEnv * env, jobject javaObject, void* cObject);
+void setJavaObjectField(JNIEnv * env, jobject this, const char * name, const char * fieldType,
+ jobject value);
/**
-* If field in Java object don't represent C object, then create new Java
-* object representation for this C object and set java field.
+* Store object pointer in java field
+* @param name name of field used to store pointer
+* @param objectRef pointer to store
*/
-void checkAndSetField(JNIEnv * env, jobject this, char * fieldName,
-char * fieldType, char * javaObjectClassName, void * cObject);
+void setObjectRef(JNIEnv * env, jobject this, const char * name, void * objectRef);
#endif
diff --git a/java/src/java/com/entrouvert/lasso/LassoIdentity.java b/java/src/java/com/entrouvert/lasso/LassoIdentity.java
new file mode 100644
index 00000000..8f82ccf6
--- /dev/null
+++ b/java/src/java/com/entrouvert/lasso/LassoIdentity.java
@@ -0,0 +1,44 @@
+/*
+ * JLasso -- Java bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Benjamin Poussin <poussin@codelutin.com>
+ * Emmanuel Raviart <eraviart@entrouvert.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package com.entrouvert.lasso;
+
+public class LassoIdentity extends LassoObject { // LassoIdentity
+
+ public LassoIdentity(){
+ init();
+ }
+
+ public LassoIdentity(String dump){
+ initFromDump(dump);
+ }
+
+ native protected void init();
+
+ native protected void initFromDump(String dump);
+
+ native public String dump();
+
+} // LassoIdentity
+
diff --git a/java/src/java/com/entrouvert/lasso/LassoLogin.java b/java/src/java/com/entrouvert/lasso/LassoLogin.java
index 461078dc..4fb720f0 100644
--- a/java/src/java/com/entrouvert/lasso/LassoLogin.java
+++ b/java/src/java/com/entrouvert/lasso/LassoLogin.java
@@ -31,18 +31,20 @@ public class LassoLogin extends LassoProfile { // LassoLogin
init(server);
}
- public LassoLogin(LassoServer server, LassoUser user, String dump){
+ public LassoLogin(LassoServer server, LassoIdentity identity, String dump){
this.server = server;
- this.user = user;
- initFromDump(server, user, dump);
+ this.identity = identity;
+ initFromDump(server, identity, dump);
}
native protected void init(LassoServer server);
native protected void initFromDump(LassoServer server,
- LassoUser user,
+ LassoIdentity identity,
String dump);
+ native public int acceptSso();
+
native public int buildArtifactMsg(boolean authenticationResult,
String authenticationMethod,
String reauthenticateOnOrAfter,
@@ -56,8 +58,6 @@ public class LassoLogin extends LassoProfile { // LassoLogin
native public int buildRequestMsg();
- native public int createUser(String userDump);
-
native public String dump();
native public int initAuthnRequest(String providerId);
diff --git a/java/src/java/com/entrouvert/lasso/LassoLogout.java b/java/src/java/com/entrouvert/lasso/LassoLogout.java
index 3af45b2d..a500eae7 100644
--- a/java/src/java/com/entrouvert/lasso/LassoLogout.java
+++ b/java/src/java/com/entrouvert/lasso/LassoLogout.java
@@ -37,8 +37,6 @@ public class LassoLogout extends LassoProfile { // LassoLogout
native public int buildResponseMsg();
- native public String getNameIdentifier();
-
native public String getNextProviderId();
native public int initRequest(String providerId);
diff --git a/java/src/java/com/entrouvert/lasso/LassoProfile.java b/java/src/java/com/entrouvert/lasso/LassoProfile.java
index 02e1c590..e2389f4a 100644
--- a/java/src/java/com/entrouvert/lasso/LassoProfile.java
+++ b/java/src/java/com/entrouvert/lasso/LassoProfile.java
@@ -25,18 +25,30 @@
package com.entrouvert.lasso;
public abstract class LassoProfile extends LassoObject { // LassoProfile
+ protected LassoIdentity identity = null;
protected LassoNode request = null;
protected LassoNode response = null;
protected LassoServer server = null;
- protected LassoUser user = null;
+ protected LassoSession session = null;
- native protected void initRequestField();
+ native protected void getCIdentity();
- native protected void initResponseField();
+ native protected void getCRequest();
- native protected void initServerField();
+ native protected void getCResponse();
- native protected void initUserField();
+ native protected void getCServer();
+
+ native protected void getCSession();
+
+ native protected int setCIdentity();
+
+ native protected int setCSession();
+
+ public LassoIdentity getIdentity() {
+ getCIdentity();
+ return identity;
+ }
native public String getMsgBody();
@@ -48,30 +60,42 @@ public abstract class LassoProfile extends LassoObject { // LassoProfile
native public String getProviderID();
- public LassoNode getRequest(){
- initRequestField();
+ public LassoNode getRequest() {
+ getCRequest();
return request;
}
native public int getRequestType();
- public LassoNode getResponse(){
- initResponseField();
+ public LassoNode getResponse() {
+ getCResponse();
return response;
}
native public int gettResponseType();
- public LassoServer getServer(){
- initServerField();
+ public LassoServer getServer() {
+ getCServer();
return server;
}
- public LassoUser getUser(){
- initUserField();
- return user;
+ public LassoSession getSession() {
+ getCSession();
+ return session;
+ }
+
+ public int setIdentity(LassoIdentity identity) {
+ this.identity = identity;
+ return setCIdentity();
+ }
+
+ native public int setIdentityFromDump(String identityDump);
+
+ public int setSession(LassoSession session) {
+ this.session = session;
+ return setCSession();
}
- native public int setUserFromDump(String userDump);
+ native public int setSessionFromDump(String sessionDump);
} // LassoProfile
diff --git a/java/src/java/com/entrouvert/lasso/LassoUser.java b/java/src/java/com/entrouvert/lasso/LassoSession.java
index b31345ed..29aa19a9 100644
--- a/java/src/java/com/entrouvert/lasso/LassoUser.java
+++ b/java/src/java/com/entrouvert/lasso/LassoSession.java
@@ -24,13 +24,13 @@
package com.entrouvert.lasso;
-public class LassoUser extends LassoObject { // LassoUser
+public class LassoSession extends LassoObject { // LassoSession
- public LassoUser(){
+ public LassoSession(){
init();
}
- public LassoUser(String dump){
+ public LassoSession(String dump){
initFromDump(dump);
}
@@ -42,5 +42,5 @@ public class LassoUser extends LassoObject { // LassoUser
native public String getAuthenticationMethod(String remoteProviderId);
-} // LassoUser
+} // LassoSession
diff --git a/java/tests/LoginTest.java b/java/tests/LoginTest.java
index 7c7f8b22..8e14bb11 100644
--- a/java/tests/LoginTest.java
+++ b/java/tests/LoginTest.java
@@ -80,14 +80,16 @@ public class LoginTest extends TestCase {
boolean userAuthenticated;
int method, requestType;
LassoAuthnRequest authnRequest;
+ LassoIdentity idpIdentityContext, spIdentityContext;
LassoLogin idpLoginContext, spLoginContext;
LassoLogout idpLogoutContext, spLogoutContext;
LassoResponse response;
LassoServer idpContext, spContext;
- LassoUser idpUserContext, spUserContext;
+ LassoSession idpSessionContext, spSessionContext;
String artifact, authenticationMethod, authnRequestQuery, authnRequestUrl, idpContextDump,
- idpUserContextDump, nameIdentifier, relayState, responseQuery, responseUrl,
- soapEndpoint, soapResponseMsg, soapRequestMsg, spContextDump, spUserContextDump;
+ idpIdentityContextDump, idpSessionContextDump, nameIdentifier, relayState,
+ responseQuery, responseUrl, soapEndpoint, soapResponseMsg, soapRequestMsg,
+ spContextDump, spIdentityContextDump, spSessionContextDump;
// Service provider login using HTTP redirect.
spContextDump = generateServiceProviderContextDump();
@@ -122,8 +124,10 @@ public class LoginTest extends TestCase {
assertEquals(0, idpLoginContext.buildArtifactMsg(
userAuthenticated, authenticationMethod, "FIXME: reauthenticateOnOrAfter",
Lasso.httpMethodRedirect));
- idpUserContextDump = idpLoginContext.getUser().dump();
- assertNotNull(idpUserContextDump);
+ idpIdentityContextDump = idpLoginContext.getIdentity().dump();
+ assertNotNull(idpIdentityContextDump);
+ idpSessionContextDump = idpLoginContext.getSession().dump();
+ assertNotNull(idpSessionContextDump);
responseUrl = idpLoginContext.getMsgUrl();
responseQuery = responseUrl.substring(responseUrl.indexOf("?") + 1);
soapResponseMsg = idpLoginContext.getResponseDump();
@@ -149,12 +153,16 @@ public class LoginTest extends TestCase {
assertEquals(0, spLoginContext.processResponseMsg(soapResponseMsg));
assertEquals(nameIdentifier, spLoginContext.getNameIdentifier());
// The user doesn't have any federation yet.
- assertEquals(0, spLoginContext.createUser(null));
- spUserContext = spLoginContext.getUser();
- assertNotNull(spUserContext);
- spUserContextDump = spUserContext.dump();
- assertNotNull(spUserContextDump);
- authenticationMethod = spUserContext.getAuthenticationMethod(null);
+ assertEquals(0, spLoginContext.acceptSso());
+ spIdentityContext = spLoginContext.getIdentity();
+ assertNotNull(spIdentityContext);
+ spIdentityContextDump = spIdentityContext.dump();
+ assertNotNull(spIdentityContextDump);
+ spSessionContext = spLoginContext.getSession();
+ assertNotNull(spSessionContext);
+ spSessionContextDump = spSessionContext.dump();
+ assertNotNull(spSessionContextDump);
+ authenticationMethod = spSessionContext.getAuthenticationMethod(null);
assertEquals(Lasso.samlAuthenticationMethodPassword, authenticationMethod);
// Service provider logout.
@@ -163,8 +171,10 @@ public class LoginTest extends TestCase {
spContext = new LassoServer(spContextDump);
assertNotNull(spContext);
spLogoutContext = new LassoLogout(spContext, Lasso.providerTypeSp);
- assertNotNull(spUserContextDump);
- spLogoutContext.setUserFromDump(spUserContextDump);
+ assertNotNull(spIdentityContextDump);
+ spLogoutContext.setIdentityFromDump(spIdentityContextDump);
+ assertNotNull(spSessionContextDump);
+ spLogoutContext.setSessionFromDump(spSessionContextDump);
assertEquals(0, spLogoutContext.initRequest(null));
assertEquals(0, spLogoutContext.buildRequestMsg());
soapEndpoint = spLogoutContext.getMsgUrl();
@@ -180,13 +190,15 @@ public class LoginTest extends TestCase {
idpLogoutContext = new LassoLogout(idpContext, Lasso.providerTypeIdp);
assertEquals(0, idpLogoutContext.loadRequestMsg(soapRequestMsg, Lasso.httpMethodSoap));
assertEquals(nameIdentifier, idpLogoutContext.getNameIdentifier());
- assertNotNull(idpUserContextDump);
- assertEquals(0, idpLogoutContext.setUserFromDump(idpUserContextDump));
+ assertNotNull(idpIdentityContextDump);
+ assertEquals(0, idpLogoutContext.setIdentityFromDump(idpIdentityContextDump));
+ assertNotNull(idpSessionContextDump);
+ assertEquals(0, idpLogoutContext.setSessionFromDump(idpSessionContextDump));
assertEquals(0, idpLogoutContext.processRequest());
- idpUserContext = idpLogoutContext.getUser();
- assertNotNull(idpUserContext);
- idpUserContextDump = idpUserContext.dump();
- assertNotNull(idpUserContextDump);
+ idpIdentityContext = idpLogoutContext.getIdentity();
+ assertNotNull(idpIdentityContext);
+ idpIdentityContextDump = idpIdentityContext.dump();
+ assertNotNull(idpIdentityContextDump);
// There is no other service provider from which the user must be logged out.
assertEquals(null, idpLogoutContext.getNextProviderId());
assertEquals(0, idpLogoutContext.buildResponseMsg());
@@ -194,8 +206,8 @@ public class LoginTest extends TestCase {
// Service provider logout (step 2: process SOAP response).
assertEquals(0, spLogoutContext.processResponseMsg(soapResponseMsg, Lasso.httpMethodSoap));
- spUserContextDump = spLogoutContext.getUser().dump();
- assertNotNull(spUserContextDump);
+ spIdentityContextDump = spLogoutContext.getIdentity().dump();
+ assertNotNull(spIdentityContextDump);
}
public static Test suite() {