We got our Netflix WatchNow disk for Wii today in the mail.
Surprisingly enough, it was in the form of an actual disk. I suspect that Netflix would have preferred to make the app available for downloading as WiiWare. But my guess is that Nintendo would have insisted on charging too much for the privilege. So a disk it is. And sure enough, you pop the disk in and select it from the "Disk channel" and fire it up.
The first time it phoned home and presumably noticed that it wasn't activated, so, like all Netflix devices, it put up an activation code and directed you to type that code into the Netflix website. It then immediately displayed the Instant queue, just like on the Roku.
The first surprise was that, though it wasn't obvious, it is possible to see other lists besides the instant queue. In fact, there are multiple lists, some genre based, others of various suggested titles... It was a nice surprise.
The navigation is fairly natural too. All in all, the whole solution is very Roku-like (as opposed to how TiVo works).
Friday, March 26, 2010
Sunday, March 21, 2010
Fancy or ugly Spring wiring? po-TAY-to, po-TAH-to...
One situation we have run across at work is the need to be able to, at configuration, time, choose between two alternate ways to construct an object, depending on the runtime configuration. In a lot of cases, this sort of thing winds up being a datasource configured within the container, meaning that you can use JNDI to your advantage, but this case wasn't really amenable to that.
So once you've split your application context into three pieces (the main piece and each alternative piece), then what?
Spring presently doesn't have any sort of conditionals for application contexts. It does have an <import> statement. You can use property placeholder syntax to conditionalize the import, thusly:
And that works, as long as the whichOne property is a system property. But what if you're using PropertyPlaceholderConfigurer to get placeholder material from a property file? That won't work on <import> tags, because imports take place before bean creation, which is where the configurer gets loaded.
The workaround for that, it turns out, is to rephrase your <import> like this:
That is, create a ClassPathXmlApplicatioContext object out of the correct context file, then call getBean("myChoiceBean") on it, and cache the resulting bean in this context as "myChoiceBean".
So once you've split your application context into three pieces (the main piece and each alternative piece), then what?
Spring presently doesn't have any sort of conditionals for application contexts. It does have an <import> statement. You can use property placeholder syntax to conditionalize the import, thusly:
<import resource="${whichOne}ChoiceContext.xml"/>
And that works, as long as the whichOne property is a system property. But what if you're using PropertyPlaceholderConfigurer to get placeholder material from a property file? That won't work on <import> tags, because imports take place before bean creation, which is where the configurer gets loaded.
The workaround for that, it turns out, is to rephrase your <import> like this:
<bean id="myChoiceBeanFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg type="java.lang.String" value="${whichOne}ChoiceContext.xml"/>
</bean>
<bean factory-bean="myChoiceBeanFactory" factory-method="getBean">
<constructor-arg value="myChoiceBean"/>
</bean>
That is, create a ClassPathXmlApplicatioContext object out of the correct context file, then call getBean("myChoiceBean") on it, and cache the resulting bean in this context as "myChoiceBean".
Labels:
java
Monday, March 8, 2010
Spring JCE / PKCS11
At work we have a need to integrate JCE with network crypto boxes. Turns out, with Spring, it's almost completely trivial.
If you're going to be using either a smart card or a network crypto provider, what you're likely to wind up with is a PKCS11 module for your platform. Sun provides for JCE a PKCS11 JCE Provider shim.
First, there is a very handy Spring idiom for adding providers to JCE at runtime. Here's how you can load BouncyCastle, for example, in a Spring application context as a throw-away bean (from this post at the SpringSource forums):
You can add the PKCS11 provider in almost exactly the same way. The only change is how you declare the actual provider bean within the <list>:
The PKCS11ConfigFactoryBean's job is to spit out an InputStream, which it creates from a mock configuration file that it creates from various properties. You can check the PKCS11 provider's documentation for the complete list of the contents of the config file, but at the very least, it has to contain a line that says "library=path/to/pkcs11/module". After filling a
Once you have the provider, you'll want to obtain a keystore. Your actual working code should be in the form of a bean that has a java.security.KeyStore property. You'll use the KeyStore to obtain the certificates and keys that are stored in the hardware. Spring provides the KeyStoreFactoryBean to fetch, load and initialize the keystore and plug it into your code. Just specify that you want a type "PKCS11" keystore and use the PIN as the password. You can then look up the certs and private keys and use them as normal. Of course, the
If you're going to be using either a smart card or a network crypto provider, what you're likely to wind up with is a PKCS11 module for your platform. Sun provides for JCE a PKCS11 JCE Provider shim.
First, there is a very handy Spring idiom for adding providers to JCE at runtime. Here's how you can load BouncyCastle, for example, in a Spring application context as a throw-away bean (from this post at the SpringSource forums):
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="java.security.Security.addProvider"/>
<property name="arguments">
<list>
<bean class="org.bouncycastle.jce.provider.BouncyCastleProvider"/>
</list>
</property>
</bean>
You can add the PKCS11 provider in almost exactly the same way. The only change is how you declare the actual provider bean within the <list>:
<bean class="sun.security.pkcs11.SunPKCS11">
<constructor-arg>
<bean class="PKCS11ConfigFactoryBean">
<property name="modulePath" value="path/to/pkcs11/module"/>
</bean>
</constructor-arg>
</bean>
The PKCS11ConfigFactoryBean's job is to spit out an InputStream, which it creates from a mock configuration file that it creates from various properties. You can check the PKCS11 provider's documentation for the complete list of the contents of the config file, but at the very least, it has to contain a line that says "library=path/to/pkcs11/module". After filling a
StringBuffer
with the configuration options (don't forget to separate each line with \n), the getObject() method should return new ByteArrayInputStream(string.toBytes())
.Once you have the provider, you'll want to obtain a keystore. Your actual working code should be in the form of a bean that has a java.security.KeyStore property. You'll use the KeyStore to obtain the certificates and keys that are stored in the hardware. Spring provides the KeyStoreFactoryBean to fetch, load and initialize the keystore and plug it into your code. Just specify that you want a type "PKCS11" keystore and use the PIN as the password. You can then look up the certs and private keys and use them as normal. Of course, the
PrivateKey
object you get back won't actually be the key - calling getEncoded()
on it, for example, won't work - it'll just be a sham object that provides a pointer to the actual key when it comes time to use it.
Labels:
java
Monday, March 1, 2010
ATK Rice pudding
ATK has done it again. I modified the recipe a bit. It makes a bigger batch, but is just as tasty.
Rice Pudding
1½ cups medium grain rice
3 cups boiling water
1 tsp salt
1 cup sugar
3 cups cream
4 cups skim milk
or
3½ cups half-and-half
3½ cups whole milk
flavorings of your choice
combine rice, salt and water in a larger pot than you think you need. Bring to a boil, reduce to a simmer and cover for 15 minutes.
Add dairy and sugar, return to a boil and simmer for 30 minutes uncovered, stirring occasionally. After 30 minutes, continue to simmer for 15 more minutes, stirring more frequently to avoid scorching. Continue until the pudding can hold a wooden spoon standing straight up.
For flavorings, I like vanilla and cinnamon. There are a plethora of other options, including rose water, raisins, pistachio, walnuts, almonds.....
Rice Pudding
1½ cups medium grain rice
3 cups boiling water
1 tsp salt
1 cup sugar
3 cups cream
4 cups skim milk
or
3½ cups half-and-half
3½ cups whole milk
flavorings of your choice
combine rice, salt and water in a larger pot than you think you need. Bring to a boil, reduce to a simmer and cover for 15 minutes.
Add dairy and sugar, return to a boil and simmer for 30 minutes uncovered, stirring occasionally. After 30 minutes, continue to simmer for 15 more minutes, stirring more frequently to avoid scorching. Continue until the pudding can hold a wooden spoon standing straight up.
For flavorings, I like vanilla and cinnamon. There are a plethora of other options, including rose water, raisins, pistachio, walnuts, almonds.....
Labels:
food
Subscribe to:
Posts (Atom)