Re: Need help with S3App.java example, from RESTful Web Services (O'Reilly)

2009-07-16 Thread R.H.
Hello Jerome,

Any updates on when Restlet: Official Developer's Guide to RESTful
Web Applications in Java printing will be available. This is all the
information I get from Amazon.co.uk:
 Currently unavailable. We don't know when or if this item will
be back in stock.

Cheers,
woodHack

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2371669


Need help with S3App.java example, from RESTful Web Services (O'Reilly)

2009-07-01 Thread R.H.
I am trying to run the S3App.java (RESTful Web Services publisher O'Reilly) and 
getting a HTTP response code of 403 Forbidden. S3App.java extends 
S3Authorized.java which defines the following keys (constants),
public final static String PUBLIC_KEY = 0F9DBXKB5274JK​​TJ8DG2;​
public final static String PRIVATE_KEY = 
GuUHQ086Wawbwv​​Vl3JPl9JIk4VO​tLcllkv​Ib0b7w​;
which are not allowing me to authenticate properly. I have compiled, S3App, 
S3Authorized, S3Bucket, and S3Object, successfully.
 
Please might someone shed some light on what I am doing wrong?

I tried the following work around. I created an account at AWS. When doing so, 
I was assigned an Access Key ID and a Secret Access Key. I updated the 
code's original PUBLIC_KEY value by replacing it with the value of my 
AWS_Access_Key_ID and PRIVATE_KEY with my AWS_Secret_Access_Key value. The work 
around failed. I figured this was a long shot and would probably fail; because 
I was assuming the AWS_Secret_Access_Key is suppose to be used to create 
signatures for requests made to retrieve S3 content. However, I could have 
misunderstood the intent of an AWS_Secret_Access_Key and how to use it properly.

I have attached all the java code.

Cheers and thanks for reading,
woodHack/*
 * Copyright 2005-2007 Noelios Consulting.
 * 
 * The contents of this file are subject to the terms of the Common Development
 * and Distribution License (the License). You may not use this file except in
 * compliance with the License.
 * 
 * You can obtain a copy of the license at
 * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
 * language governing permissions and limitations under the License.
 * 
 * When distributing Covered Code, include this CDDL HEADER in each file and
 * include the License file at http://www.opensource.org/licenses/cddl1.txt If
 * applicable, add the following below this CDDL HEADER, with the fields
 * enclosed by brackets [] replaced with your own identifying information:
 * Portions Copyright [] [name of copyright owner]
 */

package org.restlet.example.book.rest.ch3;

import java.util.ArrayList;
import java.util.List;

import org.restlet.data.Response;
import org.restlet.resource.DomRepresentation;
import org.w3c.dom.Node;

/**
 * Amazon S3 client application. Returns a list of buckets.
 * 
 * @author Jerome Louvel (cont...@noelios.com)
 */
public class S3App extends S3Authorized {

public static void main(String... args) {
for (S3Bucket bucket : new S3App().getBuckets()) {
System.out.println(bucket.getName() +  :  + bucket.getUri());
}
}

public ListS3Bucket getBuckets() {
ListS3Bucket result = new ArrayListS3Bucket();

// Fetch a resource: an XML document with our list of buckets
Response response = authorizedGet(HOST);
DomRepresentation document = response.getEntityAsDom();

// Use XPath to find the bucket names
for (Node node : document.getNodes(//Bucket/Name)) {
result.add(new S3Bucket(node.getTextContent()));
}

return result;
}
}
/*
 * Copyright 2005-2007 Noelios Consulting.
 * 
 * The contents of this file are subject to the terms of the Common Development
 * and Distribution License (the License). You may not use this file except in
 * compliance with the License.
 * 
 * You can obtain a copy of the license at
 * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
 * language governing permissions and limitations under the License.
 * 
 * When distributing Covered Code, include this CDDL HEADER in each file and
 * include the License file at http://www.opensource.org/licenses/cddl1.txt If
 * applicable, add the following below this CDDL HEADER, with the fields
 * enclosed by brackets [] replaced with your own identifying information:
 * Portions Copyright [] [name of copyright owner]
 */

package org.restlet.example.book.rest.ch3;

import org.restlet.Client;
import org.restlet.data.ChallengeResponse;
import org.restlet.data.ChallengeScheme;
import org.restlet.data.Method;
import org.restlet.data.Protocol;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.resource.Representation;

/**
 * Amazon S3 client. Support class handling authorized requests.
 * 
 * @author Jerome Louvel (cont...@noelios.com)
 */
public class S3Authorized {
public final static String PUBLIC_KEY = 0F9DBXKB5274JKTJ8DG2;

public final static String PRIVATE_KEY = 
GuUHQ086WawbwvVl3JPl9JIk4VOtLcllkvIb0b7w;

public final static String HOST = https://s3.amazonaws.com/;;

private static Response handleAuthorized(Method method, String uri,
Representation entity) {
// Send an authenticated request
Request request = new Request(method, HOST, entity);
request.setChallengeResponse(new ChallengeResponse(
ChallengeScheme.HTTP_AWS, PUBLIC_KEY, PRIVATE_KEY));
return new