本文整理汇总了Java中org.jets3t.service.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于org.jets3t.service包,在下文中一共展示了Constants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testGetMetadataFile
import org.jets3t.service.Constants; //导入依赖的package包/类
@Test
public void testGetMetadataFile() throws Exception {
final S3Session session = new S3Session(
new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
new Credentials(
System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
)));
session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.volume));
final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
new S3TouchFeature(session).touch(test, new TransferStatus().withMime("text/plain"));
final Map<String, String> metadata = new S3MetadataFeature(session, new S3AccessControlListFeature(session)).getMetadata(test);
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertFalse(metadata.isEmpty());
assertTrue(metadata.containsKey("Content-Type"));
assertEquals("text/plain", metadata.get("Content-Type"));
assertFalse(metadata.containsKey(Constants.KEY_FOR_USER_METADATA));
assertFalse(metadata.containsKey(Constants.KEY_FOR_SERVICE_METADATA));
assertFalse(metadata.containsKey(Constants.KEY_FOR_COMPLETE_METADATA));
session.close();
}
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:23,代码来源:S3MetadataFeatureTest.java
示例2: toXMLBuilder
import org.jets3t.service.Constants; //导入依赖的package包/类
public XMLBuilder toXMLBuilder() throws ServiceException, ParserConfigurationException,
FactoryConfigurationError, TransformerException
{
if (owner == null) {
throw new ServiceException("Invalid AccessControlList: missing an owner");
}
XMLBuilder builder = XMLBuilder.create("AccessControlPolicy")
.attr("xmlns", Constants.XML_NAMESPACE)
.elem("Owner")
.elem("ID").text(owner.getId()).up()
.elem("DisplayName").text(owner.getDisplayName()).up()
.up();
XMLBuilder accessControlList = builder.elem("AccessControlList");
for (GrantAndPermission gap: grants) {
GranteeInterface grantee = gap.getGrantee();
Permission permission = gap.getPermission();
accessControlList
.elem("Grant")
.importXMLBuilder(grantee.toXMLBuilder())
.elem("Permission").text(permission.toString());
}
return builder;
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:25,代码来源:AccessControlList.java
示例3: AWSRoleSessionCredentials
import org.jets3t.service.Constants; //导入依赖的package包/类
public AWSRoleSessionCredentials(String iamAccessKey, String iamSecretKey, String roleToBeAssumed, String externalId,
String friendlyName, Jets3tProperties jets3tProperties){
if(roleToBeAssumed == null){
throw new IllegalArgumentException("roleToBeAssumed needs to be present.");
}
this.iamAccessKey = iamAccessKey;
this.iamSecretKey = iamSecretKey;
this.roleToBeAssumed = roleToBeAssumed;
this.externalId = externalId;
this.friendlyName = friendlyName;
if(jets3tProperties == null){
this.jets3tProperties = Jets3tProperties.getInstance(Constants.JETS3T_PROPERTIES_FILENAME);
}else {
this.jets3tProperties = jets3tProperties;
}
assumeRoleAndGetCredentials();
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:18,代码来源:AWSRoleSessionCredentials.java
示例4: getUserAgentDescription
import org.jets3t.service.Constants; //导入依赖的package包/类
/**
* Returns a user agent string describing the jets3t library, and optionally the application
* using it, to server-side services.
*
* @param applicationDescription
* a description of the application using the jets3t toolkit, included at the end of the
* user agent string. This value may be null.
* @return
* a string built with the following components (some elements may not be available):
* <tt>JetS3t/</tt><i>{@link Constants#JETS3T_VERSION}</i>
* (<i>os.name</i>/<i>os.version</i>; <i>os.arch</i>; <i>user.region</i>;
* <i>user.region</i>; <i>user.language</i>) <i>applicationDescription</i></tt>
*
*/
public static String getUserAgentDescription(String applicationDescription) {
return
"JetS3t/" + Constants.JETS3T_VERSION + " ("
+ System.getProperty("os.name") + "/"
+ System.getProperty("os.version") + ";"
+ " " + System.getProperty("os.arch")
+ (System.getProperty("user.region") != null
? "; " + System.getProperty("user.region")
: "")
+ (System.getProperty("user.language") != null
? "; " + System.getProperty("user.language")
: "")
+ (System.getProperty("java.version") != null
? "; JVM " + System.getProperty("java.version")
: "")
+ ")"
+ (applicationDescription != null
? " " + applicationDescription
: "");
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:35,代码来源:ServiceUtils.java
示例5: load
import org.jets3t.service.Constants; //导入依赖的package包/类
/**
* Loads the products listed in the {@link java.util.Properties}.
* Specifically, any properties ending in {@link Constants#DEVPAY_PRODUCT_NAME_PROP_SUFFIX}
* (the product's name)
* have that ending removed and replaced with {@link Constants#DEVPAY_PRODUCT_NAME_PROP_SUFFIX}
* (to form name of the property for the product's token).
* If the token exists, then a <code>AWSDevPayProduct</code> is constructed
* with that name and token, and then is added to the Vector. For example,
* (with the current constants) "foo.name" would become "foo.token";
* if both properties exist, then a product is constructed with the values of
* the "foo.name" and "foo.token" properties (e.g. "Foo" and "{ProductToken}AAA...").
*
* @param prodProps the properties
*
* @return the Vector of <code>AWSDevPayProduct</code>s, sorted by name
*/
public static Vector load(Properties prodProps) {
Vector ret = new Vector();
Enumeration propEnum = prodProps.propertyNames();
while (propEnum.hasMoreElements()) {
String propName = (String) propEnum.nextElement();
if (propName.endsWith(Constants.DEVPAY_PRODUCT_NAME_PROP_SUFFIX)) {
String tokenPropName = propName.substring(0,
propName.length()-Constants.DEVPAY_PRODUCT_NAME_PROP_SUFFIX.length()) +
Constants.DEVPAY_PRODUCT_TOKEN_PROP_SUFFIX;
String prodName = prodProps.getProperty(propName);
String prodToken = prodProps.getProperty(tokenPropName);
if (prodToken != null) {
ret.add(new AWSDevPayProduct(prodToken, prodName));
}
}
}
Collections.sort(ret);
return ret;
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:36,代码来源:AWSDevPayProduct.java
示例6: toXMLBuilder
import org.jets3t.service.Constants; //导入依赖的package包/类
public XMLBuilder toXMLBuilder() throws ParserConfigurationException,
FactoryConfigurationError, TransformerException
{
XMLBuilder builder = XMLBuilder.create("BucketLoggingStatus")
.attr("xmlns", Constants.XML_NAMESPACE);
if (isLoggingEnabled()) {
XMLBuilder enabledBuilder = builder.elem("LoggingEnabled")
.elem("TargetBucket").text(getTargetBucketName()).up()
.elem("TargetPrefix").text(getLogfilePrefix()).up();
if (targetGrantsList.size() > 0) {
Iterator<GrantAndPermission> targetGrantsIter = targetGrantsList.iterator();
XMLBuilder grantsBuilder = enabledBuilder.elem("TargetGrants");
while (targetGrantsIter.hasNext()) {
GrantAndPermission gap = targetGrantsIter.next();
grantsBuilder.elem("Grant")
.importXMLBuilder(gap.getGrantee().toXMLBuilder())
.elem("Permission").text(gap.getPermission().toString());
}
}
}
return builder;
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:24,代码来源:S3BucketLoggingStatus.java
示例7: setBucketPolicyImpl
import org.jets3t.service.Constants; //导入依赖的package包/类
@Override
protected void setBucketPolicyImpl(String bucketName, String policyDocument)
throws S3ServiceException
{
Map<String, String> requestParameters = new HashMap<String, String>();
requestParameters.put("policy", "");
Map<String, Object> metadata = new HashMap<String, Object>();
metadata.put("Content-Type", "text/plain");
try {
performRestPut(bucketName, null, metadata, requestParameters,
new StringEntity(policyDocument, "text/plain", Constants.DEFAULT_ENCODING),
true);
} catch (ServiceException se) {
throw new S3ServiceException(se);
} catch (UnsupportedEncodingException e) {
throw new S3ServiceException("Unable to encode LoggingStatus XML document", e);
}
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:21,代码来源:RestS3Service.java
示例8: performRestPutWithXmlBuilder
import org.jets3t.service.Constants; //导入依赖的package包/类
protected HttpResponseAndByteCount performRestPutWithXmlBuilder(String bucketName,
String objectKey, Map<String, Object> metadata, Map<String, String> requestParameters,
XMLBuilder builder) throws ServiceException
{
try {
if (metadata == null) {
metadata = new HashMap<String, Object>();
}
if (!metadata.containsKey("content-type")) {
metadata.put("Content-Type", "text/plain");
}
String xml = builder.asString(null);
return performRestPut(bucketName, objectKey, metadata, requestParameters,
new StringEntity(xml, "text/plain", Constants.DEFAULT_ENCODING), true);
} catch (Exception e) {
if (e instanceof ServiceException) {
throw (ServiceException) e;
} else {
throw new ServiceException("Failed to PUT request containing an XML document", e);
}
}
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:23,代码来源:RestStorageService.java
示例9: performRestPostWithXmlBuilder
import org.jets3t.service.Constants; //导入依赖的package包/类
protected HttpResponse performRestPostWithXmlBuilder(String bucketName,
String objectKey, Map<String, Object> metadata, Map<String, String> requestParameters,
XMLBuilder builder) throws ServiceException
{
try {
if (metadata == null) {
metadata = new HashMap<String, Object>();
}
if (!metadata.containsKey("content-type")) {
metadata.put("Content-Type", "text/plain");
}
String xml = builder.asString(null);
return performRestPost(bucketName, objectKey, metadata, requestParameters,
new StringEntity(xml, "text/plain", Constants.DEFAULT_ENCODING), false);
} catch (Exception e) {
if (e instanceof ServiceException) {
throw (ServiceException) e;
} else {
throw new ServiceException("Failed to POST request containing an XML document", e);
}
}
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:23,代码来源:RestStorageService.java
示例10: putAclImpl
import org.jets3t.service.Constants; //导入依赖的package包/类
protected void putAclImpl(String bucketName, String objectKey, AccessControlList acl,
String versionId) throws ServiceException
{
if (log.isDebugEnabled()) {
log.debug("Setting Access Control List for bucketName=" + bucketName + ", objectKey=" + objectKey);
}
Map<String, String> requestParameters = new HashMap<String, String>();
requestParameters.put("acl","");
if (versionId != null) {
requestParameters.put("versionId", versionId);
}
Map<String, Object> metadata = new HashMap<String, Object>();
metadata.put("Content-Type", "text/plain");
try {
String aclAsXml = acl.toXml();
metadata.put("Content-Length", String.valueOf(aclAsXml.length()));
performRestPut(bucketName, objectKey, metadata, requestParameters,
new StringEntity(aclAsXml, "text/plain", Constants.DEFAULT_ENCODING),
true);
} catch (UnsupportedEncodingException e) {
throw new ServiceException("Unable to encode ACL XML document", e);
}
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:27,代码来源:RestStorageService.java
示例11: putObjectAclWithSignedUrl
import org.jets3t.service.Constants; //导入依赖的package包/类
/**
* Sets an object's ACL details using a pre-signed PUT URL generated for that object.
* This method is an implementation of the interface {@link org.jets3t.service.utils.signedurl.SignedUrlHandler}.
*
* @param signedAclUrl
* a signed URL generated with {@link org.jets3t.service.S3Service#createSignedUrl(String, String, String, String, java.util.Map, org.jets3t.service.security.ProviderCredentials, long, boolean)}.
* @param acl
* the ACL settings to apply to the object represented by the signed URL.
*
* @throws org.jets3t.service.ServiceException
*/
public void putObjectAclWithSignedUrl(String signedAclUrl, AccessControlList acl) throws ServiceException {
HttpPut putMethod = new HttpPut(signedAclUrl);
if (acl != null) {
String restHeaderAclValue = acl.getValueForRESTHeaderACL();
if (restHeaderAclValue != null) {
putMethod.addHeader(this.getRestHeaderPrefix() + "acl", restHeaderAclValue);
} else {
try {
String aclAsXml = acl.toXml();
putMethod.setEntity(new StringEntity(
aclAsXml, "text/xml", Constants.DEFAULT_ENCODING));
} catch (UnsupportedEncodingException e) {
throw new ServiceException("Unable to encode ACL XML document", e);
}
}
}
HttpResponse httpResponse = performRequest(putMethod, new int[] {200});
// Consume response data and release connection.
releaseConnection(httpResponse);
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:36,代码来源:RestStorageService.java
示例12: parseXmlInputStream
import org.jets3t.service.Constants; //导入依赖的package包/类
/**
* Parses an XML document from an input stream using a document handler.
* @param handler
* the handler for the XML document
* @param inputStream
* an input stream containing the XML document to parse
* @throws S3ServiceException
* any parsing, IO or other exceptions are wrapped in an S3ServiceException.
*/
protected void parseXmlInputStream(DefaultHandler handler, InputStream inputStream)
throws CloudFrontServiceException
{
try {
if (log.isDebugEnabled()) {
log.debug("Parsing XML response document with handler: " + handler.getClass());
}
BufferedReader breader = new BufferedReader(new InputStreamReader(inputStream,
Constants.DEFAULT_ENCODING));
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
xr.parse(new InputSource(breader));
} catch (Throwable t) {
try {
inputStream.close();
} catch (IOException e) {
if (log.isErrorEnabled()) {
log.error("Unable to close response InputStream up after XML parse failure", e);
}
}
throw new CloudFrontServiceException("Failed to parse XML document with handler "
+ handler.getClass(), t);
}
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:34,代码来源:CloudFrontXmlResponsesSaxParser.java
示例13: parseXmlInputStream
import org.jets3t.service.Constants; //导入依赖的package包/类
/**
* Parses an XML document from an input stream using a document handler.
* @param handler
* the handler for the XML document
* @param inputStream
* an input stream containing the XML document to parse
* @throws ServiceException
* any parsing, IO or other exceptions are wrapped in an ServiceException.
*/
protected void parseXmlInputStream(DefaultHandler handler, InputStream inputStream)
throws ServiceException
{
try {
if (log.isDebugEnabled()) {
log.debug("Parsing XML response document with handler: " + handler.getClass());
}
BufferedReader breader = new BufferedReader(
new InputStreamReader(inputStream, Constants.DEFAULT_ENCODING));
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
xr.parse(new InputSource(breader));
inputStream.close();
} catch (Throwable t) {
try {
inputStream.close();
} catch (IOException e) {
if (log.isErrorEnabled()) {
log.error("Unable to close response InputStream up after XML parse failure", e);
}
}
throw new ServiceException("Failed to parse XML document with handler "
+ handler.getClass(), t);
}
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:35,代码来源:XmlResponsesSaxParser.java
示例14: getRestS3Service
import org.jets3t.service.Constants; //导入依赖的package包/类
protected RestS3Service getRestS3Service(ProviderCredentials credentials)
throws S3ServiceException
{
if (!this.isTargetS3) {
// Override endpoint property in JetS3t properties
originalTargetEndpoint = cockpitProperties.getStringProperty(
"s3service.s3-endpoint", Constants.S3_DEFAULT_HOSTNAME);
cockpitProperties.setProperty(
"s3service.s3-endpoint", Constants.GS_DEFAULT_HOSTNAME);
} else if (originalTargetEndpoint != null) {
cockpitProperties.setProperty(
"s3service.s3-endpoint", originalTargetEndpoint);
}
return new RestS3Service(credentials, APPLICATION_DESCRIPTION,
this, cockpitProperties);
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:17,代码来源:Cockpit.java
示例15: main
import org.jets3t.service.Constants; //导入依赖的package包/类
/**
* Creates stand-alone dialog box for testing only.
*
* @param args
* @throws Exception
*/
public static void main(String args[]) throws Exception {
JFrame f = new JFrame();
HyperlinkActivatedListener listener = new HyperlinkActivatedListener() {
private static final long serialVersionUID = -225585129296632961L;
public void followHyperlink(URL url, String target) {
BareBonesBrowserLaunch.openURL(url.toString());
}
};
StartupDialog startupDialog = new StartupDialog(f,
Jets3tProperties.getInstance(Constants.JETS3T_PROPERTIES_FILENAME), listener);
startupDialog.setVisible(true);
ProviderCredentials credentials = startupDialog.getProviderCredentials();
startupDialog.dispose();
if (credentials != null) {
System.out.println("Credentials: " + credentials.getLogString());
} else {
System.out.println("Credentials: null");
}
f.dispose();
}
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:32,代码来源:StartupDialog.java
示例16: putAclImpl
import org.jets3t.service.Constants; //导入依赖的package包/类
protected void putAclImpl(String bucketName, String objectKey, AccessControlList acl) throws S3ServiceException
{
if (log.isDebugEnabled()) {
log.debug("Setting Access Control List for bucketName=" + bucketName + ", objectKey=" + objectKey);
}
HashMap requestParameters = new HashMap();
requestParameters.put("acl","");
HashMap metadata = new HashMap();
metadata.put("Content-Type", "text/plain");
try {
String aclAsXml = acl.toXml();
metadata.put("Content-Length", String.valueOf(aclAsXml.length()));
performRestPut(bucketName, objectKey, metadata, requestParameters,
new StringRequestEntity(aclAsXml, "text/plain", Constants.DEFAULT_ENCODING),
true);
} catch (UnsupportedEncodingException e) {
throw new S3ServiceException("Unable to encode ACL XML document", e);
}
}
开发者ID:fajoy,项目名称:jets3t,代码行数:23,代码来源:RestS3Service.java
示例17: setBucketLoggingStatusImpl
import org.jets3t.service.Constants; //导入依赖的package包/类
protected void setBucketLoggingStatusImpl(String bucketName, S3BucketLoggingStatus status)
throws S3ServiceException
{
if (log.isDebugEnabled()) {
log.debug("Setting Logging Status for bucket: " + bucketName);
}
HashMap requestParameters = new HashMap();
requestParameters.put("logging","");
HashMap metadata = new HashMap();
metadata.put("Content-Type", "text/plain");
try {
String statusAsXml = status.toXml();
metadata.put("Content-Length", String.valueOf(statusAsXml.length()));
performRestPut(bucketName, null, metadata, requestParameters,
new StringRequestEntity(statusAsXml, "text/plain", Constants.DEFAULT_ENCODING),
true);
} catch (UnsupportedEncodingException e) {
throw new S3ServiceException("Unable to encode LoggingStatus XML document", e);
}
}
开发者ID:fajoy,项目名称:jets3t,代码行数:24,代码来源:RestS3Service.java
示例18: sign
import org.jets3t.service.Constants; //导入依赖的package包/类
protected String sign(final String secret, final String body) {
try {
// Acquire an HMAC/SHA1 from the raw key bytes.
final SecretKeySpec signingKey = new SecretKeySpec(secret.getBytes(Charset.forName("UTF-8")),
Constants.HMAC_SHA1_ALGORITHM);
// Acquire the MAC instance and initialize with the signing key.
final Mac mac = Mac.getInstance(Constants.HMAC_SHA1_ALGORITHM);
mac.init(signingKey);
return Hex.encodeHexString(mac.doFinal(body.getBytes(Charset.forName("UTF-8"))));
}
catch(NoSuchAlgorithmException | InvalidKeyException e) {
log.error(String.format("Error signing %s %s", body, e.getMessage()));
return null;
}
}
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:16,代码来源:SwiftUrlProvider.java
示例19: LoginLocalFolderPanel
import org.jets3t.service.Constants; //导入依赖的package包/类
public LoginLocalFolderPanel(Frame ownerFrame, HyperlinkActivatedListener hyperlinkListener)
{
super(new GridBagLayout());
this.ownerFrame = ownerFrame;
if (Constants.DEFAULT_PREFERENCES_DIRECTORY.exists()) {
this.cockpitHomeFolder = Constants.DEFAULT_PREFERENCES_DIRECTORY;
} else {
this.cockpitHomeFolder = new File(System.getProperty("user.home"));
}
this.hyperlinkListener = hyperlinkListener;
initGui();
refreshStoredCredentialsTable();
}
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:15,代码来源:LoginLocalFolderPanel.java
示例20: main
import org.jets3t.service.Constants; //导入依赖的package包/类
/**
* Creates stand-alone dialog box for testing only.
*
* @param args
* @throws Exception
*/
public static void main(String args[]) throws Exception {
// String algorithm = Jets3tProperties.getInstance(Constants.JETS3T_PROPERTIES_FILENAME)
// .getStringProperty("crypto.algorithm", "PBEWithMD5AndDES");
// File file = new File("/Users/jmurty/Desktop/test.enc");
// AWSCredentials awsCredentialsTest = new AWSCredentials("a", "b");
// awsCredentialsTest.save("please", file, algorithm);
// System.err.println("Saved: " + awsCredentialsTest);
// System.err.println("Loaded: " + AWSCredentials.load("please", file));
// if (true)
// return;
//
JFrame f = new JFrame();
HyperlinkActivatedListener listener = new HyperlinkActivatedListener() {
private static final long serialVersionUID = -225585129296632961L;
public void followHyperlink(URL url, String target) {
BareBonesBrowserLaunch.openURL(url.toString());
}
};
StartupDialog startupDialog = new StartupDialog(f,
Jets3tProperties.getInstance(Constants.JETS3T_PROPERTIES_FILENAME), listener);
startupDialog.setVisible(true);
AWSCredentials awsCredentials = startupDialog.getAWSCredentials();
startupDialog.dispose();
if (awsCredentials != null) {
System.out.println("AWS Credentials: " + awsCredentials.getLogString());
} else {
System.out.println("AWS Credentials: null");
}
f.dispose();
}
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:42,代码来源:StartupDialog.java
注:本文中的org.jets3t.service.Constants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论