You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package com.raja.openstack;
import org.javaswift.joss.client.factory.AccountConfig;
import org.javaswift.joss.client.factory.AccountFactory;
import org.javaswift.joss.client.factory.AuthenticationMethod;
import org.javaswift.joss.model.Account;
import org.javaswift.joss.model.Container;
import org.javaswift.joss.model.StoredObject;
import java.io.File;
import java.util.Map;
/**
* Created by raja on 04-05-2017.
*/
public class OpenStackSwiftTest {
public static void main(String[] args) {
//create config
AccountConfig config = new AccountConfig();
config.setAuthUrl("https://blr1.ipstorage.tatacommunications.com/auth/v1.0/");
config.setAuthenticationMethod(AuthenticationMethod.BASIC);
config.setUsername("admin");
config.setPassword("admin");
config.setHashPassword("secret");
//create account from config
Account account = new AccountFactory(config).createAccount();
Map<String, Object> metadata1 = account.getMetadata();
metadata1.forEach((s, o) -> {
System.out.println(s+":"+o);
});
// account.saveMetadata();
//get the container
Container container = account.getContainer("my-container");
//open a stored object handle
StoredObject storedObject = container.getObject("TEST");
//upload something
// storedObject.uploadObject("Hello World!!".getBytes());
String tempGetUrl = storedObject.getTempGetUrl(24*60*60);
System.out.println(tempGetUrl);
}
}
The output from the debug logs of the above program is 2017-08-01 14:29:11 DEBUG TempURL:44 - Text to hash for the signature (CRLF replaced by readable \n): GETn1501664401nhttps://my.full.url/v1/AUTH_admin/my-container/TEST
Here you can see that the full url is used to create the hash. however, The example in the this documentaion, only the relative path of the resource is used to generate the Hash.
The following method under TempURL.java may need changes as per my understanding.
protected String getSignaturePlainText() {
// Note that we're not making use here of the standard getPath() because we don't want the URL encoded names,
// but the pure names. Swift uses the same approach to compose a signature plaintext with container/object names.
String objectPath = this.prefix + "/" + this.object.getContainer().getName() + "/" + this.object.getName();
return this.method + "\n" + this.expiry + "\n" + objectPath;
}
The text was updated successfully, but these errors were encountered:
Hi @raja-anbazhagan, I've run into this issue before and I'm going to work on fixing it. I see some other related issues, such as issue #102 and PR #90 so there might be a solution there if you're desperate for a fix now. Thanks!
Here is how to regenerate the issue
The output from the debug logs of the above program is
2017-08-01 14:29:11 DEBUG TempURL:44 - Text to hash for the signature (CRLF replaced by readable \n): GETn1501664401nhttps://my.full.url/v1/AUTH_admin/my-container/TEST
Here you can see that the full url is used to create the hash. however, The example in the this documentaion, only the relative path of the resource is used to generate the Hash.
The following method under TempURL.java may need changes as per my understanding.
The text was updated successfully, but these errors were encountered: