OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / mico / security / odm_impl.h
1 // -*- c++ -*-
2 //
3 //  MICOsec --- a free CORBA Security implementation
4 //  Copyright (C) 2000 ObjectSecurity Ltd.
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Library General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2 of the License, or (at your option) any later version.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Library General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Library General Public
17 //  License along with this library; if not, write to the Free
18 //  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 //  Send comments and/or bug reports to:
21 //                 micosec@objectsecurity.com
22 //
23
24 #ifndef __ODM_IMPL_H__
25 #define __ODM_IMPL_H__
26
27 #include <CORBA.h>
28
29 namespace MICOSODM
30 {
31     class Manager_impl;
32     struct ODMRecord;
33
34     extern void _init ();
35
36     extern ODMRecord*
37     find_record(std::string& key, MICOSODM::Manager_impl* odm);
38
39     extern void
40     remove_record(std::string& key, MICOSODM::Manager_impl* odm);
41
42     extern void
43     set_lspolicy
44     (MICOSODM::Manager_impl* odm,
45      PortableServer::LifespanPolicyValue p);
46
47     extern PortableServer::LifespanPolicyValue
48     get_lspolicy(MICOSODM::Manager_impl* odm);
49
50     // ODM options (-ODMConfig)
51
52     class ODMOptions
53     {
54     public:
55         CORBA::Boolean
56         parse (CORBA::ORB_ptr, int&, char* []);
57
58         const char*
59         operator[](const char *);
60
61     private:
62         std::map<std::string, std::string, std::less<std::string> > options_;
63     };
64
65     extern MICO_EXPORT ODMOptions odmopts;
66
67     struct ODMRecord
68     {
69         ODMRecord()
70         {}
71         ~ODMRecord()
72         {}
73         ODMRecord(const ODMRecord& s);
74
75         ODMRecord&
76         operator=(const ODMRecord& s);
77     
78         ObjectDomainMapping::Manager::ODMGranularity gran_;
79         SecurityDomain::NameList dnamelist_; // Domain Namelist
80         Manager_impl* dm_;
81         std::string x509_;
82         PortableServer::LifespanPolicyValue pol_;
83     };
84
85     typedef std::map<std::string, ODMRecord *, std::less<std::string> > DomainMap;
86
87     class AllDomainList
88     {
89     public:
90         AllDomainList(std::ostream* o = &std::cout)
91         { out_ = o;}
92         ~AllDomainList()
93         {}
94
95         DomainMap&
96         get_domain_map();
97
98         CORBA::Boolean
99         load_config(const char* conffile);
100
101         CORBA::Boolean
102         load_config();
103
104         CORBA::Boolean
105         save_config(const char* conffile);
106     
107     private:
108         DomainMap all_domains_;
109         std::ostream* out_;
110     };
111
112   
113     // Manager interface
114
115     class Manager_impl
116         : public ObjectDomainMapping::Manager
117     {
118     private:
119         Manager_impl* parent_;
120         Manager_impl* def_parent_;
121         //    ObjectDomainMapping::Manager::ODMGranularity gran;
122         //    string key;
123         std::string def_key_;
124         //    PortableServer::POA_ptr poa;
125         PortableServer::LifespanPolicyValue pol_;
126         AllDomainList* domains_;
127
128     protected:
129         std::string
130         opaque_to_string(const Security::Opaque& key);
131       
132     public:
133         Manager_impl();
134         Manager_impl(AllDomainList* domains);
135         ~Manager_impl();
136
137         virtual void
138         set_domain_name_key
139         (ODMGranularity granularity,
140          const Security::Opaque& key,
141          const SecurityDomain::NameList& domain_name_list);
142
143         virtual SecurityDomain::NameList*
144         get_domain_names(const Security::Opaque& key);
145
146         virtual void
147         remove_domain_names(const Security::Opaque& key);
148
149         virtual void
150         set_parent_odm_key
151         (const Security::Opaque& key,
152          ObjectDomainMapping::Manager_ptr odm);
153
154         virtual void
155         set_default_parent_odm(ObjectDomainMapping::Manager_ptr odm);
156
157         virtual void
158         set_default_name_key(const SecurityDomain::NameList& domain_name_list);
159       
160         friend ODMRecord*
161         find_record(std::string& key, MICOSODM::Manager_impl* odm);
162
163         friend void
164         remove_record(std::string& key, MICOSODM::Manager_impl* odm);
165
166         friend void
167         set_lspolicy
168         (MICOSODM::Manager_impl* odm,
169          PortableServer::LifespanPolicyValue p);
170
171         friend PortableServer::LifespanPolicyValue
172         get_lspolicy(MICOSODM::Manager_impl* odm);
173     };
174   
175   
176     // Manager Factory interface
177
178     class Factory_impl
179         : public ObjectDomainMapping::Factory {
180     public:
181         Factory_impl();
182         ~Factory_impl();
183       
184         virtual ObjectDomainMapping::Manager_ptr
185         create();
186
187         // extention
188         virtual CORBA::Boolean
189         load_config_file(const char* cf);
190
191         virtual CORBA::Boolean
192         save_config_file(const char* cf);
193
194         AllDomainList* domains_;
195     };
196
197     class ODM_impl
198         : public ObjectDomainMapping::ODM
199     {
200     private:
201         Factory_impl* cur_factory_;
202     
203     public:
204         ODM_impl()
205         { cur_factory_ = NULL; }
206         ~ODM_impl()
207         {}
208     
209         virtual ObjectDomainMapping::Factory_ptr
210         create()
211         {
212             cur_factory_ = new Factory_impl;
213             return cur_factory_;
214         }
215     
216         virtual ObjectDomainMapping::Factory_ptr current()
217         { return cur_factory_; }
218     };
219 } // MICOSODM
220
221 #endif // __ODM_IMPL_H__