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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Update
- fix: add stricter validation for Ed25519 Signed Payload.
- fix: replace assert statements with explicit null checks in `Federation` class to ensure validation is not bypassed when assertions are disabled.

## 2.2.1

Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/stellar/sdk/federation/Federation.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,17 @@ private FederationResponse resolve(String q, String domain, QueryType queryType)
private HttpUrl getFederationServerUri(@NonNull String domain) {
String uriBuilder = "https://" + domain + "/.well-known/stellar.toml";
HttpUrl stellarTomlUri = HttpUrl.parse(uriBuilder);
assert stellarTomlUri != null;
if (stellarTomlUri == null) {
throw new IllegalArgumentException("Invalid domain: " + domain);
}
Request request = new Request.Builder().get().url(stellarTomlUri).build();
try (Response response = httpClient.newCall(request).execute()) {
if (response.code() >= 300) {
throw new StellarTomlNotFoundInvalidException(response.code());
}
assert response.body() != null;
if (response.body() == null) {
throw new StellarTomlNotFoundInvalidException("Empty response body");
}
Toml stellarToml = new Toml().read(response.body().string());
String federationServer = stellarToml.getString("FEDERATION_SERVER");
if (federationServer == null || federationServer.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ public class StellarTomlNotFoundInvalidException extends NetworkException {
public StellarTomlNotFoundInvalidException(Integer code) {
super(code, null);
}

public StellarTomlNotFoundInvalidException(String message) {
super(message, null, null);
}
}
Loading