# SCTProvider.h

Go to the documentation of this file.

    00001 /*
    00002  * Copyright 2005,2009 WSO2, Inc. http://wso2.com
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  * http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016
    00017 #ifndef SCT_PROVIDER_H
    00018 #define SCT_PROVIDER_H
    00019
    00020 #include <WSFDefines.h>
    00021 #include <string>
    00022 #include <rampart_sct_provider.h>
    00023 #include <MessageContext.h>
    00024 #include <Environment.h>
    00025
    00034 namespace wso2wsf
    00035 {
    00048     class SCTProvider
    00049     {
    00050     public:
    00057         virtual void* WSF_CALL getToken(
    00058             std::string& sct_id,
    00059             MessageContext* msgctx) = 0;
    00060
    00068         virtual bool WSF_CALL storeToken(
    00069             std::string& sct_id,
    00070             MessageContext* msgctx,
    00071             void* sct) = 0;
    00072
    00079         virtual bool WSF_CALL removeToken(
    00080             std::string& sct_id,
    00081             MessageContext* msgctx) = 0;
    00082
    00089         virtual bool WSF_CALL validateToken(
    00090             OMNode* sct_node,
    00091             MessageContext* msgctx) = 0;
    00092
    00096         WSF_EXTERN virtual WSF_CALL ~SCTProvider();
    00097
    00102         WSF_EXTERN static axis2_status_t WSF_CALL storeToken(
    00103             const axutil_env_t *env,
    00104             axis2_msg_ctx_t* msg_ctx,
    00105             axis2_char_t *sct_global_id,
    00106             axis2_char_t *sct_local_id,
    00107             void *sct,
    00108             void *user_params);
    00109
    00113         WSF_EXTERN static void* WSF_CALL getToken(
    00114             const axutil_env_t *env,
    00115             axis2_bool_t is_encryption,
    00116             axis2_msg_ctx_t* msg_ctx,
    00117             axis2_char_t *sct_id,
    00118             int sct_id_type,
    00119             void* user_params);
    00120
    00124         WSF_EXTERN static axis2_status_t WSF_CALL removeToken(
    00125             const axutil_env_t *env,
    00126             axis2_msg_ctx_t* msg_ctx,
    00127             axis2_char_t *sct_id,
    00128             int sct_id_type,
    00129             void* user_params);
    00130
    00134         WSF_EXTERN static axis2_status_t WSF_CALL validateToken(
    00135             const axutil_env_t *env,
    00136             axiom_node_t *sct_node,
    00137             axis2_msg_ctx_t *msg_ctx,
    00138             void *user_params);
    00139     };
    00141 }
    00142
    00149 #define WSF_SCT_PROVIDER_INIT(class_name) \
    00150 extern "C" \
    00151 { \
    00152     WSF_EXTERN int \
    00153     axis2_remove_instance( \
    00154         rampart_sct_provider_t *inst, \
    00155         const axutil_env_t *env) \
    00156     { \
    00157         if (inst) \
    00158         { \
    00159             AXIS2_FREE(env->allocator, inst->ops); \
    00160             AXIS2_FREE(env->allocator, inst); \
    00161         } \
    00162         return AXIS2_SUCCESS; \
    00163     } \
    00164 \
    00165     axis2_status_t WSF_CALL \
    00166     wsf_sct_provider_free( \
    00167         rampart_sct_provider_t *inst, \
    00168         const axutil_env_t *env) \
    00169     { \
    00170         return axis2_remove_instance(inst, env); \
    00171     }\
    00172 \
    00173     void* WSF_CALL wsf_sct_get_user_params(const axutil_env_t *env) \
    00174     { \
    00175         return new class_name; \
    00176     } \
    00177 \
    00178     WSF_EXTERN int \
    00179     axis2_get_instance( \
    00180         rampart_sct_provider_t **inst, \
    00181         const axutil_env_t *env) \
    00182     { \
    00183         rampart_sct_provider_t* sct_provider = NULL; \
    00184     \
    00185         sct_provider = (rampart_sct_provider_t*)AXIS2_MALLOC(env->allocator, sizeof(rampart_sct_provider_t)); \
    00186     \
    00187         sct_provider->ops = (rampart_sct_provider_ops_t *)AXIS2_MALLOC(env->allocator, sizeof(rampart_sct_provider_ops_t)); \
    00188         sct_provider->ops->obtain_security_context_token = wso2wsf::SCTProvider::getToken; \
    00189         sct_provider->ops->store_security_context_token = wso2wsf::SCTProvider::storeToken; \
    00190         sct_provider->ops->delete_security_context_token = wso2wsf::SCTProvider::removeToken; \
    00191         sct_provider->ops->validate_security_context_token = wso2wsf::SCTProvider::validateToken; \
    00192         sct_provider->ops->get_user_params = wsf_sct_get_user_params; \
    00193         sct_provider->ops->free = wsf_sct_provider_free; \
    00194     \
    00195         *inst = sct_provider; \
    00196         if (!(*inst)) \
    00197         { \
    00198             AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsf_rampart]Cannot initialize the SCT provider module"); \
    00199             return AXIS2_FAILURE; \
    00200         } \
    00201 \
    00202         wso2wsf::Environment::setEnv(env); \
    00203 \
    00204         return AXIS2_SUCCESS; \
    00205     } \
    00206 } \
    00207
    00208
    00209 #endif // SCT_PROVIDER_H