ReplayDetector.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef REPLAY_DETECTOR_H
00018 #define REPLAY_DETECTOR_H
00019
00020 #include <WSFDefines.h>
00021 #include <string>
00022 #include <MessageContext.h>
00023 #include <rampart_replay_detector.h>
00024 #include <Environment.h>
00025
00035 namespace wso2wsf
00036 {
00047 class WSF_EXTERN ReplayDetector
00048 {
00049 public:
00054 virtual bool WSF_CALL isValid(MessageContext* msgctx) = 0;
00055
00059 virtual WSF_CALL ~ReplayDetector();
00060
00064 static axis2_status_t WSF_CALL checkValidity(
00065 rampart_replay_detector_t *rrd,
00066 const axutil_env_t* env,
00067 axis2_msg_ctx_t *msg_ctx,
00068 rampart_context_t *rampart_context);
00069 };
00071 }
00075 typedef struct wsf_replay_detector
00076 {
00077 rampart_replay_detector_ops_t *ops;
00078 axutil_param_t *param;
00079 wso2wsf::ReplayDetector* callback;
00080 }wsf_replay_detector_t;
00087 #define WSF_REPLAY_DETECTOR_INIT(class_name) \
00088 extern "C" \
00089 { \
00090 WSF_EXTERN int \
00091 axis2_remove_instance( \
00092 wsf_replay_detector_t *inst, \
00093 const axutil_env_t *env) \
00094 { \
00095 if (inst) \
00096 { \
00097 delete inst->callback; \
00098 AXIS2_FREE(env->allocator, inst->ops); \
00099 AXIS2_FREE(env->allocator, inst); \
00100 } \
00101 return AXIS2_SUCCESS; \
00102 } \
00103 \
00104 axis2_status_t WSF_CALL \
00105 wsf_rampart_replay_detector_free( \
00106 rampart_replay_detector_t *inst, \
00107 const axutil_env_t *env) \
00108 { \
00109 return axis2_remove_instance((wsf_replay_detector_t *)inst, env);\
00110 } \
00111 \
00112 WSF_EXTERN int \
00113 axis2_get_instance( \
00114 wsf_replay_detector_t **inst, \
00115 const axutil_env_t *env) \
00116 { \
00117 wsf_replay_detector_t* replay_detector = NULL; \
00118 \
00119 replay_detector = (wsf_replay_detector_t*)AXIS2_MALLOC(env->allocator, sizeof(wsf_replay_detector_t)); \
00120 \
00121 replay_detector->ops = (rampart_replay_detector_ops_t *)AXIS2_MALLOC(env->allocator, sizeof(rampart_replay_detector_ops_t)); \
00122 replay_detector->ops->is_replayed = wso2wsf::ReplayDetector::checkValidity; \
00123 replay_detector->ops->free = wsf_rampart_replay_detector_free; \
00124 \
00125 replay_detector->callback = new class_name; \
00126 \
00127 *inst = replay_detector; \
00128 if (!(*inst)) \
00129 { \
00130 AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsf_rampart]Cannot initialize the Replay Detection module"); \
00131 return AXIS2_FAILURE; \
00132 } \
00133 \
00134 wso2wsf::Environment::setEnv(env); \
00135 \
00136 return AXIS2_SUCCESS; \
00137 } \
00138 } \
00139
00140
00141 #endif // REPLAY_DETECTOR_H