code: private static AWSSecurityTokenService buildStsClient(Builder builder) throws
                                                                             IllegalArgumentException {
          /**
           * Passing two types of credential interfaces is not permitted
           */
          if (builder.longLivedCredentials != null && builder.longLivedCredentialsProvider != null) {
              throw new IllegalArgumentException(
                      "It is illegal to set both an AWSCredentials and an AWSCredentialsProvider for an " +
                      STSAssumeRoleSessionCredentialsProvider.class.getName());
          }
  
          AWSCredentialsProvider longLivedCredentialsProvider = null;
          if (builder.longLivedCredentials != null) {
              longLivedCredentialsProvider = new StaticCredentialsProvider(
                      builder.longLivedCredentials);
          } else if (builder.longLivedCredentialsProvider != null) {
              longLivedCredentialsProvider = builder.longLivedCredentialsProvider;
          }
  
          // Depending on which options are explicitly provided we have to call the right overloaded constructor so
          // defaults are properly applied.
          if (longLivedCredentialsProvider == null) {
              if (builder.clientConfiguration == null) {
                  return new AWSSecurityTokenServiceClient();
              } else {
                  return new AWSSecurityTokenServiceClient(builder.clientConfiguration);
              }
          } else {
              if (builder.clientConfiguration == null) {
                  return new AWSSecurityTokenServiceClient(longLivedCredentialsProvider);
              } else {
                  return new AWSSecurityTokenServiceClient(longLivedCredentialsProvider,
                                                           builder.clientConfiguration);
              }
          }
      }
docs: Construct a new STS client from the settings in the builder.
  
  @param builder Configured builder
  @return New instance of AWSSecurityTokenService
  @throws IllegalArgumentException if builder configuration is inconsistent