Skip to content

Commit 7e98bc3

Browse files
authored
fix: removed noauth flow (#899)
* removed noauth flow * added noauth test
1 parent 303bf6d commit 7e98bc3

24 files changed

+113
-880
lines changed

src/main/java/com/twilio/TwilioNoAuth.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/main/java/com/twilio/auth_strategy/NoAuthStrategy.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,24 @@
22

33
import com.twilio.constant.EnumConstants;
44

5+
// Does not have any state thus thread safe.
56
public class NoAuthStrategy extends AuthStrategy {
7+
private static volatile NoAuthStrategy INSTANCE;
68

7-
public NoAuthStrategy(String token) {
9+
private static volatile NoAuthStrategy instance;
10+
11+
public static NoAuthStrategy getInstance() {
12+
if (instance == null) {
13+
synchronized (NoAuthStrategy.class) {
14+
if (instance == null) {
15+
instance = new NoAuthStrategy();
16+
}
17+
}
18+
}
19+
return instance;
20+
}
21+
22+
private NoAuthStrategy() {
823
super(EnumConstants.AuthType.NO_AUTH);
924
}
1025

src/main/java/com/twilio/base/noauth/Creator.java

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/main/java/com/twilio/base/noauth/Deleter.java

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/main/java/com/twilio/base/noauth/Fetcher.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/main/java/com/twilio/base/noauth/Resource.java

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/main/java/com/twilio/base/noauth/Updater.java

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/main/java/com/twilio/http/TwilioRestClient.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@ protected TwilioRestClient(Builder b) {
8989
* @return Response object
9090
*/
9191
public Response request(final Request request) {
92-
if (username != null && password != null) {
93-
request.setAuth(username, password);
94-
} else if (authStrategy != null) {
95-
request.setAuth(authStrategy);
92+
// If authStrategy is passed from NoAuth API, no need to set authStrategy (ex TokenCreator).
93+
if (request.getAuthStrategy() == null) {
94+
if (username != null && password != null) {
95+
request.setAuth(username, password);
96+
} else if (authStrategy != null) {
97+
request.setAuth(authStrategy);
98+
}
9699
}
97100

98101
if (region != null)

0 commit comments

Comments
 (0)