Security_PolicyFactory.cpp File Reference

#include "orbsvcs/Security/Security_PolicyFactory.h"
#include "orbsvcs/Security/SL2_QOPPolicy.h"
#include "orbsvcs/Security/SL2_EstablishTrustPolicy.h"
#include "orbsvcs/Security/SL3_ContextEstablishmentPolicy.h"
#include "orbsvcs/Security/SL3_ObjectCredentialsPolicy.h"
#include "orbsvcs/SecurityLevel2C.h"
#include "orbsvcs/SecurityLevel3C.h"
#include "tao/ORB_Constants.h"

Include dependency graph for Security_PolicyFactory.cpp:

Include dependency graph

Go to the source code of this file.

Functions

 ACE_RCSID (Security, Security_PolicyFactory,"$Id:Security_PolicyFactory.cpp 77001 2007-02-12 07:54:49Z johnnyw $") TAO_BEGIN_VERSIONED_NAMESPACE_DECL CORBA


Function Documentation

ACE_RCSID Security  ,
Security_PolicyFactory  ,
"$Id:Security_PolicyFactory.cpp 77001 2007-02-12 07:54:49Z johnnyw $" 
 

Definition at line 5 of file Security_PolicyFactory.cpp.

References ACE_NEW_THROW_EX, and TAO_BEGIN_VERSIONED_NAMESPACE_DECL.

00007                : Security_PolicyFactory.cpp 77001 2007-02-12 07:54:49Z johnnyw $")
00008 
00009 #include "orbsvcs/Security/SL2_QOPPolicy.h"
00010 #include "orbsvcs/Security/SL2_EstablishTrustPolicy.h"
00011 
00012 #include "orbsvcs/Security/SL3_ContextEstablishmentPolicy.h"
00013 #include "orbsvcs/Security/SL3_ObjectCredentialsPolicy.h"
00014 
00015 #include "orbsvcs/SecurityLevel2C.h"
00016 #include "orbsvcs/SecurityLevel3C.h"
00017 
00018 #include "tao/ORB_Constants.h"
00019 
00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00021 
00022 CORBA::Policy_ptr
00023 TAO::Security::PolicyFactory::create_policy (
00024     CORBA::PolicyType type,
00025     const CORBA::Any &value)
00026 {
00027   // Not all security policies can be created using the
00028   // ORB::create_policy() mechanism.  Only those that can be created
00029   // using that mechanism are supported by this factory.
00030 
00031   if (type == ::Security::SecQOPPolicy)
00032     {
00033       ::Security::QOP qop;
00034 
00035       // Extract the desired Quality-of-Protection value from the
00036       // given Any.
00037       if (!(value >>= qop))
00038         throw CORBA::BAD_PARAM (
00039           CORBA::SystemException::_tao_minor_code (
00040             TAO::VMCID,
00041             EINVAL),
00042           CORBA::COMPLETED_NO);
00043 
00044       TAO::Security::QOPPolicy * qop_policy = 0;
00045       ACE_NEW_THROW_EX (qop_policy,
00046                         TAO::Security::QOPPolicy (qop),
00047                         CORBA::NO_MEMORY (
00048                           CORBA::SystemException::_tao_minor_code (
00049                             TAO::VMCID,
00050                             ENOMEM),
00051                           CORBA::COMPLETED_NO));
00052 
00053       return qop_policy;
00054     }
00055 
00056   else if (type == ::Security::SecEstablishTrustPolicy)
00057     {
00058       ::Security::EstablishTrust *trust = 0;
00059 
00060       // Extract the desired establishing of trust value from the
00061       // given Any.
00062       if (!(value >>= trust))
00063         throw CORBA::BAD_PARAM (
00064           CORBA::SystemException::_tao_minor_code (
00065             TAO::VMCID,
00066             EINVAL),
00067           CORBA::COMPLETED_NO);
00068 
00069       TAO::Security::EstablishTrustPolicy * trust_policy = 0;
00070       ACE_NEW_THROW_EX (trust_policy,
00071                         TAO::Security::EstablishTrustPolicy (*trust),
00072                         CORBA::NO_MEMORY (
00073                           CORBA::SystemException::_tao_minor_code (
00074                             TAO::VMCID,
00075                             ENOMEM),
00076                           CORBA::COMPLETED_NO));
00077 
00078       return trust_policy;
00079     }
00080 
00081   else if (type == SecurityLevel3::ContextEstablishmentPolicyType)
00082     {
00083       SecurityLevel3::ContextEstablishmentPolicyArgument * args = 0;
00084 
00085       // Extract the desired establishing of trust value from the
00086       // given Any.
00087       if (!(value >>= args))
00088         throw CORBA::BAD_PARAM (
00089           CORBA::SystemException::_tao_minor_code (
00090             TAO::VMCID,
00091             EINVAL),
00092           CORBA::COMPLETED_NO);
00093 
00094       TAO::SL3::ContextEstablishmentPolicy * policy = 0;
00095       ACE_NEW_THROW_EX (policy,
00096                         TAO::SL3::ContextEstablishmentPolicy (
00097                           args->creds_directive,
00098                           args->creds_list,
00099                           args->use_client_auth,
00100                           args->use_target_auth,
00101                           args->use_confidentiality,
00102                           args->use_integrity),
00103                         CORBA::NO_MEMORY (
00104                           CORBA::SystemException::_tao_minor_code (
00105                             TAO::VMCID,
00106                             ENOMEM),
00107                           CORBA::COMPLETED_NO));
00108 
00109       return policy;
00110     }
00111 
00112   else if (type == SecurityLevel3::ObjectCredentialsPolicyType)
00113     {
00114       SecurityLevel3::OwnCredentialsList * creds = 0;
00115 
00116       // Extract the desired establishing of trust value from the
00117       // given Any.
00118       if (!(value >>= creds))
00119         throw CORBA::BAD_PARAM (
00120           CORBA::SystemException::_tao_minor_code (
00121             TAO::VMCID,
00122             EINVAL),
00123           CORBA::COMPLETED_NO);
00124 
00125       TAO::SL3::ObjectCredentialsPolicy * policy = 0;
00126       ACE_NEW_THROW_EX (policy,
00127                         TAO::SL3::ObjectCredentialsPolicy (*creds),
00128                         CORBA::NO_MEMORY (
00129                           CORBA::SystemException::_tao_minor_code (
00130                             TAO::VMCID,
00131                             ENOMEM),
00132                           CORBA::COMPLETED_NO));
00133 
00134       return policy;
00135     }
00136 
00137   else if (type == ::Security::SecInvocationCredentialsPolicy
00138            || type == ::Security::SecMechanismsPolicy
00139            || type == ::Security::SecFeaturePolicy             // Deprecated.
00140            || type == ::Security::SecDelegationDirectivePolicy)
00141     throw CORBA::PolicyError (CORBA::UNSUPPORTED_POLICY);
00142   else
00143     throw CORBA::PolicyError (CORBA::BAD_POLICY_TYPE);
00144 }


Generated on Sun Jan 27 16:09:48 2008 for TAO_Security by doxygen 1.3.6