You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sh...@apache.org on 2008/08/14 10:03:34 UTC

svn commit: r685799 [2/2] - in /webservices/axis2/trunk/c: ides/vc/axis2c/neethi/ neethi/include/ neethi/src/ neethi/src/secpolicy/builder/ neethi/src/secpolicy/model/

Modified: webservices/axis2/trunk/c/neethi/src/secpolicy/builder/username_token_builder.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/neethi/src/secpolicy/builder/username_token_builder.c?rev=685799&r1=685798&r2=685799&view=diff
==============================================================================
--- webservices/axis2/trunk/c/neethi/src/secpolicy/builder/username_token_builder.c (original)
+++ webservices/axis2/trunk/c/neethi/src/secpolicy/builder/username_token_builder.c Thu Aug 14 01:03:32 2008
@@ -24,7 +24,7 @@
 
 /*private functions*/
 
-axis2_status_t AXIS2_CALL username_token_process_alternatives(
+static axis2_status_t AXIS2_CALL username_token_process_alternatives(
     const axutil_env_t *env,
     neethi_all_t *all,
     rp_username_token_t *username_token);
@@ -50,12 +50,18 @@
     neethi_policy_t *normalized_policy = NULL;
 
     username_token = rp_username_token_create(env);
-    qname = axutil_qname_create(env, RP_INCLUDE_TOKEN, RP_SP_NS, RP_SP_PREFIX);
-
+    qname = axutil_qname_create(env, RP_INCLUDE_TOKEN, RP_SP_NS_11, RP_SP_PREFIX);
     inclusion_value = axiom_element_get_attribute_value(element, env, qname);
-
     axutil_qname_free(qname, env);
     qname = NULL;
+    if(!inclusion_value)
+    {
+        /* we can try whether WS-SP1.2 specific inclusion value */
+        qname = axutil_qname_create(env, RP_INCLUDE_TOKEN, RP_SP_NS_12, RP_SP_PREFIX);
+        inclusion_value = axiom_element_get_attribute_value(element, env, qname);
+        axutil_qname_free(qname, env);
+        qname = NULL;
+    }
 
     rp_username_token_set_inclusion(username_token, env, inclusion_value);
 
@@ -63,9 +69,7 @@
     if (!child_node)
     {
         assertion = neethi_assertion_create(env);
-        neethi_assertion_set_value(assertion, env,
-                                   username_token,
-                                   ASSERTION_TYPE_USERNAME_TOKEN);
+        neethi_assertion_set_value(assertion, env, username_token, ASSERTION_TYPE_USERNAME_TOKEN);
         return assertion;
     }
 
@@ -80,23 +84,17 @@
             {
                 return NULL;
             }
-            normalized_policy =
-                neethi_engine_get_normalize(env, AXIS2_FALSE, policy);
+            normalized_policy = neethi_engine_get_normalize(env, AXIS2_FALSE, policy);
             neethi_policy_free(policy, env);
             policy = NULL;
-            alternatives =
-                neethi_policy_get_alternatives(normalized_policy, env);
-            component =
-                (neethi_operator_t *) axutil_array_list_get(alternatives, env,
-                                                            0);
+            alternatives = neethi_policy_get_alternatives(normalized_policy, env);
+            component = (neethi_operator_t *) axutil_array_list_get(alternatives, env, 0);
             all = (neethi_all_t *) neethi_operator_get_value(component, env);
             username_token_process_alternatives(env, all, username_token);
 
-            assertion =
-                neethi_assertion_create_with_args(env,
-                                                  (AXIS2_FREE_VOID_ARG)rp_username_token_free,
-                                                  username_token,
-                                                  ASSERTION_TYPE_USERNAME_TOKEN);
+            assertion = neethi_assertion_create_with_args(
+                env,(AXIS2_FREE_VOID_ARG)rp_username_token_free, 
+                username_token, ASSERTION_TYPE_USERNAME_TOKEN);
 
             neethi_policy_free(normalized_policy, env);
             normalized_policy = NULL;
@@ -110,7 +108,7 @@
         return NULL;
 }
 
-axis2_status_t AXIS2_CALL
+static axis2_status_t AXIS2_CALL
 username_token_process_alternatives(
     const axutil_env_t *env,
     neethi_all_t *all,

Modified: webservices/axis2/trunk/c/neethi/src/secpolicy/builder/x509_token_builder.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/neethi/src/secpolicy/builder/x509_token_builder.c?rev=685799&r1=685798&r2=685799&view=diff
==============================================================================
--- webservices/axis2/trunk/c/neethi/src/secpolicy/builder/x509_token_builder.c (original)
+++ webservices/axis2/trunk/c/neethi/src/secpolicy/builder/x509_token_builder.c Thu Aug 14 01:03:32 2008
@@ -50,7 +50,7 @@
     neethi_policy_t *normalized_policy = NULL;
 
     x509_token = rp_x509_token_create(env);
-    qname = axutil_qname_create(env, RP_INCLUDE_TOKEN, RP_SP_NS, RP_SP_PREFIX);
+    qname = axutil_qname_create(env, RP_INCLUDE_TOKEN, RP_SP_NS_11, RP_SP_PREFIX);
 
     inclusion_value = axiom_element_get_attribute_value(element, env, qname);
 

Modified: webservices/axis2/trunk/c/neethi/src/secpolicy/model/signed_encrypted_parts.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/neethi/src/secpolicy/model/signed_encrypted_parts.c?rev=685799&r1=685798&r2=685799&view=diff
==============================================================================
--- webservices/axis2/trunk/c/neethi/src/secpolicy/model/signed_encrypted_parts.c (original)
+++ webservices/axis2/trunk/c/neethi/src/secpolicy/model/signed_encrypted_parts.c Thu Aug 14 01:03:32 2008
@@ -22,6 +22,7 @@
 {
     axis2_bool_t body;
     axis2_bool_t signedparts;
+    axis2_bool_t attachments;
     axutil_array_list_t *headers;
     int ref;
 };
@@ -31,35 +32,31 @@
     const axutil_env_t * env)
 {
     rp_signed_encrypted_parts_t *signed_encrypted_parts = NULL;
+    signed_encrypted_parts = (rp_signed_encrypted_parts_t *) AXIS2_MALLOC(
+        env->allocator, sizeof(rp_signed_encrypted_parts_t));
 
-    AXIS2_ENV_CHECK(env, NULL);
-
-    signed_encrypted_parts =
-        (rp_signed_encrypted_parts_t *) AXIS2_MALLOC(env->allocator,
-                                                     sizeof
-                                                     (rp_signed_encrypted_parts_t));
-
-    if (signed_encrypted_parts == NULL)
+    if(!signed_encrypted_parts)
     {
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+            "[neethi] Cannot create signed_encrypted_parts. Insuficient memory.");
         return NULL;
     }
-    signed_encrypted_parts->headers = NULL;
 
     signed_encrypted_parts->headers = axutil_array_list_create(env, 0);
-    if (!(signed_encrypted_parts->headers))
+    if (!signed_encrypted_parts->headers)
     {
         rp_signed_encrypted_parts_free(signed_encrypted_parts, env);
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+            "[neethi] Cannot create signed_encrypted_parts. Headers array list creation failed.");
         return NULL;
     }
 
     signed_encrypted_parts->body = AXIS2_FALSE;
     signed_encrypted_parts->ref = 0;
     signed_encrypted_parts->signedparts = AXIS2_FALSE;
-
+    signed_encrypted_parts->attachments = AXIS2_FALSE;
     return signed_encrypted_parts;
-
 }
 
 AXIS2_EXTERN void AXIS2_CALL
@@ -67,38 +64,32 @@
     rp_signed_encrypted_parts_t * signed_encrypted_parts,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
     if (signed_encrypted_parts)
     {
         if (--(signed_encrypted_parts->ref) > 0)
         {
             return;
         }
+
         if (signed_encrypted_parts->headers)
         {
             int i = 0;
-            for (i = 0;
-                 i < axutil_array_list_size(signed_encrypted_parts->headers,
-                                            env); i++)
+            for (i = 0; i < axutil_array_list_size(signed_encrypted_parts->headers, env); i++)
             {
                 rp_header_t *header = NULL;
-                header = (rp_header_t *)
-                    axutil_array_list_get(signed_encrypted_parts->headers, env,
-                                          i);
+                header = (rp_header_t *)axutil_array_list_get(
+                    signed_encrypted_parts->headers, env, i);
                 if (header)
+                {
                     rp_header_free(header, env);
-
-                header = NULL;
+                }
             }
             axutil_array_list_free(signed_encrypted_parts->headers, env);
             signed_encrypted_parts->headers = NULL;
-
         }
         AXIS2_FREE(env->allocator, signed_encrypted_parts);
         signed_encrypted_parts = NULL;
     }
-    return;
 }
 
 /* Implementations */
@@ -108,8 +99,6 @@
     rp_signed_encrypted_parts_t * signed_encrypted_parts,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
     return signed_encrypted_parts->body;
 }
 
@@ -119,10 +108,8 @@
     const axutil_env_t * env,
     axis2_bool_t body)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, body, AXIS2_FAILURE);
     signed_encrypted_parts->body = body;
-
     return AXIS2_SUCCESS;
 }
 
@@ -131,8 +118,6 @@
     rp_signed_encrypted_parts_t * signed_encrypted_parts,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
     return signed_encrypted_parts->signedparts;
 }
 
@@ -142,10 +127,7 @@
     const axutil_env_t * env,
     axis2_bool_t signedparts)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    /*AXIS2_PARAM_CHECK(env->error,signedparts,AXIS2_FAILURE); */
     signed_encrypted_parts->signedparts = signedparts;
-
     return AXIS2_SUCCESS;
 }
 
@@ -154,8 +136,6 @@
     rp_signed_encrypted_parts_t * signed_encrypted_parts,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
     return signed_encrypted_parts->headers;
 }
 
@@ -165,9 +145,7 @@
     const axutil_env_t * env,
     rp_header_t * header)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, header, AXIS2_FAILURE);
-
     axutil_array_list_add(signed_encrypted_parts->headers, env, header);
     return AXIS2_SUCCESS;
 }
@@ -177,7 +155,23 @@
     rp_signed_encrypted_parts_t * signed_encrypted_parts,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     signed_encrypted_parts->ref++;
     return AXIS2_SUCCESS;
 }
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+rp_signed_encrypted_parts_get_attachments(
+    rp_signed_encrypted_parts_t * signed_encrypted_parts,
+    const axutil_env_t * env)
+{
+    return signed_encrypted_parts->attachments;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rp_signed_encrypted_parts_set_attachments(
+    rp_signed_encrypted_parts_t * signed_encrypted_parts,
+    const axutil_env_t * env,
+    axis2_bool_t attachments)
+{
+    signed_encrypted_parts->attachments = attachments;
+    return AXIS2_SUCCESS;
+}

Modified: webservices/axis2/trunk/c/neethi/src/secpolicy/model/ut.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/neethi/src/secpolicy/model/ut.c?rev=685799&r1=685798&r2=685799&view=diff
==============================================================================
--- webservices/axis2/trunk/c/neethi/src/secpolicy/model/ut.c (original)
+++ webservices/axis2/trunk/c/neethi/src/secpolicy/model/ut.c Thu Aug 14 01:03:32 2008
@@ -17,13 +17,15 @@
  */
 
 #include <rp_username_token.h>
+#include <rp_token.h>
 
 struct rp_username_token_t
 {
     axis2_char_t *inclusion;
-    axis2_bool_t derivedkeys;
+    password_type_t password_type;
     axis2_bool_t useUTprofile10;
     axis2_bool_t useUTprofile11;
+    rp_token_t *token;
     int ref;
 };
 
@@ -32,26 +34,33 @@
     const axutil_env_t * env)
 {
     rp_username_token_t *username_token = NULL;
+    username_token = (rp_username_token_t *) AXIS2_MALLOC(
+        env->allocator, sizeof (rp_username_token_t));
 
-    AXIS2_ENV_CHECK(env, NULL);
-
-    username_token = (rp_username_token_t *) AXIS2_MALLOC(env->allocator,
-                                                          sizeof
-                                                          (rp_username_token_t));
-
-    if (username_token == NULL)
+    if (!username_token)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+            "[neethi] User name token creation failed. Insufficient memory");
+        return NULL;
+    }
+
+    username_token->token = rp_token_create(env);
+    if(!username_token->token)
+    {
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+            "[neethi] User name token creation failed.");
+        rp_username_token_free(username_token, env);
         return NULL;
     }
+
     username_token->inclusion = RP_INCLUDE_ALWAYS;
-    username_token->derivedkeys = AXIS2_FALSE;
+    username_token->password_type = PASSWORD_PLAIN;
     username_token->useUTprofile10 = AXIS2_TRUE;
     username_token->useUTprofile11 = AXIS2_FALSE;
     username_token->ref = 0;
 
     return username_token;
-
 }
 
 AXIS2_EXTERN void AXIS2_CALL
@@ -59,19 +68,17 @@
     rp_username_token_t * username_token,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
-    if (--(username_token->ref) > 0)
+    if(username_token)
     {
-        return;
-    }
+        if (--(username_token->ref) > 0)
+        {
+            return;
+        }
 
-    if (username_token)
-    {
+        rp_token_free(username_token, env);
         AXIS2_FREE(env->allocator, username_token);
         username_token = NULL;
     }
-    return;
 }
 
 /* Implementations */
@@ -81,8 +88,6 @@
     rp_username_token_t * username_token,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-
     return username_token->inclusion;
 }
 
@@ -92,91 +97,120 @@
     const axutil_env_t * env,
     axis2_char_t * inclusion)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, inclusion, AXIS2_FAILURE);
-
     username_token->inclusion = inclusion;
-
     return AXIS2_SUCCESS;
 }
 
 AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-rp_username_token_get_derivedkeys(
+rp_username_token_get_useUTprofile10(
     rp_username_token_t * username_token,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FALSE);
-
-    return username_token->derivedkeys;
+    return username_token->useUTprofile10;
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
-rp_username_token_set_derivedkeys(
+rp_username_token_set_useUTprofile10(
     rp_username_token_t * username_token,
     const axutil_env_t * env,
-    axis2_bool_t derivedkeys)
+    axis2_bool_t useUTprofile10)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, derivedkeys, AXIS2_FAILURE);
-    username_token->derivedkeys = derivedkeys;
-
+    username_token->useUTprofile10 = useUTprofile10;
     return AXIS2_SUCCESS;
-
 }
 
 AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-rp_username_token_get_useUTprofile10(
+rp_username_token_get_useUTprofile11(
     rp_username_token_t * username_token,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FALSE);
-
     return username_token->useUTprofile10;
-
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
-rp_username_token_set_useUTprofile10(
+rp_username_token_set_useUTprofile11(
     rp_username_token_t * username_token,
     const axutil_env_t * env,
-    axis2_bool_t useUTprofile10)
+    axis2_bool_t useUTprofile11)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, useUTprofile10, AXIS2_FAILURE);
-    username_token->useUTprofile10 = useUTprofile10;
+    username_token->useUTprofile11 = useUTprofile11;
+    return AXIS2_SUCCESS;
+}
 
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rp_username_token_increment_ref(
+    rp_username_token_t * username_token,
+    const axutil_env_t * env)
+{
+    username_token->ref++;
     return AXIS2_SUCCESS;
 }
 
-AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-rp_username_token_get_useUTprofile11(
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+rp_username_token_get_issuer(
     rp_username_token_t * username_token,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FALSE);
+    return rp_token_get_issuer(username_token->token, env);
+}
 
-    return username_token->useUTprofile10;
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rp_username_token_set_issuer(
+    rp_username_token_t * username_token,
+    const axutil_env_t * env,
+    axis2_char_t * issuer)
+{
+    return rp_token_set_issuer(username_token->token, env, issuer);
+}
+
+AXIS2_EXTERN derive_key_type_t AXIS2_CALL
+rp_username_token_get_derivedkey_type(
+    rp_username_token_t * username_token,
+    const axutil_env_t * env)
+{
+    return rp_token_get_derivedkey_type(username_token->token, env);
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
-rp_username_token_set_useUTprofile11(
+rp_username_token_set_derivedkey_type(
     rp_username_token_t * username_token,
     const axutil_env_t * env,
-    axis2_bool_t useUTprofile11)
+    derive_key_type_t derivedkey)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, useUTprofile11, AXIS2_FAILURE);
-    username_token->useUTprofile11 = useUTprofile11;
+    return rp_token_set_derivedkey_type(username_token->token, env, derivedkey);
+}
 
-    return AXIS2_SUCCESS;
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+rp_username_token_get_is_issuer_name(
+    rp_username_token_t * username_token,
+    const axutil_env_t * env)
+{
+    return rp_token_get_is_issuer_name(username_token->token, env);
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
-rp_username_token_increment_ref(
+rp_username_token_set_is_issuer_name(
+    rp_username_token_t * username_token,
+    const axutil_env_t * env,
+    axis2_bool_t is_issuer_name)
+{
+    return rp_token_set_is_issuer_name(username_token->token, env, is_issuer_name);
+}
+
+AXIS2_EXTERN axiom_node_t *AXIS2_CALL
+rp_username_token_get_claim(
     rp_username_token_t * username_token,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    username_token->ref++;
-    return AXIS2_SUCCESS;
+    return rp_token_get_claim(username_token->token, env);
 }
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rp_username_token_set_claim(
+    rp_username_token_t * username_token,
+    const axutil_env_t * env,
+    axiom_node_t *claim)
+{
+    return rp_token_set_claim(username_token->token, env, claim);
+}
\ No newline at end of file