Select your localized edition:

Close ×

More Ways to Connect

Discover one of our 28 local entrepreneurial communities »

Be the first to know as we launch in new countries and markets around the globe.

Interested in bringing MIT Technology Review to your local market?

MIT Technology ReviewMIT Technology Review - logo

 

Unsupported browser: Your browser does not meet modern web standards. See how it scores »

In response to my post The Beginning of the Real Mess in the Clouds I received several emails / twitters / comments saying some variation of “these are easy problems to address” or “the cloud computing providers will quickly fix all this stuff and even my mother will be able to use cloud computing.”

Uh huh.  Here’s another one.  We’ve got hundreds of these already and it has only been 75 days since we started the company.

A heads up to anyone attempting to connect to Slicehost using Java:

There is a subtle bug in the JDK (including 1.6), such that long username/password combinations (like the long username used with the Slicehost API) are encoded improperly in an HttpURLConnection. If you include the username in the URL, you will get a 401 error; if you attempt to use an Authenticator you will get an exception from Java that there is an invalid line. The solution is to override the base64encoder and set the authorization property manually OR potentially use the Apache Http client rather than the built-in JDK client.

Here is the basic code for the solution:

static final String Credential = "my Slicehost API username here"; // the part before the @

class LongLineBase64Encoder extends BASE64Encoder { @Override public int bytesPerLine() { return 1024; } }

URL ServiceURL = new URL("https://api.slicehost.com/slices.xml");

HttpsURLConnection Conn = (HttpsURLConnection) ServiceURL.openConnection(); String EncodedUsername = (new LongLineBase64Encoder()).encode(Credential.getBytes());

Conn.setRequestProperty("Authorization", "Basic " + EncodedUsername); Conn.connect();

What part of mess wasn’t I clear about?  Oh, and my mother is really smart, but I’m betting that “The solution is to override the base64encoder and set the authorization property manually OR potentially use the Apache Http client rather than the built-in JDK client” doesn’t mean much to her.

0 comments about this story. Start the discussion »

Reprints and Permissions | Send feedback to the editor

From the Archives