diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2012-03-26 00:48:11 -0500 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-03-27 16:36:22 -0500 |
commit | 2ad71e6dab29ca5ed8362fe7cb672325884aaec5 (patch) | |
tree | bb19d73925dd0a5b56ec41ff10c4d251a943fd83 /base | |
parent | 78378144e71a00a67690a1f99152402c892b0103 (diff) | |
download | pki-2ad71e6dab29ca5ed8362fe7cb672325884aaec5.tar.gz pki-2ad71e6dab29ca5ed8362fe7cb672325884aaec5.tar.xz pki-2ad71e6dab29ca5ed8362fe7cb672325884aaec5.zip |
Replaced deprecated XMLSerializer.
The deprecated XMLSerializer has been replaced with LSSerializer.
The new API does not provide a way to control the indentation or
line width.
Ticket #3
Diffstat (limited to 'base')
-rw-r--r-- | base/silent/src/com/netscape/pkisilent/common/ParseXML.java | 21 | ||||
-rw-r--r-- | base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java | 14 |
2 files changed, 19 insertions, 16 deletions
diff --git a/base/silent/src/com/netscape/pkisilent/common/ParseXML.java b/base/silent/src/com/netscape/pkisilent/common/ParseXML.java index de1b38172..3e434498f 100644 --- a/base/silent/src/com/netscape/pkisilent/common/ParseXML.java +++ b/base/silent/src/com/netscape/pkisilent/common/ParseXML.java @@ -26,11 +26,13 @@ import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import org.apache.xml.serialize.OutputFormat; -import org.apache.xml.serialize.XMLSerializer; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import org.w3c.dom.bootstrap.DOMImplementationRegistry; +import org.w3c.dom.ls.DOMImplementationLS; +import org.w3c.dom.ls.LSOutput; +import org.w3c.dom.ls.LSSerializer; public class ParseXML { Document dom = null; @@ -99,14 +101,17 @@ public class ParseXML { public void prettyprintxml() { try { // Serialize the document - OutputFormat format = new OutputFormat(dom); + DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); + DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS"); - format.setLineWidth(65); - format.setIndenting(true); - format.setIndent(2); - XMLSerializer serializer = new XMLSerializer(System.out, format); + LSSerializer writer = impl.createLSSerializer(); + writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE); + + LSOutput output = impl.createLSOutput(); + output.setByteStream(System.out); + + writer.write(dom, output); - serializer.serialize(dom); } catch (Exception e) { } } diff --git a/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java b/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java index bf8a9cfc1..06f177887 100644 --- a/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java +++ b/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java @@ -406,7 +406,7 @@ public class CryptoUtil { /** * strips out the begin and end certificate brackets - * + * * @param s the string potentially bracketed with * "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----" * @return string without the brackets @@ -744,8 +744,7 @@ public class CryptoUtil { certInfo.set(X509CertInfo.ALGORITHM_ID, new CertificateAlgorithmId(aid)); - org.mozilla.jss.crypto.PrivateKey priKey = - (org.mozilla.jss.crypto.PrivateKey) privateKey; + org.mozilla.jss.crypto.PrivateKey priKey = privateKey; CryptoToken token = priKey.getOwningToken(); DerOutputStream tmp = new DerOutputStream(); @@ -991,7 +990,7 @@ public class CryptoUtil { Enumeration<CryptoToken> enums = cm.getAllTokens(); while (enums.hasMoreElements()) { - CryptoToken token = (CryptoToken) enums.nextElement(); + CryptoToken token = enums.nextElement(); CryptoStore store = token.getCryptoStore(); org.mozilla.jss.crypto.X509Certificate list[] = store.getCertificates(); @@ -1141,7 +1140,7 @@ public class CryptoUtil { return certs; } - + @SuppressWarnings("deprecation") public static String unwrapUsingPassphrase(String wrappedRecoveredKey, String recoveryPassphrase) throws IOException, InvalidBERException, InvalidKeyException, IllegalStateException, @@ -1205,7 +1204,6 @@ public class CryptoUtil { return wrappedPassphrase; } - @SuppressWarnings("deprecation") public static byte[] wrapSymmetricKey(CryptoManager manager, CryptoToken token, String transportCert, SymmetricKey sk) throws CertificateEncodingException, TokenException, NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException { @@ -1258,7 +1256,7 @@ public class CryptoUtil { encoded = oStream.toByteArray(); ByteArrayInputStream inStream = new ByteArrayInputStream(encoded); - + @SuppressWarnings("unused") PKIArchiveOptions options = (PKIArchiveOptions) (new PKIArchiveOptions.Template()).decode(inStream); @@ -1268,7 +1266,7 @@ public class CryptoUtil { } // START ENABLE_ECC -// This following can be removed when JSS with ECC capability +// This following can be removed when JSS with ECC capability // is integrated. class CryptoAlgorithm extends Algorithm { protected CryptoAlgorithm(int oidIndex, String name) { |