/** * Gets the collection of attributes which are none namespace declarations for an OMElement * * @param element * @return Returns the collection of attributes which are none namespace declarations */ public Collection getAttributesWithoutNS(OMElement element) { SortedMap map = new TreeMap(); Iterator itr = element.getAllAttributes(); while (itr.hasNext()) { OMAttribute attribute = (OMAttribute) itr.next(); if (!(attribute.getLocalName().equals("xmlns") || attribute.getLocalName().startsWith("xmlns:"))) map.put(getExpandedName(attribute), attribute); } return map.values(); }
/** * This method is an overloaded method for the digest generation for OMAttribute * * @param attribute * @param digestAlgorithm * @return Returns a byte array representing the calculated digest value */ public byte[] getDigest(OMAttribute attribute, String digestAlgorithm) throws OMException { byte[] digest = new byte[0]; if (!(attribute.getLocalName().equals("xmlns") || attribute.getLocalName().startsWith("xmlns:"))) try { MessageDigest md = MessageDigest.getInstance(digestAlgorithm); md.update((byte) 0); md.update((byte) 0); md.update((byte) 0); md.update((byte) 2); md.update(getExpandedName(attribute).getBytes("UnicodeBigUnmarked")); md.update((byte) 0); md.update((byte) 0); md.update(attribute.getAttributeValue().getBytes("UnicodeBigUnmarked")); digest = md.digest(); } catch (NoSuchAlgorithmException e) { throw new OMException(e); } catch (UnsupportedEncodingException e) { throw new OMException(e); } return digest; }
DataOutputStream dos = new DataOutputStream(baos); dos.writeInt(1); dos.write(getExpandedName(element).getBytes("UnicodeBigUnmarked")); dos.write((byte) 0); dos.write((byte) 0);