<?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>IT Business Tonic</title>
	<atom:link href="http://www.butonic.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.butonic.de</link>
	<description>tools and hacks that glow in the dark</description>
	<lastBuildDate>Mon, 19 Mar 2012 18:56:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Partitioning the SD card for app2ext with adb shell</title>
		<link>http://www.butonic.de/2012/03/14/partitioning-the-sd-card-for-app2ext-with-adb-shell/</link>
		<comments>http://www.butonic.de/2012/03/14/partitioning-the-sd-card-for-app2ext-with-adb-shell/#comments</comments>
		<pubDate>Wed, 14 Mar 2012 22:38:29 +0000</pubDate>
		<dc:creator>Jörn Dreyer</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[adb]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[app2sd]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[partition]]></category>
		<category><![CDATA[sd card]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.butonic.de/?p=409</guid>
		<description><![CDATA[My Motorola Milestone kept nagging me with “Not enough free disk space”. As I am running the latest FroyoMOD, I started investigating the built in app2sd / app2sd+ / app2ext. Unfortunately, I did not have an SD card reader at hand and tried to use an adb shell to set up the needed partitions while the [...]]]></description>
				<content:encoded><![CDATA[<p>My <a title="Motorola Milestone in the english Wikipedia" href="http://en.wikipedia.org/wiki/Motorola_A853#Motorola_Milestone" target="_blank">Motorola Milestone</a> kept nagging me with “Not enough free disk space”. As I am running the latest <a title="FroyoMOD at xda developers" href="http://forum.xda-developers.com/showthread.php?t=815595">FroyoMOD</a>, I started investigating the built in <a title="(german) App2SD - Komplett-Überblick verschiedener Methoden" href="http://www.android-hilfe.de/android-allgemein/144338-app2sd-komplett-uberblick-verschiedener-methoden.html" target="_blank">app2sd / app2sd+ / app2ext</a>. Unfortunately, I did not have an SD card reader at hand and tried to use an adb shell to set up the needed partitions while the card was in the phone. Following <a title="(german) [How-To] Apps2SD auf dem Milestone" href="http://www.android-hilfe.de/anleitungen-fuer-motorola-milestone/17470-how-apps2sd-auf-dem-milestone.html" target="_blank">these steps</a> I soon ran into problems. Nevertheless, it put me on the right track to free some of that <a title="My precious!" href="http://www.youtube.com/watch?v=Gk4Ntcq5uNg" target="_blank">precious</a> space on the internal flash and this is what worked for me:</p>
<ol>
<li>Connect your mobile phone in USB debugging mode and enable “mass storage share”.</li>
<li>Backup your SD card with <a title="rsync in the Wikipedia with examples" href="http://en.wikipedia.org/wiki/Rsync" target="_blank">rsync</a>. <em>I recommend rsync becaus the USB link may not be very stable and copying 16GB of data might need several runs of rsync.</em></li>
<li>No, <strong>seriously</strong>! Backup the complete SD card with hidden folders and everything, or else the apps you already moved to the SD card with app2sd will break in this process and leave you with half dead apps that need to be shot.</li>
<li>After the backup, disable “mass storage share”.</li>
<li><code>adb shell</code> to your device.</li>
<li>Unmount the SD card partitions with <code>umount /mnt/sdcard/.android_secure</code> and <code>umount /mnt/sdcard</code></li>
<li>Use <code>fdisk /dev/block/mmcblk0</code> to repartition the SD card to your liking (recommended: 512MB Linux partition for app2ext, rest of SD card for FAT)
<ol>
<li style="list-style-type: lower-alpha;">Delete the old partition table: <code>d</code> <em>Beware! This is where you wipe the SD card. You did make a backup, right?</em></li>
<li style="list-style-type: lower-alpha;">Create new primary partition: <code>n p 1 enter +15500M</code> Adjust the value to the size of your SD minus ~512MB.</li>
<li style="list-style-type: lower-alpha;">Mark it as FAT: <code>t b</code>  <em>This will be the new partition visible as &#8220;mass storage share&#8221;.</em></li>
<li style="list-style-type: lower-alpha;">Create new primary partition: <code>n p 2 enter enter</code> <em>This will use up the available space of your SD card for the app2ext Linux partition.</em></li>
<li style="list-style-type: lower-alpha;">Print the new partition table: <code>p</code></li>
<li style="list-style-type: lower-alpha;">Check that you now have a <code>WIN95 FAT32</code> partition <code>/dev/block/mmcblk0p1</code> and a <code>Linux</code> partition <code>/dev/block/mmcblk0p2</code> If not, read up on <code>fdisk</code> and go back to step a.</li>
<li style="list-style-type: lower-alpha;">Write the new partition table with <code>w</code>.</li>
</ol>
</li>
<li>Format the FAT partition with <code>newfs_msdos -F 32 /dev/block/mmcblk0p1</code></li>
<li>Format the Linux partition with <code>mkfs.ext2 /dev/block/mmcblk0p2</code></li>
<li>Convert the ext2 partition to ext4 with <code>tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p2</code> (if you want to use ext2 go to step 11)</li>
<li>Force a filesystem check with <code>e2fsck -fDC0 /dev/block/mmcblk0p2</code> Fix any errors with <code>y</code>.</li>
<li>Reboot your phone with <code>reboot</code>, FroyoMOD will now automagically mount the partitions as <code>/mnt/sdcard</code> and <code>/sd-ext</code>, move your remaining apps from the phone flash to the new ext partiton on the SD card and in general do some crazy mount and link magic. <em>Read: you do not need to wait for anything to happen at this point.</em></li>
<li>Enable “mass storage share”. <em>Don&#8217;t worry, this will not interfere with the previous step.</em></li>
<li>Restore your SD card with rsync. <em>This will also restore the apps you moved to the SD with app2sd. Nice to have a backup, right?</em></li>
<li>Disable “mass storage share” to give your phone complete access to the SD card again.</li>
<li>To move the app2sd apps on the “mass storage share” partition to the new app2ext partition go to <code>Menu -&gt; Settings -&gt; Applications Manage Applications -&gt; On SD Card</code> and move the apps back to the “phone”. <em>This might be confusing, but the app2ext partition is transparent to app2sd, so moving an app to the phone actually moves it to the new app2ext partition on the SD card.</em></li>
<li><em>Congratulations, you are done! Enjoy more free space on the phone and slightly better performance (depending on you SD card)!</em></li>
</ol>
<p>Bonus hints gained while investigating:</p>
<ul>
<li>The available milestone kernels are missing the swap module, so don&#8217;t bother setting up a swap partition.</li>
<li>I have not tried creating the 512MB ext partition first and then auto filling up the rest of the SD with FAT, tell me how it goes. It <em>should</em> work.</li>
<li>Unfortunately, there is no <code>mkfs.vfat</code> on a running FroyoMOD <code>busybox</code>. And I could not boot into Recovery Mode to see if it was available there.</li>
<li>My linux fu is still usefull on an android phone and it was interesting to see the way android taylored linux to its needs.</li>
<li>I still don&#8217;t understand the difference between app2sd and app2sd+ &#8230; if such a thing even exists &#8230;</li>
</ul>
<p>Leave a comment below if I could help you with this.</p>
<p>so long</p>
 <p><a href="http://www.butonic.de/?flattrss_redirect&amp;id=409&amp;md5=84a9e3d1f4eba63232fc18c61ca9a60a" title="Flattr" target="_blank"><img src="http://www.butonic.de/wp-content/plugins/flattrss/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.butonic.de/2012/03/14/partitioning-the-sd-card-for-app2ext-with-adb-shell/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=35060&amp;popout=1&amp;url=http%3A%2F%2Fwww.butonic.de%2F2012%2F03%2F14%2Fpartitioning-the-sd-card-for-app2ext-with-adb-shell%2F&amp;language=en_GB&amp;category=text&amp;title=Partitioning+the+SD+card+for+app2ext+with+adb+shell&amp;description=My+Motorola+Milestone+kept+nagging+me+with+%E2%80%9CNot+enough+free+disk+space%E2%80%9D.+As+I+am+running+the+latest%C2%A0FroyoMOD%2C+I+started+investigating+the+built+in+app2sd+%2F+app2sd%2B+%2F+app2ext.+Unfortunately%2C...&amp;tags=adb%2Candroid%2Capp2sd%2Cflash%2Clinux%2Cpartition%2Csd+card%2Cshell%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Ted on a Round-Trip</title>
		<link>http://www.butonic.de/2011/07/21/ted-on-a-round-trip/</link>
		<comments>http://www.butonic.de/2011/07/21/ted-on-a-round-trip/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 17:55:56 +0000</pubDate>
		<dc:creator>Jörn Dreyer</dc:creator>
				<category><![CDATA[Yatta]]></category>
		<category><![CDATA[code generation]]></category>
		<category><![CDATA[mordor]]></category>
		<category><![CDATA[round-trip]]></category>
		<category><![CDATA[uml lab]]></category>
		<category><![CDATA[yatta]]></category>

		<guid isPermaLink="false">http://www.butonic.de/?p=355</guid>
		<description><![CDATA[I recently stumbled upon abstratt&#8217;s blog post on Anti-patterns in code generation and could not resist the call for comments. My response got a little bit longer so I am posting it here. I may be biased, because I work at Yatta Solutions, but to keep Ted from pulling out his hair forever, I would [...]]]></description>
				<content:encoded><![CDATA[<p>I recently stumbled upon abstratt&#8217;s blog post on <a title="abstratt's blog" href="http://abstratt.com/blog/2011/04/05/anti-patterns-in-code-generation-part-1/">Anti-patterns in code generation</a> and could not resist the call for comments. My response got a little bit longer so I am posting it here. I may be biased, because I work at <a title="Yatta Solutions GmbH" href="http://www.yatta.de">Yatta Solutions</a>, but to keep Ted from pulling out his hair forever, I would continue his story something like this:</p>
<h2>Finding the ring in the Land of Mordor</h2>
<p>Loosing himself in the World Wide Web looking for the right search terms, Ted falls asleep and starts dreaming&#8230;</p>
<p>He finds himself in a bare cold land – alone and freezing, only with his Modeling IDE on his laptop. In the far distance he sees his destination: Mount Doom. A shiver runs down his spine. But being a brave developer, Ted starts to find his way through the Land of Mordor. He keeps his distance from all the beasts, struggeling to find his path. His idea: separating model and code! But then, some rather deep pitfalls are becoming evident, more and more single guards (like his team mates) are gathering. The horde is rising! Finally, a good man comes along, a sage. He tells Ted to think of the solution, not the problem. <em>&#8220;Ted, you need help to find your way through Mordor. Find your Sam!&#8221;</em></p>
<p>Suddenly, Ted wonders why his modeling tool is no aid at all. It screws up his changes when generating code and jumbles his model when reverse engineering. <em>&#8220;What if it was never meant to match model and code?&#8221;</em> For a second Ted’s pale grey laptop seems to have a wicked evil grin.</p>
<h2>At the orc camp</h2>
<p>Ted takes a rest to think his mission through. An idea is growing in a corner of his mind. He needs help, he needs another tool! Being a good software engineer, he starts to work out his solution. He starts to build yet-another-case-tool! His idea, now: matching code and model as he, the typical enterprise software developer, wants! Ted thinks about pattern and best practices, about all the things his tool will be able to do. He gets really excited about his tool, his precious tool – his one ring&#8230;</p>
<p>At the beginning, Ted works out a new kick-ass code generator. In fact, there are many pretty good code generators out there as Ted knows, but he wants his own precious <em>&#8220;friend&#8221;</em>. So, Ted works hard until it is done. His ring &#8230; err, tool &#8230; uses templates for code generation. They allow him to stay agile by adapting the code generation to his changing project needs. He develops his own template language – instead of using Xpand/Xtend.</p>
<p>Then, Ted starts working on the reverse engineering: first, he builds a tool to merge all his code changes back into his model. Just having finished (and being a bit jumpy), Ted starts running his tool – and it works! All his code changes were transferred into his model. The model grew and became more detailed. But then, Ted realizes the problem: his model got flooded with implementation details. Getters, setters, toString, iteratorOfStuff &#8230; they all got into his pure model &#8211; his beautiful clear model, it became ugly and senseless.</p>
<p>After thinking of protected regions – and discarding this non-solution –, Ted starts writing a parser. The parser is meant to recognize code patterns and merge them back into his model. After reverse engineering his project again, Ted gets really excited. <em>&#8220;Yes, I did it!&#8221;</em> His model looks as expected, pretty and simple, – and it seems to contain his manual changes, doesn’t it? So, Ted continues developing by modeling some more classes, changing some property names and dragging some new associations. Generating code again, the word <em>&#8220;easy&#8221;</em> crosses his mind. Still dreaming, Ted takes a look at the code:<em> &#8220;FFFFUUUUUUUUUU&#8230; What a nightmare!&#8221;</em> His precious tool screwed up his code again! Somewhere in the guts of the parser there is a mismatch between the details the code generator adds to the code and the details the parser hides from the model.</p>
<p>Suddenly, it hits Teds mind: <em>&#8220;Why not useing the same code generation templates for reverse engineering?&#8221;</em></p>
<h2>Awakening</h2>
<p>Ted awakes with a start and does a quick google search for <em>&#8220;template-based round-trip-engineering&#8221;</em>: &#8230; <em>&#8220;Hmm, a scientific paper&#8230; another one &#8230; come on, I just had that idea, it ain&#8217;t rocket science! Wait, what’s that? <a title="Yatta UML Lab is a modeling IDE based on eclipse" href="http://www.uml-lab.com/">UML Lab</a>?&#8221;</em></p>
<p style="text-align: center;"><em>*clicketiclick*</em></p>
<p>Ted quickly skimms the section on <em><a title="Next Generation Round-Trip-Engineering" href="http://www.uml-lab.com/en/uml-lab/features/roundtrip/">&#8220;Round-Rrip-Engineering NG&#8221;</a></em>. Having a look at the <a title="Screenshots of the net class diagram editor and videos on the round-trip experience" href="http://www.uml-lab.com/en/uml-lab/screenshots/">screenshots and videos</a>, he decides to download UML Lab ( from the <a title="UML Lab in the Eclipse marketplace" href="http://marketplace.eclipse.org/content/uml-lab">eclipse marketplace</a> | as a <a title="Download page for the RCP version of UML Lab" href="http://www.uml-lab.com/download/">RCP</a> ). The tool tour takes him through a simple example, giving him an idea of template-based reverse engineering, modeling, code generation and hacking. He leans back smiling, finally having reached his goal: truly agile modeling and coding.</p>
<p>His nightmare long forgotten, Ted ( coded | modeled ) happily ever after.</p>
 <p><a href="http://www.butonic.de/?flattrss_redirect&amp;id=355&amp;md5=9768644dd8f68342b4ed9a9947c9591c" title="Flattr" target="_blank"><img src="http://www.butonic.de/wp-content/plugins/flattrss/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.butonic.de/2011/07/21/ted-on-a-round-trip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=35060&amp;popout=1&amp;url=http%3A%2F%2Fwww.butonic.de%2F2011%2F07%2F21%2Fted-on-a-round-trip%2F&amp;language=en_GB&amp;category=text&amp;title=Ted+on+a+Round-Trip&amp;description=I+recently+stumbled+upon+abstratt%26%238217%3Bs+blog+post+on+Anti-patterns+in+code+generation+and+could+not+resist+the+call+for+comments.+My+response+got+a+little+bit+longer+so+I+am...&amp;tags=code+generation%2Cmordor%2Cround-trip%2Cuml+lab%2Cyatta%2Cblog" type="text/html" />
	</item>
		<item>
		<title>A simple JAX-RS security context example in GlassFish</title>
		<link>http://www.butonic.de/2010/06/18/a-simple-jax-rs-security-context-example-in-glassfish/</link>
		<comments>http://www.butonic.de/2010/06/18/a-simple-jax-rs-security-context-example-in-glassfish/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 10:48:41 +0000</pubDate>
		<dc:creator>Jörn Dreyer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[nt2od]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://butonic.de/?p=301</guid>
		<description><![CDATA[When creating a REST api with Java EE 6 and JAX-RS there comes the time when you start thinking about security. In our case we were trying to set up HTTP Basic Auth for the REST api to identify users and keep them from deleting other peoples stuff. It took me a while to understand [...]]]></description>
				<content:encoded><![CDATA[<p>When creating a REST api with Java EE 6 and <a title="JSR-000311 JAX-RS: The Java API for RESTful Web Services " href="http://jcp.org/aboutJava/communityprocess/final/jsr311/index.html">JAX-RS</a> there comes the time when you start <a title="Carol McDonald, Secure REST with JAX-RS" href="http://www.slideshare.net/caroljmcdonald/secure-rest-with-jaxrs">thinking about security</a>. In our case we were trying to set up <a title="Wikipedia: Basic access authentication" href="http://en.wikipedia.org/wiki/Basic_access_authentication">HTTP Basic Auth</a> for the REST api to identify users and keep them from deleting other peoples stuff. It took me a while to understand the different aspects of configuring HTTP Basic Auth when using <a title="glassfish: Open Source Application Server" href="https://glassfish.dev.java.net/">GlassFish</a>:</p>
<ol>
<li>Use <code>SecurityContext</code> in your Java code to access the authentication information.</li>
<li>To enable HTTP Basic Auth add a <code>&lt;security-constraint&gt;</code> section to your <code>web.xml</code></li>
<li>Map user roles to GlassFish groups by creating a <code><a title="The sun-web.xml file" href="http://docs.sun.com/app/docs/doc/819-3660/beaql?a=view">sun-web.xml</a></code></li>
<li>Configure a FileRealm / JDBCRealm in GlassFish to store user passwords</li>
</ol>
<p>I will detail the steps with a simple <code>deleteRating()</code> example and xml snippets.<br />
<span id="more-301"></span></p>
<h2>The REST bean</h2>
<p>First, let me show you the current <code>deleteRating()</code> implementation:</p>
<pre>import javax.ws.rs.DELETE;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;

@Path("/api/")
public class RestBean {

    @DELETE
    @Path("ratings/{id}")
    public Response deleteRating( @PathParam("id") int id ) {
        // code here: delete the rating, no matter what
    }

}</pre>
<p>Right, no security whatsoever. We need to change that!</p>
<h2>Security annotations in the Java Code</h2>
<p>To access the authentication information we have to add the <code>@Context</code>:</p>
<pre>import javax.ws.rs.core.Context;
import javax.ws.rs.core.SecurityContext;
//...

@DELETE
@Path("ratings/{id}")
public Response deleteRating( @PathParam("id") int id, @Context SecurityContext context ) {
    String username = context.getUserPrincipal().getName();
    // code here: check if he is the owner of the rating
    // code here: deny the request or
    // code here: delete the rating
}</pre>
<p>Using the <code>SecurityContext</code> we can get the authenticated username and start the authorization. So much for the easy part. On to xml configuration hell!</p>
<h2>Security constrains in the <code>web.xml</code></h2>
<p>The <code>SecurityContext</code> remains useless until we add a <code>&lt;security-constraint&gt;</code> section to the <code>web.xml</code>. <a title="Posts by Eric Warriner " href="http://www.ericonjava.com/?author=1">Eric Warriner</a> has written up a <a title="Jersey JAX-RS, Tomcat, Basic Auth and Security Annotations" href="http://www.ericonjava.com/?p=325">tomcat example</a> which leads to something like this:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
  &lt;display-name&gt;your service name&lt;/display-name&gt;
  &lt;welcome-file-list&gt;
    &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  &lt;servlet&gt;
    &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
    &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
    &lt;init-param&gt;
      &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
      &lt;param-value&gt;de.uks.nt2od.service&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;!-- to use JSR 250 Role Based Authentication and annotations
         like @RolesAllowed uncomment the next init-param section --&gt;
    &lt;!--init-param&gt;
      &lt;param-name&gt;com.sun.jersey.spi.container.ResourceFilters&lt;/param-name&gt;
      &lt;param-value&gt;com.sun.jersey.api.container.filter.RolesAllowedResourceFilterFactory&lt;/param-value&gt;
    &lt;/init-param--&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;

  &lt;!-- which resources should be protected --&gt;
  &lt;security-constraint&gt;
    &lt;web-resource-collection&gt;
      &lt;web-resource-name&gt;Secure&lt;/web-resource-name&gt;
      &lt;!-- be specific about the urls and methods here --&gt;
      &lt;url-pattern&gt;/api/ratings/*&lt;/url-pattern&gt;
      &lt;http-method&gt;DELETE&lt;/http-method&gt;
    &lt;/web-resource-collection&gt;
    &lt;auth-constraint&gt;
      &lt;description&gt;has to be a USER&lt;/description&gt;
      &lt;role-name&gt;USERS&lt;/role-name&gt;
    &lt;/auth-constraint&gt;
  &lt;/security-constraint&gt;

  &lt;!-- which realm to use for basic auth --&gt;
  &lt;login-config&gt;
    &lt;auth-method&gt;BASIC&lt;/auth-method&gt;
    &lt;realm-name&gt;your_realm_name&lt;/realm-name&gt;
  &lt;/login-config&gt;
  &lt;security-role&gt;
    &lt;role-name&gt;USERS&lt;/role-name&gt;
  &lt;/security-role&gt;
&lt;/web-app&gt;</pre>
<p>This would work in <a title="Tomcat Security Overview and Analysis" href="http://www.cafesoft.com/products/cams/tomcat-security.html">tomcat</a> if a USERS role was defined in the <code>tomcat-users.xml</code>. For GlassFish we are not done yet&#8230;</p>
<h2>Role mapping in the <code>sun-web.xml</code></h2>
<p>GlassFish uses principals and groups of a realm that <a title="Thread: Can login, but roles are not assigned " href="http://forums.java.net/jive/thread.jspa?threadID=33414">have</a> <a title="Java EE 5 Tutorial – Working with Realms, Users, Groups, and Roles – Mapping Roles to Users and Groups" href="http://download.oracle.com/docs/cd/E17477_01/javaee/5/tutorial/doc/bnbxj.html#bnbxv">to be mapped</a> to role names for the application.</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE sun-web-app PUBLIC '-//Sun Microsystems, Inc.//DTD
Application Server 9.0 Servlet 2.5//EN'
'http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd'&gt;
&lt;sun-web-app&gt;
  &lt;security-role-mapping&gt;
    &lt;role-name&gt;USERS&lt;/role-name&gt;
    &lt;group-name&gt;USERS&lt;/group-name&gt;
  &lt;/security-role-mapping&gt;
&lt;/sun-web-app&gt;</pre>
<p>We are nearly done. Only one step left!</p>
<h2>Setting up a GlassFish FileRealm</h2>
<p>Open the admin console and navigate to <em>Configuration -&gt; Security -&gt; Realms</em>. Create a new security realm:</p>
<table>
<tbody>
<tr>
<td><strong>Name</strong></td>
<td><code>your_realm_name</code> (use the one from your web.xml)</td>
</tr>
<tr>
<td><strong>Class Name</strong></td>
<td><code>com.sun.enterprise.security.auth.realm.file.FileRealm</code></td>
</tr>
<tr>
<td><strong>JAAS Context</strong></td>
<td><code>fileRealm</code> (yep, a <a title="Thread: Problem in using jdbc realm, i get &quot;No  LoginModules configured for jdbcrealm&quot; " href="http://forums.java.net/jive/thread.jspa?threadID=33734">magic string</a>)</td>
</tr>
<tr>
<td><strong>Key File</strong></td>
<td><code>/path/to/users_and_passwords.xml</code></td>
</tr>
</tbody>
</table>
<p>You can then add users to the realm which can be authenticated with HTTP Basic Auth as defined in the <code>web.xml</code>.</p>
<p>For a dynamic web application you may prefer to <a title="JDBCRealm in GlassFish" href="http://blogs.sun.com/swchan/entry/jdbcrealm_in_glassfish">use the JDBCRealm</a>, which is what we are going to <a title="Marc Hadley, Authentication in Jersey" href="http://weblogs.java.net/blog/2008/03/07/authentication-jersey">set up next</a> for <a title="From Natural Text to Object Diagram" href="http://nt2od.org">nt2od</a>.</p>
 <p><a href="http://www.butonic.de/?flattrss_redirect&amp;id=301&amp;md5=b64862d365540fea30bc01300517d9d9" title="Flattr" target="_blank"><img src="http://www.butonic.de/wp-content/plugins/flattrss/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.butonic.de/2010/06/18/a-simple-jax-rs-security-context-example-in-glassfish/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=35060&amp;popout=1&amp;url=http%3A%2F%2Fwww.butonic.de%2F2010%2F06%2F18%2Fa-simple-jax-rs-security-context-example-in-glassfish%2F&amp;language=en_GB&amp;category=text&amp;title=A+simple+JAX-RS+security+context+example+in+GlassFish&amp;description=When+creating+a+REST+api+with+Java+EE+6+and+JAX-RS+there+comes+the+time+when+you+start+thinking+about+security.+In+our+case+we+were+trying+to+set+up...&amp;tags=api%2Cglassfish%2Cjava%2Cnt2od%2Crest%2Csecurity%2Ctomcat%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Blog migration from s9y to wp finished</title>
		<link>http://www.butonic.de/2010/06/15/blog-migration-from-s9y-to-wp-finished/</link>
		<comments>http://www.butonic.de/2010/06/15/blog-migration-from-s9y-to-wp-finished/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 16:49:47 +0000</pubDate>
		<dc:creator>Jörn Dreyer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[migration]]></category>

		<guid isPermaLink="false">http://butonic.de/?p=297</guid>
		<description><![CDATA[I just finished configuring the redirects for the old s9y urls. Posts, Feeds and Tags should now redirect to the proper wordpress pages. Unfortunately, the script I used to migrate the content left out the tags, so I retagged all the posts. On the bright side I now know which posts still need to be [...]]]></description>
				<content:encoded><![CDATA[<p>I just finished configuring the redirects for the old s9y urls. Posts, Feeds and Tags should now redirect to the proper wordpress pages. Unfortunately, the script I used to migrate the content left out the tags, so I retagged all the posts. On the bright side I now know which posts still need to be fixed because an image did not get uploaded or a link is broken.</p>
<p>I still need to think of a use for categories &#8230; so the site will be in flux a few more days. Lets see how google handles the new url, as <a title="the old serendipity url" href="http://blog.butonic.de">http://blog.butonic.de</a> now points to <a title="the new wordpress url" href="http://butonic.de">http://butonic.de</a>, the new wordpress installation.</p>
 <p><a href="http://www.butonic.de/?flattrss_redirect&amp;id=297&amp;md5=dd91d0c60e8b0c9d6eae1d723d4f0b0a" title="Flattr" target="_blank"><img src="http://www.butonic.de/wp-content/plugins/flattrss/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.butonic.de/2010/06/15/blog-migration-from-s9y-to-wp-finished/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=35060&amp;popout=1&amp;url=http%3A%2F%2Fwww.butonic.de%2F2010%2F06%2F15%2Fblog-migration-from-s9y-to-wp-finished%2F&amp;language=en_GB&amp;category=text&amp;title=Blog+migration+from+s9y+to+wp+finished&amp;description=I+just+finished+configuring+the+redirects+for+the+old+s9y+urls.+Posts%2C+Feeds+and+Tags+should+now+redirect+to+the+proper+wordpress+pages.+Unfortunately%2C+the+script+I+used+to+migrate...&amp;tags=blog%2Cmigration%2Cblog" type="text/html" />
	</item>
		<item>
		<title>updates and breakdowns and upgrades</title>
		<link>http://www.butonic.de/2010/06/11/updates-and-breakdowns-and-upgrades/</link>
		<comments>http://www.butonic.de/2010/06/11/updates-and-breakdowns-and-upgrades/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 22:30:08 +0000</pubDate>
		<dc:creator>Jörn Dreyer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[serendipity]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.butonic.de/?p=134</guid>
		<description><![CDATA[I don&#8217;t exactly remember when the server started to fall apart. I wanted to move from hardy to lucid and ended up juggling the partitions to create a small gap between the MBR and the first partition. You know, thats where the grub bootloader puts some of his code &#8230; at least it warns you [...]]]></description>
				<content:encoded><![CDATA[<p>I don&#8217;t exactly remember when the server started to fall apart. I wanted to <a title="Upgrade from 8.04 LTS to 10.04 LTS" href="https://help.ubuntu.com/community/LucidUpgrades">move</a> from <a title="Ubuntu 8.04 LTS, Hardy Heron" href="https://help.ubuntu.com/8.04/index.html">hardy</a> to <a title="Ubuntu 10.04 LTS, Lucid Lynx" href="https://help.ubuntu.com/10.04/index.html">lucid</a> and ended up juggling the partitions to create a small gap between the MBR and the first partition. You know, thats where the grub bootloader puts some of his code &#8230; at least it warns you about this. That <a title="Star-Hosting e.K." href="http://www.star-hosting.de/">star-hosting</a> uses a completely anarchistic rescue image did not make it any easier.</p>
<p>In the process  I also moved from <a title="Serendipity Weblog System" href="http://www.s9y.org/">serendipity</a> to <a title="WordPress › Blog Tool and Publishing Platform" href="http://wordpress.org/">WordPress</a>. Mainly because an <a title="Android" href="http://www.android.com/">Android</a> <a title="WordPress for Androud" href="http://android.wordpress.org/">app</a> is availiable. I&#8217;ll take this as an opportunity to restart my blogging efforts. So, expect posts more often in the future.</p>
 <p><a href="http://www.butonic.de/?flattrss_redirect&amp;id=134&amp;md5=2a7878bcfade80ec5f54ae1f67e598d7" title="Flattr" target="_blank"><img src="http://www.butonic.de/wp-content/plugins/flattrss/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.butonic.de/2010/06/11/updates-and-breakdowns-and-upgrades/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=35060&amp;popout=1&amp;url=http%3A%2F%2Fwww.butonic.de%2F2010%2F06%2F11%2Fupdates-and-breakdowns-and-upgrades%2F&amp;language=en_GB&amp;category=text&amp;title=updates+and+breakdowns+and+upgrades&amp;description=I+don%26%238217%3Bt+exactly+remember+when+the+server+started+to+fall+apart.+I+wanted+to+move+from+hardy+to+lucid+and+ended+up+juggling+the+partitions+to+create+a+small+gap...&amp;tags=android%2Cserendipity%2Cserver%2Cwordpress%2Cblog" type="text/html" />
	</item>
		<item>
		<title>I can hear it</title>
		<link>http://www.butonic.de/2009/02/25/i-can-hear-it/</link>
		<comments>http://www.butonic.de/2009/02/25/i-can-hear-it/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 18:59:22 +0000</pubDate>
		<dc:creator>Jörn Dreyer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://www.butonic.de/?p=79</guid>
		<description><![CDATA[I&#8217;m 30 and it made me rip out my earphones. Created by Train Horns]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m 30 and it made me rip out my earphones.<br />
<a href="http://trainhorns.net/sound/"><img src="http://trainhorns.net/sound/img/passed.png" alt="Train Horns" /></a></p>
<p>Created by <a href="http://trainhorns.net">Train Horns</a></p>
 <p><a href="http://www.butonic.de/?flattrss_redirect&amp;id=79&amp;md5=5c95f7e9da9da0eb9e5d79a6f3521d92" title="Flattr" target="_blank"><img src="http://www.butonic.de/wp-content/plugins/flattrss/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.butonic.de/2009/02/25/i-can-hear-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=35060&amp;popout=1&amp;url=http%3A%2F%2Fwww.butonic.de%2F2009%2F02%2F25%2Fi-can-hear-it%2F&amp;language=en_GB&amp;category=text&amp;title=I+can+hear+it&amp;description=I%26%238217%3Bm+30+and+it+made+me+rip+out+my+earphones.+Created+by+Train+Horns&amp;tags=fun%2Cblog" type="text/html" />
	</item>
		<item>
		<title>possible nickname explanations</title>
		<link>http://www.butonic.de/2008/07/28/possible-nickname-explanations/</link>
		<comments>http://www.butonic.de/2008/07/28/possible-nickname-explanations/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 10:56:28 +0000</pubDate>
		<dc:creator>Jörn Dreyer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dictionary]]></category>
		<category><![CDATA[hellatine]]></category>
		<category><![CDATA[nick]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.butonic.de/?p=78</guid>
		<description><![CDATA[I tried out the Cuil search engine and typed in my nickname. It did not find my website, but I found this in the Hellatine Dictionary of Bureaucratese: butonic; n., Any political view or ideology reduced to a slogan designed to fit on a pin, button or other small clothing accessory, as either a symbol [...]]]></description>
				<content:encoded><![CDATA[<p>I tried out the <a href="http://www.cuil.com">Cuil</a> search engine and typed in my nickname. It did not find my website, but I found this in the <a href="http://www.home.earthlink.net/~skilton/dictionary.html">Hellatine Dictionary of Bureaucratese</a>:</p>
<p><strong>butonic;</strong><br />
n., Any political view or ideology reduced to a slogan designed to fit on a pin, button or other small clothing accessory, as either a symbol or as text. adj.. Describing a political stand which has been reduced, ad absurdam, to fit the limted intellectual or philosophical capacity of its proponent. Also butonism.<br />
<em>(Fr. boutonier: a decorative element worn in a buttonhole)</em></p>
 <p><a href="http://www.butonic.de/?flattrss_redirect&amp;id=78&amp;md5=a03ced0422123edf94a871c9b187368d" title="Flattr" target="_blank"><img src="http://www.butonic.de/wp-content/plugins/flattrss/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.butonic.de/2008/07/28/possible-nickname-explanations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=35060&amp;popout=1&amp;url=http%3A%2F%2Fwww.butonic.de%2F2008%2F07%2F28%2Fpossible-nickname-explanations%2F&amp;language=en_GB&amp;category=text&amp;title=possible+nickname+explanations&amp;description=I+tried+out+the+Cuil+search+engine+and+typed+in+my+nickname.+It+did+not+find+my+website%2C+but+I+found+this+in+the+Hellatine+Dictionary+of+Bureaucratese%3A+butonic%3B+n.%2C...&amp;tags=dictionary%2Chellatine%2Cnick%2Csearch%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Really Achieving Your Childhood Dreams</title>
		<link>http://www.butonic.de/2008/07/27/really-achieving-your-childhood-dreams/</link>
		<comments>http://www.butonic.de/2008/07/27/really-achieving-your-childhood-dreams/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 16:33:57 +0000</pubDate>
		<dc:creator>Jörn Dreyer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cancer]]></category>
		<category><![CDATA[dreams]]></category>
		<category><![CDATA[lecture]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[tears]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.butonic.de/?p=77</guid>
		<description><![CDATA[I found this in the last WWWW and it gave me more than just tears in the eyes. Enjoy Randy Pausch giving his Last Lecture:]]></description>
				<content:encoded><![CDATA[<p>I found this in the last <a href="http://www.heise.de/newsticker/Was-war-Was-wird--/meldung/113393">WWWW</a> and it gave me more than just tears in the eyes. Enjoy <a href="http://en.wikipedia.org/wiki/Randy_Pausch">Randy Pausch</a> giving his Last Lecture:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="src" value="http://www.youtube.com/v/ji5_MqicxSo&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/ji5_MqicxSo&amp;hl=en&amp;fs=1" allowfullscreen="true"></embed></object></p>
 <p><a href="http://www.butonic.de/?flattrss_redirect&amp;id=77&amp;md5=934b06ea48b0ebab3a772e33ccc76651" title="Flattr" target="_blank"><img src="http://www.butonic.de/wp-content/plugins/flattrss/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.butonic.de/2008/07/27/really-achieving-your-childhood-dreams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=35060&amp;popout=1&amp;url=http%3A%2F%2Fwww.butonic.de%2F2008%2F07%2F27%2Freally-achieving-your-childhood-dreams%2F&amp;language=en_GB&amp;category=text&amp;title=Really+Achieving+Your+Childhood+Dreams&amp;description=I+found+this+in+the+last+WWWW+and+it+gave+me+more+than+just+tears+in+the+eyes.+Enjoy+Randy+Pausch+giving+his+Last+Lecture%3A&amp;tags=cancer%2Cdreams%2Clecture%2Clife%2Ctears%2Cyoutube%2Cblog" type="text/html" />
	</item>
		<item>
		<title>4368781</title>
		<link>http://www.butonic.de/2008/02/01/4368781/</link>
		<comments>http://www.butonic.de/2008/02/01/4368781/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 11:51:17 +0000</pubDate>
		<dc:creator>Jörn Dreyer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[syslog]]></category>
		<category><![CDATA[wtf]]></category>

		<guid isPermaLink="false">http://www.butonic.de/?p=76</guid>
		<description><![CDATA[Feb 1 12:51:32 gromit kernel: Cannot read proc file system: 9 &#8211; Bad file descriptor. Feb 1 12:52:03 gromit last message repeated 4368781 times WTF?!?]]></description>
				<content:encoded><![CDATA[<p>Feb  1 12:51:32 gromit kernel: Cannot read proc file system: 9 &#8211; Bad file descriptor.<br />
Feb  1 12:52:03 gromit last message repeated 4368781 times</p>
<p>WTF?!?</p>
 <p><a href="http://www.butonic.de/?flattrss_redirect&amp;id=76&amp;md5=2e8e46295c02473b586da001aacb7c04" title="Flattr" target="_blank"><img src="http://www.butonic.de/wp-content/plugins/flattrss/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.butonic.de/2008/02/01/4368781/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=35060&amp;popout=1&amp;url=http%3A%2F%2Fwww.butonic.de%2F2008%2F02%2F01%2F4368781%2F&amp;language=en_GB&amp;category=text&amp;title=4368781&amp;description=Feb+1+12%3A51%3A32+gromit+kernel%3A+Cannot+read+proc+file+system%3A+9+%26%238211%3B+Bad+file+descriptor.+Feb+1+12%3A52%3A03+gromit+last+message+repeated+4368781+times+WTF%3F%21%3F&amp;tags=kernel%2Csyslog%2Cwtf%2Cblog" type="text/html" />
	</item>
		<item>
		<title>finally, suspend / resume works!</title>
		<link>http://www.butonic.de/2007/12/30/finally-suspend-resume-works/</link>
		<comments>http://www.butonic.de/2007/12/30/finally-suspend-resume-works/#comments</comments>
		<pubDate>Sun, 30 Dec 2007 15:44:20 +0000</pubDate>
		<dc:creator>Jörn Dreyer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[fglrx]]></category>
		<category><![CDATA[phoronix]]></category>
		<category><![CDATA[radeonhd]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.butonic.de/?p=75</guid>
		<description><![CDATA[Yeah I know, most of you out there think I am crazy to have used my laptop without working suspend to ram or disk. Well in my case the combination of my graphicscard and a widscreen resolution forced me to use the fglrx driver from ati (not even vesa was an option). Fortunately, the newopen [...]]]></description>
				<content:encoded><![CDATA[<p>Yeah I know, most of you out there think I am crazy to have used my laptop without working suspend to ram or disk. Well in my case the combination of my graphicscard and a widscreen resolution forced me to use the fglrx driver from ati (not even vesa was an option). Fortunately, the newopen source radeonhd driver works like a charm <img src='http://www.butonic.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I deactivated the fglrx driver and am now radeonhd only &#8230; yeah that will keep me from gaming &#8230; not a big issue currently anyway &#8230;</p>
<p><a title="Phoronix Forums" href="http://www.phoronix.com/scan.php?page=article&amp;item=843&amp;num=1">Here</a> are the instructions to install from git.</p>
<p>Happy holidays!</p>
 <p><a href="http://www.butonic.de/?flattrss_redirect&amp;id=75&amp;md5=040129b60e0975caa2976ea892d3d293" title="Flattr" target="_blank"><img src="http://www.butonic.de/wp-content/plugins/flattrss/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.butonic.de/2007/12/30/finally-suspend-resume-works/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" title="Flattr this!" href="https://flattr.com/submit/auto?user_id=35060&amp;popout=1&amp;url=http%3A%2F%2Fwww.butonic.de%2F2007%2F12%2F30%2Ffinally-suspend-resume-works%2F&amp;language=en_GB&amp;category=text&amp;title=finally%2C+suspend+%2F+resume+works%21&amp;description=Yeah+I+know%2C+most+of+you+out+there+think+I+am+crazy+to+have+used+my+laptop+without+working+suspend+to+ram+or+disk.+Well+in+my+case+the+combination...&amp;tags=fglrx%2Cphoronix%2Cradeonhd%2Cubuntu%2Cblog" type="text/html" />
	</item>
	</channel>
</rss>
