本文整理汇总了Java中com.amazonaws.Protocol类的典型用法代码示例。如果您正苦于以下问题:Java Protocol类的具体用法?Java Protocol怎么用?Java Protocol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Protocol类属于com.amazonaws包,在下文中一共展示了Protocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: launchAWSConfigurationTest
import com.amazonaws.Protocol; //导入依赖的package包/类
protected void launchAWSConfigurationTest(Settings settings,
Protocol expectedProtocol,
String expectedProxyHost,
int expectedProxyPort,
String expectedProxyUsername,
String expectedProxyPassword,
String expectedSigner,
int expectedReadTimeout) {
ClientConfiguration configuration = AwsEc2ServiceImpl.buildConfiguration(logger, settings);
assertThat(configuration.getResponseMetadataCacheSize(), is(0));
assertThat(configuration.getProtocol(), is(expectedProtocol));
assertThat(configuration.getProxyHost(), is(expectedProxyHost));
assertThat(configuration.getProxyPort(), is(expectedProxyPort));
assertThat(configuration.getProxyUsername(), is(expectedProxyUsername));
assertThat(configuration.getProxyPassword(), is(expectedProxyPassword));
assertThat(configuration.getSignerOverride(), is(expectedSigner));
assertThat(configuration.getSocketTimeout(), is(expectedReadTimeout));
}
示例2: testAWSConfigurationWithAwsSettingsBackcompat
import com.amazonaws.Protocol; //导入依赖的package包/类
public void testAWSConfigurationWithAwsSettingsBackcompat() {
Settings settings = Settings.builder()
.put(AwsS3Service.PROTOCOL_SETTING.getKey(), "http")
.put(AwsS3Service.PROXY_HOST_SETTING.getKey(), "aws_proxy_host")
.put(AwsS3Service.PROXY_PORT_SETTING.getKey(), 8080)
.put(AwsS3Service.PROXY_USERNAME_SETTING.getKey(), "aws_proxy_username")
.put(AwsS3Service.PROXY_PASSWORD_SETTING.getKey(), "aws_proxy_password")
.put(AwsS3Service.SIGNER_SETTING.getKey(), "AWS3SignerType")
.put(AwsS3Service.READ_TIMEOUT.getKey(), "10s")
.build();
launchAWSConfigurationTest(settings, Settings.EMPTY, Protocol.HTTP, "aws_proxy_host", 8080, "aws_proxy_username",
"aws_proxy_password", "AWS3SignerType", 3, false, 10000);
assertSettingDeprecationsAndWarnings(new Setting<?>[]{
AwsS3Service.PROXY_USERNAME_SETTING,
AwsS3Service.PROXY_PASSWORD_SETTING,
AwsS3Service.PROTOCOL_SETTING,
AwsS3Service.PROXY_HOST_SETTING,
AwsS3Service.PROXY_PORT_SETTING,
AwsS3Service.SIGNER_SETTING,
AwsS3Service.READ_TIMEOUT});
}
示例3: awsClientConfig
import com.amazonaws.Protocol; //导入依赖的package包/类
@Bean
public ClientConfiguration awsClientConfig(final ProxyDetails proxyDetails) {
ClientConfiguration clientConfig = new ClientConfiguration();
if (useProxy) {
clientConfig.setProxyHost(clientProxyHost);
clientConfig.setProxyPort(clientProxyPort);
} else if(proxyDetails != null) {
clientConfig.setProxyHost(proxyDetails.getHost());
clientConfig.setProxyPort(proxyDetails.getPort());
}
clientConfig.setProtocol(Protocol.valueOf(clientProtocol.toUpperCase()));
clientConfig.setConnectionTimeout(clientConnectionTimeout);
clientConfig.setMaxErrorRetry(clientMaxErrorRetry);
return clientConfig;
}
示例4: transformAndVerifyOrThrow
import com.amazonaws.Protocol; //导入依赖的package包/类
public static com.amazonaws.ClientConfiguration transformAndVerifyOrThrow(ClientConfiguration clientConfiguration) {
com.amazonaws.ClientConfiguration awsClientConfig = new com.amazonaws.ClientConfigurationFactory().getConfig();
if (awsClientConfig.getProtocol() != Protocol.HTTPS) {
throw new SecurityConfigurationException("Must use HTTPS protocol");
}
clientConfiguration.proxy.ifPresent(p -> {
awsClientConfig.setProxyHost(p.proxyHost);
awsClientConfig.setProxyPort(p.proxyPort);
if (!p.nonProxyHosts.isEmpty()) {
awsClientConfig.setNonProxyHosts(String.join("|", p.nonProxyHosts));
}
p.proxyUsername.ifPresent(awsClientConfig::setProxyUsername);
p.proxyPassword.ifPresent(awsClientConfig::setProxyPassword);
});
return verifyOrThrow(awsClientConfig);
}
示例5: toUri
import com.amazonaws.Protocol; //导入依赖的package包/类
/**
* Returns an URI for the given endpoint.
* Prefixes the protocol if the endpoint given does not have it.
*
* @throws IllegalArgumentException if the inputs are null.
*/
public static URI toUri(String endpoint, Protocol protocol) {
if (endpoint == null) {
throw new IllegalArgumentException("endpoint cannot be null");
}
/*
* If the endpoint doesn't explicitly specify a protocol to use, then
* we'll defer to the default protocol specified in the client
* configuration.
*/
if (!endpoint.contains("://")) {
endpoint = protocol.toString() + "://" + endpoint;
}
try {
return new URI(endpoint);
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
}
示例6: load
import com.amazonaws.Protocol; //导入依赖的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);
}
}
示例7: amazonS3Client
import com.amazonaws.Protocol; //导入依赖的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();
}
示例8: connectToS3
import com.amazonaws.Protocol; //导入依赖的package包/类
private void connectToS3(String accessKey, String secretKey, String endpoint, boolean secure, boolean pathStyle) {
LOG.info("'{}','{}','{}'", accessKey, secretKey, endpoint);
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
ClientConfiguration clientConfiguration = new ClientConfiguration()
.withProtocol(secure ? Protocol.HTTPS : Protocol.HTTP)
.withUserAgentPrefix("s3browser")
.withSignerOverride("S3SignerType");
s3Client = new AmazonS3Client(credentials, clientConfiguration);
s3Client.setS3ClientOptions(S3ClientOptions.builder()
.setPathStyleAccess(pathStyle)
.disableChunkedEncoding()
.build());
s3Client.setEndpoint(endpoint);
}
示例9: buildS3Client
import com.amazonaws.Protocol; //导入依赖的package包/类
/**
* @return S3 client
*/
private AmazonS3 buildS3Client() {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
ClientConfiguration clientConfiguration = new ClientConfiguration()
.withProtocol(useHttp ? Protocol.HTTP : Protocol.HTTPS)
.withUserAgent("s3pt")
.withGzip(useGzip)
.withTcpKeepAlive(useKeepAlive);
if (signerOverride != null) {
String signer = signerOverride.endsWith("Type")
? signerOverride
: signerOverride + "Type";
clientConfiguration.setSignerOverride(signer);
}
AmazonS3 s3Client = new AmazonS3Client(credentials, clientConfiguration);
s3Client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(usePathStyleAccess).disableChunkedEncoding().build());
s3Client.setEndpoint(endpointUrl);
return s3Client;
}
示例10: getClientConfig
import com.amazonaws.Protocol; //导入依赖的package包/类
public static ClientConfiguration getClientConfig(Parameters config){
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setProtocol(Protocol.valueOf(config.get("aws.protocol").toString().toUpperCase()));
String host = config.get("aws.proxy.host").toString();
if (host != null && host.length() > 0){
clientConfig.setProxyHost(host);
clientConfig.setProxyPort(Integer.valueOf(config.get("aws.proxy.port").toString()));
String username = config.get("aws.proxy.username").toString();
String password = config.get("aws.proxy.password").toString();
if (username != null && username.length() > 0)
clientConfig.setProxyUsername(username);
if (password != null && password.length() > 0)
clientConfig.setProxyPassword(password);
}
return clientConfig;
}
示例11: buildClientConfig
import com.amazonaws.Protocol; //导入依赖的package包/类
private ClientConfiguration buildClientConfig() {
final String userAgent = System.getProperty(
PROP_S3_HANDLER_USER_AGENT,
null);
final String protocol = System.getProperty(
PROP_S3_HANDLER_PROTOCOL,
"https");
final String signerOverride = System.getProperty(
PROP_S3_HANDLER_SIGNER_OVERRIDE,
null);
final ClientConfiguration clientConfig = new ClientConfiguration().withProtocol("https"
.equalsIgnoreCase(protocol) ? Protocol.HTTPS : Protocol.HTTP);
if (userAgent != null) {
clientConfig.setUserAgent(userAgent);
}
if (signerOverride != null) {
clientConfig.setSignerOverride(signerOverride);
}
return clientConfig;
}
示例12: getS3Client
import com.amazonaws.Protocol; //导入依赖的package包/类
private AmazonS3 getS3Client() throws Exception{
this.bucketName = properties.getProperty( "usergrid.binary.bucketname" );
if(bucketName == null){
logger.error( "usergrid.binary.bucketname not properly set so amazon bucket is null" );
throw new AwsPropertiesNotFoundException( "usergrid.binary.bucketname" );
}
final UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider();
AWSCredentials credentials = ugProvider.getCredentials();
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setProtocol(Protocol.HTTP);
s3Client = new AmazonS3Client(credentials, clientConfig);
if(regionName != null)
s3Client.setRegion( Region.getRegion(Regions.fromName(regionName)) );
return s3Client;
}
示例13: copyToS3
import com.amazonaws.Protocol; //导入依赖的package包/类
private void copyToS3( String fileName ) {
String bucketName = ( String ) properties.get( BUCKET_PROPNAME );
String accessId = ( String ) properties.get( ACCESS_ID_PROPNAME );
String secretKey = ( String ) properties.get( SECRET_KEY_PROPNAME );
Properties overrides = new Properties();
overrides.setProperty( "s3" + ".identity", accessId );
overrides.setProperty( "s3" + ".credential", secretKey );
final Iterable<? extends Module> MODULES = ImmutableSet
.of( new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(),
new NettyPayloadModule() );
AWSCredentials credentials = new BasicAWSCredentials(accessId, secretKey);
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setProtocol( Protocol.HTTP);
AmazonS3Client s3Client = new AmazonS3Client(credentials, clientConfig);
s3Client.createBucket( bucketName );
File uploadFile = new File( fileName );
PutObjectResult putObjectResult = s3Client.putObject( bucketName, uploadFile.getName(), uploadFile );
logger.info("Uploaded file etag={}", putObjectResult.getETag());
}
示例14: testRepositorySettingsGlobalOnly
import com.amazonaws.Protocol; //导入依赖的package包/类
/**
* We test when only cloud.aws settings are set
*/
public void testRepositorySettingsGlobalOnly() {
Settings nodeSettings = buildSettings(AWS);
assertThat(AwsEc2Service.CLOUD_EC2.KEY_SETTING.get(nodeSettings), is("global-key"));
assertThat(AwsEc2Service.CLOUD_EC2.SECRET_SETTING.get(nodeSettings), is("global-secret"));
assertThat(AwsEc2Service.CLOUD_EC2.PROTOCOL_SETTING.get(nodeSettings), is(Protocol.HTTPS));
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_HOST_SETTING.get(nodeSettings), is("global-proxy-host"));
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING.get(nodeSettings), is(10000));
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING.get(nodeSettings), is("global-proxy-username"));
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING.get(nodeSettings), is("global-proxy-password"));
assertThat(AwsEc2Service.CLOUD_EC2.SIGNER_SETTING.get(nodeSettings), is("global-signer"));
assertThat(AwsEc2Service.CLOUD_EC2.REGION_SETTING.get(nodeSettings), is("global-region"));
assertThat(AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING.get(nodeSettings), isEmptyString());
}
示例15: testRepositorySettingsGlobalOverloadedByEC2
import com.amazonaws.Protocol; //导入依赖的package包/类
/**
* We test when cloud.aws settings are overloaded by cloud.aws.ec2 settings
*/
public void testRepositorySettingsGlobalOverloadedByEC2() {
Settings nodeSettings = buildSettings(AWS, EC2);
assertThat(AwsEc2Service.CLOUD_EC2.KEY_SETTING.get(nodeSettings), is("ec2-key"));
assertThat(AwsEc2Service.CLOUD_EC2.SECRET_SETTING.get(nodeSettings), is("ec2-secret"));
assertThat(AwsEc2Service.CLOUD_EC2.PROTOCOL_SETTING.get(nodeSettings), is(Protocol.HTTP));
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_HOST_SETTING.get(nodeSettings), is("ec2-proxy-host"));
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING.get(nodeSettings), is(20000));
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING.get(nodeSettings), is("ec2-proxy-username"));
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING.get(nodeSettings), is("ec2-proxy-password"));
assertThat(AwsEc2Service.CLOUD_EC2.SIGNER_SETTING.get(nodeSettings), is("ec2-signer"));
assertThat(AwsEc2Service.CLOUD_EC2.REGION_SETTING.get(nodeSettings), is("ec2-region"));
assertThat(AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING.get(nodeSettings), is("ec2-endpoint"));
}