source: libabac/abac.hh @ 09496b3

mei_rt2mei_rt2_fix_1
Last change on this file since 09496b3 was 09496b3, checked in by Mei <mei@…>, 12 years ago

1) add ID api that takes abac_chunk_t*

  • Property mode set to 100644
File size: 48.4 KB
Line 
1#ifndef __ABAC_HH__
2#define __ABAC_HH__
3
4#include <string>
5#include <vector>
6
7namespace ABAC {
8    extern "C" {
9        #include "abac.h"
10    }
11    static int debug=0;
12    class Role;
13    class Oset;
14    class ID;
15
16/***
17ABAC::Constraint
18   Constraint on a data term.
19   There are 3 types:
20     - Role constraint on a principal
21     - Oset constraint on a principal, or a data object
22     - Range/List constraint on a data object
23   It holds a ptr to a abac_condition_t structure
24***/
25    class Constraint {
26        public:
27/***
28f  Constraint()
29     default constructor, do not use, for swig only
30f  Constraint(const Constraint &)
31     copy constructor, used for cloning a constraint
32f  ~Constraint()
33     default destructor
34***/
35            Constraint() : m_constraint(NULL) { }
36            Constraint(const Constraint &constraint) { 
37              m_constraint=abac_condition_dup(constraint.m_constraint);
38            }
39            ~Constraint() { 
40              if(m_constraint) abac_condition_free(m_constraint);
41            }
42/***
43f  Constraint(Role &)
44     constructor that takes a constraining role
45       [role:?R[{role-constraint}]
46     (C:abac_constraint_from_role)
47f  Constraint(Oset &)
48     constructor that takes a constraining oset
49       [oset:?O[{oset-constraint}]
50       [urn:?F[keyid:$alpha_keyid].oset:documents([string:?P])]
51     (C:abac_constraint_from_oset)
52f  Constraint(char *)
53     constructor that takes one of following string
54     as its vartype to set up a range constraint:
55       "integer"
56       "urn"
57       "float"
58       "boolean"
59       "time"
60       "string"
61     it should be followed with one or many of following utility
62     calls.
63     (C:abac_constraint_create)
64***/
65            Constraint(Role& role);
66            Constraint(Oset& oset);
67            Constraint(char *vartype)
68            { m_constraint=abac_constraint_create(vartype); }
69/*ii**
70f  Constraint(abac_condition_t *)
71     internal constructor that takes an abac_condition_t structure
72**ii*/
73            Constraint(abac_condition_t *constraint):
74              m_constraint(abac_condition_dup(constraint))
75            { }
76/***
77f  void constraint_add_integer_max(int)
78     (C:abac_constraint_add_integer_max)
79   void constraint_add_integer_min(int)
80     utility routines to setup a integer range constraint
81       [integer:?I[10 .. 20]]
82     (C:abac_constraint_add_integer_min)
83f  void constraint_add_integer_target(int)
84     utility routine to setup a integer list constraint
85       [integer:?I[10,20]]
86     (C:abac_constraint_add_integer_target)
87***/
88            void constraint_add_integer_max(int val)
89            { abac_constraint_add_integer_max(m_constraint,val); }
90            void constraint_add_integer_min(int val)
91            { abac_constraint_add_integer_min(m_constraint,val); }
92            void constraint_add_integer_target(int val) 
93            { abac_constraint_add_integer_target(m_constraint,val); }
94/***
95f  void constraint_add_float_max(float)
96     (C:abac_constraint_add_float_max)
97   void constraint_add_float_min(float)
98     utility routines to setup a float range constraint
99       [float:?F[1.0 .. 2.5]]
100     (C:abac_constraint_add_float_min)
101f  void constraint_add_float_target(float)
102     utility routine to setup a float list constraint
103       [float:?F[0.5, 2.5]]
104     (C:abac_constraint_add_float_target)
105***/
106            void constraint_add_float_max(float val) 
107            { abac_constraint_add_float_max(m_constraint,val); }
108            void constraint_add_float_min(float val)
109            { abac_constraint_add_float_min(m_constraint,val); }
110            void constraint_add_float_target(float val) 
111            { abac_constraint_add_float_target(m_constraint,val); }
112/***
113f  void constraint_add_time_max(char*)
114     (C:abac_constraint_add_time_max)
115   void constraint_add_time_min(char*)
116     utility routines to setup a time range constraint,
117     takes quoted string values, beyond T is optional
118       [time:?F["20120228T" .. "20120228T090000"]]
119     (C:abac_constraint_add_time_min)
120f  void constraint_add_time_target(char*)
121     utility routine to setup a time list constraint
122       [time:?M["20201101T182930","20201101T"]]
123     (C:abac_constraint_add_time_target)
124***/
125            void constraint_add_time_max(char* val) 
126            { abac_constraint_add_time_max(m_constraint,val); }
127            void constraint_add_time_min(char* val)
128            { abac_constraint_add_time_min(m_constraint,val); }
129            void constraint_add_time_target(char* val) 
130            { abac_constraint_add_time_target(m_constraint,val); }
131/***
132f  void constraint_add_urn_target(char*)
133     utility routine to setup a an urn list constraint
134       [urn:?U["fileA","http://fileB"]]
135     (C:abac_constraint_add_urn_target)
136f  void constraint_add_string_target(char*)
137     utility routine to setup a a string list constraint
138       [string:?S["abc",'efg',"hij"]]
139     (C:abac_constraint_add_string_target)
140f  void constraint_add_boolean_target(char*)
141     utility routine to setup a a boolean list constraint
142       [boolean:?B['true']]
143     (C:abac_constraint_add_boolean_target)
144***/
145            void constraint_add_urn_target(char* val) 
146            { abac_constraint_add_urn_target(m_constraint,val); }
147            void constraint_add_string_target(char* val)
148            { abac_constraint_add_string_target(m_constraint,val); }
149            void constraint_add_boolean_target(char* val)
150            { abac_constraint_add_boolean_target(m_constraint,val); }
151/***
152f  char *string() const
153     returns literal string of the constraint
154     (C:abac_constraint_string)
155f  char *typed_string() const
156     returns typed literal string of the constraint
157     (C:abac_constraint_typed_string)
158***/
159            char *string() const 
160            { return abac_constraint_string(m_constraint); }
161            char *typed_string() const 
162            { return abac_constraint_typed_string(m_constraint); }
163/*ii**
164f  abac_condition_t *constraint()
165     internal returns internal constraint structure
166**ii*/
167            abac_condition_t *constraint()
168            { return m_constraint; }
169        private:
170            abac_condition_t *m_constraint;
171    };
172
173/***
174ABAC::DataTerm
175   A data term is associated with Role or Oset as a parameter that
176   maybe be instantiated, or uninstantiated but being constrained,
177   or as a principal oset term (standalone right handside of an oset
178   policy rule).  It holds a pointer to a abac_term_t structure.
179   Types of data terms are:
180     "integer"
181     "urn"
182     "float"
183     "boolean"
184     "string"
185     "time"
186     "principal"
187     "anonymous"
188***/
189    class DataTerm {
190        public:
191/***
192f  DataTerm()
193     default constructor, do not use, for swig only
194f  DataTerm(const DataTerm &)
195     copy constructor, used for cloning a data term
196f  ~DataTerm()
197     default destructor
198***/
199            DataTerm() : m_term(NULL) { } // do not use: here for swig
200            DataTerm(const DataTerm &dterm) { 
201              m_term=abac_term_dup(dterm.m_term);
202            }
203            ~DataTerm() { 
204              if(m_term) abac_term_free(m_term);
205            }
206/*ii**
207f  DataTerm(abac_term_t *)
208     internal constructor to make data term from abac_term_t structure
209**ii*/
210            DataTerm(abac_term_t *term)
211            { m_term=abac_term_dup(term); }
212/***
213f  DataTerm(char*)
214     constructor to make named principal data term for the oset RHS
215     (C: abac_term_named_create)
216f  DataTerm(const ID&)
217     constructor to make named principal data term for parameter term
218     (C: abac_term_id_create)
219f  DataTerm(char*, char*, Constraint*)
220     constructor for making a variable data term
221     (C: abac_term_create)
222f  DataTerm(char*, char*)
223     constructor for making an instantiated data term
224     (C: abac_term_create)
225***/
226            DataTerm(char *name) {
227              if(debug) printf("adding a Dataterm named principal(%s)\n",name);
228              m_term=abac_term_named_create(name);
229            }
230            DataTerm(ID& id);
231            DataTerm(char* typenm, char *name, Constraint *cond) {
232              if(debug) printf("adding a Dataterm (%s)\n",name);
233              m_term=abac_term_create(typenm,name,cond->constraint());
234            }
235            DataTerm(char* typenm, char *name) {
236              if(debug) printf("adding a Dataterm (%s)\n",name);
237              m_term=abac_term_create(typenm,name,NULL);
238            }
239/***
240f  char *string() const
241     returns literal string of the data term
242     (C:abac_term_string)
243f  char *typed_string() const
244     returns typed literal string of the data term
245     (C:abac_term_typed_string)
246***/
247            char *string() const
248            { return abac_term_string(m_term); }
249            char *typed_string() const
250            { return abac_term_typed_string(m_term); }
251/***
252f  bool term_is_time() const
253     (C:abac_term_is_time)
254   bool term_is_string() const
255     (C:abac_term_is_string)
256   bool term_is_urn() const
257     (C:abac_term_is_urn)
258   bool term_is_integer() const
259     (C:abac_term_is_integer)
260     returns true if data term is of certain type
261***/
262            bool term_is_time() const 
263            { return abac_term_is_time(m_term); }
264            bool term_is_string() const
265            { return abac_term_is_string(m_term); }
266            bool term_is_urn() const
267            { return abac_term_is_urn(m_term); }
268            bool term_is_integer() const 
269            { return abac_term_is_integer(m_term); }
270/***
271f  int term_add_constraint(Contraint&)
272     utiltiy routine to add a constraint to this data term
273     (C:abac_term_add_constraint)
274***/
275            int term_add_constraint(Constraint& cond) {
276              abac_term_add_constraint(m_term, cond.constraint());
277              return 1;
278            }
279/***
280f  int term_type() const
281     returns subtype of the data term
282     (C:abac_term_type)
283f  char *term_name() const
284     returns the name of the data term
285     (C:abac_term_name)
286***/
287            int term_type() const 
288            { abac_term_type(m_term); }
289            char *term_name() const 
290            { return abac_term_name(m_term); }
291/*ii**
292f  abac_term_t *term()
293     returns abac_term_t term structure
294**ii*/
295            abac_term_t *term() 
296            { return m_term; }
297        private:
298            abac_term_t *m_term;
299    };
300
301
302/***
303ABAC::Role
304   A Role is role specification of a set of entitities for a principal
305***/
306    class Role {
307        public:
308/***
309f  Role()
310     default constructor, do not use, for swig only
311f  Role(const Role &)
312     copy constructor, used for cloning a role
313f  ~Role()
314     default destructor
315***/
316            Role() : m_role(NULL) { } // do not use: here for swig
317            Role(const Role &role) { 
318              m_role = abac_aspect_dup(role.m_role);
319            }
320            ~Role() { 
321              if (m_role) abac_aspect_free(m_role);
322            }
323/*ii**
324f  Role(abac_aspect_t*)
325     constructor that takes an abac_aspect_t structure
326**ii*/
327            Role(abac_aspect_t *role): m_role(abac_aspect_dup(role))
328            { }
329/***
330f  Role(char*)
331     constructor that builds a bare bone role with just principal's name
332     (C:abac_role_principal_create)
333f  Role(char*, char*)
334     constructor that builds a bare bone role with just principal's name
335     and a role name
336     (C:abac_role_create)
337f  Role(char*, char*, char*)
338     constructor that builds a bare bone role with just principal's name
339     and a linking role name and a role name
340     (C:abac_role_linked_create)
341***/
342            Role(char *principal_name) : 
343               m_role(abac_role_principal_create(principal_name)) 
344            { }
345            Role(char *principal_name, char *role_name) : 
346               m_role(abac_role_create(principal_name, role_name)) 
347            { }
348            Role(char *principal_name, char *linked_role_name, char *role_name) : 
349               m_role(abac_role_linked_create(principal_name, linked_role_name,role_name)) 
350            { }
351/***
352f  bool role_is_principal() const
353     return true if the role is a principal object(made from
354     a data term), the right hand side of,
355       [keyid:A].role:r <- [keyid:B]
356     (C:abac_role_is_principal)
357***/
358            bool role_is_principal() const
359            { return abac_role_is_principal(m_role); }
360/***
361f  bool role_is_linking() const
362     returns true if the role is a linking role like
363     the right hand side of,
364       [keyid:A].role:r1 <- [keyid:B].role:r2.role:r3
365     (C:abac_role_is_linking)
366***/
367            bool is_linking() const
368            { return abac_role_is_linking(m_role); }
369/***
370f  char *string() const
371     returns literal string of the role
372     (C:abac_role_string)
373f  char *typed_string() const
374     returns typed literal string of the role
375     (C:abac_role_typed_string)
376***/
377            char *string() const
378            { return abac_role_string(m_role); }
379            char *typed_string()
380            { return abac_role_typed_string(m_role); }
381/***
382f  char *role_linked_role() const
383     returns linked part of a linking role, for
384       [keyid:A].role:r1.role:r2, it returns r1
385     (C:abac_role_linked_role)
386***/
387            char *role_linked_role() const 
388            { return abac_role_linked_role(m_role); }
389/***
390f  char *role_name() const
391     returns the role name of any role (the part after the last dot)
392       [keyid:A].role.r1.role:r2, it returns r2
393       [keyid:A].role.r1, it returns r1
394     (C:abac_role_name)
395f  char *role_principal() const
396     returns the principal of role (the part before the first dot)
397       [keyid:A].role.r1, it returns A
398     (C:abac_role_principal)
399***/
400            char *role_name() const
401            { return abac_role_name(m_role); }
402            char *role_principal() const
403            { return abac_role_principal(m_role); }
404
405/***
406f  void role_add_data_term(DataTerm&)
407     add a data term to the role
408     (C:abac_role_add_data_term)
409***/
410            void role_add_data_term(DataTerm& d) {
411              abac_role_add_data_term(m_role, d.term());
412            }
413/***
414f  std::vector<DataTerm> get_data_terms(bool &)
415     return the data terms bound to this role.
416     (C:abac_role_get_data_terms)
417***/
418            std::vector<DataTerm> get_data_terms(bool &success) {
419              abac_term_t **terms, **end;
420              int i;
421              terms = abac_role_get_data_terms(m_role);
422              for (i = 0; terms[i] != NULL; ++i)
423                  ;
424              end = &terms[i];
425              std::vector<DataTerm> dataterms = std::vector<DataTerm>(terms, end);
426              abac_terms_free(terms);
427              success=1;
428              return dataterms;
429            }
430/***
431f  void role_add_linked_data_term(DataTerm&)
432     add a data term to the linking role
433     (C:abac_role_add_linked_data_term)
434***/
435            void role_add_linked_data_term(DataTerm& d) {
436              abac_role_add_linked_data_term(m_role, d.term());
437            }
438/***
439f  std::vector<DataTerm> get_linked_data_terms(bool &)
440     return the data terms bound to this role's linking role.
441     (C:abac_role_get_linked_data_terms)
442***/
443            std::vector<DataTerm> get_linked_data_terms(bool &success) {
444              abac_term_t **terms, **end;
445              int i;
446              terms = abac_role_get_linked_data_terms(m_role);
447              for (i = 0; terms[i] != NULL; ++i)
448                  ;
449              end = &terms[i];
450              std::vector<DataTerm> dataterms = std::vector<DataTerm>(terms, end);
451              abac_terms_free(terms);
452              success=1;
453              return dataterms;
454            }
455/*ii**
456f  abac_aspect_t *role()
457     returns the interal libabac representation of this role
458**ii*/
459            abac_aspect_t *role() {return m_role;}
460        private:
461            abac_aspect_t *m_role;
462    };
463
464/***
465ABAC::Oset
466   An Oset is oset specification of a set of entitities for a principal
467***/
468    class Oset {
469        public:
470/***
471f  Oset()
472     default constructor, do not use, for swig only
473f  Oset(const Oset &)
474     copy constructor, used for cloning an oset
475f  ~Oset()
476     default destructor
477***/
478            Oset() : m_oset(NULL) { } // do not use: here for swig
479            Oset(const Oset &oset)
480            { m_oset =abac_aspect_dup(oset.m_oset); }
481            ~Oset()
482            { if(m_oset) abac_aspect_free(m_oset); }
483/*ii**
484f  Oset(abac_aspect_t *)
485     constructor that takes abac_aspect_t structure
486**ii*/
487            Oset(abac_aspect_t *oset): m_oset(abac_aspect_dup(oset)) 
488            { }
489/***
490f  Oset(char *)
491     constructor that makes a principal oset, ie [keyid:B]
492     (C:abac_role_principal_create)
493f  Oset(char *, char *)
494     constructor that makes a regular oset, ie. [keyid:B].oset:o
495     (C:abac_role_create)
496f  Oset(char *, char*, char *)
497     constructor that makes a linked oset, ie. [keyid:B].role:r.oset:o
498     (C:abac_oset_linked_create)
499f  Oset(DataTerm&)
500     constructor that makes an object oset, ie. [urn:'file/fileA']
501     (C:abac_oset_object_create)
502***/
503            Oset(char *oset_name) : m_oset(abac_oset_principal_create(oset_name)) 
504            { }
505            Oset(char *principal_name, char *oset_name) : 
506               m_oset(abac_oset_create(principal_name, oset_name)) 
507            { }
508            Oset(char *principal_name, char *linked_role_name,char *oset_name) : 
509               m_oset(abac_oset_linked_create(principal_name, linked_role_name, oset_name)) 
510            { }
511            Oset(DataTerm& d) :
512               m_oset(abac_oset_object_create(d.term())) 
513            { }
514
515/***
516f  bool oset_is_object(), ie <- [integer:10]
517     return ture if this oset is an object oset
518     (C:abac_oset_is_object)
519***/
520            bool oset_is_object() const
521            { return abac_oset_is_object(m_oset); }
522/***
523f  bool oset_is_principal() const
524     return true if the oset is a principal object(made from
525     a data term), the right hand side of,
526       [keyid:A].oset:o <- [keyid:B]
527     (C:abac_oset_is_principal)
528***/
529            bool oset_is_principal() const 
530            { return abac_oset_is_principal(m_oset); }
531/***
532f  bool oset_is_linking() const
533     returns true if the oset is a linking oset like
534     the right hand side of,
535       [keyid:A].oset:o1 <- [keyid:B].role:r1.oset:o2
536     (C:abac_oset_is_linking)
537***/
538            bool oset_is_linking() const 
539            { return abac_oset_is_linking(m_oset); }
540/***
541f  char *string() const
542     returns literal string of the oset
543     (C:abac_oset_string)
544f  char *typed_string() const
545     returns typed literal string of the oset
546     (C:abac_oset_typed_string)
547***/
548            char *string() const
549            { return abac_oset_string(m_oset); }
550            char *typed_string()
551            { return abac_oset_typed_string(m_oset); }
552/***
553f  char *oset_linked_role() const
554     returns linked part of a linking oset, for
555       [keyid:A].role:r1.oset:o1, it returns r1
556     (C:abac_oset_linked_role)
557***/
558            char *oset_linked_role() const 
559            { return abac_oset_linked_role(m_oset); }
560/***
561f  char *oset_name() const
562     returns oset name,
563       [keyid:A].role:r1.oset:o1, it returns o1
564       [keyid:A].oset:o1, it returns o1
565     (C:abac_oset_name)
566***/
567            char *oset_name() const
568            { return abac_oset_name(m_oset); }
569/***
570f  char *oset_principal() const
571     returns principal name,
572       [keyid:A].role:r1.oset:o1, it returns A
573     (C:abac_oset_principal)
574***/
575            char *oset_principal() const
576            { return abac_oset_principal(m_oset); }
577/***
578f  char *oset_object() const
579     returns object's name when the oset is a principal object
580       [keyid:A].oset:values <- [integer:10], it returns 10
581     (C:abac_oset_object)
582***/
583            char *oset_object() const 
584            { return abac_oset_object(m_oset); }
585/***
586f  void add_data_term(DataTerm&)
587     add a data term to this oset's parameter set
588     (C:abac_oset_add_data_term)
589***/
590            void oset_add_data_term(DataTerm& d) {
591              abac_oset_add_data_term(m_oset, d.term()); 
592            }
593/***
594f  std::vector<DataTerm> get_data_terms(bool &)
595     returns the data terms bound to this oset. 
596     (C:abac_oset_get_data_terms)
597***/
598            std::vector<DataTerm> get_data_terms(bool &success) {
599              abac_term_t **terms, **end;
600              int i;
601              terms = abac_oset_get_data_terms(m_oset);
602              for (i = 0; terms[i] != NULL; ++i)
603                  ;
604              end = &terms[i];
605              std::vector<DataTerm> dataterms = std::vector<DataTerm>(terms, end);
606              abac_terms_free(terms);
607              success=1;
608              return dataterms;
609            }
610/***
611f  void oset_add_linked_data_term(DataTerm&)
612     add a data term to this oset's linking role's parameter set.
613     (C:abac_oset_add_linked_data_term)
614***/
615            void oset_add_linked_data_term(DataTerm& d) {
616              abac_oset_add_linked_data_term(m_oset, d.term());
617            }
618/***
619f  std::vector<DataTerm> get_linked_data_terms(bool &)
620     returns the data terms bound to this oset's linking role. 
621     (C:abac_oset_get_linked_data_terms)
622***/
623            std::vector<DataTerm> get_linked_data_terms(bool &success) {
624              abac_term_t **terms, **end;
625              int i;
626              terms = abac_oset_get_linked_data_terms(m_oset);
627              for (i = 0; terms[i] != NULL; ++i)
628                  ;
629              end = &terms[i];
630              std::vector<DataTerm> dataterms = std::vector<DataTerm>(terms, end);
631              abac_terms_free(terms);
632              success=1;
633              return dataterms;
634            }
635/*ii**
636f  abac_aspect_t *oset()
637     internal returns the internal libabac representation of the oset
638**ii*/
639            abac_aspect_t *oset() {return m_oset;}
640        private:
641            abac_aspect_t *m_oset;
642    };
643
644
645/***
646ABAC::ID
647   An ID holds a principal credential. It maybe imported from an existing
648   ID credential via external files, constructed from a streaming chunk,
649   or instantiated on the fly 
650***/
651    class ID {
652        public:
653/***
654f  ID()
655     default constructor, do not use, for swig only
656f  ID(const ID &)
657     copy constructor, used for cloning an ID
658f  ~ID()
659     default destructor
660***/
661            ID() : m_id(NULL) { } // do not use: here for swig
662            ID(const ID &id) { m_id =abac_id_dup(id.m_id); }
663            ~ID() { if(m_id) abac_id_free(m_id); }
664/*ii**
665f  ID(abac_id_t *)
666     constructor from abac_id_t
667f  ID(abac_id_credential_t *)
668     constructor from abac_id_credential_t
669**ii*/
670            ID(abac_id_t *id): m_id(abac_id_dup(id)) 
671            { }
672            ID(abac_id_credential_t *idcred) {
673              if(idcred)
674                m_id=abac_id_dup(abac_id_credential_id(idcred));
675              else m_id=NULL;
676            }
677/***
678f  ID(char *)
679     load an ID cert from a file, will throw an exception
680     if the cert cannot be loaded
681     (C:abac_id_from_file)
682***/
683            ID(char *filename) {
684              if(debug) printf("calling ID with a filename\n");
685              m_id=abac_id_from_file(filename); 
686              if(m_id==NULL)
687                abac_errx(1, "Id creation from filename failed");
688            }
689/***
690f  ID(abac_chunk_t *chunk)
691     create an ID cert from an cert chunk, will
692     throw an exception if the cert cannot be loaded
693     (C:abac_id_from_chunk)
694***/
695            ID(abac_chunk_t *chunk) {
696              if(debug) printf("calling ID with chunk\n");
697              m_id=abac_id_from_chunk(*chunk); 
698              if(m_id==NULL)
699                abac_errx(1, "Id creation from chunk failed");
700            }
701/***
702f  ID(char *,int)
703     generates a new ID(cert&key) with the supplied CN and validity period
704     - CN must be alphanumeric and begin with a letter
705     - validity must be at least one second
706     will throw an exception if either of the above is violated
707     (C:abac_id_generate)
708***/
709            ID(char *cn, int validity) {
710              int rt=abac_id_generate(&m_id, cn, validity);
711              if(rt != ABAC_ID_SUCCESS) 
712                abac_errx(1, "Id generation failed");
713            }
714/***
715f  ID(char *,int, char*, char*)
716     generates a new ID from a supplied CN, keyfile, passphrase(optional) file
717     and validity period
718     - CN must be alphanumeric and begin with a letter
719     - validity must be at least one second
720     will throw an exception if either of the above is violated
721     (C:abac_id_generate_with_key)
722***/
723            ID(char *cn, int validity, char *kfile, char* pfile) {
724
725              int rt=abac_id_generate_with_key(&m_id, cn, validity, kfile, pfile);
726              if(rt != ABAC_ID_SUCCESS) 
727                abac_errx(1, "Id (with key) creation failed");
728            }
729/***
730f  void id_load_privkey_file(char *)
731     loads the private key associated with the ID credential,
732     will throw an exception if the key cannot be loaded
733     (C:abac_id_load_privkey_file)
734***/
735            void id_load_privkey_file(char *filename) {
736              int rt=abac_id_load_privkey_file(m_id, filename);
737              if(rt != 1) 
738                abac_errx(1, "Failed to load private key");
739            }
740/***
741f  void id_load_encrypted_privkey_file(char *, char*)
742     loads an encrypted private key and pfile associated with the
743     ID credential, will throw an exception if the key cannot be loaded
744     (C:abac_id_load_enc_privkey_file)
745***/
746            void id_load_encrypted_privkey_file(char *filename, char* pfile) {
747              int rt=abac_id_load_encrypted_privkey_file(m_id, filename, pfile);
748              if(rt != 1) 
749                abac_errx(1, "Failed to load private key");
750            }
751/*ii**
752f  abac_id_t *id()
753     returns the abac_id_t
754     returns the interal libabac representation of this id
755**ii*/
756            abac_id_t *id() { return m_id; }
757
758/***
759f  char *id_keyid()
760     returns the SHA1 keyid of the id cert
761     (C:abac_id_keyid)
762f  char *id_name()
763     returns the CN (the parameter passed to the constructor or the
764     CN of the cert).
765     (C:abac_id_cn)
766***/
767            char *id_keyid() { return abac_id_keyid(m_id); }
768            char *id_name() { return abac_id_cn(m_id); }
769/***
770f  bool id_has_privkey()
771     returns true if the ID has an associated private key
772     (C:abac_id_has_privkey)
773***/
774            bool id_has_privkey()
775            { return abac_id_has_privkey(m_id); }
776
777/***
778f  void id_write_cert(FILE *)
779     writes a PEM-encoded cert to the file handle
780     (C:abac_id_write_cert)
781f  void id_write_cert(char *)
782     writes a PEM-encoded cert to a file named out
783     (C:abac_id_write_cert_fname)
784***/
785            void id_write_cert(FILE *out)
786            { abac_id_write_cert(m_id, out); }
787            void id_write_cert(char *filename)
788            { abac_id_write_cert_fname(m_id, filename); }
789/***
790f  void id_write_privkey(FILE *)
791     writes a PEM-encoded private key to the file handle
792     throws an exception if no private key is loaded
793     (C:abac_id_write_privkey)
794f  void id_write_privkey(char *)
795      writes a PEM-encoded private key a file named out
796      throws an exception if no private key is loaded
797     (C:abac_id_write_privkey_fname)
798***/
799            void id_write_privkey(FILE *out) {
800              if(!id_has_privkey())
801                  abac_errx(1, "No privkey to write");
802              abac_id_write_privkey(m_id, out);
803            }
804            void id_write_privkey(char *filename)
805            { abac_id_write_privkey_fname(m_id, filename); }
806/***
807f  abac_chunk_t *id_cert_chunk_ptr()
808     returns a DER-encoded binary representation of the X.509 ID cert
809     associated with this ID. (chunk ptr version)
810     can be passed to libabac's Context::load_id_chunk()
811     (C:abac_id_cert_chunk_ptr)
812f  abac_chunk_t *id_privkey_chunk_ptr()
813     returns a PEM-encoded binary representation of the private key
814     associated with this ID. (chunk ptr version)
815     can be passed to libabac's Context::load_id_chunks()
816     (C:abac_id_privkey_chunk_ptr)
817f  abac_chunk_t id_cert_chunk()
818     returns a DER-encoded binary representation of the X.509 ID cert
819     associated with this ID.
820     can be passed to libabac's Context::load_id_chunk()
821     (C:abac_id_cert_chunk)
822f  abac_chunk_t id_privkey_chunk()
823     returns a PEM-encoded binary representation of the private key
824     associated with this ID.
825     can be passed to libabac's Context::load_id_chunks()
826     (C:abac_id_privkey_chunk)
827***/
828            abac_chunk_t *id_cert_chunk_ptr()
829            { return abac_id_cert_chunk_ptr(m_id); }
830            abac_chunk_t *id_privkey_chunk_ptr()
831            { return abac_id_privkey_chunk_ptr(m_id); }
832            abac_chunk_t id_cert_chunk()
833            { return abac_id_cert_chunk(m_id); }
834            abac_chunk_t id_privkey_chunk()
835            { return abac_id_privkey_chunk(m_id); }
836            void print_key_chunk()
837            { abac_id_print_key_chunk(m_id); } 
838/***
839f  char *string()
840     returns literal string of the id credential
841     (C:abac_id_string)
842***/
843            char *string()
844            { return abac_id_string(m_id); }
845        public:
846            abac_id_t *m_id;
847    };
848
849
850/***
851ABAC::Attribute
852   This is the attribute representation for the access policy rule
853       LHS <- RHS
854   The sequence of generation is to
855       first, instantiate the object, ie, LHS (head)
856       second, adding subject(s) to it, ie, RHS (tail)
857       and then baking it.
858   Only once it's baked can you access the X.509 cert.
859   Once it's been baked you can no longer add subjects to it
860***/
861    class Attribute {
862        public:
863/***
864f  Attribute()
865     default constructor, do not use, for swig only
866f  Attribute(const Attribute &)
867     copy constructor, used for cloning an attribute
868f  ~Attribute()
869     default destructor
870***/
871            Attribute() : m_attr(NULL) { } 
872            Attribute(const Attribute &id)
873            { m_attr =abac_attribute_dup(id.m_attr); }
874            ~Attribute()
875            { if(m_attr) abac_attribute_free(m_attr); }
876/*ii**
877f  Attribute(abac_attribute_t *)
878     constructor that takes abac_attribute_t, locally used
879f  Attribute(abac_credential_t *)
880     constructor that takes abac_credential_t, locally used
881**ii*/
882            Attribute(abac_attribute_t *attr): m_attr(abac_attribute_dup(attr)) 
883            { }
884            Attribute(abac_credential_t *cred)
885            { m_attr=abac_attribute_dup(abac_credential_attribute(cred)); }
886/***
887f  Attribute(Role&, int)
888     constructor that creates an attribute policy to be signed by the issuer
889     with the given role with a specified validity period
890     An exception will be thrown if:
891       - the issuer has no private key
892       - the Head role is invalid
893       - the validity period is invalid (must be >= 1 second)
894     (C:abac_attribute_create)
895***/
896            Attribute(Role& head, int validity) {
897              int rt=abac_attribute_create(&m_attr, head.role(), NULL, validity);
898              if(rt!=ABAC_ATTRIBUTE_SUCCESS)
899                  abac_errx(1, "attribute(role), unable to make an attribute");
900            }
901/***
902f  Attribute(Oset&, int)
903     constructor that creates an attribute policy to be signed by the issuer
904     with the given oset with a specified validity period
905     An exception will be thrown if:
906       - the issuer has no private key
907       - the Head oset is invalid
908       - the validity period is invalid (must be >= 1 second)
909     (C:abac_attribute_create)
910***/
911            Attribute(Oset& head, int validity) {
912              int rt=abac_attribute_create(&m_attr, head.oset(), NULL, validity);
913              if(rt!=ABAC_ATTRIBUTE_SUCCESS)
914                  abac_errx(1, "attribute(oset), unable to make an attribute");
915            }
916/***
917f  bool attribute_add_tail(Role&)
918      Add a role tail.  Call multiple times for intersection
919     (C:abac_attribute_add_tail)
920f  bool attribute_add_tail(Oset&)
921      Add an oset tail.  Call multiple times for intersection
922     (C:abac_attribute_add_tail)
923***/
924            bool attribute_add_tail(Role& tail) {
925              if(abac_attribute_add_tail(m_attr, tail.role()))
926                  return 1;
927                  else return 0;
928            }
929            bool attribute_add_tail(Oset& tail) {
930              if(abac_attribute_add_tail(m_attr, tail.oset()))
931                  return 1;
932                  else return 0;
933            }
934/***
935f  char *head_string()
936     returns literal string of head of the attribute
937     (C:abac_head_string)
938f  char *tail_string()
939     returns literal string of tail of the attribute
940     (C:abac_tail_string)
941***/
942            char *head_string()
943            { return abac_head_string(m_attr); }
944            char *tail_string()
945            { return abac_tail_string(m_attr); }
946/***
947f  char *head_typed_string()
948     returns typed literal string of head of the attribute
949     (C:abac_head_typed_string)
950f  char *tail_typed_string()
951     returns typed literal string of tail of the attribute
952     (C:abac_tail_typed_string)
953***/
954            char *head_typed_string()
955            { return abac_head_typed_string(m_attr); }
956            char *tail_typed_string()
957            { return abac_tail_typed_string(m_attr); }
958/***
959f  char *string()
960     returns literal string of the attribute
961     (C:abac_attribute_string)
962f  char *typed_string()
963     returns typed literal string of the attribute
964     (C:abac_attribute_typed_string)
965***/
966            char *string()
967            { return abac_attribute_string(m_attr); }
968            char *typed_string()
969            { return abac_attribute_typed_string(m_attr); }
970
971/*** ??? not sure about implmentation
972f  const Role &role_head()
973     returns the head role
974f  const Oset &oset_head()
975     returns the oset head
976***/
977            const Role &role_head() {
978              abac_aspect_t *head=abac_attribute_head(m_attr);
979              static Role role=Role(head);
980              return role;
981            }
982            const Oset &oset_head() {
983              abac_aspect_t *head=abac_attribute_tail(m_attr);
984              static Oset oset=Oset(head);
985              return oset;
986            }
987/***
988f  std::vector<Role> role_tails(bool &)
989     retrieve tail role which maybe more than 1 if intersecting
990     (C:abac_attribute_role_tails)
991f  std::vector<Oset> oset_tails(bool &)
992     retrieve tail oset which maybe more than 1 if intersecting
993     (C:abac_attribute_oset_tails)
994***/
995            std::vector<Role> role_tails(bool &success) {
996              abac_aspect_t **tails, **end;
997              int i;
998              /* make sure it is role */
999              if(!abac_attribute_is_role(m_attr)) {
1000                success=0; 
1001                abac_errx(1, "role_tails, attribute is not a role");
1002              }
1003              tails = abac_attribute_role_tails(m_attr);
1004              for (i = 0; tails[i] != NULL; ++i)
1005                  ;
1006              end = &tails[i];
1007              std::vector<Role> roles = std::vector<Role>(tails, end);
1008              abac_aspects_free(tails);
1009              success=1;
1010              return roles;
1011            }
1012            std::vector<Oset> oset_tails(bool &success) {
1013              abac_aspect_t **tails, **end;
1014              int i;
1015              /* make sure that tail is not role */
1016              if(abac_attribute_is_role(m_attr)) {
1017                success=0; 
1018                abac_errx(1, "oset_tails, attribute is not an oset");
1019              }
1020              tails = abac_attribute_oset_tails(m_attr);
1021              for (i = 0; tails[i] != NULL; ++i)
1022                  ;
1023              end = &tails[i];
1024              std::vector<Oset> osets = std::vector<Oset>(tails, end);
1025              success=1;
1026              abac_aspects_free(tails);
1027              return osets;
1028            }
1029/*ii**
1030f  abac_attribute_t *attribute()
1031      return libabac structure for attribute
1032**ii*/
1033            abac_attribute_t *attribute() { return m_attr; }
1034
1035/***
1036f  bool attribute_bake()
1037     Generate the cert. Call this after you've added subjects to your cert.
1038     This returns false if there are no subjects
1039     This will throw an exception if the cert's already been baked.
1040     (C:abac_attribute_bake)
1041***/
1042            bool attribute_bake() {
1043              /* can not bake in ABAC_CN mode */
1044              if(USE("ABAC_CN"))
1045                  abac_errx(1, "bake, can not bake the cert with env(ABAC_CN) set");
1046              int rt=abac_attribute_bake(m_attr);
1047              if(rt!=1)
1048                  abac_errx(1, "bake, can not bake the cert");
1049            }
1050/***
1051f  bool attribute_baked()
1052     returns true iff the cert has been baked.
1053     (C:abac_attribute_baked)
1054***/
1055            bool attribute_baked()
1056            { return abac_attribute_baked(m_attr); }
1057
1058/***
1059f  void attribute_write_cert(FILE *)
1060     write the DER-encoded X.509 attribute cert to the open file handle
1061     Throws an exception if the cert isn't baked
1062     (C:abac_attribute_write_cert)
1063***/
1064            void attribute_write_cert(FILE *out) {
1065              int rt= abac_attribute_write_cert(m_attr,out);
1066              if(!rt)
1067                  abac_errx(1, "write, cert is not baked");
1068            }
1069/***
1070f  void attribute_write_cert(char *)
1071     write the DER-encoded X.509 attribute cert to a file named out
1072     Throws an exception if the cert isn't baked
1073     (C:abac_attribute_write_cert_fname)
1074***/
1075            void attribute_write_cert(char *filename)
1076            { abac_attribute_write_cert_fname(m_attr,filename); }
1077/***
1078f  abac_chunk_t cert_chunk()
1079     returns a DER-encoded binary representation of the X.509 attribute
1080     cert associated with this cert
1081     Throws an exception if the cert isn't baked
1082     the chunk can be passed to libabac's Context::load_attribute_chunk()
1083     (C:abac_attribute_cert_chunk)
1084***/
1085            abac_chunk_t cert_chunk()
1086            { return abac_attribute_cert_chunk(m_attr); }
1087      private:
1088            abac_attribute_t *m_attr;
1089     };
1090
1091
1092/***
1093ABAC::Context
1094    An ABAC Context
1095***/
1096    class Context {
1097        public:
1098/***
1099f  Context()
1100     default constructor
1101f  Context(const Context &)
1102     copy constructor, used for cloning the context
1103f  ~Context()
1104     default destructor
1105***/
1106            Context() { 
1107              m_ctx = abac_context_new();
1108              m_abac_version=strdup(abac_version());
1109            }
1110            Context(const Context &context) { 
1111              m_ctx = abac_context_dup(context.m_ctx);
1112              m_abac_version=strdup(context.m_abac_version);
1113            }
1114            ~Context() { 
1115              abac_context_free(m_ctx);
1116              if(m_abac_version) free(m_abac_version);
1117            }
1118/***
1119f  void dump_yap_db()
1120     dump the complete yap prolog database
1121     (C:show_yap_db)
1122***/
1123            void dump_yap_db()
1124            { show_yap_db("dump_yap"); }
1125/***
1126f  int load_id(ABAC::ID&)
1127     load id cert from ID
1128     (C:abac_context_load_id)
1129f  int load_id_file(char *)
1130     load id cert from an idkey combo file. key retrieval will be attempted
1131     but won't fail if not found
1132     (C:abac_context_load_id_file)
1133f  int load_id_encrypted_file(char *, char *)
1134     load id cert from an idkey combo file and a pfile. Encrypted key
1135     retrieval will be attempted but won't fail if not found
1136     (C:abac_context_load_encrypted_id_file)
1137f  int load_id_files(char *, char *)
1138     load id cert from an id file and a key file
1139     (C:abac_context_load_id_files)
1140f  int load_id_encrypted_files(char *, char *, char *)
1141     load id cert from an id file, an encrypted key file, and a pfile
1142     (C:abac_context_load_encrypted_id_files)
1143f  int load_id_chunk(abac_chunk_t)
1144     load id cert from a chunk structure
1145     (C:abac_context_load_id_chunk)
1146f  int load_id_chunks(abac_chunk_t, abac_chunk_t)
1147     load id & privkey from chunk structures
1148     (C:abac_context_load_id_privkey_chunk)
1149f  int load_id_encrypted_chunks(abac_chunk_t, abac_chunk_t,char *pfile)
1150     load id & encrypted privkey from chunk structures
1151     (C:abac_context_load_id_enc_privkey_chunk)
1152     returns:
1153       ABAC_CERT_SUCCESS   successfully loaded
1154       ABAC_CERT_INVALID   invalid certificate (or file not found)
1155       ABAC_CERT_BAD_SIG   invalid signature
1156***/
1157            int load_id(ABAC::ID& id)
1158            { return abac_context_load_id(m_ctx, id.id()); }
1159            int load_id_file(char *filename)
1160            { return abac_context_load_id_file(m_ctx, filename); }
1161            int load_id_encrypted_file(char *filename, char *pfile)
1162            { return abac_context_load_encrypted_id_file(m_ctx, filename, pfile); }
1163            int load_id_files(char *filename, char *keyfilename) 
1164            { return abac_context_load_id_files(m_ctx, filename, keyfilename); }
1165            int load_id_encrypted_files(char *filename, char *keyfilename, char *pfile) 
1166            { return abac_context_load_encrypted_id_files(m_ctx, filename, keyfilename, pfile); }
1167            int load_id_chunk(abac_chunk_t cert) 
1168            { return abac_context_load_id_chunk(m_ctx, cert); }
1169            int load_id_chunks(abac_chunk_t cert, abac_chunk_t privkey) 
1170            { if(debug) printf("load_id_chunks, FUNNY privkey ptr, loc(%p)\n",
1171                                                            privkey.ptr);
1172              return abac_context_load_id_privkey_chunk(m_ctx, cert, privkey); }
1173            int load_id_encrypted_chunks(abac_chunk_t cert, abac_chunk_t privkey, char *pfile) 
1174            { if(debug) printf("load_id_encrypted_chunks, FUNNY privkey ptr, loc(%p)\n",
1175                                                            privkey.ptr);
1176              return abac_context_load_id_enc_privkey_chunk(m_ctx, cert, privkey, pfile); }
1177
1178/***
1179f  int load_attribute(ABAC::Attribute&)
1180     load attribute credential from attribute structure
1181     (C:abac_context_load_attribute)
1182f  int load_attribute_file(char *)
1183     load attribute credential from a file
1184     (C:abac_context_load_attribute_file)
1185f  int load_attribute_chunk(abac_chunk_t)
1186     load attribute credential from a chunk
1187     (C:abac_context_load_attribute_chunk)
1188f    returns the same values as above, additionally
1189     returns ABAC_CERT_MISSING_ISSUER if the issuer
1190     certificate has not been loaded
1191***/
1192            int load_attribute(ABAC::Attribute& a)
1193            { return abac_context_load_attribute(m_ctx, a.attribute()); }
1194            int load_attribute_file(char *filename)
1195            { return abac_context_load_attribute_file(m_ctx, filename); }
1196            int load_attribute_chunk(abac_chunk_t cert)
1197            { return abac_context_load_attribute_chunk(m_ctx, cert); }
1198/***
1199f  void load_principals(char *)
1200     load a directory full of principals only:
1201f       first: ${path}/*_ID.{der,pem} as identity certificates
1202               implicitly looking for ${path}/*_private.{der,pem} as
1203               the private key file
1204        then: ${path}/*_IDKEY.{der,pem} as id/key combo certificate
1205      (C:abac_context_load_principals)
1206f  void load_directory(char *)
1207     load a directory full of certificates:
1208f       first: ${path}/*_ID.{der,pem} as identity certificates
1209               implicitly looking for ${path}/*_private.{der,pem} as
1210               the private key file
1211        then: ${path}/*_IDKEY.{der,pem} as id/key combo certificate
1212        last: ${path}/*_attr.der as attribute certificates
1213      (C:abac_context_load_directory)
1214***/
1215            void load_principals(char *path)
1216            { abac_context_load_principals(m_ctx, path); }
1217            void load_directory(char *path)
1218            { abac_context_load_directory(m_ctx, path); }
1219/***
1220f  std::vector<Attribute> query(char *, char *, bool &)
1221     the string version is for query that is composed by hand with SHA or
1222     in non ABAC_CN mode 
1223     (C:abac_context_query)
1224f  std::vector<Attribute> query(Role &, Role &, bool &)
1225     (C:abac_context_query_with_structure)
1226   std::vector<Attribute> query(Oset &, Oset &, bool &)
1227     (C:abac_context_query_with_structure)
1228     runs the query:
1229       role <-?- principal
1230       oset <-?- principal/obj
1231     returns true/false in success
1232     returns a proof upon success,
1233     partial proof on failure (not implemented yet)
1234***/
1235            std::vector<Attribute> query(char *role, char *principal, bool &success) {
1236               abac_credential_t **creds, **end;
1237               int i, success_int;
1238
1239               creds = abac_context_query(m_ctx, role, principal, &success_int);
1240               success = success_int;
1241
1242               for (i = 0; creds[i] != NULL; ++i)
1243                  ;
1244
1245               end = &creds[i];
1246               std::vector<Attribute> attributes = std::vector<Attribute>(creds, end);
1247               if(debug) printf("query, got rules(%d)\n", i);
1248
1249               abac_context_credentials_free(creds);
1250
1251               return attributes;
1252            }
1253
1254            std::vector<Attribute> query(Role &role, Role &p_role, bool &success) {
1255               abac_credential_t **creds, **end;
1256               int i, success_int;
1257
1258               creds = abac_context_query_with_structure(m_ctx, role.role(), p_role.role(), &success_int);
1259               success = success_int;
1260
1261               for (i = 0; creds[i] != NULL; ++i)
1262                  ;
1263
1264               end = &creds[i];
1265               std::vector<Attribute> attributes = std::vector<Attribute>(creds, end);
1266
1267               abac_context_credentials_free(creds);
1268
1269               return attributes;
1270            }
1271
1272            std::vector<Attribute> query(Oset &oset, Oset &p_oset, bool &success) {
1273               abac_credential_t **creds, **end;
1274               int i, success_int;
1275           
1276               creds = abac_context_query_with_structure(m_ctx, oset.oset(), p_oset.oset(), &success_int);
1277               success = success_int;
1278
1279               for (i = 0; creds[i] != NULL; ++i)
1280                  ;
1281
1282               end = &creds[i];
1283               std::vector<Attribute> attributes = std::vector<Attribute>(creds, end);
1284               if(debug) printf("query, returning rules(%d)\n", i);
1285
1286               abac_context_credentials_free(creds);
1287
1288               return attributes;
1289            }
1290
1291/***
1292f  std::vector<Attribute> next_proof(bool &)
1293     (C:abac_context_query_again)
1294     force backtrack and try to get next solution proof:
1295     returns true/false in success
1296     returns a proof upon success,
1297***/
1298            std::vector<Attribute> next_proof(bool &success) {
1299               abac_credential_t **creds, **end;
1300               int i, success_int;
1301
1302               creds = abac_context_query_again(m_ctx, &success_int);
1303               success = success_int;
1304
1305               for (i = 0; creds[i] != NULL; ++i)
1306                  ;
1307
1308               end = &creds[i];
1309               std::vector<Attribute> attributes = std::vector<Attribute>(creds, end);
1310               if(debug) printf("repeat query, got rules(%d)\n", i);
1311
1312               abac_context_credentials_free(creds);
1313
1314               return attributes;
1315            }
1316/***
1317f  std::vector<Attribute> context_credentials(bool &)
1318     returns a vector of all the credentials loaded in the context
1319     extracted from the internal data structure
1320     (C:abac_context_credentials)
1321***/
1322            std::vector<Attribute> context_credentials(bool &success) {
1323              abac_credential_t **creds, **end;
1324              int i;
1325              success = 1;
1326
1327              creds = abac_context_credentials(m_ctx);
1328              for (i = 0; creds[i] != NULL; ++i)
1329                  ;
1330
1331              end = &creds[i];
1332              std::vector<Attribute> attributes = std::vector<Attribute>(creds, end);
1333              if(debug) printf("credentials, got (%d)\n", i);
1334
1335              abac_context_credentials_free(creds);
1336              if(debug) show_yap_db("calling from context_credentials");
1337              return attributes;
1338            }
1339
1340/***
1341f  std::vector<Attribute> context_principals(bool &)
1342     returns a vector of all the principals loaded in the context
1343     extracted from the internal data structure
1344     (C:abac_context_principals)
1345***/
1346            std::vector<ID> context_principals(bool &success) {
1347              abac_id_credential_t **ids, **end;
1348              int i;
1349              success = 1;
1350
1351              ids = abac_context_principals(m_ctx);
1352              for (i = 0; ids[i] != NULL; ++i)
1353                  ;
1354
1355              end = &ids[i];
1356              std::vector<ID> principals = std::vector<ID>(ids, end);
1357              if(debug) printf("principals, got (%d)\n", i);
1358
1359              abac_context_principals_free(ids);
1360              return principals;
1361            }
1362/***
1363f  ID lookup_principal(char *)
1364     find a particular principal from the context
1365***/
1366            ID lookup_principal(char *name) const 
1367              { 
1368                abac_id_credential_t *principal=abac_context_principal_lookup(m_ctx,name);
1369                if(principal==NULL) {
1370                  if(debug) printf("did not find the principal(%s)\n", name);
1371                  abac_errx(1, "lookup principal failed");
1372                }
1373                return principal;
1374              }
1375/***
1376f  char *version()
1377     return the version of this interface
1378***/
1379            char *version() const { return m_abac_version; }
1380
1381        private:
1382            abac_context_t *m_ctx;
1383            char *m_abac_version;
1384    };
1385
1386    Constraint::Constraint(Role& role)
1387    { m_constraint=abac_constraint_from_role(role.role()); }
1388    Constraint::Constraint(Oset &oset)
1389    { m_constraint=abac_constraint_from_oset(oset.oset()); }
1390    DataTerm::DataTerm(ID& id)
1391    { m_term=abac_term_id_create(id.id()); }
1392}
1393
1394#endif /* __ABAC_HH__ */
Note: See TracBrowser for help on using the repository browser.