Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_authorization.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework Authorization
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 
16 
17 /* Declares and rti/inf defines for interface afw_authorization_handler */
18 #define AFW_IMPLEMENTATION_ID "authorizationHandler"
20 
21 static const afw_utf8_t
22 impl_s_a_notApplicable_policy_id =
23 AFW_UTF8_LITERAL("/afw/_AdaptivePolicyId_/notApplicable");
24 
25 static const afw_value_string_t
26 impl_authorization_decision_id_action_id_control = {
28  AFW_UTF8_LITERAL("control")
29 };
30 
33 (const afw_value_t *)& impl_authorization_decision_id_action_id_control;
34 
35 
36 static const afw_value_string_t
37 impl_authorization_decision_id_action_id_create = {
39  AFW_UTF8_LITERAL("create")
40 };
41 
44 (const afw_value_t *)& impl_authorization_decision_id_action_id_create;
45 
46 
47 static const afw_value_string_t
48 impl_authorization_decision_id_action_id_delete = {
50  AFW_UTF8_LITERAL("delete")
51 };
52 
55 (const afw_value_t *)& impl_authorization_decision_id_action_id_delete;
56 
57 
58 static const afw_value_string_t
59 impl_authorization_decision_id_action_id_modify = {
61  AFW_UTF8_LITERAL("modify")
62 };
63 
66 (const afw_value_t *)& impl_authorization_decision_id_action_id_modify;
67 
68 
69 static const afw_value_string_t
70 impl_authorization_decision_id_action_id_query = {
72  AFW_UTF8_LITERAL("query")
73 };
74 
77 (const afw_value_t *)& impl_authorization_decision_id_action_id_query;
78 
79 static const afw_value_string_t
80 impl_authorization_decision_id_action_id_read = {
82  AFW_UTF8_LITERAL("read")
83 };
84 
87 (const afw_value_t *)& impl_authorization_decision_id_action_id_read;
88 
89 
90 
91 static const afw_value_string_t
92 impl_authorization_decision_id_deny_value = {
94  AFW_UTF8_LITERAL("deny")
95 };
96 
99 (const afw_value_t *)& impl_authorization_decision_id_deny_value;
100 
101 
102 static const afw_value_string_t
103 impl_authorization_decision_id_indeterminate_value = {
105  AFW_UTF8_LITERAL("indeterminate")
106 };
107 
110 (const afw_value_t *)& impl_authorization_decision_id_indeterminate_value;
111 
112 
113 static const afw_value_string_t
114 impl_authorization_decision_id_indeterminateD_value = {
116  AFW_UTF8_LITERAL("indeterminateD")
117 };
118 
121 (const afw_value_t *)& impl_authorization_decision_id_indeterminateD_value;
122 
123 
124 static const afw_value_string_t
125 impl_authorization_decision_id_indeterminateDP_value = {
127  AFW_UTF8_LITERAL("indeterminateDP")
128 };
129 
132 (const afw_value_t *)& impl_authorization_decision_id_indeterminateDP_value;
133 
134 
135 static const afw_value_string_t
136 impl_authorization_decision_id_indeterminateP_value = {
138  AFW_UTF8_LITERAL("indeterminateP")
139 };
140 
143 (const afw_value_t *)& impl_authorization_decision_id_indeterminateP_value;
144 
145 
146 static const afw_value_string_t
147 impl_authorization_decision_id_notApplicable_value = {
149  AFW_UTF8_LITERAL("notApplicable")
150 };
151 
154 (const afw_value_t *)& impl_authorization_decision_id_notApplicable_value;
155 
156 
157 static const afw_value_string_t
158 impl_authorization_decision_id_permit_value = {
160  AFW_UTF8_LITERAL("permit")
161 };
162 
165 (const afw_value_t *)&impl_authorization_decision_id_permit_value;
166 
167 
168 
169 static const afw_value_string_t
170 impl_authorization_mode_id_core_value = {
172  AFW_UTF8_LITERAL("core")
173 };
174 
177 (const afw_value_t *)& impl_authorization_mode_id_core_value;
178 
179 
180 static const afw_value_string_t
181 impl_authorization_mode_id_intermediate_value = {
183  AFW_UTF8_LITERAL("intermediate")
184 };
185 
188 (const afw_value_t *)& impl_authorization_mode_id_intermediate_value;
189 
190 
191 static const afw_value_string_t
192 impl_authorization_mode_id_user_value = {
194  AFW_UTF8_LITERAL("user")
195 };
196 
199 (const afw_value_t *)& impl_authorization_mode_id_user_value;
200 
201 
202 
203 static const afw_value_t *
204 impl_requestId_cb(
206  const afw_utf8_t *name,
207  afw_xctx_t *xctx)
208 {
210 
211  return ctx->requestId;
212 }
213 
214 static const
216 impl_current_variable_meta_requestId =
217 {
218  &afw_s_requestId,
221  "Request Id"
222 };
223 
224 static const
226 impl_current_variable_requestId = {
227  &impl_current_variable_meta_requestId,
228  "The id of the authorization check being processed.",
229  impl_requestId_cb,
230  1
231 };
232 
233 
234 
235 static const afw_value_t *
236 impl_resourceId_cb(
238  const afw_utf8_t *name,
239  afw_xctx_t *xctx)
240 {
242 
243  return ctx->resourceId;
244 }
245 
246 static const
248 impl_current_variable_meta_resourceId =
249 {
250  &afw_s_resourceId,
253  "Resource Id"
254 };
255 
256 static const
258 impl_current_variable_resourceId = {
259  &impl_current_variable_meta_resourceId,
260  "The id of the resource being accessed.",
261  impl_resourceId_cb,
262  1
263 };
264 
265 
266 
267 static const afw_value_t *
268 impl_object_cb(
270  const afw_utf8_t *name,
271  afw_xctx_t *xctx)
272 {
274 
275  return ctx->object;
276 }
277 
278 static const
280 impl_current_variable_meta_object =
281 {
282  &afw_s_object,
285  "Object"
286 };
287 
288 static const
290 impl_current_variable_object = {
291  &impl_current_variable_meta_object,
292  "The object being accessed.",
293  impl_object_cb,
294  1
295 };
296 
297 
298 
299 static const afw_value_t *
300 impl_actionId_cb(
302  const afw_utf8_t *name,
303  afw_xctx_t *xctx)
304 {
306 
307  return ctx->actionId;
308 }
309 
310 static const
312 impl_current_variable_meta_actionId =
313 {
314  &afw_s_actionId,
317  "Action Id"
318 };
319 
320 static const
322 impl_current_variable_actionId = {
323  &impl_current_variable_meta_actionId,
324  "The id of the action being performed on the resource.",
325  impl_actionId_cb,
326  1
327 };
328 
329 
331 impl_context_current_runtime_ctx[] = {
332  &impl_current_variable_requestId,
333  &impl_current_variable_resourceId,
334  &impl_current_variable_object,
335  &impl_current_variable_actionId,
336  NULL
337 };
338 
339 
341 afw_authorization_internal_set_control(
342  const afw_object_t *object,
343  afw_xctx_t *xctx)
344 {
346  const afw_pool_t *p = xctx->env->p;
347  const afw_object_t *not_applicable_object;
348  const afw_list_t *list;
349  afw_boolean_t found;
350  afw_boolean_t deny_if_not_applicable;
351 
352  /* Can only call once. */
353  if (xctx->env->authorization_control) {
354  AFW_THROW_ERROR_Z(general,
355  "afw_authorization_internal_set_control() already called",
356  xctx);
357  }
358 
359  /* Allocate self. */
360  deny_if_not_applicable = false;
362  ((afw_environment_t *)xctx->env)->authorization_control = self;
363 
364  /* Set control from config object if, present. */
365  if (object) {
366  self->core_authorization_check =
368  &afw_s_coreAuthorizationCheck,
369  &afw_s_internal, NULL, p, xctx);
370 
371  self->initial_authorization_check =
373  &afw_s_initialAuthorizationCheck,
374  &afw_s_internal, NULL, p, xctx);
375 
376  self->check_intermediate_mode = afw_object_old_get_property_as_boolean(
377  object, &afw_s_checkIntermediateMode, &found, xctx);
378 
379  deny_if_not_applicable = afw_object_old_get_property_as_boolean(
380  object, &afw_s_denyIfNotApplicable, &found, xctx);
381  }
382 
383  /* Set not_applicable_result */
384  not_applicable_object = afw_object_create(p, xctx);
385  afw_object_meta_set_object_type_id(not_applicable_object,
386  &afw_s__AdaptiveAuthorizationResult_, xctx);
387  afw_object_set_property(not_applicable_object, &afw_s_decisionId,
388  ((deny_if_not_applicable)
391  xctx);
392  self->not_applicable_decision_id =
393  (deny_if_not_applicable)
394  ? &afw_s_deny
395  : &afw_s_permit;
397  &impl_s_a_notApplicable_policy_id,
398  false, afw_data_type_anyURI, 1, p, xctx);
399  afw_object_set_property_as_list(not_applicable_object,
400  &afw_s_applicablePolicies, list, xctx);
401  self->not_applicable_result = afw_value_create_object(not_applicable_object, p, xctx);
402 
403  /* Return self. */
404  return self;
405 }
406 
407 
408 /* Perform authorization check on an object. */
409 AFW_DEFINE(const afw_value_t *)
411  afw_boolean_t enforce,
412  const afw_value_t *request_id_value,
413  const afw_value_t *resource_id_value,
414  const afw_value_t *object_value,
415  const afw_value_t *action_id_value,
416  const afw_pool_t *p,
417  afw_xctx_t *xctx)
418 {
419  int top;
420  const afw_value_t *result;
421  const afw_value_t *result2;
422  const afw_utf8_t *request_id;
423  const afw_utf8_t *resource_id;
424  const afw_utf8_t *action_id;
425  const afw_utf8_t *decision_id;
426  const afw_utf8_t *decision_id2;
427  const afw_authorization_control_t *ctl;
428  const afw_utf8_t *s;
429  const afw_object_t *obj;
430  const afw_value_t *check;
433  const afw_authorization_handler_t *ah;
434  const char * property_name;
435  const afw_utf8_t *current_decider;
436  const afw_utf8_t *final_decider;
437  afw_boolean_t final_result;
438 
439  if (!request_id_value) {
440  request_id_value = afw_uuid_create_string(p, xctx);
441  }
442 
443  ctx.actionId = action_id_value;
444  action_id = afw_value_as_string(action_id_value, xctx);
445  request_id = afw_value_as_string(request_id_value, xctx);
446  final_result = false;
447  result = NULL;
448  ctx.object = object_value;
449  ctx.requestId = request_id_value;
450  ctx.resourceId = resource_id_value;
451  resource_id = afw_value_as_string(resource_id_value, xctx);
452  current_decider = &afw_s_none;
453  final_decider = &afw_s_none;
454 
455  /*
456  * Bypass checks if any of the following:
457  * . No authorization control
458  * . No core authorization check and running in core mode
459  * . Not checking intermediate mode and running in intermediate mode.
460  */
461  ctl = xctx->env->authorization_control;
462  if (!ctl)
463  {
464  afw_trace_fz(1, xctx->env->flag_index_trace_authorization_check_bypass,
465  NULL, xctx,
466  "[Authorization check requestId %" AFW_UTF8_FMT
467  " mode %" AFW_UTF8_FMT
468  " actionId %" AFW_UTF8_FMT
469  " resourceId %" AFW_UTF8_FMT
470  "] call bypassed because there is no authorizationControl",
471  AFW_UTF8_FMT_ARG(request_id),
472  AFW_UTF8_FMT_ARG(&((const afw_value_string_t *)xctx->mode)->internal),
473  AFW_UTF8_FMT_ARG(action_id),
474  AFW_UTF8_FMT_ARG(resource_id));
475  return NULL;
476  }
477 
478  if (xctx->mode == afw_authorization_mode_id_core_value &&
480  {
481  afw_trace_fz(1, xctx->env->flag_index_trace_authorization_check_bypass,
482  NULL, xctx,
483  "[Authorization check requestId %" AFW_UTF8_FMT
484  " mode %" AFW_UTF8_FMT
485  " actionId %" AFW_UTF8_FMT
486  " resourceId %" AFW_UTF8_FMT
487  "] call bypassed because mode is core and there is no "
488  "coreAuthorizationCheck",
489  AFW_UTF8_FMT_ARG(request_id),
490  AFW_UTF8_FMT_ARG(&((const afw_value_string_t *)xctx->mode)->internal),
491  AFW_UTF8_FMT_ARG(action_id),
492  AFW_UTF8_FMT_ARG(resource_id));
493  return NULL;
494  }
495 
496  else if (xctx->mode == afw_authorization_mode_id_intermediate_value &&
498  {
499  afw_trace_fz(1, xctx->env->flag_index_trace_authorization_check_bypass,
500  NULL, xctx,
501  "[Authorization check requestId %" AFW_UTF8_FMT
502  " mode %" AFW_UTF8_FMT
503  " actionId %" AFW_UTF8_FMT
504  " resourceId %" AFW_UTF8_FMT
505  "] call bypassed because mode is intermediate and "
506  "checkIntermediateMode is false",
507  AFW_UTF8_FMT_ARG(request_id),
508  AFW_UTF8_FMT_ARG(&((const afw_value_string_t *)xctx->mode)->internal),
509  AFW_UTF8_FMT_ARG(action_id),
510  AFW_UTF8_FMT_ARG(resource_id));
511  return NULL;
512  }
513 
515  ah = NULL;
516  AFW_TRY{
517  afw_context_push_cb_variables(&afw_s_current,
518  impl_context_current_runtime_ctx, &ctx,
519  p, xctx);
520 
521  afw_trace_fz(1, xctx->env->flag_index_trace_authorization_check,
522  NULL, xctx,
523  "[Authorization check requestId %" AFW_UTF8_FMT
524  " mode %" AFW_UTF8_FMT
525  " actionId %" AFW_UTF8_FMT
526  " resourceId %" AFW_UTF8_FMT
527  "] called",
528  AFW_UTF8_FMT_ARG(request_id),
529  AFW_UTF8_FMT_ARG(&((const afw_value_string_t *)xctx->mode)->internal),
530  AFW_UTF8_FMT_ARG(action_id),
531  AFW_UTF8_FMT_ARG(resource_id));
532 
533  if (afw_flag_is_active(
534  xctx->env->flag_index_trace_authorization_check_detail, xctx))
535  {
536  /* Add additional tracing. */
537  }
538 
539  /* Do core mode authorization check. */
540  check = NULL;
541  if (xctx->mode == afw_authorization_mode_id_core_value) {
542  check = ctl->core_authorization_check;
543  property_name = "coreAuthorizationCheck";
544  current_decider = &afw_s_coreAuthorizationCheck;
545  final_decider = &afw_s_coreAuthorizationCheck;
546  }
547  else if (ctl->initial_authorization_check) {
548  check = ctl->initial_authorization_check;
549  property_name = "initialAuthorizationCheck";
550  current_decider = &afw_s_initialAuthorizationCheck;
551  final_decider = &afw_s_initialAuthorizationCheck;
552  }
553 
554  /* Do check. */
555  if (check) {
556  result = afw_value_evaluate(check, p, xctx);
557 
558  if (!result || afw_value_is_null(result)) {
559  decision_id = &afw_s_notApplicable;
560  }
561  else {
562  if (!afw_value_is_object(result)) {
563  AFW_THROW_ERROR_FZ(general, xctx,
564  "applicationControl.%s must return an "
565  "_AdaptiveAuthorizationDecision_ object", property_name);
566  }
568  ((const afw_value_object_t *)result)->internal,
569  &afw_s_decisionId, xctx);
570  if (!decision_id) {
571  AFW_THROW_ERROR_FZ(general, xctx,
572  "applicationControl.%s returned an "
573  "_AdaptiveAuthorizationDecision_ object with missing "
574  "decisionId property", property_name);
575  }
576  }
577 
578  if (afw_utf8_equal(decision_id, &afw_s_permit)) {
579  final_result = true;
580  }
581  else if (afw_utf8_equal(decision_id, &afw_s_deny)) {
582  final_result = true;
583  }
584  else if (afw_utf8_equal(decision_id, &afw_s_notApplicable)) {
585  final_result = false;
586  }
587  else {
588  AFW_THROW_ERROR_FZ(general, xctx,
589  "applicationControl.%s returned an "
590  "_AdaptiveAuthorizationDecision_ object with invalid "
591  "decisionId %" AFW_UTF8_FMT,
592  property_name, AFW_UTF8_FMT_ARG(decision_id));
593  }
594  }
595 
596  /* Check with authorization handlers. */
597  if (!final_result && xctx->mode != afw_authorization_mode_id_core_value) {
598  for (decision_id = &afw_s_notApplicable,
599  result = NULL,
600  anchor = xctx->env->authorization_control->first_anchor;
601  anchor;
602  anchor = anchor->next_anchor)
603  {
604  ah = anchor->authorization_handler;
605  if (ah) {
606  current_decider = &ah->authorization_handler_id;
607  if (afw_utf8_equal(decision_id, &afw_s_permit)) {
608  if (!ah->allow_permit_override) {
609  afw_trace_fz(1, ah->trace_flag_index,
610  NULL, xctx,
611  "[Authorization check requestId %" AFW_UTF8_FMT
612  " mode %" AFW_UTF8_FMT
613  " actionId %" AFW_UTF8_FMT
614  " resourceId %" AFW_UTF8_FMT
615  " authorizationHandler %" AFW_UTF8_FMT
616  "] skipped because of a previous permit decision",
617  AFW_UTF8_FMT_ARG(request_id),
619  &((const afw_value_string_t *)xctx->mode)->internal),
620  AFW_UTF8_FMT_ARG(action_id),
621  AFW_UTF8_FMT_ARG(resource_id),
622  AFW_UTF8_FMT_ARG(&ah->authorization_handler_id));
623  continue;
624  }
625  }
626  else if (afw_utf8_equal(decision_id, &afw_s_deny)) {
627  if (!ah->allow_deny_override) {
628  afw_trace_fz(1, ah->trace_flag_index,
629  NULL, xctx,
630  "[Authorization check requestId %" AFW_UTF8_FMT
631  " mode %" AFW_UTF8_FMT
632  " actionId %" AFW_UTF8_FMT
633  " resourceId %" AFW_UTF8_FMT
634  " authorizationHandler %" AFW_UTF8_FMT
635  "] skipped because of a previous deny decision",
636  AFW_UTF8_FMT_ARG(request_id),
638  &((const afw_value_string_t *)xctx->mode)->internal),
639  AFW_UTF8_FMT_ARG(action_id),
640  AFW_UTF8_FMT_ARG(resource_id),
641  AFW_UTF8_FMT_ARG(&ah->authorization_handler_id));
642  continue;
643  }
644  }
645  result2 = afw_authorization_handler_check(ah,
646  resource_id_value, object_value, action_id_value, p, xctx);
647  if (result2) {
649  ((const afw_value_object_t *)result2)->internal,
650  &afw_s_decisionId, xctx);
651  if (afw_utf8_equal(decision_id2, &afw_s_permit) ||
652  afw_utf8_equal(decision_id2, &afw_s_deny)) {
653  result = result2;
654  decision_id = decision_id2;
655  final_result = true;
656  final_decider = &ah->authorization_handler_id;
657  }
658  afw_trace_fz(1, ah->trace_flag_index,
659  NULL, xctx,
660  "[Authorization check requestId %" AFW_UTF8_FMT
661  " mode %" AFW_UTF8_FMT
662  " actionId %" AFW_UTF8_FMT
663  " resourceId %" AFW_UTF8_FMT
664  " authorizationHandler %" AFW_UTF8_FMT
665  "] handler decision is %" AFW_UTF8_FMT,
666  AFW_UTF8_FMT_ARG(request_id),
668  &((const afw_value_string_t *)xctx->mode)->internal),
669  AFW_UTF8_FMT_ARG(action_id),
670  AFW_UTF8_FMT_ARG(resource_id),
671  AFW_UTF8_FMT_ARG(&ah->authorization_handler_id),
672  AFW_UTF8_FMT_ARG(decision_id));
673 
675  }
676  }
677  }
678  }
679 
680  /* If not applicable, permit/deny based on deny_if_not_applicable*/
681  if (!final_result) {
682  current_decider = &afw_s_denyIfNotApplicable;
683  final_decider = &afw_s_denyIfNotApplicable;
684  result = ctl->not_applicable_result;
685  decision_id = ctl->not_applicable_decision_id;
686  }
687 
688  /* If permit at this point, handle for any obligations. */
689 
690  }
692  obj = afw_object_create(p, xctx);
694  &afw_s__AdaptiveAuthorizationResult_, xctx);
695  afw_object_set_property(obj, &afw_s_decisionId,
697  xctx);
698  result = afw_value_create_object(obj, p, xctx);
699  decision_id = &afw_s_indeterminate;
700  final_decider = current_decider;
701 
702  if (afw_flag_is_active(
703  xctx->env->flag_index_trace_authorization_decision, xctx))
704  {
705  s = afw_error_to_utf8(AFW_ERROR_THROWN, p, xctx);
706  afw_trace_fz(1, xctx->env->flag_index_trace_authorization_decision_detail,
707  NULL, xctx,
708  "[Authorization check requestId %" AFW_UTF8_FMT
709  " mode %" AFW_UTF8_FMT
710  " actionId %" AFW_UTF8_FMT
711  " resourceId %" AFW_UTF8_FMT
712  "] detail for indeterminate produced by %" AFW_UTF8_FMT
713  ":\n\n%" AFW_UTF8_FMT,
714  AFW_UTF8_FMT_ARG(request_id),
716  &((const afw_value_string_t *)xctx->mode)->internal),
717  AFW_UTF8_FMT_ARG(action_id),
718  AFW_UTF8_FMT_ARG(resource_id),
719  AFW_UTF8_FMT_ARG(current_decider),
720  AFW_UTF8_FMT_ARG(s));
721  }
722  }
723  AFW_FINALLY{
725  }
726  AFW_ENDTRY;
727 
728  afw_trace_fz(1, xctx->env->flag_index_trace_authorization_decision,
729  NULL, xctx,
730  "[Authorization check requestId %" AFW_UTF8_FMT
731  " mode %" AFW_UTF8_FMT
732  " actionId %" AFW_UTF8_FMT
733  " resourceId %" AFW_UTF8_FMT
734  "] final decision is %" AFW_UTF8_FMT
735  " made by %" AFW_UTF8_FMT,
736  AFW_UTF8_FMT_ARG(request_id),
738  &((const afw_value_string_t *)xctx->mode)->internal),
739  AFW_UTF8_FMT_ARG(action_id),
740  AFW_UTF8_FMT_ARG(resource_id),
741  AFW_UTF8_FMT_ARG(decision_id),
742  AFW_UTF8_FMT_ARG(final_decider));
743 
744  if (afw_flag_is_active(
745  xctx->env->flag_index_trace_authorization_decision_detail, xctx))
746  {
747  /* Add additional tracing. */
748  }
749 
750  if (enforce) {
751  if (!afw_utf8_equal(decision_id, &afw_s_permit)) {
752  s = afw_value_as_string(resource_id_value, xctx);
753  AFW_THROW_ERROR_FZ(denied, xctx,
754  "Access to %" AFW_UTF8_FMT " is not permitted",
755  AFW_UTF8_FMT_ARG(s));
756  }
757  }
758 
759  return result;
760 }
761 
762 
763 
764 /* actionId */
765 /*FIXME
766 static const afw_value_t *
767 impl_actionId_cb(
768  const afw_xctx_qualifier_stack_entry_t *entry,
769  const afw_utf8_t *name,
770  afw_xctx_t *xctx)
771 {
772  impl_request_context_t *ctx = entry->data;
773 
774  if (!ctx->action_id) {
775  return NULL;
776  }
777 
778  if (!ctx->action_id_value.inf && ctx->action_id) {
779  ctx->action_id_value.inf = &afw_value_evaluated_string_inf;
780  afw_memory_copy(&ctx->action_id_value.internal, ctx->action_id);
781  }
782  return (const afw_value_t *)& ctx->action_id_value;
783 }
784 
785 static const
786 afw_context_cb_variable_meta_t
787 impl_actionId_meta =
788 {
789  &afw_s_actionId,
790  &afw_value_evaluated_string_inf,
791  &afw_data_type_string_direct,
792  "Action Id"
793 };
794 
795 
796 static const
797 afw_context_cb_variable_t
798 impl_action_variable_actionId = {
799  &impl_actionId_meta,
800  "The actionId for authorization check.",
801  impl_actionId_cb,
802  1
803 };
804 
805 static const afw_context_cb_variable_t *
806 impl_action_variables[] = {
807  &impl_action_variable_actionId,
808  NULL
809 };
810 
811 
812  */
813 
814 
815 /* Internal function called to register core authorization. */
816 void
817 afw_authorization_internal_register(
818  afw_xctx_t *xctx)
819 {
820  afw_environment_t *env = (afw_environment_t *)xctx->env;
821 
822  /* Register service and conf type authorization_handler. */
823  afw_authorization_internal_register_service_and_conf(xctx);
824 
825  /* Register authorization handler type script. */
826  afw_authorization_internal_register_handler_type_script(xctx);
827 
828  /* Register context handlers */
830  &afw_s_authorizationCheck,
831  &afw_s_current,
832  "Qualified variables available during authorizationCheck processing",
833  &impl_context_current_runtime_ctx[0],
834  1, xctx);
835 
836 
837  /* Register flag trace:authorization:detail */
839  &afw_s_a_flag_trace_authorization_detail,
840  &afw_s_a_flag_trace_authorization_detail_brief,
841  &afw_s_a_flag_trace_authorization_detail_description,
842  &afw_s_a_flag_trace_detail,
843  xctx);
844 
845  /* Register flag trace:authorization */
847  &afw_s_a_flag_trace_authorization,
848  &afw_s_a_flag_trace_authorization_brief,
849  &afw_s_a_flag_trace_authorization_description,
850  &afw_s_a_flag_trace,
851  xctx);
853  &afw_s_a_flag_trace_authorization,
854  &afw_s_a_flag_trace_authorization_detail,
855  xctx);
856 
857  /* Register flag trace:authorization:check:bypass */
859  &afw_s_a_flag_trace_authorization_check_bypass,
860  &afw_s_a_flag_trace_authorization_check_bypass_brief,
861  &afw_s_a_flag_trace_authorization_check_bypass_description,
862  &afw_s_a_flag_trace_authorization,
863  xctx);
866  &afw_s_a_flag_trace_authorization_check_bypass,
867  xctx)->flag_index;
868 
869  /* Register flag trace:authorization:check:detail */
871  &afw_s_a_flag_trace_authorization_check_detail,
872  &afw_s_a_flag_trace_authorization_check_detail_brief,
873  &afw_s_a_flag_trace_authorization_check_detail_description,
874  &afw_s_a_flag_trace_authorization_detail,
875  xctx);
878  &afw_s_a_flag_trace_authorization_check_detail,
879  xctx)->flag_index;
880 
881  /* Register flag trace:authorization:check */
883  &afw_s_a_flag_trace_authorization_check,
884  &afw_s_a_flag_trace_authorization_check_brief,
885  &afw_s_a_flag_trace_authorization_check_description,
886  &afw_s_a_flag_trace_authorization,
887  xctx);
890  &afw_s_a_flag_trace_authorization_check,
891  xctx)->flag_index;
893  &afw_s_a_flag_trace_authorization_check,
894  &afw_s_a_flag_trace_authorization_check_detail,
895  xctx);
896 
897  /* Register flag trace:authorization:decision:detail */
899  &afw_s_a_flag_trace_authorization_decision_detail,
900  &afw_s_a_flag_trace_authorization_decision_detail_brief,
901  &afw_s_a_flag_trace_authorization_decision_detail_description,
902  &afw_s_a_flag_trace_authorization_detail,
903  xctx);
906  &afw_s_a_flag_trace_authorization_decision_detail,
907  xctx)->flag_index;
908 
909  /* Register flag trace:authorization:decision */
911  &afw_s_a_flag_trace_authorization_decision,
912  &afw_s_a_flag_trace_authorization_decision_brief,
913  &afw_s_a_flag_trace_authorization_decision_description,
914  &afw_s_a_flag_trace_authorization,
915  xctx);
918  &afw_s_a_flag_trace_authorization_decision,
919  xctx)->flag_index;
921  &afw_s_a_flag_trace_authorization_decision,
922  &afw_s_a_flag_trace_authorization_decision_detail,
923  xctx);
924 
925 }
926 
927 
928 /*
929  * Set instance to the active one for its id. Instance can be NULL to stop
930  * new access to this id.
931  */
932 static void
933 impl_set_instance_active(
934  const afw_utf8_t *authorization_handler_id,
935  const afw_authorization_handler_t *authorization_handler,
936  afw_xctx_t *xctx)
937 {
943  afw_integer_t processing_order;
944 
945  stopping = NULL;
947 
948  /*
949  * Get anchor and control. If not already registered, make a new one
950  * in env->p and register it.
951  */
952  control = (afw_authorization_control_t * )xctx->env->authorization_control;
953  if (!control) {
954  control = afw_authorization_internal_set_control(NULL, xctx);
955  }
958  authorization_handler_id, xctx);
959  if (!anchor) {
960  if (!authorization_handler) {
961  AFW_THROW_ERROR_Z(general, "Internal error", xctx);
962  }
963  anchor = afw_pool_calloc_type(
964  xctx->env->p, afw_authorization_handler_id_anchor_t, xctx);
966  authorization_handler_id,
967  xctx->env->p, xctx);
968  anchor->service_id = afw_utf8_clone(
969  authorization_handler->service_id,
970  xctx->env->p, xctx);
972  anchor->authorization_handler_id, anchor, xctx);
973  }
974 
975  /*
976  * If there is already an active instance, make a copy of active
977  * anchor in the active instance's pool so it will go away when
978  * instance is released put it in stopping chain.
979  *
980  * Removed anchor from active list. It will be added back later
981  * if there is an authorization handler.
982  */
983  else {
984  for (prev = NULL,
986  control->first_anchor;
987  curr;
988  prev = curr,
990  curr->next_anchor)
991  {
992  if (afw_utf8_equal(
993  curr->authorization_handler_id, authorization_handler_id))
994  {
995  if (prev) {
996  prev->next_anchor = curr->next_anchor;
997  }
998  else {
999  control->first_anchor = curr->next_anchor;
1000  }
1001  curr->next_anchor = NULL;
1002  break;
1003  }
1004  }
1005  if (!authorization_handler) {
1006  stopping = afw_pool_calloc_type(anchor->authorization_handler->p,
1008  afw_memory_copy(stopping, anchor);
1009  anchor->stopping = stopping;
1010  }
1011  }
1012 
1013  /* If starting, link into correct place in active anchors. */
1014  anchor->authorization_handler = authorization_handler;
1015  if (authorization_handler) {
1016  anchor->properties = authorization_handler->properties;
1017  anchor->reference_count = 1;
1018  for (prev = NULL,
1020  control->first_anchor;
1021  curr;
1022  prev = curr,
1024  curr->next_anchor)
1025  {
1026  if (curr->authorization_handler->priority >
1027  anchor->authorization_handler->priority)
1028  {
1029  anchor->next_anchor = curr;
1030  if (prev) {
1031  prev->next_anchor = anchor;
1032  }
1033  else {
1034  control->first_anchor = anchor;
1035  }
1036  break;
1037  }
1038  }
1039  if (!curr) {
1040  if (prev) {
1041  prev->next_anchor = anchor;
1042  }
1043  else {
1044  control->first_anchor = anchor;
1045  }
1046  }
1047  }
1048 
1049  /* If stopping, clear some fields in anchor. */
1050  else {
1051  anchor->properties = NULL;
1052  anchor->reference_count = 0;
1053  anchor->processing_order = 0;
1054  }
1055 
1056  /* Update processing order. */
1057  for (processing_order = 1,
1059  control->first_anchor;
1060  curr;
1061  processing_order++,
1063  curr->next_anchor)
1064  {
1065  curr->processing_order = processing_order;
1066  }
1067  }
1068 
1070 
1071  /* If there was a previously active authorizationHandler, release it. */
1072  if (stopping) {
1074  stopping->authorization_handler, xctx);
1075  }
1076 }
1077 
1078 
1079 
1080 static const afw_authorization_handler_t *
1081 impl_get_reference(
1082  const afw_utf8_t *authorization_handler_id,
1083  afw_xctx_t *xctx)
1084 {
1086  const afw_authorization_handler_t *instance;
1087 
1089 
1090  instance = NULL;
1093  authorization_handler_id, xctx);
1094  if (anchor) {
1095  instance = anchor->authorization_handler;
1096  if (instance) {
1097  anchor->reference_count++;
1098  }
1099  }
1100  }
1101 
1103 
1104  return instance;
1105 }
1106 
1107 
1108 
1109 /* Get reference to authorization handler */
1112  const afw_utf8_t *authorization_handler_id,
1113  afw_xctx_t *xctx)
1114 {
1115  const afw_authorization_handler_t *instance;
1116  const afw_utf8_t *service_id;
1117 
1118  instance = impl_get_reference(authorization_handler_id, xctx);
1119 
1120  /* If authorizationHandler is not registered, try starting it. */
1121  if (!instance) {
1122  service_id = afw_utf8_concat(xctx->p, xctx,
1123  &afw_s_authorizationHandler,
1124  &afw_s_a_dash, authorization_handler_id, NULL);
1125  afw_service_start(service_id, false, xctx);
1126  instance = impl_get_reference(authorization_handler_id, xctx);
1127  if (!instance) {
1128  AFW_THROW_ERROR_FZ(general, xctx,
1129  "Authorization Handler %" AFW_UTF8_FMT
1130  " is not available",
1131  AFW_UTF8_FMT_ARG(authorization_handler_id));
1132  }
1133  }
1134 
1135  return instance;
1136 }
1137 
1138 
1139 AFW_DEFINE(void)
1141  const afw_authorization_handler_t *instance,
1142  afw_xctx_t *xctx)
1143 {
1145  afw_authorization_handler_id_anchor_t *previous_anchor;
1146  afw_boolean_t destroy;
1147 
1148  destroy = false;
1149  AFW_LOCK_WRITE_BEGIN(xctx->env->authorization_handler_id_anchor_rw_lock) {
1150 
1151  /* Find anchor for this authorization handler instance. */
1152  for (
1155  &instance->authorization_handler_id, xctx),
1156  previous_anchor = NULL;
1157  anchor && anchor->authorization_handler != instance;
1158  previous_anchor = anchor,
1159  anchor = anchor->stopping);
1160 
1161  if (anchor) {
1162  anchor->reference_count--;;
1163  if (anchor->reference_count <= 0) {
1164  destroy = true;
1165  anchor->reference_count = 0;
1166  if (!previous_anchor) {
1167  anchor->authorization_handler = NULL;
1168  }
1169  else {
1170  previous_anchor->stopping = anchor->stopping;
1171  }
1172  }
1173  }
1174  }
1175 
1177 
1178  if (destroy) {
1179  afw_authorization_handler_destroy(instance, xctx);
1180  }
1181 }
1182 
1183 
1184 /* Configuration handler for entry type "authorizationHandler". */
1185 void
1186 impl_authorization_conf_type_create_cede_p(
1187  const afw_utf8_t *type,
1188  const afw_object_t *conf,
1189  const afw_utf8_t *source_location,
1190  const afw_pool_t *p, afw_xctx_t *xctx)
1191 {
1193  const afw_utf8_t *authorization_id;
1194 
1195  /* Get authorization_handler_id. */
1196  authorization_id = afw_object_old_get_property_as_string(conf,
1197  &afw_s_authorizationHandlerId, xctx);
1198  if (!authorization_id) {
1199  AFW_THROW_ERROR_FZ(general, xctx,
1201  "authorizationId properties is required",
1202  AFW_UTF8_FMT_ARG(source_location));
1203  }
1204 
1205  /* See if authorizationHandler id already used. */
1206  anchor = afw_environment_get_authorization_handler_id(authorization_id, xctx);
1207  if (anchor) {
1208  AFW_THROW_ERROR_FZ(general, xctx,
1209  "%" AFW_UTF8_FMT " authorizationHandlerId %" AFW_UTF8_FMT
1210  " is already running",
1211  source_location->len, source_location->s,
1212  authorization_id->len, authorization_id->s);
1213  }
1214 
1215  /* Start authorizationHandler. */
1217  conf, source_location, p, xctx);
1218 }
1219 
1220 
1221 
1222 /* Internal function called to register core authorization. */
1223 AFW_DEFINE_INTERNAL(void)
1224 afw_authorization_internal_register_service_and_conf(
1225  afw_xctx_t *xctx)
1226 {
1227  afw_service_type_t *self;
1228 
1229  /* Register type "authorization" configuration entry handler. */
1231  &afw_s_authorizationHandler,
1232  impl_authorization_conf_type_create_cede_p,
1233  &afw_s_a_authorizationHandler_title,
1234  &afw_s_a_authorizationHandler_description,
1235  &afw_s_authorizationHandlerId,
1236  &afw_s_authorization_handler_id,
1237  &afw_s__AdaptiveAuthorizationHandler_,
1238  &afw_s_authorizationHandlerType,
1239  &afw_s_authorization_handler_type,
1240  &afw_s__AdaptiveAuthorizationHandlerType_,
1241  false,
1242  xctx);
1243 
1244  /* Create and register service type. */
1246  self->inf = &impl_afw_service_type_inf;
1247  afw_memory_copy(&self->service_type_id, &afw_s_authorizationHandler);
1248  self->conf_type = afw_environment_get_conf_type(
1249  &afw_s_authorizationHandler, xctx);
1250  if (!self->conf_type) {
1251  AFW_THROW_ERROR_Z(general, "conf_type must already be registered",
1252  xctx);
1253  }
1254  self->title = &afw_s_a_service_type_authorizationHandler_title;
1255  self->conf_type_object = afw_runtime_get_object(&afw_s__AdaptiveConfType_,
1256  &afw_s_authorizationHandler, xctx);
1257  afw_environment_register_service_type(&afw_s_authorizationHandler, self, xctx);
1258 }
1259 
1260 
1261 
1262 /*
1263  * Implementation of method related_instance_count of interface afw_service_type.
1264  */
1266 impl_afw_service_type_related_instance_count (
1267  const afw_service_type_t * instance,
1268  const afw_utf8_t * id,
1269  afw_xctx_t *xctx)
1270 {
1273  afw_integer_t result = 0;
1274 
1276 
1279  if (anchor) {
1280  for (stopping = anchor->stopping;
1281  stopping;
1282  stopping = stopping->stopping)
1283  {
1284  result++;
1285  }
1286  if (anchor->authorization_handler) {
1287  result++;
1288  }
1289  else {
1290  result = -result;
1291  }
1292  }
1293  }
1295 
1296  return result;
1297 }
1298 
1299 
1300 
1301 /*
1302  * Implementation of method start_cede_p of interface afw_service_type.
1303  */
1304 void
1305 impl_afw_service_type_start_cede_p (
1306  const afw_service_type_t * instance,
1307  const afw_object_t * properties,
1308  const afw_pool_t * p,
1309  afw_xctx_t *xctx)
1310 {
1311  const afw_authorization_handler_factory_t *factory;
1312  const afw_authorization_handler_t *authorization_handler;
1313  const afw_utf8_t *authorization_handler_type;
1314 
1315  authorization_handler_type = afw_object_old_get_property_as_utf8(
1316  properties, &afw_s_authorizationHandlerType, p, xctx);
1317  if (!authorization_handler_type) {
1318  AFW_THROW_ERROR_Z(general,
1319  "parameter authorizationHandlerType missing",
1320  xctx);
1321  }
1322 
1324  authorization_handler_type, xctx);
1325  if (!factory) {
1326  AFW_THROW_ERROR_FZ(general, xctx,
1327  "authorizationHandlerType %" AFW_UTF8_FMT
1328  " is not a registered authorizationHandler type",
1329  AFW_UTF8_FMT_ARG(authorization_handler_type));
1330  }
1331 
1332  /* Create authorization handler. */
1333  authorization_handler =
1335  factory, properties, p, xctx);
1336 
1337  /* Make this authorization handler the active one. */
1338  impl_set_instance_active(&authorization_handler->authorization_handler_id,
1339  authorization_handler, xctx);
1340 }
1341 
1342 
1343 
1344 /*
1345  * Implementation of method stop of interface afw_service_type.
1346  */
1347 void
1348 impl_afw_service_type_stop (
1349  const afw_service_type_t * instance,
1350  const afw_utf8_t * id,
1351  afw_xctx_t *xctx)
1352 {
1353  impl_set_instance_active(id, NULL, xctx);
1354 }
1355 
1356 
1357 
1358 /*
1359  * Implementation of method restart_cede_p of interface afw_service_type.
1360  */
1361 void
1362 impl_afw_service_type_restart_cede_p (
1363  const afw_service_type_t * instance,
1364  const afw_object_t * properties,
1365  const afw_pool_t * p,
1366  afw_xctx_t *xctx)
1367 {
1368  /* Count on already running. Start will restart if necessary. */
1369  impl_afw_service_type_start_cede_p(instance, properties, p, xctx);
1370 }
AFW_DEFINE(const afw_object_t *)
#define AFW_DEFINE_INTERNAL(type)
Define an internal function for /src/afw/ source*.c files.
#define AFW_DEFINE_INTERNAL_CONST_DATA(type)
Define an internal variable for /src/afw/ source*.c files.
#define AFW_DEFINE_CONST_DATA(type)
Define a public afw variable.
Adaptive Framework Core Internal.
Interface afw_interface implementation declares.
#define afw_authorization_handler_factory_create_authorization_handler_cede_p(instance, properties, p, xctx)
Call method create_authorization_handler_cede_p of interface afw_authorization_handler_factory.
#define afw_authorization_handler_destroy(instance, xctx)
Call method destroy of interface afw_authorization_handler.
#define afw_authorization_handler_check(instance, resource_id, object, action_id, p, xctx)
Call method check of interface afw_authorization_handler.
afw_authorization_action_id_read
actionId value read.
afw_authorization_action_id_create
actionId value create.
afw_authorization_handler_release(const afw_authorization_handler_t *instance, afw_xctx_t *xctx)
Release reference to authorization handler.
afw_authorization_decision_id_notApplicable_value
AdaptiveAuthorizationResult decisionId value notApplicable.
afw_authorization_handler_get_reference(const afw_utf8_t *authorization_handler_id, afw_xctx_t *xctx)
Get reference to authorization handler.
afw_authorization_decision_id_permit_value
AdaptiveAuthorizationResult decisionId value permit.
afw_authorization_action_id_query
actionId value retrieve.
afw_authorization_decision_id_indeterminateD_value
AdaptiveAuthorizationResult decisionId value indeterminateD.
afw_authorization_action_id_modify
actionId value modify.
afw_authorization_check(afw_boolean_t enforce, const afw_value_t *request_id_value, const afw_value_t *resource_id_value, const afw_value_t *object_value, const afw_value_t *action_id_value, const afw_pool_t *p, afw_xctx_t *xctx)
Perform authorization check.
afw_authorization_action_id_control
actionId value control.
afw_authorization_mode_id_core_value
AdaptiveAuthorizationMode core.
afw_authorization_decision_id_deny_value
AdaptiveAuthorizationResult decisionId value deny.
afw_authorization_decision_id_indeterminateP_value
AdaptiveAuthorizationResult decisionId value indeterminateP.
afw_authorization_action_id_delete
actionId value delete.
afw_authorization_mode_id_intermediate_value
AdaptiveAuthorizationMode intermediate.
afw_authorization_decision_id_indeterminate_value
AdaptiveAuthorizationResult decisionId value indeterminate.
afw_authorization_mode_id_user_value
AdaptiveAuthorizationMode user.
afw_authorization_decision_id_indeterminateDP_value
AdaptiveAuthorizationResult decisionId value indeterminateDP.
afw_data_type_anyURI
Data type struct for anyURI.
#define afw_object_old_get_property_as_boolean(object, property_name, found, xctx)
Get property function for data type boolean value.
afw_object_set_property_as_list(const afw_object_t *object, const afw_utf8_t *property_name, const afw_list_t *internal, afw_xctx_t *xctx)
Set property function for data type list values.
#define afw_value_is_null(A_VALUE)
Macro to determine if value is evaluated null.
#define afw_value_is_object(A_VALUE)
Macro to determine if value is evaluated object.
afw_value_create_object(const afw_object_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type object value.
afw_data_type_object_direct
extern for data type object struct.
afw_value_evaluated_object_inf
Unmanaged evaluated value inf for data type object.
afw_data_type_string_direct
extern for data type string struct.
#define afw_object_old_get_property_as_string(object, property_name, xctx)
Get property function for data type string value.
afw_value_evaluated_string_inf
Unmanaged evaluated value inf for data type string.
afw_value_as_string(const afw_value_t *value, afw_xctx_t *xctx)
Typesafe cast of data type string.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
Definition: afw_common.h:605
#define AFW_UTF8_LITERAL(A_STRING)
String literal initializer.
Definition: afw_common.h:582
#define AFW_UTF8_CONTEXTUAL_LABEL_FMT
Format string used for source location.
Definition: afw_common.h:595
_Bool afw_boolean_t
Definition: afw_common.h:373
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
Definition: afw_common.h:588
apr_int64_t afw_integer_t
typedef for big signed int.
Definition: afw_common.h:321
afw_context_type_register_cb_variables(const afw_utf8_t *context_type_id, const afw_utf8_t *qualifier_id, const afw_utf8_octet_t *description_z, const afw_context_cb_variable_t *const *variables, int include_mask, afw_xctx_t *xctx)
Register context type id for array of current variable callbacks.
Definition: afw_context.c:135
afw_context_push_cb_variables(const afw_utf8_t *qualifier_id, const afw_context_cb_variable_t *const *variables, void *data, const afw_pool_t *p, afw_xctx_t *xctx)
Push NULL terminated list of variable callback structs.
Definition: afw_context.c:47
void afw_environment_register_authorization_handler_id(const afw_utf8_t *authorization_handler_id, const afw_authorization_handler_id_anchor_t *anchor, afw_xctx_t *xctx)
Register an authorization handler id anchor.
void afw_environment_register_service_type(const afw_utf8_t *service_type_id, const afw_service_type_t *service_type, afw_xctx_t *xctx)
Register a service type.
const afw_environment_conf_type_t * afw_environment_get_conf_type(const afw_utf8_t *type, afw_xctx_t *xctx)
Get the conf_type associated with type.
const afw_authorization_handler_id_anchor_t * afw_environment_get_authorization_handler_id(const afw_utf8_t *authorization_handler_id, afw_xctx_t *xctx)
Get the authorization handler id anchor associated with authorization handler id.
afw_environment_create_and_register_conf_type(const afw_utf8_t *conf_type_id, afw_environment_conf_type_create_cede_p_t create, const afw_utf8_t *title, const afw_utf8_t *description, const afw_utf8_t *id_property_name, const afw_utf8_t *id_registry_type_id, const afw_utf8_t *id_runtime_object_type_id, const afw_utf8_t *subtype_property_name, const afw_utf8_t *subtype_registry_type_id, const afw_utf8_t *subtype_runtime_object_type_id, afw_boolean_t is_unique, afw_xctx_t *xctx)
Create and register a configuration (conf) type.
const afw_flag_t * afw_environment_get_flag(const afw_utf8_t *flag_id, afw_xctx_t *xctx)
Get the flag instance associated with flag_id.
const afw_authorization_handler_factory_t * afw_environment_get_authorization_handler_type(const afw_utf8_t *authorization_handler_type, afw_xctx_t *xctx)
Get the authorization_handler factory instance associated with authorization handler type.
#define AFW_FINALLY
Always executed regardless of error.
Definition: afw_error.h:702
#define AFW_CATCH_UNHANDLED
Catch an unhandled error that occurs in a AFW_TRY block.
Definition: afw_error.h:684
#define AFW_ENDTRY
Ends an AFW try block.
Definition: afw_error.h:727
#define AFW_TRY
Begin an AFW TRY block.
Definition: afw_error.h:634
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:319
afw_error_to_utf8(const afw_error_t *error, const afw_pool_t *p, afw_xctx_t *xctx)
Convert error to utf8.
Definition: afw_error.c:547
#define AFW_ERROR_THROWN
Access the thrown error. See AFW_TRY.
Definition: afw_error.h:554
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:283
#define afw_flag_is_active(flag_index, xctx)
Determine if flag for flag index is set in xctx.
Definition: afw_flag.h:84
void afw_flag_environment_register_flag(const afw_utf8_t *flag_id, const afw_utf8_t *brief, const afw_utf8_t *description, const afw_utf8_t *included_by_flag_id, afw_xctx_t *xctx)
Register a flag definition.
Definition: afw_flag.c:579
void afw_flag_add_included_by(const afw_utf8_t *flag_id, const afw_utf8_t *included_by_flag_id, afw_xctx_t *xctx)
Add another include_by flag to a registered flag.
Definition: afw_flag.c:688
afw_list_create_wrapper_for_array(const void *array, afw_boolean_t indirect, const afw_data_type_t *data_type, afw_size_t count, const afw_pool_t *p, afw_xctx_t *xctx)
Create a immutable list wrapper for an array.
#define AFW_LOCK_READ_END
Macro to end a read lock section for pool.
Definition: afw_lock.h:320
#define AFW_LOCK_WRITE_BEGIN(instance)
Macro to begin a write lock section.
Definition: afw_lock.h:400
#define AFW_LOCK_WRITE_END
Macro to end a write lock section.
Definition: afw_lock.h:411
#define AFW_LOCK_READ_BEGIN(instance)
Macro to begin a read lock section for pool.
Definition: afw_lock.h:309
#define afw_memory_copy(to, from)
Copy to preallocated memory of same type.
Definition: afw_memory.h:39
afw_object_meta_set_object_type_id(const afw_object_t *instance, const afw_utf8_t *object_type_id, afw_xctx_t *xctx)
Set object's object type id.
afw_object_old_get_property_as_utf8(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_pool_t *p, afw_xctx_t *xctx)
Get an object's property value as a string in specified pool.
Definition: afw_object.c:531
#define afw_object_create(p, xctx)
Create an empty unmanaged object in memory.
Definition: afw_object.h:948
afw_object_old_get_property_as_compiled_hybrid(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_utf8_t *source_location, const afw_compile_shared_t *shared, const afw_pool_t *p, afw_xctx_t *xctx)
Return a compiled hybrid property value.
Definition: afw_object.c:402
afw_object_set_property(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_value_t *value, afw_xctx_t *xctx)
Set the value of an object's property.
Definition: afw_object.c:46
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
Definition: afw_pool.h:167
afw_runtime_get_object(const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_xctx_t *xctx)
Get a runtime object.
Definition: afw_runtime.c:853
afw_service_start_using_AdaptiveConf_cede_p(const afw_object_t *conf, const afw_utf8_t *source_location, const afw_pool_t *p, afw_xctx_t *xctx)
Start a service using AdaptiveConf object and cede p.
Definition: afw_service.c:1147
afw_service_start(const afw_utf8_t *service_id, afw_boolean_t manual_start, afw_xctx_t *xctx)
Start a service.
Definition: afw_service.c:1201
#define afw_trace_fz(trace_level, flag_index, instance, xctx, format_z,...)
If applicable, write trace using a printf style format.
Definition: afw_trace.h:88
const afw_utf8_t * afw_utf8_concat(const afw_pool_t *p, afw_xctx_t *xctx,...)
Concatenate strings with result in specifed pool.
afw_boolean_t afw_utf8_equal(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string equals another string.
const afw_utf8_t * afw_utf8_clone(const afw_utf8_t *string, const afw_pool_t *p, afw_xctx_t *xctx)
Clone a utf-8 string into a specific pool.
Definition: afw_utf8.h:347
afw_uuid_create_string(const afw_pool_t *p, afw_xctx_t *xctx)
Create a UUID as a standard format UUID utf-8 string value.
Definition: afw_uuid.c:43
#define afw_value_evaluate(value, p, xctx)
Evaluate value if needed using specific pool.
Definition: afw_value.h:841
afw_xctx_get_qualifier_stack_top(afw_xctx_t *xctx)
Get qualifier stack top.
Definition: afw_xctx.c:316
afw_xctx_set_qualifier_stack_top(int top, afw_xctx_t *xctx)
Set stack top index.
Definition: afw_xctx.c:325
#define afw_xctx_calloc_type(type, xctx)
Macro to allocate cleared memory to hold type in xctx's pool.
Definition: afw_xctx.h:199
Interface afw_authorization_handler_factory public struct.
Interface afw_authorization_handler public struct.
const afw_value_t * initial_authorization_check
Initial authorization check or NULL.
const afw_utf8_t * not_applicable_decision_id
Final notApplicable decision id.
const afw_value_t * not_applicable_result
Final notApplicable result.
const afw_authorization_handler_id_anchor_t * first_anchor
First authorization handler id anchor in priority order.
const afw_value_t * core_authorization_check
Core authorization check or NULL.
afw_boolean_t check_intermediate_mode
Check authorization for mode intermediate.
const afw_authorization_handler_id_anchor_t * next_anchor
Next authorization id anchor in priority order.
const afw_authorization_handler_t * authorization_handler
Authorization Handler instance or NULL.
afw_integer_t processing_order
Order this authorization handler will be processed.
const afw_utf8_t * service_id
Associated service id or NULL.
const afw_utf8_t * authorization_handler_id
Authorization Handler id.
afw_integer_t reference_count
Reference count for this instance of authorization handler.
const afw_object_t * properties
Associated properties.
afw_authorization_handler_id_anchor_t * stopping
First/next stopping authorization handler or NULL.
Struct used in afw_context_cb_variable_s.
Definition: afw_context.h:31
Struct passed to afw_context_type_register_cb_variables()
Definition: afw_context.h:43
Struct for typedef afw_environment_t defined in afw_common.h.
Definition: afw_common.h:1383
afw_size_t flag_index_trace_authorization_check_detail
Flag index of trace:authorization:check:detail.
Definition: afw_common.h:1561
const afw_pool_t * p
Pool used to hold environment.
Definition: afw_common.h:1386
afw_size_t flag_index_trace_authorization_check
Flag index of trace:authorization:check.
Definition: afw_common.h:1555
afw_size_t flag_index_trace_authorization_decision_detail
Flag index of trace:authorization:decision:detail.
Definition: afw_common.h:1567
afw_size_t flag_index_trace_authorization_decision
Flag index of trace:authorization:decision.
Definition: afw_common.h:1564
const afw_lock_rw_t * authorization_handler_id_anchor_rw_lock
Lock for protecting changes to authorization handler id anchors.
Definition: afw_common.h:1488
afw_size_t flag_index_trace_authorization_check_bypass
Flag index of trace:authorization:check:bypass.
Definition: afw_common.h:1558
const afw_authorization_control_t * authorization_control
Used by authorization.
Definition: afw_common.h:1449
afw_size_t flag_index
Index of this flag in flags array.
Definition: afw_flag.h:51
Interface afw_list public struct.
Interface afw_object public struct.
Interface afw_pool public struct.
Interface afw_service_type public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
struct for data type object values.
Interface afw_value public struct.
struct for data type string values.
Definition: afw_xctx.h:352
void * data
Data that will be passed to get/set.
Definition: afw_xctx.h:367
Interface afw_xctx public struct.