/** * Initiates the module * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance * * @return bool * @throws \AppserverIo\Server\Exceptions\ModuleException */ public function init(ServerContextInterface $serverContext) { // initialize the server context $this->serverContext = $serverContext; // initialize the profile logger if ($serverContext->hasLogger(LoggerUtils::PROFILE)) { $this->profileLogger = $serverContext->getLogger(LoggerUtils::PROFILE); } }
/** * Factory method to create a new DNS resolver instance. * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server context for the resolver * @param \AppserverIo\Server\Interfaces\ModuleConfigurationInterface $moduleConfiguration The module configuration with the initialization parameters * * @return \AppserverIo\DnsServer\StorageProvider\StorageProviderInterface The initialized DNS resolver */ public static function factory(ServerContextInterface $serverContext, ModuleConfigurationInterface $moduleConfiguration) { // laod the system configuration from the server context $systemConfiguration = $serverContext->getContainer()->getInitialContext()->getSystemConfiguration(); // initialize the storage provider $storageProvider = new SystemConfigurationStorageProvider($systemConfiguration, $moduleConfiguration); // initialize the DNS resolver to load the DNS entries from the storage return new StackableResolver(array($storageProvider, new RecursiveProvider())); }
/** * Initiates the module * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance * * @return bool * @throws \AppserverIo\Server\Exceptions\ModuleException */ public function init(ServerContextInterface $serverContext) { // We have to throw a ModuleException on failure, so surround the body with a try...catch block try { // Save the server context for later re-use $this->serverContext = $serverContext; // Register our dependencies $this->dependencies = array('virtualHost'); $this->supportedServerVars = array('headers' => array(Protocol::HEADER_STATUS, Protocol::HEADER_DATE, Protocol::HEADER_CONNECTION, Protocol::HEADER_CONNECTION_VALUE_CLOSE, Protocol::HEADER_CONNECTION_VALUE_KEEPALIVE, Protocol::HEADER_CONTENT_TYPE, Protocol::HEADER_CONTENT_DISPOSITION, Protocol::HEADER_CONTENT_LENGTH, Protocol::HEADER_CONTENT_ENCODING, Protocol::HEADER_CACHE_CONTROL, Protocol::HEADER_PRAGMA, Protocol::HEADER_PROXY_CONNECTION, Protocol::HEADER_X_FORWARD, Protocol::HEADER_LAST_MODIFIED, Protocol::HEADER_EXPIRES, Protocol::HEADER_IF_MODIFIED_SINCE, Protocol::HEADER_LOCATION, Protocol::HEADER_X_POWERED_BY, Protocol::HEADER_COOKIE, Protocol::HEADER_SET_COOKIE, Protocol::HEADER_HOST, Protocol::HEADER_ACCEPT, Protocol::HEADER_ACCEPT_CHARSET, Protocol::HEADER_ACCEPT_LANGUAGE, Protocol::HEADER_ACCEPT_ENCODING, Protocol::HEADER_USER_AGENT, Protocol::HEADER_REFERER, Protocol::HEADER_KEEP_ALIVE, Protocol::HEADER_SERVER, Protocol::HEADER_WWW_AUTHENTICATE, Protocol::HEADER_AUTHORIZATION, Protocol::HEADER_X_REQUESTED_WITH, Protocol::HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, Protocol::HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, Protocol::STATUS_REASONPHRASE_UNASSIGNED)); $this->supportedSslEnvironmentVars = array(EnvVars::HTTPS, EnvVars::SSL_PROTOCOL, EnvVars::SSL_SESSION_ID, EnvVars::SSL_CIPHER, EnvVars::SSL_CIPHER_EXPORT, EnvVars::SSL_CIPHER_USEKEYSIZE, EnvVars::SSL_CIPHER_ALGKEYSIZE, EnvVars::SSL_COMPRESS_METHOD, EnvVars::SSL_VERSION_INTERFACE, EnvVars::SSL_VERSION_LIBRARY, EnvVars::SSL_CLIENT_M_VERSION, EnvVars::SSL_CLIENT_M_SERIAL, EnvVars::SSL_CLIENT_S_DN, EnvVars::SSL_CLIENT_S_DN_X509, EnvVars::SSL_CLIENT_I_DN, EnvVars::SSL_CLIENT_I_DN_X509, EnvVars::SSL_CLIENT_V_START, EnvVars::SSL_CLIENT_V_END, EnvVars::SSL_CLIENT_V_REMAIN, EnvVars::SSL_CLIENT_A_SIG, EnvVars::SSL_CLIENT_A_KEY, EnvVars::SSL_CLIENT_CERT, EnvVars::SSL_CLIENT_CERT_CHAIN_N, EnvVars::SSL_CLIENT_VERIFY, EnvVars::SSL_SERVER_M_VERSION, EnvVars::SSL_SERVER_M_SERIAL, EnvVars::SSL_SERVER_S_DN, EnvVars::SSL_SERVER_S_DN_X509, EnvVars::SSL_SERVER_I_DN, EnvVars::SSL_SERVER_I_DN_X509, EnvVars::SSL_SERVER_V_START, EnvVars::SSL_SERVER_V_END, EnvVars::SSL_SERVER_A_SIG, EnvVars::SSL_SERVER_A_KEY, EnvVars::SSL_SERVER_CERT, EnvVars::SSL_TLS_SNI); // Get the variables which came from our configuration. There might be more coming from preceding modules // which we will load within the process() method. $this->configuredVariables = $this->serverContext->getServerConfig()->getEnvironmentVariables(); } catch (\Exception $e) { // Re-throw as a ModuleException throw new ModuleException($e); } }
/** * Initiates the module * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance * * @return bool * @throws \AppserverIo\Server\Exceptions\ModuleException */ public function init(ServerContextInterface $serverContext) { $this->typeInstances = array(); $this->serverContext = $serverContext; $this->authentications = $serverContext->getServerConfig()->getAuthentications(); $systemLogger = $serverContext->getLogger(LoggerUtils::SYSTEM); // check if authentication are given if (is_array($this->authentications)) { // init all uri patterns foreach ($this->authentications as $uri => $params) { $this->uriPatterns[$uri] = $params; // try to get authentication type instance try { // pre init types by calling getter in init $this->getAuthenticationInstance($uri, $params); } catch (\Exception $e) { // log exception as warning to not end up with a server break $systemLogger->warning($e->getMessage()); } } } }
/** * Initiates the module. * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance * * @return bool * @throws \AppserverIo\Server\Exceptions\ModuleException */ public function init(ServerContextInterface $serverContext) { $this->locations = $serverContext->getServerConfig()->getLocations(); }
/** * Initiates the module * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance * * @return bool * @throws \AppserverIo\Server\Exceptions\ModuleException */ public function init(ServerContextInterface $serverContext) { $this->serverContext = $serverContext; $this->rewriteMaps = $serverContext->getServerConfig()->getRewriteMaps(); }
/** * Initiates the module * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance * * @return bool * @throws \AppserverIo\Server\Exceptions\ModuleException */ public function init(ServerContextInterface $serverContext) { $this->serverContext = $serverContext; // save directory index as array got space separated from config $this->directoryIndex = explode(' ', $serverContext->getServerConfig()->getDirectoryIndex()); }
/** * Initiates the module * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance * * @return bool * @throws \AppserverIo\Server\Exceptions\ModuleException */ public function init(ServerContextInterface $serverContext) { try { $this->serverContext = $serverContext; $this->analytics = $serverContext->getServerConfig()->getAnalytics(); } catch (\Exception $e) { // Re-throw as a ModuleException throw new ModuleException($e); } }
/** * Initiates the module * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance * * @return bool * @throws \AppserverIo\Server\Exceptions\ModuleException */ public function init(ServerContextInterface $serverContext) { // We have to throw a ModuleException on failure, so surround the body with a try...catch block try { // Save the server context for later re-use $this->serverContext = $serverContext; // Register our dependencies $this->dependencies = array('virtualHost'); $this->supportedServerVars = array('headers' => array(ServerVars::HTTP_USER_AGENT, ServerVars::HTTP_REFERER, ServerVars::HTTP_COOKIE, ServerVars::HTTP_FORWARDED, ServerVars::HTTP_HOST, ServerVars::HTTP_PROXY_CONNECTION, ServerVars::HTTP_ACCEPT)); $this->supportedEnvVars = EnvVars::all(); // Get the rules as the array they are within the config // We might not even get anything, so prepare our rules accordingly $this->configuredRules = $this->serverContext->getServerConfig()->getRewrites(); } catch (\Exception $e) { // Re-throw as a ModuleException throw new ModuleException($e); } }
/** * Will init the parameter mappings for our hit types * * @param array $params The parameters to check for requirements * * @return null */ protected function checkInputParameters(array $params) { // we only check if we know the requirements if (isset($this->requiredParameters[$params['t']])) { foreach ($this->requiredParameters[$params['t']] as $requirement) { if (!isset($params[$requirement])) { // do the logging, preferably by one of our loggers $message = 'We miss the required parameter "%s", you might not get proper analytics!'; if ($this->serverContext->hasLogger(LoggerUtils::SYSTEM)) { $logger = $this->serverContext->getLogger(LoggerUtils::SYSTEM); $logger->warning(sprintf($message, $requirement)); } else { error_log(sprintf($message, $requirement)); } } } } }
/** * Initiates the module * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance * * @return boolean * @throws \AppserverIo\Server\Exceptions\ModuleException */ public function init(ServerContextInterface $serverContext) { $this->serverContext = $serverContext; $this->accesses = $serverContext->getServerConfig()->getAccesses(); }