Ignore auths when value not specified in Java clients

This commit is contained in:
xhh
2015-11-20 17:34:46 +08:00
committed by Alvin Zeng
parent 7c0fd4b85f
commit e4ac6ef033
9 changed files with 31 additions and 4 deletions

View File

@@ -44,6 +44,9 @@ public class ApiKeyAuth implements Authentication {
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
if (apiKey == null) {
return;
}
String value;
if (apiKeyPrefix != null) {
value = apiKeyPrefix + " " + apiKey;

View File

@@ -31,6 +31,9 @@ public class HttpBasicAuth implements Authentication {
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
if (username == null && password == null) {
return;
}
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
try {
headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes("UTF-8"), false));