shorne in japan

blog archive about resume

Ikebukuro

22 Feb 2009

Yesterday, Sachi and I were going to a concert for the Yomiuri Orchestra in Ikebukuro, a town on the west side of Tokyo. We received free tickets from Sachi's father, who works for Yomiuri. The nice thing about watching the symphony is that the music is really relaxing and sometimes we get to fall asleep. I guess its ok because most of the people there also sleep. Maybe its a Japanese tradition.

After the concert we left Ikebukuro for shinjuku to do some shopping. First we went to I-Setan. There we bought some really nice bread; German style muesli rolls, pretzel rolls and some anpan.

We also saw some of that really expensive fruit you always hear about. Now, I have seen melons priced at $80 before but this time I saw strawberries.

Japanese strawberries for the sick

The price says 12600Yen, which is about 135USD today. You could also buy one for about $20 if you don't want to splurge.

Anyway, after that we took our bread and went looking for an Indian restaurant because we felt like eating curry. We walked and walked in the north direction and didn't find anything until we got up to Shinokubo; the Tokyo Korea town. By that time we decided we were pretty much hungry for anything and decided to have some Korean BBQ.

The food turned out to be pretty good until I decided to order some Maccori. The lady asked me if I wanted sweet or dry, I chose dry. Next think I know she brings out a one liter bottle and starts to open it. Within about 30 minutes I am done with the bottle and speaking Chinese and having a good time with the owner of the restaurant who is from Taiwan. I give them my business card to staple onto the roof, pay the bill and leave.

By the time I got home I realized we left the bread in the Korean restaurant. I hope they ate it for us.


Using Acegi with Hibernate

13 Feb 2009

A while back I started working on a web application with, at the time, all new java technologies. Once the web application needed an authentication framework I turned to acegi (now part of Spring Security API). Acegi security provides much of the authentication features a developer requires in a web application including: remember me, failed login handling, public content access and so on. Other technologies I used where Struts2, Spring and Hibernate.

Since I was using hibernate and spring daos I thought it best that I store my user names and passwords in the database via the same mechanism. That is, I needed to use Acegi for authentication and Hibernate and Spring for managing the user detail persistence layer. After searching a few forums it turned out that many people wanted to do the same, but no one was providing a solution. Proceeding with a brief brainstorm session and research into the acegi API I came up with my own UserDetailsService implementation backed by hibernate and spring. Its simple but it provides me with what I need and I hope it will be a helpful reference for others as well.

Source Code

The code used for the implementation is packaged as auth.jar with class and source files for your reference. Please do with it as you like (BSD license). The contents of the archive are described below:

net.shornepla.auth

Together these small classes provide the groundwork for our authentication layer. Next, the hard part is dealing with all of the Acegi spring configuration.

ApplicationContext.xml

Acegi is loaded via two spring application context xml files. This first one is pretty basic, first it initialises my hibernate authentication implementation. Next it initialises the authentication provider.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="autodetect">
  <!-- Load the hibernate model for authentication -->
  <bean id="sessionFactory" 
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
    <property name="mappingResources">
      <list>
	<value>net/shornepla/auth/model.hbm.xml</value>
      </list>
    </property>
  </bean>
  <!-- The hibernate backed implementation for UserDetailService -->
  <bean  id="userDetailProvider"
    class="net.shornepla.auth.UserDetailProvider" >
    <property name="sessionFactory" ref="sessionFactory" />
  </bean>
  <!-- Just use MD5 password hashing -->
  <bean id="passwordEncoder"
    class="org.acegisecurity.providers.encoding.Md5PasswordEncoder" />
  <!-- Tie together with the DaoAuthenticationProvider -->
  <bean id="daoAuthenticationProvider"
    class="org.acegisecurity.providers.dao.DaoAuthenticationProvider" >
    <property name="userDetailsService">
       <ref local="userDetailProvider"/>
    </property>
    <property name="passwordEncoder">
      <ref local="passwordEncoder"/>
    </property>
  </bean>
</beans>

applicationContext-acegi-security.xml

The second application context config is applicationContext-acegi-security.xml. This is mostly copied directly out of the acegi example and simplified as much as possible.

The main beans here are:

  • authenticationManager - uses the above defined daoAuthenticationProvider
  • filterInvocationInterceptor - specifies which roles have access to what
  • authenticationProcessingFilter - specifies which pages are used for authentication

All together, these resources will probably not work for you as they require a web application to be deployed. However, the pieces I provide should make integration into your application as simple as possible. If there are any issues or suggestions please let me know.


Decome

29 Dec 2008

It looks like google gmail now supports Japanese decome (デコメ) or decorated mails. These are small charset extensions added by Japanese mobile companies to allow cell phone users to exchange emotional icons in their email.

Example with a peace sign

decmo

Decome is specific to japan so most computers will not support this natively. To implement this It seems google have a public image repository which is referenced to display the pictures. This should prove useful for 3rd party mash-up applications as well.

Code example

<br>
今帰るので、Checkしてみます
<img src="https://mail.google.com/mail/e/docomo_ne_jp/B94"
     goomoji="docomo_ne_jp.B94"
     style="margin: 0pt 0.2ex; vertical-align: middle;">
<br>

Pretty nice stuff.


Google Android - take 1

01 Oct 2008

Just recently, in America, google and t-mobile released the G1.  This new phone takes advantage of googles new android mobile OS.

I have been waiting to see if this phone is worth the wait, if not I will buy the iPhone.  So far things look bad. There is no sign of a Japan release and the first edition from the US does not look so promising. One review sums up G1 pretty well with 10 shortcomings. From my perspective only 5 of these issues are valid, lets see why:

 Doesn't bother me

  • No exchange - I dont use exchange for personal mail, neither should most people
  • Desktop synching - This phone is meant to privide access to web services, the desktop is obsolete
  • Skimpy Storage - For me, 1GB is enough
  • No video recording - Who really uses video recording? Its a novelty item
  • Accelerometer quirk - I Can write my own software if I need to fix this

Sucks

  • Wanted: 3.5mm headphone jack
  • Stingy data cap
  • Battery life
  • Uninspiring interface
  • Multitouch MIA

For now I will be planning on getting an iPhone for me and my girlfriend and wait for the Japan release before considering android again.


Medal Count

28 Aug 2008

As everyone knows, the Beijing olympics is over and the medal counts are in. Who is on top? If you look at news agecies from China, Australia or Great Britain they will tell you the Chinese, who have the most gold medals. But if you look at the US Olympic coverage they will tell you USA is in first with the most Total medals. Now why can't the United States of America just do things like other countries?

This chart shows China at the top with 51 gold medals
Australia Medal Count

This chart shows the US at the top with
NBC Medal Count

Now, these olympics were great. I just about cried during the opening and closing ceremonies as well as when the Japanese won the Softball gold. What else can I say?