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


Java AWSStaticCredentialsProvider类代码示例

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


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

示例1: client

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
private AmazonIdentityManagement client() {
    return AmazonIdentityManagementClientBuilder.standard()
            .withCredentials(new AWSStaticCredentialsProvider(new AWSCredentials() {
                @Override
                public String getAWSAccessKeyId() {
                    return bookmark.getCredentials().getUsername();
                }

                @Override
                public String getAWSSecretKey() {
                    return bookmark.getCredentials().getPassword();
                }
            }))
            .withClientConfiguration(configuration)
            .withRegion(Regions.DEFAULT_REGION).build();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:17,代码来源:AmazonIdentityConfiguration.java

示例2: obtainResource

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
@Override
protected void obtainResource() throws Exception {
	// See https://github.com/mhart/kinesalite#cbor-protocol-issues-with-the-java-sdk
	System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");

	this.resource = AmazonKinesisAsyncClientBuilder.standard()
			.withClientConfiguration(
					new ClientConfiguration()
							.withMaxErrorRetry(0)
							.withConnectionTimeout(1000))
			.withEndpointConfiguration(
					new AwsClientBuilder.EndpointConfiguration("http://localhost:" + this.port,
							Regions.DEFAULT_REGION.getName()))
			.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("", "")))
			.build();

	// Check connection
	this.resource.listStreams();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:20,代码来源:LocalKinesisResource.java

示例3: setupTest

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
/**
 * Do any initialization required by this client. In this case,
 * initialization consists of getting the value of the AWS region
 * and credentials parameters.
 *
 * @param context
 *            the context to run with. This provides access to
 *            initialization parameters.
 */
@Override
public void setupTest(JavaSamplerContext context) {
  apigatewayBaseUrl = context.getParameter("APIGATEWAY_BASE_URL");
  accessKeyId = context.getParameter("ACCESS_KEY_ID");
  secretKey = context.getParameter("SECRET_KEY");
  sessionToken = context.getParameter("SESSION_TOKEN");

  AWSCredentials awsCredentials = new BasicSessionCredentials(accessKeyId, secretKey,
      sessionToken);
  AWSStaticCredentialsProvider awsStaticCredentialsProvider = new AWSStaticCredentialsProvider(
      awsCredentials);

  String region = context.getParameter("REGION");
  client = Squash.builder().iamRegion(region)
      .iamCredentials((AWSCredentialsProvider) awsStaticCredentialsProvider).build();
  samplerName = context.getParameter(TestElement.NAME);
  bookingName = context.getParameter("BOOKING_NAME");
  court = context.getParameter("COURT");
  courtSpan = context.getParameter("COURTSPAN");
  slot = context.getParameter("SLOT");
  slotSpan = context.getParameter("SLOTSPAN");
  date = context.getParameter("DATE");
  putOrDelete = context.getParameter("PUT_OR_DELETE");
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:34,代码来源:SquashBookingApiCustomSampler.java

示例4: getClient

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
/**
 * Returns a client instance for AWS DynamoDB.
 * @return a client that talks to DynamoDB
 */
public static AmazonDynamoDB getClient() {
	if (ddbClient != null) {
		return ddbClient;
	}

	if (Config.IN_PRODUCTION) {
		ddbClient = AmazonDynamoDBClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(
			new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY))).
				withRegion(Config.AWS_REGION).build();
	} else {
		ddbClient = AmazonDynamoDBClientBuilder.standard().
				withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("local", "null"))).
				withEndpointConfiguration(new EndpointConfiguration(LOCAL_ENDPOINT, "")).build();
	}

	if (!existsTable(Config.getRootAppIdentifier())) {
		createTable(Config.getRootAppIdentifier());
	}

	ddb = new DynamoDB(ddbClient);

	Para.addDestroyListener(new DestroyListener() {
		public void onDestroy() {
			shutdownClient();
		}
	});

	return ddbClient;
}
 
开发者ID:Erudika,项目名称:para,代码行数:34,代码来源:AWSDynamoUtils.java

示例5: getS3Client

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
public static AmazonS3 getS3Client(final String region, final String roleArn) {
    final Regions awsRegion = StringUtils.isNullOrEmpty(region) ? Regions.US_EAST_1 : Regions.fromName(region);

    if (StringUtils.isNullOrEmpty(roleArn)) {
        return AmazonS3ClientBuilder.standard().withRegion(awsRegion).build();
    } else {
        final AssumeRoleRequest assumeRole = new AssumeRoleRequest().withRoleArn(roleArn).withRoleSessionName("io-klerch-mp3-converter");

        final AWSSecurityTokenService sts = AWSSecurityTokenServiceClientBuilder.standard().withRegion(awsRegion).build();
        final Credentials credentials = sts.assumeRole(assumeRole).getCredentials();

        final BasicSessionCredentials sessionCredentials = new BasicSessionCredentials(
                credentials.getAccessKeyId(),
                credentials.getSecretAccessKey(),
                credentials.getSessionToken());

        return AmazonS3ClientBuilder.standard().withRegion(awsRegion).withCredentials(new AWSStaticCredentialsProvider(sessionCredentials)).build();
    }
}
 
开发者ID:KayLerch,项目名称:alexa-meets-polly,代码行数:20,代码来源:ConvertService.java

示例6: deploy

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
public void deploy(AwsKeyPair keyPair, String region, final String restApiName, final String stage, Proxy proxy) {
    final AWSCredentialsProvider credentials = new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(keyPair.key, keyPair.secret));

    ClientConfiguration cc = Util.createConfiguration(proxy);

    AmazonApiGateway ag = AmazonApiGatewayClientBuilder.standard().withCredentials(credentials) //
            .withClientConfiguration(cc) //
            .withRegion(region) //
            .build();
    GetRestApisResult apis = ag.getRestApis(new GetRestApisRequest().withLimit(10000));
    Optional<RestApi> api = apis.getItems().stream().filter(item -> item.getName().equals(restApiName)).findFirst();
    RestApi a = api.orElseThrow(() -> new RuntimeException("no rest api found with name='" + restApiName + "'"));
    String restApiId = a.getId();
    log.info("creating deployment of " + restApiId + " to stage " + stage);
    CreateDeploymentResult r = ag
            .createDeployment(new CreateDeploymentRequest().withRestApiId(restApiId).withStageName(stage));
    Map<String, Map<String, MethodSnapshot>> summary = r.getApiSummary();
    log.info("created deployment");
    log.info("summary=" + summary);
}
 
开发者ID:davidmoten,项目名称:aws-maven-plugin,代码行数:22,代码来源:ApiGatewayDeployer.java

示例7: getClient

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
/**
 * Returns a client instance for AWS SQS.
 * @return a client that talks to SQS
 */
public static AmazonSQS getClient() {
	if (sqsClient != null) {
		return sqsClient;
	}
	if (Config.IN_PRODUCTION) {
		sqsClient = AmazonSQSClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(
			new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY))).
				withRegion(Config.AWS_REGION).build();
	} else {
		sqsClient = AmazonSQSClientBuilder.standard().
				withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("x", "x"))).
				withEndpointConfiguration(new EndpointConfiguration(LOCAL_ENDPOINT, "")).build();
	}

	Para.addDestroyListener(new DestroyListener() {
		public void onDestroy() {
			sqsClient.shutdown();
		}
	});
	return sqsClient;
}
 
开发者ID:Erudika,项目名称:para,代码行数:26,代码来源:AWSQueueUtils.java

示例8: amazonEC2Async

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
@Override
public AmazonEC2Async amazonEC2Async() {
    User user = authenticationService.getCurrentUser();

    String accessKey = user.getAwsKey();
    String secretKey = user.getAwsSecret();
    String region = user.getAwsRegion();

    if (secretKey.equals("") || accessKey.equals("") || region.equals("")) {
        return null;
    }

    BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(
            accessKey, secretKey);

    return AmazonEC2AsyncClientBuilder.standard().withRegion(region)
            .withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials))
            .build();
}
 
开发者ID:peavers,项目名称:swordfish-service,代码行数:20,代码来源:EC2UserClientImpl.java

示例9: setUp

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    context = mock(Context.class);
    when(context.getLogger()).thenReturn(System.out::println);

    handler = new AuthLambdaHandler(TEST_AWS_REGION, TEST_JWT_KEY_ARN, TEST_VIDEO_STORAGE_BUCKET,
            TEST_USER_ACCESS_KEY_ID, TEST_USER_SECRET_ACCESS_KEY);

    AWSKMS kmsClient = AWSKMSClientBuilder.standard()
            .withRegion(TEST_AWS_REGION)
            .withCredentials(new AWSStaticCredentialsProvider(
                    new BasicAWSCredentials(TEST_USER_ACCESS_KEY_ID, TEST_USER_SECRET_ACCESS_KEY))
            )
            .build();
    kmsEncrypt = new KMSEncrypt(kmsClient, TEST_JWT_KEY_ARN);
}
 
开发者ID:julianghionoiu,项目名称:tdl-auth,代码行数:17,代码来源:AuthLambdaAcceptanceTest.java

示例10: amazonS3Client

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
/**
 * S3 储存客户端
 *
 * @return 客户端
 */
@Bean
@ConditionalOnProperty(value = "bigbug.storage.s3.enable", havingValue = "true")
AmazonS3Client amazonS3Client() {
    ClientConfiguration clientConfig = new ClientConfiguration();
    clientConfig.setProtocol(Protocol.HTTP);

    BasicAWSCredentials basicAWSCredentials =
            new BasicAWSCredentials(
                    storageProperties.getStorage().getS3().getAccessKey(),
                    storageProperties.getStorage().getS3().getSecretKey());

    return (AmazonS3Client) AmazonS3ClientBuilder.standard()
            .withClientConfiguration(clientConfig)
            .withEndpointConfiguration(
                    new AwsClientBuilder.EndpointConfiguration(
                            storageProperties.getStorage().getS3().getEndpoint(), Regions.DEFAULT_REGION.getName()))
            .withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials))
            .build();
}
 
开发者ID:bigbug-studio,项目名称:generator-jhipster-storage,代码行数:25,代码来源:_StorageConfiguration.java

示例11: S3ConfigurationCache

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
/**
 * Creates a new S3 configuration cache.
 * @param bucket The S3 bucket.
 * @param prefix The S3 object prefix.
 * @param pathPattern The path pattern.
 * @param accessKey The (optional) S3 access key.
 * @param secretKey The (optional) S3 secret key.
 * @param region The AWS region (e.g. us-east-1).
 * @throws IOException Thrown if the configuration cannot be read.
 */
public S3ConfigurationCache(String bucket, String prefix, String pathPattern,
    String accessKey, String secretKey, String region) throws IOException {

  this.bucket = bucket;
  this.prefix = prefix;
  this.pathPattern = pathPattern;

  if (!StringUtils.isEmpty(accessKey)) {

    s3 = AmazonS3Client.builder()
      .withCredentials(new AWSStaticCredentialsProvider(
         new BasicAWSCredentials(accessKey, secretKey)))
        .withRegion(Regions.fromName(region))
        .build();

  } else {

    s3 = AmazonS3Client.builder()
        .withRegion(Regions.fromName(region))
        .build();
  }

}
 
开发者ID:apache,项目名称:nifi-minifi,代码行数:34,代码来源:S3ConfigurationCache.java

示例12: getS3Client

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
public static AmazonS3Client getS3Client(AuthCredentialsServiceState credentials,
        String regionId) {

    ClientConfiguration configuration = new ClientConfiguration();
    configuration.withRetryPolicy(new RetryPolicy(new CustomRetryCondition(),
            DEFAULT_BACKOFF_STRATEGY,
            DEFAULT_MAX_ERROR_RETRY,
            false));

    AWSStaticCredentialsProvider awsStaticCredentialsProvider = new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(credentials.privateKeyId,
                    EncryptionUtils.decrypt(credentials.privateKey)));

    AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder
            .standard()
            .withClientConfiguration(configuration)
            .withCredentials(awsStaticCredentialsProvider)
            .withRegion(regionId);

    if (isAwsClientMock()) {
        throw new IllegalArgumentException("AWS Mock does not support S3 client");
    }

    return (AmazonS3Client) amazonS3ClientBuilder.build();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:26,代码来源:AWSUtils.java

示例13: getEC2SynchronousClient

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
public static AmazonEC2 getEC2SynchronousClient(AuthCredentialsServiceState credentials,
        String region) {
    ClientConfiguration configuration = new ClientConfiguration();
    configuration.withRetryPolicy(new RetryPolicy(new CustomRetryCondition(),
            DEFAULT_BACKOFF_STRATEGY,
            DEFAULT_MAX_ERROR_RETRY,
            true));

    AWSStaticCredentialsProvider awsStaticCredentialsProvider = new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(credentials.privateKeyId,
                    EncryptionUtils.decrypt(credentials.privateKey)));

    AmazonEC2ClientBuilder ec2ClientBuilder = AmazonEC2ClientBuilder.standard()
            .withCredentials(awsStaticCredentialsProvider)
            .withRegion(region)
            .withClientConfiguration(configuration);

    return ec2ClientBuilder.build();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:TestUtils.java

示例14: setup

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
@Before
public void setup() {
  store = new InMemoryStorage();
  metrics = new InMemoryCollectorMetrics();

  collector = new SQSCollector.Builder()
      .queueUrl(sqsRule.queueUrl())
      .parallelism(2)
      .waitTimeSeconds(1) // using short wait time to make test teardown faster
      .endpointConfiguration(new EndpointConfiguration(sqsRule.queueUrl(), "us-east-1"))
      .credentialsProvider(new AWSStaticCredentialsProvider(new BasicAWSCredentials("x", "x")))
      .metrics(metrics)
      .sampler(CollectorSampler.ALWAYS_SAMPLE)
      .storage(store)
      .build()
      .start();
}
 
开发者ID:openzipkin,项目名称:zipkin-aws,代码行数:18,代码来源:SQSCollectorTest.java

示例15: create

import com.amazonaws.auth.AWSStaticCredentialsProvider; //导入依赖的package包/类
/**
 * Creates an {@link S3Connector} instance  with embedded {@link AmazonS3 Amazon Web Services S3 SDK Client} from
 * {@link S3ServiceInfo}.
 * @param serviceInfo S3ServiceInfo provided by {@link org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator}
 *                    implementation included within the application.
 * @param serviceConnectorConfig
 * @return
 */
@Override
public S3Connector create(S3ServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfig) {
    AWSCredentials credentials = new BasicAWSCredentials(serviceInfo.getAccessKey(), serviceInfo.getSecretKey());
    AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
    AwsClientBuilder.EndpointConfiguration endpointConfig = new AwsClientBuilder.EndpointConfiguration(
            serviceInfo.getEndpoint(), Region.getRegion(Regions.DEFAULT_REGION).getName());
    AmazonS3 amazonS3 = AmazonS3ClientBuilder
            .standard()
            .withEndpointConfiguration(endpointConfig)
            .withCredentials(credentialsProvider)
            .enablePathStyleAccess()
            .build();
    if (serviceInfo.getBucket() != null) {
        log.debug("Creating connector addressing ECS bucket: " + serviceInfo.getBucket());
        return new S3Connector(amazonS3, serviceInfo.getEndpoint(), serviceInfo.getBucket());
    } else {
        log.debug("Creating connector addressing ECS namespace.");
        return new S3Connector(amazonS3, serviceInfo.getEndpoint());
    }
}
 
开发者ID:spiegela,项目名称:spring-cloud-ecs-connector,代码行数:29,代码来源:S3ServiceConnectorCreator.java


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