You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ka...@apache.org on 2006/09/12 07:15:40 UTC

svn commit: r442454 - in /webservices/axis2/trunk/c/rampart: include/oxs_axiom.h src/omxmlsec/axiom.c src/util/rampart_crypto_util.c src/util/timestamp_token.c src/util/username_token.c

Author: kaushalye
Date: Mon Sep 11 22:15:39 2006
New Revision: 442454

URL: http://svn.apache.org/viewvc?view=rev&rev=442454
Log:
Commititng changes made in UsernameToken and Timestamp

Modified:
    webservices/axis2/trunk/c/rampart/include/oxs_axiom.h
    webservices/axis2/trunk/c/rampart/src/omxmlsec/axiom.c
    webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c
    webservices/axis2/trunk/c/rampart/src/util/timestamp_token.c
    webservices/axis2/trunk/c/rampart/src/util/username_token.c

Modified: webservices/axis2/trunk/c/rampart/include/oxs_axiom.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_axiom.h?view=diff&rev=442454&r1=442453&r2=442454
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_axiom.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_axiom.h Mon Sep 11 22:15:39 2006
@@ -40,6 +40,13 @@
 typedef struct axiom_document_t oxs_axiom_document, *oxs_axiom_document_ptr;
 typedef struct axiom_node_t oxs_axiom_node, *oxs_axiom_node_ptr;
 
+AXIS2_EXTERN int AXIS2_CALL
+oxs_axiom_get_number_of_children_with_qname(const axis2_env_t *env,
+                                         axiom_node_t* parent,
+                                         axis2_char_t* local_name,
+                                         axis2_char_t* ns_uri,
+                                         axis2_char_t* prefix);
+
 
 AXIS2_EXTERN axiom_node_t* AXIS2_CALL
 oxs_axiom_get_first_child_node_by_name(const axis2_env_t *env,

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/axiom.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/axiom.c?view=diff&rev=442454&r1=442453&r2=442454
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/axiom.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/axiom.c Mon Sep 11 22:15:39 2006
@@ -25,6 +25,40 @@
 #include <axiom_document.h>
 #include <axiom_stax_builder.h>
 
+AXIS2_EXTERN int AXIS2_CALL
+oxs_axiom_get_number_of_children_with_qname(const axis2_env_t *env,
+                                         axiom_node_t* parent, 
+                                         axis2_char_t* local_name, 
+                                         axis2_char_t* ns_uri,
+                                         axis2_char_t* prefix)
+{
+
+    axis2_qname_t *qname = NULL;
+    axiom_element_t *parent_ele = NULL;
+    axiom_children_qname_iterator_t *qname_iter = NULL;
+    axiom_node_t *temp_node = NULL;
+    int counter = 0;
+
+    qname = axis2_qname_create(env, local_name, ns_uri, prefix);
+    parent_ele = AXIOM_NODE_GET_DATA_ELEMENT(parent,env);
+    if(!parent_ele){
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+            "Cannot find %s element", local_name);
+        return -1;
+    }
+
+    qname_iter = AXIOM_ELEMENT_GET_CHILDREN_WITH_QNAME(parent_ele, env, qname, parent);
+    while(AXIS2_TRUE == AXIOM_CHILDREN_QNAME_ITERATOR_HAS_NEXT(qname_iter ,env))
+    {
+        
+        counter++;
+        temp_node = AXIOM_CHILDREN_QNAME_ITERATOR_NEXT(qname_iter, env);
+    }
+
+    return counter;
+}
+
+
 AXIS2_EXTERN axiom_node_t* AXIS2_CALL
 oxs_axiom_get_first_child_node_by_name(const axis2_env_t *env, 
                                          axiom_node_t* parent, 
@@ -39,12 +73,12 @@
     
     qname = axis2_qname_create(env, local_name, ns_uri, prefix);
     parent_ele = AXIOM_NODE_GET_DATA_ELEMENT(parent,env);
-    /*Get the child*/
     if(!parent_ele){
-        oxs_error(ERROR_LOCATION, OXS_ERROR_DECRYPT_FAILED,
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
             "Cannot find %s element", local_name);
         return NULL;
     }
+    /*Get the child*/
     ele = AXIOM_ELEMENT_GET_FIRST_CHILD_WITH_QNAME(parent_ele, env, qname, parent, &node  );
     
     AXIS2_QNAME_FREE(qname, env);
@@ -52,7 +86,7 @@
 
     parent_name = AXIOM_NODE_TO_STRING(parent, env);
     if(!node){
-        oxs_error(ERROR_LOCATION, OXS_ERROR_DECRYPT_FAILED,
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
             "Cannot find child %s of %s", local_name, parent_name);
         return NULL;
     }
@@ -151,5 +185,4 @@
     
 
 }
-
 

Modified: webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c?view=diff&rev=442454&r1=442453&r2=442454
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c Mon Sep 11 22:15:39 2006
@@ -38,10 +38,20 @@
    axis2_char_t *result = NULL;
    char* input = NULL;
    axis2_char_t* encoded_str=NULL;
-
-   input= AXIS2_MALLOC(env->allocator, AXIS2_STRLEN(nonce) + 
-          AXIS2_STRLEN(created) + AXIS2_STRLEN(password) + 1);
-   sprintf(input, "%s%s%s", nonce, created, password);
+    
+   if((!nonce) && (!created)){/*If both nonce and created are omitted*/
+        input= AXIS2_MALLOC(env->allocator,  AXIS2_STRLEN(password) + 1);
+        sprintf(input, "%s",  password);   
+   }else if(!nonce){/*If nonce is omitted*/
+        input= AXIS2_MALLOC(env->allocator, AXIS2_STRLEN(created) + AXIS2_STRLEN(password) + 1);
+        sprintf(input, "%s%s",  created, password);
+   }else  if(!created){/*If created is omitted*/
+        input= AXIS2_MALLOC(env->allocator, AXIS2_STRLEN(nonce) + AXIS2_STRLEN(password) + 1);
+        sprintf(input, "%s%s",  nonce, password);
+   }else{/*If all nonce, created and password are present*/
+        input= AXIS2_MALLOC(env->allocator, AXIS2_STRLEN(nonce) + AXIS2_STRLEN(created) + AXIS2_STRLEN(password) + 1);
+        sprintf(input, "%s%s%s", nonce, created, password);
+   }
    result = AXIS2_MALLOC(env->allocator, SHA_DIGEST_LENGTH + 1);
     
    SHA1((unsigned char*)input,SHA_DIGEST_LENGTH,(unsigned char*)result);

Modified: webservices/axis2/trunk/c/rampart/src/util/timestamp_token.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/timestamp_token.c?view=diff&rev=442454&r1=442453&r2=442454
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/timestamp_token.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/timestamp_token.c Mon Sep 11 22:15:39 2006
@@ -179,6 +179,15 @@
     axiom_node_t *created_node = NULL, *expires_node = NULL;
     axis2_char_t *created_val = NULL, *expires_val = NULL, *current_val = NULL;    
 
+    /*TODO*/
+    /* 
+    R3227   A SECURITY_HEADER MUST NOT contain more than one TIMESTAMP
+    R3203   A TIMESTAMP MUST contain exactly one CREATED
+    R3224   Any TIMESTAMP MUST NOT contain more than one EXPIRES.    
+    R3221   Any TIMESTAMP containing an EXPIRES MUST contain a CREATED that preceeds its sibling EXPIRES.
+    R3222   Any TIMESTAMP MUST NOT contain anything other than CREATED or EXPIRES elements
+    */
+
     ts_ele = AXIOM_NODE_GET_DATA_ELEMENT(ts_node, env);
     
     if(!ts_ele)

Modified: webservices/axis2/trunk/c/rampart/src/util/username_token.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/username_token.c?view=diff&rev=442454&r1=442453&r2=442454
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/username_token.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/username_token.c Mon Sep 11 22:15:39 2006
@@ -279,9 +279,13 @@
         if(0 == AXIS2_STRCMP(password_type, RAMPART_PASSWORD_DIGEST) )
         {   
             axiom_namespace_t *dec_ns = NULL;
-          
+            #if 1 
             nonce_val = rampart_generate_nonce(env) ;
             created_val = rampart_generate_time(env,0);
+            #else
+                nonce_val = NULL;
+                created_val = NULL;
+            #endif
             digest_val = rampart_crypto_sha1(env, nonce_val, created_val, password);
 
             pw_ele = axiom_element_create (env, ut_node, RAMPART_SECURITY_USERNAMETOKEN_PASSWORD, sec_ns_obj,
@@ -304,7 +308,7 @@
                                 om_attr, pw_node);
 
              }                 
-            
+            #if 1  
             nonce_ele = axiom_element_create (env, ut_node, RAMPART_SECURITY_USERNAMETOKEN_NONCE, sec_ns_obj,
                                              &nonce_node);
             if(NULL != nonce_ele)
@@ -314,8 +318,12 @@
                 dec_ns = AXIOM_ELEMENT_FIND_DECLARED_NAMESPACE(nonce_ele, env, 
                                                              RAMPART_WSSE_XMLNS,
                                                             RAMPART_WSSE);
-            }       
-
+            }     
+            #else   
+                nonce_ele = NULL;
+                nonce_node = NULL;
+            #endif  
+            #if 1
             created_ele = axiom_element_create (env, ut_node, RAMPART_SECURITY_USERNAMETOKEN_CREATED, sec_ns_obj,
                                              &created_node);
             if(NULL != created_ele)
@@ -328,7 +336,12 @@
 
                 AXIOM_ELEMENT_SET_NAMESPACE(created_ele, env, wsu_ns_obj, created_node);
 
-            }       
+            } 
+            #else
+                created_ele = NULL;
+                created_node = NULL;
+            #endif
+                  
             /*
             AXIS2_FREE(env->allocator, nonce_val);
             AXIS2_FREE(env->allocator, created_val);
@@ -345,6 +358,14 @@
                 dec_ns = AXIOM_ELEMENT_FIND_DECLARED_NAMESPACE(pw_ele, env, 
                                                              RAMPART_WSSE_XMLNS,
                                                             RAMPART_WSSE);
+           
+                om_attr = axiom_attribute_create (env,
+                                    RAMPART_SECURITY_USERNAMETOKEN_PASSWORD_ATTR_TYPE,
+                                    RAMPART_PASSWORD_TEXT_URI,                                    
+                                    NULL);
+
+                AXIOM_ELEMENT_ADD_ATTRIBUTE (pw_ele, env,
+                                om_attr, pw_node);
              }                 
          } /*End if passwordType == passwordText*/
     }
@@ -368,6 +389,15 @@
     axis2_qname_t *qname = NULL;
     rampart_username_token_impl_t *username_token_impl = NULL;
 
+    /*TODO*/
+    /*
+    R4222 Any USERNAME_TOKEN MUST NOT have more than one PASSWORD.
+    R4201 Any PASSWORD MUST specify a Type attribute.
+    R4212 [summary] If no noce or created specified those should be avoided from the concatenation
+    R4223 Any USERNAME_TOKEN MUST NOT have more than one CREATED.
+    R4225 Any USERNAME_TOKEN MUST NOT have more than one NONCE
+    */
+
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     username_token_impl = AXIS2_INTF_TO_IMPL(username_token);
 
@@ -428,9 +458,10 @@
                                             
                     if(!password_type)
                     {
-                        password_type = RAMPART_PASSWORD_TEXT_URI;
+                       /*R4201 Any PASSWORD MUST specify a Type attribute */
+                       AXIS2_LOG_INFO(env->log,"Password Type is not specified in the password element");
+                       return AXIS2_FAILURE;
                     } 
-                       
 
                     password = AXIOM_ELEMENT_GET_TEXT(element, env, node);        
 



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org