-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
191 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/io/split/android/client/network/SplitBasicAuthenticator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.split.android.client.network; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
class SplitBasicAuthenticator extends SplitAuthenticator { | ||
|
||
private static final String PROXY_AUTHORIZATION_HEADER = "Proxy-Authorization"; | ||
private final String mUsername; | ||
private final String mPassword; | ||
@NonNull | ||
private final Base64Encoder mBase64Encoder; | ||
|
||
SplitBasicAuthenticator(String username, String password, @NonNull Base64Encoder base64Encoder) { | ||
mUsername = username; | ||
mPassword = password; | ||
mBase64Encoder = base64Encoder; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public SplitAuthenticatedRequest authenticate(@NonNull SplitAuthenticatedRequest request) { | ||
String credential = basic(mUsername, mPassword); | ||
request.setHeader(PROXY_AUTHORIZATION_HEADER, credential); | ||
|
||
return request; | ||
} | ||
|
||
private String basic(String username, String password) { | ||
String usernameAndPassword = username + ":" + password; | ||
String encoded = mBase64Encoder.encode(usernameAndPassword); | ||
return "Basic " + encoded; | ||
} | ||
|
||
interface Base64Encoder { | ||
String encode(String value); | ||
} | ||
} |
49 changes: 0 additions & 49 deletions
49
src/main/java/io/split/android/client/network/SplitOkHttpAuthenticator.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.