Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions src/main/java/com/twilio/TwilioNoAuth.java

This file was deleted.

17 changes: 16 additions & 1 deletion src/main/java/com/twilio/auth_strategy/NoAuthStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@

import com.twilio.constant.EnumConstants;

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

public NoAuthStrategy(String token) {
private static volatile NoAuthStrategy instance;

public static NoAuthStrategy getInstance() {
if (instance == null) {
synchronized (NoAuthStrategy.class) {
if (instance == null) {
instance = new NoAuthStrategy();
}
}
}
return instance;
}

private NoAuthStrategy() {
super(EnumConstants.AuthType.NO_AUTH);
}

Expand Down
51 changes: 0 additions & 51 deletions src/main/java/com/twilio/base/noauth/Creator.java

This file was deleted.

51 changes: 0 additions & 51 deletions src/main/java/com/twilio/base/noauth/Deleter.java

This file was deleted.

52 changes: 0 additions & 52 deletions src/main/java/com/twilio/base/noauth/Fetcher.java

This file was deleted.

9 changes: 0 additions & 9 deletions src/main/java/com/twilio/base/noauth/Resource.java

This file was deleted.

51 changes: 0 additions & 51 deletions src/main/java/com/twilio/base/noauth/Updater.java

This file was deleted.

11 changes: 7 additions & 4 deletions src/main/java/com/twilio/http/TwilioRestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ protected TwilioRestClient(Builder b) {
* @return Response object
*/
public Response request(final Request request) {
if (username != null && password != null) {
request.setAuth(username, password);
} else if (authStrategy != null) {
request.setAuth(authStrategy);
// If authStrategy is passed from NoAuth API, no need to set authStrategy (ex TokenCreator).
if (request.getAuthStrategy() == null) {
if (username != null && password != null) {
request.setAuth(username, password);
} else if (authStrategy != null) {
request.setAuth(authStrategy);
}
}

if (region != null)
Expand Down
Loading