Author: supun
Date: Fri Oct 12 09:49:01 2007
New Revision: 584198

URL: http://svn.apache.org/viewvc?rev=584198&view=rev
Log: (empty)

Modified:
    webservices/rampart/scratch/c/saml/SAML.vcproj
    webservices/rampart/scratch/c/saml/include/SAML.h
    webservices/rampart/scratch/c/saml/src/assertion.c
    webservices/rampart/scratch/c/saml/src/condition.c

Modified: webservices/rampart/scratch/c/saml/SAML.vcproj
URL: 
http://svn.apache.org/viewvc/webservices/rampart/scratch/c/saml/SAML.vcproj?rev=584198&r1=584197&r2=584198&view=diff
==============================================================================
--- webservices/rampart/scratch/c/saml/SAML.vcproj (original)
+++ webservices/rampart/scratch/c/saml/SAML.vcproj Fri Oct 12 09:49:01 2007
@@ -40,8 +40,8 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               
AdditionalIncludeDirectories="E:\axis2c\util\include;E:\axis2c\axiom\include"
-                               
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SAML_EXPORTS;AXIS2_DECLARE_EXPORT"
+                               
AdditionalIncludeDirectories="E:\axis2c\axis2c\util\include;E:\axis2c\axis2c\axiom\include;E:\project\SAML\include"
+                               
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SAML_EXPORTS;AXIS2_DECLARE_EXPORT;_CRT_SECURE_NO_DEPRECATE"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="3"
@@ -63,7 +63,7 @@
                                Name="VCLinkerTool"
                                AdditionalDependencies="axutil.lib axiom.lib"
                                LinkIncremental="2"
-                               
AdditionalLibraryDirectories="E:\axis2c\ides\vc\axis2c\deploy\lib"
+                               
AdditionalLibraryDirectories="E:\axis2c\axis2c\ides\vc\axis2c\deploy\lib"
                                GenerateDebugInformation="true"
                                SubSystem="2"
                                TargetMachine="1"
@@ -202,14 +202,6 @@
                                >
                        </File>
                        <File
-                               RelativePath=".\src\saml_request.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath=".\src\saml_responce.c"
-                               >
-                       </File>
-                       <File
                                RelativePath=".\src\stmt.c"
                                >
                        </File>
@@ -225,10 +217,6 @@
                        >
                        <File
                                RelativePath=".\include\SAML.h"
-                               >
-                       </File>
-                       <File
-                               RelativePath=".\include\saml_req.h"
                                >
                        </File>
                </Filter>

Modified: webservices/rampart/scratch/c/saml/include/SAML.h
URL: 
http://svn.apache.org/viewvc/webservices/rampart/scratch/c/saml/include/SAML.h?rev=584198&r1=584197&r2=584198&view=diff
==============================================================================
--- webservices/rampart/scratch/c/saml/include/SAML.h (original)
+++ webservices/rampart/scratch/c/saml/include/SAML.h Fri Oct 12 09:49:01 2007
@@ -27,67 +27,68 @@
 #define SAML_URI_LEN_MAX    2048
 #define SAML_ARRAY_LIST_DEF    4
 
-#define SAML_PREFIX                        "saml"
-#define SAML_NMSP_URI                    
"urn:oasis:names:tc:SAML:1.0:assertion"
-#define SAML_XML_TYPE                    "type"
-#define SAML_XSI_NS                        
"http://www.w3.org/2001/XMLSchema-instance";
-#define SAML_XSI                        "xsi"
-
-#define SAML_MAJORVERSION                "MajorVersion"
-#define SAML_MINORVERSION                "MinorVersion"
-#define SAML_ASSERTION_ID                "AssertionID"
-#define SAML_ISSUER                        "Issuer"
-#define SAML_ISSUE_INSTANT                "IssueInstant"
-#define SAML_STATEMENT                    "Statement"
-#define SAML_SUBJECT_STATEMENT            "SubjectStatement"
-#define SAML_AUTHENTICATION_STATEMENT    "AuthenticationStatement"
-#define SAML_AUTHORIZATION_DECISION_STATEMENT    
"AuthorizationDecisionStatement"
-#define SAML_ATTRIBUTE_STATEMENT            "AttributeStatement"
-#define SAML_CONDITIONS                    "Conditions"
-#define SAML_ADVICE                        "Advice"
-#define SAML_NOT_BEFORE                    "NotBefore"
+#define SAML_PREFIX                                                    "saml"
+#define SAML_NMSP_URI                                          
"urn:oasis:names:tc:SAML:1.0:assertion"
+#define SAML_XML_TYPE                                          "type"
+#define SAML_XSI_NS                                                    
"http://www.w3.org/2001/XMLSchema-instance";
+#define SAML_XSI                                                       "xsi"
+
+#define SAML_MAJORVERSION                                      "MajorVersion"
+#define SAML_MINORVERSION                                      "MinorVersion"
+#define SAML_ASSERTION_ID                                      "AssertionID"
+#define SAML_ISSUER                                                    "Issuer"
+#define SAML_ISSUE_INSTANT                                     "IssueInstant"
+#define SAML_STATEMENT                                         "Statement"
+#define SAML_SUBJECT_STATEMENT                         "SubjectStatement"
+#define SAML_AUTHENTICATION_STATEMENT          "AuthenticationStatement"
+#define SAML_AUTHORIZATION_DECISION_STATEMENT "AuthorizationDecisionStatement"
+#define SAML_ATTRIBUTE_STATEMENT                       "AttributeStatement"
+#define SAML_CONDITIONS                                                
"Conditions"
+#define SAML_ADVICE                                                    "Advice"
+#define SAML_NOT_BEFORE                                                
"NotBefore"
 #define SAML_NOT_ON_OR_AFTER                "NotOnOrAfter"
+#define SAML_SIGNATURE                                         "Signature"
 
-#define SAML_EMAIL_ADDRESS                "#emailAddress"
-#define SAML_X509_SUBJECT_NAME            "#X509SubjectName"
-#define SAML_WINDOWS_DOMAIN_QUALIFIED_NAME    "#WindowsDomainQualifiedName"
+#define SAML_EMAIL_ADDRESS                                     "#emailAddress"
+#define SAML_X509_SUBJECT_NAME                         "#X509SubjectName"
+#define SAML_WINDOWS_DOMAIN_QUALIFIED_NAME  "#WindowsDomainQualifiedName"
 
-#define SAML_NAME_QUALIFIER                "NameQualifier"
-#define SAML_FORMAT                        "Format"
+#define SAML_NAME_QUALIFIER                                    "NameQualifier"
+#define SAML_FORMAT                                                    "Format"
 #define SAML_NAME_IDENTIFIER                "NameIdentifier"
-#define SAML_SUBJECT_CONFIRMATION        "SubjectConfirmation"
+#define SAML_SUBJECT_CONFIRMATION                      "SubjectConfirmation"
 #define SAML_CONFIRMATION_METHOD            "ConfirmationMethod"
-#define SAML_SUBJECT_CONFIRMATION_DATA    "SubjectConfirmationData"
-#define SAML_KEY_INFO                    "KeyInfo"
-#define SAML_SUBJECT                    "Subject"
-
-#define SAML_AUDIENCE                    "Audience"
-#define SAML_AUDIENCE_RESTRICTION_CONDITION_TYPE    
"AudienceRestrictionConditionType" 
-
-#define SAML_AUTHENTICATION_METHOD        "AuthenticationMethod"
-#define SAML_AUTHENTICATION_INSTANT        "AuthenticationInstant"
-#define SAML_IP_ADDRESS                    "IPAddress" 
+#define SAML_SUBJECT_CONFIRMATION_DATA         "SubjectConfirmationData"
+#define SAML_KEY_INFO                                          "KeyInfo"
+#define SAML_SUBJECT                                           "Subject"
+
+#define SAML_AUDIENCE                                          "Audience"
+#define SAML_AUDIENCE_RESTRICTION_CONDITION_TYPE 
"AudienceRestrictionConditionType" 
+
+#define SAML_AUTHENTICATION_METHOD                     "AuthenticationMethod"
+#define SAML_AUTHENTICATION_INSTANT                    "AuthenticationInstant"
+#define SAML_IP_ADDRESS                                                
"IPAddress" 
 #define SAML_DNS_ADDRESS                    "DNSAddress"
 #define SAML_SUBJEC_LOCALITY                "SubjectLocality"
-#define SAML_AUTHORITY_BINDING            "AuthorityBinding"
-#define SAML_AUTHORITY_KIND                "AuthorityKind"
-#define SAML_LOCATION                    "Location"
-#define SAML_BINDING                    "Binding"
-
-#define SAML_RESOURCE                    "Resource"
-#define SAML_DECISION                    "Decision"    
-#define SAML_ACTION                        "Action"
-#define SAML_NAMESPACE                    "Namespace"
-#define SAML_ASSERTION_ID_REFERENCE        "AssertionIDReference" 
-#define SAML_ASSERTION                    "Assertion"    
-#define SAML_ACTION                        "Action"
-#define SAML_EVIDENCE                    "Evidence"
+#define SAML_AUTHORITY_BINDING                         "AuthorityBinding"
+#define SAML_AUTHORITY_KIND                                    "AuthorityKind"
+#define SAML_LOCATION                                          "Location"
+#define SAML_BINDING                                           "Binding"
+
+#define SAML_RESOURCE                                          "Resource"
+#define SAML_DECISION                                          "Decision"    
+#define SAML_ACTION                                                    "Action"
+#define SAML_NAMESPACE                                         "Namespace"
+#define SAML_ASSERTION_ID_REFERENCE                    "AssertionIDReference" 
+#define SAML_ASSERTION                                         "Assertion"    
+#define SAML_ACTION                                                    "Action"
+#define SAML_EVIDENCE                                          "Evidence"
 
-#define SAML_ATTRIBUTE_NAME                "AttributeName"
+#define SAML_ATTRIBUTE_NAME                                    "AttributeName"
 #define SAML_ATTRIBUTE_NAMESPACE            "AttributeNamespace"
 #define SAML_ATTRIBUTE_VALUE                "AttributeValue"
-#define SAML_ATTRIBUTE                    "Attribute"
-#define SAML_ATTRIBUTE_DESIGNATOR        "AttributeDesignator"
+#define SAML_ATTRIBUTE                                         "Attribute"
+#define SAML_ATTRIBUTE_DESIGNATOR                      "AttributeDesignator"
 
 typedef struct saml_assertion_s saml_assertion_t;
 
@@ -342,17 +343,7 @@
     /* An XML Signature that authenticates the assertion */
     saml_signature_t *signature;
 
-    /* A subject statement defined in an extension schema */
-    saml_subject_stmt_t *sub_stmt;
-
-    /* An authentication statement */
-    saml_auth_stmt_t *auth_stmt;    
-
-    /* An authorization decision statement */
-    saml_auth_desicion_stmt_t *auth_des_stmt; 
-
-    /* An attribute statement */
-    saml_attr_stmt_t *attr_stmt;
+       axutil_array_list_t *statements;
 };
 
 
@@ -361,6 +352,11 @@
 AXIS2_EXTERN int saml_assertion_build(saml_assertion_t *assertion, 
axiom_node_t *node, axutil_env_t *env);
 AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_assertion_to_om(saml_assertion_t 
*assertion, axiom_node_t *node, axutil_env_t *env);
 
+AXIS2_EXTERN saml_stmt_t * AXIS2_CALL saml_stmt_create(axutil_env_t *env);
+AXIS2_EXTERN void AXIS2_CALL saml_stmt_free(saml_stmt_t *stmt, axutil_env_t 
*env);
+AXIS2_EXTERN int AXIS2_CALL saml_stmt_build(saml_stmt_t *stmt, axiom_node_t 
*node, axutil_env_t *env);
+AXIS2_EXTERN int AXIS2_CALL saml_stmt_to_om(saml_stmt_t *stmt, axiom_node_t 
*parent, axutil_env_t *env);
+
 AXIS2_EXTERN int AXIS2_CALL saml_id_init(saml_id_t *id, axutil_env_t *env);
 AXIS2_EXTERN int AXIS2_CALL saml_id_generate_random_bytes(saml_id_t *id, 
axutil_env_t *env);
 AXIS2_EXTERN void AXIS2_CALL saml_id_uninit(saml_id_t *id, axutil_env_t *env);
@@ -403,5 +399,5 @@
 AXIS2_EXTERN saml_condition_t * AXIS2_CALL saml_condition_create(axutil_env_t 
*env);
 AXIS2_EXTERN void AXIS2_CALL saml_condition_free(saml_condition_t *cond, 
axutil_env_t *env);
 AXIS2_EXTERN int AXIS2_CALL saml_condition_build(saml_condition_t *cond, 
axiom_node_t *node, axutil_env_t *env);
-AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_condtion_to_om(saml_condition_t 
*cond, axiom_node_t *parent, axutil_env_t * env);
+AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_condition_to_om(saml_condition_t 
*cond, axiom_node_t *parent, axutil_env_t * env);
 #endif 

Modified: webservices/rampart/scratch/c/saml/src/assertion.c
URL: 
http://svn.apache.org/viewvc/webservices/rampart/scratch/c/saml/src/assertion.c?rev=584198&r1=584197&r2=584198&view=diff
==============================================================================
--- webservices/rampart/scratch/c/saml/src/assertion.c (original)
+++ webservices/rampart/scratch/c/saml/src/assertion.c Fri Oct 12 09:49:01 2007
@@ -20,11 +20,86 @@
 
 AXIS2_EXTERN int AXIS2_CALL saml_assertion_init(saml_assertion_t *assertion, 
axutil_env_t *env)
 {              
+       assertion->major_version = NULL;
+       assertion->minor_version = NULL;
+       assertion->not_before = NULL;
+       assertion->not_on_or_after = NULL;
+       assertion->assertion_id = NULL;
+       assertion->conditions = NULL;
+       assertion->statements = axutil_array_list_create(env, 
SAML_ARRAY_LIST_DEF * 2);
+       assertion->issuer = NULL;
+       assertion->issue_instant = NULL;
+       assertion->signature = NULL;
        return AXIS2_SUCCESS;
 }
 
 AXIS2_EXTERN int AXIS2_CALL saml_assertion_uninit(saml_assertion_t *assertion, 
axutil_env_t *env)
 {      
+       int i = 0, size = 0;
+       if (assertion->major_version)
+       {
+               AXIS2_FREE(env->allocator, assertion->major_version);
+               assertion->major_version = NULL;
+       }
+       if (assertion->minor_version)
+       {
+               AXIS2_FREE(env->allocator, assertion->minor_version);
+               assertion->minor_version = NULL;
+       }
+       if (assertion->not_before)
+       {
+               axutil_date_time_free(assertion->not_before, env);
+               assertion->not_before = NULL;
+       }
+       if (assertion->not_on_or_after)
+       {
+               axutil_date_time_free(assertion->not_on_or_after, env);
+               assertion->not_on_or_after = NULL;
+       }
+       if (assertion->issue_instant)
+       {
+               axutil_date_time_free(assertion->issue_instant, env);
+               assertion->issue_instant = NULL;
+       }
+       if (assertion->assertion_id)
+       {
+               AXIS2_FREE(env->allocator, assertion->assertion_id);
+               assertion->assertion_id = NULL;
+       }
+       if (assertion->conditions)
+       {
+               saml_condition_t *cond = NULL;
+               size = axutil_array_list_size(assertion->conditions, env);
+               for (i = 0; i < size; i++)
+               {
+                       cond = axutil_array_list_get(assertion->conditions, 
env, i);
+                       if (cond)
+                       {
+                               saml_condition_free(cond, env);
+                       }
+               }
+       }
+       if (assertion->statements)
+       {
+               saml_stmt_t *stmt = NULL;
+               size = axutil_array_list_size(assertion->statements, env);
+               for (i = 0; i < size; i++)
+               {
+                       stmt = axutil_array_list_get(assertion->statements, 
env, i);
+                       if (stmt)
+                       {
+                               saml_stmt_free(stmt, env);
+                       }
+               }
+       }
+       if (assertion->issue_instant)
+       {
+               AXIS2_FREE(env->allocator, assertion->issue_instant);
+               assertion->issue_instant = NULL;
+       }
+       if (assertion->signature)
+       {
+       }
        return AXIS2_SUCCESS;
 }
 
@@ -33,10 +108,31 @@
        axiom_element_t *element = NULL;        
        axiom_child_element_iterator_t *ci = NULL;
        axis2_char_t *attr_val = NULL;
+       saml_stmt_t *stmt = NULL;
+       saml_condition_t *cond = 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 (!(assertion->major_version = 
axiom_element_get_attribute_value_by_name(element, env, SAML_MAJORVERSION)) ||
+               !(assertion->minor_version = 
axiom_element_get_attribute_value_by_name(element, env, SAML_MINORVERSION)) ||
+               !(assertion->assertion_id = 
axiom_element_get_attribute_value_by_name(element, env, SAML_ASSERTION_ID)) ||
+               !(assertion->issuer = 
axiom_element_get_attribute_value_by_name(element, env, SAML_ISSUER)))
+       {
+               return AXIS2_FAILURE;
+       }
+       
+       assertion->issue_instant = axutil_date_time_create(env);
+       attr_val = axiom_element_get_attribute_value_by_name(element, env, 
SAML_ISSUE_INSTANT);
+       if (attr_val)
+       {
+               
axutil_date_time_deserialize_date_time(assertion->issue_instant, env, attr_val);
+       }
+       else
+       {
+               return AXIS2_FAILURE;
+       }
+
        if ((ci = axiom_element_get_child_elements(element, env, node)) != NULL)
        {
                axiom_element_t *ce = NULL;
@@ -45,105 +141,335 @@
                axiom_node_t *ccn = NULL;
                axiom_child_element_iterator_t *cci = 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 (axutil_strcmp(SAML_STATEMENT, 
axiom_element_get_localname(ce, env)))
+                       if (axutil_strcmp(axiom_element_get_localname(ce, env), 
SAML_CONDITIONS))
                        {
-                               
-                       }
-                       else if (axutil_strcmp(SAML_SUBJECT_STATEMENT, 
axiom_element_get_localname(ce, env)))
-                       {
-                               if ((assertion->sub_stmt = 
saml_subject_stmt_create(env)) != NULL)
+                               attr_val = 
axiom_element_get_attribute_value_by_name(ce, env, SAML_NOT_BEFORE);
+                               if (attr_val)
                                {
-                                       
saml_subject_stmt_build(assertion->sub_stmt, cn, env);
+                                       assertion->not_before = 
axutil_date_time_create(env);
+                                       
axutil_date_time_deserialize_date_time(assertion->not_before, env, attr_val);
                                }
-                       }
-                       else if (axutil_strcmp(SAML_AUTHENTICATION_STATEMENT, 
axiom_element_get_localname(ce, env)))
-                       {
-                               if ((assertion->auth_stmt = 
saml_auth_stmt_create(env)) != NULL)
+                               attr_val = 
axiom_element_get_attribute_value_by_name(ce, env, SAML_NOT_ON_OR_AFTER);
+                               if (attr_val)
                                {
-                                       
saml_auth_stmt_build(assertion->auth_stmt, cn, env);
+                                       assertion->not_on_or_after = 
axutil_date_time_create(env);
+                                       
axutil_date_time_deserialize_date_time(assertion->not_before, env, attr_val);
                                }                               
-                       }
-                       else if 
(axutil_strcmp(SAML_AUTHORIZATION_DECISION_STATEMENT, 
axiom_element_get_localname(ce, env)))
-                       {
-                               if ((assertion->auth_des_stmt = 
saml_auth_desicion_stmt_create(env)) != NULL)
+                               if ((cci = 
axiom_element_get_child_elements(element, env, node)) != NULL)
                                {
-                                       
saml_auth_desicion_stmt_build(assertion->auth_des_stmt, cn, env);
+                                       assertion->conditions = 
axutil_array_list_create(env, SAML_ARRAY_LIST_DEF);
+                                       while(AXIS2_TRUE == 
axiom_child_element_iterator_has_next(cci, env))
+                                       {
+                                               ccn = 
axiom_child_element_iterator_next(ci, env);                                     
          
+                                               cond = 
saml_condition_create(env);
+                                               if(saml_condition_build(cond, 
ccn, env))
+                                               {
+                                                       
axutil_array_list_add(assertion->conditions, env, cond);
+                                               }
+                                               else
+                                               {
+                                                       
saml_condition_free(cond, env);
+                                               }
+                                       }
+                                       axiom_child_element_iterator_free(cci, 
env);
                                }
                        }
-                       else if (axutil_strcmp(SAML_ATTRIBUTE_STATEMENT, 
axiom_element_get_localname(ce, env)))
-                       {
-                               if ((assertion->attr_stmt = 
saml_attr_stmt_create(env)) != NULL)
-                               {
-                                       
saml_attr_stmt_build(assertion->attr_stmt, cn, env);
-                               }
+                       else if (axutil_strcmp(axiom_element_get_localname(ce, 
env), SAML_ADVICE))
+                       {       
+                               
+                       }
+                       else if (axutil_strcmp(axiom_element_get_localname(ce, 
env), SAML_SIGNATURE))
+                       {       
+                                                                               
                        }
-                       else if (axutil_strcmp(SAML_CONDITIONS, 
axiom_element_get_localname(ce, env)))
+                       else 
                        {
-                               axutil_qname_t *qn = axutil_qname_create(env, 
SAML_NOT_BEFORE, SAML_NMSP_URI, SAML_PREFIX);
-                               if (qn)
+                               if ((cci = 
axiom_element_get_child_elements(element, env, node)) != NULL)
                                {
-                                       attr_val = 
axiom_element_get_attribute_value(ce, env, qn); 
-                                       if (attr_val)
-                                       {
-                                               assertion->not_before = 
axutil_date_time_create(env);
-                                               
axutil_date_time_deserialize_date_time(assertion->not_before, env, attr_val);
-                                       }                                       
                        
-                                       axutil_qname_free(qn, env);
-                               }
-                               qn = axutil_qname_create(env, 
SAML_NOT_ON_OR_AFTER, SAML_NMSP_URI, SAML_PREFIX);
-                               if (qn)
-                               {
-                                       attr_val = 
axiom_element_get_attribute_value(ce, env, qn); 
-                                       if (attr_val)
-                                       {
-                                               assertion->not_on_or_after = 
axutil_date_time_create(env);
-                                               
axutil_date_time_deserialize_date_time(assertion->not_on_or_after, env, 
attr_val);
-                                       }
-                                       axutil_qname_free(qn, env);
-                               }
-                               if ((cci = axiom_element_get_child_elements(ce, 
env, cn)) != NULL)
-                               {       
-                                       saml_condition_t *cond = NULL;
                                        while(AXIS2_TRUE == 
axiom_child_element_iterator_has_next(cci, env))
                                        {
-                                               ccn = 
axiom_child_element_iterator_next(cci, env);
-                                               cce = 
axiom_node_get_data_element(ccn, env);            
-                                               if (cond == NULL)
+                                               ccn = 
axiom_child_element_iterator_next(ci, env);                                     
          
+                                               stmt = saml_stmt_create(env);
+                                               if(saml_stmt_build(stmt, ccn, 
env))
                                                {
-                                                       cond = 
saml_condition_create(env);
-                                               }                               
                
-                                               if (saml_condition_build(cond, 
ccn, env) == AXIS2_SUCCESS)
+                                                       
axutil_array_list_add(assertion->statements, env, stmt);
+                                               }
+                                               else
                                                {
-                                                       
axutil_array_list_add(assertion->conditions, env, cond);
-                                                       cond = NULL;
+                                                       saml_stmt_free(stmt, 
env);
                                                }
                                        }
+                                       axiom_child_element_iterator_free(cci, 
env);
+                               }                               
+                       }
+               }
+       }       
+       return AXIS2_SUCCESS;
+}
+
+
+AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_assertion_to_om(saml_assertion_t 
*assertion, axiom_node_t *parent, axutil_env_t *env)
+{
+       int i = 0, size = 0;
+       axiom_element_t *e = NULL, *ce = NULL, *cce = NULL;
+       axiom_node_t *n = NULL, *cn = NULL, *ccn = NULL;
+       axiom_attribute_t *attr = NULL;
+       axiom_namespace_t *ns = NULL;   
+       saml_condition_t *cond = NULL;
+       saml_stmt_t *stmt = NULL;
+       ns = axiom_namespace_create(env, SAML_NMSP_URI, SAML_PREFIX);
+       e = axiom_element_create(env, parent, SAML_ASSERTION, ns, &n);
+       if (e)
+       {
+               if (assertion->major_version && assertion->minor_version && 
assertion->assertion_id && assertion->issuer && assertion->issue_instant)
+               {
+                       attr = axiom_attribute_create(env, SAML_MAJORVERSION, 
assertion->major_version, NULL);
+                       axiom_element_add_attribute(e, env, attr, n);
+                       attr = axiom_attribute_create(env, SAML_MINORVERSION, 
assertion->minor_version, NULL);
+                       axiom_element_add_attribute(e, env, attr, n);
+                       attr = axiom_attribute_create(env, SAML_ASSERTION_ID, 
assertion->assertion_id, NULL);
+                       axiom_element_add_attribute(e, env, attr, n);
+                       attr = axiom_attribute_create(env, SAML_ISSUER, 
assertion->issuer, NULL);
+                       axiom_element_add_attribute(e, env, attr, n);
+                       attr = axiom_attribute_create(env, SAML_ISSUE_INSTANT, 
axutil_date_time_serialize_date_time(assertion->issue_instant, env), NULL);
+                       axiom_element_add_attribute(e, env, attr, n);           
                                
+               }               
+               else
+               {
+                       axiom_element_free(e, env);
+                       return NULL;
+               }
+               if (assertion->conditions)
+               {                                               
+                       ce = axiom_element_create(env, parent, SAML_CONDITIONS, 
ns, &cn);
+                       if (ce)
+                       {
+                               if (assertion->not_before)
+                               {
+                                       attr = axiom_attribute_create(env, 
SAML_NOT_BEFORE, axutil_date_time_serialize_date_time(assertion->not_before, 
env), NULL);
+                                       axiom_element_add_attribute(ce, env, 
attr, cn);                                         
+                               }
+                               if (assertion->not_on_or_after)
+                               {
+                                       attr = axiom_attribute_create(env, 
SAML_NOT_ON_OR_AFTER, 
axutil_date_time_serialize_date_time(assertion->not_on_or_after, env), NULL);
+                                       axiom_element_add_attribute(ce, env, 
attr, cn);                                         
+                               }
+                               size = 
axutil_array_list_size(assertion->conditions, env);
+                               for (i = 0; i < size; i++)
+                               {
+                                       cond = 
axutil_array_list_get(assertion->conditions, env, i);
                                        if (cond)
                                        {
-                                               saml_condition_free(cond, env);
+                                               saml_condition_to_om(cond, cn, 
env);
                                        }
                                }
-
                        }
-                       else if (axutil_strcmp(SAML_ADVICE, 
axiom_element_get_localname(ce, env)))
+               }
+               if (assertion->statements)
+               {                                                               
        
+                       size = axutil_array_list_size(assertion->statements, 
env);
+                       for (i = 0; i < size; i++)
                        {
-                                                               
-                       }
-                       else
+                               cond = 
axutil_array_list_get(assertion->statements, env, i);
+                               if (cond)
+                               {
+                                       saml_stmt_to_om(stmt, n, env);
+                               }
+                       }               
+               }
+               if (assertion->signature)
+               {
+
+               }               
+       }       
+       return n;
+}
+
+AXIS2_EXTERN axutil_array_list_t * AXIS2_CALL 
saml_assetion_get_conditions(saml_assertion_t *a, axutil_env_t *env)
+{
+       return a->conditions;;
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_assertion_set_conditions(saml_assertion_t *a, 
axutil_env_t *env, axutil_array_list_t *list)
+{
+       int i = 0, size = 0;
+       saml_condition_t *cond = NULL;
+       if (a->conditions)
+       {
+               size = axutil_array_list_size(a->conditions, env);
+               for (i = 0; i < size; i++)
+               {
+                       cond =  axutil_array_list_get(a->conditions, env, i);
+                       if (cond)
                        {
+                               saml_condition_free(cond, env);
+                       }
+               }
+               axutil_array_list_free(a->conditions, env);
+               a->conditions = list;
+       }
+       else
+       {
+               a->conditions = list;
+       }
+       return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_assertion_add_condition(saml_assertion_t *a, 
axutil_env_t *env, saml_condition_t *cond)
+{
+       if (!a->conditions)
+       {
+               a->conditions = axutil_array_list_create(env, 
SAML_ARRAY_LIST_DEF);
+       }
+       axutil_array_list_add(a->conditions, env, cond);
+       return AXIS2_SUCCESS;
+}
 
+AXIS2_EXTERN int AXIS2_CALL saml_assertion_remove_condition(saml_assertion_t 
*a, axutil_env_t *env, int index)
+{
+       saml_condition_t *cond = NULL;
+       if (a->conditions && axutil_array_list_size(a->conditions, env) > index)
+       {
+               cond = axutil_array_list_remove(a->conditions, env, index);     
                
+               if (cond)
+               {
+                       saml_condition_free(cond, env);
+               }
+               return AXIS2_SUCCESS;           
+       }
+       else
+       {
+               return AXIS2_FAILURE;
+       }
+}
+
+AXIS2_EXTERN axutil_array_list_t * AXIS2_CALL 
saml_assertion_get_statements(saml_assertion_t *a, axutil_env_t *env)
+{
+       return a->statements;
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_assertion_set_statements(saml_assertion_t *a, 
axutil_env_t *env, axutil_array_list_t *list)
+{
+       int i = 0, size = 0;
+       saml_stmt_t *stmt = NULL;
+       if (a->statements)
+       {
+               size = axutil_array_list_size(a->statements, env);
+               for (i = 0; i < size; i++)
+               {
+                       stmt =  axutil_array_list_get(a->statements, env, i);
+                       if (stmt)
+                       {
+                               saml_stmt_free(stmt, env);
                        }
                }
-       }       
+               axutil_array_list_free(a->statements, env);
+               a->statements = list;
+       }
+       else
+       {
+               a->statements = list;
+       }
        return AXIS2_SUCCESS;
 }
 
+AXIS2_EXTERN int AXIS2_CALL saml_assertion_add_statement(saml_assertion_t *a, 
axutil_env_t *env, saml_stmt_t *stmt)
+{
+       if (!a->statements)
+       {
+               a->statements = axutil_array_list_create(env, 
SAML_ARRAY_LIST_DEF * 2);
+       }
+       axutil_array_list_add(a->statements, env, stmt);
+       return AXIS2_SUCCESS;
+}
 
-AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_assertion_to_om(saml_assertion_t 
*assertion, axiom_node_t *node, axutil_env_t *env)
+AXIS2_EXTERN int AXIS2_CALL saml_assertion_remove_statement(saml_assertion_t 
*a, axutil_env_t *env, int index)
 {
+       saml_stmt_t *stmt = NULL;
+       if (a->statements && axutil_array_list_size(a->statements, env) > index)
+       {
+               stmt = axutil_array_list_remove(a->statements, env, index);     
                
+               if (stmt)
+               {
+                       saml_stmt_free(stmt, env);
+               }
+               return AXIS2_SUCCESS;           
+       }
+       else
+       {
+               return AXIS2_FAILURE;
+       }
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_assertion_set_minor_version(saml_assertion_t 
*a, axutil_env_t *env, int version)
+{
+       if (a->minor_version)
+       {
+               AXIS2_FREE(env->allocator, a->minor_version);
+       }
+       sprintf(a->minor_version, "%d", version);
+       return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_assertion_set_issuer(saml_assertion_t *a, 
axutil_env_t *env, axis2_char_t *issuer)
+{
+       if (a->issuer)
+       {
+               AXIS2_FREE(env->allocator, a->issuer);
+       }
+       a->issuer = issuer;
+       return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN int AXIS2_CALL saml_assertion_set_issue_instant(saml_assertion_t 
*a, axutil_env_t *env, axutil_date_time_t *instant)
+{
+       if (a->issue_instant)
+       {
+               axutil_date_time_free(a->issue_instant, env);
+       }
+       a->issue_instant = instant;
+       return AXIS2_SUCCESS;
+}
 
-       return NULL;
+AXIS2_EXTERN int AXIS2_CALL saml_assertion_set_not_before(saml_assertion_t *a, 
axutil_env_t *env, axutil_date_time_t *time)
+{
+       if (a->not_before)
+       {
+               axutil_date_time_free(a->not_before, env);
+       }
+       a->not_before = time;
+       return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN int AXIS2_CALL 
saml_assertion_set_not_on_or_after(saml_assertion_t *a, axutil_env_t *env, 
axutil_date_time_t *time)
+{
+       if (a->not_on_or_after)
+       {
+               axutil_date_time_free(a->not_on_or_after, env);
+       }
+       a->not_on_or_after = time;
+       return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_char_t * AXIS2_CALL 
saml_assertion_get_issuer(saml_assertion_t *a, axutil_env_t *env)
+{
+       return a->issuer;
+}
+
+AXIS2_EXTERN axutil_date_time_t * AXIS2_CALL 
saml_assertion_get_issue_instant(saml_assertion_t *a, axutil_env_t *env)
+{
+       return a->issue_instant;
+}
+
+AXIS2_EXTERN axutil_date_time_t * AXIS2_CALL 
saml_assertion_get_not_before(saml_assertion_t *a, axutil_env_t *env)
+{
+       return a->not_before;
+}
+
+AXIS2_EXTERN axutil_date_time_t * AXIS2_CALL 
saml_assertion_get_not_on_or_after(saml_assertion_t *a, axutil_env_t *env)
+{
+       return a->not_on_or_after;
 }

Modified: webservices/rampart/scratch/c/saml/src/condition.c
URL: 
http://svn.apache.org/viewvc/webservices/rampart/scratch/c/saml/src/condition.c?rev=584198&r1=584197&r2=584198&view=diff
==============================================================================
--- webservices/rampart/scratch/c/saml/src/condition.c (original)
+++ webservices/rampart/scratch/c/saml/src/condition.c Fri Oct 12 09:49:01 2007
@@ -144,7 +144,7 @@
        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)
+AXIS2_EXTERN axiom_node_t * AXIS2_CALL saml_condition_to_om(saml_condition_t 
*cond, axiom_node_t *parent, axutil_env_t * env)
 {      
        if (cond->type == SAML_COND_AUDI_RESTRICTION)
        {


Reply via email to