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:Main.java

/**
 * The method returns attribute node by the given qname.
 * /* w w w. j  av a2 s .c o m*/
 * @param el owner element.
 * @param attributeName QName of the attribute node to be searched.
 * @return attribute node by the given qname.
 */
static public Attr getAttribute(Element el, QName attributeName) {
    if (el == null)
        throw new IllegalArgumentException("Element can not be NULL");
    if (attributeName == null)
        throw new IllegalArgumentException("Attribute name can not be NULL");
    String nsURI = attributeName.getNamespaceURI();
    String localPart = attributeName.getLocalPart();
    if (localPart == null)
        throw new IllegalArgumentException("Local part of the attribute name can not be NULL");

    Attr a = el.getAttributeNodeNS(nsURI, localPart);
    if (a == null)
        // try to get with null namespace
        a = el.getAttributeNodeNS(null, localPart);
    return a;
}

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

/** {@inheritDoc} */
protected void doParse(Element element, BeanDefinitionBuilder builder) {
    if (element.hasAttributeNS(null, "processEmptyCRLs")) {
        Attr attr = element.getAttributeNodeNS(null, "processEmptyCRLs");
        builder.addPropertyValue("processEmptyCRLs", XMLHelper.getAttributeValueAsBoolean(attr));
    }/*from   w  w w  .  ja  va 2s .  c  om*/

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

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

    if (element.hasAttributeNS(null, "defaultVerificationDepth")) {
        Integer depth = new Integer(
                DatatypeHelper.safeTrim(element.getAttributeNS(null, "defaultVerificationDepth")));
        builder.addPropertyValue("defaultVerificationDepth", depth);
    }

}

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

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

    if (element.hasAttributeNS(null, "forceRevocationEnabled")) {
        Attr attr = element.getAttributeNodeNS(null, "forceRevocationEnabled");
        builder.addPropertyValue("forceRevocationEnabled", XMLHelper.getAttributeValueAsBoolean(attr));
    }//from w  w  w.  j  av  a 2 s .co  m

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

}

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

/**
 * Gets the fail fast initialization requirement for the metadata provider.
 * /*from w  ww .  ja  v a 2s.com*/
 * @param config metadata provider config
 * 
 * @return fail fast initialization requirement for the metadata provider
 */
protected boolean getFailFastInitialization(Element config) {
    boolean failFastInit = true;
    if (config.hasAttributeNS(null, "failFastInitialization")) {
        failFastInit = XMLHelper
                .getAttributeValueAsBoolean(config.getAttributeNodeNS(null, "failFastInitialization"));
    }

    return failFastInit;
}

From source file:com.hazelcast.config.XmlConfigSchemaLocationTest.java

private String extractSchemaAttribute(InputStream documentStream) throws Exception {
    DocumentBuilder parser = documentBuilderFactory.newDocumentBuilder();
    Document document = parser.parse(documentStream);

    Element item = document.getDocumentElement();
    if (item == null) {
        return null;
    }//w w w  .j a va2  s  .c  o m
    Attr schemaAttr = item.getAttributeNodeNS(XML_SCHEMA_NAMESPACE, XML_SCHEMA_LOCATION_ATTRIBUTE);
    if (schemaAttr == null) {
        return null;
    }
    return schemaAttr.getValue();
}

From source file:edu.internet2.middleware.assurance.mcb.config.profile.authn.MCBLoginHandlerBeanDefinitionParser.java

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

    if (config.hasAttributeNS(null, "previousSession")) {
        builder.addPropertyValue("previousSession",
                XMLHelper.getAttributeValueAsBoolean(config.getAttributeNodeNS(null, "previousSession")));
    } else {//ww w .j av  a2s. c  o  m
        builder.addPropertyValue("previousSession", false);
    }

    if (config.hasAttributeNS(null, "depends-on")) {
        builder.addPropertyValue("dependsOn",
                DatatypeHelper.safeTrim(config.getAttributeNS(null, "depends-on")));
    } else {
        builder.addPropertyValue("dependsOn", null);
    }

}

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

/**
 * Gets the valid metadata requirement for the metadata provider.
 * //from   ww w  . j  a va2s.  c  o m
 * @param config metadata provider configuration
 * 
 * @return valid metadata requirement for the metadata provider
 */
protected boolean getRequireValidMetadata(Element config) {
    boolean requireValidMetadata = true;

    if (config.hasAttributeNS(null, "maintainExpiredMetadata")) {
        boolean maintainedExpiredMetadata = XMLHelper
                .getAttributeValueAsBoolean(config.getAttributeNodeNS(null, "maintainExpiredMetadata"));
        requireValidMetadata = !maintainedExpiredMetadata;
        log.warn(
                "Use of metadata provider configuration attribute 'maintainExpiredMetadata' is deprecated.  Use requireValidMetadata=\"{}\" instead.",
                requireValidMetadata);
    }

    if (config.hasAttributeNS(null, "requireValidMetadata")) {
        requireValidMetadata = XMLHelper
                .getAttributeValueAsBoolean(config.getAttributeNodeNS(null, "requireValidMetadata"));
    }

    return requireValidMetadata;
}

From source file:edu.internet2.middleware.shibboleth.common.config.relyingparty.saml.ShibbolethSSOProfileConfigurationBeanDefinitionParser.java

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

    if (element.hasAttributeNS(null, "includeAttributeStatement")) {
        builder.addPropertyValue("includeAttributeStatement", XMLHelper
                .getAttributeValueAsBoolean(element.getAttributeNodeNS(null, "includeAttributeStatement")));
    } else {/*from  www .jav  a 2s  .  co  m*/
        builder.addPropertyValue("includeAttributeStatement", false);
    }
}

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

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

    builder.setInitMethodName("initialize");

    ArrayList<String> services = new ArrayList<String>();
    for (String dependency : XMLHelper
            .getAttributeValueAsList(configElement.getAttributeNodeNS(null, "depends-on"))) {
        services.add(dependency);/*from w  w w .j  a  v a  2s  .  co  m*/
    }
    builder.addConstructorArgValue(services);
}

From source file:edu.internet2.middleware.shibboleth.common.config.relyingparty.saml.SAML2SSOProfileConfigurationBeanDefinitionParser.java

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

    if (element.hasAttributeNS(null, "includeAttributeStatement")) {
        builder.addPropertyValue("includeAttributeStatement", XMLHelper
                .getAttributeValueAsBoolean(element.getAttributeNodeNS(null, "includeAttributeStatement")));
    } else {/*from  w w w .  j a v  a 2 s  . co  m*/
        builder.addPropertyValue("includeAttributeStatement", true);
    }

    if (element.hasAttributeNS(null, "maximumSPSessionLifetime")) {
        long lifetime = SpringConfigurationUtils.parseDurationToMillis(
                "'maximumSPSessionLifetime' on profile configuration of type " + XMLHelper.getXSIType(element),
                element.getAttributeNS(null, "maximumSPSessionLifetime"), 0);
        builder.addPropertyValue("maximumSPSessionLifetime", lifetime);
    }
}