summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2008-04-29 12:06:25 +0000
committerFrederic Peters <fpeters@entrouvert.com>2008-04-29 12:06:25 +0000
commit34e4fd0b5aae872344a16267efac847f45108ca7 (patch)
tree904ed6027947636f41f52c6a04ae33507509711e
parent073b0504389253893c636f40047eb4e0531cec34 (diff)
downloadlasso-34e4fd0b5aae872344a16267efac847f45108ca7.tar.gz
lasso-34e4fd0b5aae872344a16267efac847f45108ca7.tar.xz
lasso-34e4fd0b5aae872344a16267efac847f45108ca7.zip
[project @ fpeters@0d.be-20080118215410-d45drghkhvba7822]
merged Damien branch; and fixed PHP5 binding to use GLib memory management functions Original author: Frederic Peters <fpeters@0d.be> Date: 2008-01-18 22:54:10.239000+01:00
-rw-r--r--bindings/lang_php5_helpers/wrapper_source.py4
-rw-r--r--bindings/lang_php5_helpers/wrapper_source_top.c2
-rw-r--r--bindings/php5/examples/get_attributes_from_assertion.php11
-rwxr-xr-xbindings/php5/tests/binding_tests.php82
-rw-r--r--bindings/python/examples/get_attributes_from_assertion.py8
5 files changed, 102 insertions, 5 deletions
diff --git a/bindings/lang_php5_helpers/wrapper_source.py b/bindings/lang_php5_helpers/wrapper_source.py
index 1dfef51a..c6a348a9 100644
--- a/bindings/lang_php5_helpers/wrapper_source.py
+++ b/bindings/lang_php5_helpers/wrapper_source.py
@@ -343,13 +343,13 @@ PHP_MSHUTDOWN_FUNCTION(lasso)
print >> self.fd, ' this->%s = %s;' % (m_name, m_name)
elif parse_tuple_format == 's':
print >> self.fd, ' if (this->%s) {' % m_name
- print >> self.fd, ' efree(this->%s);' % m_name
+ print >> self.fd, ' g_free(this->%s);' % m_name
print >> self.fd, ' }'
print >> self.fd, ' if (%s_str && strcmp(%s_str, "") != 0) {' % (m_name, m_name)
if arg_type == 'xmlNode*':
print >> self.fd, ' this->%s = get_xml_node_from_string(%s_str);' % (m_name, m_name)
else:
- print >> self.fd, ' this->%s = estrndup(%s_str, %s_len);' % (m_name, m_name, m_name)
+ print >> self.fd, ' this->%s = g_strndup(%s_str, %s_len);' % (m_name, m_name, m_name)
print >> self.fd, ' } else {'
print >> self.fd, ' this->%s = NULL;' % m_name
print >> self.fd, ' }'
diff --git a/bindings/lang_php5_helpers/wrapper_source_top.c b/bindings/lang_php5_helpers/wrapper_source_top.c
index 9181f3c0..877d4b7d 100644
--- a/bindings/lang_php5_helpers/wrapper_source_top.c
+++ b/bindings/lang_php5_helpers/wrapper_source_top.c
@@ -159,7 +159,7 @@ get_list_from_array_of_strings(zval* array)
temp = **data;
zval_copy_ctor(&temp);
convert_to_string(&temp);
- result = g_list_append(result, estrndup(Z_STRVAL(temp), Z_STRLEN(temp)));
+ result = g_list_append(result, g_strndup(Z_STRVAL(temp), Z_STRLEN(temp)));
zval_dtor(&temp);
}
return result;
diff --git a/bindings/php5/examples/get_attributes_from_assertion.php b/bindings/php5/examples/get_attributes_from_assertion.php
new file mode 100644
index 00000000..3ac48159
--- /dev/null
+++ b/bindings/php5/examples/get_attributes_from_assertion.php
@@ -0,0 +1,11 @@
+/* Example SP PHP5 code to get attributes from an assertion */
+
+foreach ($assertion->attributeStatement[0]->attribute as $attribute) {
+ if ($attribute->name == LASSO_SAML2_ATTRIBUTE_NAME_EPR) {
+ continue;
+ }
+ echo 'attribute : ' . $attribute->name . "\n";
+ foreach ($attribute->attributeValue as $value) {
+ echo ' value : ' . $value->any[0]->content . "\n";
+ }
+}
diff --git a/bindings/php5/tests/binding_tests.php b/bindings/php5/tests/binding_tests.php
index d22440ff..d4614154 100755
--- a/bindings/php5/tests/binding_tests.php
+++ b/bindings/php5/tests/binding_tests.php
@@ -56,7 +56,7 @@ function test02() {
}
function test03() {
- echo "Get and set a list of xmlNode*...";
+ echo "Get and set a list of xmlNode*... ";
$server = new LassoServer(
DATA_DIR . "sp1-la/metadata.xml",
@@ -87,7 +87,7 @@ function test03() {
}
function test04() {
- echo "Get and set a list of Lasso objects...";
+ echo "Get and set a list of Lasso objects... ";
$response = new LassoSamlpResponse();
assert(!$response->assertion);
@@ -139,6 +139,83 @@ function test05() {
echo "OK.\n";
}
+function test06() {
+ echo "Get and set SAML 2.0 assertion attribute values... ";
+
+ $attribute1_name = "first attribute";
+ $attribute1_string = "first string";
+ $attribute2_name = "second attribute";
+ $attribute2_string = "second string";
+ $attribute3_string = "third string";
+
+ $expected_assertion_dump = '<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" SignType="0" SignMethod="0" EncryptionActivated="false" EncryptionSymKeyType="0">
+ <saml:AttributeStatement>
+ <saml:Attribute Name="first attribute">
+ <saml:AttributeValue>
+ <XXX>first string</XXX>
+ </saml:AttributeValue>
+ </saml:Attribute>
+ <saml:Attribute Name="second attribute">
+ <saml:AttributeValue>
+ <XXX>second string</XXX>
+ </saml:AttributeValue>
+ <saml:AttributeValue>
+ <XXX>third string</XXX>
+ </saml:AttributeValue>
+ </saml:Attribute>
+ </saml:AttributeStatement>
+</saml:Assertion>';
+
+ $text_node1 = new LassoMiscTextNode();
+ $text_node1->content = $attribute1_string;
+ $any1 = array();
+ $any1[] = $text_node1;
+ $attribute_value1 = new LassoSaml2AttributeValue();
+ $attribute_value1->any = $any1;
+ $attribute_values1 = array();
+ $attribute_values1[] = $attribute_value1;
+ $attribute1 = new LassoSaml2Attribute();
+ $attribute1->name = $attribute1_name;
+ $attribute1->attributeValue = $attribute_values1;
+
+ $text_node2 = new LassoMiscTextNode();
+ $text_node2->content = $attribute2_string;
+ $any2 = array();
+ $any2[] = $text_node2;
+ $attribute_value2 = new LassoSaml2AttributeValue();
+ $attribute_value2->any = $any2;
+
+ $text_node3 = new LassoMiscTextNode();
+ $text_node3->content = $attribute3_string;
+ $any3 = array();
+ $any3[] = $text_node3;
+ $attribute_value3 = new LassoSaml2AttributeValue();
+ $attribute_value3->any = $any3;
+
+ $attribute_values2 = array();
+ $attribute_values2[] = $attribute_value2;
+ $attribute_values2[] = $attribute_value3;
+
+ $attribute2 = new LassoSaml2Attribute();
+ $attribute2->name = $attribute2_name;
+ $attribute2->attributeValue = $attribute_values2;
+
+ $attributes = array();
+ $attributes[] = $attribute1;
+ $attributes[] = $attribute2;
+
+ $attributeStatement = new LassoSaml2AttributeStatement();
+ $attributeStatement->attribute = $attributes;
+ $attributeStatements = array();
+ $attributeStatements[] = $attributeStatement;
+
+ $assertion = new LassoSaml2Assertion();
+ $assertion->attributeStatement = $attributeStatements;
+
+ assert($assertion->dump() == $expected_assertion_dump);
+
+ echo "OK.\n";
+}
lasso_init();
test01();
@@ -146,5 +223,6 @@ test02();
test03();
test04();
//test05();
+test06();
lasso_shutdown();
diff --git a/bindings/python/examples/get_attributes_from_assertion.py b/bindings/python/examples/get_attributes_from_assertion.py
new file mode 100644
index 00000000..44ceb9e5
--- /dev/null
+++ b/bindings/python/examples/get_attributes_from_assertion.py
@@ -0,0 +1,8 @@
+# Example SP Python code to get attributes from an assertion
+
+for attribute in assertion.attributeStatement[0].attribute:
+ if attribute.name == lasso.SAML2_ATTRIBUTE_NAME_EPR:
+ continue
+ print 'attribute : ' + attribute.name
+ for value in attribute.attributeValue:
+ print ' value : ' + value.any[0].content