@@ -215,11 +215,8 @@ public ApiClient(
215215
216216 SignatureConfiguration signatureConfiguration = configuration .getSignatureConfiguration ();
217217 if (signatureConfiguration != null ) {
218- Authentication authentication =
219- binanceAuthenticationFactory .getAuthentication (signatureConfiguration );
220- if (authentication != null ) {
221- authentications .put (BINANCE_SIGNATURE , authentication );
222- }
218+ Map <String , Authentication > customAuthentications = getCustomAuthentications (binanceAuthenticationFactory , signatureConfiguration );
219+ authentications .putAll (customAuthentications );
223220 }
224221
225222 Authentication binanceApiKeyOnly =
@@ -515,6 +512,21 @@ public Map<String, Authentication> getAuthentications() {
515512 return authentications ;
516513 }
517514
515+ /**
516+ * Get custom authentications to be added (key: authentication name, value: authentication).
517+ *
518+ * @return Map of authentication objects
519+ */
520+ protected Map <String , Authentication > getCustomAuthentications (BinanceAuthenticationFactory binanceAuthenticationFactory , SignatureConfiguration signatureConfiguration ) {
521+ Map <String , Authentication > authentications = new HashMap <>();
522+ Authentication authentication =
523+ binanceAuthenticationFactory .getAuthentication (signatureConfiguration );
524+ if (authentication != null ) {
525+ authentications .put (BINANCE_SIGNATURE , authentication );
526+ }
527+ return authentications ;
528+ }
529+
518530 /**
519531 * Get authentication for the given name.
520532 *
@@ -1215,8 +1227,7 @@ public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiExceptio
12151227 try {
12161228 Response response = call .execute ();
12171229 T data = handleResponse (response , returnType );
1218- Map <RateLimitType , RateLimit > rateLimit =
1219- getRateLimit (response .code (), response .headers ());
1230+ Map <RateLimitType , ? extends RateLimit > rateLimit = getRateLimit (response .code (), response .headers ());
12201231 return new ApiResponse <T >(
12211232 response .code (), response .headers ().toMultimap (), data , rateLimit );
12221233 } catch (IOException e ) {
@@ -1571,7 +1582,7 @@ public void updateParamsForAuth(
15711582 for (String authName : authNames ) {
15721583 Authentication auth = authentications .get (authName );
15731584 if (auth == null ) {
1574- if (BINANCE_SIGNATURE . equals (authName )) {
1585+ if (isRequiredAuth (authName )) {
15751586 throw new RuntimeException (
15761587 "Request is signed, please add signatureConfiguration to"
15771588 + " clientConfiguration" );
@@ -1586,6 +1597,10 @@ public void updateParamsForAuth(
15861597 }
15871598 }
15881599
1600+ protected boolean isRequiredAuth (String authName ) {
1601+ return BINANCE_SIGNATURE .equals (authName );
1602+ }
1603+
15891604 /**
15901605 * Build a form-encoding request body with the given form parameters.
15911606 *
@@ -1819,7 +1834,7 @@ private String requestBodyToString(RequestBody requestBody) throws ApiException
18191834 return "" ;
18201835 }
18211836
1822- private Map <RateLimitType , RateLimit > getRateLimit (Integer responseCode , Headers headers ) {
1837+ protected Map <RateLimitType , ? extends RateLimit > getRateLimit (Integer responseCode , Headers headers ) {
18231838 HashMap <RateLimitType , RateLimit > rateLimitMap = new HashMap <>();
18241839 Integer retryAfter = null ;
18251840 if (Arrays .asList (HTTP_TEA_POT , HTTP_TOO_MANY_REQS ).contains (responseCode )) {
0 commit comments