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 ka...@apache.org on 2007/01/29 08:34:56 UTC

svn commit: r500955 - in /webservices/axis2/trunk/c/rampart: include/ samples/ samples/credential_provider/ src/util/

Author: kaushalye
Date: Sun Jan 28 23:34:55 2007
New Revision: 500955

URL: http://svn.apache.org/viewvc?view=rev&rev=500955
Log:
Adding credentials provider sample

Added:
    webservices/axis2/trunk/c/rampart/samples/credential_provider/
    webservices/axis2/trunk/c/rampart/samples/credential_provider/Makefile.am
    webservices/axis2/trunk/c/rampart/samples/credential_provider/cred_provider.c
Modified:
    webservices/axis2/trunk/c/rampart/include/rampart_util.h
    webservices/axis2/trunk/c/rampart/samples/Makefile.am
    webservices/axis2/trunk/c/rampart/samples/configure.ac
    webservices/axis2/trunk/c/rampart/src/util/rampart_util.c
    webservices/axis2/trunk/c/rampart/src/util/username_token.c

Modified: webservices/axis2/trunk/c/rampart/include/rampart_util.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart_util.h?view=diff&rev=500955&r1=500954&r2=500955
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart_util.h (original)
+++ webservices/axis2/trunk/c/rampart/include/rampart_util.h Sun Jan 28 23:34:55 2007
@@ -22,6 +22,7 @@
 #include <axis2_property.h>
 #include <axis2_msg_ctx.h>
 #include <rampart_authn_provider.h>
+#include <rampart_credentials.h>
 /**
   * @file rampart_util.h
   * @brief Utilities of rampart 
@@ -38,6 +39,22 @@
   * @ingroup Rampart_Util
   */
 
+/**
+ *Load the credentials module
+ */
+AXIS2_EXTERN rampart_credentials_t* AXIS2_CALL
+rampart_load_credentials_module(const axis2_env_t *env,
+    axis2_char_t *cred_module_name);
+
+/**
+ *Call credentials module
+ */
+AXIS2_EXTERN rampart_credentials_status_t AXIS2_CALL
+rampart_call_credentials(const axis2_env_t *env,
+    rampart_credentials_t *cred_module,
+    axis2_msg_ctx_t *ctx,
+    axis2_char_t **username,
+    axis2_char_t **password);
 
 AXIS2_EXTERN rampart_authn_provider_status_t AXIS2_CALL
 rampart_authenticate_un_pw(const axis2_env_t *env,

Modified: webservices/axis2/trunk/c/rampart/samples/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/samples/Makefile.am?view=diff&rev=500955&r1=500954&r2=500955
==============================================================================
--- webservices/axis2/trunk/c/rampart/samples/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/samples/Makefile.am Sun Jan 28 23:34:55 2007
@@ -1,3 +1,3 @@
 TESTS =
-SUBDIRS = callback client server keys authn_provider data
+SUBDIRS = callback client server keys authn_provider data credential_provider
 

Modified: webservices/axis2/trunk/c/rampart/samples/configure.ac
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/samples/configure.ac?view=diff&rev=500955&r1=500954&r2=500955
==============================================================================
--- webservices/axis2/trunk/c/rampart/samples/configure.ac (original)
+++ webservices/axis2/trunk/c/rampart/samples/configure.ac Sun Jan 28 23:34:55 2007
@@ -80,6 +80,7 @@
         callback/Makefile \
         callback/htpasswd_callback/Makefile \
         authn_provider/Makefile \
+        credential_provider/Makefile \
         server/Makefile \
         server/sec_echo/Makefile \
         client/Makefile

Added: webservices/axis2/trunk/c/rampart/samples/credential_provider/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/samples/credential_provider/Makefile.am?view=auto&rev=500955
==============================================================================
--- webservices/axis2/trunk/c/rampart/samples/credential_provider/Makefile.am (added)
+++ webservices/axis2/trunk/c/rampart/samples/credential_provider/Makefile.am Sun Jan 28 23:34:55 2007
@@ -0,0 +1,7 @@
+prglibdir=$(prefix)/bin/samples/rampart/credential_provider
+prglib_LTLIBRARIES = libcredential.la
+libcredential_la_SOURCES = cred_provider.c
+libcredential_la_LIBADD  = ../../src/util/librampart_util.la \
+					  ../../src/omxmlsec/openssl/libomopenssl.la
+INCLUDES = -I ../../include\
+			-I$(AXIS2C_HOME)/include 

Added: webservices/axis2/trunk/c/rampart/samples/credential_provider/cred_provider.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/samples/credential_provider/cred_provider.c?view=auto&rev=500955
==============================================================================
--- webservices/axis2/trunk/c/rampart/samples/credential_provider/cred_provider.c (added)
+++ webservices/axis2/trunk/c/rampart/samples/credential_provider/cred_provider.c Sun Jan 28 23:34:55 2007
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <axis2_defines.h>
+#include <axis2_error.h>
+#include <axis2_env.h>
+#include <axis2_utils.h>
+#include <rampart_credentials.h>
+#include <rampart_crypto_util.h> 
+#include <axis2_string.h>
+#include <axis2_svc_skeleton.h>
+#include <axis2_string.h>
+
+
+rampart_credentials_status_t AXIS2_CALL
+rampart_sample_credentials_username_get(
+                rampart_credentials_t *credentials,
+                const axis2_env_t* env,
+                axis2_msg_ctx_t *msg_ctx,
+                axis2_char_t **username,
+                axis2_char_t **password
+            )
+{
+    *username = "Gampola";
+    *password = "GampolaPW";
+
+    return RAMPART_CREDENTIALS_PW_FOUND;
+}
+
+/**
+ * Following block distinguishes the exposed part of the dll.
+ */
+AXIS2_EXPORT int
+axis2_get_instance(rampart_credentials_t **inst,
+        const axis2_env_t *env)
+{
+    rampart_credentials_t* cred_p = NULL;
+
+    cred_p = AXIS2_MALLOC(env->allocator,
+            sizeof(rampart_credentials_t));
+
+    cred_p->ops = AXIS2_MALLOC(
+                env->allocator, sizeof(rampart_credentials_t));
+
+    /*assign function pointers*/
+
+    cred_p->ops->rampart_credentials_username_get = rampart_sample_credentials_username_get;
+   
+    *inst = cred_p;
+
+    if (!(*inst))
+    {
+        return AXIS2_FAILURE;
+    }
+
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int
+axis2_remove_instance(rampart_credentials_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/util/rampart_util.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_util.c?view=diff&rev=500955&r1=500954&r2=500955
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_util.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_util.c Sun Jan 28 23:34:55 2007
@@ -29,6 +29,7 @@
 #include <axis2_msg_ctx.h>
 #include <rampart_constants.h>
 #include <rampart_callback.h>
+#include <rampart_credentials.h>
 
 /*Calculate the hash of concatenated string of
  * nonce, created and the password.
@@ -41,6 +42,50 @@
 
 /*#define PRINTINFO 1 */
 
+AXIS2_EXTERN rampart_credentials_status_t AXIS2_CALL
+rampart_call_credentials(const axis2_env_t *env,
+    rampart_credentials_t *cred_module,
+    axis2_msg_ctx_t *msg_ctx,
+    axis2_char_t **username,
+    axis2_char_t **password)
+{
+    rampart_credentials_status_t cred_status = RAMPART_CREDENTIALS_GENERAL_ERROR;
+    
+    cred_status = RAMPART_CREDENTIALS_USERNAME_GET(cred_module, env, msg_ctx, username, password);
+    return cred_status;
+}
+
+AXIS2_EXTERN rampart_credentials_t* AXIS2_CALL
+rampart_load_credentials_module(const axis2_env_t *env,
+    axis2_char_t *cred_module_name)
+{
+    rampart_credentials_t *cred = NULL;
+    axis2_dll_desc_t *dll_desc = NULL;
+    axis2_param_t *impl_info_param = NULL;
+    void *ptr = NULL;
+
+    dll_desc = axis2_dll_desc_create(env);
+    AXIS2_DLL_DESC_SET_NAME(dll_desc, env, cred_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);
+
+    if (!ptr)
+    {
+        AXIS2_LOG_INFO(env->log, "[rampart][rampart_util] Unable to load the credentials module %s. ERROR", cred_module_name);
+        return AXIS2_FAILURE;
+    }
+    cred = (rampart_credentials_t*)ptr;
+    if (!cred)
+    {
+        AXIS2_LOG_INFO(env->log, "[rampart][rampart_util] Unable to identify the credentials  module %s. ERROR", cred_module_name);
+        return AXIS2_FAILURE;
+    }
+
+    return cred;
+}
+/*TODO: Seperate load and calling logic*/
 AXIS2_EXTERN rampart_authn_provider_status_t AXIS2_CALL
 rampart_authenticate_un_pw(const axis2_env_t *env,
     axis2_char_t *authn_module_name,

Modified: webservices/axis2/trunk/c/rampart/src/util/username_token.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/username_token.c?view=diff&rev=500955&r1=500954&r2=500955
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/username_token.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/username_token.c Sun Jan 28 23:34:55 2007
@@ -106,6 +106,8 @@
         return password;
     }
 
+    /*TODO: If not in the context, get the password+username from the credentials module*/
+
     /*If not check whether there is a callback class specified*/
     pw_callback_module = RAMPART_ACTIONS_GET_PW_CB_CLASS(actions, env);
     if (pw_callback_module)



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