@@ -22,8 +22,7 @@ import scala.collection.immutable._
2222import scala .concurrent .{blocking , Future }
2323import scala .jdk .CollectionConverters ._
2424
25- class AwsRequestSigner private (credentialsProvider : AwsCredentialsProvider , region : String )(implicit mat : Materializer )
26- extends StrictLogging {
25+ class AwsRequestSigner private (credentialsProvider : AwsCredentialsProvider , region : String )(implicit mat : Materializer ) extends StrictLogging {
2726 private val awsSigner = Aws4Signer .create()
2827 private val executionAttributes = new ExecutionAttributes ()
2928 .putAttribute(AwsSignerExecutionAttribute .SERVICE_SIGNING_NAME , " execute-api" )
@@ -57,20 +56,15 @@ class AwsRequestSigner private (credentialsProvider: AwsCredentialsProvider, reg
5756 * @param headers `Seq[HttpHeader]` headers of an Akka `HttpRequest`
5857 * @return true if "Authorization" header exists
5958 */
60- private def isAlreadyAuthorized (headers : Seq [HttpHeader ]): Boolean =
61- headers.exists { header : HttpHeader =>
62- header.is(" authorization" )
63- }
59+ private def isAlreadyAuthorized (headers : Seq [HttpHeader ]): Boolean = headers.exists(_.is(" authorization" ))
6460
6561 /** Constructs an `SdkHttpFullRequest` from Akka's `HttpRequest` for signing.
6662 *
6763 * @param request HttpRequest to convert
6864 * @return SdkHttpFullRequest
6965 */
7066 private def toSdkRequest (request : HttpRequest ): SdkHttpFullRequest = {
71- val content : InputStream = request.entity.dataBytes.runWith(
72- StreamConverters .asInputStream()
73- )
67+ val content : InputStream = request.entity.dataBytes.runWith(StreamConverters .asInputStream())
7468 val headers : util.Map [String , util.List [String ]] =
7569 request.headers.groupBy(_.name).view.mapValues(_.map(_.value)).map(h => h._1 -> h._2.toList.asJava).toMap.asJava
7670 val query : util.Map [String , util.List [String ]] =
@@ -115,14 +109,16 @@ object AwsRequestSigner extends StrictLogging {
115109
116110 object AwsRequestSignerConfig {
117111 final case class AssumeRole (roleArn : String , roleSessionName : String , awsRegion : String ) extends AwsRequestSignerConfig
112+
118113 final case class BasicCredentials (accessKey : String , secretKey : String , awsRegion : String ) extends AwsRequestSignerConfig
114+
119115 final case class Instance (awsRegion : String ) extends AwsRequestSignerConfig
120116 }
121117
122118 /** Construct an `AwsRequestSigner` from the given configuration.
123119 *
124120 * @param config `AwsRequestSignerConfig` to be used to construct one of the three config providers
125- * @param mat `Materializer` on which the `Future`s run
121+ * @param mat `Materializer` on which the `Future`s run
126122 * @return `AwsRequestSigner`
127123 */
128124 def fromConfig (config : AwsRequestSignerConfig )(implicit mat : Materializer ): AwsRequestSigner =
@@ -135,9 +131,7 @@ object AwsRequestSigner extends StrictLogging {
135131 val provider : StsAssumeRoleCredentialsProvider = StsAssumeRoleCredentialsProvider
136132 .builder()
137133 .stsClient(StsClient .create())
138- .refreshRequest(
139- AssumeRoleRequest .builder().roleArn(roleArn).roleSessionName(roleSessionName).build()
140- )
134+ .refreshRequest(AssumeRoleRequest .builder().roleArn(roleArn).roleSessionName(roleSessionName).build())
141135 .build()
142136 new AwsRequestSigner (provider, awsRegion)
143137 case AwsRequestSignerConfig .BasicCredentials (accessKey, secretKey, awsRegion) =>
0 commit comments