summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2008-04-29 12:07:59 +0000
committerFrederic Peters <fpeters@entrouvert.com>2008-04-29 12:07:59 +0000
commit4e43c605c28a713ca3d7b4a55ea1b118dc67d43d (patch)
treeb781ddfa5e7467529f2b571e4f6f5be942902dfc
parent52c7f0902468c00e6b2f6bfd4882dd132558a7cb (diff)
downloadlasso-4e43c605c28a713ca3d7b4a55ea1b118dc67d43d.tar.gz
lasso-4e43c605c28a713ca3d7b4a55ea1b118dc67d43d.tar.xz
lasso-4e43c605c28a713ca3d7b4a55ea1b118dc67d43d.zip
[project @ fpeters@0d.be-20080309152828-pw4gd3lcm7rb7dxd]
merging benjamin branch Original author: Frederic Peters <fpeters@0d.be> Date: 2008-03-09 16:28:28.854000+01:00
-rw-r--r--bindings/java/GObject.java3
-rw-r--r--bindings/java/Makefile.am6
-rw-r--r--bindings/java/tests/BindingTests.java20
-rw-r--r--bindings/java/tests/LoginTest.java26
-rw-r--r--bindings/lang_java.py6
-rw-r--r--bindings/lang_java_wrapper_top.c90
-rw-r--r--bindings/lang_php5_helpers/php_code.py9
-rw-r--r--bindings/overrides.xml6
-rw-r--r--bindings/php5/Makefile.am2
-rw-r--r--bindings/python/Makefile.am2
10 files changed, 124 insertions, 46 deletions
diff --git a/bindings/java/GObject.java b/bindings/java/GObject.java
index a7815a72..8a1664fa 100644
--- a/bindings/java/GObject.java
+++ b/bindings/java/GObject.java
@@ -5,6 +5,9 @@ class GObject {
private long cptr;
protected GObject(long ptr) {
+ if (ptr == 0) {
+ throw new RuntimeException("Error creating " + getClass().getName());
+ }
cptr = ptr;
}
protected Map arrayToMap(Object[] arr) {
diff --git a/bindings/java/Makefile.am b/bindings/java/Makefile.am
index 9f7f613d..be5990a4 100644
--- a/bindings/java/Makefile.am
+++ b/bindings/java/Makefile.am
@@ -19,7 +19,7 @@ lasso_jar_class_files = $(java_lasso_source_files:.java=.class)
JAVAH=gcjh
$(lasso_jar_class_files): %.class: %.java
- $(JAVAC) -C -classpath . -d . $<
+ $(JAVAC) -ftarget=1.4 -C -classpath . -d . $<
all_jar_class_files = $(shell find com/entrouvert/lasso -name '*.class' | sed 's%\$$%\\$$%g')
@@ -38,7 +38,7 @@ doc:
com_entrouvert_lasso_LassoJNI.h: $(lasso_jar_class_files)
$(JAVAH) -jni -d . --classpath=. com.entrouvert.lasso.LassoJNI
-libjnilasso_la_CFLAGS = $(LASSO_CORE_CFLAGS) -I$(top_srcdir) -I$(top_builddir)
+libjnilasso_la_CFLAGS = -fno-strict-aliasing $(LASSO_CORE_CFLAGS) -I$(top_srcdir) -I$(top_builddir)
libjnilasso_la_LDFLAGS = -export-dynamic -prefer-pic -module -avoid-version
libjnilasso_la_LIBADD = $(top_builddir)/lasso/liblasso.la $(LASSO_LIBS)
nodist_libjnilasso_la_SOURCES = com_entrouvert_lasso_LassoJNI.c
@@ -46,7 +46,7 @@ nodist_libjnilasso_la_SOURCES = com_entrouvert_lasso_LassoJNI.c
BUILT_SOURCES = com_entrouvert_lasso_LassoJNI.c com_entrouvert_lasso_LassoJNI.h
$(java_lasso_source_files) com_entrouvert_lasso_LassoJNI.c: ../lang_java_wrapper_top.c ../lang_java.py
- $(PYTHON) $(top_srcdir)/bindings/bindings.py -l java --src-dir=$(top_srcdir)/lasso/
+ $(PYTHON) $(top_srcdir)/bindings/bindings.py --enable-exception-docs -l java --src-dir=$(top_srcdir)/lasso/
cp $(srcdir)/GObject.java com/entrouvert/lasso
diff --git a/bindings/java/tests/BindingTests.java b/bindings/java/tests/BindingTests.java
index 10b08f2b..9d2fcd99 100644
--- a/bindings/java/tests/BindingTests.java
+++ b/bindings/java/tests/BindingTests.java
@@ -4,7 +4,7 @@
* Java unit tests for Lasso library
*
* Copyright (C) 2004-2007 Entr'ouvert
- * http://LassoConstants.LASSO_entrouvert.org
+ * http://lasso.entrouvert.org
*
* Authors: See AUTHORS file in top-level directory.
*
@@ -23,16 +23,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-// To run it:
-// $ export LD_LIBRARY_PATH=../
-// $ javac -classpath /usr/share/java/junit.jar:../LassoConstants.LASSO_jar:. BindingTests.java
-// $ java -classpath /usr/share/java/junit.jar:../LassoConstants.LASSO_jar:. BindingTests
-// or for gcj:
-// $ export LD_LIBRARY_PATH=../
-// $ gcj -C -classpath /usr/share/java/junit.jar:../LassoConstants.LASSO_jar:. BindingTests.java
-// $ gij -classpath /usr/share/java/junit.jar:../LassoConstants.LASSO_jar:. BindingTests
-
-
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -65,8 +55,8 @@ public class BindingTests extends TestCase {
// Test a string attribute.
assertNull(authnRequest.getConsent());
- authnRequest.setConsent(LassoConstants.LASSO_LIB_CONSENT_OBTAINED);
- assertEquals(authnRequest.getConsent(), LassoConstants.LASSO_LIB_CONSENT_OBTAINED);
+ authnRequest.setConsent(LassoConstants.LIB_CONSENT_OBTAINED);
+ assertEquals(authnRequest.getConsent(), LassoConstants.LIB_CONSENT_OBTAINED);
authnRequest.setConsent(null);
assertNull(authnRequest.getConsent());
@@ -249,8 +239,8 @@ public class BindingTests extends TestCase {
assertNull(login.getRequest());
login.setRequest((SamlpRequestAbstract) new LibAuthnRequest());
- ((LibAuthnRequest) login.getRequest()).setConsent(LassoConstants.LASSO_LIB_CONSENT_OBTAINED);
- assertEquals(((LibAuthnRequest) login.getRequest()).getConsent(), LassoConstants.LASSO_LIB_CONSENT_OBTAINED);
+ ((LibAuthnRequest) login.getRequest()).setConsent(LassoConstants.LIB_CONSENT_OBTAINED);
+ assertEquals(((LibAuthnRequest) login.getRequest()).getConsent(), LassoConstants.LIB_CONSENT_OBTAINED);
login.setRequest(null);
assertNull(login.getRequest());
diff --git a/bindings/java/tests/LoginTest.java b/bindings/java/tests/LoginTest.java
index a961415a..5f9286a4 100644
--- a/bindings/java/tests/LoginTest.java
+++ b/bindings/java/tests/LoginTest.java
@@ -47,7 +47,7 @@ public class LoginTest extends TestCase {
null,
"../../../tests/data/idp1-la/certificate.pem");
server.addProvider(
- LassoConstants.LASSO_PROVIDER_ROLE_SP,
+ LassoConstants.PROVIDER_ROLE_SP,
"../../../tests/data/sp1-la/metadata.xml",
"../../../tests/data/sp1-la/public-key.pem",
"../../../tests/data/ca1-la/certificate.pem");
@@ -62,7 +62,7 @@ public class LoginTest extends TestCase {
null,
"../../../tests/data/sp1-la/certificate.pem");
server.addProvider(
- LassoConstants.LASSO_PROVIDER_ROLE_IDP,
+ LassoConstants.PROVIDER_ROLE_IDP,
"../../../tests/data/idp1-la/metadata.xml",
"../../../tests/data/idp1-la/public-key.pem",
"../../../tests/data/ca1-la/certificate.pem");
@@ -97,11 +97,11 @@ public class LoginTest extends TestCase {
assertNotNull(spDump);
sp = Server.newFromDump(spDump);
spLogin = new Login(sp);
- spLogin.initAuthnRequest("https://idp1/metadata", LassoConstants.LASSO_HTTP_METHOD_REDIRECT);
+ spLogin.initAuthnRequest("https://idp1/metadata", LassoConstants.HTTP_METHOD_REDIRECT);
authnRequest = (LibAuthnRequest) spLogin.getRequest();
authnRequest.setIsPassive(false);
- authnRequest.setNameIdPolicy(LassoConstants.LASSO_LIB_NAMEID_POLICY_TYPE_FEDERATED);
- authnRequest.setConsent(LassoConstants.LASSO_LIB_CONSENT_OBTAINED);
+ authnRequest.setNameIdPolicy(LassoConstants.LIB_NAMEID_POLICY_TYPE_FEDERATED);
+ authnRequest.setConsent(LassoConstants.LIB_CONSENT_OBTAINED);
relayState = "fake";
authnRequest.setRelayState(relayState);
spLogin.buildAuthnRequestMsg();
@@ -120,15 +120,15 @@ public class LoginTest extends TestCase {
userAuthenticated = true;
userConsentObtained = false;
idpLogin.validateRequestMsg(userAuthenticated, userConsentObtained);
- authenticationMethod = LassoConstants.LASSO_SAML_AUTHENTICATION_METHOD_PASSWORD;
+ authenticationMethod = LassoConstants.SAML_AUTHENTICATION_METHOD_PASSWORD;
idpLogin.buildAssertion(
authenticationMethod,
null, // authenticationInstant
null, // reauthenticateOnOrAfter
null, // notBefore
null);// notOnOrAfter
- assertEquals(LassoConstants.LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_ART, idpLogin.getProtocolProfile());
- idpLogin.buildArtifactMsg(LassoConstants.LASSO_HTTP_METHOD_REDIRECT);
+ assertEquals(LassoConstants.LOGIN_PROTOCOL_PROFILE_BRWS_ART, idpLogin.getProtocolProfile());
+ idpLogin.buildArtifactMsg(LassoConstants.HTTP_METHOD_REDIRECT);
idpIdentityDump = idpLogin.getIdentity().dump();
assertNotNull(idpIdentityDump);
idpSessionDump = idpLogin.getSession().dump();
@@ -139,7 +139,7 @@ public class LoginTest extends TestCase {
nameIdentifier = ((SamlNameIdentifier)idpLogin.getNameIdentifier()).getContent();
artifact = idpLogin.getAssertionArtifact();
assertNotNull(artifact);
- method = LassoConstants.LASSO_HTTP_METHOD_REDIRECT;
+ method = LassoConstants.HTTP_METHOD_REDIRECT;
// Service provider assertion consumer.
spDump = generateServiceProviderDump();
@@ -156,7 +156,7 @@ public class LoginTest extends TestCase {
// Identity provider SOAP endpoint.
requestType = LassoJNI.lasso_get_request_type_from_soap_msg(soapRequestMsg);
- assertEquals(LassoConstants.LASSO_REQUEST_TYPE_LOGIN, requestType);
+ assertEquals(LassoConstants.REQUEST_TYPE_LOGIN, requestType);
idpDump = generateIdentityProviderDump();
assertNotNull(idpDump);
idp = Server.newFromDump(idpDump);
@@ -184,7 +184,7 @@ public class LoginTest extends TestCase {
assertNotNull(spSessionDump);
assertion = (SamlAssertion) spSession.getAssertions("https://idp1/metadata").get(0);
authenticationMethod = assertion.getAuthenticationStatement().getAuthenticationMethod();
- assertEquals(LassoConstants.LASSO_SAML_AUTHENTICATION_METHOD_PASSWORD, authenticationMethod);
+ assertEquals(LassoConstants.SAML_AUTHENTICATION_METHOD_PASSWORD, authenticationMethod);
// Service provider logout.
spDump = generateServiceProviderDump();
@@ -196,14 +196,14 @@ public class LoginTest extends TestCase {
spLogout.setIdentityFromDump(spIdentityDump);
assertNotNull(spSessionDump);
spLogout.setSessionFromDump(spSessionDump);
- spLogout.initRequest(null, LassoConstants.LASSO_HTTP_METHOD_ANY);
+ spLogout.initRequest(null, LassoConstants.HTTP_METHOD_ANY);
spLogout.buildRequestMsg();
soapEndpoint = spLogout.getMsgUrl();
soapRequestMsg = spLogout.getMsgBody();
// Identity provider SOAP endpoint.
requestType = LassoJNI.lasso_get_request_type_from_soap_msg(soapRequestMsg);
- assertEquals(LassoConstants.LASSO_REQUEST_TYPE_LOGOUT, requestType);
+ assertEquals(LassoConstants.REQUEST_TYPE_LOGOUT, requestType);
idpDump = generateIdentityProviderDump();
assertNotNull(idpDump);
idp = Server.newFromDump(idpDump);
diff --git a/bindings/lang_java.py b/bindings/lang_java.py
index 026a9e43..4686eb35 100644
--- a/bindings/lang_java.py
+++ b/bindings/lang_java.py
@@ -170,7 +170,7 @@ public abstract interface LassoConstants {
print >> fd, 'String ',
elif c[0] == 'b':
print >> fd, 'boolean ',
- print >> fd, '%s = LassoJNI.%s_get();' % (c[1], c[1])
+ print >> fd, '%s = LassoJNI.%s_get();' % (c[1][6:], c[1])
def generate_Constants_footer(self, fd):
print >> fd, '}'
@@ -651,7 +651,7 @@ protected static native void destroy(long cptr);
#
def generate_exception_switch_case(self, fd, name, orig):
- print >> fd, ' if (errorCode == LassoConstants.%s) {' % orig
+ print >> fd, ' if (errorCode == LassoConstants.%s) {' % orig[6:]
print >> fd, ' throw new %s(errorCode);' % name
print >> fd, ' }'
@@ -698,7 +698,7 @@ protected static native void destroy(long cptr);
print >> fd, 'public class %s extends %s {' % (name,super)
if not abstract:
print >> fd, ' public %s() {' % name
- print >> fd, ' super(LassoConstants.%s);' % orig
+ print >> fd, ' super(LassoConstants.%s);' % orig[6:]
print >> fd, ' }'
print >> fd, ' protected %s(int errorCode) {' % name
print >> fd, ' super(errorCode);'
diff --git a/bindings/lang_java_wrapper_top.c b/bindings/lang_java_wrapper_top.c
index 0e618652..18d48907 100644
--- a/bindings/lang_java_wrapper_top.c
+++ b/bindings/lang_java_wrapper_top.c
@@ -76,6 +76,82 @@ static int get_hash_by_name(JNIEnv *env, GHashTable *hashtable, jstring jkey, Co
//#define get_hash_of_objects_by_name(end,hash,key) get_hash_by_name(end,hash,key,(Converter)gobject_to_jobject_and_ref)
/* Helper functions to access JNI interface functions */
+#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 12)
+void
+g_hash_table_remove_all (GHashTable *hash_table)
+{
+ g_return_if_fail (hash_table != NULL);
+
+#ifndef G_DISABLE_ASSERT
+ if (hash_table->nnodes != 0)
+ hash_table->version++;
+#endif
+
+ g_hash_table_remove_all_nodes (hash_table, TRUE);
+ g_hash_table_maybe_resize (hash_table);
+}
+#endif
+#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 14)
+ /* copy of private struct and g_hash_table_get_keys from GLib internals
+ * (as this function is useful but new in 2.14) */
+
+typedef struct _GHashNode GHashNode;
+
+struct _GHashNode
+{
+ gpointer key;
+ gpointer value;
+ GHashNode *next;
+ guint key_hash;
+};
+
+struct _GHashTable
+{
+ gint size;
+ gint nnodes;
+ GHashNode **nodes;
+ GHashFunc hash_func;
+ GEqualFunc key_equal_func;
+ volatile gint ref_count;
+ GDestroyNotify key_destroy_func;
+ GDestroyNotify value_destroy_func;
+};
+
+static GList *
+g_hash_table_get_keys (GHashTable *hash_table)
+{
+ GHashNode *node;
+ gint i;
+ GList *retval;
+
+ g_return_val_if_fail (hash_table != NULL, NULL);
+
+ retval = NULL;
+ for (i = 0; i < hash_table->size; i++)
+ for (node = hash_table->nodes[i]; node; node = node->next)
+ retval = g_list_prepend (retval, node->key);
+
+ return retval;
+}
+
+GList *
+g_hash_table_get_values (GHashTable *hash_table)
+{
+ GHashNode *node;
+ gint i;
+ GList *retval;
+
+ g_return_val_if_fail (hash_table != NULL, NULL);
+
+ retval = NULL;
+ for (i = 0; i < hash_table->size; i++)
+ for (node = hash_table->nodes[i]; node; node = node->next)
+ retval = g_list_prepend (retval, node->value);
+
+ return retval;
+}
+#endif
+
static int
gpointer_equal(gpointer p1, gpointer p2) {
return p1 != p2;
@@ -87,9 +163,9 @@ new_object_with_gobject(JNIEnv *env, GObject *obj, char *clsName, jobject *jobj)
g_error_if_fail(env && clsName && obj && G_IS_OBJECT(obj));
- g_return_val_if_fail(cls = (*env)->FindClass(env, clsName), 0);
- g_return_val_if_fail(mid = (*env)->GetMethodID(env, cls, "<init>", "(J)V"), 0);
- g_return_val_if_fail(*jobj = (*env)->NewObject(env, cls, mid, PTR_TO_JLONG(obj)), 0);
+ g_return_val_if_fail((cls = (*env)->FindClass(env, clsName)), 0);
+ g_return_val_if_fail((mid = (*env)->GetMethodID(env, cls, "<init>", "(J)V")), 0);
+ g_return_val_if_fail((*jobj = (*env)->NewObject(env, cls, mid, PTR_TO_JLONG(obj))), 0);
return 1;
}
/** Convert a java string to a jstring */
@@ -251,7 +327,6 @@ string_to_jstring_and_free(JNIEnv *env, char* str, jstring *jstr) {
static int
jstring_to_string(JNIEnv *env, jstring jstr, char **str) {
const char *local_str;
- char * ret;
g_return_val_if_fail(jstring_to_local_string(env, jstr, &local_str), 0);
if (local_str) {
@@ -285,7 +360,7 @@ xml_node_to_jstring(JNIEnv *env, xmlNode *xmlnode, jstring *jstr) {
int ret = 1;
xmlNodeDumpOutput(buf, NULL, xmlnode, 0, 1, NULL);
xmlOutputBufferFlush(buf);
- char *str;
+ xmlChar *str;
if (buf->conv == NULL) {
str = (char*)buf->buffer->content;
} else {
@@ -351,7 +426,6 @@ create_class_name(char *dest, const char *typename) {
* Throws if obj is not a GObject or if anyhting fail. */
static int
gobject_to_jobject_aux(JNIEnv *env, GObject *obj, gboolean doRef, jobject *jobj) {
- jweak weakRef = NULL;
jobject self = NULL;
int ret = 1;
@@ -574,7 +648,6 @@ static int
get_hash(JNIEnv *env, char *clsName, GHashTable *hashtable, Converter convert, jobjectArray *jarr)
{
jsize l,i;
- jclass cls;
GList *keys = NULL, *values = NULL;
int ret = 1;
@@ -639,7 +712,8 @@ set_hash_of_objects(JNIEnv *env, GHashTable *hashtable, jobjectArray jarr)
g_object_ref(gobj);
}
}
- /** Remove old values, if hashtable is well initialized it should unref objects automatically. */
+ /** Remove old values, if hashtable is well initialized
+ * it should unref objects automatically. */
g_hashtable_remove_all(hashtable);
/** Insert new values */
if (jarr) {
diff --git a/bindings/lang_php5_helpers/php_code.py b/bindings/lang_php5_helpers/php_code.py
index 41db50ba..583172d1 100644
--- a/bindings/lang_php5_helpers/php_code.py
+++ b/bindings/lang_php5_helpers/php_code.py
@@ -284,7 +284,12 @@ function cptrToPhp ($cptr) {
print >> sys.stderr, 'W:', m.name, 'vs', method_prefix
continue
- mname = m.name[len(method_prefix):]
+ if m.rename:
+ mname = m.rename
+ else:
+ mname = m.name
+ cname = mname
+ mname = mname[len(method_prefix):]
php_args = []
c_args = []
for arg in m.args[1:]:
@@ -323,7 +328,7 @@ function cptrToPhp ($cptr) {
print >> self.fd, ' public function %s(%s) {' % (
utils.format_underscore_as_camelcase(mname), php_args)
if m.return_type == 'void':
- print >> self.fd, ' %s($this->_cptr%s);' % (m.name, c_args)
+ print >> self.fd, ' %s($this->_cptr%s);' % (cname, c_args)
elif m.return_type in ('gint', 'int'):
print >> self.fd, ' $rc = %s($this->_cptr%s);' % (m.name, c_args)
print >> self.fd, ' if ($rc == 0) {'
diff --git a/bindings/overrides.xml b/bindings/overrides.xml
index 72895939..fc47a13d 100644
--- a/bindings/overrides.xml
+++ b/bindings/overrides.xml
@@ -74,6 +74,12 @@
<param name="remote_providerID" optional="true"/>
<param name="http_method" optional="true" default="c:LASSO_HTTP_METHOD_ANY"/>
</func>
+ <!-- LassoNameIdManagement -->
+ <func name="lasso_name_id_management_init_request">
+ <param name="remote_provider_id" optional="true"/>
+ <param name="new_name_id" optional="true"/>
+ <param name="http_method" optional="true" default="c:LASSO_HTTP_METHOD_ANY"/>
+ </func>
<!-- LassoNameIdentifier -->
<func name="lasso_name_identifier_mapping_init_request">
<param name="remote_providerID" optional="true" />
diff --git a/bindings/php5/Makefile.am b/bindings/php5/Makefile.am
index 65d1fdf2..c9e399b8 100644
--- a/bindings/php5/Makefile.am
+++ b/bindings/php5/Makefile.am
@@ -8,7 +8,7 @@ php_extensiondir = ${prefix}@PHP5_UNPREFIXED_EXTENSION_DIR@
nodist_php_extension_DATA = lasso.php
-lasso_la_CFLAGS = $(LASSO_CORE_CFLAGS) -I$(top_srcdir) -I$(top_builddir) $(PHP5_INCLUDES)
+lasso_la_CFLAGS = -fno-strict-aliasing $(LASSO_CORE_CFLAGS) -I$(top_srcdir) -I$(top_builddir) $(PHP5_INCLUDES)
lasso_la_LDFLAGS = -export-dynamic -prefer-pic -module -avoid-version
lasso_la_LIBADD = $(top_builddir)/lasso/liblasso.la $(LASSO_LIBS) $(PHP5_LDFLAGS)
nodist_lasso_la_SOURCES = _lasso.c
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
index bb2c6eaf..65b4be55 100644
--- a/bindings/python/Makefile.am
+++ b/bindings/python/Makefile.am
@@ -10,7 +10,7 @@ nodist_python_DATA = lasso.py
python_LTLIBRARIES = _lasso.la
nodist__lasso_la_SOURCES = _lasso.c
-_lasso_la_CFLAGS = $(LASSO_CORE_CFLAGS) -DSWIG_COBJECT_TYPES $(PY_CFLAGS)
+_lasso_la_CFLAGS = -fno-strict-aliasing $(LASSO_CORE_CFLAGS) $(PY_CFLAGS)
_lasso_la_LIBADD = $(top_builddir)/lasso/liblasso.la $(LASSO_LIBS)
if DARWIN
_lasso_la_LDFLAGS = -no-undefined -module -avoid-version -Wl,-F. -Wl,-F. -bundle -framework Python