Instantiate a <code>BESecurityConfig</code> from an XML stream.
334515
public static BESecurityConfig fromStream(InputStream in) throws Exception {

        BESecurityConfig config = new BESecurityConfig();

        // instantiate DOM
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(false);
        factory.setValidating(false);
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document doc = builder.parse(in);
        Element root = doc.getDocumentElement();

        // set default role configuration
        DefaultRoleConfig defaultRoleConfig = new DefaultRoleConfig();
        setValuesFromElement(defaultRoleConfig, root);
        config.setDefaultConfig(defaultRoleConfig);

        // get all child config nodes for repeated use
        NodeList nodes = root.getElementsByTagName(_CONFIG);

        // parse and add all explicitly configured sdef configurations
        // while also parsing fedoraInternalCall-1 and setting appropriate vals
        for (int i = 0; i < nodes.getLength(); i++) {
            Element e = (Element) nodes.item(i);
            String role = e.getAttribute(_ROLE);
            if (role.indexOf(":") != -1 && role.indexOf("/") == -1) {
                ServiceDeploymentRoleConfig sDepRoleConfig =
                        new ServiceDeploymentRoleConfig(defaultRoleConfig, role);
                setValuesFromElement(sDepRoleConfig, e);
                config.getServiceDeploymentConfigs().put(role, sDepRoleConfig);
            } else if (role.equals(_INTERNAL_PREFIX + "1")) {
                config.setInternalSSL(getBoolean(e, _CALLSSL));
                config.setInternalBasicAuth(getBoolean(e, _CALLBASICAUTH));
                config.setInternalUsername(getString(e, _CALLUSERNAME));
                config.setInternalPassword(getString(e, _CALLPASSWORD));
                config.setInternalIPList(getStringArray(e, _IPLIST));
            }
        }

        // finally, parse and add all configured methods, first adding
        // a blank sdef role configuration if needed
        for (int i = 0; i < nodes.getLength(); i++) {
            Element e = (Element) nodes.item(i);
            String[] parts = e.getAttribute(_ROLE).split("/");
            if (parts.length == 2) {
                String sDepPID = parts[0];
                String methodName = parts[1];
                ServiceDeploymentRoleConfig sDepRoleConfig =
                        config.getServiceDeploymentConfigs().get(sDepPID);
                if (sDepRoleConfig == null) {
                    sDepRoleConfig =
                            new ServiceDeploymentRoleConfig(defaultRoleConfig, sDepPID);
                    config.getServiceDeploymentConfigs().put(sDepPID, sDepRoleConfig);
                }
                MethodRoleConfig methodRoleConfig =
                        new MethodRoleConfig(sDepRoleConfig, methodName);
                setValuesFromElement(methodRoleConfig, e);
                sDepRoleConfig.getMethodConfigs().put(methodName,
                                                       methodRoleConfig);
            }
        }

        return config;
    }
668410
public static <T extends Trainable, TP extends Parameterizable> T create(TP trainingParameters, Configuration configuration) {
        try {
            Class<T> aClass = (Class<T>) trainingParameters.getClass().getEnclosingClass();
            Constructor<T> constructor = aClass.getDeclaredConstructor(trainingParameters.getClass(), Configuration.class);
            constructor.setAccessible(true);
            return constructor.newInstance(trainingParameters, configuration);
        }
        catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
            throw new RuntimeException(ex);
        }
    }
442572
public static SSLContext buildSSLContext(HttpClientConfig config) throws IOException, GeneralSecurityException {

    KeyManagerFactory kmf = null;
    if (isSslKeyManagerEnabled(config)) {
      kmf = getKeyManagerFactory(config.getKeyStorePath(),
          new StoreProperties(config.getKeyStorePassword(), config.getKeyManagerType(),
              config.getKeyStoreType(), config.getKeyStoreProvider()));
    }
    TrustManagerFactory tmf = null;
    if (isSslTrustStoreEnbaled(config)) {
      tmf = getTrustManagerFactory(config.getTrustStorePath(), new StoreProperties(config.getTrustStorePassword(),
          config.getTrustManagerType(), config.getTrustStoreType(), config.getTrustStoreProvider()));
    }

    SSLContext sslContext = SSLContext.getInstance(config.getSslContextType());
    sslContext.init(kmf != null ? kmf.getKeyManagers() : null,
        tmf != null ? tmf.getTrustManagers() : null,
        null);

    return sslContext;
  }
684538
public Verifier newVerifier(InputStream stream, String systemId )
		throws VerifierConfigurationException, SAXException, IOException {
		
		return compileSchema(stream,systemId).newVerifier();
	}
1179928
public Configuration create(InputStream stream) {
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setValidating(false);
            factory.setIgnoringElementContentWhitespace(true);
            factory.setNamespaceAware(true);
            DocumentBuilder documentBuilder = factory.newDocumentBuilder();
            Document document = documentBuilder.parse(stream);
            return domConfigurationFactory.create(document);
        } catch (ParserConfigurationException e) {
            throw new TextProcessorFactoryException(e);
        } catch (IOException e) {
            throw new TextProcessorFactoryException(e);
        } catch (SAXException e) {
            throw new TextProcessorFactoryException(e);
        }
    }
189250
public static Config parse(InputSource xml) throws IOException, SAXException {
		Config rv = new Config();
		XMLReader reader = XMLReaderFactory.createXMLReader();
		ConfigHandler handler = rv.new ConfigHandler(rv);
		reader.setContentHandler(handler);
		reader.parse(xml);
		return rv;
	}
251010
@FFDCIgnore(Throwable.class)
    public static XMLInputFactory createXMLInputFactory(boolean nsAware) {
        XMLInputFactory factory = null;
        try {
            factory = XMLInputFactory.newInstance();
        } catch (Throwable t) {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "XMLInputFactory.newInstance() failed with: ", t);
            }
            factory = null;
        }
        if (factory == null || !setRestrictionProperties(factory)) {
            try {
                factory = createWoodstoxFactory();
            } catch (Throwable t) {
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.log(Level.FINE, "Cannot create Woodstox XMLInputFactory: ", t);
                }
            }

            if (factory == null) {
                throw new RuntimeException("Failed to create XMLInputFactory.");
            }

            if (!setRestrictionProperties(factory)) {
                if (allowInsecureParser) {
                    //Liberty change start
                    //defect 165502: comment out the warning
                    //LOG.log(Level.WARNING, "INSECURE_PARSER_DETECTED", factory.getClass().getName());
                    //Liberty change end
                } else {
                    throw new RuntimeException("Cannot create a secure XMLInputFactory");
                }
            }
        }
        setProperty(factory, XMLInputFactory.IS_NAMESPACE_AWARE, nsAware);
        setProperty(factory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
        setProperty(factory, XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
        setProperty(factory, XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
        factory.setXMLResolver(new XMLResolver() {
            @Override
            public Object resolveEntity(String publicID, String systemID,
                                        String baseURI, String namespace)
                throws XMLStreamException {
                throw new XMLStreamException("Reading external entities is disabled");
            }
        });

        return factory;
    }
350597
public static XMLDocument create(XMLStreamEventsSync stream) throws XMLException, IOException {
		XMLDocument doc = new XMLDocument();
		do {
			switch (stream.event.type) {
			case DOCTYPE:
				if (doc.docType != null)
					throw new XMLException(stream.getPosition(), "Unexpected element ", "DOCTYPE");
				doc.docType = new XMLDocumentType(doc, stream.event.text.asString(),
					stream.event.publicId != null ? stream.event.publicId.asString() : null,
					stream.event.system != null ? stream.event.system.asString() : null);
				break;
			case START_ELEMENT:
				if (doc.root != null)
					throw new XMLException(stream.getPosition(), "Unexpected element ", stream.event.text.asString());
				doc.root = XMLElement.create(doc, stream);
				break;
			default: break;
			}
			try { stream.next(); }
			catch (EOFException e) {
				break;
			}
		} while (true);
		return doc;
	}
121950
def from_config(cls, pyvlx, item):
        """"""
        name = item['name']
        ident = item['id']
        subtype = item['subtype']
        typeid = item['typeId']
        return cls(pyvlx, ident, name, subtype, typeid)
1051350
public static NetworkConfig fromYamlStream(InputStream configStream) throws InvalidArgumentException, NetworkConfigurationException {

        logger.trace("NetworkConfig.fromYamlStream...");

        // Sanity check
        if (configStream == null) {
            throw new InvalidArgumentException("configStream must be specified");
        }

        Yaml yaml = new Yaml();

        @SuppressWarnings ("unchecked")
        Map<String, Object> map = yaml.load(configStream);

        JsonObjectBuilder builder = Json.createObjectBuilder(map);

        JsonObject jsonConfig = builder.build();
        return fromJsonObject(jsonConfig);
    }
603700
public static AsyncWork<XMLDocument, Exception> create(XMLStreamEventsAsync stream) {
		XMLDocument doc = new XMLDocument();
		AsyncWork<XMLDocument, Exception> result = new AsyncWork<>();
		create(doc, stream, result, new SynchronizationPoint<>(true));
		return result;
	}
393935
public static Document parseXmlStream(final Reader xmlStream) {

        // Build a DOM model of the provided xmlFileStream.
        final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);

        try {
            return factory.newDocumentBuilder().parse(new InputSource(xmlStream));
        } catch (Exception e) {
            throw new IllegalArgumentException("Could not acquire DOM Document", e);
        }
    }
145951
static SSLContext createSSLContext() {
    try {
      SSLContext sc = SSLContext.getInstance("SSL");
      TrustManager[] tm = {
          new X509TrustManager() {
            @SuppressLint("TrustAllX509TrustManager") @Override
            public void checkClientTrusted(X509Certificate[] paramArrayOfX509Certificate,
                String paramString) {
            }

            @SuppressLint("TrustAllX509TrustManager") @Override
            public void checkServerTrusted(X509Certificate[] paramArrayOfX509Certificate,
                String paramString) {
            }

            @Override public X509Certificate[] getAcceptedIssuers() {
              return new X509Certificate[] {};
            }
          }
      };
      sc.init(null, tm, new SecureRandom());
      return sc;
    } catch (NoSuchAlgorithmException | KeyManagementException e) {
      e.printStackTrace();
    }

    return null;
  }
1188644
public static SSLContext sslContext(AbstractConfig config, String key) {
    final String trustManagerFactoryType = config.getString(key);
    try {
      return SSLContext.getInstance(trustManagerFactoryType);
    } catch (NoSuchAlgorithmException e) {
      ConfigException exception = new ConfigException(
          key,
          trustManagerFactoryType,
          "Unknown Algorithm."
      );
      exception.initCause(e);
      throw exception;
    }
  }
444062
@SuppressWarnings( "unchecked" )
    private static synchronized void configure(InputStream in) throws ConfigurationException
    {
        if( c_factories == null )
            c_factories = new HashMap<String, StopWatchFactory>();

        try
        {
            c_config.load(in);
        }
        catch (IOException e2)
        {
            throw new ConfigurationException(e2);
        }

        for( Enumeration<String> e = (Enumeration<String>) c_config.propertyNames(); e.hasMoreElements(); )
        {
            String key = e.nextElement();

            String[] components = key.split("\\.");

            if( components.length < 2 || !components[0].equals(PROPERTY_PREFIX) ) continue;

            String logger = components[1];

            StopWatchFactory swf = c_factories.get(logger);

            if( swf == null )
            {
                swf = new StopWatchFactory( instantiateLog(logger) );
            }

            //
            //  Call the respective setXXX() methods of the logger
            //  based on the configuration.
            //
            if( components.length > 2 )
            {
                String setting = components[2];

                String method = "set"+Character.toUpperCase(setting.charAt(0))+setting.substring(1);

                try
                {
                    SetterUtil.set( swf.getLog(), method, (String)c_config.get(key) );
                }
                catch( NoSuchMethodException e1 )
                {
                    log.warn("An unknown setting {} for logger {}, wasn't able to find {}.{}.  Continuing nevertheless.",
                             new Object[] {setting, logger, logger, method} );
                }
                catch (Exception e1)
                {
                    throw new ConfigurationException(e1);
                }
            }

            c_factories.put(logger, swf);
        }
    }
251140
public SslContextBuilder trustManager(InputStream trustCertCollectionInputStream) {
        try {
            return trustManager(SslContext.toX509Certificates(trustCertCollectionInputStream));
        } catch (Exception e) {
            throw new IllegalArgumentException("Input stream does not contain valid certificates.", e);
        }
    }
500143
public static WxCpXmlMessage fromEncryptedXml(
      String encryptedXml,
      WxCpConfigStorage wxCpConfigStorage,
      String timestamp, String nonce, String msgSignature) {
    WxCpCryptUtil cryptUtil = new WxCpCryptUtil(wxCpConfigStorage);
    String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml);
    return fromXml(plainText);
  }