<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Stefan Reuter</title>
	
	<link>http://blogs.reucon.com/srt</link>
	<description>My Personal Blog</description>
	<lastBuildDate>Tue, 10 Jan 2012 19:18:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/srt" /><feedburner:info uri="srt" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>ClassLoader Leaks by Oracle</title>
		<link>http://feedproxy.google.com/~r/srt/~3/8XTL1Dgl31g/</link>
		<comments>http://blogs.reucon.com/srt/classloader-leaks-by-oracle-9056/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 04:16:15 +0000</pubDate>
		<dc:creator>Stefan Reuter</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[leak]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://blogs.reucon.com/srt/?p=9056</guid>
		<description><![CDATA[I recently had trouble with a web application deployed on Tomcat that leaked its ClassLoader every time it was redeployed resulting in OutOfMemoryErrors after a few redeployments. This is quite nasty if you plan to do continuous deployment and don&#8217;t &#8230; <a href="http://blogs.reucon.com/srt/classloader-leaks-by-oracle-9056/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently had trouble with a web application deployed on Tomcat that leaked its ClassLoader every time it was redeployed resulting in OutOfMemoryErrors after a few redeployments. This is quite nasty if you plan to do continuous deployment and don&#8217;t want to restart the servlet container with each deployment.</p>
<p>Recent versions of Tomcat include <a href="http://wiki.apache.org/tomcat/MemoryLeakProtection">some code</a> that makes you aware of problems when you undeploy the application:</p>
<pre>SEVERE: The web application [] registered the JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped.
 To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
SEVERE: The web application [] appears to have started a thread named [Thread-14] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [] appears to have started a thread named [Thread-15] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [] appears to have started a thread named [Thread-16] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [] appears to have started a thread named [Thread-17] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [] appears to have started a thread named [Thread-18] but has failed to stop it. This is very likely to create a memory leak.</pre>
<p>As you can see Tomcat managed to unregister the JDBC driver that the application had failed to unregister but could do nothing regarding the threads that had been started but not stopped.</p>
<p>I ran the application with <a href="http://www.yourkit.com/">YourKit</a> attached to check that the WebappClassLoader had actually leaked and to see what those threads were that prevented it from being garbage collected. The &#8220;Paths from GC Roots&#8221; view in YourKit is well suited for this:</p>
<p><img class="alignnone  wp-image-9256" title="ons-leaking-threads" src="http://blogs.reucon.com/srt/files/2012/01/ons-leaking-threads.png" alt="ONS Leaking Threads" width="569" height="198" /></p>
<p>As you can see there are four threads from <acronym title="Oracle Notification Service">ONS</acronym> that prevent the ClassLoader from being garbage collected: <code>oracle.ons.SenderThread</code>s and <code>oracle.ons.ReceiverThread</code>s.</p>
<p>I wrote a small ServletContextListener that shuts down ONS to get rid of them. After that I noticed that Oracle registered a <code>OracleDiagnosabilityMBean</code> that I had to unregister. Finally I made sure the JDBC drivers that the application had registered were properly unregistered from <code>DriverManager</code>.</p>
<p>With those changes in place the application undeployed well and was fully garbage collected.</p>
<p>Here is the code:</p>
<div class="gistem"><div id="gist-1571892" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="kn">import</span> <span class="nn">oracle.ons.ONS</span><span class="o">;</span></div><div class='line' id='LC2'><span class="kn">import</span> <span class="nn">oracle.ons.SenderThread</span><span class="o">;</span></div><div class='line' id='LC3'><span class="kn">import</span> <span class="nn">org.slf4j.Logger</span><span class="o">;</span></div><div class='line' id='LC4'><span class="kn">import</span> <span class="nn">org.slf4j.LoggerFactory</span><span class="o">;</span></div><div class='line' id='LC5'><span class="kn">import</span> <span class="nn">org.springframework.util.ReflectionUtils</span><span class="o">;</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'><span class="kn">import</span> <span class="nn">javax.management.MBeanServer</span><span class="o">;</span></div><div class='line' id='LC8'><span class="kn">import</span> <span class="nn">javax.management.ObjectName</span><span class="o">;</span></div><div class='line' id='LC9'><span class="kn">import</span> <span class="nn">javax.servlet.ServletContextEvent</span><span class="o">;</span></div><div class='line' id='LC10'><span class="kn">import</span> <span class="nn">javax.servlet.ServletContextListener</span><span class="o">;</span></div><div class='line' id='LC11'><span class="kn">import</span> <span class="nn">java.lang.management.ManagementFactory</span><span class="o">;</span></div><div class='line' id='LC12'><span class="kn">import</span> <span class="nn">java.lang.reflect.Field</span><span class="o">;</span></div><div class='line' id='LC13'><span class="kn">import</span> <span class="nn">java.lang.reflect.Method</span><span class="o">;</span></div><div class='line' id='LC14'><span class="kn">import</span> <span class="nn">java.sql.Driver</span><span class="o">;</span></div><div class='line' id='LC15'><span class="kn">import</span> <span class="nn">java.sql.DriverManager</span><span class="o">;</span></div><div class='line' id='LC16'><span class="kn">import</span> <span class="nn">java.util.ArrayList</span><span class="o">;</span></div><div class='line' id='LC17'><span class="kn">import</span> <span class="nn">java.util.Enumeration</span><span class="o">;</span></div><div class='line' id='LC18'><span class="kn">import</span> <span class="nn">java.util.Hashtable</span><span class="o">;</span></div><div class='line' id='LC19'><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span></div><div class='line' id='LC20'><br/></div><div class='line' id='LC21'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">CleanUpListener</span> <span class="kd">implements</span> <span class="n">ServletContextListener</span> <span class="o">{</span></div><div class='line' id='LC22'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">private</span> <span class="n">Logger</span> <span class="n">logger</span> <span class="o">=</span> <span class="n">LoggerFactory</span><span class="o">.</span><span class="na">getLogger</span><span class="o">(</span><span class="n">getClass</span><span class="o">());</span></div><div class='line' id='LC23'><br/></div><div class='line' id='LC24'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nd">@Override</span></div><div class='line' id='LC25'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">public</span> <span class="kt">void</span> <span class="nf">contextInitialized</span><span class="o">(</span><span class="n">ServletContextEvent</span> <span class="n">sce</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// do nothing</span></div><div class='line' id='LC27'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC28'><br/></div><div class='line' id='LC29'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nd">@Override</span></div><div class='line' id='LC30'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">public</span> <span class="kt">void</span> <span class="nf">contextDestroyed</span><span class="o">(</span><span class="n">ServletContextEvent</span> <span class="n">sce</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC31'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">shutdownOns</span><span class="o">();</span></div><div class='line' id='LC32'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">deregisterJdbcDrivers</span><span class="o">();</span></div><div class='line' id='LC33'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC34'><br/></div><div class='line' id='LC35'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nd">@SuppressWarnings</span><span class="o">(</span><span class="s">&quot;unchecked&quot;</span><span class="o">)</span></div><div class='line' id='LC36'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">private</span> <span class="kt">void</span> <span class="nf">shutdownOns</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC37'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">info</span><span class="o">(</span><span class="s">&quot;Shutting down ONS&quot;</span><span class="o">);</span></div><div class='line' id='LC38'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Method</span> <span class="n">getRunningONS</span> <span class="o">=</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">findMethod</span><span class="o">(</span><span class="n">ONS</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="s">&quot;getRunningONS&quot;</span><span class="o">);</span></div><div class='line' id='LC39'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Method</span> <span class="n">shutdown</span> <span class="o">=</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">findMethod</span><span class="o">(</span><span class="n">ONS</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="s">&quot;shutdown&quot;</span><span class="o">);</span></div><div class='line' id='LC40'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">makeAccessible</span><span class="o">(</span><span class="n">getRunningONS</span><span class="o">);</span></div><div class='line' id='LC41'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">makeAccessible</span><span class="o">(</span><span class="n">shutdown</span><span class="o">);</span></div><div class='line' id='LC42'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">ONS</span> <span class="n">ons</span> <span class="o">=</span> <span class="o">(</span><span class="n">ONS</span><span class="o">)</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">invokeMethod</span><span class="o">(</span><span class="n">getRunningONS</span><span class="o">,</span> <span class="kc">null</span><span class="o">);</span></div><div class='line' id='LC43'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="o">(</span><span class="n">ons</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC44'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span><span class="o">;</span></div><div class='line' id='LC45'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC46'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC47'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">invokeMethod</span><span class="o">(</span><span class="n">shutdown</span><span class="o">,</span> <span class="n">ons</span><span class="o">);</span></div><div class='line' id='LC48'><br/></div><div class='line' id='LC49'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Field</span> <span class="n">senders</span> <span class="o">=</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">findField</span><span class="o">(</span><span class="n">ONS</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="s">&quot;senders&quot;</span><span class="o">);</span></div><div class='line' id='LC50'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">makeAccessible</span><span class="o">(</span><span class="n">senders</span><span class="o">);</span></div><div class='line' id='LC51'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">SenderThread</span><span class="o">&gt;</span> <span class="n">senderThreads</span> <span class="o">=</span> <span class="o">(</span><span class="n">List</span><span class="o">&lt;</span><span class="n">SenderThread</span><span class="o">&gt;)</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">getField</span><span class="o">(</span><span class="n">senders</span><span class="o">,</span> <span class="n">ons</span><span class="o">);</span></div><div class='line' id='LC52'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="o">(</span><span class="n">senderThreads</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC53'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span><span class="o">;</span></div><div class='line' id='LC54'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC55'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC56'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Method</span> <span class="n">stopThread</span> <span class="o">=</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">findMethod</span><span class="o">(</span><span class="n">SenderThread</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="s">&quot;stopThread&quot;</span><span class="o">);</span></div><div class='line' id='LC57'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">makeAccessible</span><span class="o">(</span><span class="n">stopThread</span><span class="o">);</span></div><div class='line' id='LC58'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="o">(</span><span class="n">SenderThread</span> <span class="n">senderThread</span> <span class="o">:</span> <span class="n">senderThreads</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC59'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">invokeMethod</span><span class="o">(</span><span class="n">stopThread</span><span class="o">,</span> <span class="n">senderThread</span><span class="o">);</span></div><div class='line' id='LC60'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC61'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC62'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC63'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">private</span> <span class="kt">void</span> <span class="nf">deregisterJdbcDrivers</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC64'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">info</span><span class="o">(</span><span class="s">&quot;Deregistering JDBC Drivers&quot;</span><span class="o">);</span></div><div class='line' id='LC65'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Enumeration</span><span class="o">&lt;</span><span class="n">Driver</span><span class="o">&gt;</span> <span class="n">driverEnumeration</span> <span class="o">=</span> <span class="n">DriverManager</span><span class="o">.</span><span class="na">getDrivers</span><span class="o">();</span></div><div class='line' id='LC66'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Driver</span><span class="o">&gt;</span> <span class="n">drivers</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">Driver</span><span class="o">&gt;();</span></div><div class='line' id='LC67'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">while</span> <span class="o">(</span><span class="n">driverEnumeration</span><span class="o">.</span><span class="na">hasMoreElements</span><span class="o">())</span> <span class="o">{</span></div><div class='line' id='LC68'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">drivers</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">driverEnumeration</span><span class="o">.</span><span class="na">nextElement</span><span class="o">());</span></div><div class='line' id='LC69'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC70'><br/></div><div class='line' id='LC71'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="o">(</span><span class="n">Driver</span> <span class="n">driver</span> <span class="o">:</span> <span class="n">drivers</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC72'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="o">(</span><span class="n">driver</span><span class="o">.</span><span class="na">getClass</span><span class="o">().</span><span class="na">getClassLoader</span><span class="o">()</span> <span class="o">!=</span> <span class="n">getClass</span><span class="o">().</span><span class="na">getClassLoader</span><span class="o">())</span> <span class="o">{</span></div><div class='line' id='LC73'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">debug</span><span class="o">(</span><span class="s">&quot;Not deregistering {} as it does not originate from this webapp&quot;</span><span class="o">,</span> <span class="n">driver</span><span class="o">.</span><span class="na">getClass</span><span class="o">().</span><span class="na">getName</span><span class="o">());</span></div><div class='line' id='LC74'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">continue</span><span class="o">;</span></div><div class='line' id='LC75'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC76'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">try</span> <span class="o">{</span></div><div class='line' id='LC77'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">DriverManager</span><span class="o">.</span><span class="na">deregisterDriver</span><span class="o">(</span><span class="n">driver</span><span class="o">);</span></div><div class='line' id='LC78'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">debug</span><span class="o">(</span><span class="s">&quot;Deregistered JDBC driver &#39;{}&#39;&quot;</span><span class="o">,</span> <span class="n">driver</span><span class="o">.</span><span class="na">getClass</span><span class="o">().</span><span class="na">getName</span><span class="o">());</span></div><div class='line' id='LC79'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="o">(</span><span class="s">&quot;oracle.jdbc.OracleDriver&quot;</span><span class="o">.</span><span class="na">equals</span><span class="o">(</span><span class="n">driver</span><span class="o">.</span><span class="na">getClass</span><span class="o">().</span><span class="na">getName</span><span class="o">()))</span> <span class="o">{</span></div><div class='line' id='LC80'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">deregisterOracleDiagnosabilityMBean</span><span class="o">();</span></div><div class='line' id='LC81'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC82'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Throwable</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC83'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">error</span><span class="o">(</span><span class="s">&quot;Deregistration error&quot;</span><span class="o">,</span> <span class="n">e</span><span class="o">);</span></div><div class='line' id='LC84'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC85'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC86'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC87'><br/></div><div class='line' id='LC88'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">private</span> <span class="kt">void</span> <span class="nf">deregisterOracleDiagnosabilityMBean</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC89'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">ClassLoader</span> <span class="n">cl</span> <span class="o">=</span> <span class="n">Thread</span><span class="o">.</span><span class="na">currentThread</span><span class="o">().</span><span class="na">getContextClassLoader</span><span class="o">();</span></div><div class='line' id='LC90'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">try</span> <span class="o">{</span></div><div class='line' id='LC91'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">MBeanServer</span> <span class="n">mbs</span> <span class="o">=</span> <span class="n">ManagementFactory</span><span class="o">.</span><span class="na">getPlatformMBeanServer</span><span class="o">();</span></div><div class='line' id='LC92'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Hashtable</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">keys</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Hashtable</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;();</span></div><div class='line' id='LC93'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">keys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;type&quot;</span><span class="o">,</span> <span class="s">&quot;diagnosability&quot;</span><span class="o">);</span></div><div class='line' id='LC94'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">keys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="n">cl</span><span class="o">.</span><span class="na">getClass</span><span class="o">().</span><span class="na">getName</span><span class="o">()</span> <span class="o">+</span> <span class="s">&quot;@&quot;</span> <span class="o">+</span> <span class="n">Integer</span><span class="o">.</span><span class="na">toHexString</span><span class="o">(</span><span class="n">cl</span><span class="o">.</span><span class="na">hashCode</span><span class="o">()).</span><span class="na">toLowerCase</span><span class="o">());</span></div><div class='line' id='LC95'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">mbs</span><span class="o">.</span><span class="na">unregisterMBean</span><span class="o">(</span><span class="k">new</span> <span class="n">ObjectName</span><span class="o">(</span><span class="s">&quot;com.oracle.jdbc&quot;</span><span class="o">,</span> <span class="n">keys</span><span class="o">));</span></div><div class='line' id='LC96'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">info</span><span class="o">(</span><span class="s">&quot;Deregistered OracleDiagnosabilityMBean&quot;</span><span class="o">);</span></div><div class='line' id='LC97'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">javax</span><span class="o">.</span><span class="na">management</span><span class="o">.</span><span class="na">InstanceNotFoundException</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC98'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">debug</span><span class="o">(</span><span class="s">&quot;Oracle OracleDiagnosabilityMBean not found&quot;</span><span class="o">,</span> <span class="n">e</span><span class="o">);</span></div><div class='line' id='LC99'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Throwable</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC100'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">error</span><span class="o">(</span><span class="s">&quot;Oracle JMX unregistration error&quot;</span><span class="o">,</span> <span class="n">e</span><span class="o">);</span></div><div class='line' id='LC101'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC102'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC103'><span class="o">}</span></div><div class='line' id='LC104'><br/></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1571892/f8d0b7099209db9be49135248d036b4a8c710947/CleanUpListener.java" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1571892#file_clean_up_listener.java" style="float:right;margin-right:10px;color:#666">CleanUpListener.java</a>
            <a href="https://gist.github.com/1571892">This Gist</a> is brought to you using <a href="http://en.bainternet.info/2011/simple-gist-embed"><small>Simple Gist Embed</small></a>.
          </div>
        </div>
</div>
</div><style type="text/css">@import "http://gist.github.com/stylesheets/gist/embed.css"; .gistem .highlight {background: inherit; !important;}</style>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/srt?a=8XTL1Dgl31g:49A1GHfU-xs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/srt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=8XTL1Dgl31g:49A1GHfU-xs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/srt?i=8XTL1Dgl31g:49A1GHfU-xs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=8XTL1Dgl31g:49A1GHfU-xs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/srt?i=8XTL1Dgl31g:49A1GHfU-xs:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/srt/~4/8XTL1Dgl31g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.reucon.com/srt/classloader-leaks-by-oracle-9056/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.reucon.com/srt/classloader-leaks-by-oracle-9056/</feedburner:origLink></item>
		<item>
		<title>My First Steps with Arch Linux</title>
		<link>http://feedproxy.google.com/~r/srt/~3/nyr-zH1fRk4/</link>
		<comments>http://blogs.reucon.com/srt/my-first-steps-with-arch-linux-8286/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 17:04:00 +0000</pubDate>
		<dc:creator>Stefan Reuter</dc:creator>
				<category><![CDATA[arch]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">/?p=8286</guid>
		<description><![CDATA[I&#8217;ve been using Ubuntu for quite some time now on my desktop and for my servers. It works well and I like the Debian style apt package manager. However I am less happy with the more recent developments. Ubuntu packages &#8230; <a href="http://blogs.reucon.com/srt/my-first-steps-with-arch-linux-8286/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="/srt/wp-content/files/2011/12/archlinux.png" align="right"/><br />
I&#8217;ve been using <a href="http://www.ubuntu.com/">Ubuntu</a> for quite some time now on my desktop and for my servers. It works well and I like the Debian style apt package manager. However I am less happy with the more recent developments. Ubuntu packages differ more and more from the upstream packages and with their focus on <a href="http://unity.ubuntu.com/">Unity</a> I started wondering whether there is a better fit for my Linux needs.</p>
<p>For my new T420s I decided to give <a href="http://www.archlinux.org/">Arch Linux</a> a try after I had a short look at Mint, Debian, Fedora and openSUSE.</p>
<p> <a href="https://wiki.archlinux.org/index.php/The_Arch_Way">The Arch Way</a> makes Arch different as it values simplicity and takes an elegant, minimalist approach. The core installation installs just what you absolutely need so you are greeted by a friendly command line when it&#8217;s done. After that you can easily install a graphical environment including Gnome 3 with or without shell, KDE and Xfce along with whatever packages you need. Software patches are kept to a minimum so most Arch packages are identical or at least very close to their upstream counterparts. The difference is similar to the &#8220;Google experience&#8221; of a Nexus One or Nexus S and the modified Android versions sold by the manufacturers. New versions of upstream software end up in Arch within days.</p>
<p>Arch is a rolling release distro that allows for a one-time installation and perpetual software upgrades. There is no need to reinstall or upgrade the system from one version to the next. Everything in Arch is bleeding edge.</p>
<p>Installation on my T420s did not work as smooth as Ubuntu. The latest official <a href="http://www.archlinux.org/download/">installation ISO</a> is from May 2010 and does not support the network card of the T420s. There are newer testing versions but they have <a href="https://bugs.archlinux.org/task/24729">issues</a> setting up full disk encryption. So I went with the official ISO and installed the updates via WLAN which worked well.</p>
<p>If you come from the Debian world you are used to apt for package management. Arch comes with <a href="https://wiki.archlinux.org/index.php/Pacman">pacman</a> which is similar but a lot faster. Bringing your system up to date just means you have to run <code>pacman -Syu</code> instead of <code>apt-get update &#038;&#038; apt-get upgrade</code>. After that you have the latest kernel (2.6.39 as of now). I Installed a few additional packages including XF86, Gnome, Chromium, Thunderbird and Libre Office and had a nice working system. Sound and the Touchpad including scrolling worked out of the box. For the network I decided to use Gnome&#8217;s NetworkManager so I installed network-manager-applet and modemmanager and got an easy to manage network setup with support for wired lan, WLAN and wireless broadband. My Ericsson F5521gw was recognized automatically and UMTS worked right away.</p>
<p>The <a href="https://wiki.archlinux.org">Arch Wiki</a> is a great resource and the home of the excellent documentation of Arch. For each part of the system you have multiple options to choose from and they are well explained.</p>
<p>Up to now I am really happy with Arch.</p>
<p><b>A few notes:</b></p>
<p>To setup focus follows mouse in Gnome run</p>
<pre>gconf-editor /apps/metacity/general/focus_mode</pre>
<p>and change the value from <code>click</code> to <code>sloppy</code>.</p>
<p>To make the massive Gnome 3 title bars a bit less high run</p>
<pre>sed -i \
 &quot;/title_vertical_pad/s/value=\&quot;[0-9]\{1,2\}\&quot;/value=\&quot;0\&quot;/g&quot; \
 /usr/share/themes/Adwaita/metacity-1/metacity-theme-3.xml</pre></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/srt?a=nyr-zH1fRk4:QTeXVk7hcQc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/srt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=nyr-zH1fRk4:QTeXVk7hcQc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/srt?i=nyr-zH1fRk4:QTeXVk7hcQc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=nyr-zH1fRk4:QTeXVk7hcQc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/srt?i=nyr-zH1fRk4:QTeXVk7hcQc:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/srt/~4/nyr-zH1fRk4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.reucon.com/srt/my-first-steps-with-arch-linux-8286/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://blogs.reucon.com/srt/my-first-steps-with-arch-linux-8286/</feedburner:origLink></item>
		<item>
		<title>From Subversion to Git</title>
		<link>http://feedproxy.google.com/~r/srt/~3/ncHMOiBuMwE/</link>
		<comments>http://blogs.reucon.com/srt/from-subversion-to-git-8156/#comments</comments>
		<pubDate>Sat, 25 Dec 2010 13:32:58 +0000</pubDate>
		<dc:creator>Stefan Reuter</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">/?p=8156</guid>
		<description><![CDATA[Yesterday I&#8217;ve converted the Asterisk-Java repositories from Subversion to git. It&#8217;s rather easy when you use git-svn: sudo apt-get install git-svn git svn clone file:///var/lib/svn/repos/asterisk-java \ --no-metadata -A authors.txt \ -t tags -b branches -T trunk asterisk-java The authors file &#8230; <a href="http://blogs.reucon.com/srt/from-subversion-to-git-8156/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
Yesterday I&#8217;ve converted the <a href="http://asterisk-java.org">Asterisk-Java</a> repositories from Subversion to git. It&#8217;s rather easy when you use git-svn:
</p>
<pre class="brush: plain;">
sudo apt-get install git-svn
git svn clone file:///var/lib/svn/repos/asterisk-java \
  --no-metadata -A authors.txt \
  -t tags -b branches -T trunk asterisk-java
</pre>
<p>
The authors file maps the users in Subversion to the git users. While Subversion usually uses a short username, git uses the full name with email address as a globally unique identifier for users. My authors file looked like this:
</p>
<pre class="brush: plain;">
srt = Stefan Reuter &lt;stefan.reuter@example.com&gt;
root = Stefan Reuter &lt;stefan.reuter@example.com&gt;
</pre>
<p>
As I had direct filesystem access to the Subversion repositories I chose to use the file protocol instead of HTTP so it was much faster. The <code>--no-metadata</code> option tells git-svn not to include the orignal Subversion revision number in every commit. This removes clutter from the history.
</p>
<p>
Finally git-svn creates branches for all tags in Subversion which is a bit nasty. So I converted them to git tags:
</p>
<pre class="brush: plain;">
cd asterisk-java
for tag in `git branch -r | grep '^  tags' | sed 's,  tags/,,'`
do
  echo Converting Tag $tag
  git tag $tag tags/$tag
  git branch -r -d tags/$tag
done
</pre>
<p>
There it is a nice git repository containing the full history. I only had to push it to <a href="http://github.com">github</a> to make it available to everybody who is interested:
</p>
<pre class="brush: plain;">
git remote add origin git@github.com:srt/asterisk-java.git
git push origin master
git push --tags
</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/srt?a=ncHMOiBuMwE:TEKD9vka_1o:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/srt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=ncHMOiBuMwE:TEKD9vka_1o:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/srt?i=ncHMOiBuMwE:TEKD9vka_1o:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=ncHMOiBuMwE:TEKD9vka_1o:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/srt?i=ncHMOiBuMwE:TEKD9vka_1o:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/srt/~4/ncHMOiBuMwE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.reucon.com/srt/from-subversion-to-git-8156/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.reucon.com/srt/from-subversion-to-git-8156/</feedburner:origLink></item>
		<item>
		<title>Spring Framework Security Vulnerability Part 2</title>
		<link>http://feedproxy.google.com/~r/srt/~3/sOeyz5az-4c/</link>
		<comments>http://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-2-8756/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 12:14:00 +0000</pubDate>
		<dc:creator>Stefan Reuter</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Operations]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">/?p=8756</guid>
		<description><![CDATA[I&#8217;ve already talked about CVE-2010-1622 and what SpringSource could have done better when dealing with this security issue. Today I want to focus on what you as a developer or system administrator can learn from the bug. What can developers &#8230; <a href="http://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-2-8756/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;ve already talked about <a href="http://blogs.reucon.com/srt/2010/06/26/spring_framework_security_vulnerability_part_1.html">CVE-2010-1622</a> and what SpringSource could have done better when dealing with this security issue.<br/><br />
Today I want to focus on what you as a developer or system administrator can learn from the bug.
</p>
<p><b>What can developers learn from CVE-2010-1622?</b></p>
<p>The exploit requires manipulating the class loader property so that it will download code from an external site. So you can prevent the attack by disallowing modifications of the class loader and by disallowing your application to download and run code from external sites.</p>
<p>Be explicit! Explicitly allow binding of certain properties. This prevents the exploit from working as there is no valid use case that requires access to the class property. Explicitly whitelisting properties also makes sure users cannot change the id of the object bound to a form or altering data that is managed internally like &#8220;date of creation&#8221; or &#8220;last modified by&#8221; properties.</p>
<p>To prevent code from external sites being downloaded and executed you can make sure your applications behaves well when run with a <a href="http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/security/tour2/index.html">security manager</a>. While this is a common concept used for client side code like applets it is far less common for server side applications. Tomcat usually works well with a security manager though it is not enabled by default. Making sure you appplications works with a security manager is also a variant of being explicit: You explicitly grant certain privileges to your code bases and disallow everything else that might be abused by attackers.</p>
<p><b>What can system administrators learn from CVE-2010-1622?</b></p>
<p>Your applications should run in a demilitarized zone where they are unable to access the internet or your intranet. If you really need access to external resources use a proxy server and white list the URLs your application needs to contact. Doing so prevents attackers from making your application download external code.</p>
<p>If your applications are built in a way that they work with a security manager use it! For Tomcat there is a short <a href="http://tomcat.apache.org/tomcat-7.0-doc/security-manager-howto.html">Howto</a> available.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/srt?a=sOeyz5az-4c:M63LTVDTrhw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/srt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=sOeyz5az-4c:M63LTVDTrhw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/srt?i=sOeyz5az-4c:M63LTVDTrhw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=sOeyz5az-4c:M63LTVDTrhw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/srt?i=sOeyz5az-4c:M63LTVDTrhw:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/srt/~4/sOeyz5az-4c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-2-8756/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-2-8756/</feedburner:origLink></item>
		<item>
		<title>Spring Framework Security Vulnerability Part 1</title>
		<link>http://feedproxy.google.com/~r/srt/~3/SPj0si8XkAk/</link>
		<comments>http://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-1-8786/#comments</comments>
		<pubDate>Sat, 26 Jun 2010 09:25:00 +0000</pubDate>
		<dc:creator>Stefan Reuter</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">/?p=8786</guid>
		<description><![CDATA[Spring Source recently published CVE-2010-1622. The advisory describes a vulnerability that affects Spring Framework prior to 3.0.3 and allows attackers to execute arbitrary code. What could SpringSource have done better? When Spring Source announced the release of 3.0.3 they reported &#8230; <a href="http://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-1-8786/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
<img src="/srt/wp-content/files/2011/12/spring09_logo.png" align="right" hspace="5" vspace="5"/><br />
Spring Source recently published <a href="http://www.springsource.com/security/cve-2010-1622">CVE-2010-1622</a>. The advisory describes a vulnerability that affects Spring Framework prior to 3.0.3 and allows attackers to execute arbitrary code.
</p>
<p><b>What could SpringSource have done better?</b></p>
<p>
When Spring Source announced the release of 3.0.3 they reported to have fixed <a href="http://blog.springsource.com/2010/06/15/spring-framework-3-0-3-released/">&#8220;more than a hundred minor issues&#8221;</a> &mdash; no indication of the security fix. This could be understandable as they have released the fix 2 days prior to publishing the advisory. I do not understand why they did not announce it later however. The advisory was published as silently as possible although the vulnerability is rated critical, can be exploited remotely and probably affects a large number of applications.<br/><br />
I would have preferred receiving the security advisory through the usual channels used for announcements in addition to the <a href="http://www.springsource.com/security">security team page</a>.
</p>
<p>
Having a look at <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-1622">cve.mitre.org</a> reveals another interesting fact. The CVE id was assigned on April, 29th. That is almost 2 months before the advisory was published. The bug was <a href="https://fisheye.springsource.org/changelog/spring-framework?cs=3374">fixed</a> on May, 27th.<br/><br />
Why does it take more than 4 weeks for a 3 line fix? Why does it take almost 3 additional weeks after the fix to announce the vulnerability?<br/><br />
I would have preferred a priority fix as soon as possible after discovery and a release following short time after that.
</p>
<p>
Finally SpringSource dicided not to provide a fixed release for dm Server, a product based on Spring Framework, which is also vulnerable. Users are advised to manually patch it instead. SpringSource also continues to provide the vulnerable <a href="http://www.springsource.com/products/springsource-download-center">dm Server 2.0.2</a> for download without any warning.<br/><br />
I would have preferred to receive a fixed release of dm Server instead of seeing SpringSource continue to ship products containing known security issues.
</p>
<p><b>What can you learn from CVE-2010-1622?</b></p>
<p>
I will follow up with the lessons learned for application developers and system administrators in the next days. Stay tuned.
</p>
<p>
There is also an interesting analysis of the issue at <a href="http://blog.o0o.nu/2010/06/cve-2010-1622.html">blog.o0o.nu</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/srt?a=SPj0si8XkAk:2d04jvx1fME:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/srt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=SPj0si8XkAk:2d04jvx1fME:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/srt?i=SPj0si8XkAk:2d04jvx1fME:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=SPj0si8XkAk:2d04jvx1fME:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/srt?i=SPj0si8XkAk:2d04jvx1fME:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/srt/~4/SPj0si8XkAk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-1-8786/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-1-8786/</feedburner:origLink></item>
		<item>
		<title>Code Style: Braces, Indentation and Line Length</title>
		<link>http://feedproxy.google.com/~r/srt/~3/joch9vShszA/</link>
		<comments>http://blogs.reucon.com/srt/code-style-braces-indentation-and-line-length-8846/#comments</comments>
		<pubDate>Sun, 23 May 2010 20:26:31 +0000</pubDate>
		<dc:creator>Stefan Reuter</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">/?p=8846</guid>
		<description><![CDATA[We&#8217;ve recently revisted our Java Coding Conventions. For several years we are now using a style based on the excellent book The Elements of Java Style by RougeWave. It follows the Sun Code Style in many aspects and adds a &#8230; <a href="http://blogs.reucon.com/srt/code-style-braces-indentation-and-line-length-8846/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
<a href="http://www.amazon.de/gp/product/0521777682?ie=UTF8&#038;tag=reuconcom-21&#038;linkCode=as2&#038;camp=1638&#038;creative=19454&#038;creativeASIN=0521777682"><img border="0" hspace="5" src="/srt/wp-content/files/2011/12/elements_of_java_style.jpg" align="right"></a><br />
We&#8217;ve recently revisted our Java Coding Conventions. For several years we are now using a style based on the excellent book <a href="http://www.amazon.de/gp/product/0521777682?ie=UTF8&#038;tag=reuconcom-21&#038;linkCode=as2&#038;camp=1638&#038;creative=19454&#038;creativeASIN=0521777682">The Elements of Java Style</a> by RougeWave. It follows the <a href="http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html">Sun Code Style</a> in many aspects and adds a lot of reasoning.
</p>
<p>
Our Code Style differs mainly in two aspects:
</p>
<ul>
<li>We place curly braces on new lines</li>
<li>We use a maximum line length of 130 characters</li>
</ul>
<p>
I am well aware that there are religious opinions regarding those questions but after reconsidering our style we came to the conclusion that both differences actually make sense.
</p>
<p>
Lining up curly braces vertically (called Allman or ANSI style) makes it easy to check that the braces match. The indented code is clearly set apart from the containing statement by lines that are almost completely whitespace which makes the code easier to read. In contrast to K&amp;R style it consumes more space but today&#8217;s screens are well capable to show more than the ancient 24 lines.
</p>
<p>Good:</p>
<pre class="brush: java;">
if (condition)
{
    body;
}
</pre>
<p>Bad:</p>
<pre class="brush: java;">
if (condition) {
    body;
}
</pre>
<p>
The reason to limit the line length to 80 characters comes from the limitation of old printers that usually printed 80 characters per line. We seldomly print code on paper and modern printers are well capable to print at other resolutions. Limiting us to to 80 characters would waste a lot of screen space as with a decent screen size showing 130 characters still leaves enough place for the IDE to show up additional frames including outlines and project files left and right to the code.
</p>
<p>
What we learned: Use the mainstream conventions by default. Challenge them and check if the underlying assumptions hold true in your environment. Only derive if there is enough benefit to justify the change.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/srt?a=joch9vShszA:23hDMDyJ-fQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/srt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=joch9vShszA:23hDMDyJ-fQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/srt?i=joch9vShszA:23hDMDyJ-fQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=joch9vShszA:23hDMDyJ-fQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/srt?i=joch9vShszA:23hDMDyJ-fQ:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/srt/~4/joch9vShszA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.reucon.com/srt/code-style-braces-indentation-and-line-length-8846/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.reucon.com/srt/code-style-braces-indentation-and-line-length-8846/</feedburner:origLink></item>
		<item>
		<title>Java Applications on Privileged Ports</title>
		<link>http://feedproxy.google.com/~r/srt/~3/u7H0RvgrGC4/</link>
		<comments>http://blogs.reucon.com/srt/java-applications-on-privileged-ports-8536/#comments</comments>
		<pubDate>Sat, 08 May 2010 10:44:00 +0000</pubDate>
		<dc:creator>Stefan Reuter</dc:creator>
				<category><![CDATA[Operations]]></category>

		<guid isPermaLink="false">/?p=8536</guid>
		<description><![CDATA[I am running most of my Java applications with Java Service Wrapper on Ubuntu. Most of these applications can run on unprivileged ports above 1024, e.g. Tomcats running behind an Apache http reverse proxy or the Openfire XMPP server that &#8230; <a href="http://blogs.reucon.com/srt/java-applications-on-privileged-ports-8536/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
I am running most of my Java applications with <a href="http://wrapper.tanukisoftware.org/">Java Service Wrapper</a> on Ubuntu. Most of these applications can run on unprivileged ports above 1024, e.g. Tomcats running behind an Apache http reverse proxy or the Openfire XMPP server that uses ports above 1024 by default. However there are exceptions like the LDAP server <a href="http://directory.apache.org/">ApacheDS</a> or Tomcats that do not require the features of httpd in front of them.
</p>
<p>
If you want to run Java applications on privileged ports below 1024 there are several options you can choose from:</p>
<ul>
<li>Run the application as root (a very bad idea in terms of security)</li>
<li>Use <a href="http://www.friedhoff.org/posixfilecaps.html">POSIX File Capabilities</a> (doesn&#8217;t work with Sun JDK due to <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6919633">Bug 6919633</a>)</a></li>
<li>Use <a href="http://www.netfilter.org/">iptables</a> with NAT (works but is clumsy)</li>
<li>Use <a href="http://en.wikipedia.org/wiki/Authbind">authbind</a></li>
</ul>
<p>
To use authbind follow these steps:
</p>
<p><b>Step 1: Install and configure authbind</b></p>
<p>Install authbind from the Ubuntu repository:</p>
<pre class="codeSample"># aptitude install authbind</pre>
<p>For each port your application should be able to bind to create a file in <code>/etc/authbind/byport</code> and make in executable by the user that runs your application. For ApacheDS I did the following:</p>
<pre class="codeSample">
# cd /etc/authbind/byport
# touch 389 636
# chown apacheds:apacheds 389 636
# chmod 700 389 636
</pre>
<p>This results in the following files:</p>
<pre class="codeSample">
# ls -l /etc/authbind/byport/
total 0
-rwx------ 1 apacheds apacheds 0 2010-05-04 21:24 389
-rwx------ 1 apacheds apacheds 0 2010-05-04 21:24 636
</pre>
<p>More information on access control is available in <a href="http://manpages.ubuntu.com/manpages/lucid/man1/authbind.1.html">authbind (1)</a>.
<p><b>Step 2: Update wrapper.conf</b></p>
<p>Authbind works by overloading the bind function in libc. This is done by setting the environment variable <code>LD_PRELOAD</code>. If you are using Java Service Wrapper the easiest way to do this is to add the following line to your <code>wrapper.conf</code>:</p>
<pre class="codeSample">set.LD_PRELOAD=/usr/lib/authbind/libauthbind.so.1</pre>
<p>As authbind only supports IPv4 you must prevent your application from binding to the IPv6 port as well. This can be achieved by setting the system property <code>java.net.preferIPv4Stack</code> in <code>wrapper.conf</code>:</p>
<pre class="codeSample">wrapper.java.additional.1=-Djava.net.preferIPv4Stack=true</pre>
<p>That&#8217;s it!</p>
<p>This approach works with any Java application and is not limited to ApacheDS. Have a look at <a href="http://blogs.mulesoft.org/a-better-tomcat-for-ubuntu-and-debian/">A Better Tomcat for Ubuntu and Debian</a> by MuleSource to see how they are using authbind without Java Service Wrapper to make Tomcat run on standard HTTP ports.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/srt?a=u7H0RvgrGC4:M4RgiMkP1wM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/srt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=u7H0RvgrGC4:M4RgiMkP1wM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/srt?i=u7H0RvgrGC4:M4RgiMkP1wM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=u7H0RvgrGC4:M4RgiMkP1wM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/srt?i=u7H0RvgrGC4:M4RgiMkP1wM:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/srt/~4/u7H0RvgrGC4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.reucon.com/srt/java-applications-on-privileged-ports-8536/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.reucon.com/srt/java-applications-on-privileged-ports-8536/</feedburner:origLink></item>
		<item>
		<title>Book Review: Modular Java</title>
		<link>http://feedproxy.google.com/~r/srt/~3/E5VfJax_Qj8/</link>
		<comments>http://blogs.reucon.com/srt/book-review-modular-java-8736/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 02:57:00 +0000</pubDate>
		<dc:creator>Stefan Reuter</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[osgi]]></category>

		<guid isPermaLink="false">/?p=8736</guid>
		<description><![CDATA[Modular Java by Craig Walls is a book on building modular Java applications on OSGi platforms. Published in the Pragmatic Bookshelf series it keeps up to the standards of that great series by presenting content that matters in a format &#8230; <a href="http://blogs.reucon.com/srt/book-review-modular-java-8736/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
<a href="http://www.amazon.de/gp/product/1934356409?ie=UTF8&#038;tag=reuconcom-21&#038;linkCode=xm2&#038;camp=1638&#038;creativeASIN=1934356409"><img src="/srt/wp-content/files/2011/12/modular_java.gif" vspace="5" hspace="5" align="right"/></a><br />
<a href="http://www.amazon.de/gp/product/1934356409?ie=UTF8&#038;tag=reuconcom-21&#038;linkCode=xm2&#038;camp=1638&#038;creativeASIN=1934356409">Modular Java</a> by <a href="http://twitter.com/habuma">Craig Walls</a> is a book on building modular Java applications on <a href="http://www.osgi.org/">OSGi</a> platforms.
</p>
<p>
Published in the <a href="http://pragprog.com/">Pragmatic Bookshelf</a> series it keeps up to the standards of that great series by presenting content that matters in a format that makes you try it out immediately.
</p>
<p>
OSGi&#8217;s <a href="http://adaptevolve.blogspot.com/2009/10/osgi-value-proposition-in-recent-blog.html">value proposition</a> is to keep complexity in software products manageable. It keeps modules isolated from each other and encourages loose coupling through publishing and consuming services. You can think of OSGi as an incarnation of service oriented archietcure (SOA) within the Java Virtual Machine. OSGi has its roots in the embedded systems environment and became popular for desktop applications with <a href="http://www.eclipse.org">Eclipse</a> using it as their core infrastructure. From embedded to desktop OSGi is currently coming to the server side.
</p>
<p>
Craig&#8217;s book introduces the basics of OSGi, shows how it isolates modules by its unique approach to classpath handling and gives you an overview of the concept of OSGi services. One easy to follow example application is used consistently throughout the book to show the various aspects.<br/><br />
Most of the time the book uses <a href="http://www.eclipse.org/equinox/">Equinox</a> as runtime but <a href="http://felix.apache.org/">Felix</a> and <a href="http://www.knopflerfish.org/">Knopflerfish</a> are also mentioned. For building bundles Modular Java makes use of <a href="http://wiki.ops4j.org/display/ops4j/Pax">Pax</a> especially <a href="http://wiki.ops4j.org/display/paxconstruct/Pax+Construct">Pax Construct</a>. It does not mention <a href="http://www.springsource.org/bundlor">Bundlor</a>, <a href="http://www.aqute.biz/Code/Bnd">Bnd</a> or <a href="http://docs.codehaus.org/display/M2ECLIPSE/Tycho+user+docs">Tycho</a> in depth. Especially the <a href="http://maven.apache.org">Maven</a> based Tycho stack sounds really promising so it&#8217;s unfortunate that it isn&#8217;t covered. I guess however this is just an attribution to the current speed of development in the OSGi tooling space.
</p>
<p>
<a href="http://www.springsource.org/osgi">Spring Dynamic Modules</a> are an attempt to bring the principles of Spring Framework to OSGi. In the spirit of Spring Framework Dynamic Modules (DM) build on proven solutions (OSGi in this case) and make them easier to use. They eliminate a lot of boilerplate code that is normally require to handle OSGi services that may appear and disappear at any time. Spring-DM also provides integration with Spring Application Contexts and has support for web applications through an extender. Spring-DM is covered really well by the book. An appendix describes the new OSGi Blueprint Services that are an attempt to standardize the ideas of Spring-DM. Spring&#8217;s new <a href="http://www.springsource.com/products/dmserver">dm Server</a> is not covered.
</p>
<p>
The book focuses on the core concepts and shows the benefits of using OSGi for application development. The target audience are experienced Java developers. It is very well written, easy and fun to read and serves as a great introduction. I recommend the book to Java developers who consider making use of OSGi in future projects.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/srt?a=E5VfJax_Qj8:qbyA0ovCZKQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/srt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=E5VfJax_Qj8:qbyA0ovCZKQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/srt?i=E5VfJax_Qj8:qbyA0ovCZKQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=E5VfJax_Qj8:qbyA0ovCZKQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/srt?i=E5VfJax_Qj8:qbyA0ovCZKQ:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/srt/~4/E5VfJax_Qj8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.reucon.com/srt/book-review-modular-java-8736/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.reucon.com/srt/book-review-modular-java-8736/</feedburner:origLink></item>
		<item>
		<title>Code Style: Final Arguments</title>
		<link>http://feedproxy.google.com/~r/srt/~3/nBRogHgpRLQ/</link>
		<comments>http://blogs.reucon.com/srt/code-style-final-arguments-8806/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 18:43:00 +0000</pubDate>
		<dc:creator>Stefan Reuter</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">/?p=8806</guid>
		<description><![CDATA[Java allows you to make arguments final by declaring them as final in the argument list of the method declaration: public void doSomething(final String foo) { ... } This means that inside the method you cannot change what the argument &#8230; <a href="http://blogs.reucon.com/srt/code-style-final-arguments-8806/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Java allows you to make arguments final by declaring them as final in the argument list of the method declaration:</p>
<pre class="brush: java;">
public void doSomething(final String foo)
{
  ...
}
</pre>
<p>This means that inside the method you cannot change what the argument reference points to, i.e. it prevents you from doing things like this:
</p>
<pre class="brush: java;">
  foo = &quot;bar&quot;;
</pre>
<p>It is bad style to change the reference an argument points to. You should treat all arguments as if they were marked final. It would have even been a good idea to make this a language feature and have Java treat all arguments as final by default.</p>
<p>However does this justify to declare all arguments as final? Some people suggest this though I haven&#8217;t seen this in the wild very often.</p>
<p>The pros:</p>
<ul>
<li>enforces not changing the reference an argument points to</li</ul>
<p>The cons:</p>
<ul>
<li>makes method signatures longer and harder to read</li
<li>takes longer to write, being lazy is a virtue</li>
</ul>
<p>There is one thing to note: Changing the reference the argument points to does not actually change the value of the caller&#8217;s variable passed to the method:</p>
<pre class="brush: java;">
public void testDoSomething()
{
  String foo = "foo";
  doSomething(foo);
  System.out.println(foo); // still prints "foo"
}

public void doSomething(String foo)
{
  foo = &quot;bar&quot;;
}
</pre>
<p>However if you pass an object that is not immutable and you change the state inside the called method you actually do change the caller&#8217;s data. This is nothing a final modifier can prevent you from doing though it may be a source of trouble if not properly stated in the contract of the method.</p>
<p>So to sum it up: You should not change the reference an argument points to as it causes confusion. You can prevent this by adding the final modifer. Doing so however clutters your code and thus shouldn&#8217;t be done (except when needed to use the argument in an inner class). Pay attention to not change the state of an object passed to a method if that&#8217;s not part of the method&#8217;s contract.
<p>The same applies to some extend to final local variables. Use them where they make your code easier to understand but not everywhere you could. If you are a fan of final have a look at <a href="http://www.scala-lang.org/">Scala</a>&#8216;s val keyword.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/srt?a=nBRogHgpRLQ:hOFG4FYded0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/srt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=nBRogHgpRLQ:hOFG4FYded0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/srt?i=nBRogHgpRLQ:hOFG4FYded0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=nBRogHgpRLQ:hOFG4FYded0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/srt?i=nBRogHgpRLQ:hOFG4FYded0:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/srt/~4/nBRogHgpRLQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.reucon.com/srt/code-style-final-arguments-8806/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blogs.reucon.com/srt/code-style-final-arguments-8806/</feedburner:origLink></item>
		<item>
		<title>SSO for RoundCube Webmail with Atlassian Crowd</title>
		<link>http://feedproxy.google.com/~r/srt/~3/VX2Uh7E1XN0/</link>
		<comments>http://blogs.reucon.com/srt/sso-for-roundcube-webmail-with-atlassian-crowd-8356/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 20:23:00 +0000</pubDate>
		<dc:creator>Stefan Reuter</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[crowd]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">/?p=8356</guid>
		<description><![CDATA[Atlassian Crowd is a single sign-on and identity management tool by Atlassian that integrates well with their suite of software engineering and collaboration tools like JIRA, Confluence and Crucible. It offers a SOAP API that allows integration into arbitrary third-party &#8230; <a href="http://blogs.reucon.com/srt/sso-for-roundcube-webmail-with-atlassian-crowd-8356/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
<a href="http://www.atlassian.com/software/crowd/">Atlassian Crowd</a> is a single sign-on and identity management tool by <a href="http://www.atlassian.com/">Atlassian</a> that integrates well with their suite of software engineering and collaboration tools like JIRA, Confluence and Crucible. It offers a SOAP API that allows integration into arbitrary third-party systems. Integrating a webmail system with Crowd is quite easy. I&#8217;ve choosen <a href="http://roundcube.net/">RoundCube Webmail</a> 0.2.2 as an example. RoundCube is based on PHP and has a nice and clean user interface and a well-written code base.
</p>
<p><b>Step 1: Basic Integration</b></p>
<p>There is a <a href="http://pear.php.net/package/Services_Atlassian_Crowd/">PHP integration library</a> that can be used as a starting point. It provides the methods for SSO but lacks the convenience of Crowd&#8217;s <a href="http://docs.atlassian.com/crowd/1.6/com/atlassian/crowd/integration/http/HttpAuthenticator.html">HttpAuthenticator</a>. Implementing a simple PHP version of the HttpAuthenticator was the first step. My implementation uses <a href="http://pecl.php.net/package/APC">APC</a> to store the application token and validates every request with Crowd.</p>
<p><b>Step 2: Dovecot Masteruser</b></p>
<p>While the original version of RoundCube uses the user&#8217;s username and password to connect to the IMAP store that&#8217;s no longer possible with the crowdified version as it doesn&#8217;t have access to the user&#8217;s password. One solution is to use dovecot&#8217;s <a href="http://wiki.dovecot.org/Authentication/MasterUsers">masteruser</a> feature. With that configuration in place RoundCube can access the user&#8217;s mailbox by using its own password instead of the user&#8217;s password.</p>
<p><b>Step 3: Configuration</b></p>
<p>That&#8217;s it. Quite simple. If you like you can have a look at my <a href="http://blogs.reucon.com/srt/files/roundcubemail-0.2-crowd.diff">patch</a>. Check config/main.inc.php and provide the username and password of your dovecot masteruser as well as the application name, credential and service URL for Crowd.</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/srt?a=VX2Uh7E1XN0:RMgx5MftZ5U:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/srt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=VX2Uh7E1XN0:RMgx5MftZ5U:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/srt?i=VX2Uh7E1XN0:RMgx5MftZ5U:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/srt?a=VX2Uh7E1XN0:RMgx5MftZ5U:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/srt?i=VX2Uh7E1XN0:RMgx5MftZ5U:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/srt/~4/VX2Uh7E1XN0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.reucon.com/srt/sso-for-roundcube-webmail-with-atlassian-crowd-8356/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blogs.reucon.com/srt/sso-for-roundcube-webmail-with-atlassian-crowd-8356/</feedburner:origLink></item>
	</channel>
</rss>

