Example usage for org.w3c.dom Element hasAttributeNS

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

Introduction

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

Prototype

public boolean hasAttributeNS(String namespaceURI, String localName) throws DOMException;

Source Link

Document

Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise.

Usage

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

/** {@inheritDoc} */
protected void doParse(Element config, BeanDefinitionBuilder builder) {
    log.debug("Parsing configuration for {} authentication handler.",
            XMLHelper.getXSIType(config).getLocalPart());

    long duration = 30 * 60 * 1000;
    if (config.hasAttributeNS(null, "authenticationDuration")) {
        duration = SpringConfigurationUtils.parseDurationToMillis(
                "'authenticationDuration' on LoginHandler of type " + XMLHelper.getXSIType(config),
                config.getAttributeNS(null, "authenticationDuration"), 1000 * 60);
    }//  w w  w.  j  av a2s. c om
    log.debug("Authentication duration: {}ms", duration);
    builder.addPropertyValue("authenticationDuration", duration);

    String authnMethod;
    ArrayList<String> authnMethods = new ArrayList<String>();
    List<Element> authnMethodElems = XMLHelper.getChildElementsByTagNameNS(config,
            ProfileHandlerNamespaceHandler.NAMESPACE, "AuthenticationMethod");
    for (Element authnMethodElem : authnMethodElems) {
        authnMethod = DatatypeHelper.safeTrimOrNullString(authnMethodElem.getTextContent());
        log.debug("Authentication handler declared support for authentication method {}", authnMethod);
        authnMethods.add(authnMethod);
    }
    builder.addPropertyValue("authenticationMethods", authnMethods);
}

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

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

    String name = element.getAttributeNS(null, "name");
    builder.addPropertyValue("name", name);

    if (element.hasAttributeNS(null, "emptyValue")) {
        String emptyValue = element.getAttributeNS(null, "emptyValue");
        builder.addPropertyValue("emptyValue", emptyValue);
    }//from w  w w.jav a 2 s.  com

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

    Map<QName, List<Element>> configChildren = XMLHelper.getChildElements(element);

    builder.addPropertyValue("psoReferences", SpringConfigurationUtils.parseInnerCustomElements(
            configChildren.get(PsoReferenceBeanDefinitionParser.TYPE_NAME), parserContext));
}

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

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

    if (pluginConfig.hasAttributeNS(null, "lifetime")) {
        long lifetime = SpringConfigurationUtils.parseDurationToMillis(
                "lifetime on attribute definition " + pluginId, pluginConfig.getAttributeNS(null, "lifetime"),
                0);//from   w ww .  j  av a 2 s .  c  o  m
        pluginBuilder.addPropertyValue("identifierLifetime", lifetime);
    }

    pluginBuilder.addPropertyReference("identifierStore",
            DatatypeHelper.safeTrimOrNullString(pluginConfig.getAttributeNS(null, "storageServiceRef")));
}

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

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

    if (pluginConfig.hasAttributeNS(null, "lifetime")) {
        long lifetime = SpringConfigurationUtils.parseDurationToMillis(
                "'lifetime' on AttributeDefinition of type " + XMLHelper.getXSIType(pluginConfig),
                pluginConfig.getAttributeNS(null, "lifetime"), 1000 * 60);
        pluginBuilder.addPropertyValue("idLifetime", lifetime);
    }//w w w  .j a  v  a 2  s .  c o  m

    pluginBuilder.addPropertyReference("dataSealer",
            DatatypeHelper.safeTrimOrNullString(pluginConfig.getAttributeNS(null, "dataSealerRef")));
}

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  a  v a2  s .  com
        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 {/*from ww  w  . j  a va2 s  . co 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:info.joseluismartin.gtc.WmsCache.java

/**
 * {@inheritDoc}//from www.  j a  va2 s . c  o  m
 * @throws IOException 
 */
@Override
public InputStream parseResponse(InputStream serverStream, String remoteUri, String localUri)
        throws IOException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(remoteUri);
    UriComponents remoteComponents = builder.build();
    String localUrl = localUri + "/" + getPath();

    InputStream is = serverStream;
    MultiValueMap<String, String> params = remoteComponents.getQueryParams();

    if (GET_CAPABILITIES.equals(params.getFirst(REQUEST))) {
        String response = IOUtils.toString(serverStream);

        Document doc = XMLUtils.newDocument(response);

        if (log.isDebugEnabled())
            XMLUtils.prettyDocumentToString(doc);

        // Fix GetMapUrl
        Element getMapElement = (Element) doc.getElementsByTagName(GET_MAP).item(0);
        if (getMapElement != null) {
            if (log.isDebugEnabled()) {
                log.debug("Found GetMapUrl: " + this.getMapUrl);
            }

            NodeList nl = getMapElement.getElementsByTagName(ONLINE_RESOURCE_ELEMENT);
            if (nl.getLength() > 0) {
                Element resource = (Element) nl.item(0);
                if (resource.hasAttributeNS(XLINK_NS, HREF_ATTRIBUTE)) {
                    this.getMapUrl = resource.getAttributeNS(XLINK_NS, HREF_ATTRIBUTE).replace("?", "");
                    resource.setAttributeNS(XLINK_NS, HREF_ATTRIBUTE, localUrl);
                }
            }
        }

        // Fix GetFeatureInfoUrl
        Element getFeatureElement = (Element) doc.getElementsByTagName(GET_FEATURE_INFO).item(0);
        if (getFeatureElement != null) {
            if (log.isDebugEnabled()) {
                log.debug("Found GetFeatureInfoUrl: " + this.getFeatureInfoUrl);
            }

            NodeList nl = getFeatureElement.getElementsByTagName(ONLINE_RESOURCE_ELEMENT);
            if (nl.getLength() > 0) {
                Element resource = (Element) nl.item(0);
                if (resource.hasAttributeNS(XLINK_NS, HREF_ATTRIBUTE)) {
                    this.getFeatureInfoUrl = resource.getAttributeNS(XLINK_NS, HREF_ATTRIBUTE).replace("?", "");
                    resource.setAttributeNS(XLINK_NS, HREF_ATTRIBUTE, localUrl);
                }
            }
        }

        response = XMLUtils.documentToString(doc);
        response = response.replaceAll(getServerUrl(), localUrl);
        //   response = "<?xml version='1.0' encoding='UTF-8'>" + response; 

        is = IOUtils.toInputStream(response);
    }

    return is;
}

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 ava2  s  . com
            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);
    }
}

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));
    }// w  w  w .  j ava  2  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.AbstractPKIXValidationInformationBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element element, BeanDefinitionBuilder builder) {
    log.debug("Parsing PKIX ValidationInfo: {}", element.getAttributeNS(null, "id"));

    int depth = 1;
    if (element.hasAttributeNS(null, "verifyDepth")) {
        depth = new Integer(DatatypeHelper.safeTrim(element.getAttributeNS(null, "verifyDepth")));
    }/*from   ww  w. j  a  va 2s . c o m*/

    builder.addPropertyValue("verifyDepth", depth);

    Map<QName, List<Element>> configChildren = XMLHelper.getChildElements(element);

    parseCertificates(configChildren, builder);
    parseCRLs(configChildren, builder);
}