summaryrefslogtreecommitdiff
path: root/orbsvcs/orbsvcs/Security/SL3_PolicyFactory.cpp
blob: 129ce8fca7f9a639631ee0d60abb29e3a30f3326 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// $Id$

#include "orbsvcs/Security/SL3_PolicyFactory.h"
#include "orbsvcs/Security/SL3_ContextEstablishmentPolicy.h"
#include "orbsvcs/Security/SL3_ObjectCredentialsPolicy.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

CORBA::Policy_ptr
TAO::SL3::PolicyFactory::create_policy (CORBA::PolicyType type,
                                        const CORBA::Any & value)
{
  CORBA::Policy_ptr policy = CORBA::Policy_ptr ();

  if (type == SecurityLevel3::ContextEstablishmentPolicyType)
    {
      SecurityLevel3::ContextEstablishmentPolicyArgument * arg = 0;
      if (!(value >>= arg))
        throw CORBA::INTERNAL ();

      ACE_NEW_THROW_EX (policy,
                        TAO::SL3::ContextEstablishmentPolicy (
                          arg->creds_directive,
                          arg->creds_list,
                          arg->use_client_auth,
                          arg->use_target_auth,
                          arg->use_confidentiality,
                          arg->use_integrity),
                        CORBA::NO_MEMORY ());
    }
  else if (type == SecurityLevel3::ObjectCredentialsPolicyType)
    {
      SecurityLevel3::ObjectCredentialsPolicyArgument * creds = 0;
      if (!(value >>= creds))
        throw CORBA::INTERNAL ();

      ACE_NEW_THROW_EX (policy,
                        TAO::SL3::ObjectCredentialsPolicy (*creds),
                        CORBA::NO_MEMORY ());
    }
  else
    {
      throw CORBA::PolicyError (CORBA::BAD_POLICY_TYPE);
    }

  return policy;
}

TAO_END_VERSIONED_NAMESPACE_DECL