org.w3c.dom.Element#getAttributeNS ( )源码实例Demo

下面列出了org.w3c.dom.Element#getAttributeNS ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: javaide   文件: SecurityDetector.java
private static boolean isUnprotectedByPermission(Element element) {
    // Used to check whether an activity, service or broadcast receiver are
    // protected by a permission.
    String permission = element.getAttributeNS(ANDROID_URI, ATTR_PERMISSION);
    if (permission == null || permission.isEmpty()) {
        Node parent = element.getParentNode();
        if (parent.getNodeType() == Node.ELEMENT_NODE
                && parent.getNodeName().equals(TAG_APPLICATION)) {
            Element application = (Element) parent;
            permission = application.getAttributeNS(ANDROID_URI, ATTR_PERMISSION);
            return permission == null || permission.isEmpty();
        }
    }

    return false;
}
 
源代码2 项目: steady   文件: RequiredElementsBuilder.java
public Assertion build(Element element, AssertionBuilderFactory factory)
    throws IllegalArgumentException {

    SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
        ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;

    RequiredElements requiredElements = new RequiredElements(consts);
    String attrXPathVersion = element.getAttributeNS(consts.getNamespace(), SPConstants.XPATH_VERSION);

    if (attrXPathVersion != null) {
        requiredElements.setXPathVersion(attrXPathVersion);
    }


    Node nd = element.getFirstChild();
    while (nd != null) {
        if (nd instanceof Element) {
            processElement((Element)nd, requiredElements);                
        }
        nd = nd.getNextSibling();
    }
    return requiredElements;
}
 
源代码3 项目: steady   文件: SignedElementsBuilder.java
public Assertion build(Element element, AssertionBuilderFactory factory)
    throws IllegalArgumentException {
    
    SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
        ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;

    SignedEncryptedElements signedEncryptedElements = new SignedEncryptedElements(true,
                                                                                  consts);

    String attribute = element.getAttributeNS(consts.getNamespace(), SPConstants.XPATH_VERSION);
    if (attribute != null) {
        signedEncryptedElements.setXPathVersion(attribute);
    }

    Node nd = element.getFirstChild();
    while (nd != null) {
        if (nd instanceof Element) {
            processElement((Element)nd, signedEncryptedElements);                
        }
        nd = nd.getNextSibling();
    }
    return signedEncryptedElements;
}
 
源代码4 项目: steady   文件: AbstractBindingBuilder.java
protected String findIDFromSamlToken(Element samlToken) {
    String id = null;
    if (samlToken != null) {
        QName elName = DOMUtils.getElementQName(samlToken);
        if (elName.equals(new QName(WSConstants.SAML_NS, "Assertion"))
            && samlToken.hasAttributeNS(null, "AssertionID")) {
            id = samlToken.getAttributeNS(null, "AssertionID");
        } else if (elName.equals(new QName(WSConstants.SAML2_NS, "Assertion"))
            && samlToken.hasAttributeNS(null, "ID")) {
            id = samlToken.getAttributeNS(null, "ID");
        }
        if (id == null) {
            id = samlToken.getAttributeNS(WSConstants.WSU_NS, "Id");
        }
    }
    return id;
}
 
源代码5 项目: jdk8u-jdk   文件: DOMExcC14NMethod.java
private void unmarshalParams(Element paramsElem) {
    String prefixListAttr = paramsElem.getAttributeNS(null, "PrefixList");
    this.inclusiveNamespaces = prefixListAttr;
    int begin = 0;
    int end = prefixListAttr.indexOf(' ');
    List<String> prefixList = new ArrayList<String>();
    while (end != -1) {
        prefixList.add(prefixListAttr.substring(begin, end));
        begin = end + 1;
        end = prefixListAttr.indexOf(' ', begin);
    }
    if (begin <= prefixListAttr.length()) {
        prefixList.add(prefixListAttr.substring(begin));
    }
    this.params = new ExcC14NParameterSpec(prefixList);
}
 
源代码6 项目: steady   文件: AbstractBindingPolicyValidator.java
/**
 * Return true if the given id was encrypted
 */
private boolean isIdEncrypted(String sigId, List<WSSecurityEngineResult> results) {
    for (WSSecurityEngineResult wser : results) {
        Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
        if (actInt.intValue() == WSConstants.ENCR) {
            List<WSDataRef> el = 
                CastUtils.cast((List<?>)wser.get(WSSecurityEngineResult.TAG_DATA_REF_URIS));
            if (el != null) {
                for (WSDataRef r : el) {
                    Element protectedElement = r.getProtectedElement();
                    if (protectedElement != null) {
                        String id = protectedElement.getAttribute("Id");
                        String wsuId = protectedElement.getAttributeNS(WSConstants.WSU_NS, "Id");
                        if (sigId.equals(id) || sigId.equals(wsuId)) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
源代码7 项目: openjdk-jdk9   文件: DOMExcC14NMethod.java
private void unmarshalParams(Element paramsElem) {
    String prefixListAttr = paramsElem.getAttributeNS(null, "PrefixList");
    this.inclusiveNamespaces = prefixListAttr;
    int begin = 0;
    int end = prefixListAttr.indexOf(' ');
    List<String> prefixList = new ArrayList<String>();
    while (end != -1) {
        prefixList.add(prefixListAttr.substring(begin, end));
        begin = end + 1;
        end = prefixListAttr.indexOf(' ', begin);
    }
    if (begin <= prefixListAttr.length()) {
        prefixList.add(prefixListAttr.substring(begin));
    }
    this.params = new ExcC14NParameterSpec(prefixList);
}
 
源代码8 项目: steady   文件: RequiredElementsBuilder.java
public Assertion build(Element element, AssertionBuilderFactory factory)
    throws IllegalArgumentException {

    SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
        ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;

    RequiredElements requiredElements = new RequiredElements(consts);
    String attrXPathVersion = element.getAttributeNS(consts.getNamespace(), SPConstants.XPATH_VERSION);

    if (attrXPathVersion != null) {
        requiredElements.setXPathVersion(attrXPathVersion);
    }


    Node nd = element.getFirstChild();
    while (nd != null) {
        if (nd instanceof Element) {
            processElement((Element)nd, requiredElements);                
        }
        nd = nd.getNextSibling();
    }
    return requiredElements;
}
 
源代码9 项目: steady   文件: RequiredElementsBuilder.java
public Assertion build(Element element, AssertionBuilderFactory factory)
    throws IllegalArgumentException {

    SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
        ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;

    RequiredElements requiredElements = new RequiredElements(consts);
    String attrXPathVersion = element.getAttributeNS(consts.getNamespace(), SPConstants.XPATH_VERSION);

    if (attrXPathVersion != null) {
        requiredElements.setXPathVersion(attrXPathVersion);
    }


    Node nd = element.getFirstChild();
    while (nd != null) {
        if (nd instanceof Element) {
            processElement((Element)nd, requiredElements);                
        }
        nd = nd.getNextSibling();
    }
    return requiredElements;
}
 
源代码10 项目: openjdk-jdk9   文件: BodyImpl.java
String getPayloadAttributeValue(QName attNAme) {
    if (staxBridge != null) {
        return staxBridge.getPayloadAttributeValue(attNAme);
    } else {
        //not lazy -Just get first child element and return its attribute
        Element elem = getFirstChildElement();
        if (elem != null) {
            return elem.getAttributeNS(attNAme.getNamespaceURI(), attNAme.getLocalPart());
        }
    }
    return null;
}
 
源代码11 项目: cxf   文件: SpnegoContextTokenInInterceptor.java
private SpnegoTokenContext handleBinaryExchange(
    Element binaryExchange,
    Message message,
    String namespace
) throws Exception {
    if (binaryExchange == null) {
        throw new Exception("No BinaryExchange element received");
    }
    String encoding = binaryExchange.getAttributeNS(null, "EncodingType");
    if (!WSS4JConstants.BASE64_ENCODING.equals(encoding)) {
        throw new Exception("Unknown encoding type: " + encoding);
    }

    String valueType = binaryExchange.getAttributeNS(null, "ValueType");
    if (!(namespace + "/spnego").equals(valueType)) {
        throw new Exception("Unknown value type: " + valueType);
    }

    String content = DOMUtils.getContent(binaryExchange);
    byte[] decodedContent = XMLUtils.decode(content);

    String jaasContext =
        (String)message.getContextualProperty(SecurityConstants.KERBEROS_JAAS_CONTEXT_NAME);
    String kerberosSpn =
        (String)message.getContextualProperty(SecurityConstants.KERBEROS_SPN);
    CallbackHandler callbackHandler =
        SecurityUtils.getCallbackHandler(
            SecurityUtils.getSecurityPropertyValue(SecurityConstants.CALLBACK_HANDLER, message)
        );

    SpnegoTokenContext spnegoToken = new SpnegoTokenContext();
    spnegoToken.validateServiceTicket(
        jaasContext, callbackHandler, kerberosSpn, decodedContent
    );
    return spnegoToken;
}
 
源代码12 项目: steady   文件: SpnegoContextTokenInInterceptor.java
private SpnegoTokenContext handleBinaryExchange(
    Element binaryExchange,
    Message message,
    String namespace
) throws Exception {
    if (binaryExchange == null) {
        throw new Exception("No BinaryExchange element received");
    }
    String encoding = binaryExchange.getAttributeNS(null, "EncodingType");
    if (!BinarySecurity.BASE64_ENCODING.equals(encoding)) {
        throw new Exception("Unknown encoding type: " + encoding);
    }

    String valueType = binaryExchange.getAttributeNS(null, "ValueType");
    if (!(namespace + "/spnego").equals(valueType)) {
        throw new Exception("Unknown value type: " + valueType);
    }

    String content = DOMUtils.getContent(binaryExchange);
    byte[] decodedContent = Base64.decode(content);
    
    String jaasContext = 
        (String)message.getContextualProperty(SecurityConstants.KERBEROS_JAAS_CONTEXT_NAME);
    String kerberosSpn = 
        (String)message.getContextualProperty(SecurityConstants.KERBEROS_SPN);
    CallbackHandler callbackHandler = 
        NegotiationUtils.getCallbackHandler(
            message.getContextualProperty(SecurityConstants.CALLBACK_HANDLER), this.getClass()
        );

    SpnegoTokenContext spnegoToken = new SpnegoTokenContext();
    spnegoToken.validateServiceTicket(
        jaasContext, callbackHandler, kerberosSpn, decodedContent
    );
    return spnegoToken;
}
 
源代码13 项目: jdk8u-jdk   文件: SignedInfo.java
/**
 * Returns the Signature method URI
 *
 * @return the Signature method URI
 */
public String getSignatureMethodURI() {
    Element signatureElement = this.getSignatureMethodElement();

    if (signatureElement != null) {
        return signatureElement.getAttributeNS(null, Constants._ATT_ALGORITHM);
    }

    return null;
}
 
源代码14 项目: cxf   文件: DefaultSTSTokenCacher.java
private static String getIdFromToken(Element token) {
    if (token != null) {
        // For SAML tokens get the ID/AssertionID
        if ("Assertion".equals(token.getLocalName())
            && WSS4JConstants.SAML2_NS.equals(token.getNamespaceURI())) {
            return token.getAttributeNS(null, "ID");
        } else if ("Assertion".equals(token.getLocalName())
            && WSS4JConstants.SAML_NS.equals(token.getNamespaceURI())) {
            return token.getAttributeNS(null, "AssertionID");
        }

        // For UsernameTokens get the username
        if (WSS4JConstants.USERNAME_TOKEN_LN.equals(token.getLocalName())
            && WSS4JConstants.WSSE_NS.equals(token.getNamespaceURI())) {
            Element usernameElement =
                XMLUtils.getDirectChildElement(token, WSS4JConstants.USERNAME_LN, WSS4JConstants.WSSE_NS);
            if (usernameElement != null) {
                return XMLUtils.getElementText(usernameElement);
            }
        }

        // For BinarySecurityTokens take the hash of the value
        if (WSS4JConstants.BINARY_TOKEN_LN.equals(token.getLocalName())
            && WSS4JConstants.WSSE_NS.equals(token.getNamespaceURI())) {
            String text = XMLUtils.getElementText(token);
            if (text != null && !"".equals(text)) {
                try {
                    MessageDigest digest = MessageDigest.getInstance("SHA-256");
                    byte[] bytes = digest.digest(text.getBytes());
                    return org.apache.xml.security.utils.XMLUtils.encodeToString(bytes);
                } catch (NoSuchAlgorithmException e) {
                    // SHA-256 must be supported so not going to happen...
                }
            }
        }
    }
    return "";
}
 
源代码15 项目: javaide   文件: GridLayoutDetector.java
private static int getInt(Element element, String attribute, int defaultValue) {
    String valueString = element.getAttributeNS(ANDROID_URI, attribute);
    if (valueString != null && !valueString.isEmpty()) {
        try {
            return Integer.decode(valueString);
        } catch (NumberFormatException nufe) {
            // Ignore - error in user's XML
        }
    }

    return defaultValue;
}
 
源代码16 项目: java-n-IDE-for-Android   文件: ManifestModel.java
@Override
@Nullable
public String getKey(Element xmlElement) {
    String key = mNamespaceUri == null
        ? xmlElement.getAttribute(mAttributeName)
        : xmlElement.getAttributeNS(mNamespaceUri, mAttributeName);
    if (Strings.isNullOrEmpty(key)) return null;
    return key;
}
 
源代码17 项目: xmlunit   文件: ElementNameAndAttributeQualifier.java
/**
 * Determine whether the qualifying attributes are present in both elements
 * and if so whether their values are the same
 * @param control
 * @param test
 * @return true if all qualifying attributes are present with the same
 * values, false otherwise
 * @deprecated this method is no longer used by this class and is
 *             only kept for backwards compatibility, overriding
 *             it won't have any effect anymore
 */
@Deprecated
protected final boolean areAttributesComparable(Element control, Element test) {
    String controlValue, testValue;
    Attr[] qualifyingAttributes;
    NamedNodeMap namedNodeMap = control.getAttributes();
    if (matchesAllAttributes(qualifyingAttrNames)) {
        qualifyingAttributes = new Attr[namedNodeMap.getLength()];
        for (int n=0; n < qualifyingAttributes.length; ++n) {
            qualifyingAttributes[n] = (Attr) namedNodeMap.item(n);
        }
    } else {
        qualifyingAttributes = new Attr[qualifyingAttrNames.length];
        for (int n=0; n < qualifyingAttrNames.length; ++n) {
            qualifyingAttributes[n] = (Attr) namedNodeMap.getNamedItem(qualifyingAttrNames[n]);
        } 
    }

    String nsURI, name;
    for (int i=0; i < qualifyingAttributes.length; ++i) {
        if (qualifyingAttributes[i] != null) {
            nsURI = qualifyingAttributes[i].getNamespaceURI(); 
            controlValue = qualifyingAttributes[i].getNodeValue();
            name = qualifyingAttributes[i].getName();
        } else {
            // cannot be "*" case
            nsURI = controlValue = "";
            name = qualifyingAttrNames[i];
        }
        if (nsURI == null || nsURI.length() == 0) {
            testValue = test.getAttribute(name);
        } else {
            testValue = test.getAttributeNS(nsURI, qualifyingAttributes[i].getLocalName());
        }
        if (controlValue == null) {
            if (testValue != null) {
                return false;
            }
        } else {
            if (!controlValue.equals(testValue)) {
                return false;
            }
        }
    }
    return true;
}
 
源代码18 项目: jdk8u-dev-jdk   文件: DOMCryptoContext.java
/**
 * Registers the element's attribute specified by the namespace URI and
 * local name to be of type ID. The attribute must have a non-empty value.
 *
 * <p>This implementation uses an internal {@link HashMap} to map the
 * attribute's value to the specified element.
 *
 * @param element the element
 * @param namespaceURI the namespace URI of the attribute (specify
 *    <code>null</code> if not applicable)
 * @param localName the local name of the attribute
 * @throws IllegalArgumentException if <code>localName</code> is not an
 *    attribute of the specified element or it does not contain a specific
 *    value
 * @throws NullPointerException if <code>element</code> or
 *    <code>localName</code> is <code>null</code>
 * @see #getElementById
 */
public void setIdAttributeNS(Element element, String namespaceURI,
    String localName) {
    if (element == null) {
        throw new NullPointerException("element is null");
    }
    if (localName == null) {
        throw new NullPointerException("localName is null");
    }
    String idValue = element.getAttributeNS(namespaceURI, localName);
    if (idValue == null || idValue.length() == 0) {
        throw new IllegalArgumentException(localName + " is not an " +
            "attribute");
    }
    idMap.put(idValue, element);
}
 
源代码19 项目: Bytecoder   文件: DOMUtil.java
public static String getAttrValueNS(Element elem, String nsUri,
        String localName) {
    return elem.getAttributeNS(nsUri, localName);
}
 
源代码20 项目: steady   文件: KerberosTokenBuilder.java
public Assertion build(Element element, AssertionBuilderFactory factory) {
    
    SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
        ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;

    KerberosToken kerberosToken = new KerberosToken(consts);
    kerberosToken.setOptional(PolicyConstants.isOptional(element));
    kerberosToken.setIgnorable(PolicyConstants.isIgnorable(element));

    String attribute = element.getAttributeNS(element.getNamespaceURI(), SPConstants.ATTR_INCLUDE_TOKEN);
    if (attribute != null) {
        kerberosToken.setInclusion(consts.getInclusionFromAttributeValue(attribute.trim()));
    }
    
    Element child = DOMUtils.getFirstElement(element);
    boolean foundPolicy = false;
    while (child != null) {
        String ln = child.getLocalName();
        if (org.apache.neethi.Constants.ELEM_POLICY.equals(ln)) {
            foundPolicy = true;
            NodeList policyChildren = child.getChildNodes();
            if (policyChildren != null) {
                for (int i = 0; i < policyChildren.getLength(); i++) {
                    Node policyChild = policyChildren.item(i);
                    if (policyChild instanceof Element) {
                        QName qname = 
                            new QName(policyChild.getNamespaceURI(), policyChild.getLocalName());
                        String localpart = qname.getLocalPart();
                        if (SPConstants.KERBEROS_V5_AP_REQ_TOKEN_11.equals(localpart)) {
                            kerberosToken.setV5ApReqToken11(true);
                        } else if (SPConstants.KERBEROS_GSS_V5_AP_REQ_TOKEN_11.equals(localpart)) {
                            kerberosToken.setGssV5ApReqToken11(true);
                        } else if (SPConstants.REQUIRE_DERIVED_KEYS.equals(localpart)) {
                            kerberosToken.setDerivedKeys(true);
                        }
                    }
                }
            }
        }
        child = DOMUtils.getNextElement(child);
    }
    
    if (!foundPolicy && consts != SP11Constants.INSTANCE) {
        throw new IllegalArgumentException(
            "sp:KerberosToken/wsp:Policy must have a value"
        );
    }
    return kerberosToken;
}