<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>brain driven development</title>
	<atom:link href="http://gleichmann.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://gleichmann.wordpress.com</link>
	<description>a development driven blog</description>
	<lastBuildDate>Wed, 21 Oct 2009 18:45:43 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='gleichmann.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/471b116f17b3834243906296b3ae9511?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>brain driven development</title>
		<link>http://gleichmann.wordpress.com</link>
	</image>
			<item>
		<title>Scala in practice: Composing Traits &#8211; Lego style</title>
		<link>http://gleichmann.wordpress.com/2009/10/21/scala-in-practice-composing-traits-lego-style/</link>
		<comments>http://gleichmann.wordpress.com/2009/10/21/scala-in-practice-composing-traits-lego-style/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 18:44:29 +0000</pubDate>
		<dc:creator>Mario Gleichmann</dc:creator>
				<category><![CDATA[Scala]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=267</guid>
		<description><![CDATA[As a kid, i loved to play with Lego bricks, especially to build freaky spacecrafts.
At that time it was easy to let my phantasy go (where noone has gone before) and build completely new models simply by composing some standard bricks. Those bricks weren&#8217;t too specialized, meaning that there weren&#8217;t too many constraints on how [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=267&subd=gleichmann&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>As a kid, i loved to play with Lego bricks, especially to build freaky spacecrafts.</p>
<p><img class="alignleft size-full wp-image-268" title="spacecraft" src="http://gleichmann.files.wordpress.com/2009/10/spacecraft.jpg?w=219&#038;h=189" alt="spacecraft" width="219" height="189" />At that time it was easy to let my phantasy go (where noone has gone before) and build completely new models simply by composing some standard bricks. Those bricks weren&#8217;t too specialized, meaning that there weren&#8217;t too many constraints on how to combine them. On the other side you always had to compose a new spacecraft from the very ground up as there weren&#8217;t some more higher organized units like engines or control cabins.</p>
<p>Nowadays, you&#8217;ll find such units. There are engines, control cabins or a whole commando bridge, Wings, Field Generators and so on &#8211; a whole set of higher organized units whithin a single domain. On the other side, you can&#8217;t combine every unit with an arbitrary other unit within that domain since there are some &#8216;constraints&#8217;  that will prohibit some unsound combinations.</p>
<p>Now you may ask how that cute childhood story relates to Scala?<br />
You may have seen already some similarities to the field of software development where you also want to compose some higher organized building blocks within a certain domain, enforcing that they are only combined in a proper way. It turns out, that Scala&#8217;s concept of traits provide some mechanisms of &#8216;mixin&#8217; them together while enforcing the compliance of some constraints. This may sound too abstract at that point, but hold on &#8211; we&#8217;ll build some spacecrafts in the above mentioned way and things will get clearer.</p>
<h3>Look, it&#8217;s a spacecraft</h3>
<p>Let&#8217;s start with a hull for our spacecraft. To keep things simple and to focus on the core idea of constrained<br />
composition, the spacecraft&#8217;s hull will only provide one abstract method <em>engange</em> to start the craft:</p>
<pre class="brush: java;">
abstract class Spacecraft{

    def engage
}
</pre>
<p>As you can see, method <em>engage </em>and therefore the whole class is abstract, so you can&#8217;t instantiate a pure hull<br />
of a spacecaft. So whenever we want to build a full fledged craft, we may have to &#8216;add&#8217; (or mix in) a component<br />
that knows how to engage that craft.</p>
<h3>Captains place</h3>
<p>Typically, a spacecraft possess a kind of &#8216;control center&#8217; which is normally well suited for initiating the<br />
start of a craft, hence should provide an implementation for method engage. There may be different kinds of<br />
control centers that could be used for building your own, customized spacecraft &#8211; e.g. a whole commando bridge for<br />
those big deep space crafts or a small control cabin for those little crafts mainly maneuvering near the orbit.</p>
<pre class="brush: java;">
 trait CommandoBridge{

def engage { for( _ &lt;- 1 to 3 ){ speedUp } }

    def speedUp
}
</pre>
<p>Now we see what it means to engage (a Spacecraft) if composing a commando Bridge to the hull. We simply speed up that craft 3 times.<br />
But hold on &#8211; although we know what it means to engage that craft, speeding up that craft is not in the responsibility of the commando bridge, since <em>speedUp </em>is left abstract (speeding down is omitted since it follows the same mechanism &#8211; you get the idea).</p>
<h3>Re-calibrating all Dilithium crystals</h3>
<p>So the spacecraft seems to be incomplete without a unit to speed it up &#8211; let&#8217;s call such a unit &#8216;engine&#8217;.  Again, there may be different kinds of engines we could select from to assemble our craft.<br />
Let&#8217;s say there is a Pulse-Engine that directly supports the command of speeding up:</p>
<pre class="brush: java;">
trait PulseEngine{

    val maxPulse: Int

    var currentPulse = 0;

    def speedUp { if( currentPulse &lt; maxPulse ) currentPulse += 1  }
}
</pre>
<p>As you can see, a <em>PulseEngine </em>is able to speed up until a maximum pulse rate. In order to &#8216;produce&#8217; different pulse engines (supporting different maximum pulse rates for different types of crafts), the field is again left abstract.<br />
Now we could create our first spacecraft, using a commando bridge and a pulse engine (let&#8217;s say that&#8217;s all you need for building a full fledged spacecraft).</p>
<pre class="brush: java;">
class StarCruiser extends Spacecraft with CommandoBridge with PulseEngine{

    val maxPulse = 200
}
</pre>
<p>As you can see, we&#8217;ve created a new (Sub-)Type of a spacecraft and mixed in both Traits, obtaining a commando bridge (that knows how to engage the whole craft) and an engine (that knows how to get the craft into speed when engaging the craft).<br />
The only thing left is to define the maximum pulse rate our <em>StarCruiser </em>is able to achieve.</p>
<h3>Wiring</h3>
<p>In the above case, all units fitted together smoothly. For example, a pulse engine provided exactly the &#8216;interface&#8217; (<em>speedUp</em>) that was needed by a commando bridge, so you could compose both without additional work. Let&#8217;s take a look at another control center, that we could apply to our craft, that may offer an incompatible &#8216;interface&#8217; :</p>
<pre class="brush: java;">
trait ControlCabin{

    def engage = increaseSpeed

    def increaseSpeed
}
</pre>
<p>This time we need to do some additional wiring, if we want to compose a new type of craft using a control cabin and a pulse engine, since both units don&#8217;t fit together directly (the dependency needed by <em>ControlCabin </em>(<em>increaseSpeed</em>) isn&#8217;t directly fulfilled by <em>PulseEngine</em>)</p>
<pre class="brush: java;">
class Shuttle extends Spacecraft with ControlCabin with PulseEngine{

    val maxPulse = 10

    def increaseSpeed = speedUp
}
</pre>
<p>As you can see, we have to wire together the control cabin with the pulse engine in order to let them cooperate.<br />
In the same way, we could think of another kind of engine which offers a completely different &#8216;interface&#8217;:</p>
<pre class="brush: java;">
trait WarpEngine extends Engine{

    val maxWarp: Int

    var currentWarp = 0;

    def toWarp( x: Int ) { if( x &lt; maxWarp ) currentWarp = x }
}
</pre>
<p>Again, we need to wire together the concrete control center with the <em>WarpEngine</em>, depending on their incompatible &#8216;interfaces&#8217;.</p>
<p>Let&#8217;s compose a craft, using a commando bridge and a warp engine.<br />
Firstly, we are forced to define a maximum warp level, since it&#8217;s an abstract field of <em>WarpEngine</em>. Secondly we have to wire together the commando bridge with the warp engine, that is to &#8216;route&#8217; the commando bridge&#8217;s method <em>speedUp </em>to the warp engines &#8216;interface&#8217; <em>toWarp </em>with an appropriate implementation:</p>
<pre class="brush: java;">
class Explorer extends Spacecraft with CommandoBridge with WarpEngine{

    val maxWarp = 10

    def speedUp = toWarp( currentWarp + 1 )
}
</pre>
<p>Alternatively, we could also use a simple control cabin for another type of spacecraft. Again we have to link the contol cabins commands (<em>increaseSpeed</em>) to the warp engines &#8216;interface&#8217;:</p>
<pre class="brush: java;">
object Defiant extends Spacecraft with ControlCabin with WarpEngine{

    val maxWarp = 20 // claimed by WarpEngine

    def increaseSpeed = toWarp( 10 ) // claimed by ControlCabin
}
</pre>
<h3>Restricted Access</h3>
<p>Until now, we only applied a control center or engines to spacecrafts. But nothing would restrict us to use those units in other domains so far. Say we want to build a certain airplane and apply a warp engine.</p>
<pre class="brush: java;">
class Jet extends Airplane with WarpEngine{

    val maxWarp = 5
}
</pre>
<p>It&#8217;s propably not the best idea to equip a Jet with a warp engine, since this seems to be a bit oversized for an airplane. We need a way to restrict the usage of warp engines &#8211; they should be only applied to spacecrafts. Fortunately we can express this kind of constraint, using Scala&#8217;s self type annotation. Included within a trait, it&#8217;s like saying &#8216;<em>this trait is only allowed to be mixed into a type of x</em>&#8216; (in our case &#8216;<em>Spacecraft</em>&#8216;):</p>
<pre class="brush: java;">
trait WarpEngine extends Engine{

    this: Spacecraft =&gt;
    ...
}
</pre>
<p>As you can see, we used the <em>WarpEngine</em>s self type to restrict its appliance only to spacecrafts. In all other cases, Scala&#8217;s compiler will complain about an unsound mixin.</p>
<h3>What makes a spacecraft a spacecaft ?</h3>
<p>With selftypes, we now have an instrument to restrict the usage of a trait to be mixed in only to a certain Type.<br />
On the other side, we aren&#8217;t forced to use a control center or an engine at all if creating a new spacecraft, since we could provide an implementation of the spacecrafts abstract methods directly within a subtype. That may be fine in some cases, but what if we want to state that a spacecraft has to be composed of at least a certain type of control center and a certain type of engine? Again, we can use the service of the self type annotation, this time applied to our abstract class spacecraft, stating that a spacecraft should at least be compound of a control center and an engine:</p>
<pre class="brush: java;">
abstract class Spacecraft{

    this: ControlCenter with Engine =&gt;
    ...
}
</pre>
<p>The only thing left is to provide an appropriate type <em>ControlCenter </em>resp. <em>Engine </em>and the correct classification of those concrete units (e.g. <em>&#8216;CommandoBridge is a</em> <em>ControlCenter</em>&#8216;)</p>
<pre class="brush: java;">
 trait ControlCenter

 trait CommandoBridge extends ControlCenter{ ... }

 trait ControlCabin extends ControlCenter{ ... }

 trait Engine

 trait PulseEngine extends Engine{ ... }

 trait WarpEngine extends Engine{ ... }
</pre>
<h3>Summary</h3>
<p>Abstract methods and self type annotations are two powerful tools which help to guide or constrain the composition of traits.<br />
You may use abstract methods and abstract fields to enforce a kind of &#8216;wiring&#8217; between multiple units or at least to force the definition of some concrete information.<br />
You may use a self type annotation to restrict the appliance of a trait, so that it can only be mixed in to a certain type (or subtypes). On the other side, you&#8217;re able to enforce that a certain trait (or subtype) have to be mixed in to a certain type, again by using a self type annotation.<br />
In all cases, the &#8216;composer&#8217; of those units will be guided by the compiler &#8211; you can&#8217;t forget to give a definition for an abstract method or arrange an unsound composition, since all those &#8216;constraints&#8217; are based on Scala&#8217;s statically typed Type system.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gleichmann.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gleichmann.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gleichmann.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gleichmann.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gleichmann.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gleichmann.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gleichmann.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gleichmann.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gleichmann.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gleichmann.wordpress.com/267/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=267&subd=gleichmann&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gleichmann.wordpress.com/2009/10/21/scala-in-practice-composing-traits-lego-style/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mario.gleichmann</media:title>
		</media:content>

		<media:content url="http://gleichmann.files.wordpress.com/2009/10/spacecraft.jpg" medium="image">
			<media:title type="html">spacecraft</media:title>
		</media:content>
	</item>
		<item>
		<title>Scala Introduction &#8211; Slides available</title>
		<link>http://gleichmann.wordpress.com/2009/10/07/scala-introduction-slides-available/</link>
		<comments>http://gleichmann.wordpress.com/2009/10/07/scala-introduction-slides-available/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 08:13:53 +0000</pubDate>
		<dc:creator>Mario Gleichmann</dc:creator>
				<category><![CDATA[Scala]]></category>
		<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=255</guid>
		<description><![CDATA[I published the slides from my Scala Talk which i did yesterday evening at XPUG Rhein/Main:  &#8216;Scala &#8211; a Scalable Language&#8216;
Content:

Motivation
Scala &#38; OO
Type System
Scala &#38; Functional Programming (Function values, Closures, Currying, &#8230;)
Characteristics (Expressiveness, Conciseness, Extensibillity, Scalabillity, &#8230;)
Features (Composition, Pattern Matching, Modules, Monads)

Enjoy
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=255&subd=gleichmann&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I published the slides from my Scala Talk which i did yesterday evening at XPUG Rhein/Main:  <strong>&#8216;<a href="http://www.slideshare.net/mariogleichmann/scala-a-scalable-language" target="_blank">Scala &#8211; a Scalable Language</a>&#8216;</strong></p>
<p>Content:</p>
<ul>
<li>Motivation</li>
<li>Scala &amp; OO</li>
<li>Type System</li>
<li>Scala &amp; Functional Programming (Function values, Closures, Currying, &#8230;)</li>
<li>Characteristics (Expressiveness, Conciseness, Extensibillity, Scalabillity, &#8230;)</li>
<li>Features (Composition, Pattern Matching, Modules, Monads)</li>
</ul>
<p>Enjoy</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gleichmann.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gleichmann.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gleichmann.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gleichmann.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gleichmann.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gleichmann.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gleichmann.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gleichmann.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gleichmann.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gleichmann.wordpress.com/255/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=255&subd=gleichmann&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gleichmann.wordpress.com/2009/10/07/scala-introduction-slides-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mario.gleichmann</media:title>
		</media:content>
	</item>
		<item>
		<title>Talking about Scala</title>
		<link>http://gleichmann.wordpress.com/2009/09/21/talking-about-scala/</link>
		<comments>http://gleichmann.wordpress.com/2009/09/21/talking-about-scala/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 19:52:00 +0000</pubDate>
		<dc:creator>Mario Gleichmann</dc:creator>
				<category><![CDATA[Scala]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=249</guid>
		<description><![CDATA[

I will talk about Scala at the XPUG Rhein/Main (in Frankfurt / Germany) Meeting on October 6, 2009.
Beside a general introduction, we&#8217;ll take a closer look at some of the new possibilities that come along with the fusion of object oriented concepts and the ideas of functional programming, trying to widen the horizon esp. for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=249&subd=gleichmann&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><div>
<div>
<p><img class="size-full wp-image-252 alignleft" title="scala-logo" src="http://gleichmann.files.wordpress.com/2009/09/scala-logo.png?w=73&#038;h=73" alt="scala-logo" width="73" height="73" />I will talk about <a title="Scala" href="http://www.scala-lang.org/" target="_blank">Scala</a> at the XPUG Rhein/Main (in Frankfurt / Germany) Meeting on October 6, 2009.</p>
<p>Beside a general introduction, we&#8217;ll take a closer look at some of the new possibilities that come along with the fusion of object oriented concepts and the ideas of functional programming, trying to widen the horizon esp. for imperative thinking &#8216;brains&#8217; &#8230;</p>
<p>Come along and feel welcome if you want to know more about functions as first class objects, Pattern Matching, Mixins or how to write your own custom control structures, making Scala a truly <em>SCA</em>lable <em>LA</em>nguage (and may want to discuss about afterwards).</p>
<p>Just give me a note at <em>mario.gleichmann@mg-informatik.de</em> if you’re interested to attend and i’m up for sharing further contact / meeting infos with you (talk will be in german, slides will be in english).</p>
<p>Entrance is free!</p></div>
</div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gleichmann.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gleichmann.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gleichmann.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gleichmann.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gleichmann.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gleichmann.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gleichmann.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gleichmann.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gleichmann.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gleichmann.wordpress.com/249/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=249&subd=gleichmann&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gleichmann.wordpress.com/2009/09/21/talking-about-scala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mario.gleichmann</media:title>
		</media:content>

		<media:content url="http://gleichmann.files.wordpress.com/2009/09/scala-logo.png" medium="image">
			<media:title type="html">scala-logo</media:title>
		</media:content>
	</item>
		<item>
		<title>Scala in practice: Traits as Mixins &#8211; Motivation</title>
		<link>http://gleichmann.wordpress.com/2009/07/19/scala-in-practice-traits-as-mixins-motivation/</link>
		<comments>http://gleichmann.wordpress.com/2009/07/19/scala-in-practice-traits-as-mixins-motivation/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 22:06:48 +0000</pubDate>
		<dc:creator>Mario Gleichmann</dc:creator>
				<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=241</guid>
		<description><![CDATA[Some voices say that Scala&#8217;s type system is rich but complex.
Traits are part of Scala&#8217;s type system, but their application isn&#8217;t that mysterious nor is it incomprehensible.
This post will give some introduction to one of their main operational areas &#8211; Traits used as Mixins, a well known concept which is already provided by some dynamic [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=241&subd=gleichmann&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Some voices say that Scala&#8217;s type system is rich but complex.<br />
Traits are part of Scala&#8217;s type system, but their application isn&#8217;t that mysterious nor is it incomprehensible.<br />
This post will give some introduction to one of their main operational areas &#8211; Traits used as Mixins, a well known concept which is already provided by some dynamic languages like Ruby.<span id="more-241"></span></p>
<h3>Mixins</h3>
<p>As their name reveals, Traits are usually used to represent a distinct feature or aspect that is normally orthogonal to the responsibility of a concrete type or at least of a certain instance. Therefore, the functionality of a Trait may be required by completely different types that have nothing in common or aren&#8217;t even members of the same type hierarchy.</p>
<p>Let&#8217;s say you want to model the ability to sing as such an orthogonal feature: it could be applied to Birds, Persons (well, not all) or even to Radios (c&#8217;mon, with just a little bit of imagination).</p>
<p>In Java, you could come up with an Interface in order to express this &#8216;trait&#8217;:</p>
<pre class="brush: java;">
public interface Singer{
public void sing();
}
</pre>
<p>Now every type which is also a singer may implement this interface and give an appropriate implementation:</p>
<pre class="brush: java;">
public class Bird implements Singer{
...
public void sing(){ ... }
}

...

public class Cicada extends Singer{
...
public void sing(){...}
}
</pre>
<p>Now all of them (and their subclasses) can be treated as Singers even &#8211; as said &#8211; a Cicada is not a Bird nor a Radio.<br />
If some of them (or all) should sing the same way, you could use &#8216;copy n paste&#8217; or place a default implementation and use composition. But nevertheless, you have to provide a definition of <em>sing()</em> in every of that classes &#8211; if only because to delegate to that implementation.<br />
No matter which option you choose, the proportion of boilerplate code isn&#8217;t just small (Inheritance may be no option at all, because there may be no common parent class. Particularly, placing <em>sing()</em> into a too general supertype would mean that ALL subtypes would be singers).</p>
<h3>Mixin&#8217; traits &#8217;statically&#8217;</h3>
<p>Scala provides an elegant way to define what it means to sing (at least a default implementation) and reuse it quite idependently by separating that feature as a trait and using that trait as a mixin.<br />
That said, you can (but don&#8217;t have to) provide a definition for some or all methods of that trait and mix that trait into every type you want to:</p>
<pre class="brush: java;">
 trait Singer{
   def sing { println( &quot;singing ...&quot; ) }
 }

 ...

 class Bird extends Singer
</pre>
<p>As you can see, the class definition of class Bird has mixed trait Singer into it&#8217;s own definition using keyword &#8216;<em>extends</em>&#8216;.<br />
Now Bird has mixed in all methods (and all other members of the trait) into its own definition as if class Bird would have defined method <em>sing(</em>) on its own &#8211; no boilerplate delegation code necessary.<br />
Of course you now can ask every instance of a Bird to sing.</p>
<p>A last word on keyword &#8216;<em>extends</em>&#8216;: you also (or normally) use it to let a class inherit from a superclass. In case of a trait you only use it if you don&#8217;t inherit from a superclass and then only for mixin in the first trait. All following traits (should you want to mix in more than one trait) are mixed in using keyword &#8216;<em>with</em>&#8216;:</p>
<pre class="brush: java;">
class Insect
class Cicada extends Insect with Singer

class Bird extends Singer with Flyer    // given Flyer as another trait
 </pre>
<h3>Mixin&#8217; traits &#8216;dynamically&#8217;</h3>
<p>In case of class <em>Person</em>, we face another special problem: We only want some instances of Person to be singers. We can&#8217;t implement interface <em>Singer</em> on class <em>Person </em>since this would turn every instance of Person into a singer.</p>
<p>Fortunately, Scala allows to mix in a trait &#8216;dynamically&#8217; when creating a new instance of a class. In that case, only that special instance will be a singer and provide the methods of that trait:</p>
<pre class="brush: java;">
class Person{

def tell { println( &quot;here's a little story ...&quot; ) }
}

val singingPerson = new Person with Singer
person.sing
</pre>
<p>As you can see, we&#8217;ve created a new instance of type <em>Person</em>, saying that this instance is also a <em>Singer </em>by using keyword &#8216;<em>with</em>&#8216;.<br />
Actually, we&#8217;ll receive an instance of a new anonymous class that is a Person as well as a Singer.</p>
<pre class="brush: java;">
 println( &quot;class of singing person: &quot; + singingPerson.getClass )  // -&gt; com.mgi.traits.TraitsAsMixins$$anon$2
 println( &quot;class of singing person is a Person? &quot; + singingPerson.isInstanceOf[Person] )  // -&gt; true
 println( &quot;class of singing person is a Singer? &quot; + singingPerson.isInstanceOf[Singer] )  // -&gt; true
</pre>
<p>Unlike in Java you could call any method on that instance without any typecast (at least within the scope where you&#8217;ve created that singing Person), no matter if the method was originally defined within <em>Person </em>or <em>Singer</em>.<br />
Of course you may encounter some problems when sending that &#8217;special&#8217; singing instance to a method that expects a parameter of type <em>Person</em>. Within that methods scope, a Person (in general) isn&#8217;t a singer, therefore calling <em>sing()</em> would cause an error since method <em>sing()</em> is no regular member of class <em>Person</em>.</p>
<h3>Is it a Bird? Is it a Singer ? &#8230;</h3>
<p>In that case, Pattern Matching may come to the rescue. Since you could also try to match against an arbitrary type, we could also try to match a <em>Person </em>against trait <em>Singer</em>. Let&#8217;s say we want to cast some Persons for a Show. If that Person is a singer, she should sing, otherwise tell a story &#8230;</p>
<pre class="brush: java;">
 def cast( p: Person ) {

p match {
case s: Singer =&gt; s.sing
case _ =&gt; p.tell
}
 }
</pre>
<h3>Conclusion</h3>
<p>Scala&#8217;s traits are an elegant way to separate concerns. Every feature may be separated within an own trait and can than be mixed into every type or instance that should posses that trait. This first introduction only gave some superficial examples, motivating why and how to use traits as Mixins.<br />
The next ones will deal with some more interesting questions like how to claim that a trait may only be mixed into types (or in conjunction with some other traits) that offer some needed characteristics or how to leverage Mixins in order to inject some Dependencies into the class the trait is gonna be mixed in.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gleichmann.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gleichmann.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gleichmann.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gleichmann.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gleichmann.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gleichmann.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gleichmann.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gleichmann.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gleichmann.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gleichmann.wordpress.com/241/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=241&subd=gleichmann&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gleichmann.wordpress.com/2009/07/19/scala-in-practice-traits-as-mixins-motivation/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mario.gleichmann</media:title>
		</media:content>
	</item>
		<item>
		<title>Talking about Domain Driven Design at XPUG Rhein/Main</title>
		<link>http://gleichmann.wordpress.com/2009/04/02/talking-about-domain-driven-design-at-xpug-rheinmain/</link>
		<comments>http://gleichmann.wordpress.com/2009/04/02/talking-about-domain-driven-design-at-xpug-rheinmain/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 20:51:15 +0000</pubDate>
		<dc:creator>Mario Gleichmann</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=239</guid>
		<description><![CDATA[

I will talk about Domain Driven Design (DDD) at the Extreme Programming User Group Rhein/Main (in Frankfurt / Germany) on April 8, 2009.
We’ll take a closer look at the core intentions and ideas behind DDD (like grinding a Ubiquitous Language, Deep Models, Declarative Design or bounded Contexts),  surrounded by some real world examples.
Come along and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=239&subd=gleichmann&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><div class="content">
<div class="snap_preview">
<p>I will talk about Domain Driven Design (DDD) at the Extreme Programming User Group Rhein/Main (in Frankfurt / Germany) on April 8, 2009.</p>
<p>We’ll take a closer look at the core intentions and ideas behind DDD (like grinding a Ubiquitous Language, Deep Models, Declarative Design or bounded Contexts),  surrounded by some real world examples.</p>
<p>Come along and feel welcome if you want to know more on what it’s all about ‘DDD’ and want to discuss about afterwards.</p>
<p>Just give me a note at <em>mario.gleichmann@mg-informatik.de</em> if you&#8217;re interested to attend and i&#8217;m up for sharing further contact / meeting infos with you (talk will be in german).</div>
</div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gleichmann.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gleichmann.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gleichmann.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gleichmann.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gleichmann.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gleichmann.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gleichmann.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gleichmann.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gleichmann.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gleichmann.wordpress.com/239/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=239&subd=gleichmann&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gleichmann.wordpress.com/2009/04/02/talking-about-domain-driven-design-at-xpug-rheinmain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mario.gleichmann</media:title>
		</media:content>
	</item>
		<item>
		<title>WS-Security using Cert Authentication with Spring-WS V: How to implement a Message Signing Client</title>
		<link>http://gleichmann.wordpress.com/2009/03/02/ws-security-using-cert-authentication-with-spring-ws-v-how-to-implement-a-message-signing-client/</link>
		<comments>http://gleichmann.wordpress.com/2009/03/02/ws-security-using-cert-authentication-with-spring-ws-v-how-to-implement-a-message-signing-client/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 21:57:34 +0000</pubDate>
		<dc:creator>Mario Gleichmann</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=227</guid>
		<description><![CDATA[The previous installment set the stage for our WebService Clients&#8217; Security Inftrastucture, that is the Keystore which will provide the Clients private Key in order to build the digital Signature (the encrypted Hash for the messages&#8217; payload) and the related &#8211; now signed &#8211; Certificate, which will be included within the Request Message (so the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=227&subd=gleichmann&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The <a title="Episode 4" href="http://gleichmann.wordpress.com/2009/02/05/ws-security-using-cert-authentication-with-spring-ws-iv-how-to-set-up-your-clients-keystore/" target="_blank">previous installment</a> set the stage for our WebService Clients&#8217; Security Inftrastucture, that is the Keystore which will provide the Clients private Key in order to build the digital Signature (the encrypted Hash for the messages&#8217; payload) and the related &#8211; now signed &#8211; Certificate, which will be included within the Request Message (so the receiver &#8211; among other things &#8211; is able to decrypt the embedded digital Signature in order to compare it with the  Hash rebuilded by himself for the sake of data integrity).<span id="more-227"></span></p>
<p>With that at hand, we&#8217;re now in a position to implement the WebService Client, which should sign any outgoing message, adhering to the given Security Constraints of our WebService.<br />
We&#8217;ll again leverage Spring-WS&#8217; potential and use <em>org.springframework.ws.client.core.support.WebServiceGatewaySupport</em> for implementing our Gateway class, which will encapsulate the whole procedure of Message Signing and Message Sending.</p>
<pre class="brush: java;">

public class WebServiceGateway  extends WebServiceGatewaySupport{
  ...
  public void callService( Resource payload ){...}
}
</pre>
<p>Using <em>WebServiceGatewaySupport </em>gives us the chance to provide some of the crucial information (like the<br />
WebServices&#8217; location) via Springs&#8217; application context:</p>
<pre class="brush: xml;">
...
&lt;bean id=&quot;wsGateway&quot; class=&quot;ffb.fsm.ws.gateway.WebServiceGateway&quot;&gt;
&lt;property name=&quot;defaultUri&quot;
      value=&quot;http://www.myWebserviceProviderUrl.de/ws/auction&quot;/&gt;
&lt;property name=&quot;messageFactory&quot; ref=&quot;soap11MessageFactory&quot;/&gt;
&lt;property name=&quot;defaultRequest&quot;
      value=&quot;classpath:com/mgi/ws/resource/placeBidRequest.xml&quot;/&gt;
  ...
&lt;/bean&gt;
...
&lt;bean id=&quot;soap11MessageFactory&quot;
      class=&quot;org.springframework.ws.soap.saaj.SaajSoapMessageFactory&quot;&gt;
&lt;property name=&quot;messageFactory&quot;&gt;
    &lt;bean class=&quot;com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl&quot; /&gt;
  &lt;/property&gt;
&lt;/bean&gt;
...
</pre>
<p>As you can see, we provide the WebServices&#8217; Location in form of property <em>defaultUri </em>(so we don&#8217;t have to pass the URI within every single request). Further, we&#8217;re explicitly using SOAP 1.1 as the &#8216;communication protocoll&#8217; for the information structure and statically refer to a resource that will hold the payload of the Request Message.<br />
Please note, that i&#8217;m not going into any further details on how to implement a &#8217;standard&#8217; WebService Client via Spring-WS, since there are some good resources on that topic out there &#8211; instead we want to focus mainly on Message Signing.</p>
<h2>A simple Message Signer</h2>
<p>Signing of the &#8216;original&#8217; (unsigned) Message is best encapsulated within a class of its own &#8211; let&#8217;s call it <em>MessageSigner</em>. Although Message Signing can be done more or less completely by configuration, i&#8217;m going to implement the process of Message Signing here for the sake of clarity.<br />
Our MessageSigner will deliver an <em>org.springframework.ws.client.core.WebServiceMessageCallback</em> which in turn is responsible for securing the outgoing message. This <em>WebServiceMessageCallback </em>will be used by our <em>WebServiceGateway </em>to &#8216;intercept&#8217; the Message Sending Process and manipulate the outgoing request message right before its final delivery (as we&#8217;ll see later).</p>
<p>Like on the server side &#8211; we&#8217;ll also rely on XWSS when it comes to securing the outgoing message, thus our <em>MessageSigner </em>will behave according to some given XWSS Security Constraints. This time we have to provide those Security Constraints on client side, forcing the <em>MessageSigner </em>to sign the outgoing Message. Therefore, we&#8217;ll use an instance of <em>com.sun.xml.wss.XWSSProcessor</em> which gets fed with the Policy File (which will hold the Configuration to sign the outgoing message) and the related Keystore, holding the Key-Pair used for message Signing.</p>
<pre class="brush: java;">
import java.io.IOException;
import java.io.InputStream;
import javax.xml.soap.SOAPMessage;
import org.springframework.core.io.Resource;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.client.core.WebServiceMessageCallback;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
import org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler;
import com.sun.xml.wss.ProcessingContext;
import com.sun.xml.wss.XWSSProcessor;
import com.sun.xml.wss.XWSSProcessorFactory;

public class XwssMessageSigner {

  private final XWSSProcessor processor;

  public XwssMessageSecurer( Resource policyFile, KeyStoreCallbackHandler keystoreHandler ) throws Exception {

    InputStream in = policyFile.getInputStream();
    XWSSProcessorFactory factory = XWSSProcessorFactory.newInstance();
    processor = factory.createProcessorForSecurityConfiguration( in, keystoreHandler );
    in.close();
  }

  public WebServiceMessageCallback getCallback() {

    return       
      new WebServiceMessageCallback() {
        public void doWithMessage( WebServiceMessage message ) throws IOException {

          SaajSoapMessage origSaajMessage = (SaajSoapMessage) message;
          SOAPMessage origSoapMessage = origSaajMessage.getSaajMessage();

         ProcessingContext context = new ProcessingContext();

          try {
            context.setSOAPMessage( origSoapMessage );
            SOAPMessage securedSoapMessage = processor.secureOutboundMessage( context );
            origSaajMessage.setSaajMessage( securedSoapMessage );
          }
          catch (Exception exc) {
            exc.printStackTrace();
            throw new IOException( exc.getMessage() );
          }
        }
      };
   }
}
</pre>
<p>As you can see, our Signer relies on a policy File (containing the Security Constraints) and a <em>KeyStoreCallbackHandler</em>, which is responsible for handling the key /certificate requests. Both Dependencies will be injected into <em>XwssMessageSigner </em>via constructor injection (as we&#8217;ll see later).</p>
<p>Inside the WebServiceMessageCallback, we&#8217;ll receive the original message in a state just before sending it to the receiver. The message already conists of the whole Soap structure (Payload Body and Envelope), so that we can refer to all parts of it. After retrieving the original Soap Message (extracted from Spring-WS&#8217; <em>SaajSoapMessage </em>wrapper), <em>XWSSProcessor </em>is going to secure it according to the given Security Constraints. The outgoing message is than replaced by our newly secured Soap Message.</p>
<h2>Security Policies</h2>
<p>In order to get our <em>MessageSigner </em>to really sign the Message, we have to come up with an accordant policy File. Like we did on the server side, we also have to configure it for Message Signing. Note, that we could have placed every possible type of Security Configuration within the Policy file and our <em>MessageSigner </em>would behave accordant to that policy (under that point of view, &#8216;MessageSecurer&#8217; would be a better, more general name for our MessageSigner).</p>
<pre class="brush: xml;">
&lt;xwss:SecurityConfiguration dumpMessages=&quot;true&quot;
  xmlns:xwss=&quot;http://java.sun.com/xml/ns/xwss/config&quot;&gt;
    &lt;xwss:Sign id=&quot;signature&quot;&gt;
      &lt;xwss:X509Token certificateAlias=&quot;wstestclient&quot;/&gt;
    &lt;/xwss:Sign&gt;
&lt;/xwss:SecurityConfiguration&gt;
</pre>
<p>As you can see, we force Message Signing by placing <em>xwss:Sign</em> within theSecurity Configuration, further arranging, that the Signing should be based on X509 Certificates. Note, that we also define the alias Name of the Key-Pair which should be used for building the digital Signature (when refering to the Keystore, which we&#8217;ve assigned to our instance of <em>XWSSProcessor</em>).</p>
<h2>Configuration</h2>
<p>Now we&#8217;re able to configure our MessageSigner also within the application context, supplying the conning Security Constraints and the underlying Keystore (via the before mentioned <em>KeyStoreCallbackHandler</em>) which holds our Key-Pair for Message Signing:</p>
<pre class="brush: xml;">
&lt;bean id=&quot;xwssMessageSigner&quot; class=&quot;com.mgi.xwss.XwssMessageSigner&quot;&gt;
  &lt;constructor-arg value=&quot;classpath:com/mgi/xwss/securityPolicy.xml&quot;/&gt;
  &lt;constructor-arg&gt;
    &lt;bean class=&quot;org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler&quot;&gt;
&lt;property name=&quot;keyStore&quot; ref=&quot;clientKeystore&quot; /&gt;
&lt;property name=&quot;defaultAlias&quot; value=&quot;wstestclient&quot;/&gt;
&lt;property name=&quot;privateKeyPassword&quot; value=&quot;keyPairPasswd&quot;/&gt;
    &lt;/bean&gt;
  &lt;/constructor-arg&gt;        
&lt;/bean&gt;

&lt;bean id=&quot;clientKeystore&quot; class=&quot;org.springframework.ws.soap.security.support.KeyStoreFactoryBean&quot;&gt;
&lt;property name=&quot;location&quot; value=&quot;classpath:com/mgi/xwss/XWSSClientKeystore.jks&quot;/&gt;
&lt;property name=&quot;password&quot; value=&quot;keystorePasswd&quot;/&gt;
&lt;/bean&gt;
</pre>
<p>With our <em>MessageSigner </em>ready to go, we&#8217;ll extend the configuration of <em>WebServiceGateway</em>. It will now accept the <em>MessageSigner </em>as an additional Dependency:</p>
<pre class="brush: xml;">
&lt;bean id=&quot;wsGateway&quot; class=&quot;ffb.fsm.ws.gateway.WebServiceGateway&quot;&gt;
  ...
&lt;property name=&quot;xwssMessageSigner&quot; ref=&quot;xwssMessageSigner&quot;/&gt;
&lt;/bean
</pre>
<h2>Delegation</h2>
<p>With the <em>MessageSigner </em>injected, <em>WebServiceGateway </em>will now delegate the Signing of outgoing messages to that <em>MessageSigner </em>simply by requesting an instance of the provided <em>WebServiceMessageCallback </em>and let him do its job (of course we could have requested an instance of <em>WebServiceMessageCallback </em>only once and reuse that instance for every Request):</p>
<pre class="brush: java;">
public class WebServiceGateway  extends WebServiceGatewaySupport{
  ...
  private XwssMessageSigner xwssMessageSigner = null;
  ...
  public void setXwssMessageSigner( XwssMessageSigner signer ){
    this.xwssMessageSigner = signer;
  }

  public void callService() throws IOException{
    callService( defaultRequest );
  }

  public void callService( Resource request ) throws IOException{

    Source requestSource = new ResourceSource( request );

    try{

      getWebServiceTemplate()
        .sendSourceAndReceive(
          requestSource,
          xwssMessageSecurer.getCallback(),
          new MySourceExtractor() );        
    }
    catch( SoapFaultClientException e ){
      // error handling
    }
  }

  public class MySourceExtractor implements SourceExtractor{
    public Object extractData( Source src ) throws IOException, TransformerException {

    DOMSource dom = (DOMSource) src;
      // process response     
      return ... // processed response;
    }
  }
  ...
}
</pre>
<p>You see, that there&#8217;s nothing magic about it at all. <em>WebServiceGateway </em>gets called in order to send a new request to our WebService (which is configured via the clients&#8217; application context, as we&#8217;ve seen before).  In the easiest case, we could simply call <em>callService()</em>, so that the configured default message used, signed and send. Of course, you could also call <em>callService( Resource request )</em>, passing an individual payload that is to be signed and send over the wire.</p>
<h2>Summary</h2>
<p>Message Signing on the client side is also done by leveraging XWSS in form of an <em>XWSSProcessor </em>which is configured accordingly (using an appropriate Security Policy File). The Signing Process is encapsulated within a class of its own &#8211; <em>MessageSigner</em>. The client is able to use <em>MessageSigner </em>in that it request a <em>WebServiceMessageCallback </em>which in fact does the job of securing the outgoing message. In our case, according to the given Security Policies, a Hash is build based on the message payload (also including the Timestamp, which is also regarded by default, if not specified otherwise) which gets encrypted afterwards. Encryption is done by using the private Key of a Key-Pair, whose alias name is also defined within the Policy File &#8211; the underlying Keystore is configured via Spring-WS&#8217; application config, which in turn is passed to the responsible <em>XWSSProcessor</em>. The encrypted Hash is in fact the digital Signature which is embedded within the outgoing message. In order to give the receiver a chance to detect some unwanted payload manipulation, it will also build a Hash, also based on the payload and Timestamp. To compare that Hash with the digital Signature which is embedded within the message, the receiver has to decrypt the Signature again. This can only be done with the related Public Key (contained within the clients certificate) which therefore also has to be passed to the receiver. Once you&#8217;ve retrieved the certificate (also embedded within the message), you can perform whatever kind of logic you want to do based on the client certificate (as seen in <a title="Episode 2" href="http://gleichmann.wordpress.com/2009/01/22/ws-security-using-cert-authentification-with-spring-ws-ii-accessing-the-certificate/" target="_blank">episode two</a>).</p>
<h3>That&#8217;s it</h3>
<p>You&#8217;ve seen how to configure Certificate Authentification using Spring-WS on client and server side and hopefully got some introduction to the underlying ideas like Message Signing, Certificate Authorities and Public Key Infrastructure.<br />
Of course, Certificate Authentification might only be a reasonable instrument for some use cases which heavily rely on<br />
some given Security concerns.<br />
As always, you have to be clear about your projects goals, the given Security context your WebService is acting in and the knowledge about the given trade offs (extended configuration vs. increased Security) and consequences when leveraging WS-Security using Certificate Authentification.<br />
Maybe this series could gave some useful information on that topic or at least some helpful suggestions.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gleichmann.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gleichmann.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gleichmann.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gleichmann.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gleichmann.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gleichmann.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gleichmann.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gleichmann.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gleichmann.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gleichmann.wordpress.com/227/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=227&subd=gleichmann&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gleichmann.wordpress.com/2009/03/02/ws-security-using-cert-authentication-with-spring-ws-v-how-to-implement-a-message-signing-client/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mario.gleichmann</media:title>
		</media:content>
	</item>
		<item>
		<title>DAO &#8211; it&#8217;s not about Layering, it&#8217;s about Abstraction!</title>
		<link>http://gleichmann.wordpress.com/2009/02/17/dao-its-not-about-layering-its-about-abstraction/</link>
		<comments>http://gleichmann.wordpress.com/2009/02/17/dao-its-not-about-layering-its-about-abstraction/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 00:21:17 +0000</pubDate>
		<dc:creator>Mario Gleichmann</dc:creator>
				<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=221</guid>
		<description><![CDATA[Again there were some interesting debates in the near past, which once again discussed the role of the DAO within enterprise applications, especially based on JEE and EJB 3. One main argument for the dissapearance of DAOs is the very unlikely probability to exchange or replace your once chosen persistence technology, so that you may [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=221&subd=gleichmann&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a title="DAO" href="http://gleichmann.wordpress.com/2007/11/22/why-dao-wont-die/" target="_blank">Again</a> there were some <a title="DAO" href="http://www.olivergierke.de/wordpress/2009/01/se-radio-episode-121-or-mappers/" target="_blank">interesting</a> <a title="DAO" href="http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/" target="_blank">debates</a> in the near past, which once again discussed the role of the DAO within enterprise applications, especially based on JEE and EJB 3. One main argument for the <a title="DAO" href="http://www.adam-bien.com/roller/abien/entry/daos_aren_t_dead_but" target="_blank">dissapearance </a>of DAOs is the very unlikely <a title="Probability" href="http://www.adam-bien.com/roller/abien/entry/a_good_architecture_is_all" target="_blank">probability </a>to exchange or replace your once chosen persistence technology, so that you may directly rely on EJBs Entity Manager within your Business Services (since it&#8217;s in fact very unlikely that your underlying persistence technology will change). This argument is mostly accompanied with the concern, that the introduction of a DAO Layer might increase complexity and introduce some performance penalties, while direct usage of the Entity Manager let collapse two separate Layers into one.<span id="more-221"></span></p>
<p>All in all, those statements raise the impression, that DAOs form a kind of Layer in their own right, or represent at least the main part of your data access Layer.</p>
<p>Let me give you some counter arguments (using some input from &#8216;J2EE Design and Development&#8217; as well as &#8216;Domain Driven Design&#8217;) which will show you that DAOs aren&#8217;t so much about Layers but more importantly about Abstraction and domain specific Encapsulation (that said, with the disappearance of the DAO, collapsing two Layers into one as suggested, there is STILL a data access Layer, you only just jumbled business and data access logic).</p>
<h2>Abstraction and Separation of concerns</h2>
<p>In this post we mainly look at <a title="Wikipedia" href="http://en.wikipedia.org/wiki/Abstraction" target="_blank">Abstraction </a>as a &#8216;<em>result of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose</em>&#8216;. In case of reasoning about the existence of DAOs , we&#8217;re mainly interested in the second part; using Abstraction as a strategy of simplification, wherein concrete details are left, so that a DAOs Client is able to focus on a DAOs effects (the WHAT) he wants to benefit from, rather than worrying about the details (the HOW).</p>
<p>Within this frame, a DAO is mainly useful for decoupling Business Logic and Data Access Logic. The responsibilities between Business Services and DAOS are cleanly separated, so one can easily distinguish the business Logic (e.g. business workflows and rules) from persistence logic / data access logic (e.g. handling specific persistence issues).<br />
From the clients point of view, a DAO hides all the fiddly details of persistence operations, especially if persistence logic is not representable as a one-step-operation but consists of multi-step-operation logic which the client don&#8217;t want to mix up with his own tasks.</p>
<p>To make it clear, we are not talking about applications, where the business logic mainly consists of plain data acces operations and not much else. We rather consider separation of existent business logic and data access logic, so a business service can keep focused on the domain model and its domain centric tasks.</p>
<h2>Encapsulation</h2>
<p>A DAO encapsulates data specific logic that may not be intermingled with business logic &#8211; there might be various reasons which represent valid conditions (not only esoteric facts, as i saw those settings more than once in former projects):</p>
<ul>
<li>providing some kind of complex compensation logic (e.g. logic not expressable by simply marking a Roleback)</li>
<li>providing some domain related data integrity (e.g. difficult to express as direct constraints within your persistence store)</li>
<li>transparently handling of normalization issues (the underlying database may was designed for another system or serves in roles other than object store)</li>
<li>compensating the mismatch between data model and domain model (the relational data design may doesn&#8217;t reflect the domain model)</li>
<li>shielding the client from constraints of a specific persistence technology</li>
</ul>
<p>All those conditions result in operations you don&#8217;t want to embedd next to your business logic.<br />
Under this point of view, you can look at a DAO as a special kind of Strategy pattern, where the implementation of different data access strategies are possible and cleanly hidden from their clients, coming with a very valuable consequence: it leaves us Choice!</p>
<p>Where a DAO is data source agnostic (works with any underlying persistence technology), using the Entity Manager directly within your business Service will lock you into one way of accessing (persistent) objects and one particular O/R Mapping solution.</p>
<h2>Plain old (Java) Interface</h2>
<p>DAOs (better DAO implementations) usually implement one ore more DAO interfaces. One important (secondary) use case which is often neglected, is the fact that those interfaces are under your control (not so with Entity Manager) and therefore provides the potential for a wide variety of additional (crosscutting) concerns:</p>
<ul>
<li>gives you the potential for very different implementations of data access strategies and persistence technologies</li>
<li>allows for interception strategies (e.g. special, fine grained caching strategies which can be decided on a per-DAo level, time measurement, Filtering, &#8230;)</li>
<li>allows for portable design that isolates any non portable features behind interfaces</li>
<li>provides a common approach to (multiple) (data) resource management, regardless of the data access strategy</li>
<li>able to provide a consistent exception hierarchy (not bound to a single exception type hierarchy of one specific technology)</li>
</ul>
<p>That said, you don&#8217;t rely on one specific persistence technology (you may want to thinkk about the costs trying to use a single persistence technology in all use cases), you could even mix O/R with plain SQL or other access strategies on a per-method or per-DAO level due to specific application needs (e.g. improve performance by varying query techniques if needed or leveraging vendor specific features).</p>
<h2>Intention revealing interface</h2>
<p>By being able to express the offered possibilities and effects of (data) object access through an interface, we&#8217;re able to protect clients (Business services) from database oriented models, as said before e.g. by providing transformation strategies to the domain model inside the DAO or Repository (i&#8217;m not going into details of the difference between a DAO and a Repository here ).<br />
In this case you&#8217;re able to easily provide verbs (not only nouns) in an intention revealing way, expressing the &#8216;actions&#8217; using a domain centric vocabulary (&#8216;remove all yesterday orders of a customer&#8217;).<br />
Under this view, a DAO offers a clear, strongly typed API, which communicates the core concepts and operations of a certain domain (e.g. allow for finder methods with domain arguments, removing the need to maintain object query language Strings in business services). By looking at that interface, it&#8217;s immediately obvious which (persistent) objects are retrieved (created, deleted) &#8211; the interface communicates the core underlying design decisions about object access (while Entity Manager (with its generic API) allows to apply any persistence operation to any object which makes it hard to find out actually available operations for a specific domain)</p>
<h2>Interface segregation Principle</h2>
<p>Regarding DAO interfaces, you&#8217;re able to obey the Interface Segragation Pronciple: within that frame, DAO interfaces belong to the different Business services which describe their needs by providing a specific DAO Interface they&#8217;ll use.<br />
A single DAO implementaion then may implement one ore more DAO Interfaces (hidden from the client eyes) where (again) the Entity Manager only provides a generic API: client&#8217;s can&#8217;t communicate their needs in a domain oriented way (by providing an accordant interface) in that case.<br />
That said, a specific DAO Interface meets the demand of expressing specific (data) object access needs for a Business service (if seen as a &#8216;component&#8217; which have to express it&#8217;s &#8216;dependencies&#8217;)</p>
<h2>Conclusion</h2>
<p>As seen, a DAO is not just a Layer for the sake of Layering (replacing that Layer if in need). Instead it provides the potential for clearly separating business logic from data access logic &#8211; so the value of a DAO is more related to abstract some irrelevant aspects (in the eye of WHAT, while of course relevant in the eye of HOW ) away from its Clients, resulting in a cleaner separation of concerns.</p>
<p>Again, you always have to consider the given forces and constraints when arguing about the usefulness of DAOs in a specific setting: Of course &#8211; like most design decisions &#8211; it’s a matter of choosing the one or other side of a trade off. So one is right to say it depends on the context whether to use a DAO or directly include data access logic inside a business service &#8211; but you have to be clear about the consequences (which should be aligned with the projects goals which in turn should be also clear). And letting the DAO dissapear or collapsing with your business logic comes with the loss of the mentioned possibilities of Abstraction.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gleichmann.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gleichmann.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gleichmann.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gleichmann.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gleichmann.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gleichmann.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gleichmann.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gleichmann.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gleichmann.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gleichmann.wordpress.com/221/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=221&subd=gleichmann&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gleichmann.wordpress.com/2009/02/17/dao-its-not-about-layering-its-about-abstraction/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mario.gleichmann</media:title>
		</media:content>
	</item>
		<item>
		<title>WS-Security using Cert Authentication with Spring-WS IV: How to set up your Clients&#8217; Keystore</title>
		<link>http://gleichmann.wordpress.com/2009/02/05/ws-security-using-cert-authentication-with-spring-ws-iv-how-to-set-up-your-clients-keystore/</link>
		<comments>http://gleichmann.wordpress.com/2009/02/05/ws-security-using-cert-authentication-with-spring-ws-iv-how-to-set-up-your-clients-keystore/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 21:09:21 +0000</pubDate>
		<dc:creator>Mario Gleichmann</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=212</guid>
		<description><![CDATA[So far, our WebService is readily configured for only accepting signed messages, forcing clients to include their Certificate for decrypting the digital Signature again on server side (verifying that the message is originally send from an authorized client). In addition to that, the client&#8217;s Certificate has to be signed (issued) itself by a Certificate Authority [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=212&subd=gleichmann&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>So far, our WebService is readily configured for only accepting signed messages, forcing clients to include their Certificate for decrypting the digital Signature again on server side (verifying that the message is originally send from an authorized client). In addition to that, the client&#8217;s Certificate has to be signed (issued) itself by a Certificate Authority (CA) which is accepted by the WebService (in that the CAs Certificate is contained within the WebServices Truststore)<span id="more-212"></span></p>
<p>In this entry, we will set up the clients security infrastructure in that we create a Key-Pair and let the related Certificate be signed by the WebServices trusted CA. In the next episode, we&#8217;re going to build an accordant WebService-Client using Spring-WS&#8217; <em>WebServiceTemplate </em>which will be configured to sign its outgoing messages by using the generated clients&#8217; private Key and the associated signed Certificate.</p>
<h3>Client Keystore</h3>
<p>First of all, we&#8217;ll create a new Keystore along with the client&#8217;s private Key (needed for encrypting the messages digital Signature) and the related Certificate (holding the public Key, needed to decrypt the encrypted digital Signature again). Again we&#8217;ll use Javas&#8217; Keytool for that purpose, creating the Keystore on an arbitrary location on the clients file system, answering the upcoming questions accordingly.</p>
<pre class="brush: css;">
keytool -genkey -alias wsClient -keyalg RSA -keystore Keystore.jks
</pre>
<p>Note, that we chose &#8216;<em>wsClient</em>&#8216; as the alias name for refering to that Key-Pair any time further.<br />
If you remember the <a title="WS-Security 2" href="http://gleichmann.wordpress.com/2009/01/22/ws-security-using-cert-authentification-with-spring-ws-ii-accessing-the-certificate/" target="_blank">second part</a> of this tutorial, we did some authorization based on the Common Name of the client Certificate. So if you rely on that kind of pattern, be sure to choose an appropriate Common Name when asked about it while generating the Clients&#8217; Key-Pair.</p>
<h3>Signing the Clients&#8217; Certificate</h3>
<p>The Certificate we&#8217;ve created is initially self signed. It needs to be signed by the WebServices&#8217; trusted CA in order to be recognized as an accredited client Certificate. Hence we have to initiate a Certificate Signing Request and &#8217;send&#8217; it to the CA in question:</p>
<pre class="brush: css;">
keytool -certreq -keystore Keystore.jks -alias wsClient -file wsClient.cert.req
</pre>
<p>We&#8217;ve created a new Certificate Signing Request based on the Certificate which belongs to our newly generated Key-Pair (pointing to it by refering to the associated alias name). You&#8217;ll find a new file &#8216;<em>wsClient.cert.req</em>&#8216; which represents that Sigining Request which you now have to &#8217;send&#8217; to the CA for signing.</p>
<p>Switching back to the server side, we now have to sign the &#8216;incoming&#8217; Certificate Signing Request (after we made sure that the client behind that request is a trustworthy one). Following up the <a title="WS-Security 3" href="http://gleichmann.wordpress.com/2009/01/29/ws-security-using-cert-authentication-with-spring-ws-iii-setting-up-the-security-infrastructure/" target="_blank">last episode</a>, we&#8217;ll extend the folder structure within our &#8216;<em>Certificate Factory</em>&#8216; by creating a folder [CERTFACTORY_HOME]<em>\signing </em>in order to hold<br />
Certificate Signing Requests and the resulting signed client Certificates. After putting the incoming Signing Request into that folder, we can start to sign the embedded client Certificate, again using OpenSSL (being on the command line at [CERTFACTORY_HOME]):</p>
<pre class="brush: css;">
openssl ca -config openssl.cfg -out signing\signedWsClient.pem -infiles signing\wsClient.cert.req
</pre>
<p>Again, we have to convert the signed Certificate from PEM to DER format in order to be compatible with a Java Keystore:</p>
<pre class="brush: css;">
openssl x509 -outform DER -in signing\signedWsClient.pem -out sigining\signedWsClient.cert
</pre>
<p>After that, we&#8217;ll send the signed client Certificate <em>signedWsClient.cert</em> (along with the CAs Certificate which you&#8217;ll still find under [CERTFACTORY_HOME]<em>\ca\cacert.cert</em> back to the Client. Note, that we also need to send the CAs Certificate because a Java Keystore need to establish a valid Certificate Chain when importing (signed) Certificates into a Keystore (and that&#8217;s exactly what we&#8217;re now going to to).</p>
<h3>Importing the signed Client Certificate</h3>
<p>Back on the client side, we now have to import the signed Certificate (which we&#8217;ve received from the CA) into the Keystore, since there&#8217;s still the original self signed one inside. First we have to import the CAs Certificate, statisfying the mentioned need for exhibiting a valid Certificate Chain when importing the signed client Certificate afterwards:</p>
<pre class="brush: css;">
keytool -import -file cacert.cert -alias wsCA -keystore keystore.jks
</pre>
<p>Now we&#8217;re able to import the signed client certificate, which will automatically substitute the original self signed Certificate:</p>
<pre class="brush: css;">
keytool -import -file signedWsClient.cert -alias wsClient -keystore keystore.jks
</pre>
<p>Note, that it&#8217;s essential to import the signed Certificate under the alias name under we&#8217;ve generated the clients Key-Pair originally.</p>
<h3>Summary</h3>
<p>We&#8217;ve created a clients&#8217; Keystore which contains a private Key and a related signed Certificate. The Certificate has to be signed by the CA which our WebService trusts in. Having a client Certificate inside a request message which may be signed by another CA would result in the Rejection of that request, since that CAs Certificate don&#8217;t reside in the WebServices Truststore (of course you could also import more than one CA Certificate into your Truststore, so that the WebService would accept request messages with embedded Certificates which in turn are signed by different CAs).<br />
For receiving a signed Certificate, we first have to generate and &#8217;send&#8217; a Certificate Signing Request to the  CA in question, which in turn have to sign the client&#8217;s Certificate and return it along with the CAs Certificate back to the client. The client will then import the CAs Certificate (as the root of the Certificate Chain for the signed client Certificate) and afterwards substitute the original self signed client Certificate with the new signed Certificate.</p>
<p>With that infrastruture at hand, we&#8217;re now prepared to implement a WebService-Client which will use the contained private Key in order to encrypt the digital Signature for arbitrary request messages (since your WebService asks for &#8216;<em>Message Signing</em>&#8216; according to its configured security policies from episode one) which automatically results in the embedding of the clients (now signed) Certificate within the request messages&#8217; security header (which will be used by the WebService to decrypt the encrypted digital Signature along with some of our desired &#8217;side effects&#8217; of being able to access to the Certificates&#8217; attributes for authorization purposes or restricting access to our WebService to only a group of accredited Clients).</p>
<p>So in the next episode, we&#8217;re going to implement that Web-Service Client, also using Spring-WS (namely <em>WebServiceTemplate </em>and <em>WebServiceGatewaySupport</em>), which will sign all outgoing request messages accordingly (configuring the clients&#8217; application context using <em>Message Signing</em>, leveraging the Keystore we&#8217;ve build within this episode).</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gleichmann.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gleichmann.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gleichmann.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gleichmann.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gleichmann.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gleichmann.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gleichmann.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gleichmann.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gleichmann.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gleichmann.wordpress.com/212/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=212&subd=gleichmann&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gleichmann.wordpress.com/2009/02/05/ws-security-using-cert-authentication-with-spring-ws-iv-how-to-set-up-your-clients-keystore/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mario.gleichmann</media:title>
		</media:content>
	</item>
		<item>
		<title>WS-Security using Cert Authentication with Spring-WS III: Setting up the Security infrastructure</title>
		<link>http://gleichmann.wordpress.com/2009/01/29/ws-security-using-cert-authentication-with-spring-ws-iii-setting-up-the-security-infrastructure/</link>
		<comments>http://gleichmann.wordpress.com/2009/01/29/ws-security-using-cert-authentication-with-spring-ws-iii-setting-up-the-security-infrastructure/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 21:59:54 +0000</pubDate>
		<dc:creator>Mario Gleichmann</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=186</guid>
		<description><![CDATA[The Story so far
In the first episodes, we configured Spring-WS for rejecting incoming Messages which were sent from &#8216;unauthorized&#8217; Clients, including the demand for Clients to be trusted by our WebService Endpoint: We only trust in a Client, if its Certificate is in turn issued by a Signer we trust. In our case, the Clients [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=186&subd=gleichmann&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h3>The Story so far</h3>
<p>In the <a title="WS-Security 1" href="http://gleichmann.wordpress.com/2009/01/14/how-to-secure-a-webservice-using-spring-ws-and-certificate-authentication/" target="_blank">first</a> <a title="WS-Security 2" href="http://gleichmann.wordpress.com/2009/01/22/ws-security-using-cert-authentification-with-spring-ws-ii-accessing-the-certificate/" target="_blank">episodes</a>, we configured Spring-WS for rejecting incoming Messages which were sent from &#8216;unauthorized&#8217; Clients, including the demand for Clients to be trusted by our WebService Endpoint: We only trust in a Client, if its Certificate is in turn issued by a Signer we trust. In our case, the Clients Certificate have to be issued by a Certificate Authority (CA) we trust. We inform Spring-WS about that trusted CA by importing the CAs Certificate into our <em>Truststore </em>(a common Java Keystore), which is declared as the Truststore to check against within Spring-WS&#8217; application context.<span id="more-186"></span></p>
<p>In other words, we trust all Client Certificates which are directly issued by the CA which itself is trusted by<br />
the Service Endpoint (by providing its Certificate in the WebServices Truststore). This &#8216;Chain of Trust&#8217; is going to be validated for every Client&#8217;s Certificate (by trying to build a so called Certificate Chain) whenever a Client is transmitting an appropriate Request Message to our WebService.</p>
<h3>Certificate Authority &#8230; again</h3>
<p>As we&#8217;ve already mentioned, the Certificate Authority is an &#8216;entity&#8217;, which issues Certificates for use by other parties. Within this role, it kind of acts like an autonomous, accepted party which all participants rely on.  Although there are some commercial CAs (like VeriSign or Thawte Digital Certificates) we are free to come up with an own CA.<br />
Let&#8217;s say, we want to create a custom CA, &#8216;representing&#8217; the Host of our WebService, e.g. a CA which is commonly used by the  Company which provides the WebService (so to say a Companies own CA). All potential Clients of that WebService have to ask to be signed by that Companies CA  (we&#8217;ll get back to that task called &#8216;Certificate Signing Request&#8217; in a further episode, when switching to the client side) in order to be recognized as an accredited Client who is allowed to access the Companies WebService.</p>
<h3>OpenSSL</h3>
<p>The following sections will give some step by step instructions on how to build your own CA using <a title="OpenSSL" href="http://www.openssl.org" target="_blank">OpenSSL </a>and importing the CAs Certificate into Spring-WS&#8217; Truststore afterwards. In this regard, this episode is not too strongly related to Spring-WS but rather serve as a general approach on setting up a CA Key-Pair as a vital part of a custom Security infrastructure (sometimes called PKI &#8211; Public Key Infrastructure).</p>
<p>Before we start to create the CAs Key-Pair, we have to install OpenSSL (i will show how to do so for Windows, but the<br />
steps are very similar on a unix based operating system). If not done yet, you first have to download and install OpenSSL (you might get a download of a precompiled win version via <a title="OpenSSL for Win" href="http://www.slproweb.com/products/Win32OpenSSL.html" target="_blank">this site</a> &#8211; you may also have to download the &#8216;Visual C++ 2008 Redistributables&#8217; fom the same site should you detect and need to fix some problems under Windows &#8230;)</p>
<h3>Certificate Factory</h3>
<p>Next, we&#8217;ll build an appropriate folder structure where we&#8217;ll initially create and store our CAs private Key and the related Certificate (holding the associated public Key). We&#8217;ll extend that structure in some following sessions in order to store some more data like Certificate Signing Requests and the like.</p>
<p>I&#8217;ll use <em>[CERTFACTORY_HOME]</em> for an arbitrary folder of your choice as the root folder for our structure to build:</p>
<p>[CERTFACTORY_HOME]\ca<br />
[CERTFACTORY_HOME]\ca\certs<br />
[CERTFACTORY_HOME]\ca\crl<br />
[CERTFACTORY_HOME]\ca\newcerts<br />
[CERTFACTORY_HOME]\ca\private</p>
<h3>Groundwork</h3>
<p>Next, we have to place some files, which are needed by OpenSSL for properly creating a new CA:</p>
<ul>
<li>Create a new (empty) Textfile named <em>index.txt</em> under [CERTFACTORY_HOME]\ca</li>
<li>Copy file <em>serial</em> from [OpenSSL_HOME]\bin\PEM\demoCA to [CERTFACTORY_HOME]\ca</li>
<li>Copy OpenSSLs Master-Configuration-File <em>openssl.cfg </em>from [OPENSSL_HOME]\bin directly to [CERTFACTORY_HOME]</li>
</ul>
<h3>OpenSSL Configuration</h3>
<p>The file <em>openssl.cfg </em>serves as OpenSSLs Master-Configuration. Here we have to configure OpenSSL in order to create a CA according to our whiches. For this purpose we&#8217;ll append a new configuration section that should be used whenever<br />
we want to create a new CA, defining some defaults on where OpenSSL should place the generated Keys, which input data to use and some settings used for building the CAs certificate:</p>
<pre class="brush: css;">
[ WEBSERVICE_CA ]

dir   = ./ca
certs   = $dir/certs
crl_dir   = $dir/crl
database  = $dir/index.txt
new_certs_dir  = $dir/newcerts
certificate  = $dir/cacert.pem
serial   = $dir/serial
crlnumber  = $dir/crlnumber
crl   = $dir/crl.pem
private_key  = $dir/private/cakey.pem
RANDFILE  = $dir/private/.rand
x509_extensions  = usr_cert
default_days  = 365
default_crl_days = 30
default_md  = sha1
preserve  = no
policy   = policy_anything

[ policy_anything ]
countryName  = optional
stateOrProvinceName = optional
localityName  = optional
organizationName = optional
organizationalUnitName = optional
commonName  = supplied
emailAddress  = optional
</pre>
<p>Note, that we named our new section <em>WEBSERVICE_CA</em> (of course you are free to come up with a name of your own).<br />
The only thing left is to link to our customized configuration section as the configuration to use whenever a new CA should be created via this configuration file. This is done some lines above within section [ ca ], where we now will link to our section as the default configuration:</p>
<pre class="brush: css;">
[ ca ]
default_ca = WEBSERVICE_CA
</pre>
<h3>Look &#8230; it&#8217;s a &#8230; new CA</h3>
<p>We&#8217;re now ready to create our custom CA. Make sure that [OpenSSL_HOME]\bin is on your path, so that you&#8217;re able to<br />
invoke OpenSSL from everywhere from the command line. Now, switch to [CERTFACTORY_HOME]&gt; (where we&#8217;ve placed our adapted configuration file) and start to build your own CA by typing the following command:</p>
<pre class="brush: css;">
openssl req -x509 -newkey rsa:1024 -keyout ca\private\cakey.pem -out ca\cacert.pem -config openssl.cfg
</pre>
<p>You will be asked to give some relevant information related to the new CA (like some organisational data and a pass phrase for  restricting access to the CAs Key-Pair &#8211; you&#8217;re asked for it again, at least when signing some Client Certificates with  the CAs private Key at later time). After you&#8217;ve answered the questions appropriately, you&#8217;ll find the new CAs public Key (embedded within an accordant Certificate) under [CERTFACTORY_HOME]\ca\<em>cacert.pem</em> and the related private Key under [CERTFACTORY_HOME]\ca\private\<em>cakey.pem</em>.</p>
<p>Note, that the created Certificate is supplied in so called PEM-Format &#8211; in order to import it into a Java-Keystore, we have to convert it accordingly:</p>
<pre class="brush: css;">
openssl x509 -outform DER -in ca\cacert.pem -out ca\cacert.cert
</pre>
<p>Now if you take a look at [CERTFACTORY_HOME]\ca, you&#8217;ll find the converted Certificate with the specified name <em>cacert.cert</em>.</p>
<h3>Storing Trust</h3>
<p>Now let&#8217;s come up with a new Java-Keystore which will serve as the before mentioned Truststore for Spring-WS (used by our Security Interceptor, or better by the injected KeyStoreHandler). We&#8217;ll use Java&#8217;s <em>keytool </em>for that purpose, so be sure to have [JAVA_HOME]\bin on your path.<br />
Unfortunately, if using keytool you can&#8217;t create a new Keystore without also creating a new Key-Pair initially, which is automatically embedded within the new Keystore. As we don&#8217;t need this Key-Pair within our Truststore (we only need the CAs Certificate within), we&#8217;ll provide a Dummy which we&#8217;ll delete afterwards.  It&#8217;s a good idea to initially place that Java-Keystore within our folder structure, so we might create another separate folder for storing our Truststore, like [CERTFACTORY_HOME]\truststore. After switching to that new folder, we&#8217;re ready to go:</p>
<pre class="brush: css;">
keytool -genkey -alias dummy -keyalg RSA -keystore truststore.jks
</pre>
<p>Again you have to answer some questions, related to the new Keystore (like the password to securely refer to the Keystores content or getting permission to import some other Certificates), again some organisational data belonging to the initial Key-Pair and an associated individual passwort.<br />
As you may have seen, the initial created Key-Pair is &#8216;labeled&#8217; by an alias Name (the name to uniquely refer to that Key-Pair within the Keystore) called <em>dummy</em>, which we&#8217;ll use immediately to delete the dummy Key-Pair:</p>
<pre class="brush: css;">
keytool -delete -alias dummy -keystore truststore.jks
</pre>
<p>Now we&#8217;re ready to import the (already converted) Certificate of our trusted CA:</p>
<pre class="brush: css;">
keytool -import -file ..\ca\cacert.cert -alias trustedCA -keystore truststore.jks
</pre>
<h3>Know the Score</h3>
<p>We&#8217;re ready to go with our newly created Trustore (containing the Certificate of our also newly created custom CA) now. The only thing left is to place the Keystore accordingly, so that Spring-WS is able to refer to it at runtime within your deployed environment. If you remember the <a title="WS-Security 1" href="http://gleichmann.wordpress.com/2009/01/14/how-to-secure-a-webservice-using-spring-ws-and-certificate-authentication/" target="_blank">first episode</a>, we already configured Spring-WS for that purpose:</p>
<pre class="brush: xml;">
&lt;bean id=&quot;trustStore&quot;
      class=&quot;org.springframework.ws.soap.security.support.KeyStoreFactoryBean&quot;&gt;
&lt;property name=&quot;location&quot; value=&quot;/WEB-INF/MyTruststore.jks&quot;/&gt;
&lt;property name=&quot;password&quot; value=&quot;MyJavaKeyStorePassword&quot;/&gt;
&lt;/bean&gt;
</pre>
<p>As you see, we have to make sure that our Keystore will be deployed under /WEB-INF using the Name <em>MyTruststore.jks</em> (Spring-WS needs to run within a Web-Container, as it&#8217;s front controller / message dispatcher is a Servlet). Of course you also have to keep the property <em>password </em>in sync with the password you&#8217;ve assigned to the Keystore (while we created it).</p>
<h3>Summary</h3>
<p>OpenSSL allows for the creation of new Certificate Authorities. We created a custom CA which will serve as the WebServices entity to trust. Now, all Client Certificates, which will arrive within incoming request messages have to be signed by that new CA. We said so by importing the CAs Certificate into a newly created Java-Keystore, which have to be provided as the Truststore, which is refered by Spring-WS&#8217; Security Interceptor (more precisely, the KeyStoreHandler, which gets called by the Security Interceptor).</p>
<p>In the next episode, we&#8217;ll switch to the client side and see how to come up with a Client&#8217;s private Key and a related Certificate which gets signed by our CA. We&#8217;ll then implement a WebService-Client that will sign its request messages<br />
in accordance to our claimed security policies (also using Spring-WS) and call our secured WebService.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gleichmann.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gleichmann.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gleichmann.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gleichmann.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gleichmann.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gleichmann.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gleichmann.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gleichmann.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gleichmann.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gleichmann.wordpress.com/186/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=186&subd=gleichmann&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gleichmann.wordpress.com/2009/01/29/ws-security-using-cert-authentication-with-spring-ws-iii-setting-up-the-security-infrastructure/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mario.gleichmann</media:title>
		</media:content>
	</item>
		<item>
		<title>WS-Security using Cert Authentification with Spring-WS II: Accessing the certificate</title>
		<link>http://gleichmann.wordpress.com/2009/01/22/ws-security-using-cert-authentification-with-spring-ws-ii-accessing-the-certificate/</link>
		<comments>http://gleichmann.wordpress.com/2009/01/22/ws-security-using-cert-authentification-with-spring-ws-ii-accessing-the-certificate/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 23:07:58 +0000</pubDate>
		<dc:creator>Mario Gleichmann</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=163</guid>
		<description><![CDATA[In the last episode, we&#8217;ve introduced the Security Interceptor and its Collaborators (KeyStoreHandler, Truststore, Security Policies) as the main Actors for activating Certificate Authentification along with an appropriate application context for configuring Spring-WS accordingly.
Now every incoming request message have to be signed by the Sender (using its private Key), which also implies that the Sender&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=163&subd=gleichmann&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In the <a title="Spring WS and Cert Auth Part 1" href="http://gleichmann.wordpress.com/2009/01/14/how-to-secure-a-webservice-using-spring-ws-and-certificate-authentication/" target="_blank">last episode</a>, we&#8217;ve introduced the Security Interceptor and its Collaborators (KeyStoreHandler, Truststore, Security Policies) as the main Actors for activating Certificate Authentification along with an appropriate application context for configuring Spring-WS accordingly.<br />
Now every incoming request message have to be signed by the Sender (using its private Key), which also implies that the Sender&#8217;s public Key has to be included within the SOAP envelope (in form of an appropriate Certificate which contains the Signers public Key, used to decrypt the clients digital Signature).<span id="more-163"></span></p>
<p>So far, the current configuration is causing our Security Interceptor to reject all request messages which doesn&#8217;t comply with that security constraints. Further, the transmitted client&#8217;s certificate is checked againt the Truststore in that it itself has to be signed (issued) by the CA we trust (by placing the trusted CAs certificate into the configured Truststore).<br />
If an incoming request message meets all those requirements, it passes the Security Interception Process and can be received and consumed by an appropriate Message Endpoint (assumed that there are no other Endpoint Interceptors).</p>
<h3>Authorisation</h3>
<p>Now let&#8217;s suppose, that we need to get access to the client certificate for further processing (e.g. retrieving some of the certificate&#8217;s attributes). Let&#8217;s say that we need to retrieve the Common Name, which is registered within the client&#8217;s certificate for the sake of some custom authorisation: The Common Name should serve as input for deriving a set of rights which are permitted to the client (e.g. by associating the common name or a name pattern to a preconfigured set of rights). Since we are mainly interested on how to retrieve the client certificate, we will not dig into the authorisation process itself in greater detail (as it only serves as a valid example for motivating the retrievement of the client certificate).</p>
<h3>Certificate Validation</h3>
<p>To get access to the certificate, we have to register class <em>SpringCertificateValidationCallbackHandler </em>as another Callback Handler within our Security Interceptor:</p>
<pre class="brush: java;">
...
&lt;bean id=&quot;wsSecurityInterceptor&quot;
      class=&quot;org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor&quot;&gt;
&lt;property name=&quot;policyConfiguration&quot; value=&quot;/WEB-INF/securityPolicy.xml&quot;/&gt;
&lt;property name=&quot;callbackHandlers&quot;&gt;
	&lt;list&gt;
      &lt;ref bean=&quot;keyStoreHandler&quot;/&gt;
      &lt;ref bean=&quot;certificateValidationHandler&quot; /&gt;
    &lt;/list&gt;
  &lt;/property&gt;
&lt;/bean&gt;

&lt;bean id=&quot;certificateValidationHandler&quot;
      class=&quot;org.springframework.ws.soap.security.xwss.callback.SpringCertificateValidationCallbackHandler&quot;&gt;
  ...
&lt;/bean&gt;
</pre>
<p>As you can see, we place the new bean <em>certificateValidationHandler </em>right after the already registered <em>KeyStoreCallbackHandler </em>(which is checking  the Signer of the client certificate against the trusted CA in our Truststore).  Note, that this order is intented and of relevance &#8211; in this case, we will first check the certificate Signer against the CA in our Truststore (by building an accordant Certificate Chain). Only if this check is successful, our <em>certificateValidationHandler </em>will be called afterwards.</p>
<h3>AuthenticationManager</h3>
<p><em>SpringCertificateValidationCallbackHandler </em>itself is only a delegator in our case &#8211; it will call a given <em>AuthenticationManager </em>if configured properly. For the purpose of retrieving the clients certificate, we&#8217;ll inject a custom implementation of AuthenticationManager:</p>
<pre class="brush: java;">
...
&lt;bean id=&quot;springCertificateHandler&quot;
      class=&quot;org.springframework.ws.soap.security.xwss.callback.SpringCertificateValidationCallbackHandler&quot;&gt;
&lt;property name=&quot;authenticationManager&quot;&gt;
    &lt;bean class=&quot;com.mgi.authentication.SimpleAuthenticationManager&quot; /&gt;
  &lt;/property&gt;
&lt;/bean&gt;
</pre>
<p>A valid AuthenticationManager have to implement a correspondend Interface. In this role, he gets called and passed an instance of type <em>Authentication</em>. In case of certificate Authentication, the provided credentials are of type <em>X509Certificate </em>- this is exactly the type of information we are looking for:</p>
<pre class="brush: java;">
import java.security.cert.X509Certificate;
import org.springframework.security.Authentication;
import org.springframework.security.AuthenticationException;
import org.springframework.security.AuthenticationManager;

public class SimpleAuthenticationManager implements AuthenticationManager {

  public Authentication authenticate( Authentication authentication ) throws AuthenticationException {

    Object credentials = authentication.getCredentials();

    if( X509Certificate.class.isAssignableFrom( credentials.getClass() ) ){

      X509Certificate certificate = (X509Certificate) credentials;

      // do some custom authentication here
      setupRightsBasedOn( certificate );
    }

    authentication.setAuthenticated( true );

    return authentication;
  }
}
</pre>
<p>As you can see, we cast the given credentials (which could be any kind of information that prove the principal is correct, like a password in some other cases) to an instance of <em>X509Certificate</em>, do some authorization based on the given certificate and finally successfully complete authentication (you could of course come up with your own authentification logic, which might not always authenticate successfully in some cases).</p>
<h3>X509Certificate</h3>
<p>As we mentioned before, we might determine a set of rights based on the Common Name or any other attribute of the given certificate. In order to do this, we simply rely on the given API of <em>java.security.cert.X509Certificate</em>. Further, we might want to &#8216;publish&#8217; the resulting set of rights, so that they can be retrieved by subsequent called business logic. One solution might be to instantiate a (maybe custom) SecurityContext  (maybe using a <em>ThreadLocal </em>underneath, with all the given advantages and risks) which will accept the determined set of rights and provide them to all subsequent called business logic within the current Thread (since <em>AuthenticationManager </em>offers no way of directly returning a custom set of data):</p>
<pre class="brush: java;">
...
private void setupRightsBasedOn( X509Certificate certificate ){

  X500Principal subjectX500Principal = certificate.getSubjectX500Principal();

  Rights rights = rightsFor( commonNameFrom( subjectX500Principal.getName() ) );

  SecurityContext.initContext( rights );
}

private String commonNameFrom( String subjectName ) {
  return
    StringUtils.extractNesting(
      subjectName, &quot;CN=&quot;, &quot;,&quot;,
      EXCLUDE_OPEN_BRACE_IN_NESTING,
      EXCLUDE_CLOSING_BRACE_IN_NESTING );
}
</pre>
<p>I&#8217;ve omitted the logic on how to retrieve the accordant set of rights for a given Common Name, since this is highly dependent by the given needs and infrastructure of the appclication. You might want to retrieve a database (since we are using Spring-WS you are free to inject any type of spring bean (e.g. a service or a DAO bean) to your custom implementation of <em>AuthenticationManager </em>- remember that the parent context  of Spring-WS&#8217; application context is automatically the given web application context) or calculate the rights by any meaningful logic.<br />
You can clearly see, that we only rely on the given API of <em>X509Certificate</em>. Of course you are free to retrieve an arbitrary attribute from within the certificate.</p>
<h3>Summary</h3>
<p>Retrieving the client&#8217;s certificate is more or less a matter of providing a custom AuthenticationManager which itself gets called by a <em>SpringCertificateValidationCallbackHandler </em>(which is registered as another Callback Handler within our Security Interceptor). For having configured Certificate Authentification by the given Security policies, we&#8217;ll receive credentials in form of a <em>X509Certificate</em>. Retrieving some attributes from that certificate now is just a matter of using the provided API of <em>X509Certificate </em>in a suitable way &#8211; and that&#8217;s it.</p>
<p>In the next episode, we&#8217;ll take a closer look on how to set up the servers security infrastructure, including some step by step instructions on how to use OpenSSL and Keytool in order to create a CA Key-pair and importing the related CAs certificate into our Truststore. We&#8217;ll then move on to the client side in some further episode and will set up the client&#8217;s security infrastructure and of course come up with an implementation of a WebService-Client that will sign its request messages accordingly (also using Spring-WS) and call our secured WebService.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gleichmann.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gleichmann.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gleichmann.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gleichmann.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gleichmann.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gleichmann.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gleichmann.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gleichmann.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gleichmann.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gleichmann.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gleichmann.wordpress.com&blog=2165876&post=163&subd=gleichmann&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gleichmann.wordpress.com/2009/01/22/ws-security-using-cert-authentification-with-spring-ws-ii-accessing-the-certificate/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mario.gleichmann</media:title>
		</media:content>
	</item>
	</channel>
</rss>