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

<channel>
	<title>Tech Life of Recht</title>
	<atom:link href="http://braindump.dk/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://braindump.dk/tech</link>
	<description>Online and Working</description>
	<lastBuildDate>Thu, 28 Jan 2010 22:29:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>More on Andronos</title>
		<link>http://braindump.dk/tech/2010/01/29/more-on-andronos/</link>
		<comments>http://braindump.dk/tech/2010/01/29/more-on-andronos/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 22:29:09 +0000</pubDate>
		<dc:creator>recht</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[andronos]]></category>
		<category><![CDATA[sonos]]></category>

		<guid isPermaLink="false">http://braindump.dk/tech/?p=213</guid>
		<description><![CDATA[14 releases later, and Andronos (my Sonos controller for Android) is actually looking pretty good. My 1337 gui skills have been at work, and in my own opinion, the application has been styled somewhat nicely. Basic functionality is present:

Detect and list available zones
Group zones together
Stop/play/next/previous
Playlist management
Browse music
Browse radio stations
Volume control, both individual and group volume

I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>14 releases later, and <a href="http://code.google.com/p/andronos/">Andronos</a> (my <a href="http://sonos.com">Sonos</a> controller for Android) is actually looking pretty good. My 1337 gui skills have been at work, and in my own opinion, the application has been styled somewhat nicely. Basic functionality is present:</p>
<ul>
<li>Detect and list available zones</li>
<li>Group zones together</li>
<li>Stop/play/next/previous</li>
<li>Playlist management</li>
<li>Browse music</li>
<li>Browse radio stations</li>
<li>Volume control, both individual and group volume</li>
</ul>
<p>I&#8217;ve also managed to add some more special features:</p>
<ul>
<li>Quickplay list &#8211; I use it for starting my favorite radio without having to navigate the browsing structure</li>
<li>Indexing and freetext search</li>
<li>Last.fm integration &#8211; covers are fetched automatically if none existed locally, and extra info (tags and play count) can be retrieved. Also, it&#8217;s possible to love a song using last.fm</li>
</ul>
<p>All the features of the regular controller which I normally use are done, so I&#8217;m more or less ready to drop my iPhone. Now begins the hard part of adding new valuable features &#8211; most of them are not particularly easy to implement:</p>
<ul>
<li>Faster &#8211; the Android platform is pretty nice to work with, but Andronos is not exactly as fast as the native controller. Caching can add some performance, but in the end, I&#8217;ll probably have to do some pretty low-level optimizations all over the place</li>
<li>Cover browsing &#8211; it should be possible to browse the music archive based on a list of covers</li>
<li>Rhapsody and Pandora &#8211; probably not hard to do, but neither of the two are available in Denmark. Help is appreciated here &#8211; I don&#8217;t quite know how yet, but if you&#8217;re interested, please contact me.</li>
<li>Dynamic playlists &#8211; Andronos should be able to dynamically create playlists based for example on loved songs, previously played songs, and so on. Also, it should be able to select music based on a general category (party, relaxing, cooking, whatever)</li>
</ul>
<p>I&#8217;ll probably think of more features to add, but it should be enough for now &#8211; there should also be something left for Sonos to do when they get around to making a supported controller for Android.</p>
<p>And then to something a little different, but related. Someone asked me today if I had an opinion of mobile development with Android. Having worked with Android for a couple of my pet projects, there are some things I&#8217;ve noticed, and here are some of them, in no particular order. Hopefully, I&#8217;ll get time to elaborate on them later on.</p>
<ul>
<li>As a Java programmer, nothing really beats having your normal environment, in my case Eclipse, and all the standard libraries. Need UPnP? Download a library. Need last.fm integration? Download a library. Need raw network access? Download a library using JNI. (in the last case, be prepared to fiddle around with Make-ish files, but it can be done). No need to learn a new language or new basic tools, you just have to learn a new API.</li>
<li>It can be a little hard to drop all the fancy patterns and design principles, but it&#8217;s often necessary to get acceptable performance. Object allocation and garbage collection is pretty expensive, which is the complete opposite of the regular Java VM, so you have to be careful, and that can hurt in a number of ways (think maintainability, API design, testability)</li>
<li>The declarative UI approach works pretty well, but the Eclipse plugin does a pretty bad job of rendering the UI, so in most cases, you have to fire up the app on either an emulator or a phone to get a real look at the UI. A simple thing: Why are styles not rendered in the plugin?</li>
<li>The UI does have a number of bugs and undocumented features. Drawables are probably the worst I&#8217;ve met. They can be defined in XML, and can be used for eg background gradients, button borders, and much more, but they are truly trial-and-error</li>
<li>Android Market works pretty nicely, in principle, at least. I wouldn&#8217;t have been able to create Andronos if I&#8217;d had a turnaround time of a month for each release. Of course, Andronos is a little special, because Sonos systems can be configured in so many different ways, and I do not have one of each player model, but still. Being able to get a bug report, fix the bug, and release a new version in a matter of 10 minutes is pretty cool.</li>
<li>A couple of things about Android Market, though: Why can&#8217;t I see the comments in a regular browser, and why can&#8217;t I reply to the comments?</li>
<li>Fortunately, Andronos is pretty flexible in the layout, so it runs without any serious problems on both small and large screens. However, this can easily become a problem if you haven&#8217;t defined the UI in device-independent units, and even then, you might be forced to having different layouts for different devices. I&#8217;m guessing Apple will have to cope with this too, now that the iTablet (I forgot its name) is out</li>
<li>I can see why root access is something you don&#8217;t want to give out to everybody, but couldn&#8217;t there be some way of getting partial root access? For example, if I want to send an ICMP packet, I need write access to the network device, but I can&#8217;t get that. Why?</li>
<li>Error handling could be better when an application crashes. I&#8217;ve installed a custom exception handler which emails me stack traces, but couldn&#8217;t this just be built-in?</li>
<li>The Android API itself is at points somewhat strange. Why do I sometimes need to bitwise add flags to a component? Why must I always remember to call super? Most of the time, it&#8217;s just like doing Swing, and I can live with that. The API could be more &#8220;modern&#8221;, however, and not use inheritance quite as much as it does.</li>
<li>Testing isn&#8217;t as easy as it could have been (and with Andronos, it&#8217;s even harder, because most functionality only makes sense when connected to a Sonos device), but that&#8217;s at least in part because GUI testing has never been easy. Just learn to separate UI logic from &#8220;business&#8221; logic, and then the business logic can be tested as you would normally do it.</li>
<li>Most importantly, and this outweighs any disadvantages Android might have: The platform is open, there&#8217;s an active community, there&#8217;s lot of open source, and you&#8217;re not forced into anything</li>
</ul>
<p>That&#8217;s it for now. And no new releases tonight (but that&#8217;s probably just because I&#8217;ve been musically cultural tonight).</p>
]]></content:encoded>
			<wfw:commentRss>http://braindump.dk/tech/2010/01/29/more-on-andronos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Andronos, Sonos remote control for Android</title>
		<link>http://braindump.dk/tech/2010/01/10/andronos-sonos-remote-control-for-android/</link>
		<comments>http://braindump.dk/tech/2010/01/10/andronos-sonos-remote-control-for-android/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 21:16:51 +0000</pubDate>
		<dc:creator>recht</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[sonos]]></category>

		<guid isPermaLink="false">http://braindump.dk/tech/?p=211</guid>
		<description><![CDATA[Lately, I&#8217;ve been working on my first real project for Android, a remote control for my Sonos system, so that I can finally get rid of my iPhone (which I am only using for that purpose).
This has been quite a learning experience, both in regard to Android and Sonos &#8211; Sonos is controlled using UPNP, [...]]]></description>
			<content:encoded><![CDATA[<p>Lately, I&#8217;ve been working on my first real project for Android, a remote control for my <a href="http://www.sonos.com">Sonos</a> system, so that I can finally get rid of my iPhone (which I am only using for that purpose).</p>
<p>This has been quite a learning experience, both in regard to Android and Sonos &#8211; Sonos is controlled using UPNP, so now I probably know much more about that than I&#8217;d ever want to. However, it seems to have paid off, because I finally have something that works, at least somewhat. Performance isn&#8217;t great, and some features are still missing, but that should all be fixable. </p>
<p>My plans are to build some extra last.fm support into the remote control, so that it can, for example, generate queues based on track popularity, display album/artist/track info, and much more. Already, album covers are retrieved from last.fm (I&#8217;ll probably change this so it checks the Sonos system first, at some point).</p>
<p>The features implemented now are: basic playback control (previous, next, play, pause), mute/unmute, volume control, adding/removing from queue, and browse available music. Most important missing feature is probably zone management, but hopefully, I&#8217;ll get time to fix that soon. Also, internet radio isn&#8217;t working, and it seems that you cannot change from radio to regular playlist.</p>
<p>The application is available on Android Market under the name Andronos, so if you own an Android phone and a Sonos system, please try it out. Any bugs or suggestions can be reported on <a href="http://code.google.com/p/andronos/">the Google Code site</a>. If you&#8217;re really ambitious, I&#8217;m also accepting patches (the project is open source, after all). The code is <a href="http://gitorious.org/andronos">hosted at Gitorious</a>, so just go ahead and check it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://braindump.dk/tech/2010/01/10/andronos-sonos-remote-control-for-android/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Using ActAs with Metro</title>
		<link>http://braindump.dk/tech/2010/01/05/using-actas-with-metro/</link>
		<comments>http://braindump.dk/tech/2010/01/05/using-actas-with-metro/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 10:18:12 +0000</pubDate>
		<dc:creator>recht</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[oio]]></category>
		<category><![CDATA[saml]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[ws-*]]></category>

		<guid isPermaLink="false">http://braindump.dk/tech/?p=209</guid>
		<description><![CDATA[Yesterday, I wrote about how to implement an STS with Metro. The reason for implementing an STS in the first place is that it enables identity delegation, something you probably want if you need to access a service on behalf of a specific user. The general flow is that the user authenticates, probably using SSO [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I wrote about <a href="http://braindump.dk/tech/2010/01/04/building-an-sts-with-metro/">how to implement an STS with Metro</a>. The reason for implementing an STS in the first place is that it enables identity delegation, something you probably want if you need to access a service on behalf of a specific user. The general flow is that the user authenticates, probably using SSO of some kind, and access a website. The site invokes a service on behalf of the user, and the service needs to be pretty sure that the user is actually sitting in the other end, even though there is no direct communication between the user and the service. The job of the STS is to be the one, everybody trusts, so that when the STS issues a token which says that the user is valid, then the service can trust that this is actually the case.</p>
<p>All of this can be done more or less automatically with <a href="http://metro.dev.java.net">Metro</a> (at least when using a nightly build) by using this service policy:</p>
<div class="igBar"><span id="lcode-3"><a href="#" onclick="javascript:showPlainTxt('code-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-3">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;sp:AsymmetricBinding&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&lt;wsp:Policy&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&lt;sp:InitiatorToken&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;wsp:Policy&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;sp:IssuedToken&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&lt;sp:IssuerName&gt;urn:localsts&lt;/sp:IssuerName&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&lt;sp:RequestSecurityTokenTemplate&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;t:TokenType&gt;http:<span style="color:#FF9933; font-style:italic;">//docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0&lt;/t:TokenType&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;t:KeyType&gt;http:<span style="color:#FF9933; font-style:italic;">//docs.oasis-open.org/ws-sx/ws-trust/200512/PublicKey&lt;/t:KeyType&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&lt;/sp:RequestSecurityTokenTemplate&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;wsp:Policy&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &lt;sp:RequireInternalReference /&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/wsp:Policy&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/sp:IssuedToken&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;/wsp:Policy&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&lt;/sp:InitiatorToken&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&lt;sp:RecipientToken&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;wsp:Policy&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;sp:X509Token&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;wsp:Policy&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;sp:RequireKeyIdentifierReference /&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;sp:WssX509V3Token11 /&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/wsp:Policy&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/sp:X509Token&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;/wsp:Policy&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&nbsp;&lt;/sp:RecipientToken&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;sp:ProtectTokens/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;sp:IncludeTimestamp/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;sp:OnlySignEntireHeadersAndBody /&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp;&lt;/wsp:Policy&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&lt;/sp:AsymmetricBinding&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Here, we express that the service requires an issued token of type SAML 2.0. Issued token means that the token has been created by an STS. In this case, we specify that the STS identified by urn:localsts must issue a token of type SAML 2.0. The exact location of the STS needs to be configured in the client.</p>
<p>Unfortunately, <a href="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/ws-securitypolicy-1.2-spec-os.html">WS-SecurityPolicy</a> does not make it possible to express the requirements for the <a href="http://docs.oasis-open.org/ws-sx/ws-trust/200512/ws-trust-1.3-os.html">WS-Trust</a> Issue request. When using identity delegation, two sets of credentials should be passed to the STS: The client credentials, for example an <a href="http://docs.oasis-open.org/wss/v1.1/wss-v1.1-spec-os-x509TokenProfile.pdf">X509Token</a> or a UsernameToken, and the user credentials. The client credentials are provided using standard WS-Security mechanisms, and the user credentials are included in the Issue request using the ActAs element.</p>
<p>As shown in the STS example, the STS policy file takes care of the client credentials by specifying the appropriate tokens. The user credentials token cannot, however, be expressed in the policy, so it needs to be agreed upon out of band. This also means that you have to provide it manually to the client.</p>
<p>Luckily, it's pretty easy to add an ActAs token to the client. Normally, the client is generated using wsimport. In this example, the service is called ProviderService:</p>
<div class="igBar"><span id="lcode-4"><a href="#" onclick="javascript:showPlainTxt('code-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-4">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">DefaultSTSIssuedTokenConfiguration config = new DefaultSTSIssuedTokenConfiguration<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">config.<span style="">setSTSInfo</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"http://docs.oasis-open.org/ws-sx/ws-trust/200512"</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#CC0000;">"http://localhost:8080/sts/sts"</span>, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#CC0000;">"http://localhost:8080/sts/sts?wsdl"</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#CC0000;">"SecurityTokenService"</span>, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#CC0000;">"ISecurityTokenService_Port"</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#CC0000;">"http://tempuri.org/"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">config.<span style="">getOtherOptions</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">put</span><span style="color:#006600; font-weight:bold;">&#40;</span>STSIssuedTokenConfiguration.<span style="">ACT_AS</span>, createToken<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">STSIssuedTokenFeature feature = new STSIssuedTokenFeature<span style="color:#006600; font-weight:bold;">&#40;</span>config<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ProviderService service = new ProviderService<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Provider port = service.<span style="">getProviderPort</span><span style="color:#006600; font-weight:bold;">&#40;</span>feature<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">EchoResponse result = port.<span style="">echo</span><span style="color:#006600; font-weight:bold;">&#40;</span>new Echo<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Here, we create a new configuration object, set the endpoint information for the STS, and add an ActAs token. The contents of the ACT_AS attribute should be an instance of com.sun.xml.ws.security.Token, for example a com.sun.xml.wss.saml.Assertion. Normally, you don't generate the token yourself. Instead, you get it as part of the initial authentication response - for example, if you're using SAML 2.0 web SSO, one of the attributes received might be the ActAs token that should be passed to the STS when invoking services.</p>
]]></content:encoded>
			<wfw:commentRss>http://braindump.dk/tech/2010/01/05/using-actas-with-metro/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building an STS with Metro</title>
		<link>http://braindump.dk/tech/2010/01/04/building-an-sts-with-metro/</link>
		<comments>http://braindump.dk/tech/2010/01/04/building-an-sts-with-metro/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 20:25:34 +0000</pubDate>
		<dc:creator>recht</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[oio]]></category>
		<category><![CDATA[saml]]></category>
		<category><![CDATA[ws-*]]></category>

		<guid isPermaLink="false">http://braindump.dk/tech/?p=199</guid>
		<description><![CDATA[One of my recent tasks has been to see if it was possible to implement an OIO-Trust-compliant STS using the Metro stack from Sun. Metro contains WSIT, which has a number of classes for building an STS, so it's not that hard. However, large portions of the code is quite undocumented, so I decided to [...]]]></description>
			<content:encoded><![CDATA[<p>One of my recent tasks has been to see if it was possible to implement an <a href="http://bit.ly/oiotrust">OIO-Trust</a>-compliant STS using the <a href="https://metro.dev.java.net/">Metro</a> stack from <a href="http://sun.com">Sun</a>. Metro contains WSIT, which has a number of classes for building an STS, so it's not that hard. However, large portions of the code is quite undocumented, so I decided to write some of my findings down, hence this post (which is probably only interesing to a very few people).</p>
<p>First of all, OIO-Trust is a Danish <a href="http://docs.oasis-open.org/ws-sx/ws-trust/200512/ws-trust-1.3-os.html">WS-Trust</a> profile, which basically says how Issue requests should look. The basic premise is that in order to invoke a SOAP service, you need a token. The STS issues the token based on some criteria using the WS-Trust protocol on top of SOAP.<br />
In OIO-Trust, the Issue request must be signed, and it must contain a so-called bootstrap token. The bootstrap token is a <a href="http://saml.xml.org/saml-specifications">SAML 2.0 assertion</a>. Furthermore, the request must contain the X509 certificate which is used to sign the message. The token requested in the Issue request is a PublicKey (that is, asymmetric) of type SAML 2.0. So, the input is a SAML 2.0 assertion, and the output is also a SAML 2.0 token. More specifically, the output is a holder-of-key token, which has the requestors X509 certificate in the SubjectConfirmationData. The assertion is signed by the STS, and contains by default all the attributes from the input assertion.</p>
<p>In order to create an STS using Metro, you need to</p>
<ul>
<li>Configure the Metro servlet in web.xml</li>
<li>Implement a simple STS endpoint class</li>
<li>Create a WSDL and a security policy</li>
<li>Create a number of services for handling attributes, configuration, etc</li>
</ul>
<p><strong>Configuring web.xml</strong><br />
This assumes that you're using a simple servlet container. If the container supports JAX-WS, it shouldn't be necessary.<br />
When using Metro, all requests go through the same servlet, the WSServlet. The exact endpoint implementation used is then configured in another file, WEB-INF/sun-jaxws.xml. Therefore, simply add the following to web.xml:</p>
<div class="igBar"><span id="lcode-12"><a href="#" onclick="javascript:showPlainTxt('code-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-12">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;listener&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;listener-class&gt;com.<span style="">sun</span>.<span style="">xml</span>.<span style="">ws</span>.<span style="">transport</span>.<span style="">http</span>.<span style="">servlet</span>.<span style="">WSServletContextListener</span>&lt;/listener-class&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;/listener&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;servlet&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;servlet-name&gt;sts&lt;/servlet-name&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;servlet-class&gt;com.<span style="">sun</span>.<span style="">xml</span>.<span style="">ws</span>.<span style="">transport</span>.<span style="">http</span>.<span style="">servlet</span>.<span style="">WSServlet</span>&lt;/servlet-class&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;load-on-startup&gt;<span style="color:#800000;color:#800000;">1</span>&lt;/load-on-startup&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;/servlet&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;servlet-mapping&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;servlet-name&gt;sts&lt;/servlet-name&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;url-pattern&gt;/services<span style="color:#008000;">/*&lt;/url-pattern&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &lt;/servlet-mapping&gt; </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This maps all requests to /services to Metro.</p>
<p><strong>Implement the STS endpoint</strong><br />
Implementing the endpoint is quite simple, as it's simply a question of extending a Metro class and injecting a resource. Here is a basic implementation:</p>
<div class="igBar"><span id="lcode-13"><a href="#" onclick="javascript:showPlainTxt('code-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-13">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">annotation</span>.<span style="">Resource</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">xml</span>.<span style="">transform</span>.<span style="">Source</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">xml</span>.<span style="">ws</span>.<span style="">Provider</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">xml</span>.<span style="">ws</span>.<span style="">Service</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">xml</span>.<span style="">ws</span>.<span style="">ServiceMode</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">xml</span>.<span style="">ws</span>.<span style="">WebServiceContext</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">xml</span>.<span style="">ws</span>.<span style="">WebServiceProvider</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">xml</span>.<span style="">ws</span>.<span style="">handler</span>.<span style="">MessageContext</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import com.<span style="">sun</span>.<span style="">xml</span>.<span style="">ws</span>.<span style="">security</span>.<span style="">trust</span>.<span style="">sts</span>.<span style="">BaseSTSImpl</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@ServiceMode<span style="color:#006600; font-weight:bold;">&#40;</span>value=Service.<span style="">Mode</span>.<span style="">PAYLOAD</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@WebServiceProvider<span style="color:#006600; font-weight:bold;">&#40;</span>wsdlLocation=<span style="color:#CC0000;">"WEB-INF/wsdl/sts.wsdl"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public class TokenService extends BaseSTSImpl implements Provider&lt;Source&gt;<span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Resource</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected WebServiceContext context;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected MessageContext getMessageContext<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; MessageContext msgCtx = context.<span style="">getMessageContext</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; return msgCtx;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span>&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>No changes should be necessary, as the BaseSTSImpl class will handle all WS-Trust communication. What you need to do is to configure the base class according to the local requirements. More on that a little later.</p>
<p>In order to wire the STS endpoint into Metro, you need to create a WEB-INF/sun-jaxws.xml file. The file should contain something like this:</p>
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showPlainTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;endpoints</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns=<span style="color:#CC0000;">"http://java.sun.com/xml/ns/jax-ws/ri/runtime"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; version=<span style="color:#CC0000;">"2.0"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;endpoint</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; name=<span style="color:#CC0000;">"sts"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; implementation=<span style="color:#CC0000;">"dk.itst.oiosaml.sts.TokenService"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; wsdl=<span style="color:#CC0000;">"WEB-INF/wsdl/sts.wsdl"</span>&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; service=<span style="color:#CC0000;">"{http://tempuri.org/}SecurityTokenService"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; port=<span style="color:#CC0000;">"{http://tempuri.org/}ISecurityTokenService_Port"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; binding=<span style="color:#CC0000;">"http://schemas.xmlsoap.org/wsdl/soap/http"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; url-pattern=<span style="color:#CC0000;">"/sts"</span> /&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/endpoints&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This binds the TokenService implementation to the url /services/sts using SOAP 1.1 (specified by the binding attribute).</p>
<p><strong>Creating the WSDL and policy file</strong><br />
This is by far the hardest part of creating an STS for Metro. The WSDL should be pretty standard, and the same file can be used for all implementations. However, the WSDL file must also contain a security policy, as defined by <a href="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/ws-securitypolicy-1.2-spec-os.html">WS-SecurityPolicy</a>, and writing the policy can be pretty complicated. <a href="http://netbeans.org/">Netbeans</a> has some support for writing policies, but I prefer to do it by hand because then you're sure what you'll get (once you understand WS-SecurityPolicy, that is).</p>
<p>The WSDL file tends to get somewhat large, so I won't include it here - instead, you can download it if you want to see it. Basically, the WSDL is split into two parts: The regular WSDL stuff with types, messages, porttypes, bindings, and services, and the WS-SecurityPolicy stuff. Normally, the policy consists of 3 parts: The service policy which defined which tokens should be used, and how the security header layout should be, a policy which defines signature and encryption requirements for the request, and a policy for the response. These parts are then wired into the normal WSDL using PolicyReference elements.<br />
In the example file, the service policy defines that we're using an asymmetric binding (that is, the tokens should be different in the request and response - for example when using public/private keys). The policy also says something about the layout, and that the security header must contain a timestamp. Finally, it also enabled WS-Addressing. </p>
<p>Because this is an STS, the WSDL also contains a third part, namely static configuration of the STS. This includes configuring which certificates to use, how to validate incoming requests, and how tokens should be created.</p>
<p>Basically, this finishes the configuration of a very basic STS. However, there are some aspects which probably require some adjustments. </p>
<p><strong>Checking if the requesting entity is allowed to access the requested service</strong><br />
When a client requests a new token, it includes a reference to the service in the AppliesTo element. Sometimes, there might be restrictions on who can access what. The Metro STS can check if the client is allowed to access a service by implementing the com.sun.xml.ws.api.security.trust.STSAuthorizationProvider interface. The interface has one method, isAuthorized(subject, appliesTo, tokenType, keyType), which returns true or false:</p>
<div class="igBar"><span id="lcode-15"><a href="#" onclick="javascript:showPlainTxt('code-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-15">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package dk.<span style="">itst</span>.<span style="">oiosaml</span>.<span style="">sts</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import javax.<span style="">security</span>.<span style="">auth</span>.<span style="">Subject</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">import com.<span style="">sun</span>.<span style="">xml</span>.<span style="">ws</span>.<span style="">api</span>.<span style="">security</span>.<span style="">trust</span>.<span style="">STSAuthorizationProvider</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public class AutorizationProvider implements STSAuthorizationProvider <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; public boolean isAuthorized<span style="color:#006600; font-weight:bold;">&#40;</span>Subject subject, String appliesTo, String tokenType, String keyType<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; return true;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Metro uses the standard JDK service mechanism to discover implementations of this interface. That means that you should create the file /META-INF/services/<interfacename> under your source directory and populate the file with the fully qualified classname of the implementation - in this example, create /META-INF/services/com.sun.xml.ws.api.security.trust.STSAuthorizationProvider with the contents dk.itst.oiosaml.sts.AuthorizationProvider.</p>
<p><strong>Speficying attributes</strong><br />
Normally, you probably want to be able to configure the contents of the generated assertion, at the very least the attributes used, as well as the NameID of the subject. This is also done using a service implementation, this time using the com.sun.xml.ws.api.security.trust.STSAttributeProvider interface.</p>
<p>The STSAttributeProvider interface has one method, getClaimedAttributes(subject, appliesTo, tokenType, claims), which returns a map of all the attributes and their values.</p>
<p>The subject contains information about the requesting client, in our example identified by a X509 certificate. The claims object contains any claims included in the request. It also holds any tokens included in OnBehalfOf or ActAs. These tokens are placed in claims.getSupportingProperties(), where they can be read as Subject objects. Here's an example on reading an assertion, which has been included in ActAs:</p>
<div class="igBar"><span id="lcode-16"><a href="#" onclick="javascript:showPlainTxt('code-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-16">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">private Assertion getSubject<span style="color:#006600; font-weight:bold;">&#40;</span>Claims claims<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Subject subject = null;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; for <span style="color:#006600; font-weight:bold;">&#40;</span>Object prop : claims.<span style="">getSupportingProperties</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; if <span style="color:#006600; font-weight:bold;">&#40;</span>prop instanceof Subject<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; subject = <span style="color:#006600; font-weight:bold;">&#40;</span>Subject<span style="color:#006600; font-weight:bold;">&#41;</span> prop;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; if <span style="color:#006600; font-weight:bold;">&#40;</span>subject != null<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Set&lt;Element&gt; creds = subject.<span style="">getPublicCredentials</span><span style="color:#006600; font-weight:bold;">&#40;</span>Element.<span style="">class</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; if <span style="color:#006600; font-weight:bold;">&#40;</span>!creds.<span style="">isEmpty</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; Element assertion = creds.<span style="">iterator</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">next</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; try <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Assertion saml = SAMLAssertionFactory.<span style="">newInstance</span><span style="color:#006600; font-weight:bold;">&#40;</span>SAMLAssertionFactory.<span style="">SAML2_0</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">createAssertion</span><span style="color:#006600; font-weight:bold;">&#40;</span>assertion<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; return saml;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> catch <span style="color:#006600; font-weight:bold;">&#40;</span>Exception e<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; e.<span style="">printStackTrace</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; return null;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The attribute provider can then be implemented - here's an example where the attributes from the ActAs assertion are simply copied to the resulting assertion:</p>
<div class="igBar"><span id="lcode-17"><a href="#" onclick="javascript:showPlainTxt('code-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-17">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public Map&lt;QName, List&lt;String&gt;&gt; getClaimedAttributes<span style="color:#006600; font-weight:bold;">&#40;</span>Subject subject, String appliesTo, String tokenType, Claims claims<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Map&lt;QName, List&lt;String&gt;&gt; res = new HashMap&lt;QName, List&lt;String&gt;&gt;<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Assertion assertion = getSubject<span style="color:#006600; font-weight:bold;">&#40;</span>claims<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; if <span style="color:#006600; font-weight:bold;">&#40;</span>assertion != null<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; AttributeStatement attrs = getAttributes<span style="color:#006600; font-weight:bold;">&#40;</span>assertion<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; for <span style="color:#006600; font-weight:bold;">&#40;</span>Attribute attr : attrs.<span style="">getAttributes</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; List&lt;String&gt; values = new ArrayList&lt;String&gt;<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; for <span style="color:#006600; font-weight:bold;">&#40;</span>Object val : attr.<span style="">getAttributes</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; values.<span style="">add</span><span style="color:#006600; font-weight:bold;">&#40;</span>val.<span style="">toString</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; res.<span style="">put</span><span style="color:#006600; font-weight:bold;">&#40;</span>new QName<span style="color:#006600; font-weight:bold;">&#40;</span>attr.<span style="">getName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, values<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; res.<span style="">put</span><span style="color:#006600; font-weight:bold;">&#40;</span>new QName<span style="color:#006600; font-weight:bold;">&#40;</span>assertion.<span style="">getSubject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">getNameId</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">getNameQualifier</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; STSAttributeProvider.<span style="">NAME_IDENTIFIER</span><span style="color:#006600; font-weight:bold;">&#41;</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; Collections.<span style="">singletonList</span><span style="color:#006600; font-weight:bold;">&#40;</span>assertion.<span style="">getSubject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">getNameId</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">getValue</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; return res;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Notice the last statement, where the NameID is added. The Metro STS will check if an attribute with the name STSAttributeProvider.NAME_IDENTIFIER is present, and in that case use that as the NameID of the subject in the generated assertion.</p>
<p><strong>Handling configuration</strong><br />
The Metro STS must be know all services for which it can issue tokens. These services can either be configured statically in the WSDL file, or they can be provided programmatically. The static configuration is probably only interesting when developing, in a production environment, you probably want to build a nice admin console where services can be added and removed at runtime.</p>
<p>Static configuration takes place in the STSConfiguration element in the WSDL file. It can contain a ServiceProviders tag, which can then contain a number of ServiceProvider tags. Each ServiceProvider must be configured with an endpoint (the AppliesTo value), a certificate, and a token type:</p>
<div class="igBar"><span id="lcode-18"><a href="#" onclick="javascript:showPlainTxt('code-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-18">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;tc:STSConfiguration xmlns:tc=<span style="color:#CC0000;">"http://schemas.sun.com/ws/2006/05/trust/server"</span> encryptIssuedKey=<span style="color:#CC0000;">"false"</span> encryptIssuedToken=<span style="color:#CC0000;">"false"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;&lt;tc:LifeTime&gt;<span style="color:#800000;color:#800000;">36000</span>&lt;/tc:LifeTime&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;&lt;tc:Contract&gt;com.<span style="">sun</span>.<span style="">xml</span>.<span style="">ws</span>.<span style="">security</span>.<span style="">trust</span>.<span style="">impl</span>.<span style="">WSTrustContractImpl</span>&lt;/tc:Contract&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;&lt;tc:Issuer&gt;urn:localtokenservice&lt;/tc:Issuer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;&lt;tc:ServiceProviders&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tc:ServiceProvider endPoint=<span style="color:#CC0000;">"http://localhost:8880/poc-provider/ProviderService"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tc:CertAlias&gt;poc-provider&lt;/tc:CertAlias&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tc:TokenType&gt;http:<span style="color:#FF9933; font-style:italic;">//docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0&lt;/tc:TokenType&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/tc:ServiceProvider&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;/tc:ServiceProviders&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/tc:STSConfiguration&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The static configuration also contains information about the STS' own id (the Issuer element), as well as the lifetime of issued tokens. The CertAlias value of a ServiceProvider must point to an alias in the trust store.</p>
<p><strong>Programmatic configuration</strong><br />
Controlling configuration programmatically is a question of providing a service implementation of com.sun.xml.ws.api.security.trust.config.STSConfigurationProvider. This interface has a single method, getSTSConfiguration(), which returns a configuration object - either your own implementation or an instanceof DefaultSTSConfiguration. </p>
<p>That more or less concludes my findings for now. There are a number of details I haven't covered here, but I'll wait with that until another time. </p>
]]></content:encoded>
			<wfw:commentRss>http://braindump.dk/tech/2010/01/04/building-an-sts-with-metro/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Gnome Do in XMonad</title>
		<link>http://braindump.dk/tech/2009/12/02/gnome-do-in-xmonad/</link>
		<comments>http://braindump.dk/tech/2009/12/02/gnome-do-in-xmonad/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 20:15:35 +0000</pubDate>
		<dc:creator>recht</dc:creator>
				<category><![CDATA[xmonad]]></category>

		<guid isPermaLink="false">http://braindump.dk/tech/?p=197</guid>
		<description><![CDATA[I recently started using Gnome Do as a launcher in xmonad - not to replace the good old XMonad.Prompt, but because it integrates quite nicely into some other OS features. For example, suspending is a matter of pressing Ctrl-Alt-space and entering susp. There are a lot of other nice features like that. I still use [...]]]></description>
			<content:encoded><![CDATA[<p>I recently started using <a href="http://do.davebsd.com/">Gnome Do</a> as a launcher in <a href="http://xmonad.org">xmonad</a> - not to replace the good old XMonad.Prompt, but because it integrates quite nicely into some other OS features. For example, suspending is a matter of pressing Ctrl-Alt-space and entering susp<enter>. There are a lot of other nice features like that. I still use the regular XMonad.Prompt to start programs, as it works just fine for that.</p>
<p>To use Gnome Do with xmonad, I changed two things: I made sure that the Gnome Do window is ignored by xmonad, and I bound the popup key to Ctrl-Alt-space instead of the default mod4-space, which I use to switch layouts in xmonad.</p>
<p>Ignoring the window is simply a matter of adding a condition to the manageHook:</p>
<div class="igBar"><span id="lcode-20"><a href="#" onclick="javascript:showPlainTxt('code-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-20">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">main = do din &lt;- spawnPipe statusBarCmd</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; xmonad $ defaultConfig</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; manageHook = composeAll . <span style="">concat</span> $ <span style="color:#006600; font-weight:bold;">&#91;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#91;</span> className =? <span style="color:#CC0000;">"Do"</span> --&gt; <span style="">doIgnore</span> <span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>To assign a new shortcut for the popup, simply press mod4-space to bring it up, and then click on the small arrow in the top right corner. Under Preferences->Keyboard, a new shortcut can be assigned.</p>
]]></content:encoded>
			<wfw:commentRss>http://braindump.dk/tech/2009/12/02/gnome-do-in-xmonad/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Karmic Koala</title>
		<link>http://braindump.dk/tech/2009/10/29/karmic-koala/</link>
		<comments>http://braindump.dk/tech/2009/10/29/karmic-koala/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 19:50:08 +0000</pubDate>
		<dc:creator>recht</dc:creator>
				<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[xmonad]]></category>

		<guid isPermaLink="false">http://braindump.dk/tech/?p=195</guid>
		<description><![CDATA[Ubuntu 9.10 (Karmic Koala) is out, so I decided to upgrade. The upgrade process itself went fine, but it seems there were some other changes to the system, which affected me.
I'm running on a MacBook Pro Santa Rosa with 4 GB mem, which means that if I use the standard 32 bit kernel, I cannot [...]]]></description>
			<content:encoded><![CDATA[<p>Ubuntu 9.10 (Karmic Koala) is out, so I decided to upgrade. The upgrade process itself went fine, but it seems there were some other changes to the system, which affected me.</p>
<p>I'm running on a MacBook Pro Santa Rosa with 4 GB mem, which means that if I use the standard 32 bit kernel, I cannot use all of the memory. That's not really a problem, I just <a href="http://www.ubuntugeek.com/how-to-use-more-than-3gb-ram-on-32-bit-ubuntu.html/comment-page-1#comment-7347">recompile the kernel to support PAE</a>.<br />
However, I also use XMonad (because it's the best window manager available), and previously I launched it from ~/.xsession. However, the new version of GDM doesn't support that anymore, so now you have to drop a file in /usr/share/xsessions/xmonad.desktop - mine contains this:</p>
<div class="igBar"><span id="lcode-22"><a href="#" onclick="javascript:showPlainTxt('code-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-22">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span>Desktop Entry<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Encoding=UTF-<span style="color:#800000;color:#800000;">8</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Name=xmonad</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Comment=xmonad</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Exec=/pack/haskell/bin/runxmonad.<span style="">sh</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Type=Application </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Other than that, simply follow <a href="http://lillesvin.net/archives/255">this little guide</a> to make the keyboard and touchpad work properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://braindump.dk/tech/2009/10/29/karmic-koala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twit me</title>
		<link>http://braindump.dk/tech/2009/10/28/twit-me/</link>
		<comments>http://braindump.dk/tech/2009/10/28/twit-me/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 20:57:34 +0000</pubDate>
		<dc:creator>recht</dc:creator>
				<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://braindump.dk/tech/?p=193</guid>
		<description><![CDATA[I missed the Facebook thing, but it seems that after JAOO, I got sucked somewhat into Twitter. I'm still a little uncertain as to the actual value of it, but it's always nice to have somewhere to let out your incoherent frustrations. One of the first issues that creep up is whether to write on [...]]]></description>
			<content:encoded><![CDATA[<p>I missed the Facebook thing, but it seems that after <a href="http://jaoo.dk">JAOO</a>, I got sucked somewhat into <a href="http://twitter.com/joakimrecht">Twitter</a>. I'm still a little uncertain as to the actual value of it, but it's always nice to have somewhere to let out your incoherent frustrations. One of the first issues that creep up is whether to write on Twitter that I've written a blog post - and should I do it for a post where I write about me using Twitter? I don't know... Anyways, now you all know where to twit me.</p>
]]></content:encoded>
			<wfw:commentRss>http://braindump.dk/tech/2009/10/28/twit-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with JXTA</title>
		<link>http://braindump.dk/tech/2009/10/26/fun-with-jxta/</link>
		<comments>http://braindump.dk/tech/2009/10/26/fun-with-jxta/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 20:46:32 +0000</pubDate>
		<dc:creator>recht</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[jxta]]></category>

		<guid isPermaLink="false">http://braindump.dk/tech/?p=189</guid>
		<description><![CDATA[Recently, I've been messing around with JXTA - one of the things you might have heard about at some point (like JINI, for example), but never really given any thought to. Probably rightly so, because it's only interesting if you do any kind of P2P. And not just human peers.
Anyways, we're planning on using JXTA [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I've been messing around with JXTA - one of the things you might have heard about at some point (like JINI, for example), but never really given any thought to. Probably rightly so, because it's only interesting if you do any kind of P2P. And not just human peers.</p>
<p>Anyways, we're planning on using JXTA to create a distributed version of one of our big monolithic systems. The data model has been modified to support distribution, and we've had a prototype running with hardcoded communication channels. However, JXTA makes everything much more dynamic, and it also introduces the concept of rendezvous and relay nodes so all nodes don't have to be on the same network - they don't even have to connect to each other directly. Pretty sweet stuff. </p>
<p>It turns out, however, that the JXTA documentation really doesn't explain everything, so I have two things I want to share - not that I expect them to be useful to very many people.</p>
<p>The first thing is really just a problem rather than a solution. I develop on a nice Macbook Pro Santa Rosa. I don't particularly like Apple (as in not at all, actually. Developer-wise, they might even be higher on the hate-list than Microsoft), so I've removed OSX entirely and installed Ubuntu instead. Now you might ask why I then use a Macbook at all, but it turns out that they make pretty good hardware, so I go with that. Incidentally, I also have an iMac at home, also running Ubuntu. It turns out that this is a problem in one single regard: When I have the wireless network enabled and start a JXTA application, the kernel will freeze. Every time. And there will be no errors in any log files. Nothing bad happens if I use wired network or a 3G modem - which is my solution until now. Of course, it seems that nobody in the whole world has ever had this problem, so there's not much chance of getting it fixed (and where do you report such a bug?).</p>
<p>The other thing that's been consuming quite a lot of my time is JXTASockets. JXTASockets are basically regular Java sockets running over JXTA. Instead of connecting to a specific host on a specific port, you simply ask JXTA to give you a socket to an abstract host identifier. JXTA will then route the request to the appropriate host, and then you can send and receive data. Except for the connect phase, it works just like a normal socket. Except not entirely. In many cases you would do something like on the server side:</p>
<div class="igBar"><span id="lcode-25"><a href="#" onclick="javascript:showPlainTxt('code-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-25">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JXTAServerSocket server = new JXTAServerSocket<span style="color:#006600; font-weight:bold;">&#40;</span>...<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">while <span style="color:#006600; font-weight:bold;">&#40;</span>true<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; JXTASocket socket = server.<span style="">accept</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; InputStream is = socket.<span style="">getInputStream</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; OutputStream os = socket.<span style="">getOutputStream</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; int b = -<span style="color:#800000;color:#800000;">1</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; while <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>b = is.<span style="">read</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>&gt; -<span style="color:#800000;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// buffer bytes</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; is.<span style="">close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; byte<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> res = handleRequest<span style="color:#006600; font-weight:bold;">&#40;</span>buffer<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; os.<span style="">write</span><span style="color:#006600; font-weight:bold;">&#40;</span>res<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; os.<span style="">close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; socket.<span style="">close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And on the client side something like this:</p>
<div class="igBar"><span id="lcode-26"><a href="#" onclick="javascript:showPlainTxt('code-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-26">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Socket socket = new JXTASocket<span style="color:#006600; font-weight:bold;">&#40;</span>...<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">InputStream is = socket.<span style="">getInputStream</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">OutputStream os = socket.<span style="">getOutputStream</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">os.<span style="">write</span><span style="color:#006600; font-weight:bold;">&#40;</span>generateRequest<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">os.<span style="">close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">readResponse<span style="color:#006600; font-weight:bold;">&#40;</span>is<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">is.<span style="">close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">socket.<span style="">close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Of course, all sorts of error handling, buffering, and other stuff is missing, but the overall procedure should be clear: the client writes to the output stream and closes it. The server reads from the stream until it has been closed. The server then generates a response and writes it back. Add the appropriate resource handling, and this will work using normal sockets, but it will not work with JXTA. And no, it is not obvious why. In fact, I think the plot of "A Serious Man" is more obvious, and if you've seen the movie, you'll probably agree with me that it is, indeed, not obvious at all.<br />
The problem with JXTA turns out to be that both streams must be open all the time. If you, for example, close the output stream on the client side to signal that there is no more data, the server side will simply get a read timeout at some point. This basically means that you cannot use a closed stream to signal the end of the data stream, so instead you have to write the data length to the stream first, and then the data. The receiving side can then read the data length first, and then read the actual data accordingly. Which is not bad, it just sucks when you've spent so many hours debugging that read timeout.</p>
]]></content:encoded>
			<wfw:commentRss>http://braindump.dk/tech/2009/10/26/fun-with-jxta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hudson Plugin for Eclipse 1.0.8</title>
		<link>http://braindump.dk/tech/2009/10/01/hudson-plugin-for-eclipse-1-0-8/</link>
		<comments>http://braindump.dk/tech/2009/10/01/hudson-plugin-for-eclipse-1-0-8/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 21:50:27 +0000</pubDate>
		<dc:creator>recht</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Hudson]]></category>

		<guid isPermaLink="false">http://braindump.dk/tech/?p=186</guid>
		<description><![CDATA[It's been a while, but thanks to a couple of contributions, I finally managed to release the next version of the Hudson plugin for Eclipse, this time version 1.0.8. There are a couple of new features: Non-blocking refreshes, Date and time-information for the builds, support for HTTP Basic Auth, and a couple of bugfixes. Check [...]]]></description>
			<content:encoded><![CDATA[<p>It's been a while, but thanks to a couple of contributions, I finally managed to release the next version of the Hudson plugin for Eclipse, this time version 1.0.8. There are a couple of new features: Non-blocking refreshes, Date and time-information for the builds, support for HTTP Basic Auth, and a couple of bugfixes. Check out the changelog and download at http://code.google.com/p/hudson-eclipse/.</p>
]]></content:encoded>
			<wfw:commentRss>http://braindump.dk/tech/2009/10/01/hudson-plugin-for-eclipse-1-0-8/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Best feature ever in Eclipse 3.5</title>
		<link>http://braindump.dk/tech/2009/09/26/best-feature-ever-in-eclipse-3-5/</link>
		<comments>http://braindump.dk/tech/2009/09/26/best-feature-ever-in-eclipse-3-5/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 08:46:06 +0000</pubDate>
		<dc:creator>recht</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://braindump.dk/tech/?p=184</guid>
		<description><![CDATA[I recently decided to switch from regular Eclipse to the SpringSource Tool Suite, as we do quite a lot of Spring projects, and not having auto-completion in the XML files is kinda stupid. This also meant upgrading from Eclipse 3.4 to 3.5, and this is where I accidentally ran into the best feature addition ever [...]]]></description>
			<content:encoded><![CDATA[<p>I recently decided to switch from regular Eclipse to the <a href="http://www.springsource.com/products/sts">SpringSource Tool Suite</a>, as we do quite a lot of Spring projects, and not having auto-completion in the XML files is kinda stupid. This also meant upgrading from Eclipse 3.4 to 3.5, and this is where I accidentally ran into the best feature addition ever - or more appropriately, the best usability fix ever, although I don't actually know if this is just a feature of the STS. In that case, there's another argument for using it.<br />
The problem in the older versions was that if you had a number of tabs open, you could switch between them using the more or less standardized Ctrl+PageUp/Down, which was nice. However, if one of the tabs contained so-called minitabs, like XML documents or Properties files do, you'd be stuck in these tabs, and Ctrl+PageUp/Down would switch between the minitabs, which was with quite an amount of certainty not what you wanted. This has now changed, so Ctrl+PageUp/Down only changes between the top-level tabs. </p>
<p>The gain in productivity is almost infinite...</p>
]]></content:encoded>
			<wfw:commentRss>http://braindump.dk/tech/2009/09/26/best-feature-ever-in-eclipse-3-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
