Example usage for org.w3c.dom Element getAttributeNS

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

Introduction

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

Prototype

public String getAttributeNS(String namespaceURI, String localName) throws DOMException;

Source Link

Document

Retrieves an attribute value by local name and namespace URI.

Usage

From source file:edu.umn.msi.tropix.common.xml.ObjectDeserializationContext.java

public ObjectDeserializationContext(final Element element, final Class javaClass) throws Exception {
    super(getContext(), new SOAPHandler());

    String typeAttr = element.getAttributeNS(Constants.URI_DEFAULT_SCHEMA_XSI, "type");

    QName type = null;// w w  w .  j a  v  a 2 s . co m

    if (typeAttr != null && typeAttr.length() > 0) {
        type = XMLUtils.getQNameFromString(typeAttr, element);
    }

    init(type, javaClass);

    String inputString = XMLUtils.ElementToString(element);
    LOGGER.debug(inputString);
    inputSource = new InputSource(new StringReader(inputString));
}

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

/** {@inheritDoc} */
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    log.info("Parsing configuration for {} trust engine with id: {}",
            XMLHelper.getXSIType(element).getLocalPart(), element.getAttributeNS(null, "id"));

    List<Element> childElems = XMLHelper.getChildElementsByTagNameNS(element,
            SecurityNamespaceHandler.NAMESPACE, "ValidationInfo");
    builder.addPropertyValue("PKIXInfo",
            SpringConfigurationUtils.parseInnerCustomElements(childElems, parserContext));

    childElems = XMLHelper.getChildElementsByTagNameNS(element, SecurityNamespaceHandler.NAMESPACE,
            "TrustedName");
    HashSet<String> trustedNames = new HashSet<String>(childElems.size());
    for (Element nameElem : childElems) {
        trustedNames.add(DatatypeHelper.safeTrimOrNullString(nameElem.getTextContent()));
    }//from w  w w  .  j a  va  2  s.c  o m
    builder.addPropertyValue("trustedNames", trustedNames);

    childElems = XMLHelper.getChildElementsByTagNameNS(element, SecurityNamespaceHandler.NAMESPACE,
            "ValidationOptions");
    if (childElems.size() > 0) {
        builder.addPropertyValue("PKIXValidationOptions",
                SpringConfigurationUtils.parseInnerCustomElement((Element) childElems.get(0), parserContext));
    }
}

From source file:edu.internet2.middleware.shibboleth.common.config.attribute.filtering.ShibbolethAttributeFilteringEngineBeanDefinitionParser.java

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

    log.info("Parsing configuration for attribute filtering engine {}",
            DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "id")));
}

From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.principalConnector.BasePrincipalConnectrBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(String pluginId, Element pluginConfig,
        java.util.Map<javax.xml.namespace.QName, java.util.List<Element>> pluginConfigChildren,
        BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) {

    pluginBuilder.addPropertyValue("nameIdFormat",
            pluginConfig.getAttributeNS(null, NAMEID_FORMAT_ATTRIBUTE_NAME));
}

From source file:edu.internet2.middleware.shibboleth.common.config.profile.JSPErrorHandlerBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element config, BeanDefinitionBuilder builder) {
    log.info("Parsing configuration for JSP error handler.");
    super.doParse(config, builder);

    if (config.hasAttributeNS(null, "jspPagePath")) {
        builder.addConstructorArgValue(config.getAttributeNS(null, "jspPagePath"));
    } else {/*from w  w w  . j  a  v a2 s  .c  om*/
        builder.addConstructorArgValue(config.getAttributeNS(null, "/error.jsp"));
    }
}

From source file:edu.internet2.middleware.shibboleth.idp.config.profile.saml1.ShibbolethSSOProfileHandlerBeanDefinitionParser.java

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

    if (config.hasAttributeNS(null, "authenticationManagerPath")) {
        builder.addConstructorArgValue(/*from   w w w  . jav a  2  s  . co m*/
                DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "authenticationManagerPath")));
    } else {
        builder.addConstructorArgValue("/AuthnEngine");
    }
}

From source file:jp.co.mokha.shibboleth.idp.testing.TestingLoginHandlerBeanDefinitionParser.java

protected void doParse(Element config, BeanDefinitionBuilder builder) {
    super.doParse(config, builder);

    if (config.hasAttributeNS(null, "authenticationServletURL")) {
        builder.addPropertyValue("authenticationServletURL",
                DatatypeHelper.safeTrim(config.getAttributeNS(null, "authenticationServletURL")));
    } else {//from ww  w  . j av  a  2 s. co  m
        builder.addPropertyValue("authenticationServletURL", "/Authn/TestingAuth");
    }
}

From source file:net.gfipm.shibboleth.config.GfipmBAEDataConnectorBeanDefinitionParser.java

/**
 * Parse attribute requirements/*from  w w  w  .  j a  v  a  2s  .c om*/
 *
 * @param elements DOM elements of type <code>Attribute</code>
 *
 * @return the attributes
 */
protected List<BAEAttributeNameMap> parseAttributes(List<Element> elements) {
    if (elements == null || elements.size() == 0) {
        return null;
    }
    List<BAEAttributeNameMap> mapAttributes = new Vector<BAEAttributeNameMap>();
    for (Element ele : elements) {
        BAEAttributeNameMap mapAttribute = new BAEAttributeNameMap();
        mapAttribute.QueryName = DatatypeHelper.safeTrimOrNullString(ele.getAttributeNS(null, "QueryName"));
        mapAttribute.ReturnName = DatatypeHelper.safeTrimOrNullString(ele.getAttributeNS(null, "ReturnName"));
        log.debug("BAE Attribute " + mapAttribute.QueryName + " will be returned as local attribute "
                + mapAttribute.ReturnName);
        mapAttributes.add(mapAttribute);
    }
    return mapAttributes;
}

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

/** {@inheritDoc} */
protected void doParse(String pluginId, Element pluginConfig, Map<QName, List<Element>> pluginConfigChildren,
        BeanDefinitionBuilder pluginBuilder, ParserContext parserContext) {

    String sourceAttributeId = pluginConfig.getAttributeNS(null, "sourceAttributeID");
    log.debug("Setting source attribute ID for attribute definition {} to: {}", pluginId, sourceAttributeId);
    pluginBuilder.addPropertyValue("sourceAttributeId", sourceAttributeId);

    List<Element> displayNames = pluginConfigChildren
            .get(new QName(AttributeResolverNamespaceHandler.NAMESPACE, "DisplayName"));
    if (displayNames != null) {
        log.debug("Setting {} display names for attribute definition {}", displayNames.size(), pluginId);
        pluginBuilder.addPropertyValue("displayNames", processLocalizedElement(displayNames));
    }/*from   w w w  .j  ava  2s. c  o m*/

    List<Element> displayDescriptions = pluginConfigChildren
            .get(new QName(AttributeResolverNamespaceHandler.NAMESPACE, "DisplayDescription"));
    if (displayDescriptions != null) {
        log.debug("Setting {} display descriptions for attribute definition {}", displayDescriptions.size(),
                pluginId);
        pluginBuilder.addPropertyValue("displayDescriptions", processLocalizedElement(displayDescriptions));
    }

    boolean dependencyOnly = false;
    if (pluginConfig.hasAttributeNS(null, "dependencyOnly")) {
        dependencyOnly = XMLHelper
                .getAttributeValueAsBoolean(pluginConfig.getAttributeNodeNS(null, "dependencyOnly"));
    }
    if (log.isDebugEnabled()) {
        log.debug("Attribute definition {} produces attributes that are only dependencies: {}", pluginId,
                dependencyOnly);
    }
    pluginBuilder.addPropertyValue("dependencyOnly", dependencyOnly);

    pluginBuilder.addPropertyValue("attributeEncoders", SpringConfigurationUtils
            .parseInnerCustomElements(pluginConfigChildren.get(ATTRIBUTE_ENCODER_ELEMENT_NAME), parserContext));
}

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

/**
 * Sets the HTTP proxy properties, if any, for the HTTP client used to fetch metadata.
 * /*from   ww  w  . j a  va  2  s . com*/
 * @param builder the HTTP client builder
 * @param config the metadata provider configuration
 * @param providerId the ID of the metadata provider
 */
protected void setHttpProxySettings(HttpClientBuilder builder, Element config, String providerId) {
    String proxyHost = DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "proxyHost"));
    if (proxyHost == null) {
        return;
    }
    log.debug("Metadata provider '{}' HTTP proxy host: {}", providerId, proxyHost);
    builder.setProxyHost(proxyHost);

    if (config.hasAttributeNS(null, "proxyPort")) {
        int proxyPort = Integer.parseInt(config.getAttributeNS(null, "proxyPort"));
        log.debug("Metadata provider '{}' HTTP proxy port: ", providerId, proxyPort);
        builder.setProxyPort(proxyPort);
    }

    String proxyUser = DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "proxyUser"));
    if (proxyUser != null) {
        log.debug("Metadata provider '{}' HTTP proxy username: ", providerId, proxyUser);
        builder.setProxyUsername(proxyUser);
        log.debug("Metadata provider '{}' HTTP proxy password not shown", providerId);
        builder.setProxyPassword(
                DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "proxyPassword")));
    }
}