for (Element element : encryptedPasswordElements) { Attribute encryptedPassword = element.getAttribute(attributeName); encryptedPassword.setValue(reEncryptUsingNewKey(decodeHex(oldCipher), decodeHex(newCipher), encryptedPassword.getValue())); LOGGER.debug("Replaced encrypted value at {}", element.toString());
/** * <p> * This sets an attribute value for this element. Any existing attribute * with the same name and namespace URI is removed. * </p> * * @param name name of the attribute to set * @param value value of the attribute to set * @return this element modified * @throws IllegalNameException if the given name is illegal as an * attribute name. * @throws IllegalDataException if the given attribute value is * illegal character data (as determined by * {@link org.jdom2.Verifier#checkCharacterData}). */ public Element setAttribute(final String name, final String value) { final Attribute attribute = getAttribute(name); if (attribute == null) { final Attribute newAttribute = new Attribute(name, value); setAttribute(newAttribute); } else { attribute.setValue(value); } return this; }
/** * This will create a new <code>Attribute</code> with the * specified (local) name, value, and type, and in the provided * <code>{@link Namespace}</code>. * * @param name <code>String</code> name of <code>Attribute</code>. * @param value <code>String</code> value for new attribute. * @param type <code>AttributeType</code> for new attribute. * @param namespace <code>Namespace</code> namespace for new attribute. * @throws IllegalNameException if the given name is illegal as an * attribute name or if if the new namespace is the default * namespace. Attributes cannot be in a default namespace. * @throws IllegalDataException if the given attribute value is * illegal character data (as determined by * {@link org.jdom2.Verifier#checkCharacterData}) or * if the given attribute type is not one of the * supported types. */ public Attribute(final String name, final String value, final AttributeType type, final Namespace namespace) { setName(name); setValue(value); setAttributeType(type); setNamespace(namespace); }
/** * <p> * This sets an attribute value for this element. Any existing attribute * with the same name and namespace URI is removed. * </p> * * @param name name of the attribute to set * @param value value of the attribute to set * @param ns namespace of the attribute to set. A null implies Namespace.NO_NAMESPACE. * @return this element modified * @throws IllegalNameException if the given name is illegal as an * attribute name, or if the namespace is an unprefixed default * namespace * @throws IllegalDataException if the given attribute value is * illegal character data (as determined by * {@link org.jdom2.Verifier#checkCharacterData}). * @throws IllegalAddException if the attribute namespace prefix * collides with another namespace prefix on the element. */ public Element setAttribute(final String name, final String value, final Namespace ns) { final Attribute attribute = getAttribute(name, ns); if (attribute == null) { final Attribute newAttribute = new Attribute(name, value, ns); setAttribute(newAttribute); } else { attribute.setValue(value); } return this; }
public static MCRChangeData setValue(Attribute attribute, String value) { MCRChangeData data = new MCRChangeData("set-attribute", attribute); attribute.setValue(value); return data; }
/** * update the disks in the domain XML. It is assumed that the the size of the volumes is the same as the number of * disk elements and that the order is the same. */ public static void updateDisks(Document domainXml, List<StorageVol> volumes) throws LibvirtException { XPathFactory xpf = XPathFactory.instance(); XPathExpression<Element> diskExpr = xpf.compile(XPATH_DISK, Filters.element()); XPathExpression<Attribute> fileExpr = xpf.compile(XPATH_DISK_FILE, Filters.attribute()); List<Element> disks = diskExpr.evaluate(domainXml); Iterator<StorageVol> cloneDiskIter = volumes.iterator(); for (Element disk : disks) { Attribute file = fileExpr.evaluateFirst(disk); StorageVol cloneDisk = cloneDiskIter.next(); file.setValue(cloneDisk.getPath()); } }