3
#include "SecurityManager.h"
7
"SecurityManager.cpp,v 1.6 2003/10/28 18:34:24 bala Exp")
10
#include "PrincipalAuthenticator.h"
12
#include "tao/ORB_Constants.h"
15
TAO_SecurityManager::TAO_SecurityManager (void)
17
principal_authenticator_ ()
21
TAO_SecurityManager::~TAO_SecurityManager (void)
25
Security::MechandOptionsList *
26
TAO_SecurityManager::supported_mechanisms (ACE_ENV_SINGLE_ARG_DECL)
27
ACE_THROW_SPEC ((CORBA::SystemException))
29
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (
30
CORBA::SystemException::_tao_minor_code (
31
TAO_DEFAULT_MINOR_CODE,
37
SecurityLevel2::CredentialsList *
38
TAO_SecurityManager::own_credentials (ACE_ENV_SINGLE_ARG_DECL)
39
ACE_THROW_SPEC ((CORBA::SystemException))
41
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
46
SecurityLevel2::CredentialsList *creds_list = 0;
47
ACE_NEW_THROW_EX (creds_list,
48
SecurityLevel2::CredentialsList (this->own_credentials_),
50
CORBA::SystemException::_tao_minor_code (
51
TAO_DEFAULT_MINOR_CODE,
53
CORBA::COMPLETED_NO));
59
SecurityLevel2::RequiredRights_ptr
60
TAO_SecurityManager::required_rights_object (ACE_ENV_SINGLE_ARG_DECL)
61
ACE_THROW_SPEC ((CORBA::SystemException))
63
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (
64
CORBA::SystemException::_tao_minor_code (
65
TAO_DEFAULT_MINOR_CODE,
68
SecurityLevel2::RequiredRights::_nil ());
71
SecurityLevel2::PrincipalAuthenticator_ptr
72
TAO_SecurityManager::principal_authenticator (ACE_ENV_SINGLE_ARG_DECL)
73
ACE_THROW_SPEC ((CORBA::SystemException))
76
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
79
SecurityLevel2::PrincipalAuthenticator::_nil ());
81
if (CORBA::is_nil (this->principal_authenticator_.in ()))
83
TAO_PrincipalAuthenticator *pa = 0;
85
TAO_PrincipalAuthenticator (this),
87
CORBA::SystemException::_tao_minor_code (
88
TAO_DEFAULT_MINOR_CODE,
90
CORBA::COMPLETED_NO));
91
ACE_CHECK_RETURN (SecurityLevel2::PrincipalAuthenticator::_nil ());
93
this->principal_authenticator_ = pa;
98
SecurityLevel2::PrincipalAuthenticator::_duplicate (
99
this->principal_authenticator_.in ());
102
SecurityLevel2::AccessDecision_ptr
103
TAO_SecurityManager::access_decision (ACE_ENV_SINGLE_ARG_DECL)
104
ACE_THROW_SPEC ((CORBA::SystemException))
106
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (
107
CORBA::SystemException::_tao_minor_code (
108
TAO_DEFAULT_MINOR_CODE,
110
CORBA::COMPLETED_NO),
111
SecurityLevel2::AccessDecision::_nil ());
114
SecurityLevel2::AuditDecision_ptr
115
TAO_SecurityManager::audit_decision (ACE_ENV_SINGLE_ARG_DECL)
116
ACE_THROW_SPEC ((CORBA::SystemException))
118
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (
119
CORBA::SystemException::_tao_minor_code (
120
TAO_DEFAULT_MINOR_CODE,
122
CORBA::COMPLETED_NO),
123
SecurityLevel2::AuditDecision::_nil ());
126
SecurityLevel2::TargetCredentials_ptr
127
TAO_SecurityManager::get_target_credentials (CORBA::Object_ptr /* obj_ref */
129
ACE_THROW_SPEC ((CORBA::SystemException))
131
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (
132
CORBA::SystemException::_tao_minor_code (
133
TAO_DEFAULT_MINOR_CODE,
135
CORBA::COMPLETED_NO),
136
SecurityLevel2::TargetCredentials::_nil ());
140
TAO_SecurityManager::remove_own_credentials (
141
SecurityLevel2::Credentials_ptr creds
143
ACE_THROW_SPEC ((CORBA::SystemException))
145
ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_);
147
// Check if the given Credentials are already in the "own
148
// credentials" list.
150
const CORBA::ULong len = this->own_credentials_.length ();
152
// @@ A linear search. Yuck!
153
for (CORBA::ULong i = 0; i < len; ++i)
154
if (this->own_credentials_[i].in () == creds)
157
this->own_credentials_.length (len - 1);
160
// Avoid building a new CredentialsList. Just invalidate
161
// the Credentials in the current position in the
164
// This is has the disadvantage that it will leave "holes"
165
// in the CredentialsList.
166
this->own_credentials_[i] = SecurityLevel2::Credentials::_nil ();
172
ACE_THROW (CORBA::BAD_PARAM ());
176
TAO_SecurityManager::get_security_policy (CORBA::PolicyType /* policy_type */
178
ACE_THROW_SPEC ((CORBA::SystemException))
180
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (
181
CORBA::SystemException::_tao_minor_code (
182
TAO_DEFAULT_MINOR_CODE,
184
CORBA::COMPLETED_NO),
185
CORBA::Policy::_nil ());
189
TAO_SecurityManager::add_own_credentials (SecurityLevel2::Credentials_ptr creds
192
ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_);
194
// Check if the given Credentials are already in the "own
195
// credentials" list.
197
const CORBA::ULong len = this->own_credentials_.length ();
199
CORBA::ULong empty_slot = 0;
201
// @@ A linear search. Yuck!
202
for (CORBA::ULong i = 0; i < len; ++i)
203
if (this->own_credentials_[i].in () == creds)
204
ACE_THROW (CORBA::BAD_PARAM ());
205
else if (empty_slot == 0
206
&& CORBA::is_nil (this->own_credentials_[i]))
211
this->own_credentials_[empty_slot] =
212
SecurityLevel2::Credentials::_duplicate (creds);
216
this->own_credentials_.length (len + 1);
217
this->own_credentials_[len] =
218
SecurityLevel2::Credentials::_duplicate (creds);