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

2009-07-21 Thread Jerome Louvel
Hi WoodHack,

This book project with Apress is now longer and should have been removed from 
Amazon for a while...

Currently, we are actively working on a Restlet in Action book project for 
Manning. We will post updates in our blog (http://blog.noelios.com) and in this 
list when available!

Stay tuned,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-Message d'origine-
De : R.H. [mailto:lnrha...@gmail.com] 
Envoyé : jeudi 16 juillet 2009 07:03
À : discuss@restlet.tigris.org
Objet : Re: Need help with S3App.java example, from RESTful Web Services 
(O'Reilly)

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

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


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


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

2009-07-09 Thread webpost
Jerome Louvel,

Thank you very much for the help! As suggested, I signed up for the S3 account. 
After executing code again, this time I received a response code of 200 (OK). 
I was initially hesitant to sign-up for S3 account; because, it required credit 
card info. Was not going to do so until I was able to confirm it was absolutely 
necessary.

Cheers  thanks again,
woodHack

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


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

2009-07-07 Thread Jerome Louvel
Hi woodHack,

I've just did a test and it worked for me. I created an AWS account *and* 
signed up for the S3 service (you need this step).

I was able to retrieve the list of buckets (empty initially) fine. See also the 
slightly updated classes attached.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-Message d'origine-
De : R.H. [mailto:lnrha...@gmail.com] 
Envoyé : mercredi 1 juillet 2009 03:19
À : discuss@restlet.tigris.org
Objet : Need help with S3App.java example, from RESTful Web Services (O'Reilly)

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

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

S3App.java
Description: Binary data


S3Authorized.java
Description: Binary data


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