<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MattPayne.org &#187; IA</title>
	<atom:link href="http://www.mattpayne.org/blog/category/programming/ia/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattpayne.org/blog</link>
	<description>Omaha, NE - Computer Programmer</description>
	<lastBuildDate>Sun, 22 Aug 2010 21:51:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Trusting Mozy</title>
		<link>http://www.mattpayne.org/blog/2010/08/22/trusting-mozy/</link>
		<comments>http://www.mattpayne.org/blog/2010/08/22/trusting-mozy/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 21:13:08 +0000</pubDate>
		<dc:creator>Payne</dc:creator>
				<category><![CDATA[IA]]></category>

		<guid isPermaLink="false">http://www.mattpayne.org/blog/?p=342</guid>
		<description><![CDATA[Tried out Mozy.    Did not like that when exiting the program it refused to quit.   When running the un-install, I was informed that Mozy will keep the files on its servers.    eeeeeu!]]></description>
			<content:encoded><![CDATA[<p>Tried out Mozy.    Did not like that when exiting the program it refused to quit.   When running the un-install, I was informed that Mozy will keep the files on its servers.    eeeeeu!</p>
<p><img class="alignnone size-full wp-image-346" title="Mozy_is_Creepy" src="http://www.mattpayne.org/blog/wp-content/uploads/2010/08/Mozy_is_Creepy.png" alt="" width="366" height="203" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattpayne.org/blog/2010/08/22/trusting-mozy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSch is easy to use!</title>
		<link>http://www.mattpayne.org/blog/2006/09/17/jsch-is-easy-to-use/</link>
		<comments>http://www.mattpayne.org/blog/2006/09/17/jsch-is-easy-to-use/#comments</comments>
		<pubDate>Sun, 17 Sep 2006 11:42:40 +0000</pubDate>
		<dc:creator>Payne</dc:creator>
				<category><![CDATA[Crypto]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[jMatter]]></category>

		<guid isPermaLink="false">http://www.mattpayne.org/blog/2006/09/17/jsch-is-easy-to-use/</guid>
		<description><![CDATA[&#8220;JSch is a pure Java implementation of SSH2.&#8221; It&#8217;s great that the license is BSD style. This package is easy to use and comes with some nice demo programs. I was able to quickly adapt their SSH tunnels demo so that before starting the real main in a jMatter.org application (which was being launched via [...]]]></description>
			<content:encoded><![CDATA[<p><strong>&#8220;<a href="http://www.jcraft.com/jsch/">JSch</a> is a pure Java implementation of                <a href="http://ietf.org/html.charters/secsh-charter.html" target="_blank">SSH2</a>.&#8221;  It&#8217;s great that the <a href="http://www.jcraft.com/jsch/LICENSE.txt">license</a> is BSD style.<br />
</strong></p>
<p>This package is easy to use and comes with some <a href="http://www.jcraft.com/jsch/examples/">nice demo programs</a>.   I was able to quickly adapt <a href="http://www.jcraft.com/jsch/examples/PortForwardingL.java">their SSH tunnels demo</a> so that before starting the real main in a <a href="http://jmatter.org/">jMatter.org</a> application (which was being launched via <a href="http://java.sun.com/products/javawebstart/">Java Web Start</a>) a <a href="http://www.rzg.mpg.de/networking/tunnelling.html">SSH tunnel</a> was established.  Then the jMatter.org application makes a database connection to 127.0.0.1 which really goes through the SSH tunnel to the UNIX box with the database server on it.  This way the database server&#8217;s TCP socket doesn&#8217;t have to be directly exposed to the Internet.</p>
<p>Still to do is tweaking things so each end user has a unique tunnel&#8230; maybe with ssh keys&#8230;</p>
<p>BTW It&#8217;s interesting that the top page returned by googling SSH tunnel is <a href="http://www.rzg.mpg.de/networking/tunnelling.html">http://www.rzg.mpg.de/networking/tunnelling.html</a>.  There&#8217;s a nice picture there:</p>
<p><img src="http://mattpayne.org/i/ssh-tunnel-01.gif" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattpayne.org/blog/2006/09/17/jsch-is-easy-to-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No Doubt!  Apache&#8217;s XML Security will encrypt subtrees!</title>
		<link>http://www.mattpayne.org/blog/2006/06/23/no-doubt-apaches-xml-security-will-encrypt-subtrees/</link>
		<comments>http://www.mattpayne.org/blog/2006/06/23/no-doubt-apaches-xml-security-will-encrypt-subtrees/#comments</comments>
		<pubDate>Fri, 23 Jun 2006 21:55:08 +0000</pubDate>
		<dc:creator>Payne</dc:creator>
				<category><![CDATA[Crypto]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.mattpayne.org/blog/2006/06/23/no-doubt-apaches-xml-security-will-encrypt-subtrees/</guid>
		<description><![CDATA[Original post 10 May 2004. TODO: Still need to update the before and after samples&#8230; It was easy to hack the org.apache.xml.security.samples.encryption.Encrypter demo to show that just a subtree of a document could be encrypted&#8230;. before after 1 /* 2 * Copyright 1999-2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache [...]]]></description>
			<content:encoded><![CDATA[<p>Original post 10 May 2004.  TODO: Still need to update the before and<br />
after samples&#8230;</p>
<p>It was easy to hack the org.apache.xml.security.samples.encryption.Encrypter<br />
demo to show that just a subtree of a document could be encrypted&#8230;.<br />
<a href="http://MattPayne.org/java/crypto/xmlenc2/before.xml">before</a><br />
<a href="http://MattPayne.org/java/crypto/xmlenc2/after.xml">after</a></p>
<pre><span style="color: #a52a2a;">  1</span>  <span style="color: #0000ff;">/*</span>
<span style="color: #a52a2a;">  2</span>  <span style="color: #0000ff;"> * Copyright  1999-2004 The Apache Software Foundation.</span>
<span style="color: #a52a2a;">  3</span>  <span style="color: #0000ff;"> *</span>
<span style="color: #a52a2a;">  4</span>  <span style="color: #0000ff;"> *  Licensed under the Apache License, Version 2.0 (the "License");</span>
<span style="color: #a52a2a;">  5</span>  <span style="color: #0000ff;"> *  you may not use this file except in compliance with the License.</span>
<span style="color: #a52a2a;">  6</span>  <span style="color: #0000ff;"> *  You may obtain a copy of the License at</span>
<span style="color: #a52a2a;">  7</span>  <span style="color: #0000ff;"> *</span>
<span style="color: #a52a2a;">  8</span>  <span style="color: #0000ff;"> *      http://www.apache.org/licenses/LICENSE-2.0</span>
<span style="color: #a52a2a;">  9</span>  <span style="color: #0000ff;"> *</span>
<span style="color: #a52a2a;"> 10</span>  <span style="color: #0000ff;"> *  Unless required by applicable law or agreed to in writing, software</span>
<span style="color: #a52a2a;"> 11</span>  <span style="color: #0000ff;"> *  distributed under the License is distributed on an "AS IS" BASIS,</span>
<span style="color: #a52a2a;"> 12</span>  <span style="color: #0000ff;"> *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<span style="color: #a52a2a;"> 13</span>  <span style="color: #0000ff;"> *  See the License for the specific language governing permissions and</span>
<span style="color: #a52a2a;"> 14</span>  <span style="color: #0000ff;"> *  limitations under the License.</span>
<span style="color: #a52a2a;"> 15</span>  <span style="color: #0000ff;"> *</span>
<span style="color: #a52a2a;"> 16</span>  <span style="color: #0000ff;"> */</span>
<span style="color: #a52a2a;"> 17</span>  <span style="color: #a020f0;">package</span> org.apache.xml.security.samples.encryption;
<span style="color: #a52a2a;"> 18</span>
<span style="color: #a52a2a;"> 19</span>
<span style="color: #a52a2a;"> 20</span>  <span style="color: #a020f0;">import</span> java.io.File;
<span style="color: #a52a2a;"> 21</span>  <span style="color: #a020f0;">import</span> java.io.FileInputStream;
<span style="color: #a52a2a;"> 22</span>  <span style="color: #a020f0;">import</span> java.io.FileOutputStream;
<span style="color: #a52a2a;"> 23</span>
<span style="color: #a52a2a;"> 24</span>  <span style="color: #a020f0;">import</span> java.security.Key;
<span style="color: #a52a2a;"> 25</span>
<span style="color: #a52a2a;"> 26</span>  <span style="color: #a020f0;">import</span> javax.crypto.SecretKey;
<span style="color: #a52a2a;"> 27</span>  <span style="color: #a020f0;">import</span> javax.crypto.KeyGenerator;
<span style="color: #a52a2a;"> 28</span>
<span style="color: #a52a2a;"> 29</span>  <span style="color: #a020f0;">import</span> org.apache.xml.security.keys.KeyInfo;
<span style="color: #a52a2a;"> 30</span>  <span style="color: #a020f0;">import</span> org.apache.xml.security.encryption.XMLCipher;
<span style="color: #a52a2a;"> 31</span>  <span style="color: #a020f0;">import</span> org.apache.xml.security.encryption.EncryptedData;
<span style="color: #a52a2a;"> 32</span>  <span style="color: #a020f0;">import</span> org.apache.xml.security.encryption.EncryptedKey;
<span style="color: #a52a2a;"> 33</span>  <span style="color: #a020f0;">import</span> org.apache.xml.security.utils.XMLUtils;
<span style="color: #a52a2a;"> 34</span>  <span style="color: #a020f0;">import</span> org.apache.xml.security.utils.Constants;
<span style="color: #a52a2a;"> 35</span>
<span style="color: #a52a2a;"> 36</span>  <span style="color: #a020f0;">import</span> org.w3c.dom.Document;
<span style="color: #a52a2a;"> 37</span>  <span style="color: #a020f0;">import</span> org.w3c.dom.Element;
<span style="color: #a52a2a;"> 38</span>  <span style="color: #a020f0;">import</span> org.w3c.dom.NodeList;
<span style="color: #a52a2a;"> 39</span>
<span style="color: #a52a2a;"> 40</span>  <span style="color: #a020f0;">import</span> javax.xml.transform.TransformerFactory;
<span style="color: #a52a2a;"> 41</span>  <span style="color: #a020f0;">import</span> javax.xml.transform.Transformer;
<span style="color: #a52a2a;"> 42</span>  <span style="color: #a020f0;">import</span> javax.xml.transform.dom.DOMSource;
<span style="color: #a52a2a;"> 43</span>  <span style="color: #a020f0;">import</span> javax.xml.transform.stream.StreamResult;
<span style="color: #a52a2a;"> 44</span>  <span style="color: #a020f0;">import</span> javax.xml.transform.OutputKeys;
<span style="color: #a52a2a;"> 45</span>
<span style="color: #a52a2a;"> 46</span>  <span style="color: #0000ff;">/**</span>
<span style="color: #a52a2a;"> 47</span>  <span style="color: #0000ff;"> *</span><span style="color: #6a5acd;"> This sample demonstrates how to encrypt data inside an xml document.</span>
<span style="color: #a52a2a;"> 48</span>  <span style="color: #0000ff;"> *</span>
<span style="color: #a52a2a;"> 49</span>  <span style="color: #0000ff;"> * </span><span style="color: #6a5acd;">@author</span><span style="color: #0000ff;"> Vishal Mahajan (Sun Microsystems)</span>
<span style="color: #a52a2a;"> 50</span>  <span style="color: #0000ff;"> * Hacked by Matt</span>
<span style="color: #a52a2a;"> 51</span>  <span style="color: #0000ff;"> */</span>
<span style="color: #a52a2a;"> 52</span>  <span style="color: #2e8b57;"><strong>public</strong></span> <span style="color: #2e8b57;"><strong>class</strong></span> Encrypter2 {
<span style="color: #a52a2a;"> 53</span>
<span style="color: #a52a2a;"> 54</span>      <span style="color: #0000ff;">/**</span><span style="color: #6a5acd;"> {</span><span style="color: #0000ff;">@link org.apache.commons.logging} logging facility */</span>
<span style="color: #a52a2a;"> 55</span>      <span style="color: #2e8b57;"><strong>static</strong></span> org.apache.commons.logging.Log log =
<span style="color: #a52a2a;"> 56</span>          org.apache.commons.logging.LogFactory.getLog(
<span style="color: #a52a2a;"> 57</span>              Encrypter2.<span style="color: #2e8b57;"><strong>class</strong></span>.getName());
<span style="color: #a52a2a;"> 58</span>
<span style="color: #a52a2a;"> 59</span>      <span style="color: #2e8b57;"><strong>static</strong></span> {
<span style="color: #a52a2a;"> 60</span>          org.apache.xml.security.Init.init();
<span style="color: #a52a2a;"> 61</span>      }
<span style="color: #a52a2a;"> 62</span>
<span style="color: #a52a2a;"> 63</span>      <span style="color: #2e8b57;"><strong>private</strong></span> <span style="color: #2e8b57;"><strong>static</strong></span> Document createSampleDocument() <span style="color: #2e8b57;"><strong>throws</strong></span> Exception {
<span style="color: #a52a2a;"> 64</span>
<span style="color: #a52a2a;"> 65</span>          javax.xml.parsers.DocumentBuilderFactory dbf =
<span style="color: #a52a2a;"> 66</span>              javax.xml.parsers.DocumentBuilderFactory.newInstance();
<span style="color: #a52a2a;"> 67</span>          dbf.setNamespaceAware(<span style="color: #ff00ff;">true</span>);
<span style="color: #a52a2a;"> 68</span>          javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
<span style="color: #a52a2a;"> 69</span>          Document document = db.newDocument();
<span style="color: #a52a2a;"> 70</span>
<span style="color: #a52a2a;"> 71</span>          <span style="color: #0000ff;">/**</span>
<span style="color: #a52a2a;"> 72</span>  <span style="color: #0000ff;">         *</span><span style="color: #6a5acd;"> Build a sample document.</span><span style="color: #0000ff;"> It will look something like:</span>
<span style="color: #a52a2a;"> 73</span>  <span style="color: #0000ff;">         *</span>
<span style="color: #a52a2a;"> 74</span>  <span style="color: #0000ff;">         * </span><span style="color: #008b8b;">&lt;</span>apache<span style="color: #008b8b;">:RootElement xmlns:apache=</span><span style="color: #ff00ff;">"http://www.apache.org/ns/#app1"</span><span style="color: #008b8b;">&gt;</span>
<span style="color: #a52a2a;"> 75</span>  <span style="color: #0000ff;">         * </span><span style="color: #008b8b;">&lt;</span>apache<span style="color: #008b8b;">:foo&gt;</span><span style="color: #0000ff;">Some simple text</span><span style="color: #008b8b;">&lt;/</span>apache<span style="color: #008b8b;">:foo&gt;</span>
<span style="color: #a52a2a;"> 76</span>  <span style="color: #0000ff;">         * </span><span style="color: #008b8b;">&lt;/</span>apache<span style="color: #008b8b;">:RootElement&gt;</span>
<span style="color: #a52a2a;"> 77</span>  <span style="color: #0000ff;">         */</span>
<span style="color: #a52a2a;"> 78</span>          Element root =
<span style="color: #a52a2a;"> 79</span>              document.createElementNS(
<span style="color: #a52a2a;"> 80</span>                  <span style="color: #ff00ff;">"http://www.apache.org/ns/#app1"</span>, <span style="color: #ff00ff;">"apache:RootElement"</span>);
<span style="color: #a52a2a;"> 81</span>          root.setAttributeNS(
<span style="color: #a52a2a;"> 82</span>              Constants.NamespaceSpecNS,
<span style="color: #a52a2a;"> 83</span>              <span style="color: #ff00ff;">"xmlns:apache"</span>,
<span style="color: #a52a2a;"> 84</span>              <span style="color: #ff00ff;">"http://www.apache.org/ns/#app1"</span>);
<span style="color: #a52a2a;"> 85</span>          document.appendChild(root);
<span style="color: #a52a2a;"> 86</span>
<span style="color: #a52a2a;"> 87</span>          root.appendChild(document.createTextNode(<span style="color: #ff00ff;">"</span><span style="color: #6a5acd;">\n</span><span style="color: #ff00ff;">"</span>));
<span style="color: #a52a2a;"> 88</span>
<span style="color: #a52a2a;"> 89</span>          Element childElement =
<span style="color: #a52a2a;"> 90</span>              document.createElementNS(
<span style="color: #a52a2a;"> 91</span>                  <span style="color: #ff00ff;">"http://www.apache.org/ns/#app1"</span>, <span style="color: #ff00ff;">"apache:foo"</span>);
<span style="color: #a52a2a;"> 92</span>          childElement.appendChild(
<span style="color: #a52a2a;"> 93</span>              document.createTextNode(<span style="color: #ff00ff;">"Some simple text"</span>));
<span style="color: #a52a2a;"> 94</span>
<span style="color: #a52a2a;"> 95</span>          Element e2 = document.createElementNS(
<span style="color: #a52a2a;"> 96</span>                  <span style="color: #ff00ff;">"http://www.apache.org/ns/#app1"</span>, <span style="color: #ff00ff;">"apache:goo"</span>);
<span style="color: #a52a2a;"> 97</span>                  e2.appendChild(document.createTextNode(<span style="color: #ff00ff;">"Weather Report"</span>));
<span style="color: #a52a2a;"> 98</span>
<span style="color: #a52a2a;"> 99</span>                  Element e3 = document.createElementNS(
<span style="color: #a52a2a;">100</span>                  <span style="color: #ff00ff;">"http://www.apache.org/ns/#app1"</span>, <span style="color: #ff00ff;">"apache:bar"</span>);
<span style="color: #a52a2a;">101</span>                  e3.appendChild(document.createTextNode(<span style="color: #ff00ff;">"No Doubt"</span>));
<span style="color: #a52a2a;">102</span>
<span style="color: #a52a2a;">103</span>                  e2.appendChild(e3);
<span style="color: #a52a2a;">104</span>
<span style="color: #a52a2a;">105</span>                  e2.appendChild( e3.appendChild(document.createTextNode(<span style="color: #ff00ff;">"biteme"</span>)));
<span style="color: #a52a2a;">106</span>
<span style="color: #a52a2a;">107</span>          childElement.appendChild(e2);
<span style="color: #a52a2a;">108</span>
<span style="color: #a52a2a;">109</span>
<span style="color: #a52a2a;">110</span>          root.appendChild(childElement);
<span style="color: #a52a2a;">111</span>
<span style="color: #a52a2a;">112</span>          root.appendChild(document.createTextNode(<span style="color: #ff00ff;">"</span><span style="color: #6a5acd;">\n</span><span style="color: #ff00ff;">"</span>));
<span style="color: #a52a2a;">113</span>
<span style="color: #a52a2a;">114</span>
<span style="color: #a52a2a;">115</span>          outputDocToFile(document, <span style="color: #ff00ff;">"before2.xml"</span>);
<span style="color: #a52a2a;">116</span>
<span style="color: #a52a2a;">117</span>          <span style="color: #a52a2a;"><strong>return</strong></span> document;
<span style="color: #a52a2a;">118</span>      }
<span style="color: #a52a2a;">119</span>
<span style="color: #a52a2a;">120</span>      <span style="color: #2e8b57;"><strong>private</strong></span> <span style="color: #2e8b57;"><strong>static</strong></span> SecretKey GenerateAndStoreKeyEncryptionKey()
<span style="color: #a52a2a;">121</span>          <span style="color: #2e8b57;"><strong>throws</strong></span> Exception {
<span style="color: #a52a2a;">122</span>
<span style="color: #a52a2a;">123</span>          String jceAlgorithmName = <span style="color: #ff00ff;">"DESede"</span>;
<span style="color: #a52a2a;">124</span>          KeyGenerator keyGenerator =
<span style="color: #a52a2a;">125</span>              KeyGenerator.getInstance(jceAlgorithmName);
<span style="color: #a52a2a;">126</span>          SecretKey kek = keyGenerator.generateKey();
<span style="color: #a52a2a;">127</span>
<span style="color: #a52a2a;">128</span>          <span style="color: #2e8b57;"><strong>byte</strong></span>[] keyBytes = kek.getEncoded();
<span style="color: #a52a2a;">129</span>          File kekFile = <span style="color: #a52a2a;"><strong>new</strong></span> File(<span style="color: #ff00ff;">"kek"</span>);
<span style="color: #a52a2a;">130</span>          FileOutputStream f = <span style="color: #a52a2a;"><strong>new</strong></span> FileOutputStream(kekFile);
<span style="color: #a52a2a;">131</span>          f.write(keyBytes);
<span style="color: #a52a2a;">132</span>          f.close();
<span style="color: #a52a2a;">133</span>          System.out.println(
<span style="color: #a52a2a;">134</span>              <span style="color: #ff00ff;">"Key encryption key stored in "</span> + kekFile.toURL().toString());
<span style="color: #a52a2a;">135</span>
<span style="color: #a52a2a;">136</span>          <span style="color: #a52a2a;"><strong>return</strong></span> kek;
<span style="color: #a52a2a;">137</span>      }
<span style="color: #a52a2a;">138</span>
<span style="color: #a52a2a;">139</span>      <span style="color: #2e8b57;"><strong>private</strong></span> <span style="color: #2e8b57;"><strong>static</strong></span> SecretKey GenerateDataEncryptionKey() <span style="color: #2e8b57;"><strong>throws</strong></span> Exception {
<span style="color: #a52a2a;">140</span>
<span style="color: #a52a2a;">141</span>          String jceAlgorithmName = <span style="color: #ff00ff;">"AES"</span>;
<span style="color: #a52a2a;">142</span>          KeyGenerator keyGenerator =
<span style="color: #a52a2a;">143</span>              KeyGenerator.getInstance(jceAlgorithmName);
<span style="color: #a52a2a;">144</span>          keyGenerator.init(<span style="color: #ff00ff;">128</span>);
<span style="color: #a52a2a;">145</span>          <span style="color: #a52a2a;"><strong>return</strong></span> keyGenerator.generateKey();
<span style="color: #a52a2a;">146</span>      }
<span style="color: #a52a2a;">147</span>
<span style="color: #a52a2a;">148</span>      <span style="color: #2e8b57;"><strong>private</strong></span> <span style="color: #2e8b57;"><strong>static</strong></span> <span style="color: #2e8b57;"><strong>void</strong></span> outputDocToFile(Document doc, String fileName)
<span style="color: #a52a2a;">149</span>          <span style="color: #2e8b57;"><strong>throws</strong></span> Exception {
<span style="color: #a52a2a;">150</span>          File encryptionFile = <span style="color: #a52a2a;"><strong>new</strong></span> File(fileName);
<span style="color: #a52a2a;">151</span>          FileOutputStream f = <span style="color: #a52a2a;"><strong>new</strong></span> FileOutputStream(encryptionFile);
<span style="color: #a52a2a;">152</span>
<span style="color: #a52a2a;">153</span>          TransformerFactory factory = TransformerFactory.newInstance();
<span style="color: #a52a2a;">154</span>          Transformer transformer = factory.newTransformer();
<span style="color: #a52a2a;">155</span>          transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, <span style="color: #ff00ff;">"yes"</span>);
<span style="color: #a52a2a;">156</span>          DOMSource source = <span style="color: #a52a2a;"><strong>new</strong></span> DOMSource(doc);
<span style="color: #a52a2a;">157</span>          StreamResult result = <span style="color: #a52a2a;"><strong>new</strong></span> StreamResult(f);
<span style="color: #a52a2a;">158</span>          transformer.transform(source, result);
<span style="color: #a52a2a;">159</span>
<span style="color: #a52a2a;">160</span>          f.close();
<span style="color: #a52a2a;">161</span>          System.out.println(
<span style="color: #a52a2a;">162</span>              <span style="color: #ff00ff;">"Wrote document containing encrypted data to "</span> +
<span style="color: #a52a2a;">163</span>              encryptionFile.toURL().toString());
<span style="color: #a52a2a;">164</span>      }
<span style="color: #a52a2a;">165</span>
<span style="color: #a52a2a;">166</span>      <span style="color: #2e8b57;"><strong>public</strong></span> <span style="color: #2e8b57;"><strong>static</strong></span> <span style="color: #2e8b57;"><strong>void</strong></span> main(String unused[]) <span style="color: #2e8b57;"><strong>throws</strong></span> Exception {
<span style="color: #a52a2a;">167</span>
<span style="color: #a52a2a;">168</span>          Document document = createSampleDocument();
<span style="color: #a52a2a;">169</span>
<span style="color: #a52a2a;">170</span>          <span style="color: #0000ff;">/*</span>
<span style="color: #a52a2a;">171</span>  <span style="color: #0000ff;">         * Get a key to be used for encrypting the element.</span>
<span style="color: #a52a2a;">172</span>  <span style="color: #0000ff;">         * Here we are generating an AES key.</span>
<span style="color: #a52a2a;">173</span>  <span style="color: #0000ff;">         */</span>
<span style="color: #a52a2a;">174</span>          Key symmetricKey = GenerateDataEncryptionKey();
<span style="color: #a52a2a;">175</span>
<span style="color: #a52a2a;">176</span>          <span style="color: #0000ff;">/*</span>
<span style="color: #a52a2a;">177</span>  <span style="color: #0000ff;">         * Get a key to be used for encrypting the symmetric key.</span>
<span style="color: #a52a2a;">178</span>  <span style="color: #0000ff;">         * Here we are generating a DESede key.</span>
<span style="color: #a52a2a;">179</span>  <span style="color: #0000ff;">         */</span>
<span style="color: #a52a2a;">180</span>          Key kek = GenerateAndStoreKeyEncryptionKey();
<span style="color: #a52a2a;">181</span>
<span style="color: #a52a2a;">182</span>          String algorithmURI = XMLCipher.TRIPLEDES_KeyWrap;
<span style="color: #a52a2a;">183</span>
<span style="color: #a52a2a;">184</span>          XMLCipher keyCipher =
<span style="color: #a52a2a;">185</span>              XMLCipher.getInstance(algorithmURI);
<span style="color: #a52a2a;">186</span>          keyCipher.init(XMLCipher.WRAP_MODE, kek);
<span style="color: #a52a2a;">187</span>          EncryptedKey encryptedKey =
<span style="color: #a52a2a;">188</span>              keyCipher.encryptKey(document, symmetricKey);
<span style="color: #a52a2a;">189</span>
<span style="color: #a52a2a;">190</span>          <span style="color: #0000ff;">/*</span>
<span style="color: #a52a2a;">191</span>  <span style="color: #0000ff;">         * Let us encrypt the contents of the document element.</span>
<span style="color: #a52a2a;">192</span>  <span style="color: #0000ff;">         */</span>
<span style="color: #a52a2a;">193</span>          Element rootElement = document.getDocumentElement();
<span style="color: #a52a2a;">194</span>          NodeList node =  rootElement.getElementsByTagName(<span style="color: #ff00ff;">"apache:bar"</span>);
<span style="color: #a52a2a;">195</span>          rootElement = (Element) node.item(<span style="color: #ff00ff;">0</span>);
<span style="color: #a52a2a;">196</span>          System.out.println(<span style="color: #ff00ff;">"node="</span>+node);
<span style="color: #a52a2a;">197</span>         <span style="color: #0000ff;">// rootElement = (Element)</span>
<span style="color: #a52a2a;">198</span>                  System.out.println(<span style="color: #ff00ff;">"rootElement="</span>+rootElement);
<span style="color: #a52a2a;">199</span>          <span style="color: #0000ff;">//rootElement = (Element) rootElement.getFirstChild().getFirstChild();</span>
<span style="color: #a52a2a;">200</span>
<span style="color: #a52a2a;">201</span>          algorithmURI = XMLCipher.AES_128;
<span style="color: #a52a2a;">202</span>
<span style="color: #a52a2a;">203</span>          XMLCipher xmlCipher =
<span style="color: #a52a2a;">204</span>              XMLCipher.getInstance(algorithmURI);
<span style="color: #a52a2a;">205</span>          xmlCipher.init(XMLCipher.ENCRYPT_MODE, symmetricKey);
<span style="color: #a52a2a;">206</span>
<span style="color: #a52a2a;">207</span>          <span style="color: #0000ff;">/*</span>
<span style="color: #a52a2a;">208</span>  <span style="color: #0000ff;">         * Setting keyinfo inside the encrypted data being prepared.</span>
<span style="color: #a52a2a;">209</span>  <span style="color: #0000ff;">         */</span>
<span style="color: #a52a2a;">210</span>          EncryptedData encryptedData = xmlCipher.getEncryptedData();
<span style="color: #a52a2a;">211</span>          KeyInfo keyInfo = <span style="color: #a52a2a;"><strong>new</strong></span> KeyInfo(document);
<span style="color: #a52a2a;">212</span>          keyInfo.add(encryptedKey);
<span style="color: #a52a2a;">213</span>          encryptedData.setKeyInfo(keyInfo);
<span style="color: #a52a2a;">214</span>
<span style="color: #a52a2a;">215</span>          <span style="color: #0000ff;">/*</span>
<span style="color: #a52a2a;">216</span>  <span style="color: #0000ff;">         * doFinal -</span>
<span style="color: #a52a2a;">217</span>  <span style="color: #0000ff;">         * "true" below indicates that we want to encrypt element's content</span>
<span style="color: #a52a2a;">218</span>  <span style="color: #0000ff;">         * and not the element itself. Also, the doFinal method would</span>
<span style="color: #a52a2a;">219</span>  <span style="color: #0000ff;">         * modify the document by replacing the EncrypteData element</span>
<span style="color: #a52a2a;">220</span>  <span style="color: #0000ff;">         * for the data to be encrypted.</span>
<span style="color: #a52a2a;">221</span>  <span style="color: #0000ff;">         */</span>
<span style="color: #a52a2a;">222</span>          xmlCipher.doFinal(document, rootElement, <span style="color: #ff00ff;">true</span>);
<span style="color: #a52a2a;">223</span>
<span style="color: #a52a2a;">224</span>          <span style="color: #0000ff;">/*</span>
<span style="color: #a52a2a;">225</span>  <span style="color: #0000ff;">         * Output the document containing the encrypted information into</span>
<span style="color: #a52a2a;">226</span>  <span style="color: #0000ff;">         * a file.</span>
<span style="color: #a52a2a;">227</span>  <span style="color: #0000ff;">         */</span>
<span style="color: #a52a2a;">228</span>          outputDocToFile(document, <span style="color: #ff00ff;">"encryptedInfo2.xml"</span>);
<span style="color: #a52a2a;">229</span>      }
<span style="color: #a52a2a;">230</span>  }</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mattpayne.org/blog/2006/06/23/no-doubt-apaches-xml-security-will-encrypt-subtrees/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email Archives from Enron</title>
		<link>http://www.mattpayne.org/blog/2006/02/23/email-archives-from-enron/</link>
		<comments>http://www.mattpayne.org/blog/2006/02/23/email-archives-from-enron/#comments</comments>
		<pubDate>Thu, 23 Feb 2006 20:03:04 +0000</pubDate>
		<dc:creator>Payne</dc:creator>
				<category><![CDATA[IA]]></category>
		<category><![CDATA[LinkBlog]]></category>

		<guid isPermaLink="false">http://www.mattpayne.org/blog/2006/02/23/email-archives-from-enron/</guid>
		<description><![CDATA[It&#8217;s important to remember that email sent via your corporate email account is not private. About 500,000 email messages from the enron email servers are now publicly available because of the corporate scandal. You can get the dataset and pointers to some papers that talk about it here: www.cs.cmu.edu/~enron/. It would be fun to run [...]]]></description>
			<content:encoded><![CDATA[<p><a name="enron"></a>It&#8217;s important to remember that email sent via your corporate email account is not private.</p>
<p><a name="enron"></a>About 500,000 email messages from the enron email servers  are  <a href="http://www.cs.cmu.edu/%7Eenron/">now publicly available</a> because  of the corporate scandal. You can get the dataset and pointers to some papers  that talk about it  <a href="http://www.cs.cmu.edu/%7Eenron/">here: www.cs.cmu.edu/~enron/</a>.</p>
<p>It would be fun to run this email through Microsoft&#8217;s <a href="http://research.microsoft.com/community/snarf/">SNARF, the Social Network and Relationship Finder, from Microsoft Research</a>; or some other social network software.</p>
<p>Here are a few links that I saved from a google search:</p>
<ol>
<li><a href="http://www.mccombs.utexas.edu/news/mentions/arts/2004/07.09_NPR_Prentice.asp">Prentice Discusses Ethics &amp; Law in the Enron Era on NPR</a></li>
<li><a href="http://www.salon.com/news/feature/2003/10/14/enron/index_np.html"> The decline and fall of the Enron empire</a></li>
<li><a href="http://www.enronemail.com/">enronemail.com</a></li>
<li><a href="http://bailando.sims.berkeley.edu/enron_email.html">UC Berkeley Enron Email Analysis</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.mattpayne.org/blog/2006/02/23/email-archives-from-enron/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.369 seconds -->
