当前位置: 首页>>代码示例>>Java>>正文


Java AWSSessionCredentials类代码示例

本文整理汇总了Java中org.jets3t.service.security.AWSSessionCredentials的典型用法代码示例。如果您正苦于以下问题:Java AWSSessionCredentials类的具体用法?Java AWSSessionCredentials怎么用?Java AWSSessionCredentials使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AWSSessionCredentials类属于org.jets3t.service.security包,在下文中一共展示了AWSSessionCredentials类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testParse

import org.jets3t.service.security.AWSSessionCredentials; //导入依赖的package包/类
@Test
public void testParse() throws Exception {
    final AWSCredentials c = new AWSSessionCredentialsRetriever(new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DisabledTranscriptListener(),
            "http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access")
            .parse(IOUtils.toInputStream("{\n" +
                    "  \"Code\" : \"Success\",\n" +
                    "  \"LastUpdated\" : \"2012-04-26T16:39:16Z\",\n" +
                    "  \"Type\" : \"AWS-HMAC\",\n" +
                    "  \"AccessKeyId\" : \"AKIAIOSFODNN7EXAMPLE\",\n" +
                    "  \"SecretAccessKey\" : \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n" +
                    "  \"Token\" : \"token\",\n" +
                    "  \"Expiration\" : \"2012-04-27T22:39:16Z\"\n" +
                    "}", Charset.defaultCharset()));
    assertEquals("AKIAIOSFODNN7EXAMPLE", c.getAccessKey());
    assertEquals("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", c.getSecretKey());
    assertEquals("token", ((AWSSessionCredentials) c).getSessionToken());
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:18,代码来源:AWSSessionCredentialsRetrieverTest.java

示例2: AWSSessionCredentialsAdapter

import org.jets3t.service.security.AWSSessionCredentials; //导入依赖的package包/类
public AWSSessionCredentialsAdapter(AWSCredentialsProvider provider) {
    super(null, null, null);
    if(provider.getCredentials() instanceof com.amazonaws.auth.AWSSessionCredentials)
        this.provider = provider;
    else
        throw new IllegalArgumentException("provider does not contain session credentials");
}
 
开发者ID:Netflix,项目名称:suro,代码行数:8,代码来源:AWSSessionCredentialsAdapter.java

示例3: setupConnection

import org.jets3t.service.security.AWSSessionCredentials; //导入依赖的package包/类
/**
 * Creates an {@link HttpUriRequest} object to handle a particular connection method.
 *
 * @param method
 * the HTTP method/connection-type to use, must be one of: PUT, HEAD, GET, DELETE
 * @param bucketName
 * the bucket's name
 * @param objectKey
 * the object's key name, may be null if the operation is on a bucket only.
 * @return
 * the HTTP method object used to perform the request
 *
 * @throws org.jets3t.service.S3ServiceException
 */
@Override
protected HttpUriRequest setupConnection(HTTP_METHOD method, String bucketName, String objectKey,
    Map<String, String> requestParameters) throws S3ServiceException
{
    HttpUriRequest httpMethod;
    try {
        httpMethod = super.setupConnection(method, bucketName, objectKey, requestParameters);
    } catch (ServiceException se) {
        throw new S3ServiceException(se);
    }

    // Set DevPay request headers.
    if (getDevPayUserToken() != null || getDevPayProductToken() != null) {
        // DevPay tokens have been provided, include these with the request.
        if (getDevPayProductToken() != null) {
            String securityToken = getDevPayUserToken() + "," + getDevPayProductToken();
            httpMethod.setHeader(Constants.AMZ_SECURITY_TOKEN, securityToken);
            if (log.isDebugEnabled()) {
                log.debug("Including DevPay user and product tokens in request: "
                    + Constants.AMZ_SECURITY_TOKEN + "=" + securityToken);
            }
        } else {
            httpMethod.setHeader(Constants.AMZ_SECURITY_TOKEN, getDevPayUserToken());
            if (log.isDebugEnabled()) {
                log.debug("Including DevPay user token in request: "
                    + Constants.AMZ_SECURITY_TOKEN + "=" + getDevPayUserToken());
            }
        }
    }

    // Set the session token from Temporary Security (Session) Credentials
    // NOTE: a session token will override any DevPay credential values set above.
    if (this.credentials instanceof AWSSessionCredentials) {
        String sessionToken = ((AWSSessionCredentials)this.credentials).getSessionToken();
        httpMethod.setHeader(Constants.AMZ_SECURITY_TOKEN, sessionToken);
        if (log.isDebugEnabled()) {
            log.debug("Including AWS session token in request: "
                + Constants.AMZ_SECURITY_TOKEN + "=" + sessionToken);
        }
    }

    // Set Requester Pays header to allow access to these buckets.
    if (this.isRequesterPaysEnabled()) {
        String[] requesterPaysHeaderAndValue = Constants.REQUESTER_PAYS_BUCKET_FLAG.split("=");
        httpMethod.setHeader(requesterPaysHeaderAndValue[0], requesterPaysHeaderAndValue[1]);
        if (log.isDebugEnabled()) {
            log.debug("Including Requester Pays header in request: " +
                Constants.REQUESTER_PAYS_BUCKET_FLAG);
        }
    }

    return httpMethod;
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:68,代码来源:RestS3Service.java

示例4: getSessionToken

import org.jets3t.service.security.AWSSessionCredentials; //导入依赖的package包/类
public String getSessionToken() {
    com.amazonaws.auth.AWSSessionCredentials sessionCredentials =
            (com.amazonaws.auth.AWSSessionCredentials) provider.getCredentials();
    return sessionCredentials.getSessionToken();
}
 
开发者ID:Netflix,项目名称:suro,代码行数:6,代码来源:AWSSessionCredentialsAdapter.java


注:本文中的org.jets3t.service.security.AWSSessionCredentials类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。