Back to index

nordugrid-arc-nox  1.1.0~rc6
OrderedAlg.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include "OrderedAlg.h"
00006 
00007 //   Evaluation results
00008 // PERMIT
00009 // DENY
00010 // INDETERMINATE
00011 // NOT_APPLICABLE
00012 
00013 namespace ArcSec{
00014 
00015 std::string PermitDenyIndeterminateNotApplicableCombiningAlg::algId = "Permit-Deny-Indeterminate-NotApplicable";
00016 std::string PermitDenyNotApplicableIndeterminateCombiningAlg::algId = "Permit-Deny-NotApplicable-Indeterminate";
00017 std::string PermitIndeterminateDenyNotApplicableCombiningAlg::algId = "Permit-Indeterminate-Deny-NotApplicable";
00018 std::string PermitIndeterminateNotApplicableDenyCombiningAlg::algId = "Permit-Indeterminate-NotApplicable-Deny";
00019 std::string PermitNotApplicableDenyIndeterminateCombiningAlg::algId = "Permit-NotApplicable-Deny-Indeterminate";
00020 std::string PermitNotApplicableIndeterminateDenyCombiningAlg::algId = "Permit-NotApplicable-Indeterminate-Deny";
00021 std::string DenyPermitIndeterminateNotApplicableCombiningAlg::algId = "Deny-Permit-Indeterminate-NotApplicable";
00022 std::string DenyPermitNotApplicableIndeterminateCombiningAlg::algId = "Deny-Permit-NotApplicable-Indeterminate";
00023 std::string DenyIndeterminatePermitNotApplicableCombiningAlg::algId = "Deny-Indeterminate-Permit-NotApplicable";
00024 std::string DenyIndeterminateNotApplicablePermitCombiningAlg::algId = "Deny-Indeterminate-NotApplicable-Permit";
00025 std::string DenyNotApplicablePermitIndeterminateCombiningAlg::algId = "Deny-NotApplicable-Permit-Indeterminate";
00026 std::string DenyNotApplicableIndeterminatePermitCombiningAlg::algId = "Deny-NotApplicable-Indeterminate-Permit";
00027 std::string IndeterminatePermitDenyNotApplicableCombiningAlg::algId = "Indeterminate-Permit-Deny-NotApplicable";
00028 std::string IndeterminatePermitNotApplicableDenyCombiningAlg::algId = "Indeterminate-Permit-NotApplicable-Deny";
00029 std::string IndeterminateDenyPermitNotApplicableCombiningAlg::algId = "Indeterminate-Deny-Permit-NotApplicable";
00030 std::string IndeterminateDenyNotApplicablePermitCombiningAlg::algId = "Indeterminate-Deny-NotApplicable-Permit";
00031 std::string IndeterminateNotApplicablePermitDenyCombiningAlg::algId = "Indeterminate-NotApplicable-Permit-Deny";
00032 std::string IndeterminateNotApplicableDenyPermitCombiningAlg::algId = "Indeterminate-NotApplicable-Deny-Permit";
00033 std::string NotApplicablePermitDenyIndeterminateCombiningAlg::algId = "NotApplicable-Permit-Deny-Indeterminate";
00034 std::string NotApplicablePermitIndeterminateDenyCombiningAlg::algId = "NotApplicable-Permit-Indeterminate-Deny";
00035 std::string NotApplicableDenyPermitIndeterminateCombiningAlg::algId = "NotApplicable-Deny-Permit-Indeterminate";
00036 std::string NotApplicableDenyIndeterminatePermitCombiningAlg::algId = "NotApplicable-Deny-Indeterminate-Permit";
00037 std::string NotApplicableIndeterminatePermitDenyCombiningAlg::algId = "NotApplicable-Indeterminate-Permit-Deny";
00038 std::string NotApplicableIndeterminateDenyPermitCombiningAlg::algId = "NotApplicable-Indeterminate-Deny-Permit";
00039 
00040 Result PermitDenyIndeterminateNotApplicableCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00041   DECISION_PERMIT,
00042   DECISION_DENY,
00043   DECISION_INDETERMINATE,
00044   DECISION_NOT_APPLICABLE
00045 };
00046 
00047 Result PermitDenyNotApplicableIndeterminateCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00048   DECISION_PERMIT,
00049   DECISION_DENY,
00050   DECISION_NOT_APPLICABLE,
00051   DECISION_INDETERMINATE
00052 };
00053 
00054 Result PermitIndeterminateDenyNotApplicableCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00055   DECISION_PERMIT,
00056   DECISION_INDETERMINATE,
00057   DECISION_DENY,
00058   DECISION_NOT_APPLICABLE
00059 };
00060 
00061 Result PermitIndeterminateNotApplicableDenyCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00062   DECISION_PERMIT,
00063   DECISION_INDETERMINATE,
00064   DECISION_NOT_APPLICABLE,
00065   DECISION_DENY
00066 };
00067 
00068 Result PermitNotApplicableDenyIndeterminateCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00069   DECISION_PERMIT,
00070   DECISION_NOT_APPLICABLE,
00071   DECISION_DENY,
00072   DECISION_INDETERMINATE
00073 };
00074 
00075 Result PermitNotApplicableIndeterminateDenyCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00076   DECISION_PERMIT,
00077   DECISION_NOT_APPLICABLE,
00078   DECISION_INDETERMINATE,
00079   DECISION_DENY
00080 };
00081 
00082 Result DenyPermitIndeterminateNotApplicableCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00083   DECISION_DENY,
00084   DECISION_PERMIT,
00085   DECISION_INDETERMINATE,
00086   DECISION_NOT_APPLICABLE
00087 };
00088 
00089 Result DenyPermitNotApplicableIndeterminateCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00090   DECISION_DENY,
00091   DECISION_PERMIT,
00092   DECISION_NOT_APPLICABLE,
00093   DECISION_INDETERMINATE
00094 };
00095 
00096 Result DenyIndeterminatePermitNotApplicableCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00097   DECISION_DENY,
00098   DECISION_INDETERMINATE,
00099   DECISION_PERMIT,
00100   DECISION_NOT_APPLICABLE
00101 };
00102 
00103 Result DenyIndeterminateNotApplicablePermitCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00104   DECISION_DENY,
00105   DECISION_INDETERMINATE,
00106   DECISION_NOT_APPLICABLE,
00107   DECISION_PERMIT
00108 };
00109 
00110 Result DenyNotApplicablePermitIndeterminateCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00111   DECISION_DENY,
00112   DECISION_NOT_APPLICABLE,
00113   DECISION_PERMIT,
00114   DECISION_INDETERMINATE
00115 };
00116 
00117 Result DenyNotApplicableIndeterminatePermitCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00118   DECISION_DENY,
00119   DECISION_NOT_APPLICABLE,
00120   DECISION_INDETERMINATE,
00121   DECISION_PERMIT
00122 };
00123 
00124 Result IndeterminatePermitDenyNotApplicableCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00125   DECISION_INDETERMINATE,
00126   DECISION_PERMIT,
00127   DECISION_DENY,
00128   DECISION_NOT_APPLICABLE
00129 };
00130 
00131 Result IndeterminatePermitNotApplicableDenyCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00132   DECISION_INDETERMINATE,
00133   DECISION_PERMIT,
00134   DECISION_NOT_APPLICABLE,
00135   DECISION_DENY
00136 };
00137 
00138 Result IndeterminateDenyPermitNotApplicableCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00139   DECISION_INDETERMINATE,
00140   DECISION_DENY,
00141   DECISION_PERMIT,
00142   DECISION_NOT_APPLICABLE
00143 };
00144 
00145 Result IndeterminateDenyNotApplicablePermitCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00146   DECISION_INDETERMINATE,
00147   DECISION_DENY,
00148   DECISION_NOT_APPLICABLE,
00149   DECISION_PERMIT
00150 };
00151 
00152 Result IndeterminateNotApplicablePermitDenyCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00153   DECISION_INDETERMINATE,
00154   DECISION_NOT_APPLICABLE,
00155   DECISION_PERMIT,
00156   DECISION_DENY
00157 };
00158 
00159 Result IndeterminateNotApplicableDenyPermitCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00160   DECISION_INDETERMINATE,
00161   DECISION_NOT_APPLICABLE,
00162   DECISION_DENY,
00163   DECISION_PERMIT
00164 };
00165 
00166 Result NotApplicablePermitDenyIndeterminateCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00167   DECISION_NOT_APPLICABLE,
00168   DECISION_PERMIT,
00169   DECISION_DENY,
00170   DECISION_INDETERMINATE
00171 };
00172 
00173 Result NotApplicablePermitIndeterminateDenyCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00174   DECISION_NOT_APPLICABLE,
00175   DECISION_PERMIT,
00176   DECISION_INDETERMINATE,
00177   DECISION_DENY
00178 };
00179 
00180 Result NotApplicableDenyPermitIndeterminateCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00181   DECISION_NOT_APPLICABLE,
00182   DECISION_DENY,
00183   DECISION_PERMIT,
00184   DECISION_INDETERMINATE
00185 };
00186 
00187 Result NotApplicableDenyIndeterminatePermitCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00188   DECISION_NOT_APPLICABLE,
00189   DECISION_DENY,
00190   DECISION_INDETERMINATE,
00191   DECISION_PERMIT
00192 };
00193 
00194 Result NotApplicableIndeterminatePermitDenyCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00195   DECISION_NOT_APPLICABLE,
00196   DECISION_INDETERMINATE,
00197   DECISION_PERMIT,
00198   DECISION_DENY
00199 };
00200 
00201 Result NotApplicableIndeterminateDenyPermitCombiningAlg::priorities[MAX_OREDERED_PRIORITIES] = {
00202   DECISION_NOT_APPLICABLE,
00203   DECISION_INDETERMINATE,
00204   DECISION_DENY,
00205   DECISION_PERMIT
00206 };
00207 
00208 
00209 
00210 Result OrderedCombiningAlg::combine(EvaluationCtx* ctx, std::list<Policy*> policies,const Result priorities[MAX_OREDERED_PRIORITIES]){
00211   std::list<Policy*>::iterator it;
00212   int occurencies[MAX_OREDERED_PRIORITIES];
00213   memset(occurencies,0,sizeof(occurencies));
00214   for(it = policies.begin(); it != policies.end(); it++) {
00215     Policy* policy = *it;
00216     Result res = policy->eval(ctx);
00217     for(int n = 0;n<MAX_OREDERED_PRIORITIES;++n) {
00218       if(priorities[n] == res) {
00219         ++(occurencies[n]);
00220         break;
00221       };
00222     };
00223     if(occurencies[0]) break;
00224   };
00225   for(int n = 0;n<MAX_OREDERED_PRIORITIES;++n) {
00226     if(occurencies[n]) return priorities[n];
00227   };
00228   return priorities[MAX_OREDERED_PRIORITIES-1];
00229 }
00230 
00231 } //namespace ArcSec
00232 
00233