00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00104 #ifndef __EAP_POLICY_HXX__
00105 #define __EAP_POLICY_HXX__
00106
00107 #include <ace/Singleton.h>
00108 #include "eap.hxx"
00109
00113 class EAP_EXPORTS EapPolicyElement
00114 {
00115 friend class EapPolicy;
00116 public:
00117 enum PolicyType {
00118 FinalSuccess,
00119 FinalFailure,
00120 Continued
00121 };
00122
00124 inline bool IsContinued()
00125 {
00126 if (policyType==Continued) return true;
00127 return false;
00128 }
00129 protected:
00132 EapPolicyElement(PolicyType t) : policyType(t) {}
00133 PolicyType policyType;
00134 };
00135
00138 class EAP_EXPORTS EapSuccessPolicyElement : public EapPolicyElement
00139 {
00140 public:
00141 EapSuccessPolicyElement() : EapPolicyElement(FinalSuccess) {}
00142 };
00143
00146 class EAP_EXPORTS EapFailurePolicyElement : public EapPolicyElement
00147 {
00148 public:
00149 EapFailurePolicyElement() : EapPolicyElement(FinalFailure) {}
00150 };
00151
00153 typedef ACE_Singleton<EapSuccessPolicyElement, ACE_Recursive_Thread_Mutex>
00154 EapSuccessPolicyElement_S;
00155
00157 typedef ACE_Singleton<EapFailurePolicyElement, ACE_Recursive_Thread_Mutex>
00158 EapFailurePolicyElement_S;
00159
00165 class EAP_EXPORTS EapContinuedPolicyElement : public EapPolicyElement
00166 {
00167 friend class EapPolicy;
00168 public:
00174 EapContinuedPolicyElement(EapType t) :
00175 EapPolicyElement(Continued),
00176 nextOnSuccess(EapSuccessPolicyElement_S::instance()),
00177 nextOnFailure(EapFailurePolicyElement_S::instance()), methodType(t) {}
00179 enum PolicySwitch {
00180 PolicyOnSuccess,
00181 PolicyOnFailure
00182 };
00183 EapPolicyElement *NextPolicyElement(PolicySwitch sw)
00184 {
00185 if (sw == PolicyOnSuccess)
00186 return nextOnSuccess;
00187 else
00188 return nextOnFailure;
00189 }
00192 void AddSuccessPolicyElement(PolicySwitch sw);
00195 void AddFailurePolicyElement();
00198 void AddContinuedPolicyElement(EapPolicyElement *p, PolicySwitch sw);
00199 bool IsContinued() { return true; }
00200 EapType GetType() { return methodType; }
00201 private:
00202 EapPolicyElement *nextOnSuccess;
00203 EapPolicyElement *nextOnFailure;
00204 EapType methodType;
00205 };
00206
00210 class EAP_EXPORTS EapPolicy
00211 {
00212 public:
00213 enum PolicyError {
00214 NoCurrentMethod
00215 };
00216 EapPolicy() : initialPolicyElement(0), currentPolicyElement(0) {}
00217 ~EapPolicy() {}
00218
00220 EapPolicyElement* NextPolicyElement
00221 (EapContinuedPolicyElement::PolicySwitch sw);
00222
00224 inline EapPolicyElement* CurrentPolicyElement()
00225 { return currentPolicyElement; }
00226
00228 void CurrentPolicyElement(EapPolicyElement *e) { currentPolicyElement = e; }
00229
00231 inline EapPolicyElement* InitialPolicyElement()
00232 { return initialPolicyElement; }
00233
00235 void InitialPolicyElement(EapPolicyElement *e)
00236 { initialPolicyElement = e; }
00237
00239 EapType CurrentMethod() throw (PolicyError);
00240
00243 void Update(EapContinuedPolicyElement::PolicySwitch sw);
00244
00248 void Update(EapTypeList &typeL);
00249
00252 bool Allow(EapType t);
00253
00256 bool IsSatisfied();
00257
00263 void MakeTypeList(EapTypeList &typeL, bool isVSE);
00264
00267 bool SupportPickUp(EapType type)
00268 {
00269 if (type == EapType(1))
00270 return true;
00271 return false;
00272 }
00273
00274 private:
00276 void MakeTypeList(EapTypeList &typeL, bool isVSE, EapPolicyElement *pe);
00277
00279 EapPolicyElement *initialPolicyElement;
00280
00282 EapPolicyElement *currentPolicyElement;
00283 };
00284
00285 #endif // __EAP_POLICY_HXX__