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


Java BasicAWSCredentials类代码示例

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


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

示例1: run

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的package包/类
@Override
public void run(Webhook webhook, String login, String email, String name, String subject, String content) {

    SNSWebhookApp webhookApp = (SNSWebhookApp) webhook.getWebhookApp();
    String topicArn = webhookApp.getTopicArn();
    String awsAccount = webhookApp.getAwsAccount();
    String awsSecret = webhookApp.getAwsSecret();
    String region = webhookApp.getRegion();
    AmazonSNSClient snsClient = new AmazonSNSClient(new BasicAWSCredentials(awsAccount, awsSecret));
    snsClient.setRegion(Region.getRegion(Regions.fromName(region)));

    try {
        PublishRequest publishReq = new PublishRequest()
                .withTopicArn(topicArn)
                .withMessage(getMessage(login, email, name, subject, content));
        snsClient.publish(publishReq);

    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Cannot send notification to SNS service", e);
    } finally {
        LOGGER.log(Level.INFO, "Webhook runner terminated");
    }
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:24,代码来源:SNSWebhookRunner.java

示例2: AwsIot

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的package包/类
public AwsIot(Node root, String region, String accessKeyId, String secretAccessKey, KeyStore keyStore,
        String keyPassword) {
    AWSCredentials awsCredentials = new BasicAWSCredentials(accessKeyId, secretAccessKey);

    this.client = new AWSIotClient(awsCredentials);
    this.client.withRegion(Regions.fromName(region));

    String endpoint = getEndpoint();
    String clientId = UUID.randomUUID().toString();
    if (keyStore != null && keyPassword != null) {
        this.mqttClient = new AWSIotMqttClient(endpoint, clientId, keyStore, keyPassword);
    } else {
        this.mqttClient = new AWSIotMqttClient(endpoint, clientId, accessKeyId, secretAccessKey);
    }

    try {
        this.mqttClient.connect();
    } catch (AWSIotException e) {
        throw new RuntimeException("Failed to connect to AWS IoT service", e);
    }

    this.root = root;
}
 
开发者ID:awslabs,项目名称:aws-iot-fuse,代码行数:24,代码来源:AwsIot.java

示例3: obtainResource

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的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

示例4: buildCredentials

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的package包/类
public static AWSCredentialsProvider buildCredentials(Logger logger, DeprecationLogger deprecationLogger,
                                                      Settings settings, Settings repositorySettings, String clientName) {
    try (SecureString key = getConfigValue(repositorySettings, settings, clientName, S3Repository.ACCESS_KEY_SETTING,
                                           S3Repository.Repository.KEY_SETTING, S3Repository.Repositories.KEY_SETTING);
         SecureString secret = getConfigValue(repositorySettings, settings, clientName, S3Repository.SECRET_KEY_SETTING,
                                              S3Repository.Repository.SECRET_SETTING, S3Repository.Repositories.SECRET_SETTING)) {

        if (key.length() == 0 && secret.length() == 0) {
            logger.debug("Using instance profile credentials");
            return new PrivilegedInstanceProfileCredentialsProvider();
        } else {
            logger.debug("Using basic key/secret credentials");
            return new StaticCredentialsProvider(new BasicAWSCredentials(key.toString(), secret.toString()));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:InternalAwsS3Service.java

示例5: deploy

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的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

示例6: bindings

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的package包/类
@Override
public Seq<Binding<?>> bindings(Environment environment, Configuration configuration) {
    GlobalParams.AWS_ACCESS_KEY = Scala.orNull(configuration.getString("AWS_ACCESS_KEY", scala.Option.empty()));
    GlobalParams.AWS_SECRET_KEY = Scala.orNull(configuration.getString("AWS_SECRET_KEY", scala.Option.empty()));
    GlobalParams.AWS_S3_BUCKET = Scala.orNull(configuration.getString("AWS_S3_BUCKET", scala.Option.empty()));

    String accessKey = GlobalParams.AWS_ACCESS_KEY;
    String secretKey = GlobalParams.AWS_SECRET_KEY;
    s3Bucket = GlobalParams.AWS_S3_BUCKET;

    if ((accessKey != null) && (secretKey != null)) {
        awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
        amazonS3 = new AmazonS3Client(awsCredentials);

        Logger.info("Using S3 Bucket: " + s3Bucket);
    }
    return seq(
            bind(S3Plugin.class).to(S3PluginImpl.class)
    );
}
 
开发者ID:webinerds,项目名称:s3-proxy-chunk-upload,代码行数:21,代码来源:S3Module.java

示例7: init

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的package包/类
/**
 * Inits the.
 */
public void init() {
    if (this.awsAccessKey == null) {
        this.awsAccessKey = System.getenv("AWS_ACCESS_KEY");
        if (this.awsAccessKey == null) {
            this.awsAccessKey = System.getProperty("com.oneops.aws.accesskey");
        }
    }

    if (this.awsSecretKey == null) {
        this.awsSecretKey = System.getenv("AWS_SECRET_KEY");
        if (this.awsSecretKey == null) {
            this.awsSecretKey = System.getProperty("com.oneops.aws.secretkey");
        }
    }

    emailClient = new AmazonSimpleEmailServiceClient(
            new BasicAWSCredentials(awsAccessKey, awsSecretKey));
}
 
开发者ID:oneops,项目名称:oneops,代码行数:22,代码来源:EmailService.java

示例8: amazonEC2Async

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的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: getSessionCredentials

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的package包/类
/**
 * Creates a new session credential that is valid for 12 hours
 *
 * @return an authenticated {@link Credentials} for the new session token
 */
private Credentials getSessionCredentials() {
    // Create a new session with the user credentials for the service instance
    AWSSecurityTokenServiceClient stsClient =
            new AWSSecurityTokenServiceClient(new BasicAWSCredentials(
                    amazonProperties.getAws().getAccessKeyId(),
                    amazonProperties.getAws().getAccessKeySecret()));

    // Start a new session for managing a service instance's bucket
    GetSessionTokenRequest getSessionTokenRequest =
            new GetSessionTokenRequest().withDurationSeconds(43200);

    // Get the session token for the service instance's bucket
    sessionCredentials = stsClient.getSessionToken(getSessionTokenRequest).getCredentials();

    return sessionCredentials;
}
 
开发者ID:kbastani,项目名称:service-block-samples,代码行数:22,代码来源:LambdaCredentialsProvider.java

示例10: testTwoProfileWithSameName

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的package包/类
/**
 * Tests two profiles having same name. The second profile overrides the first profile. Also
 * checks if the AWS Access Key ID and AWS Secret Access Key are mapped properly under the
 * profile.
 */
@Test
public void testTwoProfileWithSameName() throws URISyntaxException {
    ProfilesConfigFile profile = new ProfilesConfigFile(
            ProfileResourceLoader.profilesWithSameProfileName().asFile());

    AWSCredentials defaultCred = profile.getCredentials(DEFAULT_PROFILE_NAME);
    assertNotNull(defaultCred);
    assertTrue(defaultCred instanceof BasicAWSCredentials);

    AWSCredentials testCred = profile.getCredentials(PROFILE_NAME_TEST);
    assertNotNull(testCred);
    assertTrue(testCred instanceof AWSSessionCredentials);
    AWSSessionCredentials testSessionCred = (AWSSessionCredentials) testCred;
    assertEquals(testSessionCred.getAWSAccessKeyId(), "testProfile2");
    assertEquals(testSessionCred.getAWSSecretKey(), "testProfile2");
    assertEquals(testSessionCred.getSessionToken(), "testProfile2");

}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:24,代码来源:CredentialProfilesTest.java

示例11: request_credentials_takes_precendence_over_client_credentials

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的package包/类
@Test
public void request_credentials_takes_precendence_over_client_credentials() {
    final String awsAccessKeyId = "foo";
    final String awsSecretAccessKey = "bar";
    final AWSCredentials reqCredentials = new BasicAWSCredentials(awsAccessKeyId,
                                                                  awsSecretAccessKey);
    EmptyAmazonWebServiceRequest req = new EmptyAmazonWebServiceRequest();
    req.setRequestCredentials(reqCredentials);
    AWSCredentialsProvider actual = CredentialUtils.getCredentialsProvider(req,
                                                                           null);

    Assert.assertThat(actual, Matchers.instanceOf(StaticCredentialsProvider
                                                          .class));
    assertEquals(awsAccessKeyId, actual.getCredentials().getAWSAccessKeyId());
    assertEquals(awsSecretAccessKey, actual.getCredentials().getAWSSecretKey());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:17,代码来源:CredentialUtilsTest.java

示例12: doGet

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的package包/类
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException{
    try{
        String customerID = request.getParameter("customerID");
  BasicAWSCredentials awsCredentials = new BasicAWSCredentials("test", "test");
        AmazonSimpleDBClient sdbc = new AmazonSimpleDBClient(awsCredentials);
        
        String query = "select * from invoices where customerID = '"
            + customerID;
        SelectResult sdbResult = sdbc.select(new SelectRequest(query)); //BAD

        SelectResult sdbResult2 = sdbc.select(new SelectRequest(query, false)); //BAD

        SelectRequest sdbRequest = new SelectRequest();
        SelectResult sdbResult3 = sdbc.select(sdbRequest.withSelectExpression(query)); //BAD
        
        String query2 = "select * from invoices where customerID = 123";
        SelectResult sdbResult4 = sdbc.select(new SelectRequest(query2)); //OK

    }catch(Exception e){
        System.out.println(e);
   }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:23,代码来源:AwsQueryInjection.java

示例13: load

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的package包/类
@Override
public AmazonS3Client load(S3ClientKey clientKey) throws Exception {
  logger.debug("Opening S3 client connection for {}", clientKey);
  ClientConfiguration clientConf = new ClientConfiguration();
  clientConf.setProtocol(clientKey.isSecure ? Protocol.HTTPS : Protocol.HTTP);
  // Proxy settings (if configured)
  clientConf.setProxyHost(clientKey.s3Config.get(Constants.PROXY_HOST));
  if (clientKey.s3Config.get(Constants.PROXY_PORT) != null) {
    clientConf.setProxyPort(Integer.valueOf(clientKey.s3Config.get(Constants.PROXY_PORT)));
  }
  clientConf.setProxyDomain(clientKey.s3Config.get(Constants.PROXY_DOMAIN));
  clientConf.setProxyUsername(clientKey.s3Config.get(Constants.PROXY_USERNAME));
  clientConf.setProxyPassword(clientKey.s3Config.get(Constants.PROXY_PASSWORD));
  clientConf.setProxyWorkstation(clientKey.s3Config.get(Constants.PROXY_WORKSTATION));

  if (clientKey.accessKey == null){
    return new AmazonS3Client(new AnonymousAWSCredentialsProvider(), clientConf);
  } else {
    return new AmazonS3Client(new BasicAWSCredentials(clientKey.accessKey, clientKey.secretKey), clientConf);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:S3FileSystem.java

示例14: setUp

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的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

示例15: amazonS3Client

import com.amazonaws.auth.BasicAWSCredentials; //导入依赖的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


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