Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
OpenXPKI::Server::ContUser3Contributed Perl DocumeOpenXPKI::Server::Context(3)

	OpenXPKI::Server::Context (Singleton)

       This package provices a globally	accessible Context singleton that
       holds object references for the OpenXPKI	base infrastructure.
       Typically the package is	included in every module that needs to access
       basic functions such as logging or database operations.

       During startup of the system this Context package must be initialized
       once by passing in the configuration file (see create()).  After
       initialization has completed the	package	holds a	global context that
       can be accessed from anywhere within the	OpenXPKI code structure.

       Callers typically use the CTX() function	to access this context.	See
       below for usage hints.

   Basic objects (always available)
       The following Context objects are always	created	and can	be retrieved
       by calling CTX('...') once create() has been called:

       o   xml_config

       o   crypto_layer

       o   pki_realm

       o   volatile_vault

       o   log

       o   dbi

   Auxiliary objects (only available after explicit addition)
       In addition to the above	objects	that are guaranteed to exist after
       initialization has happened, the	following can be retrieved if they
       have been explicitly added to the Context after initialization via

       o   api2

       o   server

       These objects are usually created and attached by the OpenXPKI Server
       initialization procedure	in order to make the objects available

       Allows to retrieve an object reference for the specified	name.  If
       called before initialization has	happened (see create() function)
       calling CTX() yields an exception.  CTX() returns the associated	object
       in the global context.


	 use OpenXPKI::Server::Context;
	 my $config = OpenXPKI::Server::Context::CTX('xml_config');

       or simpler:

	 use OpenXPKI::Server::Context qw( CTX );
	 my $config = CTX('xml_config');

       It is also possible to call CTX() in array context to obtain multiple
       context entries at once:

	 my ($config, $log, $dbi) = CTX('xml_config', 'log', 'dbi');

       Allows to set additional	globally available Context information after
       the Context has been initialized	via create().

       To prevent abuse	(storing arbitrary stuff globally) the Context module
       only allows to set Context entries that are allowed explicitly.	Only
       the keys	mentioned above	are accepted, trying to	set an unsupported
       Context object yields an	exception.

       Please note that	it is NOT possible to overwrite	a Context object once
       it has been set once. setcontext() will throw an	exception if somebody
       tries to	set an object that has already been attached.


	 # attach this server object and the API to the	global context
	   server => $self,
	   api2	  => OpenXPKI::Server::API2->new(),

       Check if	the requested entry is available from the context.

       Delete the recorded session from	the context. Used during server
       startup where we	start with a mock session and need a real one later.

perl v5.32.1			  2021-03-01	  OpenXPKI::Server::Context(3)

Name | Description | Functions

Want to link to this manual page? Use this URL:

home | help