public void fromYamlFile ( File yamlPolicyFile ) throws IOException , ChaincodeEndorsementPolicyParseException { final Yaml yaml = new Yaml ( ) ; final Map < ? , ? > load = ( Map < ? , ? > ) yaml . load ( new FileInputStream ( yamlPolicyFile ) ) ; Map < ? , ? > mp = ( Map < ? , ? > ) load . get ( "policy" ) ; if ( null == mp ) { throw new ChaincodeEndorsementPolicyParseException ( "The policy file has no policy section" ) ; } IndexedHashMap < String , MSPPrincipal > identities = parseIdentities ( ( Map < ? , ? > ) load . get ( "identities" ) ) ; SignaturePolicy sp = parsePolicy ( identities , mp ) ; policyBytes = Policies . SignaturePolicyEnvelope . newBuilder ( ) . setVersion ( 0 ) . addAllIdentities ( identities . values ( ) ) . setRule ( sp ) . build ( ) . toByteArray ( ) ; }
From a yaml file