Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

eap_policy.hxx

00001 /* BEGIN_COPYRIGHT                                                        */
00002 /*                                                                        */
00003 /* Open Diameter: Open-source software for the Diameter and               */
00004 /*                Diameter related protocols                              */
00005 /*                                                                        */
00006 /* Copyright (C) 2002-2004 Open Diameter Project                          */
00007 /*                                                                        */
00008 /* This library is free software; you can redistribute it and/or modify   */
00009 /* it under the terms of the GNU Lesser General Public License as         */
00010 /* published by the Free Software Foundation; either version 2.1 of the   */
00011 /* License, or (at your option) any later version.                        */
00012 /*                                                                        */
00013 /* This library is distributed in the hope that it will be useful,        */
00014 /* but WITHOUT ANY WARRANTY; without even the implied warranty of         */
00015 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      */
00016 /* Lesser General Public License for more details.                        */
00017 /*                                                                        */
00018 /* You should have received a copy of the GNU Lesser General Public       */
00019 /* License along with this library; if not, write to the Free Software    */
00020 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307    */
00021 /* USA.                                                                   */
00022 /*                                                                        */
00023 /* In addition, when you copy and redistribute some or the entire part of */
00024 /* the source code of this software with or without modification, you     */
00025 /* MUST include this copyright notice in each copy.                       */
00026 /*                                                                        */
00027 /* If you make any changes that are appeared to be useful, please send    */
00028 /* sources that include the changed part to                               */
00029 /* diameter-developers@lists.sourceforge.net so that we can reflect your  */
00030 /* changes to one unified version of this software.                       */
00031 /*                                                                        */
00032 /* END_COPYRIGHT                                                          */
00033 // $Id: eap_policy.hxx,v 1.11 2004/06/17 21:13:36 yohba Exp $
00034 
00035 // eap_policy.hxx:  header file for EAP policy
00036 // Written by Yoshihiro Ohba
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 // used by GetCurrentMethod
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__

Generated on Fri Jun 25 19:16:16 2004 for EAP State Machine by doxygen 1.3.5