AuthenticationProvider.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 AUTHENTICATION_PROVIDER_H
00018 #define AUTHENTICATION_PROVIDER_H
00019 
00020 #include <WSFDefines.h>
00021 #include <string>
00022 #include <rampart_authn_provider.h>
00023 #include <MessageContext.h>
00024 #include <Environment.h>
00025 
00035 namespace wso2wsf
00036 {
00048     class AuthenticationProvider
00049     {
00050     public:
00057         virtual bool WSF_CALL checkPassword(
00058             std::string& username, 
00059             std::string& password, 
00060             MessageContext* msgctx) = 0;
00061 
00072         virtual bool WSF_CALL checkDigestPassword(
00073             std::string& username, 
00074             std::string& nonce, 
00075             std::string& created, 
00076             std::string& digest, 
00077             MessageContext* msgctx) = 0;
00078 
00082         WSF_EXTERN virtual WSF_CALL ~AuthenticationProvider();
00083 
00087         WSF_EXTERN static rampart_authn_provider_status_t WSF_CALL callbackPasswordPlain(
00088             rampart_authn_provider_t * authn_provider, 
00089             const axutil_env_t* env, 
00090             axis2_msg_ctx_t *msg_ctx,
00091             const axis2_char_t *username,
00092             const axis2_char_t *password);
00093 
00097         WSF_EXTERN static rampart_authn_provider_status_t WSF_CALL callbackPasswordDigest(
00098             rampart_authn_provider_t *authn_provider,
00099             const axutil_env_t* env,
00100             axis2_msg_ctx_t *msg_ctx,
00101             const axis2_char_t *username,
00102             const axis2_char_t *nonce,
00103             const axis2_char_t *created,
00104             const char *digest);
00105 
00106     };
00108 }
00109 
00110 typedef struct wsf_authn_provider
00111 {
00112     rampart_authn_provider_ops_t *ops;
00113     axutil_param_t *param;
00114     wso2wsf::AuthenticationProvider* callback;
00115 }wsf_authn_provider_t;
00116 
00122 #define WSF_AUTHENTICATION_PROVIDER_INIT(class_name) \
00123 extern "C" \
00124 { \
00125     WSF_EXTERN int \
00126     axis2_remove_instance( \
00127         wsf_authn_provider_t *inst, \
00128         const axutil_env_t *env) \
00129     { \
00130         if (inst) \
00131         { \
00132             delete inst->callback; \
00133             AXIS2_FREE(env->allocator, inst->ops); \
00134             AXIS2_FREE(env->allocator, inst); \
00135         } \
00136         return AXIS2_SUCCESS; \
00137     } \
00138 \
00139     axis2_status_t WSF_CALL \
00140     wsf_rampart_authn_provider_free( \
00141         rampart_authn_provider_t *inst, \
00142         const axutil_env_t *env) \
00143     { \
00144         return axis2_remove_instance((wsf_authn_provider_t *)inst, env);\
00145     } \
00146 \
00147     WSF_EXTERN int \
00148     axis2_get_instance( \
00149         wsf_authn_provider_t **inst, \
00150         const axutil_env_t *env) \
00151     { \
00152         wsf_authn_provider_t* authn_callback = NULL; \
00153     \
00154         authn_callback = (wsf_authn_provider_t*)AXIS2_MALLOC(env->allocator, sizeof(wsf_authn_provider_t)); \
00155     \
00156         authn_callback->ops = (rampart_authn_provider_ops_t *)AXIS2_MALLOC(env->allocator, sizeof(rampart_authn_provider_ops_t)); \
00157         authn_callback->ops->rampart_authn_provider_check_password = wso2wsf::AuthenticationProvider::callbackPasswordPlain; \
00158         authn_callback->ops->rampart_authn_provider_check_password_digest = wso2wsf::AuthenticationProvider::callbackPasswordDigest; \
00159         authn_callback->ops->free = wsf_rampart_authn_provider_free; \
00160     \
00161         authn_callback->callback = new class_name; \
00162     \
00163         *inst = authn_callback; \
00164         if (!(*inst)) \
00165         { \
00166             AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsf_rampart]Cannot initialize the Authentication provider module"); \
00167             return AXIS2_FAILURE; \
00168         } \
00169 \
00170         wso2wsf::Environment::setEnv(env); \
00171 \
00172         return AXIS2_SUCCESS; \
00173     } \
00174 } \
00175 
00176 
00177 #endif // AUTHENTICATION_PROVIDER_H

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