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.common.config.attribute.encoding.SAML1ScopedStringAttributeEncoderBeanDefinitionParser.java

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

    if (element.hasAttributeNS(null, "scopeType")) {
        builder.addPropertyValue("scopeType", element.getAttribute("scopeType"));
    } else {//  w w  w . ja v  a 2  s  . c o  m
        builder.addPropertyValue("scopeType", "attribute");
    }

    String namespace = "urn:mace:shibboleth:1.0:attributeNamespace:uri";
    if (element.hasAttributeNS(null, "namespace")) {
        namespace = DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "namespace"));
    }
    builder.addPropertyValue("namespace", namespace);

    String attributeName = DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "name"));
    if (attributeName == null) {
        throw new BeanCreationException("SAML 1 attribute encoders must contain a 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 {/* ww w  .j  a v a 2 s  .c o  m*/
        builder.addConstructorArgValue(config.getAttributeNS(null, "/error.jsp"));
    }
}

From source file:edu.internet2.middleware.shibboleth.common.config.attribute.encoding.SAML2ScopedStringAttributeEncoderBeanDefinitionParser.java

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

    if (element.hasAttributeNS(null, "scopeType")) {
        builder.addPropertyValue("scopeType", element.getAttribute("scopeType"));
    } else {/*  ww w .  ja  va 2  s  . c  o m*/
        builder.addPropertyValue("scopeType", "inline");
    }

    String namespace = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri";
    if (element.hasAttributeNS(null, "nameFormat")) {
        namespace = DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "nameFormat"));
    }
    builder.addPropertyValue("nameFormat", namespace);

    builder.addPropertyValue("friendlyName", element.getAttribute(FRIENDLY_NAME_ATTRIBUTE_NAME));

    String attributeName = DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "name"));
    if (attributeName == null) {
        throw new BeanCreationException("SAML 2 attribute encoders must contain a name");
    }
}

From source file:fi.okm.mpass.shibboleth.profile.metadata.spring.DataSourceMetadataProviderParser.java

/** {@inheritDoc} */
@Override/*from ww w  . j a v a 2s.co m*/
protected void doNativeParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {

    super.doNativeParse(element, parserContext, builder);

    if (element.hasAttributeNS(null, "dataSource")) {
        builder.addConstructorArgReference(
                StringSupport.trimOrNull(element.getAttributeNS(null, "dataSource")));
    } else {
        log.error("{}: dataSource configuration not found",
                parserContext.getReaderContext().getResource().getDescription());
        throw new BeanDefinitionParsingException(new Problem("dataSource configuration not found",
                new Location(parserContext.getReaderContext().getResource())));
    }
}

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

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

    if (configElement.hasAttributeNS(null, "configurationResourcePollingFrequency")) {
        builder.addPropertyReference("pollingTimer", configElement.getAttributeNS(null, "timerId"));

        long frequency = SpringConfigurationUtils.parseDurationToMillis(
                "'configurationResourcePollingFrequency' on service "
                        + configElement.getAttributeNS(null, "id"),
                configElement.getAttributeNS(null, "configurationResourcePollingFrequency"), 1);
        builder.addPropertyValue("pollingFrequency", frequency);
        log.debug("{} service configuration polling frequency: {}ms", getServiceId(configElement), frequency);

        int retryAttempts = 0;
        if (configElement.hasAttributeNS(null, "configurationResourcePollingRetryAttempts")) {
            retryAttempts = Integer.parseInt(DatatypeHelper.safeTrimOrNullString(
                    configElement.getAttributeNS(null, "configurationResourcePollingRetryAttempts")));
        }//ww w  . j a  v  a 2s.  c  o m
        if (retryAttempts < 1) {
            retryAttempts = 3;
        }
        builder.addPropertyValue("pollingRetryAttempts", retryAttempts);
        log.debug("{} service configuration polling retry attempts: {}", getServiceId(configElement),
                retryAttempts);
    }
}

From source file:edu.internet2.middleware.shibboleth.idp.config.profile.saml2.SAML2ECPProfileHandlerBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element config, BeanDefinitionBuilder builder) {
    super.doParse(config, builder);
    // see that the handler gets initialized
    builder.setInitMethodName("initialize");

    if (config.hasAttributeNS(null, "authnContextClassRef")) {
        builder.addPropertyValue("authnContextClassRef",
                DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "authnContextClassRef")));
    } else {// w w  w  .j  a v a  2s  .c o m
        builder.addPropertyValue("authnContextClassRef", AuthnContext.PPT_AUTHN_CTX);
    }
}

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

/**
 * Gets the default task timer reference for the metadata provider.
 * //from w  w  w  .  j a va 2  s. c o  m
 * @param config metadata provider configuration element
 * 
 * @return task timer reference
 */
protected String getTaskTimerRef(Element config) {
    String taskTimerRef = null;
    if (config.hasAttributeNS(null, "taskTimerRef")) {
        taskTimerRef = DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "taskTimerRef"));
    }

    if (taskTimerRef == null) {
        taskTimerRef = "shibboleth.TaskTimer";
    }

    return taskTimerRef;
}

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

/** {@inheritDoc} */
protected void doParse(Element element, BeanDefinitionBuilder builder) {
    builder.addConstructorArgReference(/*from   w ww .  j  a v  a  2 s  .c  o  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:edu.internet2.middleware.shibboleth.common.config.security.saml.MessageReplayRuleBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element element, BeanDefinitionBuilder builder) {
    builder.addConstructorArgReference(/* ww  w . ja  va2  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:de.betterform.xml.xforms.action.SetFocusAction.java

/**
 * Performs element init./*from   w ww  .ja  v a  2s  .  c o  m*/
 */
public void init() throws XFormsException {
    super.init();
    // check if setfocus elem has 
    NodeList childNodes = element.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node node = childNodes.item(i);
        if (NamespaceConstants.XFORMS_NS.equals(node.getNamespaceURI()) && node.getLocalName().equals("control")
                && node.getNodeType() == Node.ELEMENT_NODE) {
            Element elementImpl = (Element) node;
            XFormsElement xfElem = (XFormsElement) this.element.getUserData("");
            if (elementImpl.hasAttributeNS(null, "value")) {
                String xpath = elementImpl.getAttributeNS(null, "value");
                this.referencedControl = XPathCache.getInstance().evaluateAsString(
                        xfElem.getModel().getDefaultInstance().getRootContext(), "string(" + xpath + ")");
            } else {
                this.referencedControl = elementImpl.getTextContent();
            }
        }
    }

    if (this.referencedControl == null) {
        this.referencedControl = getXFormsAttribute(CONTROL_ATTRIBUTE);
    }
    if (this.referencedControl == null) {
        throw new XFormsBindingException(
                "missing control attribute at " + DOMUtil.getCanonicalPath(this.getElement()), this.target,
                null);
    }
}