Parses the beSecurity configuration file.

@throws BackendSecurityParserException
If an error occurs in attempting to parse the beSecurity
configuration file.
172997
public BackendSecuritySpec parseBeSecurity()
            throws BackendSecurityParserException {

        try {
            BackendSecurityDeserializer bsd =
                    new BackendSecurityDeserializer(m_encoding, m_validate);
            return bsd.deserialize(m_beSecurityPath);

        } catch (Throwable th) {
            throw new BackendSecurityParserException("[DefaultBackendSecurity] "
                    + "An error has occured in parsing the backend security "
                    + "configuration file located at \""
                    + m_beSecurityPath
                    + "\". "
                    + "The underlying error was a "
                    + th.getClass().getName()
                    + "The message was \""
                    + th.getMessage() + "\".");
        }
    }
740734
@Override
	public void configure(WebSecurity web) throws Exception {
		web.ignoring().requestMatchers(IgnoredRequestMatcher.INSTANCE);
		DefaultHttpFirewall firewall = new DefaultHttpFirewall();
		firewall.setAllowUrlEncodedSlash(true);
		web.httpFirewall(firewall);
		//web.debug(true);
	}
726080
public void parse(File file) throws UpdateException {
        LOGGER.debug("Parsing " + file.getName());
        try (InputStream fin = new FileInputStream(file);
                InputStream in = new GZIPInputStream(fin);
                InputStreamReader isr = new InputStreamReader(in, UTF_8);
                JsonReader reader = new JsonReader(isr)) {
            final Gson gson = new GsonBuilder().create();

            reader.beginObject();

            while (reader.hasNext() && !JsonToken.BEGIN_ARRAY.equals(reader.peek())) {
                reader.skipValue();
            }
            reader.beginArray();
            while (reader.hasNext()) {
                final DefCveItem cve = gson.fromJson(reader, DefCveItem.class);

                //cve.getCve().getCVEDataMeta().getSTATE();
                if (testCveCpeStartWithFilter(cve)) {
                    cveDB.updateVulnerability(cve);
                }
            }
        } catch (FileNotFoundException ex) {
            LOGGER.error(ex.getMessage());
            throw new UpdateException("Unable to find the NVD CPE file, `" + file + "`, to parse", ex);
        } catch (IOException ex) {
            LOGGER.error("Error reading NVD JSON data: {}", file);
            LOGGER.debug("Error extracting the NVD JSON data from: " + file.toString(), ex);
            throw new UpdateException("Unable to find the NVD CPE file to parse", ex);
        }
    }
219937
private static void doParse(String connectionUri, JsonObject configuration) {
    Pattern pattern = Pattern.compile(FULL_URI_REGEX);
    Matcher matcher = pattern.matcher(connectionUri);

    if (matcher.matches()) {
      // parse the user and password
      parseUserandPassword(matcher.group(USER_INFO_GROUP), configuration);

      // parse the IP address/host/unix domainSocket address
      parseNetLocation(matcher.group(NET_LOCATION_GROUP), configuration);

      // parse the port
      parsePort(matcher.group(PORT_GROUP), configuration);

      // parse the database name
      parseDatabaseName(matcher.group(DATABASE_GROUP), configuration);

      // parse the parameters
      parseParameters(matcher.group(PARAMETER_GROUP), configuration);

    } else {
      throw new IllegalArgumentException("Wrong syntax of connection URI");
    }
  }
216126
public function parse()
    {

        // load the web application base directory
        $webappPath = $this->getAuthenticationContext()->getWebappPath();

        // prepare the deployment descriptor
        $deploymentDescriptor = $webappPath . DIRECTORY_SEPARATOR . 'WEB-INF' . DIRECTORY_SEPARATOR . 'web.xml';

        // query whether we found epb.xml deployment descriptor file
        if (file_exists($deploymentDescriptor) === false) {
            return;
        }

        // validate the passed configuration file
        /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */
        $configurationService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\ConfigurationService');
        $configurationService->validateFile($deploymentDescriptor, null, true);

        // prepare and initialize the configuration node
        $webAppNode = new WebAppNode();
        $webAppNode->initFromFile($deploymentDescriptor);

        // query whether or not we've a login configuration
            /** @var \AppserverIo\Appserver\Core\Api\Node\LoginConfigNode $loginConfig */
        if ($loginConfig = $webAppNode->getLoginConfig()) {
            // create the authentication method instance
            $reflectionClass = new ReflectionClass($this->mapAuthenticator($loginConfig->getAuthMethod()->__toString()));
            $authenticator = $reflectionClass->newInstanceArgs(array($loginConfig, $this->getAuthenticationContext(), new Boolean(true)));

            // add the authentication method itself
            $this->getAuthenticationContext()->addAuthenticator($authenticator);

            // initialize the security roles, that are part of the new security subsystem
            /** @var \AppserverIo\Appserver\Core\Api\Node\SecurityRoleNode $securityRoleNode */
            foreach ($webAppNode->getSecurityRoles() as $securityRoleNode) {
                // do something here
            }

            // initialize the security roles, that are part of the new security subsystem
            /** @var \AppserverIo\Appserver\Core\Api\Node\SecurityConstraintNode $securityContstraintNode */
            foreach ($webAppNode->getSecurityConstraints() as $securityContstraintNode) {
                // prepare the array with the authentication constraint role names
                $roleNames = array();
                if ($authConstraint = $securityContstraintNode->getAuthConstraint()) {
                    $roleNames = $authConstraint->getRoleNamesAsArray();
                }
                /** @var \AppserverIo\Appserver\Core\Api\Node\WebResourceCollectionNode $webResourceCollectionNode */
                foreach ($securityContstraintNode->getWebResourceCollections() as $webResourceCollectionNode) {
                    // prepare the arrays for the HTTP methods and the method omissions
                    $httpMethods = $webResourceCollectionNode->getHttpMethodsAsArray();
                    $httpMethodOmissions = $webResourceCollectionNode->getHttpMethodOmissionsAsArray();
                    /** @var \AppserverIo\Appserver\Core\Api\Node\UrlPatternNode $urlPatternNode */
                    foreach ($webResourceCollectionNode->getUrlPatterns() as $urlPatternNode) {
                        // prepare the URL pattern to authenticator mapping with the necessary data
                        $mapping = new Mapping(
                            $urlPatternNode->__toString(),
                            $authenticator->getSerial(),
                            $roleNames,
                            $httpMethods,
                            $httpMethodOmissions
                        );
                        // add the URL pattern to authenticator mapping
                        $this->getAuthenticationContext()->addMapping($mapping);
                    }
                }
            }
        }
    }
1133335
public static void parseFile(final IVdmSourceUnit source)
			throws CoreException, IOException
	{
		try
		{
			ISourceParser parser = SourceParserManager.getInstance()
					.getSourceParser(source.getProject());
			Assert.isNotNull(parser, "No parser for file : "
					+ source.toString() + " in project "
					+ source.getProject().toString());
			parser.parse(source);
		} catch (Exception e)
		{
			if (VdmCore.DEBUG)
			{
//				System.err.println("Error in parseFile");
				VdmCore.log("SourceParseManager-Error in parseFile", e);
			}
		}
	}
1257014
public synchronized final void parseDetails() {
        LOG.debug("parsing details of {}", this.getType());
        if (content != null) {
            ByteBuffer content = this.content;
            isParsed = true;
            content.rewind();
            _parseDetails(content);
            if (content.remaining() > 0) {
                deadBytes = content.slice();
            }
            this.content = null;
            assert verify(content);
        }
    }
1306302
protected function setupParse()
    {
        $config = $this->app->config->get('parse');

        ParseClient::initialize($config['app_id'], $config['rest_key'], $config['master_key']);

        if (isset($config['server_url']) && isset($config['mount_path'])) {
            $serverURL = rtrim($config['server_url'], '/');
            $mountPath = trim($config['mount_path'], '/').'/';

            ParseClient::setServerURL($serverURL, $mountPath);
        }

        if (isset($config['session']) && $config['session'] === 'laravel') {
            ParseClient::setStorage(new ParseSessionStorage($this->app->session));
        }
    }
529892
public function fileParser()
    {

        $globalFile = '../App/Config/global.php';
        $localFile = '../App/Config/local.php';

        $data = $global = include($globalFile);

        if (file_exists($localFile)) {

            $local = include($localFile);

            // Overlay data config
            $data = array_replace($global, $local);
        }

        // Config validators
        if (!isset($data['session_prefix'])) $data['session_prefix'] = '';
        if (!isset($data['language_code'])) $data['language_code'] = 'en';

        $this->configData = $data;
    }
1266513
def __parse_config(self):
        

        if self.should_parse_config and (self.args.config or self.config_file):
            self.config = ConfigParser.SafeConfigParser()
            self.config.read(self.args.config or self.config_file)
700610
private void parse()
    {
        this.elements = new ArrayList<>();

        try {
            for (Tokenizer tokenizer = new Tokenizer(this.rawVersion); tokenizer.next();) {
                Element element = new Element(tokenizer);
                this.elements.add(element);
                if (element.getVersionType() != Type.STABLE) {
                    this.type = element.getVersionType();
                }
            }

            trimPadding(this.elements);
        } catch (Exception e) {
            // Make sure to never fail no matter what
            LOGGER.error("Failed to parse version [" + this.rawVersion + "]", e);
            this.elements.add(new Element(this.rawVersion));
        }
    }
472008
private void parseFile(File schemaSourceFile, CourierParseResult result)
      throws IOException
  {
    if (wasResolved(schemaSourceFile))
    {
      return;
    }

    final List<DataSchema> schemas = parseSchema(schemaSourceFile, result);

    for (DataSchema schema : schemas)
    {
      validateSchemaWithFilePath(schemaSourceFile, schema);
      result.getSchemaAndLocations().put(schema, new FileDataSchemaLocation(schemaSourceFile));
      result.getSourceFiles().add(schemaSourceFile);
    }
  }
1064377
private void parse()
   {
      template = text;
      if (StringUtils.isEmptyTrimmed(template))
         return;
      int index = 0;
      while (template.indexOf("${") != -1)
      {
         int from = template.lastIndexOf("${");
         int to = template.indexOf("}", from + 2);
         if (to == -1)
         {
            template = text;
            complex = false;
            entities.clear();
            return;
         }

         int dv = template.indexOf(":", from + 2);
         if (dv != -1 && dv > to)
         {
            dv = -1;
         }
         String systemProperty = null;
         String defaultValue = null;
         String s = template.substring(from + 2, to);
         if ("/".equals(s))
         {
            systemProperty = File.separator;
         }
         else if (":".equals(s))
         {
            systemProperty = File.pathSeparator;
            dv = -1;
         }
         else
         {
            systemProperty = SecurityActions.getSystemProperty(s);
         }

         if (dv != -1)
         {
            s = template.substring(from + 2, dv);
            systemProperty = SecurityActions.getSystemProperty(s);
            defaultValue = template.substring(dv + 1, to);
         }
         String prefix = "";
         String postfix = "";
         String key = StringUtils.createKey(index++);
         updateComplex(defaultValue);
         entities.put(key, new Expression(s, defaultValue, systemProperty));

         if (from != 0)
         {
            prefix = template.substring(0, from);
         }
         if (to + 1 < template.length())
         {
            postfix = template.substring(to + 1);
         }
         template = prefix + key + postfix;
      }
      updateComplex(template);
   }
368691
public static void secureSaxParser(SAXParserFactory factory) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
		String FEATURE = null;

		// This is the PRIMARY defense. If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented
		// Xerces 2 only - http://xerces.apache.org/xerces2-j/features.html#disallow-doctype-decl
		FEATURE = "http://apache.org/xml/features/disallow-doctype-decl";
		factory.setFeature(FEATURE, true);

		// If you can't completely disable DTDs, then at least do the following:
		// Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-general-entities
		// Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-general-entities
		// JDK7+ - http://xml.org/sax/features/external-general-entities
		FEATURE = "http://xml.org/sax/features/external-general-entities";
		factory.setFeature(FEATURE, false);

		// Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-parameter-entities
		// Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities
		// JDK7+ - http://xml.org/sax/features/external-parameter-entities
		FEATURE = "http://xml.org/sax/features/external-parameter-entities";
		factory.setFeature(FEATURE, false);

		// Disable external DTDs as well
		FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
		factory.setFeature(FEATURE, false);

		// and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and Entity Attacks"
		factory.setXIncludeAware(false);
//		factory.setExpandEntityReferences(false); // not supported by sax factory

		// And, per Timothy Morgan: "If for some reason support for inline DOCTYPEs are a requirement, then
		// ensure the entity settings are disabled (as shown above) and beware that SSRF attacks
		// (http://cwe.mitre.org/data/definitions/918.html) and denial
		// of service attacks (such as billion laughs or decompression bombs via "jar:") are a risk."
		// remaining parser logic


		factory.setValidating(false);

	}
1183590
private void parse(boolean isSecure) throws URIException, HttpMalformedHeaderException {

        mIsSecure = isSecure;
        Matcher matcher = patternRequestLine.matcher(mStartLine);
        if (!matcher.find()) {
            mMalformedHeader = true;
            throw new HttpMalformedHeaderException("Failed to find pattern " + patternRequestLine + " in: " + mStartLine);
        }

        mMethod = matcher.group(1);
        String sUri = matcher.group(2);
        mVersion = matcher.group(3);

        if (!mVersion.equalsIgnoreCase(HTTP09) && !mVersion.equalsIgnoreCase(HTTP10) && !mVersion.equalsIgnoreCase(HTTP11)) {
            mMalformedHeader = true;
            throw new HttpMalformedHeaderException("Unexpected version: " + mVersion);
        }
        
        if (mMethod.equalsIgnoreCase(CONNECT)) {
            parseHostName(sUri);
            mUri = parseURI(mHostName);

        } else {
            mUri = parseURI(sUri);

            if (mUri.getScheme() == null || mUri.getScheme().equals("")) {
                mUri = new URI(HTTP + "://" + getHeader(HOST) + mUri.toString(), true);
            }

            if (isSecure() && mUri.getScheme().equalsIgnoreCase(HTTP)) {
                mUri = new URI(mUri.toString().replaceFirst(HTTP, HTTPS), true);
            }

            if (mUri.getScheme().equalsIgnoreCase(HTTPS)) {
                setSecure(true);
            }
            mHostName = mUri.getHost();
            setHostPort(mUri.getPort());
        }

    }
437291
public void parse(CmsResource resource) throws CmsException {

        CmsFile file = m_cms.readFile(resource);
        m_resource = resource;
        CmsXmlContent content = CmsXmlContentFactory.unmarshal(m_cms, file);
        parse(content);
    }
596004
public function parse()
    {

        // load the deployment descriptors that has to be parsed
        $deploymentDescriptors = $this->loadDeploymentDescriptors();

        // parse the deployment descriptors from the conf.d and the application's META-INF directory
        foreach ($deploymentDescriptors as $deploymentDescriptor) {
            // query whether we found epb.xml deployment descriptor file
            if (file_exists($deploymentDescriptor) === false) {
                continue;
            }

            // validate the passed configuration file
            /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */
            $configurationService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\ConfigurationService');
            $configurationService->validateFile($deploymentDescriptor, null, true);

            // load the object manager instance
            /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */
            $objectManager = $this->getApplication()->search(ObjectManagerInterface::IDENTIFIER);

            // prepare and initialize the configuration node
            $webAppNode = new WebAppNode();
            $webAppNode->initFromFile($deploymentDescriptor);

            /** @var \AppserverIo\Appserver\Core\Api\Node\ServletNode $servletNode */
            foreach ($webAppNode->getServlets() as $servletNode) {
                // iterate over all configured descriptors and try to load object description
                /** \AppserverIo\Appserver\Core\Api\Node\DescriptorNode $descriptor */
                foreach ($this->getDescriptors() as $descriptor) {
                    try {
                        // load the descriptor class
                        $descriptorClass = $descriptor->getNodeValue()->getValue();

                        // load the object descriptor, initialize the servlet mappings and add it to the object manager
                        /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */
                        if ($objectDescriptor = $descriptorClass::newDescriptorInstance()->fromConfiguration($servletNode)) {
                            /** @var \AppserverIo\Appserver\Core\Api\Node\ServletMappingNode $servletMappingNode */
                            foreach ($webAppNode->getServletMappings() as $servletMappingNode) {
                                // query whether or not we've to add the URL pattern for the servlet
                                if ((string) $servletNode->getServletName() === (string) $servletMappingNode->getServletName()) {
                                    $objectDescriptor->addUrlPattern((string) $servletMappingNode->getUrlPattern());
                                }
                            }

                            // add the object descriptor for the servlet
                            $objectManager->addObjectDescriptor($objectDescriptor, true);
                        }

                        // proceed with the next descriptor
                        continue;

                    // if class can not be reflected continue with next class
                    } catch (\Exception $e) {
                        // log an error message
                        $this->getApplication()->getInitialContext()->getSystemLogger()->error($e->__toString());

                        // proceed with the next descriptor
                        continue;
                    }
                }
            }

            // initialize the session configuration if available
            /** @var \AppserverIo\Appserver\Core\Api\Node\SessionConfigNode $sessionConfig */
            if ($sessionConfig = $webAppNode->getSessionConfig()) {
                foreach ($sessionConfig->toArray() as $key => $value) {
                    $this->getManager()->addSessionParameter($key, $value);
                }
            }

            // initialize the error page configuration if available
            /** @var \AppserverIo\Appserver\Core\Api\Node\ErrorPageNode $errorPageNode */
            foreach ($webAppNode->getErrorPages() as $errorPageNode) {
                $this->getManager()->addErrorPage((string) $errorPageNode->getErrorCodePattern(), (string) $errorPageNode->getErrorLocation());
            }

            // initialize the context with the context parameters
            /** @var \AppserverIo\Appserver\Core\Api\Node\ContextParamNode $contextParamNode */
            foreach ($webAppNode->getContextParams() as $contextParamNode) {
                $this->getManager()->addInitParameter((string) $contextParamNode->getParamName(), (string) $contextParamNode->getParamValue());
            }
        }
    }