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.internet2.middleware.shibboleth.common.config.attribute.resolver.AbstractResolutionPlugInBeanDefinitionParser.java

/**
 * Parses the plugins ID and attribute definition and data connector dependencies.
 * //  ww  w .  ja v a 2s  .c  o  m
 * {@inheritDoc}
 */
protected final void doParse(Element config, ParserContext parserContext, BeanDefinitionBuilder builder) {
    String pluginId = DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "id"));
    log.info("Parsing configuration for {} plugin with ID: {}", config.getLocalName(), pluginId);
    builder.addPropertyValue("pluginId", pluginId);

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

    List<String> dependencyIds = parseDependencies(children.get(DEPENDENCY_ELEMENT_NAME));
    if (dependencyIds != null && !dependencyIds.isEmpty()) {
        log.debug("Dependencies for plugin {}: {}", pluginId, dependencyIds);
        builder.addPropertyValue("dependencyIds", dependencyIds);
    } else {
        log.debug("Dependencies for plugin {}: none", pluginId);
    }

    doParse(pluginId, config, children, builder, parserContext);
}

From source file:edu.internet2.middleware.shibboleth.common.config.resource.HttpResourceBeanDefinitionParser.java

/** {@inheritDoc} */
protected String resolveId(Element configElement, AbstractBeanDefinition beanDefinition,
        ParserContext parserContext) {//w  ww.ja v a  2 s  . com
    return HttpResource.class.getName() + ":"
            + DatatypeHelper.safeTrimOrNullString(configElement.getAttributeNS(null, "url"));
}

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

/**
 * Parse the credential element attributes.
 * /*from  ww w . j a v a2 s. co  m*/
 * @param element credential element
 * @param builder bean definition builder
 */
protected void parseAttributes(Element element, BeanDefinitionBuilder builder) {
    String usage = DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "usage"));
    if (usage != null) {
        builder.addPropertyValue("usageType", UsageType.valueOf(usage.toUpperCase()));
    } else {
        builder.addPropertyValue("usageType", UsageType.UNSPECIFIED);
    }

    String entityID = DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "entityID"));
    if (entityID != null) {
        builder.addPropertyValue("entityID", entityID);
    }
}

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

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

    String username = DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "username"));
    if (username == null) {
        String msg = "No username specified.";
        log.error(msg);/*from w  ww. j a v a2s  .  co m*/
        throw new BeanCreationException(msg);
    }
    log.debug("authenticated username: {}", username);
    builder.addPropertyValue("authenticatedUser", username);

    List<IPRange> ranges = getIPRanges(config);
    log.debug("registered IP ranges: {}", ranges.size());
    builder.addPropertyValue("ipRanges", ranges);

    boolean defaultDeny = XMLHelper.getAttributeValueAsBoolean(config.getAttributeNodeNS(null, "defaultDeny"));
    log.debug("default deny: {}", defaultDeny);
    builder.addPropertyValue("ipInRangeIsAuthenticated", defaultDeny);
}

From source file:edu.internet2.middleware.shibboleth.common.config.resource.ClasspathResourceBeanDefinitionParser.java

/** {@inheritDoc} */
protected String resolveId(Element configElement, AbstractBeanDefinition beanDefinition,
        ParserContext parserContext) {/*from  w ww  . j  a  v a  2s.c o m*/
    return ClasspathResource.class.getName() + ":"
            + DatatypeHelper.safeTrimOrNullString(configElement.getAttributeNS(null, "file"));
}

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

/**
 * Gets the default parser pool reference for the metadata provider.
 * /*www  .  java  2 s  .  co m*/
 * @param config metadata provider configuration element
 * 
 * @return parser pool reference
 */
protected String getParserPoolRef(Element config) {
    String parserPoolRef = null;
    if (config.hasAttributeNS(null, "parerPoolRef")) {
        parserPoolRef = DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "parserPoolRef"));
    }

    if (parserPoolRef == null) {
        parserPoolRef = "shibboleth.ParserPool";
    }

    return parserPoolRef;
}

From source file:it.garr.shibboleth.idp.config.profile.authn.AmazonS3BeanDefinitionParser.java

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

    log.debug("Parsing AmazonS3BeanDefinitionParser. authenticationServletURL="
            + DatatypeHelper.safeTrim(config.getAttributeNS(null, "authenticationServletURL")));
    builder.addPropertyValue("authenticationServletURL",
            DatatypeHelper.safeTrim(config.getAttributeNS(null, "authenticationServletURL")));
}

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

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

    builder.addConstructorArgReference(config.getAttributeNS(null, "velocityEngine"));

    if (config.hasAttributeNS(null, "errorTemplatePath")) {
        builder.addConstructorArgValue(config.getAttributeNS(null, "errorTemplatePath"));
    } else {/*from   ww  w . j  av a  2 s .c  om*/
        builder.addConstructorArgValue(config.getAttributeNS(null, "/error.vm"));
    }
}

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. ja v a 2s . c  om
        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.filtering.match.basic.NumOfAttributeValuesMatchFunctorBeanDefinitionParser.java

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

    builder.addConstructorArgValue(/*from  w  w w .  j  a va  2 s  .  c  o m*/
            DatatypeHelper.safeTrimOrNullString(configElement.getAttributeNS(null, "attributeID")));

    if (configElement.hasAttributeNS(null, "minimum")) {
        builder.addConstructorArgValue(
                DatatypeHelper.safeTrimOrNullString(configElement.getAttributeNS(null, "minimum")));
    } else {
        builder.addConstructorArgValue(0);
    }

    if (configElement.hasAttributeNS(null, "maximum")) {
        builder.addConstructorArgValue(
                DatatypeHelper.safeTrimOrNullString(configElement.getAttributeNS(null, "maximum")));
    } else {
        builder.addConstructorArgValue(Integer.MAX_VALUE);
    }
}