diff --git a/jitpack.yml b/jitpack.yml index f5600f5..52af312 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -1,2 +1,4 @@ +jdk: + - openjdk11 install: - ./gradlew :sdk:build :sdk:publishToMavenLocal \ No newline at end of file diff --git a/sdk/src/main/java/org/torusresearch/customauth/CustomAuth.java b/sdk/src/main/java/org/torusresearch/customauth/CustomAuth.java index 2f143ac..7d87110 100644 --- a/sdk/src/main/java/org/torusresearch/customauth/CustomAuth.java +++ b/sdk/src/main/java/org/torusresearch/customauth/CustomAuth.java @@ -143,24 +143,27 @@ public CompletableFuture triggerAggregateLogin(Aggr // All promises would have been resolved correctly by here userInfoArray.add(userInfoPromise.join()); } - AggregateVerifierParams aggregateVerifierParams = new AggregateVerifierParams(); - aggregateVerifierParams.setVerify_params(new VerifyParams[subVerifierDetailsArray.length]); - aggregateVerifierParams.setSub_verifier_ids(new String[subVerifierDetailsArray.length]); + + VerifyParams[] params = new VerifyParams[subVerifierDetailsArray.length]; + String[] subVerifierDetails = new String[subVerifierDetailsArray.length]; + List aggregateIdTokenSeeds = new ArrayList<>(); String aggregateVerifierId = ""; for (int i = 0; i < subVerifierDetailsArray.length; i++) { LoginWindowResponse loginParams = loginParamsArray.get(i); TorusVerifierResponse userInfo = userInfoArray.get(i); String finalToken = !Helpers.isEmpty(loginParams.getIdToken()) ? loginParams.getIdToken() : loginParams.getAccessToken(); - aggregateVerifierParams.setVerifyParamItem(new VerifyParams(userInfo.getVerifierId(), finalToken), i); - aggregateVerifierParams.setSubVerifierIdItem(userInfo.getVerifier(), i); + params[i] =new VerifyParams(userInfo.getVerifierId(), finalToken); + subVerifierDetails[i] = userInfo.getVerifier(); aggregateIdTokenSeeds.add(finalToken); aggregateVerifierId = userInfo.getVerifierId(); } Collections.sort(aggregateIdTokenSeeds); String aggregateTokenString = TextUtils.join(Character.toString((char) 29), aggregateIdTokenSeeds); String aggregateIdToken = Hash.sha3String(aggregateTokenString).substring(2); - aggregateVerifierParams.setVerifier_id(aggregateVerifierId); + + AggregateVerifierParams aggregateVerifierParams = new AggregateVerifierParams(params, subVerifierDetails, aggregateVerifierId); + VerifierParams verifierParams = new VerifierParams(aggregateVerifierParams.getVerifier_id(), null, aggregateVerifierParams.getSub_verifier_ids(), aggregateVerifierParams.getVerify_params()); try { @@ -192,23 +195,26 @@ public TorusKey getTorusKey(String verifier, String verifierId, VerifierParams v } public TorusKey getAggregateTorusKey(String verifier, String verifierId, TorusSubVerifierInfo[] subVerifierInfoArray) throws Exception { - AggregateVerifierParams aggregateVerifierParams = new AggregateVerifierParams(); - aggregateVerifierParams.setVerify_params(new VerifyParams[subVerifierInfoArray.length]); - aggregateVerifierParams.setSub_verifier_ids(new String[subVerifierInfoArray.length]); List aggregateIdTokenSeeds = new ArrayList<>(); String aggregateVerifierId = ""; + + VerifyParams[] params = new VerifyParams[subVerifierInfoArray.length]; + String[] subVerifierDetails = new String[subVerifierInfoArray.length]; + for (int i = 0; i < subVerifierInfoArray.length; i++) { TorusSubVerifierInfo userInfo = subVerifierInfoArray[i]; String finalToken = userInfo.getIdToken(); - aggregateVerifierParams.setVerifyParamItem(new VerifyParams(verifierId, finalToken), i); - aggregateVerifierParams.setSubVerifierIdItem(userInfo.getVerifier(), i); + params[i] = new VerifyParams(verifierId, finalToken); + subVerifierDetails[i] = userInfo.getVerifier(); aggregateIdTokenSeeds.add(finalToken); aggregateVerifierId = verifierId; } + Collections.sort(aggregateIdTokenSeeds); String aggregateTokenString = TextUtils.join(Character.toString((char) 29), aggregateIdTokenSeeds); String aggregateIdToken = Hash.sha3String(aggregateTokenString).substring(2); - aggregateVerifierParams.setVerifier_id(aggregateVerifierId); + + AggregateVerifierParams aggregateVerifierParams = new AggregateVerifierParams(params, subVerifierDetails, verifierId); VerifierParams verifierParams = new VerifierParams(aggregateVerifierParams.getVerifier_id(), null, aggregateVerifierParams.getSub_verifier_ids(), aggregateVerifierParams.getVerify_params()); return this.getTorusKey(verifier, aggregateVerifierId, verifierParams, aggregateIdToken); diff --git a/sdk/src/main/java/org/torusresearch/customauth/types/AggregateVerifierParams.java b/sdk/src/main/java/org/torusresearch/customauth/types/AggregateVerifierParams.java index 3a36bed..5bd8035 100644 --- a/sdk/src/main/java/org/torusresearch/customauth/types/AggregateVerifierParams.java +++ b/sdk/src/main/java/org/torusresearch/customauth/types/AggregateVerifierParams.java @@ -1,5 +1,6 @@ package org.torusresearch.customauth.types; +import org.jetbrains.annotations.NotNull; import org.torusresearch.torusutils.types.VerifyParams; public class AggregateVerifierParams { @@ -7,35 +8,23 @@ public class AggregateVerifierParams { private String[] sub_verifier_ids; private String verifier_id; - public VerifyParams[] getVerify_params() { - return verify_params; + public AggregateVerifierParams(@NotNull VerifyParams[] verifyParams, @NotNull String[] subVerifierIds, @NotNull String verifierId) { + this.verify_params = verifyParams; + this.sub_verifier_ids = subVerifierIds; + this.verifier_id = verifierId; } - public void setVerify_params(VerifyParams[] verify_params) { - this.verify_params = verify_params; - } - public void setVerifyParamItem(VerifyParams verify_param, int index) { - this.verify_params[index] = verify_param; + public VerifyParams[] getVerify_params() { + return verify_params; } public String[] getSub_verifier_ids() { return sub_verifier_ids; } - public void setSub_verifier_ids(String[] sub_verifier_ids) { - this.sub_verifier_ids = sub_verifier_ids; - } - - public void setSubVerifierIdItem(String sub_verifier_id, int index) { - this.sub_verifier_ids[index] = sub_verifier_id; - } - public String getVerifier_id() { return verifier_id; } - public void setVerifier_id(String verifier_id) { - this.verifier_id = verifier_id; - } }