mirror of
https://github.com/apache/poi.git
synced 2025-02-09 03:24:46 +00:00
[bug-65701] use createElementNS in agile encyption writer code
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895303 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f661e7c5a0
commit
9cd858c393
@ -17,13 +17,12 @@
|
|||||||
|
|
||||||
package org.apache.poi.poifs.crypt.agile;
|
package org.apache.poi.poifs.crypt.agile;
|
||||||
|
|
||||||
import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.getBinAttr;
|
|
||||||
import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setBinAttr;
|
|
||||||
|
|
||||||
import org.apache.poi.EncryptedDocumentException;
|
import org.apache.poi.EncryptedDocumentException;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.*;
|
||||||
|
|
||||||
public class CertificateKeyEncryptor {
|
public class CertificateKeyEncryptor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,9 +59,9 @@ public class CertificateKeyEncryptor {
|
|||||||
|
|
||||||
void write(Element encryption) {
|
void write(Element encryption) {
|
||||||
Document doc = encryption.getOwnerDocument();
|
Document doc = encryption.getOwnerDocument();
|
||||||
Element keyEncryptor = (Element) encryption.appendChild(doc.createElement("keyEncryptor"));
|
Element keyEncryptor = (Element) encryption.appendChild(doc.createElementNS(ENC_NS, "keyEncryptor"));
|
||||||
keyEncryptor.setAttribute("uri", KeyEncryptor.CERT_NS);
|
keyEncryptor.setAttribute("uri", KeyEncryptor.CERT_NS);
|
||||||
Element encryptedKey = (Element) keyEncryptor.appendChild(doc.createElement("c:encryptedKey"));
|
Element encryptedKey = (Element) keyEncryptor.appendChild(doc.createElementNS(KeyEncryptor.CERT_NS, "c:encryptedKey"));
|
||||||
|
|
||||||
setBinAttr(encryptedKey, "encryptedKeyValue", encryptedKeyValue);
|
setBinAttr(encryptedKey, "encryptedKeyValue", encryptedKeyValue);
|
||||||
setBinAttr(encryptedKey, "x509Certificate", x509Certificate);
|
setBinAttr(encryptedKey, "x509Certificate", x509Certificate);
|
||||||
|
@ -59,7 +59,7 @@ public class DataIntegrity {
|
|||||||
|
|
||||||
void write(Element encryption) {
|
void write(Element encryption) {
|
||||||
Document doc = encryption.getOwnerDocument();
|
Document doc = encryption.getOwnerDocument();
|
||||||
Element dataIntegrity = (Element)encryption.appendChild(doc.createElement("dataIntegrity"));
|
Element dataIntegrity = (Element)encryption.appendChild(doc.createElementNS(ENC_NS, "dataIntegrity"));
|
||||||
setBinAttr(dataIntegrity, "encryptedHmacKey", encryptedHmacKey);
|
setBinAttr(dataIntegrity, "encryptedHmacKey", encryptedHmacKey);
|
||||||
setBinAttr(dataIntegrity, "encryptedHmacValue", encryptedHmacValue);
|
setBinAttr(dataIntegrity, "encryptedHmacValue", encryptedHmacValue);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class EncryptionDocument {
|
|||||||
if (dataIntegrity != null) {
|
if (dataIntegrity != null) {
|
||||||
dataIntegrity.write(encryption);
|
dataIntegrity.write(encryption);
|
||||||
}
|
}
|
||||||
Element keyEncryptors = (Element)encryption.appendChild(doc.createElement("keyEncryptors"));
|
Element keyEncryptors = (Element)encryption.appendChild(doc.createElementNS(ENC_NS, "keyEncryptors"));
|
||||||
boolean hasPass = false;
|
boolean hasPass = false;
|
||||||
boolean hasCert = false;
|
boolean hasCert = false;
|
||||||
for (KeyEncryptor ke : this.keyEncryptors) {
|
for (KeyEncryptor ke : this.keyEncryptors) {
|
||||||
|
@ -71,7 +71,7 @@ public class KeyData {
|
|||||||
|
|
||||||
void write(Element encryption) {
|
void write(Element encryption) {
|
||||||
Document doc = encryption.getOwnerDocument();
|
Document doc = encryption.getOwnerDocument();
|
||||||
Element keyData = (Element)encryption.appendChild(doc.createElement("keyData"));
|
Element keyData = (Element)encryption.appendChild(doc.createElementNS(ENC_NS, "keyData"));
|
||||||
setIntAttr(keyData, "saltSize", saltSize);
|
setIntAttr(keyData, "saltSize", saltSize);
|
||||||
setIntAttr(keyData, "blockSize", blockSize);
|
setIntAttr(keyData, "blockSize", blockSize);
|
||||||
setIntAttr(keyData, "keyBits", keyBits);
|
setIntAttr(keyData, "keyBits", keyBits);
|
||||||
|
@ -17,12 +17,6 @@
|
|||||||
|
|
||||||
package org.apache.poi.poifs.crypt.agile;
|
package org.apache.poi.poifs.crypt.agile;
|
||||||
|
|
||||||
import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.getBinAttr;
|
|
||||||
import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.getIntAttr;
|
|
||||||
import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setAttr;
|
|
||||||
import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setBinAttr;
|
|
||||||
import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setIntAttr;
|
|
||||||
|
|
||||||
import org.apache.poi.EncryptedDocumentException;
|
import org.apache.poi.EncryptedDocumentException;
|
||||||
import org.apache.poi.poifs.crypt.ChainingMode;
|
import org.apache.poi.poifs.crypt.ChainingMode;
|
||||||
import org.apache.poi.poifs.crypt.CipherAlgorithm;
|
import org.apache.poi.poifs.crypt.CipherAlgorithm;
|
||||||
@ -30,6 +24,9 @@ import org.apache.poi.poifs.crypt.HashAlgorithm;
|
|||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.*;
|
||||||
|
import static org.apache.poi.poifs.crypt.agile.KeyEncryptor.PASS_NS;
|
||||||
|
|
||||||
public class PasswordKeyEncryptor {
|
public class PasswordKeyEncryptor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,9 +121,9 @@ public class PasswordKeyEncryptor {
|
|||||||
|
|
||||||
void write(Element encryption) {
|
void write(Element encryption) {
|
||||||
Document doc = encryption.getOwnerDocument();
|
Document doc = encryption.getOwnerDocument();
|
||||||
Element keyEncryptor = (Element) encryption.appendChild(doc.createElement("keyEncryptor"));
|
Element keyEncryptor = (Element) encryption.appendChild(doc.createElementNS(ENC_NS, "keyEncryptor"));
|
||||||
keyEncryptor.setAttribute("uri", KeyEncryptor.PASS_NS);
|
keyEncryptor.setAttribute("uri", PASS_NS);
|
||||||
Element encryptedKey = (Element) keyEncryptor.appendChild(doc.createElement("p:encryptedKey"));
|
Element encryptedKey = (Element) keyEncryptor.appendChild(doc.createElementNS(PASS_NS, "p:encryptedKey"));
|
||||||
|
|
||||||
setIntAttr(encryptedKey, "saltSize", saltSize);
|
setIntAttr(encryptedKey, "saltSize", saltSize);
|
||||||
setIntAttr(encryptedKey, "blockSize", blockSize);
|
setIntAttr(encryptedKey, "blockSize", blockSize);
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user