public static IdemixRoles ToIdemixRole(this MSPRole.Types.MSPRoleType role) { if (role < MSPRole.Types.MSPRoleType.Member || role > MSPRole.Types.MSPRoleType.Peer) { throw new ArgumentException("The provided role is not valid: " + role); } return((IdemixRoles)(1 << (int)role)); }
/** * Creates a {@link SignaturePolicyEnvelope} * requiring 1 signature from any fabric entity, having the passed role, of the specified MSP * * @param mspId * @param role * @return */ public static SignaturePolicyEnvelope SignedByFabricEntity(string mspId, MSPRole.Types.MSPRoleType role) { // specify the principal: it's a member of the msp we just found MSPPrincipal principal = new MSPPrincipal { PrincipalClassification = MSPPrincipal.Types.Classification.Role, Principal = new MSPRole { MspIdentifier = mspId, Role = role }.ToByteString() }; SignaturePolicyEnvelope spe = new SignaturePolicyEnvelope { Version = 0, Rule = NOutOf(1, new List <SignaturePolicy> { SignedBy(0) }) }; spe.Identities.Add(principal); return(spe); }