summaryrefslogtreecommitdiff
path: root/TAO/tao/PortableServer/Default_Policy_Validator.cpp
blob: b53222baed76b9936feb633bf7bbced7756f6cf5 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// @(#) $Id$

#include "Default_Policy_Validator.h"
#include "POA_Policies.h"
#include "tao/Policy_Set.h"

ACE_RCSID(tao, POA, "$Id$")


TAO_POA_Default_Policy_Validator::TAO_POA_Default_Policy_Validator (TAO_ORB_Core &orb_core)
  : TAO_POA_Policy_Validator (orb_core)
{
}

TAO_POA_Default_Policy_Validator::~TAO_POA_Default_Policy_Validator (void)
{
}

void
TAO_POA_Default_Policy_Validator::validate_impl (TAO_Policy_Set &policies,
                                                 CORBA::Environment &ACE_TRY_ENV)
{
#if (TAO_HAS_MINIMUM_POA == 0)
  CORBA::Policy_var policy =
    policies.get_cached_policy (TAO_CACHED_POLICY_SERVANT_RETENTION);
  PortableServer::ServantRetentionPolicy_var srp =
    PortableServer::ServantRetentionPolicy::_narrow (policy.in (),
                                                     ACE_TRY_ENV);
  ACE_CHECK;
  PortableServer::ServantRetentionPolicyValue servant_retention =
    srp->value (ACE_TRY_ENV);
  ACE_CHECK;

  policy = policies.get_cached_policy (TAO_CACHED_POLICY_REQUEST_PROCESSING);
  PortableServer::RequestProcessingPolicy_var rpp =
    PortableServer::RequestProcessingPolicy::_narrow (policy.in (),
                                                      ACE_TRY_ENV);
  ACE_CHECK;
  PortableServer::RequestProcessingPolicyValue request_processing =
    rpp->value (ACE_TRY_ENV);
  ACE_CHECK;

  // The NON_RETAIN policy requires either the USE_DEFAULT_SERVANT or
  // USE_SERVANT_MANAGER policies.
  if (servant_retention == PortableServer::NON_RETAIN)
    if (request_processing != PortableServer::USE_SERVANT_MANAGER &&
        request_processing  != PortableServer::USE_DEFAULT_SERVANT)
      ACE_THROW (PortableServer::POA::InvalidPolicy ());

  // USE_ACTIVE_OBJECT_MAP_ONLY requires the RETAIN policy.
  if (request_processing == PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY)
    if (servant_retention != PortableServer::RETAIN)
      ACE_THROW (PortableServer::POA::InvalidPolicy ());


  policy = policies.get_cached_policy (TAO_CACHED_POLICY_ID_UNIQUENESS);
  PortableServer::IdUniquenessPolicy_var iup =
    PortableServer::IdUniquenessPolicy::_narrow (policy.in (),
                                                 ACE_TRY_ENV);
  ACE_CHECK;
  PortableServer::IdUniquenessPolicyValue id_uniqueness =
    iup->value (ACE_TRY_ENV);
  ACE_CHECK;


  policy = policies.get_cached_policy (TAO_CACHED_POLICY_IMPLICIT_ACTIVATION);
  PortableServer::ImplicitActivationPolicy_var iap =
    PortableServer::ImplicitActivationPolicy::_narrow (policy.in (),
                                                       ACE_TRY_ENV);
  ACE_CHECK;
  PortableServer::ImplicitActivationPolicyValue implicit_activation =
    iap->value (ACE_TRY_ENV);
  ACE_CHECK;

  policy = policies.get_cached_policy (TAO_CACHED_POLICY_ID_ASSIGNMENT);
  PortableServer::IdAssignmentPolicy_var idap =
    PortableServer::IdAssignmentPolicy::_narrow (policy.in (),
                                                 ACE_TRY_ENV);
  ACE_CHECK;
  PortableServer::IdAssignmentPolicyValue id_assignment =
    idap->value (ACE_TRY_ENV);
  ACE_CHECK;


  // USE_DEFAULT_SERVANT requires the MULTIPLE_ID policy.
  if (request_processing == PortableServer::USE_DEFAULT_SERVANT)
    if (id_uniqueness != PortableServer::MULTIPLE_ID)
      ACE_THROW (PortableServer::POA::InvalidPolicy ());

  // IMPLICIT_ACTIVATION requires the SYSTEM_ID and RETAIN policies.
  if (implicit_activation == PortableServer::IMPLICIT_ACTIVATION)
    if (servant_retention != PortableServer::RETAIN ||
        id_assignment != PortableServer::SYSTEM_ID)
      ACE_THROW (PortableServer::POA::InvalidPolicy ());
#else /* TAO_HAS_MINIMUM_POA == 0 */
  ACE_UNUSED_ARG (policies);
  ACE_UNUSED_ARG (ACE_TRY_ENV); // FUZZ: ignore check_for_ace_check
#endif /* TAO_HAS_MINIMUM_POA == 0 */
}


CORBA::Boolean
TAO_POA_Default_Policy_Validator::legal_policy_impl (CORBA::PolicyType type)
{
  return (type == PortableServer::THREAD_POLICY_ID ||
          type == PortableServer::LIFESPAN_POLICY_ID ||
          type == PortableServer::ID_UNIQUENESS_POLICY_ID ||
          type == PortableServer::ID_ASSIGNMENT_POLICY_ID ||
          type == PortableServer::IMPLICIT_ACTIVATION_POLICY_ID ||
          type == PortableServer::SERVANT_RETENTION_POLICY_ID ||
          type == PortableServer::REQUEST_PROCESSING_POLICY_ID);
}

void
TAO_POA_Default_Policy_Validator::merge_policies_impl (TAO_Policy_Set &,
                                                       CORBA::Environment &)
{
}