/** * From a yaml file * * @param yamlPolicyFile File location for the chaincode endorsement policy specification. * @throws IOException * @throws ChaincodeEndorsementPolicyParseException */ public void FromYamlFile(string yamlPolicyFile) { IDeserializer nl = new DeserializerBuilder().Build(); Dictionary <object, object> bld = (Dictionary <object, object>)nl.Deserialize(new StreamReader(File.OpenRead(yamlPolicyFile))); var mpy = (Dictionary <object, object>)bld.GetOrNull("policy"); if (null == mpy) { throw new ChaincodeEndorsementPolicyParseException("The policy file has no policy section"); } Dictionary <object, object> idsp = (Dictionary <object, object>)bld.GetOrNull("identities"); if (null == idsp) { throw new ChaincodeEndorsementPolicyParseException("The policy file has no identities section"); } IndexedHashMap <string, MSPPrincipal> identities = ParseIdentities(idsp); SignaturePolicy sp = ParsePolicy(identities, mpy); SignaturePolicyEnvelope env = new SignaturePolicyEnvelope { Rule = sp, Version = 0 }; env.Identities.AddRange(identities.Values); ChaincodeEndorsementPolicyAsBytes = env.ToByteArray(); }
public byte[] Policy() { SignaturePolicyEnvelope spe = PolicyFromMSPIDs(); return(spe.ToByteArray()); }