axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject svn commit: r413826 [1/2] - in /webservices/axis2/trunk/c/rampart: ./ include/rampart/ samples/ samples/callback/ samples/client/ src/ src/core/ src/data/ src/handlers/ src/util/ test/ test/util/
Date Tue, 13 Jun 2006 07:52:37 GMT
Author: damitha
Date: Tue Jun 13 00:52:35 2006
New Revision: 413826

URL: http://svn.apache.org/viewvc?rev=413826&view=rev
Log:
Commiting the code attached in AXIS2C-168. Thanks Kaushalye

Added:
    webservices/axis2/trunk/c/rampart/include/rampart/rampart_callback.h
    webservices/axis2/trunk/c/rampart/include/rampart/rampart_constants.h
    webservices/axis2/trunk/c/rampart/include/rampart/rampart_crypto_util.h
    webservices/axis2/trunk/c/rampart/include/rampart/rampart_handler_util.h
    webservices/axis2/trunk/c/rampart/include/rampart/rampart_mod.h
    webservices/axis2/trunk/c/rampart/include/rampart/rampart_util.h
    webservices/axis2/trunk/c/rampart/include/rampart/timestamp_token.h
    webservices/axis2/trunk/c/rampart/include/rampart/user_sec_param.h
    webservices/axis2/trunk/c/rampart/include/rampart/username_token.h
    webservices/axis2/trunk/c/rampart/samples/
    webservices/axis2/trunk/c/rampart/samples/Makefile.am
    webservices/axis2/trunk/c/rampart/samples/callback/
    webservices/axis2/trunk/c/rampart/samples/callback/Makefile.am
    webservices/axis2/trunk/c/rampart/samples/callback/pwcb.c
    webservices/axis2/trunk/c/rampart/samples/client/
    webservices/axis2/trunk/c/rampart/src/core/
    webservices/axis2/trunk/c/rampart/src/core/Makefile.am
    webservices/axis2/trunk/c/rampart/src/core/mod_rampart.c
    webservices/axis2/trunk/c/rampart/src/core/user_sec_param.c
    webservices/axis2/trunk/c/rampart/src/data/
    webservices/axis2/trunk/c/rampart/src/data/module.xml
    webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c
    webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c
    webservices/axis2/trunk/c/rampart/src/util/
    webservices/axis2/trunk/c/rampart/src/util/Makefile.am
    webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c
    webservices/axis2/trunk/c/rampart/src/util/rampart_handler_util.c
    webservices/axis2/trunk/c/rampart/src/util/rampart_util.c
    webservices/axis2/trunk/c/rampart/src/util/timestamp_token.c
    webservices/axis2/trunk/c/rampart/src/util/username_token.c
    webservices/axis2/trunk/c/rampart/test/
    webservices/axis2/trunk/c/rampart/test/Makefile.am
    webservices/axis2/trunk/c/rampart/test/util/
    webservices/axis2/trunk/c/rampart/test/util/Makefile.am
    webservices/axis2/trunk/c/rampart/test/util/test_sha.c
Modified:
    webservices/axis2/trunk/c/rampart/INSTALL
    webservices/axis2/trunk/c/rampart/Makefile.am
    webservices/axis2/trunk/c/rampart/NEWS
    webservices/axis2/trunk/c/rampart/configure.ac
    webservices/axis2/trunk/c/rampart/src/Makefile.am
    webservices/axis2/trunk/c/rampart/src/handlers/Makefile.am

Modified: webservices/axis2/trunk/c/rampart/INSTALL
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/INSTALL?rev=413826&r1=413825&r2=413826&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/INSTALL (original)
+++ webservices/axis2/trunk/c/rampart/INSTALL Tue Jun 13 00:52:35 2006
@@ -7,8 +7,42 @@
         make install
         use './configure --help' for options
 
-NOTE: If you don't provide a --prefix configure option, it will by default 
-install into /usr/local/axis2_util directory.
+Engage rampart with axis2/C
+==================================
+Steps:
+
+Configuring server:
+-----------------------------------
+1. Run build.sh in axis2/c/rampart directory
+2. Copy rampart directory created in rampart/target to AXIS2C_HOME/deploy/modules
+3. To engage rampart add to axis.xml
+    <module ref="rampart"/>
+
+4. To set inflow security parameters add following to global configuration file or service configuration file
+    <parameter name="InflowSecurity">
+      <action>
+        <items>UsernameToken</items>
+        <passwordCallbackClass>/your/module/to/load/passwordcallback.so</passwordCallbackClass>
+      </action>
+    </parameter>
+
+Configure client:
+-----------------------------------
+1. To set outflow security parameters add following to global configuration file or service configuration file
+   <parameter name="OutflowSecurity">
+      <action>
+        <items>UsernameToken</items>
+        <user>MyName</user>
+        <passwordType>passwordDigest</passwordType>
+        <passwordCallbackClass>/your/module/to/load/passwordcallback.so</passwordCallbackClass>
+      </action>
+    </parameter>
+
+Writing callback modules:
+-----------------------------------
+User can specify which .so module to use to callback the password.
+For this user must provide a function pointer for get_password() operation in rampart_callback_t
+See rampart/samples/callback/pwcb.c for clarity
 
 
 

Modified: webservices/axis2/trunk/c/rampart/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/Makefile.am?rev=413826&r1=413825&r2=413826&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/Makefile.am Tue Jun 13 00:52:35 2006
@@ -1,2 +1,2 @@
-SUBDIRS = src
+SUBDIRS = src test samples
 

Modified: webservices/axis2/trunk/c/rampart/NEWS
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/NEWS?rev=413826&r1=413825&r2=413826&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/NEWS (original)
+++ webservices/axis2/trunk/c/rampart/NEWS Tue Jun 13 00:52:35 2006
@@ -0,0 +1 @@
+AWAIT : Timestamp token

Modified: webservices/axis2/trunk/c/rampart/configure.ac
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/configure.ac?rev=413826&r1=413825&r2=413826&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/configure.ac (original)
+++ webservices/axis2/trunk/c/rampart/configure.ac Tue Jun 13 00:52:35 2006
@@ -118,7 +118,15 @@
 
 AC_CONFIG_FILES([Makefile \
     src/Makefile \
-    src/handlers/Makefile
+    src/handlers/Makefile \
+    src/core/Makefile\
+    src/util/Makefile\
+    test/Makefile \
+    test/util/Makefile\
+    samples/Makefile \
+    samples/callback/Makefile \
+    samples/client/Makefile \
+    samples/client/echo/Makefile
     ])
     
 AC_OUTPUT

Added: webservices/axis2/trunk/c/rampart/include/rampart/rampart_callback.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart/rampart_callback.h?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart/rampart_callback.h (added)
+++ webservices/axis2/trunk/c/rampart/include/rampart/rampart_callback.h Tue Jun 13 00:52:35 2006
@@ -0,0 +1,62 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.
+*/
+
+#ifndef RAMPART_CALLBACK_H
+#define RAMPART_CALLBACK_H
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+    /**
+     * Struct to get password using callbacks
+     * @defgroup rampart_callback rampart callback
+     * @ingroup rampart_util
+     * @{
+     */
+
+    /** Type name for struct rampart_callback_ops */
+    typedef struct rampart_callback_ops rampart_callback_ops_t;
+
+    /** Type name for struct rampart_callback */
+    typedef struct rampart_callback rampart_callback_t;
+    
+    /**
+     * Only operation get_password is to get the password
+     * User should prvide a function pointer to this
+     */
+    AXIS2_DECLARE_DATA struct rampart_callback_ops
+    {
+            axis2_char_t *(AXIS2_CALL*
+            get_password)(rampart_callback_t *rcb,
+            const axis2_env_t *env, const axis2_char_t *username);
+
+    };
+
+    AXIS2_DECLARE_DATA struct rampart_callback
+    {
+        rampart_callback_ops_t *ops;
+    };
+
+    /** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif                          /* RAMPART_CALLBACK_H */
+

Added: webservices/axis2/trunk/c/rampart/include/rampart/rampart_constants.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart/rampart_constants.h?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart/rampart_constants.h (added)
+++ webservices/axis2/trunk/c/rampart/include/rampart/rampart_constants.h Tue Jun 13 00:52:35 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+
+#ifndef RAMPART_CONSTANTS_H
+#define RAMPART_CONSTANTS_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* rampart element names*/
+#define RAMPART_SECURITY "Security"
+#define RAMPART_SECURITY_USERNAMETOKEN "UsernameToken"
+#define RAMPART_SECURITY_USERNAMETOKEN_USERNAME "Username"
+#define RAMPART_SECURITY_USERNAMETOKEN_PASSWORD "Password"
+#define RAMPART_SECURITY_USERNAMETOKEN_CREATED "Created"
+#define RAMPART_SECURITY_USERNAMETOKEN_NONCE "Nonce"
+#define RAMPART_SECURITY_USERNAMETOKEN_PASSWORD_ATTR_TYPE "Type"
+#define RAMPART_SECURITY_TIMESTAMP "Timestamp"
+#define RAMPART_SECURITY_TIMESTAMP_CREATED "Created"
+#define RAMPART_SECURITY_TIMESTAMP_EXPIRES "Expires"
+    
+/*Rampart URIs*/
+#define RAMPART_WSSE "wsse"
+#define RAMPART_WSSE_XMLNS "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
+#define RAMPART_WSU "wsu"
+#define RAMPART_WSU_XMLNS "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+#define RAMPART_PASSWORD_DIGEST_URI "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"  
+
+  /* Inflow outflow security parameter    */
+#define RAMPART_INFLOW_SECURITY  "InflowSecurity"
+#define RAMPART_OUTFLOW_SECURITY "OutflowSecurity"
+#define RAMPART_ACTION "action"
+#define RAMPART_ACTION_ITEMS "items"
+#define RAMPART_USER "user"
+#define RAMPART_PASSWORD_TYPE "passwordType"
+#define RAMPART_PASSWORD_TEXT "passwordText"
+#define RAMPART_PASSWORD_DIGEST "passwordDigest"
+#define RAMPART_ACTION_ITEMS_USERNAMETOKEN "UsernameToken"
+#define RAMPART_ACTION_ITEMS_TIMESTAMP "Timestamp"
+#define RAMPART_ACTION_PW_CALLBACK_CLASS "passwordCallbackClass"
+
+/*Dynamically set values*/
+#define RAMPART_DYN_PASSWORD "password"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RAMPART_CONSTANTS_H*/

Added: webservices/axis2/trunk/c/rampart/include/rampart/rampart_crypto_util.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart/rampart_crypto_util.h?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart/rampart_crypto_util.h (added)
+++ webservices/axis2/trunk/c/rampart/include/rampart/rampart_crypto_util.h Tue Jun 13 00:52:35 2006
@@ -0,0 +1,59 @@
+/*
+ *   Copyright 2003-2004 The Apache Software Foundation.
+ *
+ *   Licensed 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<openssl/sha.h>
+
+#include <axis2_utils_defines.h>
+#include <axis2_defines.h>
+#include <axis2_env.h>
+
+/**
+  * @file rampart_crypto_util.h
+  * @brief RAMPART-UTIL Crypto
+  */
+#ifndef RAMPART_CRYPTO_UTIL
+#define RAMPART_CRYPTO_UTIL
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+  * @defgroup Rampart_Crypto_Util
+  * @ingroup Rampart_Util
+  */
+
+
+  /** 
+  * Calculate the hash of concatenated string of followings
+  * @param nonce
+  * @param created 
+  * @param password 
+  * @return calculated hash
+  */ 
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+	rampart_crypto_sha1(const axis2_env_t *env,
+				const axis2_char_t *nonce,
+	                	const axis2_char_t *created,
+	                	const axis2_char_t *password);
+												                                        
+
+/* @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif    /* !RAMPART_CRYPTO_H */

Added: webservices/axis2/trunk/c/rampart/include/rampart/rampart_handler_util.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart/rampart_handler_util.h?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart/rampart_handler_util.h (added)
+++ webservices/axis2/trunk/c/rampart/include/rampart/rampart_handler_util.h Tue Jun 13 00:52:35 2006
@@ -0,0 +1,117 @@
+/**
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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 <axis2_handler_desc.h>
+#include <axis2_array_list.h>
+#include <axiom_soap_const.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_header_block.h>
+#include <axis2_op.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_msg_info_headers.h>
+#include <axis2_property.h>
+#include <rampart/rampart_constants.h>
+
+
+
+#ifndef RAMPART_HANDLER_UTIL_H
+#define RAMPART_HANDLER_UTIL_H
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+    
+      
+ /**
+ * Get parameter for the given parameter name
+ * @param env pointer to environment struct    
+ * @param msg_ctx message context
+ * @param parameter the parameter name
+ * @return parameter 
+ */   
+                                            
+AXIS2_EXTERN axis2_param_t* AXIS2_CALL
+rampart_get_security_param( const axis2_env_t *env,
+		                const axis2_msg_ctx_t *msg_ctx,
+                         const axis2_char_t *parameter);
+    
+ /**
+ * Get actions specified in In/OutflowSecurity
+ * @param env pointer to environment struct    
+ * @param ctx context
+ * @param Outflowsecurity
+ * @return parameters in an array list
+ */   
+AXIS2_EXTERN axis2_array_list_t* AXIS2_CALL
+rampart_get_actions( const axis2_env_t *env,
+                                            const axis2_ctx_t *ctx,
+		                                    const axis2_param_t *param_x_flow_security);
+    
+
+ 
+                               
+ /**
+ * Get the value of the action parameter given the key name
+ * Here the key name means the name of the subelement of the 
+ * action element.
+ * @param env pointer to environment struct
+ * @param ctx context
+ * @param param_action action parameter
+ * @param key element name as a string
+ * @return the value of the element
+ */   
+ 
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+rampart_get_action_params( const axis2_env_t *env,
+                   const axis2_ctx_t *ctx,
+                   const axis2_param_t *param_action,
+                   const axis2_char_t *key);
+
+                               
+ /**
+ * Get the security token from the header block
+ * @param env pointer to environment struct
+ * @param msg_ctx message context
+ * @param soap heamsg_ctxder
+ * @return soap_header security element node
+ */    
+AXIS2_EXTERN axiom_node_t *AXIS2_CALL
+rampart_get_security_token(const axis2_env_t *env,
+                                const axis2_msg_ctx_t *msg_ctx,
+                                axiom_soap_header_t *soap_header);
+
+ /**
+ * Get password using callback
+ * @param env pointer to environment struct
+ * @return password
+ */
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+rampart_callback_pw( const axis2_env_t *env,
+                     const axis2_char_t *callback_module_name,
+                     const axis2_char_t *username);
+    
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /*RAMPART_HANDLER_UTIL_H*/

Added: webservices/axis2/trunk/c/rampart/include/rampart/rampart_mod.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart/rampart_mod.h?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart/rampart_mod.h (added)
+++ webservices/axis2/trunk/c/rampart/include/rampart/rampart_mod.h Tue Jun 13 00:52:35 2006
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+#ifndef RAMPART_MOD_H
+#define RAMPART_MOD_H
+
+/**
+ * @file rampart_mod.h
+ * @brief Axis2 rampart module interface
+ */
+
+#include <axis2_handler.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+AXIS2_EXTERN axis2_handler_t* AXIS2_CALL
+rampart_in_handler_create(const axis2_env_t *env, 
+							axis2_qname_t *qname);
+
+AXIS2_EXTERN axis2_handler_t* AXIS2_CALL 
+rampart_out_handler_create(const axis2_env_t *env, 
+							  axis2_qname_t *qname);
+    
+/** @} */
+    
+#ifdef __cplusplus
+}
+#endif
+
+#endif    /* AXIS2_ADDR_MOD_H */

Added: webservices/axis2/trunk/c/rampart/include/rampart/rampart_util.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart/rampart_util.h?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart/rampart_util.h (added)
+++ webservices/axis2/trunk/c/rampart/include/rampart/rampart_util.h Tue Jun 13 00:52:35 2006
@@ -0,0 +1,66 @@
+/*
+ *   Copyright 2003-2004 The Apache Software Foundation.
+ *
+ *   Licensed 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 <axis2_utils_defines.h>
+#include <axis2_defines.h>
+#include <axis2_env.h>
+
+/**
+  * @file rampart_util.h
+  * @brief RAMPART-UTIL 
+  */
+#ifndef RAMPART_UTIL_H
+#define RAMPART_UTIL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+  * @defgroup Rampart_Util
+  * @ingroup Rampart_Util
+  */
+
+												                                        
+ /** 
+    * Generates the nonce. Nonce is a base64 encoded random string.
+    * @return generated nonce
+    */ 	
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+	rampart_generate_nonce(const axis2_env_t *env);
+
+ /* Generates the nonce. Nonce is a base64 encoded random string.
+  * @return generated nonce
+ **/ 	
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL 
+rampart_generate_time(const axis2_env_t *env, int ttl);
+
+
+AXIS2_EXTERN int AXIS2_CALL 
+rampart_format_date_zulu_to_mili(const axis2_env_t *env, axis2_char_t *str);
+
+
+AXIS2_EXTERN axis2_status_t* AXIS2_CALL 
+rampart_print_info(const axis2_env_t *env, axis2_char_t* info);
+
+/* @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif    /* !RAMPART_UTIL_H */

Added: webservices/axis2/trunk/c/rampart/include/rampart/timestamp_token.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart/timestamp_token.h?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart/timestamp_token.h (added)
+++ webservices/axis2/trunk/c/rampart/include/rampart/timestamp_token.h Tue Jun 13 00:52:35 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+#ifndef TIMESTAMP_TOKEN_H
+#define TIMESTAMP_TOKEN_H
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+    
+    
+#include <axis2_env.h>
+#include <rampart/rampart_constants.h>
+
+/*
+ * 
+ * @param 
+ * @param 
+ * @return 
+ */ 
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+rampart_build_timestamp_token(const axis2_env_t *env,
+                                const axis2_ctx_t *ctx,
+                                axiom_node_t *sec_node,
+                                const  axiom_namespace_t *sec_ns_obj,
+                                int ttl
+                                );
+
+/*
+ * 
+ * @param 
+ * @param 
+ * @return 
+ */     
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_validate_timestamp(const axis2_env_t *env,
+                                                        axiom_node_t *ts_node);
+
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /*TIMESTAMP_TOKEN_H*/

Added: webservices/axis2/trunk/c/rampart/include/rampart/user_sec_param.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart/user_sec_param.h?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart/user_sec_param.h (added)
+++ webservices/axis2/trunk/c/rampart/include/rampart/user_sec_param.h Tue Jun 13 00:52:35 2006
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+#ifndef USER_SEC_PARAM_H
+#define USER_SEC_PARAM_H
+
+/**
+ * @file user_sec_param.h
+ * @brief User Security Parameter interface
+ */
+
+#include <axis2_utils_defines.h>
+#include <axis2_env.h>
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct user_sec_param ;
+struct user_sec_param_ops ;
+
+             
+AXIS2_DECLARE_DATA typedef struct user_sec_param_ops
+{
+    /**
+     *  Free a user_sec_param struct
+     *  @return Status code
+     */
+    axis2_status_t (AXIS2_CALL *
+	free) (struct user_sec_param * user_sec_param,
+           const axis2_env_t *env);                                   
+										   
+	axis2_char_t* (AXIS2_CALL *
+		get_user)(struct user_sec_param * user_sec_param,
+				const axis2_env_t *env);	
+} user_sec_param_ops_t;
+
+
+typedef struct user_sec_param
+{
+	/** Parameter related ops */
+	user_sec_param_ops_t *ops;
+}user_sec_param_t;
+
+
+/**
+ *	creates a user_sec_param struct
+ *  returns a pointer to a user_sec_param struct
+ *  @user   optional
+ *  @password      optional  
+ *  @items      optional
+ * @return a pointer to newly created user_sec_param struct
+ */
+
+AXIS2_EXTERN user_sec_param_t *AXIS2_CALL
+user_sec_param_create (const axis2_env_t *env,
+                    const axis2_char_t * user,
+                    const axis2_char_t * password,
+                    const axis2_char_t * items);
+
+#define USER_SEC_PARAM_FREE(user_sec_param , env) \
+        ((user_sec_param )->ops->free(user_sec_param ,env))
+        
+#define USER_SEC_PARAM_GET_USER(user_sec_param, env) \
+        ((user_sec_param)->ops->get_user(user_sec_param, env))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif    /* USER_SEC_PARAM_H */

Added: webservices/axis2/trunk/c/rampart/include/rampart/username_token.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart/username_token.h?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart/username_token.h (added)
+++ webservices/axis2/trunk/c/rampart/include/rampart/username_token.h Tue Jun 13 00:52:35 2006
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+#ifndef USERNAME_TOKEN_H
+#define USERNAME_TOKEN_H
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+#include <axis2_env.h>
+#include <rampart/username_token.h>
+#include <rampart/rampart_constants.h>
+#include <rampart/rampart_crypto_util.h>
+
+/**
+ * Get the password for given outflow security configuration
+ * @param env
+ * @param ctx axis2 context
+ * @param Outflow security parameter
+ * @return 
+ */ 
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+rampart_get_password( const axis2_env_t *env,
+                   axis2_ctx_t *ctx,
+           const axis2_param_t *param_out_flow_security);     
+
+  
+/**
+ * 
+ * @param 
+ * @param 
+ * @return 
+ */         
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+rampart_get_value( const axis2_env_t *env,
+                   axis2_ctx_t *ctx,
+		           const axis2_char_t *key);
+                   
+  
+/**
+ * Build username token 
+ * @param 
+ * @param 
+ * @param 
+ * @param 
+ * @param 
+ * @return 
+ */              
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+rampart_build_username_token(const axis2_env_t *env,
+                                axis2_ctx_t *ctx,
+                                axis2_param_t *param_action,
+                                axiom_node_t *sec_node,
+                                axiom_namespace_t *sec_ns_obj
+                                );
+  
+/**
+ * Validates the given username token 
+ * @param 
+ * @param 
+ * @param 
+ * @return 
+ */   
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_validate_username_token(const axis2_env_t *env,
+                                axis2_msg_ctx_t *msg_ctx,
+                                axiom_soap_header_t *soap_header,
+                                axis2_param_t *param_action);
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /*USERNAME_TOKEN_H*/

Added: webservices/axis2/trunk/c/rampart/samples/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/samples/Makefile.am?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/samples/Makefile.am (added)
+++ webservices/axis2/trunk/c/rampart/samples/Makefile.am Tue Jun 13 00:52:35 2006
@@ -0,0 +1,3 @@
+TESTS =
+SUBDIRS = callback client
+

Added: webservices/axis2/trunk/c/rampart/samples/callback/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/samples/callback/Makefile.am?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/samples/callback/Makefile.am (added)
+++ webservices/axis2/trunk/c/rampart/samples/callback/Makefile.am Tue Jun 13 00:52:35 2006
@@ -0,0 +1,7 @@
+prglibdir=$(prefix)/
+prglib_LTLIBRARIES = libpwcb.la
+libpwcb_la_SOURCES = pwcb.c
+libpwcb_la_LIBADD  =
+INCLUDES = -I$(AXIS2C_HOME)/include \
+            -I$(prefix)/../include \
+			@UTILINC@

Added: webservices/axis2/trunk/c/rampart/samples/callback/pwcb.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/samples/callback/pwcb.c?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/samples/callback/pwcb.c (added)
+++ webservices/axis2/trunk/c/rampart/samples/callback/pwcb.c Tue Jun 13 00:52:35 2006
@@ -0,0 +1,68 @@
+#include <stdio.h>
+#include <axis2_defines.h>
+#include <axis2_error.h>
+#include <axis2_env.h>
+#include <axis2_utils.h>
+#include <rampart/rampart_callback.h>
+#include <axis2_string.h>
+
+
+axis2_char_t* get_sample_password(rampart_callback_t *rcb,
+            const axis2_env_t *env, const axis2_char_t *username)
+{
+    printf("\nget_sample_password for [%s]", username);
+    axis2_char_t * pw = NULL;
+    if(0 == AXIS2_STRCMP(username, "Kau"))
+    {
+        pw = "KauPW" ;
+    }else if(0 == AXIS2_STRCMP(username, "TinTin")){
+        pw = "TinTinPW";
+    }else{
+        printf("\nWho is this? [%s]", username);
+    }
+    return pw;
+};
+
+
+/**
+ * Following block distinguish the exposed part of the dll.
+ */
+AXIS2_EXPORT int
+axis2_get_instance(rampart_callback_t **inst,
+                   const axis2_env_t *env)
+{
+    printf("\naxis2_get_instance");
+    rampart_callback_t* rcb = NULL;
+
+    rcb = AXIS2_MALLOC(env->allocator,
+        sizeof(rampart_callback_t));
+
+    rcb->ops = AXIS2_MALLOC(
+        env->allocator, sizeof(rampart_callback_ops_t));
+
+    /*assign function pointers*/
+   
+    rcb->ops->get_password = get_sample_password;
+
+    *inst = rcb;
+
+    if(!(*inst))
+    {
+        return AXIS2_FAILURE;
+    }
+
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int
+axis2_remove_instance(rampart_callback_t *inst,
+                      const axis2_env_t *env)
+{
+   axis2_status_t status = AXIS2_FAILURE;
+   if (inst)
+   {
+        status = AXIS2_SVC_SKELETON_FREE(inst, env);
+    }
+    return status;
+}
+

Modified: webservices/axis2/trunk/c/rampart/src/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/Makefile.am?rev=413826&r1=413825&r2=413826&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/Makefile.am Tue Jun 13 00:52:35 2006
@@ -1 +1 @@
-SUBDIRS = handlers
+SUBDIRS = handlers util core

Added: webservices/axis2/trunk/c/rampart/src/core/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/core/Makefile.am?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/core/Makefile.am (added)
+++ webservices/axis2/trunk/c/rampart/src/core/Makefile.am Tue Jun 13 00:52:35 2006
@@ -0,0 +1,13 @@
+TESTS =
+prglibdir=$(prefix)/rampart
+prglib_LTLIBRARIES = libmod_rampart.la
+prglib_DATA= ../data/module.xml
+
+libmod_rampart_la_SOURCES = \
+			mod_rampart.c
+
+libmod_rampart_la_LIBADD  = ../handlers/librampart_handlers.la \
+			    ../util/librampart_util.la
+
+INCLUDES = -I$(top_builddir)/include \
+			@UTILINC@

Added: webservices/axis2/trunk/c/rampart/src/core/mod_rampart.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/core/mod_rampart.c?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/core/mod_rampart.c (added)
+++ webservices/axis2/trunk/c/rampart/src/core/mod_rampart.c Tue Jun 13 00:52:35 2006
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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 <axis2_module.h>
+#include <rampart/rampart_mod.h>
+
+axis2_status_t AXIS2_CALL
+mod_rampart_shutdown(axis2_module_t *module,
+                        const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+mod_rampart_init(axis2_module_t *module,
+                        const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+mod_rampart_fill_handler_create_func_map(axis2_module_t *module,
+                                            const axis2_env_t *env);
+
+axis2_module_t *
+mod_rampart_create(const axis2_env_t *env)
+{
+    axis2_module_t *module = NULL;
+    module = AXIS2_MALLOC(env->allocator, 
+        sizeof(axis2_module_t));
+
+    
+    module->ops = AXIS2_MALLOC(
+        env->allocator, sizeof(axis2_module_ops_t));
+
+    module->ops->shutdown = mod_rampart_shutdown;
+    module->ops->init = mod_rampart_init;
+    module->ops->fill_handler_create_func_map = 
+        mod_rampart_fill_handler_create_func_map;
+
+    return module;
+}
+
+axis2_status_t AXIS2_CALL
+mod_rampart_init(axis2_module_t *module,
+                       const axis2_env_t *env)
+{
+    /* Any initialization stuff of mod_rampart goes here */
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+mod_rampart_shutdown(axis2_module_t *module,
+                        const axis2_env_t *env)
+{
+    if(module->ops)
+    {
+        AXIS2_FREE(env->allocator, module->ops);
+        module->ops = NULL;
+    }
+
+    if(module->handler_create_func_map)
+    {
+        /* TODO
+         *  do the neccessary clean in hash map
+         */
+        axis2_hash_free(module->handler_create_func_map, env);
+        module->handler_create_func_map = NULL;
+    }
+    
+    if(module)
+    {
+        AXIS2_FREE(env->allocator, module);
+        module = NULL;
+    }
+    return AXIS2_SUCCESS; 
+}
+
+axis2_status_t AXIS2_CALL
+mod_rampart_fill_handler_create_func_map(axis2_module_t *module,
+                                            const axis2_env_t *env)
+{
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    
+    module->handler_create_func_map = axis2_hash_make(env);
+    if(!module->handler_create_func_map)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, 
+            AXIS2_FAILURE);
+        return AXIS2_FAILURE;
+    }
+    axis2_hash_set(module->handler_create_func_map, "RampartInHandler", 
+        AXIS2_HASH_KEY_STRING, rampart_in_handler_create);
+
+    axis2_hash_set(module->handler_create_func_map, "RampartOutHandler", 
+        AXIS2_HASH_KEY_STRING, rampart_out_handler_create);
+    
+    return AXIS2_SUCCESS;
+}
+
+/**
+ * Following block distinguish the exposed part of the dll.
+ */
+
+AXIS2_EXPORT int 
+axis2_get_instance(axis2_module_t **inst,
+                   const axis2_env_t *env)
+{
+	*inst = mod_rampart_create(env);
+    if(!(*inst))
+    {
+        return AXIS2_FAILURE;
+    }
+
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int 
+axis2_remove_instance(axis2_module_t *inst,
+                      const axis2_env_t *env)
+{
+    axis2_status_t status = AXIS2_FAILURE;
+	if (inst)
+	{
+        status = mod_rampart_shutdown(inst, env);
+    }
+    return status;
+}

Added: webservices/axis2/trunk/c/rampart/src/core/user_sec_param.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/core/user_sec_param.c?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/core/user_sec_param.c (added)
+++ webservices/axis2/trunk/c/rampart/src/core/user_sec_param.c Tue Jun 13 00:52:35 2006
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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 <rampart/user_sec_param.h>
+#include <axis2_env.h>
+#include <axis2_utils.h>
+
+/********************************** Function prototypes *****************/
+
+axis2_status_t AXIS2_CALL 
+user_sec_param_free (user_sec_param_t * sec_param,
+                   const axis2_env_t *env);
+
+axis2_char_t* AXIS2_CALL
+user_sec_param_get_user(user_sec_param_t *user_sec_param,
+                    const axis2_env_t *env);
+                                            
+/*************************************** user_sec_param struct *********************/
+
+typedef struct user_sec_param_t
+{
+    /** this should be first member */
+    user_sec_param_t user_sec_param;
+    /** username*/
+    axis2_char_t *user;
+    /** password */
+    axis2_char_t *password;
+    /**  items */
+    axis2_char_t *items;
+}user_sec_param_impl_t;
+
+
+/************************* Macro ****************************************/
+
+#define USER_SEC_PARAM_INTF_TO_IMPL(qname) ((user_sec_param_impl_t*)user_sec_param)
+
+/************************************************************************/
+
+AXIS2_EXTERN user_sec_param_t *AXIS2_CALL
+user_sec_param_create (const axis2_env_t *env,
+                    const axis2_char_t * user,
+                    const axis2_char_t * password,
+                    const axis2_char_t * items)
+{
+        user_sec_param_impl_t *usp= NULL;
+        AXIS2_ENV_CHECK(env, NULL);
+
+    /* assign properties */
+    usp->user = NULL;
+    usp->password = NULL;
+    usp->items = NULL;
+
+    usp->user = (axis2_char_t *)AXIS2_STRDUP (user, env);
+    usp->password = (axis2_char_t *)AXIS2_STRDUP (password, env);
+    usp->items = (axis2_char_t *)AXIS2_STRDUP (items, env);
+
+    usp->user_sec_param.ops->free = user_sec_param_free;  
+    usp->user_sec_param.ops->get_user = user_sec_param_get_user;
+    return &(usp->user_sec_param);
+}
+
+
+axis2_status_t AXIS2_CALL 
+user_sec_param_free ( user_sec_param_t * user_sec_param,
+                   const axis2_env_t *env)
+{   
+       user_sec_param_impl_t *user_sec_param_impl = NULL;
+        AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+       user_sec_param_impl = AXIS2_INTF_TO_IMPL(user_sec_param);
+        
+        if (user_sec_param_impl->user)
+        {
+            AXIS2_FREE (env->allocator, user_sec_param_impl->user);
+            user_sec_param_impl->user = NULL;
+        }
+        if (user_sec_param_impl->password)
+        {
+            AXIS2_FREE (env->allocator, user_sec_param_impl->password);
+            user_sec_param_impl->password = NULL;
+        }
+        if (user_sec_param_impl->items)
+        {
+            AXIS2_FREE (env->allocator, user_sec_param_impl->items);
+            user_sec_param_impl->items = NULL;
+        }
+	    AXIS2_FREE (env->allocator, user_sec_param_impl);
+		return AXIS2_SUCCESS;
+}
+
+
+axis2_char_t* AXIS2_CALL
+user_sec_param_get_user(user_sec_param_t *user_sec_param,
+                    const axis2_env_t *env)
+{
+    AXIS2_ENV_CHECK(env,NULL);
+    return USER_SEC_PARAM_INTF_TO_IMPL(user_sec_param)->user;
+}

Added: webservices/axis2/trunk/c/rampart/src/data/module.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/data/module.xml?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/data/module.xml (added)
+++ webservices/axis2/trunk/c/rampart/src/data/module.xml Tue Jun 13 00:52:35 2006
@@ -0,0 +1,19 @@
+<module name="rampart" class="mod_rampart">
+    <inflow>
+        <handler name="RampartInHandler" class="mod_rampart">
+            <order phase="PreDispatch"/>
+        </handler>
+    </inflow>
+
+    <outflow>
+        <handler name="RampartOutHandler" class="mod_rampart">
+            <order phase="MessageOut"/>
+        </handler>
+    </outflow>
+
+    <Outfaultflow>
+        <handler name="RampartOutHandler" class="mod_rampart">
+            <order phase="MessageOut"/>
+        </handler>
+    </Outfaultflow>
+</module>

Modified: webservices/axis2/trunk/c/rampart/src/handlers/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/handlers/Makefile.am?rev=413826&r1=413825&r2=413826&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/handlers/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/handlers/Makefile.am Tue Jun 13 00:52:35 2006
@@ -1,9 +1,8 @@
 TESTS =
-noinst_LTLIBRARIES = libaxis2_woden_handlers.la
-
-libaxis2_woden_handlers_la_SOURCES = \
-				om_util.c \
-				generic_obj.c
+noinst_LTLIBRARIES = librampart_handlers.la
 
+librampart_handlers_la_SOURCES = \
+				rampart_out_handler.c\
+				rampart_in_handler.c
 INCLUDES = -I$(top_builddir)/include \
 			@UTILINC@

Added: webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c (added)
+++ webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c Tue Jun 13 00:52:35 2006
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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 <axis2_handler_desc.h>
+#include <axis2_array_list.h>
+#include <axiom_soap_const.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_header_block.h>
+#include <axis2_op.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_msg_info_headers.h>
+#include <axis2_property.h>
+#include <rampart/rampart_constants.h>
+#include <rampart/username_token.h>
+#include <rampart/rampart_handler_util.h>
+
+/*************************** Function headers *********************************/
+
+axis2_status_t AXIS2_CALL
+rampart_in_handler_invoke(struct axis2_handler *handler, 
+                         const axis2_env_t *env,
+                         struct axis2_msg_ctx *msg_ctx);
+
+/**********************end of header functions ****************************/
+
+AXIS2_EXTERN axis2_handler_t *AXIS2_CALL
+rampart_in_handler_create(const axis2_env_t *env, 
+                         axis2_qname_t *qname) 
+{
+    axis2_handler_t *handler = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
+    handler = axis2_handler_create(env);
+    if (!handler)
+    {
+        return NULL;
+    }
+    if (handler->ops) 
+        handler->ops->invoke = rampart_in_handler_invoke;
+
+    return handler;
+}
+
+
+axis2_status_t AXIS2_CALL
+rampart_in_handler_invoke(struct axis2_handler *handler, 
+                         const axis2_env_t *env,
+                         struct axis2_msg_ctx *msg_ctx)
+{
+    axiom_soap_envelope_t *soap_envelope = NULL;
+    axiom_soap_header_t *soap_header = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+    axis2_param_t *param_in_flow_security = NULL;
+    axis2_ctx_t *ctx = NULL;
+    axis2_array_list_t *action_list = NULL;
+    axis2_param_t *param_action = NULL;
+    axis2_char_t *items = NULL;
+    axiom_node_t *sec_node, *ts_node = NULL;
+    axiom_element_t *sec_ele, *ts_ele = NULL;
+    
+    AXIS2_ENV_CHECK( env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+    
+    rampart_print_info(env," Starting rampart in handler ");    
+    
+    soap_envelope = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(msg_ctx, env);
+    
+    if (soap_envelope)
+    {
+        soap_header = AXIOM_SOAP_ENVELOPE_GET_HEADER(soap_envelope, env);
+        if (soap_header)
+        { 
+            rampart_print_info(env,"soap header found");
+            /*Check InFlowSecurity parameters*/
+
+            ctx = AXIS2_MSG_CTX_GET_BASE (msg_ctx, env);
+            param_in_flow_security = rampart_get_security_param( env,msg_ctx,RAMPART_INFLOW_SECURITY);
+
+            if(!param_in_flow_security)
+            {
+                rampart_print_info(env,"No Inflow Security. So nothing to do");
+                return AXIS2_SUCCESS;
+            }else
+            {
+                rampart_print_info(env,"Inflow Security found");
+            }
+
+            /*Get actions*/
+            action_list = rampart_get_actions(env, ctx, param_in_flow_security);
+
+            rampart_print_info(env,"checking action list...");
+            if(!action_list)
+            {
+                rampart_print_info(env,"action_list is empty");
+                return AXIS2_SUCCESS;
+            }
+
+            if(AXIS2_ARRAY_LIST_IS_EMPTY(action_list, env))
+            {
+                rampart_print_info(env,"No actions defined");
+                return AXIS2_SUCCESS;
+            }
+
+            /*Now we support only one action.i.e. Only the first action*/
+            param_action = (axis2_param_t*) AXIS2_ARRAY_LIST_GET(action_list, env, 0);
+
+            if(!param_action)
+            {
+                rampart_print_info(env,"Cannot find first action element");
+                return AXIS2_FAILURE;
+            }
+      
+            items= rampart_get_action_params(env, ctx,param_action,RAMPART_ACTION_ITEMS);
+    
+            if(!items)
+            {
+                rampart_print_info(env,"No items ... ");
+                return AXIS2_FAILURE;
+            }
+                 
+            axis2_char_t* item = NULL;
+            item = strtok (items," ");
+            while (item != NULL)
+            {
+                if( 0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_USERNAMETOKEN, AXIS2_STRTRIM(env, item, NULL)) )
+                {
+                        rampart_print_info(env,"Validate usernametoken ");
+                        axis2_status_t valid_user = rampart_validate_username_token(env, msg_ctx,soap_header, param_action);
+                        if(valid_user)
+                        {
+                            rampart_print_info(env,"I know this user ");
+                            status = AXIS2_SUCCESS;
+                        }else{
+                            rampart_print_info(env,"I don't know this user ");
+                            return AXIS2_FAILURE;
+                        }
+                    
+                }else if (0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_TIMESTAMP, AXIS2_STRTRIM(env, item, NULL))){
+                         rampart_print_info(env,"Validate timestamp ");
+                         sec_node = rampart_get_security_token(env, msg_ctx, soap_header);
+                         sec_ele = AXIOM_NODE_GET_DATA_ELEMENT(sec_node, env);
+                    
+                         axis2_qname_t *qname = NULL;
+                         qname = axis2_qname_create(env,
+                                     RAMPART_SECURITY_TIMESTAMP,
+                                     RAMPART_WSU_XMLNS,
+                                     RAMPART_WSU);
+                         if(qname)
+                         {
+                             ts_ele = AXIOM_ELEMENT_GET_FIRST_CHILD_WITH_QNAME(sec_ele, env, qname, sec_node, &ts_node);
+                             if(!ts_ele)
+                             {
+                                 AXIS2_LOG_INFO(env->log,"Cannot find Timestamp in Security element...");
+                                 return AXIS2_FAILURE;
+                             }
+                         }
+                         axis2_status_t valid_ts = rampart_validate_timestamp(env, ts_node);               
+                         if(valid_ts)
+                        {
+                            rampart_print_info(env,"Timestamp is valid ");
+                            status = AXIS2_SUCCESS;
+                        }else{
+                            rampart_print_info(env,"Timestamp is not valid");
+                            return AXIS2_FAILURE;
+                        }   
+                }else{
+                    rampart_print_info(env," Rampart validates UsernameTokensOnly");
+                    return AXIS2_SUCCESS;
+                }
+                
+                item = strtok (NULL, " ");
+
+            } /* End of While */
+        } /* End of sec_header */
+        
+    }/* End of soap_envelope */
+    return status;
+}

Added: webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c (added)
+++ webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c Tue Jun 13 00:52:35 2006
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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 <axis2_handler_desc.h>
+#include <axis2_qname.h>
+#include <axis2_svc.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_body.h>
+#include <axiom_soap_header_block.h>
+#include <axis2_endpoint_ref.h>
+#include <axis2_property.h>
+#include <rampart/rampart_constants.h>
+#include <rampart/username_token.h>
+#include <rampart/rampart_handler_util.h>
+
+/*********************** Function headers *********************************/
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_out_handler_invoke (struct axis2_handler *handler,
+                               const axis2_env_t * env,
+                               struct axis2_msg_ctx *msg_ctx);
+                                   
+
+ 
+/**********************end of header functions ****************************/
+
+AXIS2_EXTERN axis2_handler_t *AXIS2_CALL
+rampart_out_handler_create(const axis2_env_t *env, axis2_qname_t *qname)
+{
+    axis2_handler_t *handler = NULL;
+    axis2_qname_t *handler_qname = NULL;
+
+    AXIS2_ENV_CHECK (env, NULL);
+
+    if (qname)
+    {
+        handler_qname = AXIS2_QNAME_CLONE (qname, env);
+        if (!(handler_qname))
+        {
+            AXIS2_ERROR_SET (env->error, AXIS2_ERROR_NO_MEMORY,
+                             AXIS2_FAILURE);
+            return NULL;
+        }
+    }
+    else
+    {
+        /* create default qname */
+        handler_qname = axis2_qname_create (env, "rampart_out_handler",
+                                            "http://axis.ws.apache.org",
+                                            NULL);
+        if (!handler_qname)
+        {
+            return NULL;
+        }
+    }
+
+    handler = axis2_handler_create (env);
+    if (!handler)
+    {
+        return NULL;
+    }
+
+    /* set the base struct's invoke op */
+    if (handler->ops)
+        handler->ops->invoke = rampart_out_handler_invoke;
+
+    AXIS2_QNAME_FREE(handler_qname, env);
+
+    return handler;
+}
+
+
+
+
+axis2_status_t AXIS2_CALL
+rampart_out_handler_invoke (struct axis2_handler * handler,
+                               const axis2_env_t * env, axis2_msg_ctx_t * msg_ctx)
+{
+    axis2_msg_info_headers_t *msg_info_headers = NULL;
+    axis2_ctx_t *ctx = NULL;
+    axiom_soap_envelope_t *soap_envelope = NULL;
+    axiom_soap_header_t *soap_header = NULL;
+    axiom_node_t *soap_header_node = NULL;
+    axiom_element_t *soap_header_ele = NULL;
+    axis2_param_t *param_out_flow_security = NULL;
+    axiom_node_t *sec_node =  NULL;    
+    axiom_element_t *sec_ele = NULL;
+	axis2_array_list_t *action_list = NULL;
+    axis2_param_t *param_action = NULL;
+    axis2_char_t *items = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK (env->error, msg_ctx, AXIS2_FAILURE);
+
+    msg_info_headers = AXIS2_MSG_CTX_GET_MSG_INFO_HEADERS (msg_ctx, env);\
+
+    soap_envelope = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(msg_ctx, env);
+    if (!soap_envelope)
+    {
+        return AXIS2_FAILURE;
+    }
+    
+    /*We are checking for the soap header element*/
+    soap_header  = AXIOM_SOAP_ENVELOPE_GET_HEADER (soap_envelope, env);
+  
+    if (!soap_header)
+    {
+        /*No SOAP header, so no point of proceeding*/
+        return AXIS2_SUCCESS; 
+    }
+    
+    /*if the soap header is available then add the security header*/
+    if (soap_header)
+    {
+        soap_header_node=AXIOM_SOAP_HEADER_GET_BASE_NODE(soap_header, env);
+        soap_header_ele = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT (soap_header_node, env);
+
+        axiom_soap_header_block_t *sec_header_block = NULL;
+        axiom_namespace_t *sec_ns_obj = NULL;  
+        ctx = AXIS2_MSG_CTX_GET_BASE (msg_ctx, env);   
+        param_out_flow_security = rampart_get_security_param( env,msg_ctx, RAMPART_OUTFLOW_SECURITY);
+
+        if(!param_out_flow_security)
+        {
+            rampart_print_info(env,"No Outflow Security");
+            return AXIS2_SUCCESS;
+        }
+
+        /*Get actions*/ 
+        action_list = rampart_get_actions(env, ctx, param_out_flow_security);
+        
+        if(!action_list)
+        {
+            rampart_print_info(env,"action_list is empty");
+            return AXIS2_SUCCESS;
+        }
+        
+        if(AXIS2_ARRAY_LIST_IS_EMPTY(action_list, env))
+        {
+            rampart_print_info(env,"No actions defined");
+            return AXIS2_SUCCESS; 
+        }
+
+        /*Now we support only one action.*/
+        param_action = (axis2_param_t*) AXIS2_ARRAY_LIST_GET(action_list, env, 0);
+        
+        if(!param_action)
+        {
+            rampart_print_info(env,"Cannot find first action element");
+            return AXIS2_FAILURE;
+        }
+      
+        items= rampart_get_action_params(env, ctx,param_action,RAMPART_ACTION_ITEMS);
+
+        if(!items)
+        {
+            rampart_print_info(env,"No items ... ");
+	        return AXIS2_FAILURE;
+    	}
+  
+        sec_ns_obj =  axiom_namespace_create (env, RAMPART_WSSE_XMLNS,
+                                      RAMPART_WSSE);   
+            
+        sec_header_block = AXIOM_SOAP_HEADER_ADD_HEADER_BLOCK (soap_header,
+                                                                 env, RAMPART_SECURITY,
+                                                                 sec_ns_obj);
+        if(sec_header_block)
+        {           
+            axis2_char_t* item = NULL;
+            sec_node = AXIOM_SOAP_HEADER_BLOCK_GET_BASE_NODE (sec_header_block, env);    
+            sec_ele = (axiom_element_t *) 
+                 AXIOM_NODE_GET_DATA_ELEMENT (sec_node, env);
+
+            AXIOM_ELEMENT_DECLARE_NAMESPACE (sec_ele, env,
+                                           sec_node, sec_ns_obj);
+
+            item = strtok (items," ");
+
+            while (item != NULL)
+            {
+                if(0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_USERNAMETOKEN , AXIS2_STRTRIM(env, item, NULL)))
+                {
+                    sec_node = rampart_build_username_token(env, ctx, param_action,  sec_node, sec_ns_obj);
+    
+                }else if(0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_TIMESTAMP, AXIS2_STRTRIM(env, item, NULL)))
+                {
+                    sec_node = rampart_build_timestamp_token(env, ctx, sec_node, sec_ns_obj, 300);
+                }else
+                {
+                    rampart_print_info(env," Rampart happy to see usernametokens and timestamps at the moment");
+                }
+                item = strtok (NULL, " ");
+           }     
+        }else{
+            rampart_print_info(env,"security header block is NULL");
+        }
+
+    }
+    return AXIS2_SUCCESS;
+}

Added: webservices/axis2/trunk/c/rampart/src/util/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/Makefile.am?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/Makefile.am (added)
+++ webservices/axis2/trunk/c/rampart/src/util/Makefile.am Tue Jun 13 00:52:35 2006
@@ -0,0 +1,11 @@
+TESTS =
+
+noinst_LTLIBRARIES = librampart_util.la
+
+librampart_util_la_SOURCES = rampart_crypto_util.c rampart_util.c rampart_handler_util.c username_token.c  timestamp_token.c
+
+librampart_util_la_LIBADD  = -lssl\
+			-lcrypto 
+
+INCLUDES = -I$(top_builddir)/include \
+			@UTILINC@

Added: 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?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c (added)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c Tue Jun 13 00:52:35 2006
@@ -0,0 +1,57 @@
+/*
+ *   Copyright 2003-2004 The Apache Software Foundation.
+ *
+ *   Licensed 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.
+ */
+
+/* Rampart_crypto_util will contain crypto functionalities of the rampart model
+ * 
+ */
+#include <stdio.h>
+#include <rampart/rampart_crypto_util.h>
+#include <axis2_util.h>
+#include <axis2_base64.h>
+
+/*Calculate the hash of concatenated string of 
+ * nonce, created and the password.
+ * 
+ */
+#define SIZE 256
+#define SIZE_HASH 32
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL rampart_crypto_sha1(const axis2_env_t *env, 
+					const axis2_char_t *nonce,
+					const axis2_char_t *created,
+					const axis2_char_t *password)
+					
+{
+	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);
+	result = AXIS2_MALLOC(env->allocator, SHA_DIGEST_LENGTH + 1);
+    
+	SHA1(input,SHA_DIGEST_LENGTH, result);
+	result[SHA_DIGEST_LENGTH + 1] = '\0';
+	  
+	encoded_str = AXIS2_MALLOC(env->allocator, axis2_base64_encode_len(SIZE_HASH));
+	axis2_base64_encode(encoded_str, result, AXIS2_STRLEN(result));
+	
+    AXIS2_FREE(env->allocator, input);
+    AXIS2_FREE(env->allocator, result);
+
+	return encoded_str;
+}

Added: webservices/axis2/trunk/c/rampart/src/util/rampart_handler_util.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_handler_util.c?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_handler_util.c (added)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_handler_util.c Tue Jun 13 00:52:35 2006
@@ -0,0 +1,240 @@
+/*
+ *Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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 <rampart/rampart_handler_util.h>
+#include <axis2_handler_desc.h>
+#include <axis2_qname.h>
+#include <axis2_svc.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_body.h>
+#include <axiom_soap_header_block.h>
+#include <axis2_endpoint_ref.h>
+#include <axis2_property.h>
+#include <rampart/rampart_constants.h>
+#include <rampart/rampart_callback.h>
+#include <axis2_dll_desc.h>
+#include <axis2_class_loader.h>
+
+AXIS2_EXTERN axis2_param_t* AXIS2_CALL
+rampart_get_security_param( const axis2_env_t *env,
+		                const axis2_msg_ctx_t *msg_ctx,
+                         const axis2_char_t *parameter);
+                         
+AXIS2_EXTERN axis2_array_list_t* AXIS2_CALL
+rampart_get_actions( const axis2_env_t *env,
+                                            const axis2_ctx_t *ctx,
+		                                    const axis2_param_t *param_x_flow_security);
+                                            
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+rampart_get_action_params( const axis2_env_t *env,
+                   const axis2_ctx_t *ctx,
+                   const axis2_param_t *param_action,
+                   const axis2_char_t *key);
+                        
+ AXIS2_EXTERN axiom_node_t *AXIS2_CALL
+rampart_get_security_token(const axis2_env_t *env,
+                                const axis2_msg_ctx_t *msg_ctx,
+                                axiom_soap_header_t *soap_header);
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+rampart_callback_pw( const axis2_env_t *env,
+                     const axis2_char_t *callback_module_name,
+                     const axis2_char_t *username);
+
+/**********************end of header functions ****************************/
+
+
+axis2_param_t* AXIS2_CALL
+rampart_get_security_param( const axis2_env_t *env,
+		                const axis2_msg_ctx_t *msg_ctx,
+                         const axis2_char_t *parameter)
+{
+  
+  
+        axis2_conf_ctx_t *conf_ctx = NULL;
+        axis2_conf_t *conf = NULL;
+        axis2_param_t *param= NULL;
+
+         conf_ctx = AXIS2_MSG_CTX_GET_CONF_CTX(msg_ctx, env);
+         if(NULL == conf_ctx)
+          {
+              return NULL;
+          }
+         conf = AXIS2_CONF_CTX_GET_CONF(conf_ctx, env);
+         if(NULL == conf)
+         {
+           return NULL;
+         }
+         param= AXIS2_CONF_GET_PARAM(conf, env, parameter); 
+
+         return param;
+}
+
+
+axis2_array_list_t *AXIS2_CALL
+rampart_get_actions( const axis2_env_t *env,
+        const axis2_ctx_t *ctx,
+        const axis2_param_t *param_x_flow_security)
+{
+    axis2_array_list_t *action_list = NULL;
+    if(!param_x_flow_security)
+    {
+        AXIS2_LOG_INFO(env->log,"param_in_flow_security is NULL");
+        return action_list;
+    }
+    
+    /*ERROR HERE param returns TEXT even for DOM*/
+    int param_type = AXIS2_PARAM_GET_PARAM_TYPE(param_x_flow_security, env);
+
+    action_list = AXIS2_PARAM_GET_VALUE_LIST(param_x_flow_security, env);
+    if(!action_list)
+    {
+            AXIS2_LOG_INFO(env->log," action_list is NULL ... ERROR ");
+    }
+    return action_list;
+}
+
+
+axis2_char_t* AXIS2_CALL
+rampart_get_action_params( const axis2_env_t *env,
+                   const axis2_ctx_t *ctx,
+                   const axis2_param_t *param_action,
+                   const axis2_char_t *key)
+{
+    axis2_char_t *value, *tmp_key = NULL;
+    axis2_array_list_t *param_list = NULL;
+    axis2_param_t *param = NULL;
+    
+    int i, size = 0;
+    if(!param_action)
+    {
+        printf("param_action is NULL");
+    }
+    
+    int param_type = AXIS2_PARAM_GET_PARAM_TYPE(param_action, env);
+    axis2_char_t * param_name = AXIS2_PARAM_GET_NAME(param_action, env);
+    printf(" parameter Type =%d Name = %s", param_type, param_name);
+    
+    param_list = AXIS2_PARAM_GET_VALUE_LIST(param_action, env);
+    if(!param_list)
+    {
+        printf("param list is null");
+    }
+    
+    size = AXIS2_ARRAY_LIST_SIZE(param_list, env);    
+    for (i = 0; i < size; i = i + 1)
+    {
+        param = (axis2_param_t*) AXIS2_ARRAY_LIST_GET(param_list, env, i);
+        if(param)
+        {
+           tmp_key = AXIS2_PARAM_GET_NAME(param, env);
+
+           if(0 == AXIS2_STRCMP(tmp_key , key) ) 
+            {
+                value = AXIS2_PARAM_GET_VALUE(param, env);
+                return value;
+            }
+        }
+    }
+
+    return value;
+}
+
+axiom_node_t *AXIS2_CALL
+rampart_get_security_token(const axis2_env_t *env,
+                                const axis2_msg_ctx_t *msg_ctx,
+                                axiom_soap_header_t *soap_header
+                                )
+{
+    axis2_array_list_t *sec_headers = NULL;
+    axis2_char_t *sec_ns_str = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+    axis2_hash_index_t *hash_index =  NULL;
+    axis2_hash_t *header_block_ht = NULL;
+    axis2_msg_info_headers_t *msg_info_headers = AXIS2_MSG_CTX_GET_MSG_INFO_HEADERS(msg_ctx, env);
+    axiom_element_t *header_block_ele = NULL;
+    axiom_node_t *header_block_node = NULL;
+
+    sec_headers = AXIOM_SOAP_HEADER_GET_HEADER_BLOCKS_WITH_NAMESPACE_URI(soap_header, env, RAMPART_WSSE_XMLNS);     
+    if(sec_headers)
+    {
+        sec_ns_str = AXIS2_STRDUP(RAMPART_WSSE_XMLNS, env);
+
+        header_block_ht = AXIOM_SOAP_HEADER_GET_ALL_HEADER_BLOCKS(soap_header, env);
+        if(!header_block_ht)
+          return AXIS2_FAILURE;    
+
+        for(hash_index = axis2_hash_first(header_block_ht, env); hash_index;
+            hash_index = axis2_hash_next(env, hash_index))
+        {   
+
+            void *hb = NULL;
+            axiom_soap_header_block_t *header_block =    NULL;
+            axis2_char_t *ele_localname = NULL;
+            
+            axis2_hash_this(hash_index, NULL, NULL, &hb);
+            header_block = (axiom_soap_header_block_t *)hb;
+            header_block_node = AXIOM_SOAP_HEADER_BLOCK_GET_BASE_NODE(header_block, env);
+            header_block_ele  = (axiom_element_t*)AXIOM_NODE_GET_DATA_ELEMENT(header_block_node, env);
+            ele_localname = AXIOM_ELEMENT_GET_LOCALNAME(header_block_ele, env);
+    
+            if(AXIS2_STRCMP(ele_localname, RAMPART_SECURITY) == 0)
+            {
+                return header_block_node;
+            }
+        
+        }/*End of for*/
+   }
+
+    return header_block_node;
+
+}
+
+axis2_char_t* AXIS2_CALL
+rampart_callback_pw( const axis2_env_t *env,
+                     const axis2_char_t *callback_module_name,
+                     const axis2_char_t *username)
+{
+    rampart_callback_t* rcb = NULL;
+    axis2_char_t *password = NULL;
+    axis2_dll_desc_t *dll_desc = NULL;
+    void *ptr = NULL;
+    axis2_param_t *impl_info_param = NULL;
+
+    dll_desc = axis2_dll_desc_create(env);
+    AXIS2_DLL_DESC_SET_NAME(dll_desc, env, callback_module_name);
+    impl_info_param = axis2_param_create(env, NULL, NULL);
+    AXIS2_PARAM_SET_VALUE(impl_info_param, env, dll_desc);
+    axis2_class_loader_init(env);
+    ptr = axis2_class_loader_create_dll(env, impl_info_param);
+
+    /*callback()*/
+    if(!ptr)
+    {
+        printf("\nCallback ptr is null");
+        return NULL;
+    }
+        
+    rcb = (rampart_callback_t*)ptr;
+    if(!rcb)
+    {
+        printf("\nrampart_callback_t is null");
+        return NULL;
+    }
+    password = rcb->ops->get_password(rcb, env, username);
+
+    return password;
+}

Added: webservices/axis2/trunk/c/rampart/src/util/rampart_util.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_util.c?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_util.c (added)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_util.c Tue Jun 13 00:52:35 2006
@@ -0,0 +1,78 @@
+/*
+ *   Copyright 2003-2004 The Apache Software Foundation.
+ *
+ *   Licensed 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.
+ */
+
+/* Rampart_crypto_util will contain crypto functionalities of the rampart model
+ * 
+ */
+#include <stdio.h>
+#include <rampart/rampart_util.h>
+#include <axis2_util.h>
+#include <time.h>
+
+/*Calculate the hash of concatenated string of 
+ * nonce, created and the password.
+ * 
+ */
+#define SIZE 256
+#define SIZE_HASH 32
+#define SIZE_NONCE 24
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL rampart_generate_nonce(const axis2_env_t *env)
+{
+	int num;
+	char* rand_str = NULL;
+	num=rand();
+	rand_str= AXIS2_MALLOC(env->allocator,16);
+	sprintf(rand_str, "%16d", num);
+
+	axis2_char_t* encoded_str=NULL;
+    encoded_str = AXIS2_MALLOC(env->allocator, axis2_base64_encode_len(SIZE_NONCE));
+    axis2_base64_encode(encoded_str,rand_str,AXIS2_STRLEN(rand_str));
+    AXIS2_FREE(env->allocator, rand_str);
+	return encoded_str;
+}
+
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL rampart_generate_time(const axis2_env_t *env, int ttl)
+{
+	char buffer[SIZE];
+	time_t curtime;
+	struct tm *loctime;
+	axis2_char_t* created_str=NULL;
+ 
+	curtime = time (NULL) + ttl;
+	loctime = localtime (&curtime);
+  	strftime (buffer, SIZE, "%Y-%m-%dT%H:%M:%SZ\n", loctime);
+    created_str = AXIS2_STRDUP(buffer, env);
+    
+	return created_str;
+}
+
+AXIS2_EXTERN int AXIS2_CALL 
+rampart_format_date_zulu_to_mili(const axis2_env_t *env, axis2_char_t *str)
+{
+    /*TODO Get the time in mili sec from the string*/
+
+   
+ 
+    return 1000000;/*TODO*/
+}
+
+AXIS2_EXTERN axis2_status_t* AXIS2_CALL 
+rampart_print_info(const axis2_env_t *env, axis2_char_t* info)
+{
+    /*printf("[rampart]: %s\n", info);*/
+}

Added: 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?rev=413826&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/timestamp_token.c (added)
+++ webservices/axis2/trunk/c/rampart/src/util/timestamp_token.c Tue Jun 13 00:52:35 2006
@@ -0,0 +1,145 @@
+/*
+ *Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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 <axis2_qname.h>
+#include <axis2_svc.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_body.h>
+#include <axiom_soap_header_block.h>
+#include <axis2_endpoint_ref.h>
+#include <axis2_property.h>
+#include <rampart/rampart_constants.h>
+#include <rampart/rampart_crypto_util.h>
+#include <rampart/rampart_util.h>
+
+/*************************** Function headers *********************************/
+
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+rampart_build_timestamp_token(const axis2_env_t *env,
+                                const axis2_ctx_t *ctx,
+                                axiom_node_t *sec_node,
+                                const  axiom_namespace_t *sec_ns_obj,
+                                int ttl
+                                );
+                                
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_validate_timestamp(const axis2_env_t *env,
+                                                        axiom_node_t *ts_node);
+
+/************************* End of function headers ****************************/
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+rampart_build_timestamp_token(const axis2_env_t *env,
+                                const axis2_ctx_t *ctx,
+                                axiom_node_t *sec_node,
+                                const  axiom_namespace_t *sec_ns_obj,
+                                int ttl
+                                )
+{
+
+    axiom_node_t  *ts_node, *created_node, *expires_node = NULL;    
+    axiom_element_t  *ts_ele, *created_ele, *expires_ele = NULL;
+    axis2_char_t *created_val, *expires_val = NULL;
+    axiom_namespace_t *wsu_ns_obj = NULL;
+
+    wsu_ns_obj = axiom_namespace_create (env, RAMPART_WSU_XMLNS,
+                                              RAMPART_WSU);
+    
+    ts_ele = axiom_element_create (env, sec_node, 
+                                        RAMPART_SECURITY_TIMESTAMP, 
+                                        wsu_ns_obj,
+                                        &ts_node);
+    if(NULL != ts_ele)
+    {
+         
+         created_ele = axiom_element_create (env, ts_node, RAMPART_SECURITY_TIMESTAMP_CREATED, wsu_ns_obj,
+                                             &created_node);
+        
+        if(NULL != created_ele)
+        {
+             created_val = rampart_generate_time(env, 0);   /*Current time*/
+             AXIOM_ELEMENT_SET_TEXT (created_ele, env, created_val, created_node);                     
+        }    
+        
+        
+         expires_ele = axiom_element_create (env, ts_node, RAMPART_SECURITY_TIMESTAMP_EXPIRES, wsu_ns_obj,
+                                             &expires_node);
+        
+        if(NULL != expires_ele)
+        {
+              expires_val = rampart_generate_time(env, ttl);
+              AXIOM_ELEMENT_SET_TEXT (expires_ele, env, expires_val, expires_node);           
+            
+        }       
+    }
+    
+    return sec_node;
+}/*rampart_build_timestamp_token*/
+
+                                
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_validate_timestamp(const axis2_env_t *env,
+                                                        axiom_node_t *ts_node)
+{
+    axis2_status_t validity = AXIS2_FAILURE;
+    axis2_qname_t *created_qname, *expires_qname = NULL;
+    axiom_element_t *created_ele, *expires_ele , *ts_ele= NULL;
+    axiom_node_t *created_node, *expires_node = NULL;
+    axis2_char_t *created_val, *expires_val = NULL;    
+    
+    ts_ele = AXIOM_NODE_GET_DATA_ELEMENT(ts_node, env);
+    
+    if(!ts_ele)
+    {
+        AXIS2_LOG_INFO(env->log," Cannot find timestamp ... :(");
+        return AXIS2_FAILURE;
+    }
+    
+    created_qname = axis2_qname_create(env,
+                                 RAMPART_SECURITY_TIMESTAMP_CREATED,
+                                 RAMPART_WSU_XMLNS,
+                                 RAMPART_WSU);
+    if(created_qname)
+    {
+        created_ele = AXIOM_ELEMENT_GET_FIRST_CHILD_WITH_QNAME(ts_ele, env, created_qname, ts_node, &created_node);
+        if(!created_ele)
+        {
+            AXIS2_LOG_INFO(env->log,"Cannot find created  in timestamp element...");
+            return AXIS2_FAILURE;
+        }
+    }
+
+     expires_qname = axis2_qname_create(env,
+                                 RAMPART_SECURITY_TIMESTAMP_EXPIRES,
+                                 RAMPART_WSU_XMLNS,
+                                 RAMPART_WSU);
+    if(expires_qname)
+    {
+        expires_ele = AXIOM_ELEMENT_GET_FIRST_CHILD_WITH_QNAME(ts_ele, env, expires_qname, ts_node, &expires_node);
+        if(!expires_ele)
+        {
+            AXIS2_LOG_INFO(env->log,"Cannot find expires  in timestamp element...");
+            return AXIS2_FAILURE;
+        }
+    }
+    
+    created_val = AXIOM_ELEMENT_GET_TEXT(created_ele, env, created_node);
+    expires_val = AXIOM_ELEMENT_GET_TEXT(expires_ele, env, expires_node);
+    
+    /*TODO check weather time has expired or not*/
+    
+    validity = AXIS2_SUCCESS;
+    /*free memory for qnames*/
+    return validity;
+}



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


Mime
View raw message