Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelchen committed Mar 6, 2012
1 parent 4c321be commit 05ca4a7
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 271 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

23 changes: 16 additions & 7 deletions src/StorageWorkspace/StorageAPI/src/com/scss/core/Handler.java
Expand Up @@ -24,6 +24,7 @@
import org.restlet.resource.Put;
import org.restlet.resource.ServerResource;

import com.scss.Headers;
import com.scss.Operation;
import com.scss.OperationResult;
import com.scss.core.security.Authorization;
Expand Down Expand Up @@ -200,13 +201,21 @@ protected Map<String, String> getRequestHeaders(){
* TODO: convert to class or module
*/
protected Boolean Authorize(APIRequest req) {
// logger.debug("Start fake authorization.");
// ScssUser suser = ScssUserDaoImpl.getInstance().getUserByAccessId("FAKE_ACCESS_ID_00002");
// logger.debug(String.format("Authorized user : %s", suser));
// req.setUser(new User(suser));
// return true;
IAuth auth = Authorization.createInstace(req);
return auth.authorize();
logger.debug("Start fake authorization.");
String id = "FAKE_ACCESS_ID_00002";
String req_auth = req.getHeaders().get(Headers.AUTHORIZATION);
if (null != req_auth) {
String[] authes = req_auth.split("\\s|:");
if (3 == authes.length){
id = authes[1];
}
}
ScssUser suser = ScssUserDaoImpl.getInstance().getUserByAccessId(id);
logger.debug(String.format("Authorized user : %s", suser));
req.setUser(new User(suser));
return true;
// IAuth auth = Authorization.createInstace(req);
// return auth.authorize();
}

/*
Expand Down
Expand Up @@ -100,8 +100,8 @@ private String getResponseText(APIRequest req, List<ScssObject> bucket_objects)
sb.append(" <MaxKeysIsNotImplemented />"); // TODO: Not implemented
sb.append(" <IsTruncated>false</IsTruncated>"); // TODO: Not implemented

sb.append(" <Contents>");
for(ScssObject obj: bucket_objects){
sb.append(" <Contents>");
sb.append(" <Key>").append(obj.getKey()).append("</Key>");
sb.append(" <LastModified>").append(CommonUtilities.formatResponseTextDate(obj.getModifyTime())).append("</LastModified>");
sb.append(" <ETag>").append(obj.getEtag()).append("</ETag>");
Expand All @@ -110,9 +110,10 @@ private String getResponseText(APIRequest req, List<ScssObject> bucket_objects)
sb.append(" <Owner>");
sb.append(" <ID>").append(req.getUser().getAccessId()).append("</ID>");
sb.append(" <DisplayName>").append(req.getUser().getSohuId()).append("</DisplayName>");
sb.append(" </Owner>");
sb.append(" </Owner>");
sb.append(" </Contents>");
}
sb.append(" </Contents>");

sb.append("</ListBucketResult>");
return sb.toString();
}
Expand Down
Expand Up @@ -20,6 +20,8 @@ public static void main(String[] args) {
String sig = signer.sign(str_to_sign);
System.err.println(String.format("http://boto-test.s3.amazonaws.com/obj3?"
+ "AWSAccessKeyId=%s&Expires=%d&Signature=%s", access_id, expires, sig));
System.err.println(String.format("http://boto-test.s3.itc.cn/obj3?"
+ "AWSAccessKeyId=%s&Expires=%d&Signature=%s", access_id, expires, sig));

}

Expand Down
8 changes: 6 additions & 2 deletions src/StorageWorkspace/StorageAPIBotoTest/src/scss/helper.py
Expand Up @@ -8,8 +8,12 @@
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
#boto.s3.connection.S3Connection.DefaultHost = "localhost"

AWS_SECRET_ACCESS_KEY = 'rfUdPSAC2hXhHMGG0wXiHcxeuEpqybEGxn8xPYMy'
AWS_ACCESS_KEY_ID = 'AKIAIXEPRIJSQA4A2KOA'
#AWS_SECRET_ACCESS_KEY = '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'
#AWS_ACCESS_KEY_ID = 'AKIAIXEPRIJSQA4A2KOA'

AWS_SECRET_ACCESS_KEY = 'FACKE_ACCESS_SECRET_KEY_!!!!!!_###_00002'
AWS_ACCESS_KEY_ID = 'FAKE_ACCESS_ID_00002'


def build_connect_s3():
s3 = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, is_secure=False)
Expand Down
@@ -1,4 +1,7 @@
# Fill in your AWS Access Key ID and Secret Access Key
# http://aws.amazon.com/security-credentials
accessKey =AKIAIXEPRIJSQA4A2KOA
secretKey =rfUdPSAC2hXhHMGG0wXiHcxeuEpqybEGxn8xPYMy
#accessKey =AKIAIXEPRIJSQA4A2KOA
#secretKey =rfUdPSAC2hXhHMGG0wXiHcxeuEpqybEGxn8xPYMy

accessKey =FAKE_ACCESS_ID_00002
secretKey =FACKE_ACCESS_SECRET_KEY_!!!!!!_###_00002
@@ -1,4 +1,7 @@
# Fill in your AWS Access Key ID and Secret Access Key
# http://aws.amazon.com/security-credentials
accessKey =AKIAIXEPRIJSQA4A2KOA
secretKey =rfUdPSAC2hXhHMGG0wXiHcxeuEpqybEGxn8xPYMy
#accessKey =AKIAIXEPRIJSQA4A2KOA
#secretKey =rfUdPSAC2hXhHMGG0wXiHcxeuEpqybEGxn8xPYMy

accessKey =FAKE_ACCESS_ID_00002
secretKey =FACKE_ACCESS_SECRET_KEY_!!!!!!_###_00002
Expand Up @@ -85,10 +85,14 @@ public static void main(String[] args) throws IOException {
* keep your data closer to your applications or users.
*/
System.out.println("Creating bucket " + bucketName + "\n");
try {
Bucket b = s3.createBucket(bucketName);
if (b != null) {
System.out.printf("bucket <%s> created or existed\n", b.getName());
}
} catch (Exception e) {
e.printStackTrace();
}

/*
* List the buckets in your account
Expand Down

0 comments on commit 05ca4a7

Please sign in to comment.