diff --git a/build.gradle b/build.gradle index 6b46d6e8b..d3d4cf4d5 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'com.github.ben-manes.versions' // gradle dependencyUpdates -Drevi apply plugin: 'project-report' // gradle htmlDependencyReport sourceCompatibility = 1.6 -version = '0.31.0' +version = '0.32.0' group = 'stellar' jar { diff --git a/src/main/java/org/stellar/sdk/Sep10Challenge.java b/src/main/java/org/stellar/sdk/Sep10Challenge.java index 50f97e2f3..9fe1b52cc 100644 --- a/src/main/java/org/stellar/sdk/Sep10Challenge.java +++ b/src/main/java/org/stellar/sdk/Sep10Challenge.java @@ -44,18 +44,19 @@ public static Transaction newChallenge( return newChallenge(signer, network, clientAccountId, domainName, webAuthDomain, timebounds, "", ""); } - /** - * Returns a valid SEP 10 challenge, for use in web authentication. - * - * @param signer The server's signing account. - * @param network The Stellar network used by the server. - * @param clientAccountId The stellar account belonging to the client. - * @param domainName The fully qualified domain name of the service requiring authentication. - * @param webAuthDomain The fully qualified domain name of the service issuing the challenge. - * @param timebounds The lifetime of the challenge token. - * @param clientDomain The domain of the client application requesting authentication. - * @param clientSigningKey The stellar account listed as the SIGNING_KEY on the client domain's TOML file. - */ + /** + * Returns a valid SEP 10 challenge, for use in web authentication. + * + * @param signer The server's signing account. + * @param network The Stellar network used by the server. + * @param clientAccountId The stellar account belonging to the client. + * @param domainName The fully qualified domain name of the service requiring authentication. + * @param webAuthDomain The fully qualified domain name of the service issuing the challenge. + * @param timebounds The lifetime of the challenge token. + * @param clientDomain The domain of the client application requesting authentication. + * @param clientSigningKey The stellar account listed as the SIGNING_KEY on the client domain's TOML file. + * @param memo The memo of the challenge transaction. + */ public static Transaction newChallenge( KeyPair signer, Network network, @@ -64,7 +65,8 @@ public static Transaction newChallenge( String webAuthDomain, TimeBounds timebounds, String clientDomain, - String clientSigningKey + String clientSigningKey, + Memo memo ) throws InvalidSep10ChallengeException { byte[] nonce = new byte[48]; SecureRandom random = new SecureRandom(); @@ -94,6 +96,10 @@ public static Transaction newChallenge( .addOperation(domainNameOperation) .addOperation(webAuthDomainOperation); + if (memo != null) { + builder.addMemo(memo); + } + if (!clientSigningKey.isEmpty()) { if (StrKey.decodeVersionByte(clientSigningKey) != StrKey.VersionByte.ACCOUNT_ID) { throw new InvalidSep10ChallengeException(clientSigningKey + " is not a valid account id"); @@ -109,6 +115,32 @@ public static Transaction newChallenge( return transaction; } + + /** + * Returns a valid SEP 10 challenge, for use in web authentication. + * + * @param signer The server's signing account. + * @param network The Stellar network used by the server. + * @param clientAccountId The stellar account belonging to the client. + * @param domainName The fully qualified domain name of the service requiring authentication. + * @param webAuthDomain The fully qualified domain name of the service issuing the challenge. + * @param timebounds The lifetime of the challenge token. + * @param clientDomain The domain of the client application requesting authentication. + * @param clientSigningKey The stellar account listed as the SIGNING_KEY on the client domain's TOML file. + */ + public static Transaction newChallenge( + KeyPair signer, + Network network, + String clientAccountId, + String domainName, + String webAuthDomain, + TimeBounds timebounds, + String clientDomain, + String clientSigningKey + ) throws InvalidSep10ChallengeException { + return newChallenge(signer, network, clientAccountId, domainName, webAuthDomain, timebounds, clientDomain, clientSigningKey, null); + } + /** * Reads a SEP 10 challenge transaction and returns the decoded transaction envelope and client account ID contained within. *