Example usage for org.w3c.dom Element getAttributeNodeNS

List of usage examples for org.w3c.dom Element getAttributeNodeNS

Introduction

In this page you can find the example usage for org.w3c.dom Element getAttributeNodeNS.

Prototype

public Attr getAttributeNodeNS(String namespaceURI, String localName) throws DOMException;

Source Link

Document

Retrieves an Attr node by local name and namespace URI.

Usage

From source file:edu.internet2.middleware.psp.spring.BaseSpmlProviderBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element configElement, ParserContext parserContext, BeanDefinitionBuilder builder) {
    super.doParse(configElement, parserContext, builder);

    String id = configElement.getAttributeNS(null, "id");
    builder.addPropertyValue("id", id);

    if (configElement.hasAttributeNS(null, "logSpml")) {
        Attr attr = configElement.getAttributeNodeNS(null, "logSpml");
        builder.addPropertyValue("logSpml", XMLHelper.getAttributeValueAsBoolean(attr));
    }/*from w  w  w .  j  ava2 s  .  c o  m*/

    if (configElement.hasAttributeNS(null, "pathToOutputFile")) {
        String pathToOutputFile = configElement.getAttributeNS(null, "pathToOutputFile");
        builder.addPropertyValue("pathToOutputFile", pathToOutputFile);
    }

    if (configElement.hasAttributeNS(null, "writeRequests")) {
        Attr attr = configElement.getAttributeNodeNS(null, "writeRequests");
        builder.addPropertyValue("writeRequests", XMLHelper.getAttributeValueAsBoolean(attr));
    }

    if (configElement.hasAttributeNS(null, "writeResponses")) {
        Attr attr = configElement.getAttributeNodeNS(null, "writeResponses");
        builder.addPropertyValue("writeResponses", XMLHelper.getAttributeValueAsBoolean(attr));
    }
}

From source file:edu.internet2.middleware.shibboleth.common.config.security.saml.MessageReplayRuleBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element element, BeanDefinitionBuilder builder) {
    builder.addConstructorArgReference(// ww  w .j a v  a 2 s.c o m
            DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "replayCacheRef")));

    if (element.hasAttributeNS(null, "required")) {
        builder.addPropertyValue("requiredRule",
                XMLHelper.getAttributeValueAsBoolean(element.getAttributeNodeNS(null, "required")));
    } else {
        builder.addPropertyValue("requiredRule", true);
    }

}

From source file:edu.internet2.middleware.shibboleth.common.config.metadata.SignatureValidationFilterBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element element, BeanDefinitionBuilder builder) {
    builder.addConstructorArgReference(//from   ww w  .j  a va  2s.co  m
            DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "trustEngineRef")));

    if (element.hasAttributeNS(null, "requireSignedMetadata")) {
        builder.addPropertyValue("requireSignature", XMLHelper
                .getAttributeValueAsBoolean(element.getAttributeNodeNS(null, "requireSignedMetadata")));
    } else {
        builder.addPropertyValue("requireSignature", false);
    }
}

From source file:uk.org.ukfederation.mdrpi.filter.RegistrationAuthorityMatcherParser.java

/** {@inheritDoc} */
protected void doParse(Element configElement, ParserContext parserContext, BeanDefinitionBuilder builder) {

    super.doParse(configElement, parserContext, builder);

    boolean matchIfSilent = false;
    if (configElement.hasAttributeNS(null, MATCH_IF_METADATA_SILENT_ATTR_NAME)) {
        matchIfSilent = XMLHelper.getAttributeValueAsBoolean(
                configElement.getAttributeNodeNS(null, MATCH_IF_METADATA_SILENT_ATTR_NAME));
    }//from   w w w  . j a  v  a  2s.  c o m
    log.debug("MDRPI Filter: Match if Metadata silent = {}", matchIfSilent);
    builder.addPropertyValue("matchIfMetadataSilent", matchIfSilent);

    final Attr attr = configElement.getAttributeNodeNS(null, REGISTRARS_ATTR_NAME);
    if (attr != null) {
        final List<String> issuers = XMLHelper.getAttributeValueAsList(attr);
        log.debug("MDRPI Filter: Issuers = {}", issuers);
        builder.addPropertyValue("issuers", issuers);
    }
}

From source file:edu.internet2.middleware.shibboleth.common.config.attribute.filtering.match.basic.AbstractStringMatchFunctorBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element configElement, BeanDefinitionBuilder builder) {
    super.doParse(configElement, builder);

    builder.addPropertyValue("matchString",
            DatatypeHelper.safeTrimOrNullString(configElement.getAttributeNS(null, "value")));

    boolean ignoreCase = false;
    if (configElement.hasAttributeNS(null, "ignoreCase")) {
        ignoreCase = XMLHelper.getAttributeValueAsBoolean(configElement.getAttributeNodeNS(null, "ignoreCase"));
    }/*from  w w  w .  j a va 2 s  .c  o  m*/
    builder.addPropertyValue("caseSensitive", !ignoreCase);
}

From source file:edu.internet2.middleware.shibboleth.common.config.security.AbstractX509CredentialBeanDefinitionParser.java

/**
 * Parses the certificates from the credential configuration.
 * /*from  w w  w.  j a va 2 s .  c o  m*/
 * @param configChildren children of the credential element
 * @param builder credential build
 */
protected void parseCertificates(Map<QName, List<Element>> configChildren, BeanDefinitionBuilder builder) {
    List<Element> certElems = configChildren.get(new QName(SecurityNamespaceHandler.NAMESPACE, "Certificate"));
    if (certElems == null || certElems.isEmpty()) {
        return;
    }

    log.debug("Parsing x509 credential certificates");
    ArrayList<X509Certificate> certs = new ArrayList<X509Certificate>();
    byte[] encodedCert;
    Collection<X509Certificate> decodedCerts;
    for (Element certElem : certElems) {
        encodedCert = getEncodedCertificate(DatatypeHelper.safeTrimOrNullString(certElem.getTextContent()));
        if (encodedCert == null) {
            continue;
        }

        boolean isEntityCert = false;
        Attr entityCertAttr = certElem.getAttributeNodeNS(null, "entityCertificate");
        if (entityCertAttr != null) {
            isEntityCert = XMLHelper.getAttributeValueAsBoolean(entityCertAttr);
        }
        if (isEntityCert) {
            log.debug("Element config flag found indicating entity certificate");
        }

        try {
            decodedCerts = X509Util.decodeCertificate(encodedCert);
            certs.addAll(decodedCerts);
            if (isEntityCert) {
                if (decodedCerts.size() == 1) {
                    builder.addPropertyValue("entityCertificate", decodedCerts.iterator().next());
                } else {
                    throw new FatalBeanException(
                            "Config element indicated an entityCertificate, but multiple certs where decoded");
                }
            }
        } catch (CertificateException e) {
            throw new FatalBeanException("Unable to create X509 credential, unable to parse certificates", e);
        }
    }

    builder.addPropertyValue("certificates", certs);
}

From source file:edu.internet2.middleware.shibboleth.idp.config.profile.authn.ExternalAuthnSystemLoginHandlerBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element config, BeanDefinitionBuilder builder) {
    super.doParse(config, builder);

    builder.addPropertyValue("externalAuthnPath",
            DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "externalAuthnPath")));

    if (config.hasAttributeNS(null, "supportsForcedAuthentication")) {
        builder.addPropertyValue("supportsForcedAuthentication", XMLHelper
                .getAttributeValueAsBoolean(config.getAttributeNodeNS(null, "supportsForcedAuthentication")));
    } else {//w w  w  .j a v  a 2 s .  c o m
        builder.addPropertyValue("supportsForcedAuthentication", false);
    }

    if (config.hasAttributeNS(null, "supportsPassiveAuthentication")) {
        builder.addPropertyValue("supportsPassiveAuthentication", XMLHelper
                .getAttributeValueAsBoolean(config.getAttributeNodeNS(null, "supportsPassiveAuthentication")));
    } else {
        builder.addPropertyValue("supportsPassiveAuthentication", false);
    }
}

From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.attributeDefinition.MappedAttributeDefinitionBeanDefinitionParser.java

/**
 * Process the value map elements.//from  w  w w.  j a  v  a2s .co  m
 * 
 * @param pluginId ID of this data connector
 * @param pluginConfigChildren configuration elements
 * @param pluginBuilder the bean definition parser
 * 
 * @return the list of value maps
 */
protected List<ValueMap> processValueMaps(String pluginId, Map<QName, List<Element>> pluginConfigChildren,
        BeanDefinitionBuilder pluginBuilder) {
    List<ValueMap> maps = new ArrayList<ValueMap>(5);

    ValueMap valueMap;
    String returnValue;
    String sourceValue;
    boolean ignoreCase;
    boolean partialMatch;
    if (pluginConfigChildren.containsKey(VALUEMAP_ELEMENT_NAME)) {
        for (Element valueMapElem : pluginConfigChildren.get(VALUEMAP_ELEMENT_NAME)) {
            valueMap = new ValueMap();

            Map<QName, List<Element>> children = XMLHelper.getChildElements(valueMapElem);

            if (children.containsKey(RETURN_VALUE_ELEMENT_NAME)) {
                List<Element> returnValueElems = children.get(RETURN_VALUE_ELEMENT_NAME);
                returnValue = DatatypeHelper.safeTrimOrNullString(returnValueElems.get(0).getTextContent());
                valueMap.setReturnValue(returnValue);
            }

            if (children.containsKey(SOURCE_VALUE_ELEMENT_NAME)) {
                for (Element sourceValueElem : children.get(SOURCE_VALUE_ELEMENT_NAME)) {
                    sourceValue = DatatypeHelper.safeTrim(sourceValueElem.getTextContent());

                    if (sourceValueElem.hasAttributeNS(null, "ignoreCase")) {
                        ignoreCase = XMLHelper.getAttributeValueAsBoolean(
                                sourceValueElem.getAttributeNodeNS(null, "ignoreCase"));
                    } else {
                        ignoreCase = false;
                    }

                    if (sourceValueElem.hasAttributeNS(null, "partialMatch")) {
                        partialMatch = XMLHelper.getAttributeValueAsBoolean(
                                sourceValueElem.getAttributeNodeNS(null, "partialMatch"));
                    } else {
                        partialMatch = false;
                    }

                    valueMap.getSourceValues()
                            .add(valueMap.new SourceValue(sourceValue, ignoreCase, partialMatch));
                }
            }

            maps.add(valueMap);
        }
    }

    return maps;
}

From source file:de.fhg.iais.cortex.services.ingest.worker.BinaryResolutionWorker.java

private CortexModel replaceLocalUrisInEDM(CortexModel model, String itemId) {
    if ((model == null) || (model.getAny().size() < 1)) {
        return model;
    }/*w  ww. j  a va 2s  .co m*/

    Element rdf = model.getAny().get(0);
    if (rdf != null) {
        //replace in edm model
        Element aggregation = (Element) rdf
                .getElementsByTagNameNS(GlobalConstants.ORE_NAMESPACE_URI, "Aggregation").item(0);
        if (aggregation != null) {
            Element thumbnail = (Element) aggregation
                    .getElementsByTagNameNS(GlobalConstants.EDM_NAMESPACE_URI, "object").item(0);
            if (thumbnail != null) {
                if (thumbnail.getAttributeNS(GlobalConstants.RDF_NAMESPACE_URI, Parser.RESOURCE) != null) {
                    Attr attr = thumbnail.getAttributeNodeNS(GlobalConstants.RDF_NAMESPACE_URI,
                            Parser.RESOURCE);
                    String href = attr.getValue();
                    String value = amendRelativeUris(itemId, href);
                    attr.setNodeValue(value);
                }
            }
        } else {
            throw new DbcException(
                    "Ingest failed: " + itemId + " has no ore:Aggregation. Please check your Mappings.");
        }
    }

    return model;
}

From source file:edu.internet2.middleware.shibboleth.common.config.service.AbstractServiceBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element configElement, ParserContext parserContext, BeanDefinitionBuilder builder) {
    List<Element> configurationResources = XMLHelper.getChildElementsByTagNameNS(configElement,
            ServiceNamespaceHandler.NAMESPACE, "ConfigurationResource");
    builder.addPropertyValue("serviceConfigurations",
            SpringConfigurationUtils.parseInnerCustomElements(configurationResources, parserContext));

    builder.addDependsOn("shibboleth.LogbackLogging");
    for (String dependency : XMLHelper
            .getAttributeValueAsList(configElement.getAttributeNodeNS(null, "depends-on"))) {
        builder.addDependsOn(dependency);
    }/*from   w w  w  . j  a va2s  .  c o m*/

    builder.setInitMethodName("initialize");
}