diff --git a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/HoldingIdentity.java b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/HoldingIdentity.java index e8f86c2..6c7b320 100644 --- a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/HoldingIdentity.java +++ b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/HoldingIdentity.java @@ -27,8 +27,9 @@ public record HoldingIdentity(String x500Name, String shortHash) implements Seri LdapName ln = new LdapName(x500Name); for(Rdn rdn : ln.getRdns()) { - if(rdn.getType().equalsIgnoreCase("OU")) { - return rdn.getValue().toString().equalsIgnoreCase("Player"); + if(rdn.getType().equalsIgnoreCase("CN")) { + final String name = rdn.getValue().toString(); + return !name.equalsIgnoreCase("Custodian") && !name.equalsIgnoreCase("NotaryService"); } } @@ -39,7 +40,7 @@ public record HoldingIdentity(String x500Name, String shortHash) implements Seri LdapName ln = new LdapName(x500Name); for(Rdn rdn : ln.getRdns()) { - if(rdn.getType().equalsIgnoreCase("OU")) { + if(rdn.getType().equalsIgnoreCase("CN")) { return rdn.getValue().toString().equalsIgnoreCase("Custodian"); } } @@ -51,7 +52,7 @@ public record HoldingIdentity(String x500Name, String shortHash) implements Seri LdapName ln = new LdapName(x500Name); for(Rdn rdn : ln.getRdns()) { - if(rdn.getType().equalsIgnoreCase("O")) { + if(rdn.getType().equalsIgnoreCase("OU")) { return rdn.getValue().toString().equalsIgnoreCase("Checkers"); } } diff --git a/corda/config/static-network-config.json b/corda/config/static-network-config.json index a9398ac..4b66fbe 100644 --- a/corda/config/static-network-config.json +++ b/corda/config/static-network-config.json @@ -1,23 +1,23 @@ [ { - "x500Name" : "CN=Alice, OU=Player, O=Checkers, L=Zug, C=CH", + "x500Name" : "CN=Alice, OU=Checkers, O=Corda, L=Zug, C=CH", "cpi" : "CordaCheckers" }, { - "x500Name" : "CN=Bobik, OU=Player, O=Checkers, L=Kyiv, C=UA", + "x500Name" : "CN=Bobik, OU=Checkers, O=Corda, L=Zug, C=CH", "cpi" : "CordaCheckers" }, { - "x500Name" : "CN=Kumar, OU=Player, O=Checkers, L=Mumbai, C=IN", + "x500Name" : "CN=Kumar, OU=Checkers, O=Corda, L=Zug, C=CH", "cpi" : "CordaCheckers" }, { - "x500Name" : "CN=Eva, OU=Custodian, O=Checkers, L=Rotkreuz, C=CH", + "x500Name" : "CN=Custodian, OU=Checkers, O=Corda, L=Zug, C=CH", "cpi" : "CordaCheckers" }, { - "x500Name" : "CN=NotaryRep1, OU=Notary, O=Checkers, L=Rotkreuz, C=CH", + "x500Name" : "CN=NotaryRep1, OU=Checkers, O=Corda, L=Zug, C=CH", "cpi" : "NotaryServer", - "serviceX500Name" : "CN=Djmil, OU=Notary, O=Checkers, L=Rotkreuz, C=CH" + "serviceX500Name" : "CN=NotaryService, OU=Checkers, O=Corda, L=Zug, C=CH" } ] diff --git a/corda/workflows/src/main/java/djmil/cordacheckers/VNode.java b/corda/workflows/src/main/java/djmil/cordacheckers/VNode.java index a6203a4..bb45c8b 100644 --- a/corda/workflows/src/main/java/djmil/cordacheckers/VNode.java +++ b/corda/workflows/src/main/java/djmil/cordacheckers/VNode.java @@ -7,33 +7,26 @@ import net.corda.v5.membership.MemberInfo; import net.corda.v5.membership.NotaryInfo; public class VNode { - static final String CHECKERS = "Checkers"; // O aka Organization - static final String PLAYER = "Player"; // OU aka OrganizationUnit - static final String CUSTODIAN = "Custodian"; // OU aka OrganizationUnit - static final String NOTARY = "Notary"; // OU aka OrganizationUnit + static final String CUSTODIAN = "Custodian"; + static final String NOTARY = "NotaryService"; @CordaInject MemberLookup memberLookup; public static boolean isCordaCherckersPlayer(MemberInfo memberInfo) { - final MemberX500Name memberName = memberInfo.getName(); - - return memberName.getOrganization().equals(CHECKERS) && - memberName.getOrganizationUnit().equals(PLAYER); + return !isCordaCherckersCustodian(memberInfo); } public static boolean isCordaCherckersCustodian(MemberInfo memberInfo) { final MemberX500Name memberName = memberInfo.getName(); - return memberName.getOrganization().equals(CHECKERS) && - memberName.getOrganizationUnit().equals(CUSTODIAN); + return memberName.getCommonName().equals(CUSTODIAN); } public static boolean isCordaCherckersNotary(NotaryInfo notaryInfo) { final MemberX500Name memberName = notaryInfo.getName(); - return memberName.getOrganization().equals(CHECKERS) && - memberName.getOrganizationUnit().equals(NOTARY); + return memberName.getCommonName().equals(NOTARY); } } diff --git a/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/CommitTrxResponder.java b/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/CommitTrxResponder.java index f6b37be..ae8d8a5 100644 --- a/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/CommitTrxResponder.java +++ b/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/CommitTrxResponder.java @@ -3,6 +3,7 @@ package djmil.cordacheckers.gamestate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import djmil.cordacheckers.VNode; import djmil.cordacheckers.contracts.GameInfo; import net.corda.v5.application.flows.CordaInject; import net.corda.v5.application.flows.InitiatedBy; @@ -62,11 +63,11 @@ public class CommitTrxResponder implements ResponderFlow { if (info.issuer.compareTo(conterpartyName) != 0) throw new ParticipantException("Issuer", conterpartyName, info.issuer); - final var myName = memberLookup.myInfo().getName(); - if (myName.getOrganizationUnit().equals("Custodian")) + final var myInfo = memberLookup.myInfo(); + if (VNode.isCordaCherckersCustodian(myInfo)) return; // Custodian shall not validate state's counterparty - - final var opponentName = info.state.getOpponentName(myName); // throws NotInvolved + + final var opponentName = info.state.getOpponentName(myInfo.getName()); // throws NotInvolved if (conterpartyName.compareTo(opponentName) != 0) throw new ParticipantException("Opponent", conterpartyName, opponentName); }