org.apache.axis2.util.XMLUtils Java Examples

The following examples show how to use org.apache.axis2.util.XMLUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MicroIntegratorBaseUtils.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private static String getPropertyFromAxisConf(String parameter) throws IOException, XMLStreamException {

        try (InputStream file = new FileInputStream(Paths.get(getCarbonConfigDirPath(), "axis2",
                "axis2.xml").toString())) {
            if (axis2Config == null) {
                OMElement element = (OMElement) XMLUtils.toOM(file);
                element.build();
                axis2Config = element;
            }
            Iterator parameters = axis2Config.getChildrenWithName(new QName("parameter"));
            while (parameters.hasNext()) {
                OMElement parameterElement = (OMElement) parameters.next();
                if (parameter.equals(parameterElement.getAttribute(new QName("name")).getAttributeValue())) {
                    return parameterElement.getText();
                }
            }
            return null;
        } catch (IOException | XMLStreamException e) {
            throw e;
        }
    }
 
Example #2
Source File: CarbonContextDataHolder.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private static void setupAuthenticator(CarbonAuthenticator authenticator) throws Exception {
    OMElement documentElement = XMLUtils.toOM(
            MicroIntegratorBaseUtils.getServerConfiguration().getDocumentElement());
    OMElement authenticators = documentElement.getFirstChildWithName(
            new QName(Constants.CARBON_SERVER_XML_NAMESPACE, "Security")).
            getFirstChildWithName(
                    new QName(Constants.CARBON_SERVER_XML_NAMESPACE, "NetworkAuthenticatorConfig"));

    if (authenticators == null) {
        return;
    }

    for (Iterator iterator = authenticators.getChildElements(); iterator.hasNext(); ) {
        OMElement authenticatorElement = (OMElement) iterator.next();
        if (!authenticatorElement.getLocalName().equalsIgnoreCase("Credential")) {
            continue;
        }
        String pattern = authenticatorElement.getFirstChildWithName(
                new QName(Constants.CARBON_SERVER_XML_NAMESPACE, "Pattern")).getText();
        String type = authenticatorElement.getFirstChildWithName(
                new QName(Constants.CARBON_SERVER_XML_NAMESPACE, "Type")).getText();
        String username = authenticatorElement.getFirstChildWithName(
                new QName(Constants.CARBON_SERVER_XML_NAMESPACE, "Username")).getText();
        String password = authenticatorElement.getFirstChildWithName(
                new QName(Constants.CARBON_SERVER_XML_NAMESPACE, "Password")).getText();
        authenticator.addAuthenticator(type, pattern, username, password);
    }
}
 
Example #3
Source File: XMLUtil.java    From developer-studio with Apache License 2.0 4 votes vote down vote up
public static String getElementString(Element element) throws Exception {
	OMElement om = XMLUtils.toOM(element);
	return XMLUtil.prettify(om);
}