/** * Unmarshal the handler-chains xml file. * * @param in the input stream of the file * @return ServiceReferenceHandlerChainsMetaData * @throws JBossXBException */ protected ServiceReferenceHandlerChainsMetaData unmarshall(InputStream in) throws JBossXBException { if(in == null) throw new IllegalArgumentException("InputStream may not be null."); Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller(); return (ServiceReferenceHandlerChainsMetaData) unmarshaller.unmarshal(in, resolver); }
/** * <p> * Creates and return an {@code ACLConfiguration} object using the specified input stream to read the ACL * configuration file. * </p> * * @param aclConfigFileStream an {@code InputStream} that reads the contents of the ACL configuration file. * @return the constructed {@code ACLConfiguration} object that contains the configured ACLs. */ public static ACLConfiguration getConfiguration(InputStream aclConfigFileStream) { ClassLoader tcl = Thread.currentThread().getContextClassLoader(); SchemaBinding schema = XsdBinder.bind(tcl.getResourceAsStream(schemaName), null); Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller(); try { ACLConfiguration configuration = (ACLConfiguration) unmarshaller.unmarshal(aclConfigFileStream, schema); return configuration; } catch (JBossXBException e) { log.debug("Error parsing ACL configuration file", e); throw new RuntimeException(e); } } }
/** * Parse bootstrap metadata from the given url * * @param url the url * @return the bootstrap metadata */ public static BootstrapMetaData parse(URL url) { if (url == null) throw new IllegalArgumentException("Null url"); UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); try { BootstrapMetaData result = (BootstrapMetaData) unmarshaller.unmarshal(url.toString(), new BootstrapSchemaBinding()); if (result == null) throw new IllegalStateException("The bootsrap xml " + url + " is not well formed"); return result; } catch (Exception e) { throw new RuntimeException("Error unmarshalling " + url, e); } } }
/** * Parse bootstrap metadata from the given url * * @param url the url * @return the bootstrap metadata */ public static BootstrapMetaData parse(URL url) { if (url == null) throw new IllegalArgumentException("Null url"); UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); try { BootstrapMetaData result = (BootstrapMetaData) unmarshaller.unmarshal(url.toString(), new BootstrapSchemaBinding()); if (result == null) throw new IllegalStateException("The bootsrap xml " + url + " is not well formed"); return result; } catch (Exception e) { throw new RuntimeException("Error unmarshalling " + url, e); } } }
public Object getValue(ServiceValueContext valueContext) throws Exception { // Get the attribute element content in a parsable form StringBuffer buffer = ServiceConfigurator.getElementContent(getElement()); Thread current = Thread.currentThread(); ClassLoader oldTcl = current.getContextClassLoader(); ClassLoader cl = valueContext.getClassloader(); if (cl != null) current.setContextClassLoader(cl); try { // Parse the attribute element content SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver(); Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller(); StringReader reader = new StringReader(buffer.toString()); return unmarshaller.unmarshal(reader, resolver); } finally { if (cl != null) current.setContextClassLoader(oldTcl); } } }
/** Unmrashall the webservices.xml if there is one */ protected WebservicesMetaData getWebservicesMetaData(DeploymentInfo unit, String wsFile) { WebservicesMetaData wsMetaData = (WebservicesMetaData)unit.context.get(WebservicesMetaData.class); UnifiedVirtualFile vfWebservices = getWebservicesFile(unit, wsFile); if (wsMetaData == null && vfWebservices != null) { try { URL wsURL = vfWebservices.toURL(); Element root = DOMUtils.parse(wsURL.openStream()); String namespaceURI = root.getNamespaceURI(); if (namespaceURI.equals("http://java.sun.com/xml/ns/j2ee")) { Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller(); ObjectModelFactory factory = new WebservicesFactory(wsURL); wsMetaData = (WebservicesMetaData)unmarshaller.unmarshal(wsURL.openStream(), factory, null); unit.context.put(WebservicesMetaData.class, wsMetaData); } } catch (Exception ex) { throw new WSFDeploymentException(ex); } } return wsMetaData; }
public Object getValue(ServiceValueContext valueContext) throws Exception { // Get the attribute element content in a parsable form StringBuffer buffer = ServiceConfigurator.getElementContent(getElement()); Thread current = Thread.currentThread(); ClassLoader oldTcl = current.getContextClassLoader(); ClassLoader cl = valueContext.getClassloader(); if (cl != null) current.setContextClassLoader(cl); try { // Parse the attribute element content SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver(); Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller(); StringReader reader = new StringReader(buffer.toString()); Object bean = unmarshaller.unmarshal(reader, resolver); return bean; } finally { if (cl != null) current.setContextClassLoader(oldTcl); } } }
/** Unmrashall the webservices.xml if there is one */ protected WebservicesMetaData getWebservicesMetaData(DeploymentInfo unit, String wsFile) { WebservicesMetaData wsMetaData = (WebservicesMetaData)unit.context.get(WebservicesMetaData.class); UnifiedVirtualFile vfWebservices = getWebservicesFile(unit, wsFile); if (wsMetaData == null && vfWebservices != null) { try { URL wsURL = vfWebservices.toURL(); Element root = DOMUtils.parse(wsURL.openStream()); String namespaceURI = root.getNamespaceURI(); if (namespaceURI.equals("http://java.sun.com/xml/ns/j2ee")) { Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller(); ObjectModelFactory factory = new WebservicesFactory(wsURL); wsMetaData = (WebservicesMetaData)unmarshaller.unmarshal(wsURL.openStream(), factory, null); unit.context.put(WebservicesMetaData.class, wsMetaData); } } catch (Exception ex) { throw new WSFDeploymentException(ex); } } return wsMetaData; }
public static ApplicationClientDD parse(URL ddResource) throws JBossXBException, IOException { if (ddResource == null) return null; log.debug("found application-client.xml " + ddResource); ApplicationClientDDObjectFactory factory = new ApplicationClientDDObjectFactory(); UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setEntityResolver(new JBossEntityResolver()); unmarshaller.setNamespaceAware(true); unmarshaller.setSchemaValidation(true); unmarshaller.setValidation(true); ApplicationClientDD dd = (ApplicationClientDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null); return dd; }
public static ApplicationClientDD parse(URL ddResource) throws JBossXBException, IOException { if (ddResource == null) return null; log.debug("found application-client.xml " + ddResource); ApplicationClientDDObjectFactory factory = new ApplicationClientDDObjectFactory(); UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setEntityResolver(new JBossEntityResolver()); unmarshaller.setNamespaceAware(true); unmarshaller.setSchemaValidation(true); unmarshaller.setValidation(true); ApplicationClientDD dd = (ApplicationClientDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null); return dd; }
public static final XsdAnnotation unmarshal(String annotation) { Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller(); unmarshaller.mapFactoryToNamespace(JaxbObjectModelFactory.INSTANCE, Constants.NS_JAXB); unmarshaller.mapFactoryToNamespace(JbxbObjectModelFactory.INSTANCE, Constants.NS_JBXB); try { return (XsdAnnotation)unmarshaller.unmarshal(new StringReader(annotation), XsdObjectModelFactory.INSTANCE, (Object)null ); } catch(JBossXBException e) { throw new JBossXBRuntimeException("Failed to parse annotation string: " + annotation + ": " + e.getMessage(), e ); } }
/** Unmrashall the webservices.xml if there is one */ protected WebservicesMetaData getWebservicesMetaData(DeploymentUnit unit) { WebservicesMetaData wsMetaData = unit.getAttachment(WebservicesMetaData.class); UnifiedVirtualFile vfWebservices = getWebservicesFile(unit); if (wsMetaData == null && vfWebservices != null) { try { URL wsURL = vfWebservices.toURL(); Element root = DOMUtils.parse(wsURL.openStream()); String namespaceURI = root.getNamespaceURI(); if (namespaceURI.equals("http://java.sun.com/xml/ns/j2ee")) { Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller(); ObjectModelFactory factory = new WebservicesFactory(wsURL); wsMetaData = (WebservicesMetaData)unmarshaller.unmarshal(wsURL.openStream(), factory, null); unit.addAttachment(WebservicesMetaData.class, wsMetaData); } } catch (Exception ex) { throw new WSFDeploymentException(ex); } } return wsMetaData; }
public static EjbJarDD parse(URL ddResource) throws JBossXBException, IOException { ObjectModelFactory factory = null; Unmarshaller unmarshaller = null; EjbJarDD dd = null; if (ddResource != null) { log.debug("found ejb-jar.xml " + ddResource); factory = new EjbJarDDObjectFactory(); UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance(); unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setEntityResolver(new JBossEntityResolver()); unmarshaller.setNamespaceAware(true); unmarshaller.setSchemaValidation(true); unmarshaller.setValidation(true); dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null); } return dd; }
public static EjbJarDD parse(URL ddResource) throws JBossXBException, IOException { ObjectModelFactory factory = null; Unmarshaller unmarshaller = null; EjbJarDD dd = null; if (ddResource != null) { log.debug("found ejb-jar.xml " + ddResource); factory = new EjbJarDDObjectFactory(); UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance(); unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setEntityResolver(new JBossEntityResolver()); unmarshaller.setNamespaceAware(true); unmarshaller.setSchemaValidation(true); unmarshaller.setValidation(true); dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null); } return dd; }
public static ApplicationClientDD parse(URL ddResource, ApplicationClientDD dd) throws JBossXBException, IOException { // TODO: how to properly fix this if (dd == null) dd = new ApplicationClientDD(); if (ddResource == null) return dd; log.debug("found jboss-client.xml " + ddResource); JBossClientDDObjectFactory factory = new JBossClientDDObjectFactory(dd); UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setEntityResolver(new JBossEntityResolver()); unmarshaller.setNamespaceAware(true); unmarshaller.setSchemaValidation(true); unmarshaller.setValidation(true); dd = (ApplicationClientDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null); return dd; }
public static ApplicationClientDD parse(URL ddResource, ApplicationClientDD dd) throws JBossXBException, IOException { // TODO: how to properly fix this if (dd == null) dd = new ApplicationClientDD(); if (ddResource == null) return dd; log.debug("found jboss-client.xml " + ddResource); JBossClientDDObjectFactory factory = new JBossClientDDObjectFactory(dd); UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setEntityResolver(new JBossEntityResolver()); unmarshaller.setNamespaceAware(true); unmarshaller.setSchemaValidation(true); unmarshaller.setValidation(true); dd = (ApplicationClientDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null); return dd; }
public static EjbJarDD parse(URL ddResource, EjbJarDD dd) throws JBossXBException, IOException { ObjectModelFactory factory = null; Unmarshaller unmarshaller = null; if (ddResource != null) { log.debug("found jboss.xml " + ddResource); if (dd == null) dd = new EjbJarDD(); factory = new JBossDDObjectFactory(dd); UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance(); unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setEntityResolver(new JBossEntityResolver()); unmarshaller.setNamespaceAware(true); unmarshaller.setSchemaValidation(true); unmarshaller.setValidation(true); dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null); } return dd; }
public static EjbJarDD parse(URL ddResource, EjbJarDD dd) throws JBossXBException, IOException { ObjectModelFactory factory = null; Unmarshaller unmarshaller = null; if (ddResource != null) { log.debug("found jboss.xml " + ddResource); if (dd == null) dd = new EjbJarDD(); factory = new JBossDDObjectFactory(dd); UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance(); unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setEntityResolver(new JBossEntityResolver()); unmarshaller.setNamespaceAware(true); unmarshaller.setSchemaValidation(true); unmarshaller.setValidation(true); dd = (EjbJarDD)unmarshaller.unmarshal(ddResource.openStream(), factory, null); } return dd; }
/** * Unmarshal XML data from the specified InputStream and return the resulting content tree. */ public Object unmarshal(InputStream is) throws UnmarshalException { assertRequiredProperties(); org.jboss.xb.binding.Unmarshaller unm = UnmarshallerFactory.newInstance().newUnmarshaller(); SchemaBinding schemaBinding = JBossXBSupport.getOrCreateSchemaBinding(properties); try { return unm.unmarshal(is, schemaBinding); } catch (JBossXBException e) { throw new UnmarshalException(e.getMessage(), e); } }
public void parse(URL loginConfigURL, ArrayList<String> configNames) throws Exception { LoginConfigObjectModelFactory lcomf = new SecurityConfigObjectModelFactory(); UsersObjectModelFactory uomf = new UsersObjectModelFactory(); InputStreamReader xmlReader = loadURL(loginConfigURL); Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller(); unmarshaller.mapFactoryToNamespace(uomf, "http://www.jboss.org/j2ee/schemas/XMLLoginModule"); Object root = null; PolicyConfig config = (PolicyConfig) unmarshaller.unmarshal(xmlReader, lcomf, root); Set<String> cnames = config.getConfigNames(); configNames.addAll(cnames); xmlConfig.copy(config); // Add the config to SecurityConfiguration for (String cname : cnames) { ApplicationPolicy ap = config.get(cname); SecurityConfiguration.addApplicationPolicy(ap); handleJASPIDelegation(ap); } }