You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rampart-dev@ws.apache.org by du...@apache.org on 2007/10/10 14:40:30 UTC
svn commit: r583456 [2/3] - in /webservices/rampart/scratch/c/saml:
include/SAML.h include/saml_req.h src/assertion.c src/attr_stmt.c
src/auth_des_stmt.c src/auth_smt.c src/condition.c src/id_type.c
src/saml_request.c src/saml_responce.c src/subject.c
Modified: webservices/rampart/scratch/c/saml/src/auth_des_stmt.c
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/saml/src/auth_des_stmt.c?rev=583456&r1=583455&r2=583456&view=diff
==============================================================================
--- webservices/rampart/scratch/c/saml/src/auth_des_stmt.c (original)
+++ webservices/rampart/scratch/c/saml/src/auth_des_stmt.c Wed Oct 10 05:40:28 2007
@@ -1,353 +1,353 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "SAML.h"
-
-
-AXIS2_EXTERN int AXIS2_CALL saml_action_init(saml_action_t *action, axutil_env_t *env)
-{
- action->data = NULL;
- action->name_space = NULL;
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN int AXIS2_CALL saml_action_uninit(saml_action_t *action, axutil_env_t *env)
-{
- if (action->data)
- {
- AXIS2_FREE(env->allocator, action->data);
- }
- if (action->name_space)
- {
- AXIS2_FREE(env->allocator, action->name_space);
- }
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN int AXIS2_CALL saml_action_build(saml_action_t *action, axiom_node_t *node, axutil_env_t *env)
-{
- axiom_element_t *element = NULL;
- if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
- {
- return AXIS2_FAILURE;
- }
- action->name_space = axiom_element_get_attribute_value_by_name(element, env, SAML_NAMESPACE);
- if ((action->data = axiom_element_get_text(element, env, node)) == NULL)
- {
- return AXIS2_FALSE;
- }
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_action_to_om(saml_action_t *action, axiom_node_t *parent, axutil_env_t *env)
-{
- axiom_element_t *e = NULL;
- axiom_node_t *n = NULL;
- axiom_namespace_t *ns = NULL;
- axiom_attribute_t *attr = NULL;
- ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
- e = axiom_element_create(env, parent, SAML_ACTION, ns, &n);
- if (e)
- {
- if (action->name_space)
- {
- attr = axiom_attribute_create(env, SAML_NAMESPACE, action->name_space, NULL);
- axiom_element_add_attribute(e, env, attr, n);
- }
- if (action->data)
- {
- axiom_element_set_text(e, env, action->data, n);
- }
- else
- {
- return NULL;
- }
- }
- return n;
-}
-
-AXIS2_EXTERN saml_evidence_t * AXIS2_CALL saml_evidence_create(axutil_env_t *env)
-{
- saml_evidence_t *evidence = (saml_evidence_t *)AXIS2_MALLOC(env->allocator, sizeof(saml_evidence_t));
- if (evidence)
- {
- evidence->assertion_ids = axutil_array_list_create(env, SAML_ARRAY_LIST_DEF);
- evidence->assertions = axutil_array_list_create(env, SAML_ARRAY_LIST_DEF);
- }
- return evidence;
-}
-
-AXIS2_EXTERN void AXIS2_CALL saml_evidence_free(saml_evidence_t *evidence, axutil_env_t *env)
-{
- int i = 0, size = 0;
- char *val = NULL;
- saml_assertion_t *assertion = NULL;
-
- if (evidence->assertion_ids)
- {
- size = axutil_array_list_size(evidence->assertion_ids, env);
- for (i = 0; i < size; i++)
- {
- val = axutil_array_list_get(evidence->assertion_ids, env, i);
- if (val)
- {
- AXIS2_FREE(env->allocator, val);
- }
- }
- }
- if (evidence->assertions)
- {
- size = axutil_array_list_size(evidence->assertions, env);
- for (i = 0; i < size; i++)
- {
- assertion = axutil_array_list_get(evidence->assertions, env, i);
- if (assertion)
- {
- saml_assertion_uninit(assertion, env);
- AXIS2_FREE(env->allocator, assertion);
- }
- }
- }
-}
-
-AXIS2_EXTERN int AXIS2_CALL saml_evidence_build(saml_evidence_t *evidence, axiom_node_t *node, axutil_env_t *env)
-{
- axiom_element_t *element = NULL;
- axiom_element_t *fce = NULL;
- axiom_node_t *fcn = NULL;
- axiom_child_element_iterator_t *ci = NULL;
- saml_assertion_t *assertion = NULL;
- if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
- {
- return AXIS2_FAILURE;
- }
- ci = axiom_element_get_child_elements(element, env, node);
- if (ci)
- {
- while(AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
- {
- fcn = axiom_child_element_iterator_next(ci, env);
- fce = axiom_node_get_data_element(fcn, env);
- if (strcmp(axiom_element_get_localname(fce, env), SAML_ASSERTIONIDREFERENCE) == 0)
- {
- axutil_array_list_add(evidence->assertion_ids, env, axiom_element_get_text(fce, env, fcn));
- }
- else if (strcmp(axiom_element_get_localname(fce, env), SAML_ASSERTION) == 0)
- {
- assertion = AXIS2_MALLOC(env->allocator, sizeof(saml_assertion_t));
- saml_assertion_build(assertion, fcn, env);
- axutil_array_list_add(evidence->assertions, env, assertion);
- }
- else
- {
- return AXIS2_FAILURE;
- }
- }
- }
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_evidence_to_om(saml_evidence_t *evidence, axiom_node_t *parent, axutil_env_t *env)
-{
- int size = 0, i = 0;
- axiom_element_t *e = NULL, *ce = NULL;
- axiom_node_t *n = NULL, *cn = NULL;
- axiom_namespace_t *ns = NULL;
- axiom_attribute_t *attr = NULL;
- saml_assertion_t *assertion = NULL;
- ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
- e = axiom_element_create(env, parent, SAML_EVIDENCE, ns, &n);
- if (e)
- {
- if (evidence->assertion_ids)
- {
- size = axutil_array_list_size(evidence->assertion_ids, env);
- for (i = 0; i < size; i++)
- {
- ce = axiom_element_create(env, n, SAML_ASSERTIONIDREFERENCE, ns, &n);
- axiom_element_set_text(ce, env, axutil_array_list_get(evidence->assertion_ids, env, i), cn);
- }
- }
- if (evidence->assertions)
- {
- size = axutil_array_list_size(evidence->assertions, env);
- for (i = 0; i < size; i++)
- {
- assertion = axutil_array_list_get(evidence->assertions, env, i);
- saml_assertion_to_om(assertion, n, env);
- }
- }
- }
- return n;
-}
-
-
-AXIS2_EXTERN saml_auth_desicion_stmt_t * AXIS2_CALL saml_auth_desicion_stmt_create(axutil_env_t *env)
-{
- saml_auth_desicion_stmt_t *auth_des_stmt = AXIS2_MALLOC(env->allocator, sizeof(saml_auth_desicion_stmt_t));
- if (auth_des_stmt)
- {
- auth_des_stmt->decision = NULL;
- auth_des_stmt->resource = NULL;
- auth_des_stmt->evidence = NULL;
- auth_des_stmt->action = axutil_array_list_create(env, SAML_ARRAY_LIST_DEF);
- saml_subject_init(&auth_des_stmt->subject, env);
- }
- return auth_des_stmt;
-}
-
-AXIS2_EXTERN void AXIS2_CALL saml_auth_desicion_stmt_free(saml_auth_desicion_stmt_t *auth_des_stmt, axutil_env_t *env)
-{
- if (auth_des_stmt->decision)
- {
- AXIS2_FREE(env->allocator, auth_des_stmt->decision);
- }
- if (auth_des_stmt->resource)
- {
- AXIS2_FREE(env->allocator, auth_des_stmt->resource);
- }
- if (auth_des_stmt->evidence)
- {
- saml_evidence_free(auth_des_stmt->evidence, env);
- }
- if (auth_des_stmt->action)
- {
- int i = 0;
- saml_action_t *action = NULL;
- for (i = 0; i < axutil_array_list_size(auth_des_stmt->action, env); i++)
- {
- action = axutil_array_list_get(auth_des_stmt->action, env, i);
- if (action)
- {
- saml_action_uninit(action, env);
- }
- }
- axutil_array_list_free(auth_des_stmt->action, env);
- }
- saml_subject_uninit(&auth_des_stmt->subject, env);
- AXIS2_FREE(env->allocator, auth_des_stmt);
-}
-
-AXIS2_EXTERN int AXIS2_CALL saml_auth_desicion_stmt_build(saml_auth_desicion_stmt_t *auth_des_stmt, axiom_node_t *node, axutil_env_t *env)
-{
- axutil_hash_t *attr_hash = NULL;
- axutil_hash_index_t *hi = NULL;
- axiom_element_t *element = NULL;
- axiom_element_t *fce = NULL;
- axiom_node_t *fcn = NULL;
- axiom_child_element_iterator_t *ci = NULL;
- if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
- {
- return AXIS2_FAILURE;
- }
- if ((auth_des_stmt->resource = axiom_element_get_attribute_value_by_name(element, env, SAML_RESOURCE)) == NULL || (auth_des_stmt->decision = axiom_element_get_attribute_value_by_name(element, env, SAML_DECISION)) == NULL)
- {
- return AXIS2_FAILURE;
- }
- attr_hash = axiom_element_get_all_attributes(element, env);
- for (hi = axutil_hash_first(attr_hash, env); hi != NULL; hi = axutil_hash_next(env, hi))
- {
- void *v = NULL;
- axutil_hash_this(hi, NULL, NULL, &v);
- if (v)
- {
- axis2_char_t *attr_val = NULL;
- axiom_attribute_t *attr = (axiom_attribute_t*)v;
- attr_val = axiom_attribute_get_value(attr, env);
- if (0 != axutil_strcmp(attr_val, SAML_RESOURCE) && 0 != axutil_strcmp(attr_val, SAML_DECISION))
- {
- return AXIS2_FALSE;
- }
- }
- }
- ci = axiom_element_get_child_elements(element, env, node);
- if (ci)
- {
- fcn = axiom_child_element_iterator_next(ci, env);
- fce = axiom_node_get_data_element(fcn, env);
- while(AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
- {
- if (strcmp(axiom_element_get_localname(fce, env), SAML_SUBJECTSTATEMENT) == 0)
- {
- saml_subject_build(&auth_des_stmt->subject, fcn, env);
- }
- else if (strcmp(axiom_element_get_localname(fce, env), SAML_ACTION) == 0)
- {
- axutil_array_list_add(auth_des_stmt->action, env, axiom_element_get_text(fce, env, fcn));
- }
- else if (strcmp(axiom_element_get_localname(fce, env), SAML_EVIDENCE) == 0)
- {
- saml_evidence_t *evi = saml_evidence_create(env);
- if (saml_evidence_build(evi, fcn, env))
- {
- auth_des_stmt->evidence = evi;
- }
- else
- {
- return AXIS2_FALSE;
- }
- }
- else
- {
- return AXIS2_FAILURE;
- }
- }
- }
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_auth_desicion_stmt_to_om(saml_auth_desicion_stmt_t *auth_des_stmt, axiom_node_t *parent, axutil_env_t *env)
-{
- int i = 0, size = 0;
- axiom_element_t *e = NULL;
- axiom_node_t *n = NULL;
- axiom_attribute_t *attr = NULL;
- axiom_namespace_t *ns = NULL;
- saml_action_t *action = NULL;
- ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
- e = axiom_element_create(env, parent, SAML_AUTHORIZATIONDECISIONSTATEMENT, ns, &n);
- if (e)
- {
- if (auth_des_stmt->resource && auth_des_stmt->decision)
- {
- attr = axiom_attribute_create(env, SAML_RESOURCE, auth_des_stmt->resource, NULL);
- axiom_element_add_attribute(e, env, attr, n);
- attr = axiom_attribute_create(env, SAML_DECISION, auth_des_stmt->decision, NULL);
- axiom_element_add_attribute(e, env, attr, n);
- }
- else
- {
- axiom_element_free(e, env);
- return NULL;
- }
- saml_subject_to_om(&auth_des_stmt->subject, n, env);
- if (auth_des_stmt->action)
- {
- size = axutil_array_list_size(auth_des_stmt->action, env);
- for (i = 0; i < size; i++)
- {
- action = axutil_array_list_get(auth_des_stmt->action, env, i);
- saml_action_to_om(action, n, env);
- }
- }
- if (auth_des_stmt->evidence)
- {
- saml_evidence_to_om(auth_des_stmt->evidence, n, env);
- }
- }
- return NULL;
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SAML.h"
+
+
+AXIS2_EXTERN int AXIS2_CALL saml_action_init(saml_action_t *action, axutil_env_t *env)
+{
+ action->data = NULL;
+ action->name_space = NULL;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_action_uninit(saml_action_t *action, axutil_env_t *env)
+{
+ if (action->data)
+ {
+ AXIS2_FREE(env->allocator, action->data);
+ }
+ if (action->name_space)
+ {
+ AXIS2_FREE(env->allocator, action->name_space);
+ }
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_action_build(saml_action_t *action, axiom_node_t *node, axutil_env_t *env)
+{
+ axiom_element_t *element = NULL;
+ if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
+ {
+ return AXIS2_FAILURE;
+ }
+ action->name_space = axiom_element_get_attribute_value_by_name(element, env, SAML_NAMESPACE);
+ if ((action->data = axiom_element_get_text(element, env, node)) == NULL)
+ {
+ return AXIS2_FALSE;
+ }
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_action_to_om(saml_action_t *action, axiom_node_t *parent, axutil_env_t *env)
+{
+ axiom_element_t *e = NULL;
+ axiom_node_t *n = NULL;
+ axiom_namespace_t *ns = NULL;
+ axiom_attribute_t *attr = NULL;
+ ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
+ e = axiom_element_create(env, parent, SAML_ACTION, ns, &n);
+ if (e)
+ {
+ if (action->name_space)
+ {
+ attr = axiom_attribute_create(env, SAML_NAMESPACE, action->name_space, NULL);
+ axiom_element_add_attribute(e, env, attr, n);
+ }
+ if (action->data)
+ {
+ axiom_element_set_text(e, env, action->data, n);
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+ return n;
+}
+
+AXIS2_EXTERN saml_evidence_t * AXIS2_CALL saml_evidence_create(axutil_env_t *env)
+{
+ saml_evidence_t *evidence = (saml_evidence_t *)AXIS2_MALLOC(env->allocator, sizeof(saml_evidence_t));
+ if (evidence)
+ {
+ evidence->assertion_ids = axutil_array_list_create(env, SAML_ARRAY_LIST_DEF);
+ evidence->assertions = axutil_array_list_create(env, SAML_ARRAY_LIST_DEF);
+ }
+ return evidence;
+}
+
+AXIS2_EXTERN void AXIS2_CALL saml_evidence_free(saml_evidence_t *evidence, axutil_env_t *env)
+{
+ int i = 0, size = 0;
+ char *val = NULL;
+ saml_assertion_t *assertion = NULL;
+
+ if (evidence->assertion_ids)
+ {
+ size = axutil_array_list_size(evidence->assertion_ids, env);
+ for (i = 0; i < size; i++)
+ {
+ val = axutil_array_list_get(evidence->assertion_ids, env, i);
+ if (val)
+ {
+ AXIS2_FREE(env->allocator, val);
+ }
+ }
+ }
+ if (evidence->assertions)
+ {
+ size = axutil_array_list_size(evidence->assertions, env);
+ for (i = 0; i < size; i++)
+ {
+ assertion = axutil_array_list_get(evidence->assertions, env, i);
+ if (assertion)
+ {
+ saml_assertion_uninit(assertion, env);
+ AXIS2_FREE(env->allocator, assertion);
+ }
+ }
+ }
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_evidence_build(saml_evidence_t *evidence, axiom_node_t *node, axutil_env_t *env)
+{
+ axiom_element_t *element = NULL;
+ axiom_element_t *fce = NULL;
+ axiom_node_t *fcn = NULL;
+ axiom_child_element_iterator_t *ci = NULL;
+ saml_assertion_t *assertion = NULL;
+ if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
+ {
+ return AXIS2_FAILURE;
+ }
+ ci = axiom_element_get_child_elements(element, env, node);
+ if (ci)
+ {
+ while(AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
+ {
+ fcn = axiom_child_element_iterator_next(ci, env);
+ fce = axiom_node_get_data_element(fcn, env);
+ if (strcmp(axiom_element_get_localname(fce, env), SAML_ASSERTIONIDREFERENCE) == 0)
+ {
+ axutil_array_list_add(evidence->assertion_ids, env, axiom_element_get_text(fce, env, fcn));
+ }
+ else if (strcmp(axiom_element_get_localname(fce, env), SAML_ASSERTION) == 0)
+ {
+ assertion = AXIS2_MALLOC(env->allocator, sizeof(saml_assertion_t));
+ saml_assertion_build(assertion, fcn, env);
+ axutil_array_list_add(evidence->assertions, env, assertion);
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_evidence_to_om(saml_evidence_t *evidence, axiom_node_t *parent, axutil_env_t *env)
+{
+ int size = 0, i = 0;
+ axiom_element_t *e = NULL, *ce = NULL;
+ axiom_node_t *n = NULL, *cn = NULL;
+ axiom_namespace_t *ns = NULL;
+ axiom_attribute_t *attr = NULL;
+ saml_assertion_t *assertion = NULL;
+ ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
+ e = axiom_element_create(env, parent, SAML_EVIDENCE, ns, &n);
+ if (e)
+ {
+ if (evidence->assertion_ids)
+ {
+ size = axutil_array_list_size(evidence->assertion_ids, env);
+ for (i = 0; i < size; i++)
+ {
+ ce = axiom_element_create(env, n, SAML_ASSERTIONIDREFERENCE, ns, &n);
+ axiom_element_set_text(ce, env, axutil_array_list_get(evidence->assertion_ids, env, i), cn);
+ }
+ }
+ if (evidence->assertions)
+ {
+ size = axutil_array_list_size(evidence->assertions, env);
+ for (i = 0; i < size; i++)
+ {
+ assertion = axutil_array_list_get(evidence->assertions, env, i);
+ saml_assertion_to_om(assertion, n, env);
+ }
+ }
+ }
+ return n;
+}
+
+
+AXIS2_EXTERN saml_auth_desicion_stmt_t * AXIS2_CALL saml_auth_desicion_stmt_create(axutil_env_t *env)
+{
+ saml_auth_desicion_stmt_t *auth_des_stmt = AXIS2_MALLOC(env->allocator, sizeof(saml_auth_desicion_stmt_t));
+ if (auth_des_stmt)
+ {
+ auth_des_stmt->decision = NULL;
+ auth_des_stmt->resource = NULL;
+ auth_des_stmt->evidence = NULL;
+ auth_des_stmt->action = axutil_array_list_create(env, SAML_ARRAY_LIST_DEF);
+ saml_subject_init(&auth_des_stmt->subject, env);
+ }
+ return auth_des_stmt;
+}
+
+AXIS2_EXTERN void AXIS2_CALL saml_auth_desicion_stmt_free(saml_auth_desicion_stmt_t *auth_des_stmt, axutil_env_t *env)
+{
+ if (auth_des_stmt->decision)
+ {
+ AXIS2_FREE(env->allocator, auth_des_stmt->decision);
+ }
+ if (auth_des_stmt->resource)
+ {
+ AXIS2_FREE(env->allocator, auth_des_stmt->resource);
+ }
+ if (auth_des_stmt->evidence)
+ {
+ saml_evidence_free(auth_des_stmt->evidence, env);
+ }
+ if (auth_des_stmt->action)
+ {
+ int i = 0;
+ saml_action_t *action = NULL;
+ for (i = 0; i < axutil_array_list_size(auth_des_stmt->action, env); i++)
+ {
+ action = axutil_array_list_get(auth_des_stmt->action, env, i);
+ if (action)
+ {
+ saml_action_uninit(action, env);
+ }
+ }
+ axutil_array_list_free(auth_des_stmt->action, env);
+ }
+ saml_subject_uninit(&auth_des_stmt->subject, env);
+ AXIS2_FREE(env->allocator, auth_des_stmt);
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_auth_desicion_stmt_build(saml_auth_desicion_stmt_t *auth_des_stmt, axiom_node_t *node, axutil_env_t *env)
+{
+ axutil_hash_t *attr_hash = NULL;
+ axutil_hash_index_t *hi = NULL;
+ axiom_element_t *element = NULL;
+ axiom_element_t *fce = NULL;
+ axiom_node_t *fcn = NULL;
+ axiom_child_element_iterator_t *ci = NULL;
+ if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
+ {
+ return AXIS2_FAILURE;
+ }
+ if ((auth_des_stmt->resource = axiom_element_get_attribute_value_by_name(element, env, SAML_RESOURCE)) == NULL || (auth_des_stmt->decision = axiom_element_get_attribute_value_by_name(element, env, SAML_DECISION)) == NULL)
+ {
+ return AXIS2_FAILURE;
+ }
+ attr_hash = axiom_element_get_all_attributes(element, env);
+ for (hi = axutil_hash_first(attr_hash, env); hi != NULL; hi = axutil_hash_next(env, hi))
+ {
+ void *v = NULL;
+ axutil_hash_this(hi, NULL, NULL, &v);
+ if (v)
+ {
+ axis2_char_t *attr_val = NULL;
+ axiom_attribute_t *attr = (axiom_attribute_t*)v;
+ attr_val = axiom_attribute_get_value(attr, env);
+ if (0 != axutil_strcmp(attr_val, SAML_RESOURCE) && 0 != axutil_strcmp(attr_val, SAML_DECISION))
+ {
+ return AXIS2_FALSE;
+ }
+ }
+ }
+ ci = axiom_element_get_child_elements(element, env, node);
+ if (ci)
+ {
+ fcn = axiom_child_element_iterator_next(ci, env);
+ fce = axiom_node_get_data_element(fcn, env);
+ while(AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
+ {
+ if (strcmp(axiom_element_get_localname(fce, env), SAML_SUBJECTSTATEMENT) == 0)
+ {
+ saml_subject_build(&auth_des_stmt->subject, fcn, env);
+ }
+ else if (strcmp(axiom_element_get_localname(fce, env), SAML_ACTION) == 0)
+ {
+ axutil_array_list_add(auth_des_stmt->action, env, axiom_element_get_text(fce, env, fcn));
+ }
+ else if (strcmp(axiom_element_get_localname(fce, env), SAML_EVIDENCE) == 0)
+ {
+ saml_evidence_t *evi = saml_evidence_create(env);
+ if (saml_evidence_build(evi, fcn, env))
+ {
+ auth_des_stmt->evidence = evi;
+ }
+ else
+ {
+ return AXIS2_FALSE;
+ }
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_auth_desicion_stmt_to_om(saml_auth_desicion_stmt_t *auth_des_stmt, axiom_node_t *parent, axutil_env_t *env)
+{
+ int i = 0, size = 0;
+ axiom_element_t *e = NULL;
+ axiom_node_t *n = NULL;
+ axiom_attribute_t *attr = NULL;
+ axiom_namespace_t *ns = NULL;
+ saml_action_t *action = NULL;
+ ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
+ e = axiom_element_create(env, parent, SAML_AUTHORIZATIONDECISIONSTATEMENT, ns, &n);
+ if (e)
+ {
+ if (auth_des_stmt->resource && auth_des_stmt->decision)
+ {
+ attr = axiom_attribute_create(env, SAML_RESOURCE, auth_des_stmt->resource, NULL);
+ axiom_element_add_attribute(e, env, attr, n);
+ attr = axiom_attribute_create(env, SAML_DECISION, auth_des_stmt->decision, NULL);
+ axiom_element_add_attribute(e, env, attr, n);
+ }
+ else
+ {
+ axiom_element_free(e, env);
+ return NULL;
+ }
+ saml_subject_to_om(&auth_des_stmt->subject, n, env);
+ if (auth_des_stmt->action)
+ {
+ size = axutil_array_list_size(auth_des_stmt->action, env);
+ for (i = 0; i < size; i++)
+ {
+ action = axutil_array_list_get(auth_des_stmt->action, env, i);
+ saml_action_to_om(action, n, env);
+ }
+ }
+ if (auth_des_stmt->evidence)
+ {
+ saml_evidence_to_om(auth_des_stmt->evidence, n, env);
+ }
+ }
+ return NULL;
+}
Modified: webservices/rampart/scratch/c/saml/src/auth_smt.c
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/saml/src/auth_smt.c?rev=583456&r1=583455&r2=583456&view=diff
==============================================================================
--- webservices/rampart/scratch/c/saml/src/auth_smt.c (original)
+++ webservices/rampart/scratch/c/saml/src/auth_smt.c Wed Oct 10 05:40:28 2007
@@ -1,353 +1,353 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "SAML.h"
-
-AXIS2_EXTERN saml_auth_stmt_t * AXIS2_CALL saml_auth_stmt_create(axutil_env_t *env)
-{
- saml_auth_stmt_t *auth_stmt = AXIS2_MALLOC(env->allocator, sizeof(saml_auth_stmt_t));
- if (auth_stmt)
- {
- auth_stmt->auth_instanse = NULL;
- auth_stmt->auth_method = NULL;
- auth_stmt->sub_locality = NULL;
- auth_stmt->auth_binding = NULL;
- }
- return auth_stmt;
-}
-
-AXIS2_EXTERN void AXIS2_CALL saml_auth_stmt_free(saml_auth_stmt_t *auth_stmt, axutil_env_t *env)
-{
- if (auth_stmt->auth_instanse)
- {
- axutil_date_time_free(auth_stmt->auth_instanse, env);
- }
- if (auth_stmt->auth_method)
- {
- AXIS2_FREE(env->allocator, auth_stmt->auth_method);
- }
- if (auth_stmt->sub_locality)
- {
- saml_subject_locality_free(auth_stmt->sub_locality, env);
- }
- if (auth_stmt->auth_binding)
- {
- int i = 0;
- saml_auth_binding_t *auth_bind = NULL;
- for (i = 0; i < axutil_array_list_size(auth_stmt->auth_binding, env); i++)
- {
- auth_bind = axutil_array_list_get(auth_stmt->auth_binding, env, i);
- if (auth_bind)
- {
- saml_auth_binding_free(auth_bind, env);
- }
- }
- axutil_array_list_free(auth_stmt->auth_binding, env);
- }
- AXIS2_FREE(env->allocator, auth_stmt);
-}
-
-
-AXIS2_EXTERN int AXIS2_CALL saml_auth_stmt_build(saml_auth_stmt_t *auth_stmt, axiom_node_t *node, axutil_env_t *env)
-{
- axiom_element_t *element = NULL;
- axiom_node_t *sub_locality = NULL;
- axiom_child_element_iterator_t *ci = NULL;
- axis2_char_t *time = NULL;
- if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = axiom_node_get_data_element(node, env)) == NULL)
- {
- return AXIS2_FAILURE;
- }
- if ((auth_stmt->auth_method = axiom_element_get_attribute_value_by_name(element, env, SAML_AUTHENTICATIONMETHOD)) == NULL)
- {
- return AXIS2_FAILURE;
- }
- if ((time = axiom_element_get_attribute_value_by_name(element, env, SAML_AUTHENTICATIONINSTANT)) != NULL)
- {
- auth_stmt->auth_instanse = axutil_date_time_create(env);
- axutil_date_time_deserialize_date_time(auth_stmt->auth_instanse, env, time);
- }
- ci = axiom_element_get_child_elements(element, env, node);
- if (ci)
- {
- axiom_node_t *child_node = NULL;
- axiom_element_t *child_element = NULL;
- saml_auth_binding_t *auth_bind = NULL;
- char *child_name = NULL;
- if (AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
- {
- child_node = axiom_child_element_iterator_next(ci, env);
- element = (axiom_element_t *)axiom_node_get_data_element(node, env);
- if (element != NULL && axutil_strcmp(axiom_element_get_localname(element, env), SAML_SUBJECTOCALITY) == 0)
- {
- auth_stmt->sub_locality = saml_subject_locality_create(env);
- if (!auth_stmt->sub_locality || !saml_subject_locality_build(auth_stmt->sub_locality, child_node, env))
- {
- return AXIS2_FAILURE;
- }
- /* Ensure we have iniitialized array list before going in to the while loop below */
- if (AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
- {
- child_node = axiom_child_element_iterator_next(ci, env);
- element = (axiom_element_t *)axiom_node_get_data_element(node, env);
- }
- }
- if (element != NULL && axutil_strcmp(axiom_element_get_localname(element, env), SAML_AUTHORITYBINDING) == 0)
- {
- auth_bind = saml_auth_binding_create(env);
- auth_stmt->auth_binding = axutil_array_list_create(env, SAML_ARRAY_LIST_DEF);
-
- if (auth_bind && auth_stmt->auth_binding)
- {
- axutil_array_list_add(auth_stmt->auth_binding, env, (const void *)auth_bind);
- }
- else
- {
- return AXIS2_FAILURE;
- }
- }
- while (AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
- {
- auth_bind = saml_auth_binding_create(env);
- child_node = axiom_child_element_iterator_next(ci, env);
- if (auth_bind && auth_stmt->auth_binding && !saml_auth_binding_build(auth_bind, child_node, env))
- {
- axutil_array_list_add(auth_stmt->auth_binding, env, (const void *)auth_bind);
- }
- else
- {
- return AXIS2_FAILURE;
- }
- }
- }
- }
- else
- {
- return AXIS2_FAILURE;
- }
- return AXIS2_FAILURE;
-}
-
-AXIS2_EXTERN axiom_node_t *AXIS2_CALL saml_auth_stmt_to_om(saml_auth_stmt_t *auth_stmt, axiom_node_t *parent, axutil_env_t *env)
-{
- int i = 0, size = 0;
- axiom_element_t *e = NULL;
- axiom_node_t *n = NULL;
- axiom_attribute_t *attr = NULL;
- axiom_namespace_t *ns = NULL;
- saml_auth_binding_t *auth_bind = NULL;
- ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
- e = axiom_element_create(env, parent, SAML_AUTHENTICATIONINSTANT, ns, &n);
- if (e)
- {
- if (auth_stmt->auth_instanse && auth_stmt->auth_method)
- {
- attr = axiom_attribute_create(env, SAML_AUTHENTICATIONMETHOD, auth_stmt->auth_method, NULL);
- axiom_element_add_attribute(e, env, attr, n);
- attr = axiom_attribute_create(env, SAML_AUTHENTICATIONINSTANT, axutil_date_time_serialize_date_time(auth_stmt->auth_instanse, env), NULL);
- axiom_element_add_attribute(e, env, attr, n);
- }
- else
- {
- axiom_element_free(e, env);
- return NULL;
- }
- if (saml_subject_locality_to_om(auth_stmt->sub_locality, n, env) == NULL)
- {
- axiom_element_free(e, env);
- return NULL;
- }
- size = axutil_array_list_size(auth_stmt->auth_binding, env);
- for (i = 0; i < size; i++)
- {
- auth_bind = axutil_array_list_get(auth_stmt->auth_binding, env, i);
- saml_auth_binding_to_om(auth_bind, n, env);
- }
- }
- return n;
-}
-
-
-AXIS2_EXTERN saml_subject_locality_t * AXIS2_CALL saml_subject_locality_create(axutil_env_t *env)
-{
- saml_subject_locality_t *sub_locality = AXIS2_MALLOC(env->allocator, sizeof(saml_subject_locality_t));
- if (sub_locality)
- {
- sub_locality->ip = NULL;
- sub_locality->dns = NULL;
- return sub_locality;
- }
- return NULL;
-}
-
-AXIS2_EXTERN void AXIS2_CALL saml_subject_locality_free(saml_subject_locality_t *sub_locality, axutil_env_t *env)
-{
- if (sub_locality->dns)
- {
- AXIS2_FREE(env->allocator, sub_locality->dns);
- }
- if (sub_locality->ip)
- {
- AXIS2_FREE(env->allocator, sub_locality->ip);
- }
-
- AXIS2_FREE(env->allocator, sub_locality);
-}
-
-AXIS2_EXTERN int AXIS2_CALL saml_subject_locality_build(saml_subject_locality_t *sub_locality, axiom_node_t *node, axutil_env_t *env)
-{
- axutil_hash_t *attr_hash = NULL;
- axiom_element_t *element = NULL;
- axutil_hash_index_t *hi = NULL;
- if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
- {
- return AXIS2_FAILURE;
- }
- attr_hash = axiom_element_get_all_attributes(element, env);
- for (hi = axutil_hash_first(attr_hash, env); hi; hi = axutil_hash_next(env, hi))
- {
- void *v = NULL;
- axutil_hash_this(hi, NULL, NULL, &v);
- if (v)
- {
- axis2_char_t *attr_val = NULL;
- axis2_char_t *attr_lname = NULL;
- axiom_attribute_t *attr = (axiom_attribute_t*)v;
- attr_val = axiom_attribute_get_value(attr, env);
- attr_lname = axiom_attribute_get_localname(attr, env);
- if (!axutil_strcmp(attr_lname, SAML_IPADDRESS))
- {
- sub_locality->ip = attr_val;
- }
- else if (!axutil_strcmp(attr_lname, SAML_DNSADDRESS))
- {
- sub_locality->dns = attr_val;
- }
- else
- {
- return AXIS2_FAILURE;
- }
- }
- }
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_subject_locality_to_om(saml_subject_locality_t *sub_locality, axiom_node_t *parent, axutil_env_t *env)
-{
- axiom_element_t *e = NULL;
- axiom_node_t *n = NULL;
- axiom_attribute_t *attr = NULL;
- axiom_namespace_t *ns = NULL;
- ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
- e = axiom_element_create(env, parent, SAML_SUBJECTOCALITY, ns, &n);
- if (e)
- {
- if (sub_locality->dns)
- {
- attr = axiom_attribute_create(env, SAML_DNSADDRESS, sub_locality->dns, NULL);
- axiom_element_add_attribute(e, env, attr, n);
- }
- if (sub_locality->ip)
- {
- attr = axiom_attribute_create(env, SAML_IPADDRESS, sub_locality->ip, NULL);
- axiom_element_add_attribute(e, env, attr, n);
- }
- else
- {
- axiom_element_free(e, env);
- return NULL;
- }
- }
- return n;
-}
-
-AXIS2_EXTERN saml_auth_binding_t * AXIS2_CALL saml_auth_binding_create(axutil_env_t *env)
-{
- saml_auth_binding_t *auth_bind = AXIS2_MALLOC(env->allocator, sizeof(saml_auth_binding_t));
- if (auth_bind)
- {
- auth_bind->auth_kind = NULL;
- auth_bind->binding = NULL;
- auth_bind->location = NULL;
- return auth_bind;
- }
- return NULL;
-}
-
-AXIS2_EXTERN void AXIS2_CALL saml_auth_binding_free(saml_auth_binding_t *auth_bind, axutil_env_t *env)
-{
- if (auth_bind->auth_kind)
- {
- AXIS2_FREE(env->allocator, auth_bind->auth_kind);
- }
- if (auth_bind->binding)
- {
- AXIS2_FREE(env->allocator, auth_bind->binding);
- }
- if (auth_bind->location)
- {
- AXIS2_FREE(env->allocator, auth_bind->location);
- }
- AXIS2_FREE(env->allocator, auth_bind);
-}
-
-AXIS2_EXTERN int AXIS2_CALL saml_auth_binding_build(saml_auth_binding_t *auth_bind, axiom_node_t *node, axutil_env_t *env)
-{
- axutil_hash_t *attr_hash = NULL;
- axiom_element_t *element = NULL;
- axutil_hash_index_t *hi = NULL;
- if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
- {
- return AXIS2_FAILURE;
- }
- if ((auth_bind->auth_kind = axiom_element_get_attribute_value_by_name(element, env, SAML_AUTHORITYKIND)) == NULL ||
- (auth_bind->binding = axiom_element_get_attribute_value_by_name(element, env, SAML_BINDING)) == NULL ||
- (auth_bind->location = axiom_element_get_attribute_value_by_name(element, env, SAML_LOCATION)) == NULL)
- {
- return AXIS2_FAILURE;
- }
- return AXIS2_SUCCESS;
-}
-
-
-AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_auth_binding_to_om(saml_auth_binding_t *auth_binding, axiom_node_t *parent, axutil_env_t *env)
-{
- axiom_element_t *e = NULL;
- axiom_node_t *n = NULL;
- axiom_attribute_t *attr = NULL;
- axiom_namespace_t *ns = NULL;
- ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
- e = axiom_element_create(env, parent, SAML_AUTHORITYBINDING, ns, &n);
- if (e)
- {
- if (auth_binding->auth_kind && auth_binding->binding && auth_binding->location)
- {
- attr = axiom_attribute_create(env, SAML_AUTHORITYKIND, auth_binding->auth_kind, NULL);
- axiom_element_add_attribute(e, env, attr, n);
- attr = axiom_attribute_create(env, SAML_BINDING, auth_binding->binding, NULL);
- axiom_element_add_attribute(e, env, attr, n);
- attr = axiom_attribute_create(env, SAML_LOCATION, auth_binding->location, NULL);
- axiom_element_add_attribute(e, env, attr, n);
- }
- else
- {
- axiom_element_free(e, env);
- return NULL;
- }
- }
- return n;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SAML.h"
+
+AXIS2_EXTERN saml_auth_stmt_t * AXIS2_CALL saml_auth_stmt_create(axutil_env_t *env)
+{
+ saml_auth_stmt_t *auth_stmt = AXIS2_MALLOC(env->allocator, sizeof(saml_auth_stmt_t));
+ if (auth_stmt)
+ {
+ auth_stmt->auth_instanse = NULL;
+ auth_stmt->auth_method = NULL;
+ auth_stmt->sub_locality = NULL;
+ auth_stmt->auth_binding = NULL;
+ }
+ return auth_stmt;
+}
+
+AXIS2_EXTERN void AXIS2_CALL saml_auth_stmt_free(saml_auth_stmt_t *auth_stmt, axutil_env_t *env)
+{
+ if (auth_stmt->auth_instanse)
+ {
+ axutil_date_time_free(auth_stmt->auth_instanse, env);
+ }
+ if (auth_stmt->auth_method)
+ {
+ AXIS2_FREE(env->allocator, auth_stmt->auth_method);
+ }
+ if (auth_stmt->sub_locality)
+ {
+ saml_subject_locality_free(auth_stmt->sub_locality, env);
+ }
+ if (auth_stmt->auth_binding)
+ {
+ int i = 0;
+ saml_auth_binding_t *auth_bind = NULL;
+ for (i = 0; i < axutil_array_list_size(auth_stmt->auth_binding, env); i++)
+ {
+ auth_bind = axutil_array_list_get(auth_stmt->auth_binding, env, i);
+ if (auth_bind)
+ {
+ saml_auth_binding_free(auth_bind, env);
+ }
+ }
+ axutil_array_list_free(auth_stmt->auth_binding, env);
+ }
+ AXIS2_FREE(env->allocator, auth_stmt);
+}
+
+
+AXIS2_EXTERN int AXIS2_CALL saml_auth_stmt_build(saml_auth_stmt_t *auth_stmt, axiom_node_t *node, axutil_env_t *env)
+{
+ axiom_element_t *element = NULL;
+ axiom_node_t *sub_locality = NULL;
+ axiom_child_element_iterator_t *ci = NULL;
+ axis2_char_t *time = NULL;
+ if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = axiom_node_get_data_element(node, env)) == NULL)
+ {
+ return AXIS2_FAILURE;
+ }
+ if ((auth_stmt->auth_method = axiom_element_get_attribute_value_by_name(element, env, SAML_AUTHENTICATIONMETHOD)) == NULL)
+ {
+ return AXIS2_FAILURE;
+ }
+ if ((time = axiom_element_get_attribute_value_by_name(element, env, SAML_AUTHENTICATIONINSTANT)) != NULL)
+ {
+ auth_stmt->auth_instanse = axutil_date_time_create(env);
+ axutil_date_time_deserialize_date_time(auth_stmt->auth_instanse, env, time);
+ }
+ ci = axiom_element_get_child_elements(element, env, node);
+ if (ci)
+ {
+ axiom_node_t *child_node = NULL;
+ axiom_element_t *child_element = NULL;
+ saml_auth_binding_t *auth_bind = NULL;
+ char *child_name = NULL;
+ if (AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
+ {
+ child_node = axiom_child_element_iterator_next(ci, env);
+ element = (axiom_element_t *)axiom_node_get_data_element(node, env);
+ if (element != NULL && axutil_strcmp(axiom_element_get_localname(element, env), SAML_SUBJECTOCALITY) == 0)
+ {
+ auth_stmt->sub_locality = saml_subject_locality_create(env);
+ if (!auth_stmt->sub_locality || !saml_subject_locality_build(auth_stmt->sub_locality, child_node, env))
+ {
+ return AXIS2_FAILURE;
+ }
+ /* Ensure we have iniitialized array list before going in to the while loop below */
+ if (AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
+ {
+ child_node = axiom_child_element_iterator_next(ci, env);
+ element = (axiom_element_t *)axiom_node_get_data_element(node, env);
+ }
+ }
+ if (element != NULL && axutil_strcmp(axiom_element_get_localname(element, env), SAML_AUTHORITYBINDING) == 0)
+ {
+ auth_bind = saml_auth_binding_create(env);
+ auth_stmt->auth_binding = axutil_array_list_create(env, SAML_ARRAY_LIST_DEF);
+
+ if (auth_bind && auth_stmt->auth_binding)
+ {
+ axutil_array_list_add(auth_stmt->auth_binding, env, (const void *)auth_bind);
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ }
+ while (AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
+ {
+ auth_bind = saml_auth_binding_create(env);
+ child_node = axiom_child_element_iterator_next(ci, env);
+ if (auth_bind && auth_stmt->auth_binding && !saml_auth_binding_build(auth_bind, child_node, env))
+ {
+ axutil_array_list_add(auth_stmt->auth_binding, env, (const void *)auth_bind);
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ }
+ }
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ return AXIS2_FAILURE;
+}
+
+AXIS2_EXTERN axiom_node_t *AXIS2_CALL saml_auth_stmt_to_om(saml_auth_stmt_t *auth_stmt, axiom_node_t *parent, axutil_env_t *env)
+{
+ int i = 0, size = 0;
+ axiom_element_t *e = NULL;
+ axiom_node_t *n = NULL;
+ axiom_attribute_t *attr = NULL;
+ axiom_namespace_t *ns = NULL;
+ saml_auth_binding_t *auth_bind = NULL;
+ ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
+ e = axiom_element_create(env, parent, SAML_AUTHENTICATIONINSTANT, ns, &n);
+ if (e)
+ {
+ if (auth_stmt->auth_instanse && auth_stmt->auth_method)
+ {
+ attr = axiom_attribute_create(env, SAML_AUTHENTICATIONMETHOD, auth_stmt->auth_method, NULL);
+ axiom_element_add_attribute(e, env, attr, n);
+ attr = axiom_attribute_create(env, SAML_AUTHENTICATIONINSTANT, axutil_date_time_serialize_date_time(auth_stmt->auth_instanse, env), NULL);
+ axiom_element_add_attribute(e, env, attr, n);
+ }
+ else
+ {
+ axiom_element_free(e, env);
+ return NULL;
+ }
+ if (saml_subject_locality_to_om(auth_stmt->sub_locality, n, env) == NULL)
+ {
+ axiom_element_free(e, env);
+ return NULL;
+ }
+ size = axutil_array_list_size(auth_stmt->auth_binding, env);
+ for (i = 0; i < size; i++)
+ {
+ auth_bind = axutil_array_list_get(auth_stmt->auth_binding, env, i);
+ saml_auth_binding_to_om(auth_bind, n, env);
+ }
+ }
+ return n;
+}
+
+
+AXIS2_EXTERN saml_subject_locality_t * AXIS2_CALL saml_subject_locality_create(axutil_env_t *env)
+{
+ saml_subject_locality_t *sub_locality = AXIS2_MALLOC(env->allocator, sizeof(saml_subject_locality_t));
+ if (sub_locality)
+ {
+ sub_locality->ip = NULL;
+ sub_locality->dns = NULL;
+ return sub_locality;
+ }
+ return NULL;
+}
+
+AXIS2_EXTERN void AXIS2_CALL saml_subject_locality_free(saml_subject_locality_t *sub_locality, axutil_env_t *env)
+{
+ if (sub_locality->dns)
+ {
+ AXIS2_FREE(env->allocator, sub_locality->dns);
+ }
+ if (sub_locality->ip)
+ {
+ AXIS2_FREE(env->allocator, sub_locality->ip);
+ }
+
+ AXIS2_FREE(env->allocator, sub_locality);
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_subject_locality_build(saml_subject_locality_t *sub_locality, axiom_node_t *node, axutil_env_t *env)
+{
+ axutil_hash_t *attr_hash = NULL;
+ axiom_element_t *element = NULL;
+ axutil_hash_index_t *hi = NULL;
+ if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
+ {
+ return AXIS2_FAILURE;
+ }
+ attr_hash = axiom_element_get_all_attributes(element, env);
+ for (hi = axutil_hash_first(attr_hash, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ void *v = NULL;
+ axutil_hash_this(hi, NULL, NULL, &v);
+ if (v)
+ {
+ axis2_char_t *attr_val = NULL;
+ axis2_char_t *attr_lname = NULL;
+ axiom_attribute_t *attr = (axiom_attribute_t*)v;
+ attr_val = axiom_attribute_get_value(attr, env);
+ attr_lname = axiom_attribute_get_localname(attr, env);
+ if (!axutil_strcmp(attr_lname, SAML_IPADDRESS))
+ {
+ sub_locality->ip = attr_val;
+ }
+ else if (!axutil_strcmp(attr_lname, SAML_DNSADDRESS))
+ {
+ sub_locality->dns = attr_val;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_subject_locality_to_om(saml_subject_locality_t *sub_locality, axiom_node_t *parent, axutil_env_t *env)
+{
+ axiom_element_t *e = NULL;
+ axiom_node_t *n = NULL;
+ axiom_attribute_t *attr = NULL;
+ axiom_namespace_t *ns = NULL;
+ ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
+ e = axiom_element_create(env, parent, SAML_SUBJECTOCALITY, ns, &n);
+ if (e)
+ {
+ if (sub_locality->dns)
+ {
+ attr = axiom_attribute_create(env, SAML_DNSADDRESS, sub_locality->dns, NULL);
+ axiom_element_add_attribute(e, env, attr, n);
+ }
+ if (sub_locality->ip)
+ {
+ attr = axiom_attribute_create(env, SAML_IPADDRESS, sub_locality->ip, NULL);
+ axiom_element_add_attribute(e, env, attr, n);
+ }
+ else
+ {
+ axiom_element_free(e, env);
+ return NULL;
+ }
+ }
+ return n;
+}
+
+AXIS2_EXTERN saml_auth_binding_t * AXIS2_CALL saml_auth_binding_create(axutil_env_t *env)
+{
+ saml_auth_binding_t *auth_bind = AXIS2_MALLOC(env->allocator, sizeof(saml_auth_binding_t));
+ if (auth_bind)
+ {
+ auth_bind->auth_kind = NULL;
+ auth_bind->binding = NULL;
+ auth_bind->location = NULL;
+ return auth_bind;
+ }
+ return NULL;
+}
+
+AXIS2_EXTERN void AXIS2_CALL saml_auth_binding_free(saml_auth_binding_t *auth_bind, axutil_env_t *env)
+{
+ if (auth_bind->auth_kind)
+ {
+ AXIS2_FREE(env->allocator, auth_bind->auth_kind);
+ }
+ if (auth_bind->binding)
+ {
+ AXIS2_FREE(env->allocator, auth_bind->binding);
+ }
+ if (auth_bind->location)
+ {
+ AXIS2_FREE(env->allocator, auth_bind->location);
+ }
+ AXIS2_FREE(env->allocator, auth_bind);
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_auth_binding_build(saml_auth_binding_t *auth_bind, axiom_node_t *node, axutil_env_t *env)
+{
+ axutil_hash_t *attr_hash = NULL;
+ axiom_element_t *element = NULL;
+ axutil_hash_index_t *hi = NULL;
+ if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
+ {
+ return AXIS2_FAILURE;
+ }
+ if ((auth_bind->auth_kind = axiom_element_get_attribute_value_by_name(element, env, SAML_AUTHORITYKIND)) == NULL ||
+ (auth_bind->binding = axiom_element_get_attribute_value_by_name(element, env, SAML_BINDING)) == NULL ||
+ (auth_bind->location = axiom_element_get_attribute_value_by_name(element, env, SAML_LOCATION)) == NULL)
+ {
+ return AXIS2_FAILURE;
+ }
+ return AXIS2_SUCCESS;
+}
+
+
+AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_auth_binding_to_om(saml_auth_binding_t *auth_binding, axiom_node_t *parent, axutil_env_t *env)
+{
+ axiom_element_t *e = NULL;
+ axiom_node_t *n = NULL;
+ axiom_attribute_t *attr = NULL;
+ axiom_namespace_t *ns = NULL;
+ ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
+ e = axiom_element_create(env, parent, SAML_AUTHORITYBINDING, ns, &n);
+ if (e)
+ {
+ if (auth_binding->auth_kind && auth_binding->binding && auth_binding->location)
+ {
+ attr = axiom_attribute_create(env, SAML_AUTHORITYKIND, auth_binding->auth_kind, NULL);
+ axiom_element_add_attribute(e, env, attr, n);
+ attr = axiom_attribute_create(env, SAML_BINDING, auth_binding->binding, NULL);
+ axiom_element_add_attribute(e, env, attr, n);
+ attr = axiom_attribute_create(env, SAML_LOCATION, auth_binding->location, NULL);
+ axiom_element_add_attribute(e, env, attr, n);
+ }
+ else
+ {
+ axiom_element_free(e, env);
+ return NULL;
+ }
+ }
+ return n;
}
Modified: webservices/rampart/scratch/c/saml/src/condition.c
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/saml/src/condition.c?rev=583456&r1=583455&r2=583456&view=diff
==============================================================================
--- webservices/rampart/scratch/c/saml/src/condition.c (original)
+++ webservices/rampart/scratch/c/saml/src/condition.c Wed Oct 10 05:40:28 2007
@@ -1,154 +1,154 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "SAML.h"
-
-AXIS2_EXTERN saml_audi_restriction_cond_t * AXIS2_CALL saml_audi_restriction_cond_create(axutil_env_t *env)
-{
- saml_audi_restriction_cond_t *arc = AXIS2_MALLOC(env->allocator, sizeof(saml_audi_restriction_cond_t));
- if (arc)
- {
- arc->audiences = axutil_array_list_create(env, SAML_ARRAY_LIST_DEF);
- if (arc->audiences)
- {
- return arc;
- }
- AXIS2_FREE(env->allocator, arc);
- }
- return NULL;
-}
-
-AXIS2_EXTERN void AXIS2_CALL saml_audi_restriction_cond_free(saml_audi_restriction_cond_t *arc, axutil_env_t * env)
-{
- int i = 0, size = 0;
- char *val = NULL;
- if (arc->audiences)
- {
- size = axutil_array_list_size(arc->audiences, env);
- for (i = 0; i <size; i++)
- {
- val = axutil_array_list_get(arc->audiences, env, i);
- if (val)
- {
- AXIS2_FREE(env->allocator, val);
- }
- }
- }
- AXIS2_FREE(env->allocator, arc);
-}
-
-
-AXIS2_EXTERN int AXIS2_CALL saml_audi_restriction_build(saml_audi_restriction_cond_t *arc, axiom_node_t *node, axutil_env_t *env)
-{
- axiom_element_t *element = NULL;
- axiom_child_element_iterator_t *ci = NULL;
- if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
- {
- return AXIS2_FAILURE;
- }
- ci = axiom_element_get_child_elements(element, env, node);
- if (ci)
- {
- axiom_node_t *cn = NULL;
- axiom_element_t *ce = NULL;
- while(AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
- {
- cn = axiom_child_element_iterator_next(ci, env);
- ce = axiom_node_get_data_element(cn, env);
- if (0 == axutil_strcmp(SAML_AUDIENCE, axiom_element_get_localname(ce, env)))
- {
- axutil_array_list_add(arc->audiences, env, axiom_element_get_text(ce, env, cn));
- }
- else
- {
- return AXIS2_FAILURE;
- }
- }
- }
- return AXIS2_SUCCESS;
-}
-
-
-AXIS2_EXTERN axiom_node_t *AXIS2_CALL saml_audi_restriction_cond_to_om(saml_audi_restriction_cond_t *cond, axiom_node_t *parent, axutil_env_t * env)
-{
- int i = 0, size = 0;
- axiom_element_t *e = NULL, *ce = NULL;
- axiom_node_t *n = NULL, *cn = NULL;
- axiom_namespace_t *ns = NULL, *cns = NULL;
- ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
- e = axiom_element_create(env, parent, SAML_AUDIENCERESTRICTIONCONDITIONTYPE, ns, &n);
- if (e && cond->audiences)
- {
- size = axutil_array_list_size(cond->audiences, env);
- for (i = 0; i < size; i++)
- {
- cns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
- ce = axiom_element_create(env, n, SAML_AUDIENCE, cns, &cn);
- axiom_element_set_text(ce, env, (axis2_char_t *)axutil_array_list_get(cond->audiences, env, i), cn);
- }
- }
- return n;
-}
-
-AXIS2_EXTERN saml_condition_t * AXIS2_CALL saml_condition_create(axutil_env_t *env)
-{
- saml_condition_t *cond = AXIS2_MALLOC(env->allocator, sizeof(saml_condition_t));
- if (cond)
- {
- cond->type = SAML_COND_UNSPECFIED;
- cond->cond = NULL;
- }
- return cond;
-}
-
-AXIS2_EXTERN void AXIS2_CALL saml_condition_free(saml_condition_t *cond, axutil_env_t *env)
-{
- if (cond->type == SAML_COND_AUDI_RESTRICTION)
- {
- saml_audi_restriction_cond_free(cond->cond, env);
- }
- AXIS2_FREE(env->allocator, cond);
-}
-
-AXIS2_EXTERN int AXIS2_CALL saml_condition_get_type(saml_condition_t *cond, axiom_node_t *node, axutil_env_t *env)
-{
- return cond->type;
-}
-
-AXIS2_EXTERN int AXIS2_CALL saml_condition_build(saml_condition_t *cond, axiom_node_t *node, axutil_env_t *env)
-{
- axiom_element_t *element = NULL;
- axiom_child_element_iterator_t *ci = NULL;
- axis2_char_t *type_val = NULL;
- axutil_qname_t *type = NULL;
- if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
- {
- return AXIS2_FAILURE;
- }
- type = axutil_qname_create(env, SAML_XML_TYPE, SAML_XSI_NS, SAML_XSI);
- type_val = axiom_element_get_attribute_value(element, env, type);
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_condtion_to_om(saml_condition_t *cond, axiom_node_t *parent, axutil_env_t * env)
-{
- if (cond->type == SAML_COND_AUDI_RESTRICTION)
- {
- return saml_audi_restriction_cond_to_om(cond->cond, parent, env);
- }
- return NULL;
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SAML.h"
+
+AXIS2_EXTERN saml_audi_restriction_cond_t * AXIS2_CALL saml_audi_restriction_cond_create(axutil_env_t *env)
+{
+ saml_audi_restriction_cond_t *arc = AXIS2_MALLOC(env->allocator, sizeof(saml_audi_restriction_cond_t));
+ if (arc)
+ {
+ arc->audiences = axutil_array_list_create(env, SAML_ARRAY_LIST_DEF);
+ if (arc->audiences)
+ {
+ return arc;
+ }
+ AXIS2_FREE(env->allocator, arc);
+ }
+ return NULL;
+}
+
+AXIS2_EXTERN void AXIS2_CALL saml_audi_restriction_cond_free(saml_audi_restriction_cond_t *arc, axutil_env_t * env)
+{
+ int i = 0, size = 0;
+ char *val = NULL;
+ if (arc->audiences)
+ {
+ size = axutil_array_list_size(arc->audiences, env);
+ for (i = 0; i <size; i++)
+ {
+ val = axutil_array_list_get(arc->audiences, env, i);
+ if (val)
+ {
+ AXIS2_FREE(env->allocator, val);
+ }
+ }
+ }
+ AXIS2_FREE(env->allocator, arc);
+}
+
+
+AXIS2_EXTERN int AXIS2_CALL saml_audi_restriction_build(saml_audi_restriction_cond_t *arc, axiom_node_t *node, axutil_env_t *env)
+{
+ axiom_element_t *element = NULL;
+ axiom_child_element_iterator_t *ci = NULL;
+ if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
+ {
+ return AXIS2_FAILURE;
+ }
+ ci = axiom_element_get_child_elements(element, env, node);
+ if (ci)
+ {
+ axiom_node_t *cn = NULL;
+ axiom_element_t *ce = NULL;
+ while(AXIS2_TRUE == axiom_child_element_iterator_has_next(ci, env))
+ {
+ cn = axiom_child_element_iterator_next(ci, env);
+ ce = axiom_node_get_data_element(cn, env);
+ if (0 == axutil_strcmp(SAML_AUDIENCE, axiom_element_get_localname(ce, env)))
+ {
+ axutil_array_list_add(arc->audiences, env, axiom_element_get_text(ce, env, cn));
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+
+AXIS2_EXTERN axiom_node_t *AXIS2_CALL saml_audi_restriction_cond_to_om(saml_audi_restriction_cond_t *cond, axiom_node_t *parent, axutil_env_t * env)
+{
+ int i = 0, size = 0;
+ axiom_element_t *e = NULL, *ce = NULL;
+ axiom_node_t *n = NULL, *cn = NULL;
+ axiom_namespace_t *ns = NULL, *cns = NULL;
+ ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
+ e = axiom_element_create(env, parent, SAML_AUDIENCERESTRICTIONCONDITIONTYPE, ns, &n);
+ if (e && cond->audiences)
+ {
+ size = axutil_array_list_size(cond->audiences, env);
+ for (i = 0; i < size; i++)
+ {
+ cns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
+ ce = axiom_element_create(env, n, SAML_AUDIENCE, cns, &cn);
+ axiom_element_set_text(ce, env, (axis2_char_t *)axutil_array_list_get(cond->audiences, env, i), cn);
+ }
+ }
+ return n;
+}
+
+AXIS2_EXTERN saml_condition_t * AXIS2_CALL saml_condition_create(axutil_env_t *env)
+{
+ saml_condition_t *cond = AXIS2_MALLOC(env->allocator, sizeof(saml_condition_t));
+ if (cond)
+ {
+ cond->type = SAML_COND_UNSPECFIED;
+ cond->cond = NULL;
+ }
+ return cond;
+}
+
+AXIS2_EXTERN void AXIS2_CALL saml_condition_free(saml_condition_t *cond, axutil_env_t *env)
+{
+ if (cond->type == SAML_COND_AUDI_RESTRICTION)
+ {
+ saml_audi_restriction_cond_free(cond->cond, env);
+ }
+ AXIS2_FREE(env->allocator, cond);
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_condition_get_type(saml_condition_t *cond, axiom_node_t *node, axutil_env_t *env)
+{
+ return cond->type;
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_condition_build(saml_condition_t *cond, axiom_node_t *node, axutil_env_t *env)
+{
+ axiom_element_t *element = NULL;
+ axiom_child_element_iterator_t *ci = NULL;
+ axis2_char_t *type_val = NULL;
+ axutil_qname_t *type = NULL;
+ if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT || (element = (axiom_element_t *)axiom_node_get_data_element(node, env)) == NULL)
+ {
+ return AXIS2_FAILURE;
+ }
+ type = axutil_qname_create(env, SAML_XML_TYPE, SAML_XSI_NS, SAML_XSI);
+ type_val = axiom_element_get_attribute_value(element, env, type);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_condtion_to_om(saml_condition_t *cond, axiom_node_t *parent, axutil_env_t * env)
+{
+ if (cond->type == SAML_COND_AUDI_RESTRICTION)
+ {
+ return saml_audi_restriction_cond_to_om(cond->cond, parent, env);
+ }
+ return NULL;
+}
Modified: webservices/rampart/scratch/c/saml/src/id_type.c
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/saml/src/id_type.c?rev=583456&r1=583455&r2=583456&view=diff
==============================================================================
--- webservices/rampart/scratch/c/saml/src/id_type.c (original)
+++ webservices/rampart/scratch/c/saml/src/id_type.c Wed Oct 10 05:40:28 2007
@@ -1,46 +1,46 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "SAML.h"
-#include <axutil_uuid_gen.h>
-
-AXIS2_EXTERN int AXIS2_CALL saml_id_init(saml_id_t *id, axutil_env_t *env)
-{
- id->id = NULL;
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN int AXIS2_CALL saml_id_generate_random_bytes(saml_id_t *id, axutil_env_t *env)
-{
- if (!id->id)
- {
- id->id = axutil_uuid_gen(env);
- if (id->id)
- {
- return AXIS2_SUCCESS;
- }
- }
- return AXIS2_FAILURE;
-}
-
-AXIS2_EXTERN void AXIS2_CALL saml_id_uninit(saml_id_t *id, axutil_env_t *env)
-{
- if (id->id)
- {
- AXIS2_FREE(env->allocator, id->id);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SAML.h"
+#include <axutil_uuid_gen.h>
+
+AXIS2_EXTERN int AXIS2_CALL saml_id_init(saml_id_t *id, axutil_env_t *env)
+{
+ id->id = NULL;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_id_generate_random_bytes(saml_id_t *id, axutil_env_t *env)
+{
+ if (!id->id)
+ {
+ id->id = axutil_uuid_gen(env);
+ if (id->id)
+ {
+ return AXIS2_SUCCESS;
+ }
+ }
+ return AXIS2_FAILURE;
+}
+
+AXIS2_EXTERN void AXIS2_CALL saml_id_uninit(saml_id_t *id, axutil_env_t *env)
+{
+ if (id->id)
+ {
+ AXIS2_FREE(env->allocator, id->id);
+ }
+}