Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lijamie98 committed Jun 14, 2023
1 parent b23c02b commit 2fad087
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ void validateConfig(Errors errors) {
errors.rejectValue(
"homeDomain", "home-domain-empty", "The sep10.home_domain is not defined.");
} else {
try {
new ManageDataOperation.Builder(String.format("%s %s", homeDomain, "auth"), new byte[64])
.build();
} catch (IllegalArgumentException iaex) {
errors.rejectValue(
"homeDomain",
"sep10-home-domain-invalid",
format(
"The sep10.home_domain (%s) is longer than the maximum length (64) of a domain. Error=%s",
homeDomain, iaex));
}

if (!NetUtil.isServerPortValid(homeDomain)) {
errors.rejectValue(
"homeDomain",
Expand All @@ -96,6 +108,17 @@ void validateConfig(Errors errors) {
}

if (isNotEmpty(webAuthDomain)) {
try {
new ManageDataOperation.Builder(webAuthDomain, new byte[64]).build();
} catch (IllegalArgumentException iaex) {
errors.rejectValue(
"webAuthDomain",
"sep10-web-auth-domain-invalid",
format(
"The sep10.web_auth_home_domain (%s) is longer than the maximum length (64) of a domain. Error=%s",
webAuthDomain, iaex));
}

if (!NetUtil.isServerPortValid(webAuthDomain)) {
errors.rejectValue(
"webAuthDomain",
Expand All @@ -117,30 +140,6 @@ void validateConfig(Errors errors) {
"sep10-jwt-timeout-invalid",
"The sep10.jwt_timeout must be greater than 0");
}

byte[] nonce = new byte[64];

try {
new ManageDataOperation.Builder(String.format("%s %s", homeDomain, "auth"), nonce).build();
} catch (IllegalArgumentException iaex) {
errors.rejectValue(
"homeDomain",
"sep10-home-domain-invalid",
format(
"The sep10.home_domain (%s) is longer than the maximum length (64) of a domain. Error=%s",
homeDomain, iaex));
}

try {
if (webAuthDomain != null) new ManageDataOperation.Builder(webAuthDomain, nonce).build();
} catch (IllegalArgumentException iaex) {
errors.rejectValue(
"webAuthDomain",
"sep10-web-auth-domain-invalid",
format(
"The sep10.web_auth_home_domain (%s) is longer than the maximum length (64) of a domain. Error=%s",
webAuthDomain, iaex));
}
}

void validateClientAttribution(Errors errors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ class Sep10ConfigTest {
@ValueSource(
strings =
[
"this-is-longer-than-64-bytes-which-is-the-maximum-length-for-a-web-auth-domain.stellar.org",
"stellar .org",
"abc",
"299.0.0.1",
"0123456789012345678901234567890123456789012345678912.stellar.org",
"this-is-longer-than-64-bytes-which-is-the-maximum-length-for-a-web-auth-domain.stellar.org"
]
)
fun `test invalid web auth domains`(value: String) {
Expand All @@ -159,13 +159,13 @@ class Sep10ConfigTest {
@ValueSource(
strings =
[
"this-is-longer-than-64-bytes-which-is-the-maximum-length-for-a-home-domain.stellar.org",
"stellar .org",
"abc",
"299.0.0.1",
"http://stellar.org",
"https://stellar.org",
"://stellar.org",
"this-is-longer-than-64-bytes-which-is-the-maximum-length-for-a-home-domain.stellar.org"
]
)
fun `test invalid home domains`(value: String) {
Expand Down

0 comments on commit 2fad087

Please sign in to comment.