Java Code Examples for software.amazon.awssdk.utils.StringUtils#isBlank()
The following examples show how to use
software.amazon.awssdk.utils.StringUtils#isBlank() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnvironmentAwsCredentialsProvider.java From micronaut-aws with Apache License 2.0 | 6 votes |
@Override public AwsCredentials resolveCredentials() { String accessKey = environment.getProperty(ACCESS_KEY_ENV_VAR, String.class, environment.getProperty(ALTERNATE_ACCESS_KEY_ENV_VAR, String.class, (String) null)); String secretKey = environment.getProperty(SECRET_KEY_ENV_VAR, String.class, environment.getProperty(ALTERNATE_SECRET_KEY_ENV_VAR, String.class, (String) null)); accessKey = StringUtils.trim(accessKey); secretKey = StringUtils.trim(secretKey); String sessionToken = StringUtils.trim(environment.getProperty(AWS_SESSION_TOKEN_ENV_VAR, String.class, (String) null)); if (StringUtils.isBlank(accessKey) || StringUtils.isBlank(secretKey)) { throw SdkClientException.create( "Unable to load AWS credentials from environment " + "(" + ACCESS_KEY_ENV_VAR + " (or " + ALTERNATE_ACCESS_KEY_ENV_VAR + ") and " + SECRET_KEY_ENV_VAR + " (or " + ALTERNATE_SECRET_KEY_ENV_VAR + "))"); } return sessionToken == null ? AwsBasicCredentials.create(accessKey, secretKey) : AwsSessionCredentials.create(accessKey, secretKey, sessionToken); }
Example 2
Source File: RequestAdapter.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
/** * Configures the headers in the specified Netty HTTP request. */ private void addHeadersToRequest(DefaultHttpRequest httpRequest, SdkHttpRequest request) { httpRequest.headers().add(HOST, getHostHeaderValue(request)); String scheme = request.getUri().getScheme(); if (Protocol.HTTP2 == protocol && !StringUtils.isBlank(scheme)) { httpRequest.headers().add(ExtensionHeaderNames.SCHEME.text(), scheme); } // Copy over any other headers already in our request request.headers().entrySet().stream() /* * Skip the Host header to avoid sending it twice, which will * interfere with some signing schemes. */ .filter(e -> !IGNORE_HEADERS.contains(e.getKey())) .forEach(e -> e.getValue().forEach(h -> httpRequest.headers().add(e.getKey(), h))); }
Example 3
Source File: S3BundlePersistenceProvider.java From nifi-registry with Apache License 2.0 | 6 votes |
private Region getRegion(final ProviderConfigurationContext configurationContext) { final String regionValue = configurationContext.getProperties().get(REGION_PROP); if (StringUtils.isBlank(regionValue)) { throw new ProviderCreationException("The property '" + REGION_PROP + "' must be provided"); } Region region = null; for (Region r : Region.regions()) { if (r.id().equals(regionValue)) { region = r; break; } } if (region == null) { LOGGER.warn("The provided region was not found in the list of known regions. This may indicate an invalid region, " + "or may indicate a region that is newer than the known list of regions"); region = Region.of(regionValue); } LOGGER.debug("Using region {}", new Object[] {region.id()}); return region; }
Example 4
Source File: AmazonClientTransportRecorder.java From quarkus with Apache License 2.0 | 5 votes |
private void validateProxyEndpoint(String extension, URI endpoint, String clientType) { if (StringUtils.isBlank(endpoint.getScheme())) { throw new RuntimeConfigurationError( String.format("quarkus.%s.%s-client.proxy.endpoint (%s) - scheme must be specified", extension, clientType, endpoint.toString())); } if (StringUtils.isBlank(endpoint.getHost())) { throw new RuntimeConfigurationError( String.format("quarkus.%s.%s-client.proxy.endpoint (%s) - host must be specified", extension, clientType, endpoint.toString())); } if (StringUtils.isNotBlank(endpoint.getUserInfo())) { throw new RuntimeConfigurationError( String.format("quarkus.%s.%s-client.proxy.endpoint (%s) - user info is not supported.", extension, clientType, endpoint.toString())); } if (StringUtils.isNotBlank(endpoint.getPath())) { throw new RuntimeConfigurationError( String.format("quarkus.%s.%s-client.proxy.endpoint (%s) - path is not supported.", extension, clientType, endpoint.toString())); } if (StringUtils.isNotBlank(endpoint.getQuery())) { throw new RuntimeConfigurationError( String.format("quarkus.%s.%s-client.proxy.endpoint (%s) - query is not supported.", extension, clientType, endpoint.toString())); } if (StringUtils.isNotBlank(endpoint.getFragment())) { throw new RuntimeConfigurationError( String.format("quarkus.%s.%s-client.proxy.endpoint (%s) - fragment is not supported.", extension, clientType, endpoint.toString())); } }
Example 5
Source File: RequestAdapter.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private static String encodedPathAndQueryParams(SdkHttpRequest sdkRequest) { String encodedPath = sdkRequest.encodedPath(); if (StringUtils.isBlank(encodedPath)) { encodedPath = "/"; } String encodedQueryParams = SdkHttpUtils.encodeAndFlattenQueryParameters(sdkRequest.rawQueryParameters()) .map(queryParams -> "?" + queryParams) .orElse(""); return encodedPath + encodedQueryParams; }
Example 6
Source File: S3BundlePersistenceProvider.java From nifi-registry with Apache License 2.0 | 5 votes |
@Override public void onConfigured(final ProviderConfigurationContext configurationContext) throws ProviderCreationException { s3BucketName = configurationContext.getProperties().get(BUCKET_NAME_PROP); if (StringUtils.isBlank(s3BucketName)) { throw new ProviderCreationException("The property '" + BUCKET_NAME_PROP + "' must be provided"); } final String keyPrefixValue = configurationContext.getProperties().get(KEY_PREFIX_PROP); s3KeyPrefix = StringUtils.isBlank(keyPrefixValue) ? null : keyPrefixValue; s3Client = createS3Client(configurationContext); }
Example 7
Source File: S3BundlePersistenceProvider.java From nifi-registry with Apache License 2.0 | 5 votes |
private AwsCredentialsProvider getCredentialsProvider(final ProviderConfigurationContext configurationContext) { final String credentialsProviderValue = configurationContext.getProperties().get(CREDENTIALS_PROVIDER_PROP); if (StringUtils.isBlank(credentialsProviderValue)) { throw new ProviderCreationException("The property '" + CREDENTIALS_PROVIDER_PROP + "' must be provided"); } CredentialProvider credentialProvider; try { credentialProvider = CredentialProvider.valueOf(credentialsProviderValue); } catch (Exception e) { throw new ProviderCreationException("The property '" + CREDENTIALS_PROVIDER_PROP + "' must be one of [" + CredentialProvider.STATIC + ", " + CredentialProvider.DEFAULT_CHAIN + " ]"); } if (CredentialProvider.STATIC == credentialProvider) { final String accesKeyValue = configurationContext.getProperties().get(ACCESS_KEY_PROP); final String secretAccessKey = configurationContext.getProperties().get(SECRET_ACCESS_KEY_PROP); if (StringUtils.isBlank(accesKeyValue) || StringUtils.isBlank(secretAccessKey)) { throw new ProviderCreationException("The properties '" + ACCESS_KEY_PROP + "' and '" + SECRET_ACCESS_KEY_PROP + "' must be provided when using " + CredentialProvider.STATIC + " credentials provider"); } LOGGER.debug("Creating StaticCredentialsProvider"); final AwsCredentials awsCredentials = AwsBasicCredentials.create(accesKeyValue, secretAccessKey); return StaticCredentialsProvider.create(awsCredentials); } else { LOGGER.debug("Creating DefaultCredentialsProvider"); return DefaultCredentialsProvider.create(); } }
Example 8
Source File: S3BundlePersistenceProvider.java From nifi-registry with Apache License 2.0 | 5 votes |
private URI getS3EndpointOverride(final ProviderConfigurationContext configurationContext) { final URI s3EndpointOverride; final String endpointUrlValue = configurationContext.getProperties().get(ENDPOINT_URL_PROP); try { s3EndpointOverride = StringUtils.isBlank(endpointUrlValue) ? null : URI.create(endpointUrlValue); } catch (IllegalArgumentException e) { final String errMessage = "The optional property '" + ENDPOINT_URL_PROP + "' must be a valid URL if set. " + "URI Syntax Exception is: " + e.getLocalizedMessage(); LOGGER.error(errMessage); LOGGER.debug("", e); throw new ProviderCreationException(errMessage, e); } return s3EndpointOverride; }
Example 9
Source File: StreamsRecord.java From pulsar with Apache License 2.0 | 5 votes |
public StreamsRecord(com.amazonaws.services.kinesis.model.Record record) { if (record instanceof RecordAdapter) { com.amazonaws.services.dynamodbv2.model.Record dynamoRecord = ((RecordAdapter) record).getInternalObject(); this.key = Optional.of(dynamoRecord.getEventID()); setProperty(EVENT_NAME, dynamoRecord.getEventName()); setProperty(SEQUENCE_NUMBER, dynamoRecord.getDynamodb().getSequenceNumber()); } else { this.key = Optional.of(record.getPartitionKey()); setProperty(ARRIVAL_TIMESTAMP, record.getApproximateArrivalTimestamp().toString()); setProperty(ENCRYPTION_TYPE, record.getEncryptionType()); setProperty(PARTITION_KEY, record.getPartitionKey()); setProperty(SEQUENCE_NUMBER, record.getSequenceNumber()); } if (StringUtils.isBlank(record.getEncryptionType())) { String s = null; try { s = decoder.decode(record.getData()).toString(); } catch (CharacterCodingException e) { // Ignore } this.value = (s != null) ? s.getBytes() : null; } else { // Who knows? this.value = null; } }
Example 10
Source File: S3ClientConfiguration.java From tutorials with MIT License | 5 votes |
@Bean public AwsCredentialsProvider awsCredentialsProvider(S3ClientConfigurarionProperties s3props) { if (StringUtils.isBlank(s3props.getAccessKeyId())) { // Return default provider return DefaultCredentialsProvider.create(); } else { // Return custom credentials provider return () -> { AwsCredentials creds = AwsBasicCredentials.create(s3props.getAccessKeyId(), s3props.getSecretAccessKey()); return creds; }; } }
Example 11
Source File: Metadata.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
private String joinPackageNames(String lhs, String rhs) { return StringUtils.isBlank(rhs) ? lhs : lhs + '.' + rhs; }