Configures a {@link TransformerFactory} to protect it against XML
External Entity attacks.
@param factory the factory
@see <a href=
"https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_Prevention_Cheat_Sheet#Java">
XXE Cheat Sheet</a>
1159
public static void applyXXEProtection(TransformerFactory factory) {
		//@formatter:off
		String[] attributes = {
			//XMLConstants.ACCESS_EXTERNAL_DTD (Java 7 only)
			"http://javax.xml.XMLConstants/property/accessExternalDTD",

			//XMLConstants.ACCESS_EXTERNAL_STYLESHEET (Java 7 only)
			"http://javax.xml.XMLConstants/property/accessExternalStylesheet"
		};
		//@formatter:on

		for (String attribute : attributes) {
			try {
				factory.setAttribute(attribute, "");
			} catch (IllegalArgumentException e) {
				//attribute is not supported by the local XML engine, skip it
			}
		}
	}
257178
private static SAXParser createSAXParser()
      throws ParserConfigurationException, SAXException {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(false);
    factory.setXIncludeAware(false);
    factory.setFeature(
        "http://xml.org/sax/features/external-general-entities", false);
    factory.setFeature(
        "http://xml.org/sax/features/external-parameter-entities", false);
    factory.setFeature(
        "http://apache.org/xml/features/nonvalidating/load-external-dtd",
        false);
    factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);

    SAXParser parser = factory.newSAXParser();
    XMLReader xmlReader = parser.getXMLReader();
    xmlReader.setEntityResolver(NOOP_RESOLVER);
    return parser;
  }
808227
def setFactory( self, factory ):
        
        self._factory = factory
        self._queryWidget.setFactory(factory)
348465
protected void configureEndpointFactory(AbstractWSDLBasedEndpointFactory factory)
   {
      //Configure binding customization
      if (customization != null)
      {
         ReflectionServiceFactoryBean serviceFactory = factory.getServiceFactory();
         //customize default databinding (early pulls in ServiceFactory default databinding and configure it, as it's lazily loaded)
         serviceFactory.reset();
         DataBinding serviceFactoryDataBinding = serviceFactory.getDataBinding(true);
         configureBindingCustomization(serviceFactoryDataBinding, customization);
         serviceFactory.setDataBinding(serviceFactoryDataBinding);
         //customize user provided databinding (CXF later overrides the ServiceFactory databinding using the user provided one) 
         if (factory.getDataBinding() == null)
         {
            //set the endpoint factory's databinding to prevent CXF resetting everything because user did not provide anything
            factory.setDataBinding(serviceFactoryDataBinding);
         }
         else
         {
            configureBindingCustomization(factory.getDataBinding(), customization);
         }
      }
      //add other configurations here below
   }
1248466
@Override
    public void setConstraintValidatorFactory(Configuration<?> apiConfig) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "setConstraintValidatorFactory", apiConfig);
        }
        Class<? extends ConstraintValidatorFactory> clazz = null;
        ConstraintValidatorFactory cvf = null;
        if (constraintValidatorFactory != null) {

            try {
                clazz = loadClass(constraintValidatorFactory).asSubclass(ConstraintValidatorFactory.class);
                cvf = instantiateClass(clazz);
            } catch (Throwable t) {
                FFDCFilter.processException(t, CLASS_NAME + ".setConstraintValidatorFactory", "313");
                // message and exception printed out in previous method called.
                // however since we can not create a validation factory throw validationException
                ValidationException e = new ValidationException(t);
                throw e;
            }
        }

        if (cvf != null) {
            apiConfig.constraintValidatorFactory(cvf);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "setConstraintValidatorFactory", cvf);
        }
    }
231961
public RuntimeEnvironmentBuilder entityManagerFactory(Object emf) {
        if (emf == null) {
            return this;
        }
        if (!(emf instanceof EntityManagerFactory)) {
            throw new IllegalArgumentException("Argument is not of type EntityManagerFactory");
        }
        _runtimeEnvironment.setEmf((EntityManagerFactory)emf);

        return this;
    }
1018753
public static void applyXXEProtection(DocumentBuilderFactory factory) {
		Map<String, Boolean> features = new HashMap<String, Boolean>();
		features.put("http://apache.org/xml/features/disallow-doctype-decl", true);
		features.put("http://xml.org/sax/features/external-general-entities", false);
		features.put("http://xml.org/sax/features/external-parameter-entities", false);
		features.put("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

		for (Map.Entry<String, Boolean> entry : features.entrySet()) {
			String feature = entry.getKey();
			Boolean value = entry.getValue();
			try {
				factory.setFeature(feature, value);
			} catch (ParserConfigurationException e) {
				//feature is not supported by the local XML engine, skip it
			}
		}

		factory.setXIncludeAware(false);
		factory.setExpandEntityReferences(false);
	}
75448
synchronized void setChannelFactory(ChannelFactory factory) throws ChannelFactoryException {
        if (factory != null && cf != null) {
            throw new ChannelFactoryException("ChannelFactory already exists");
        }
        this.cf = factory;
    }
52890
private static Transformer transformer(final TransformerFactory factory,
        final Source stylesheet) throws TransformerConfigurationException {
        final Transformer tnfr = factory.newTransformer(stylesheet);
        if (tnfr == null) {
            throw new TransformerConfigurationException(
                String.format(
                    "%s failed to create new XSL transformer for '%s'",
                    factory.getClass(),
                    stylesheet.getSystemId()
                )
            );
        }
        return tnfr;
    }
176266
public function setFactory(\Elcodi\Component\Core\Factory\Abstracts\AbstractFactory $factory)
    {
        $this->factory = $factory;

        return $this;
    }
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);

	}
190030
@Bean
    public ArmeriaClientConfigurator armeriaClientConfigurator(ClientFactory clientFactory) {
        // Customize the client using the given HttpClientBuilder. For example:
        return builder -> {
            // Use a circuit breaker for each remote host.
            final CircuitBreakerStrategy strategy = CircuitBreakerStrategy.onServerErrorStatus();
            builder.decorator(new CircuitBreakerHttpClientBuilder(strategy).newDecorator());

            // Set a custom client factory.
            builder.factory(clientFactory);
        };
    }
583429
public synchronized static void initGlobal(ContextFactory factory)
    {
        if (factory == null) {
            throw new IllegalArgumentException();
        }
        if (hasCustomGlobal) {
            throw new IllegalStateException();
        }
        hasCustomGlobal = true;
        global = factory;
    }
1186419
public static void setURLStreamHandlerFactory ( URLStreamHandlerFactory factory ) {
        synchronized ( PROTOCOL_HANDLERS ) {
            if ( Handler.factory != null ) {
                throw new IllegalStateException("URLStreamHandlerFactory already set.");
            }
            PROTOCOL_HANDLERS.clear();
            Handler.factory = factory;
        }
    }
974422
public JMapper<D, S> destinationFactory(DestinationFactory<D> factory){
    	this.mapper.setDestinationFactory(factory);
    	return this;
    }
1017071
public BuildableType.Builder builderFactory(BuilderFactory builderFactory) {
    this.builderFactory = Objects.requireNonNull(builderFactory);
    _unsetProperties.remove(Property.BUILDER_FACTORY);
    return (BuildableType.Builder) this;
  }
882785
static private JsonTransformer factory(Object jsonObject) throws InvalidTransformerException {
        if (jsonObject instanceof JSONObject) {
            return factory((JSONObject)jsonObject);
        }
        else if (jsonObject instanceof JSONArray) {
            return factory((JSONArray)jsonObject);
        }
        else if (jsonObject instanceof String) {
            return factoryAction((String)jsonObject);
        }
        
        throw new InvalidTransformerException("Not supported transformer type: " + jsonObject);
    }