Hi Dave,

Please take a look at the attached sample, which makes use of the message
context. Read through the axis2_http_transport.h for more possibilities in
terms of constants you can use. We use these constants to add info to the
hash and therefore, you'll have to use them too.

Regards,
Senaka

> Hi Senaka,
>
> I saw this email after the one I just responded to.  That would be great
> if you have any code samples or let me know how to get at the http
> header.
> Our web services allow simple authentication as arguments, http basic
> auth,
> or WS-SECURITY.  So I will definately be using the Rampart/C code as
> well.
>
> I also will need to mess around with stuff in the SOAP envelope and
> headers
> as we have some other custom stuff implemented in gsoap that embeds some
> XML with other authentication info.  So I will need to find out how to
> process things at a lower level on both input and output for the server
> code.
>
> Thanks,
>
> -Dave.
>
> -----Original Message-----
> From: Senaka Fernando [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 11, 2008 9:13 PM
> To: Apache AXIS C Developers List
> Subject: Re: [AXIS2C] HTTP Basic Authentication question
>
> Hi Dave,
>
> Do you mean access to Authentication info on the server side? Well that
> is not implemented as yet. However, you may be able to access the Auth
> Header and make use of the Basic Authentication Credentials. I will look
> into this and let you know.
>
> We did not focus on server side Authentication as we do have WS-Security
> support, Rampart/C, which can provide you the ability to handle this,
> and many other security related scenarios. You can find more info on
> Rampart/C at [1].
>
> [1] http://ws.apache.org/rampart/c/
>
> Regards,
> Senaka
>
>> Hi All,
>>
>> With my gsoap web services I can get at the userid and password that
>> are passed in the HTTP header using HTTP Basic Authentication.  It
>> decodes the password as well and sticks both the userid and password
>> in the structure that it passes to me.
>>
>> I want to offer the same support with my Axis2/C implementation.  Does
>
>> the Axis2/C code do something similar to the above?  I'm basically
>> just wanting to get a userid and password passed via HTTP Basic auth
>> and use these credentials in my code to log the user in.
>>
>> Thanks,
>>
>> -Dave.
>>
>> **********************************************************************
>> This email and any files transmitted with it are confidential and
>> intended solely for the use of the individual or entity to whom they
> are addressed.
>> Any unauthorized review, use, disclosure or distribution is
>> prohibited. If you are not the intended recipient, please contact the
>> sender by reply e-mail and destroy all copies of the original message.
>> **********************************************************************
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
/*
 * 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 <axis2_svc_skeleton.h>
#include "echo.h"
#include <axutil_array_list.h>
#include <axis2_msg_ctx.h>
#include <stdio.h>
#include <axis2_http_header.h>
#include <axis2_http_transport.h>

int AXIS2_CALL echo_free(
    axis2_svc_skeleton_t * svc_skeleton,
    const axutil_env_t * env);

/*
 * This method invokes the right service method
 */
axiom_node_t *AXIS2_CALL echo_invoke(
    axis2_svc_skeleton_t * svc_skeleton,
    const axutil_env_t * env,
    axiom_node_t * node,
    axis2_msg_ctx_t * msg_ctx);

int AXIS2_CALL echo_init(
    axis2_svc_skeleton_t * svc_skeleton,
    const axutil_env_t * env);

axiom_node_t *AXIS2_CALL echo_on_fault(
    axis2_svc_skeleton_t * svc_skeli,
    const axutil_env_t * env,
    axiom_node_t * node);

static const axis2_svc_skeleton_ops_t echo_svc_skeleton_ops_var = {
    echo_init,
    echo_invoke,
    echo_on_fault,
    echo_free
};

/*Create function */
axis2_svc_skeleton_t *
axis2_echo_create(
    const axutil_env_t * env)
{
    axis2_svc_skeleton_t *svc_skeleton = NULL;
    /* Allocate memory for the structs */
    svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t));

    svc_skeleton->ops = &echo_svc_skeleton_ops_var;

    svc_skeleton->func_array = NULL;

    return svc_skeleton;
}

/* Initialize the service */
int AXIS2_CALL
echo_init(
    axis2_svc_skeleton_t * svc_skeleton,
    const axutil_env_t * env)
{
    /* Any initialization stuff of echo service should go here */
    return AXIS2_SUCCESS;
}

/*
 * This method invokes the right service method
 */
axiom_node_t *AXIS2_CALL
echo_invoke(
    axis2_svc_skeleton_t * svc_skeleton,
    const axutil_env_t * env,
    axiom_node_t * node,
    axis2_msg_ctx_t * msg_ctx)
{
    /* Invoke the business logic.
     * Depending on the function name invoke the correct impl method.
     * We have only echo in this sample, hence invoke echo method.
     * To see how to deal with multiple impl methods, have a look at the
     * math sample.
     */

    axutil_hash_t *headers = NULL;

    headers = axis2_msg_ctx_get_transport_headers(msg_ctx, env);
    if (headers)
    {
        axis2_http_header_t *test_header = NULL;
        test_header = (axis2_http_header_t *) axutil_hash_get(
            headers,
            AXIS2_HTTP_HEADER_CONTENT_LENGTH,
            AXIS2_HASH_KEY_STRING);

        if (test_header)
        {
            axis2_char_t *test_value = NULL;
            test_value = axis2_http_header_get_value(test_header, env);
            printf("Content-Length: %s\n", test_value);
        }
    }


    return axis2_echo_echo(env, node);
}

/* On fault, handle the fault */
axiom_node_t *AXIS2_CALL
echo_on_fault(
    axis2_svc_skeleton_t * svc_skeli,
    const axutil_env_t * env,
    axiom_node_t * node)
{
    /* Here we are just setting a simple error message inside an element
     * called 'EchoServiceError' 
     */
    axiom_node_t *error_node = NULL;
    axiom_element_t *error_ele = NULL;

    error_ele =
        axiom_element_create(env, NULL, "EchoServiceError", NULL, &error_node);
    axiom_element_set_text(error_ele, env, "Echo service failed ", error_node);
    return error_node;
}

/* Free the resources used */
int AXIS2_CALL
echo_free(
    axis2_svc_skeleton_t * svc_skeleton,
    const axutil_env_t * env)
{
    /* Free the function array */
    if (svc_skeleton->func_array)
    {
        axutil_array_list_free(svc_skeleton->func_array, env);
        svc_skeleton->func_array = NULL;
    }

    /* Free the service skeleton */
    if (svc_skeleton)
    {
        AXIS2_FREE(env->allocator, svc_skeleton);
        svc_skeleton = NULL;
    }

    return AXIS2_SUCCESS;
}

/**
 * Following block distinguish the exposed part of the dll.
 */
AXIS2_EXPORT int
axis2_get_instance(
    axis2_svc_skeleton_t ** inst,
    const axutil_env_t * env)
{
    *inst = axis2_echo_create(env);
    if (!(*inst))
    {
        return AXIS2_FAILURE;
    }

    return AXIS2_SUCCESS;
}

AXIS2_EXPORT int
axis2_remove_instance(
    axis2_svc_skeleton_t * inst,
    const axutil_env_t * env)
{
    axis2_status_t status = AXIS2_FAILURE;
    if (inst)
    {
        status = AXIS2_SVC_SKELETON_FREE(inst, env);
    }
    return status;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to