PasswordCallback.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 PASSWORD_CALLBACK_H
00018 #define PASSWORD_CALLBACK_H
00019 
00020 #include <WSFDefines.h>
00021 #include <string>
00022 #include <rampart_callback.h>
00023 #include <Environment.h>
00024 
00033 namespace wso2wsf
00034 {
00045     class PasswordCallback
00046     {
00047     public:
00053         virtual std::string WSF_CALL getPassword(std::string& username) = 0;
00054 
00060         virtual std::string WSF_CALL getPKCS12Password(std::string& username) = 0;
00061 
00065         WSF_EXTERN virtual WSF_CALL ~PasswordCallback();
00066 
00070         static WSF_EXTERN axis2_char_t* WSF_CALL callbackPassword(
00071             rampart_callback_t * callback, const axutil_env_t* env, const axis2_char_t *username, void *param);
00072 
00076         static WSF_EXTERN axis2_char_t* WSF_CALL callbackPKCS12Password(
00077             rampart_callback_t * callback, const axutil_env_t* env, const axis2_char_t *username, void *param);
00078     };
00080 }
00085 typedef struct wsf_rampart_callback
00086 {
00090     rampart_callback_ops_t *ops;
00094     axutil_param_t *param;
00098     wso2wsf::PasswordCallback* callback;
00099 }wsf_rampart_callback_t;
00100 
00107 #define WSF_PASSWORD_CALLBACK_INIT(class_name) \
00108 extern "C" \
00109 { \
00110     WSF_EXTERN int \
00111     axis2_remove_instance( \
00112         wsf_rampart_callback_t *inst, \
00113         const axutil_env_t *env) \
00114     { \
00115         if (inst) \
00116         { \
00117             delete inst->callback; \
00118             AXIS2_FREE(env->allocator, inst->ops); \
00119             AXIS2_FREE(env->allocator, inst); \
00120         } \
00121         return AXIS2_SUCCESS; \
00122     } \
00123 \
00124     axis2_status_t WSF_CALL \
00125     wsf_rampart_callback_free( \
00126         rampart_callback_t *inst, \
00127         const axutil_env_t *env) \
00128     { \
00129         return axis2_remove_instance((wsf_rampart_callback_t *)inst, env);\
00130     } \
00131 \
00132     WSF_EXTERN int \
00133     axis2_get_instance( \
00134         wsf_rampart_callback_t **inst, \
00135         const axutil_env_t *env) \
00136     { \
00137         wsf_rampart_callback_t* rcb = NULL; \
00138     \
00139         rcb = (wsf_rampart_callback_t*)AXIS2_MALLOC(env->allocator, sizeof(wsf_rampart_callback_t)); \
00140     \
00141         rcb->ops = (rampart_callback_ops_t *)AXIS2_MALLOC(env->allocator, sizeof(rampart_callback_ops_t)); \
00142         rcb->ops->callback_password = wso2wsf::PasswordCallback::callbackPassword; \
00143         rcb->ops->callback_pkcs12_password = wso2wsf::PasswordCallback::callbackPKCS12Password; \
00144         rcb->ops->free = wsf_rampart_callback_free; \
00145     \
00146         rcb->callback = new class_name; \
00147     \
00148         *inst = rcb; \
00149         if (!(*inst)) \
00150         { \
00151             AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsf_rampart]Cannot initialize the PWCB module"); \
00152             return AXIS2_FAILURE; \
00153         } \
00154 \
00155         wso2wsf::Environment::setEnv(env); \
00156 \
00157     \
00158         return AXIS2_SUCCESS; \
00159     } \
00160 } \
00161 
00162 
00163 #endif // PASSWORD_CALLBACK_H

Generated on Wed Oct 14 00:43:25 2009 for WSF/CPP by  doxygen 1.5.7.1