private void getTLSCerts(String nodeName, JsonObject jsonOrderer, Properties props) { JsonObject jsonTlsCaCerts = getJsonObject(jsonOrderer, "tlsCACerts"); if (jsonTlsCaCerts != null) { String pemFilename = getJsonValueAsString(jsonTlsCaCerts.get("path")); String pemBytes = getJsonValueAsString(jsonTlsCaCerts.get("pem")); if (pemFilename != null) { // let the sdk handle non existing errors could be they don't exist during parsing but are there later. props.put("pemFile", pemFilename); } if (pemBytes != null) { props.put("pemBytes", pemBytes.getBytes()); } } }
private static String getJsonValue(JsonValue value) { String s = null; if (value != null) { s = getJsonValueAsString(value); if (s == null) { s = getJsonValueAsNumberString(value); } if (s == null) { Boolean b = getJsonValueAsBoolean(value); if (b != null) { s = b ? "true" : "false"; } } } return s; }
private static String extractPemString(JsonObject json, String fieldName, String msgPrefix) throws NetworkConfigurationException { String path = null; String pemString = null; JsonObject jsonField = getJsonValueAsObject(json.get(fieldName)); if (jsonField != null) { path = getJsonValueAsString(jsonField.get("path")); pemString = getJsonValueAsString(jsonField.get("pem")); } if (path != null && pemString != null) { throw new NetworkConfigurationException(format("%s should not specify both %s path and pem", msgPrefix, fieldName)); } if (path != null) { // Determine full pathname and ensure the file exists File pemFile = new File(path); String fullPathname = pemFile.getAbsolutePath(); if (!pemFile.exists()) { throw new NetworkConfigurationException(format("%s: %s file %s does not exist", msgPrefix, fieldName, fullPathname)); } try (FileInputStream stream = new FileInputStream(pemFile)) { pemString = IOUtils.toString(stream, "UTF-8"); } catch (IOException ioe) { throw new NetworkConfigurationException(format("Failed to read file: %s", fullPathname), ioe); } } return pemString; }
private CAInfo createCA(String name, JsonObject jsonCA, OrgInfo org) throws NetworkConfigurationException { String url = getJsonValueAsString(jsonCA.get("url")); Properties httpOptions = extractProperties(jsonCA, "httpOptions"); enrollId = getJsonValueAsString(reg.get("enrollId")); enrollSecret = getJsonValueAsString(reg.get("enrollSecret")); try { regUsers.add(new UserInfo(CryptoSuite.Factory.getCryptoSuite(), org.mspId, enrollId, enrollSecret)); String caName = getJsonValueAsString(jsonCA.get("caName")); if (caName != null) { caInfo.setCaName(caName);
private NetworkConfig(JsonObject jsonConfig) throws InvalidArgumentException, NetworkConfigurationException { this.jsonConfig = jsonConfig; // Extract the main details String configName = getJsonValueAsString(jsonConfig.get("name")); if (configName == null || configName.isEmpty()) { throw new InvalidArgumentException("Network config must have a name"); } String configVersion = getJsonValueAsString(jsonConfig.get("version")); if (configVersion == null || configVersion.isEmpty()) { throw new InvalidArgumentException("Network config must have a version"); // TODO: Validate the version } // Preload and create all peers, orderers, etc createAllPeers(); createAllOrderers(); Map<String, JsonObject> foundCertificateAuthorities = findCertificateAuthorities(); //createAllCertificateAuthorities(); createAllOrganizations(foundCertificateAuthorities); // Validate the organization for this client JsonObject jsonClient = getJsonObject(jsonConfig, "client"); String orgName = jsonClient == null ? null : getJsonValueAsString(jsonClient.get("organization")); if (orgName == null || orgName.isEmpty()) { throw new InvalidArgumentException("A client organization must be specified"); } clientOrganization = getOrganizationInfo(orgName); if (clientOrganization == null) { throw new InvalidArgumentException("Client organization " + orgName + " is not defined"); } }
String mspId = getJsonValueAsString(jsonOrg.get("mspid")); if (jsonPeers != null) { for (JsonValue peer : jsonPeers) { String peerName = getJsonValueAsString(peer); if (peerName != null) { org.addPeerName(peerName); for (JsonValue jsonCA : jsonCertificateAuthorities) { String caName = getJsonValueAsString(jsonCA);
for (JsonValue jsonVal : ordererNames) { String ordererName = getJsonValueAsString(jsonVal); Orderer orderer = getOrderer(client, ordererName); if (orderer == null) {
private void getTLSCerts(String nodeName, JsonObject jsonOrderer, Properties props) { JsonObject jsonTlsCaCerts = getJsonObject(jsonOrderer, "tlsCACerts"); if (jsonTlsCaCerts != null) { String pemFilename = getJsonValueAsString(jsonTlsCaCerts.get("path")); String pemBytes = getJsonValueAsString(jsonTlsCaCerts.get("pem")); if (pemFilename != null) { // let the sdk handle non existing errors could be they don't exist during parsing but are there later. props.put("pemFile", pemFilename); } if (pemBytes != null) { props.put("pemBytes", pemBytes.getBytes()); } } }
private void getTLSCerts(String nodeName, JsonObject jsonOrderer, Properties props) { JsonObject jsonTlsCaCerts = getJsonObject(jsonOrderer, "tlsCACerts"); if (jsonTlsCaCerts != null) { String pemFilename = getJsonValueAsString(jsonTlsCaCerts.get("path")); String pemBytes = getJsonValueAsString(jsonTlsCaCerts.get("pem")); if (pemFilename != null) { // let the sdk handle non existing errors could be they don't exist during parsing but are there later. props.put("pemFile", pemFilename); } if (pemBytes != null) { props.put("pemBytes", pemBytes.getBytes()); } } }
private static String getJsonValue(JsonValue value) { String s = null; if (value != null) { s = getJsonValueAsString(value); if (s == null) { s = getJsonValueAsNumberString(value); } if (s == null) { Boolean b = getJsonValueAsBoolean(value); if (b != null) { s = b ? "true" : "false"; } } } return s; }
private static String getJsonValue(JsonValue value) { String s = null; if (value != null) { s = getJsonValueAsString(value); if (s == null) { s = getJsonValueAsNumberString(value); } if (s == null) { Boolean b = getJsonValueAsBoolean(value); if (b != null) { s = b ? "true" : "false"; } } } return s; }
private static String extractPemString(JsonObject json, String fieldName, String msgPrefix) throws NetworkConfigurationException { String path = null; String pemString = null; JsonObject jsonField = getJsonValueAsObject(json.get(fieldName)); if (jsonField != null) { path = getJsonValueAsString(jsonField.get("path")); pemString = getJsonValueAsString(jsonField.get("pem")); } if (path != null && pemString != null) { throw new NetworkConfigurationException(format("%s should not specify both %s path and pem", msgPrefix, fieldName)); } if (path != null) { // Determine full pathname and ensure the file exists File pemFile = new File(path); String fullPathname = pemFile.getAbsolutePath(); if (!pemFile.exists()) { throw new NetworkConfigurationException(format("%s: %s file %s does not exist", msgPrefix, fieldName, fullPathname)); } try (FileInputStream stream = new FileInputStream(pemFile)) { pemString = IOUtils.toString(stream, "UTF-8"); } catch (IOException ioe) { throw new NetworkConfigurationException(format("Failed to read file: %s", fullPathname), ioe); } } return pemString; }
private static String extractPemString(JsonObject json, String fieldName, String msgPrefix) throws NetworkConfigurationException { String path = null; String pemString = null; JsonObject jsonField = getJsonValueAsObject(json.get(fieldName)); if (jsonField != null) { path = getJsonValueAsString(jsonField.get("path")); pemString = getJsonValueAsString(jsonField.get("pem")); } if (path != null && pemString != null) { throw new NetworkConfigurationException(format("%s should not specify both %s path and pem", msgPrefix, fieldName)); } if (path != null) { // Determine full pathname and ensure the file exists File pemFile = new File(path); String fullPathname = pemFile.getAbsolutePath(); if (!pemFile.exists()) { throw new NetworkConfigurationException(format("%s: %s file %s does not exist", msgPrefix, fieldName, fullPathname)); } try (FileInputStream stream = new FileInputStream(pemFile)) { pemString = IOUtils.toString(stream, "UTF-8"); } catch (IOException ioe) { throw new NetworkConfigurationException(format("Failed to read file: %s", fullPathname), ioe); } } return pemString; }
private CAInfo createCA(String name, JsonObject jsonCA, OrgInfo org) throws NetworkConfigurationException { String url = getJsonValueAsString(jsonCA.get("url")); Properties httpOptions = extractProperties(jsonCA, "httpOptions"); String enrollId = null; String enrollSecret = null; List<JsonObject> registrars = getJsonValueAsList(jsonCA.get("registrar")); List<UserInfo> regUsers = new LinkedList<>(); if (registrars != null) { for (JsonObject reg : registrars) { enrollId = getJsonValueAsString(reg.get("enrollId")); enrollSecret = getJsonValueAsString(reg.get("enrollSecret")); regUsers.add(new UserInfo(org.mspId, enrollId, enrollSecret)); } } CAInfo caInfo = new CAInfo(name, org.mspId, url, regUsers, httpOptions); String caName = getJsonValueAsString(jsonCA.get("caName")); if (caName != null) { caInfo.setCaName(caName); } Properties properties = new Properties(); if (null != httpOptions && "false".equals(httpOptions.getProperty("verify"))) { properties.setProperty("allowAllHostNames", "true"); } getTLSCerts(name, jsonCA, properties); caInfo.setProperties(properties); return caInfo; }
private CAInfo createCA(String name, JsonObject jsonCA, OrgInfo org) throws NetworkConfigurationException { String url = getJsonValueAsString(jsonCA.get("url")); Properties httpOptions = extractProperties(jsonCA, "httpOptions"); enrollId = getJsonValueAsString(reg.get("enrollId")); enrollSecret = getJsonValueAsString(reg.get("enrollSecret")); try { regUsers.add(new UserInfo(CryptoSuite.Factory.getCryptoSuite(), org.mspId, enrollId, enrollSecret)); String caName = getJsonValueAsString(jsonCA.get("caName")); if (caName != null) { caInfo.setCaName(caName);
private NetworkConfig(JsonObject jsonConfig) throws InvalidArgumentException, NetworkConfigurationException { this.jsonConfig = jsonConfig; // Extract the main details String configName = getJsonValueAsString(jsonConfig.get("name")); if (configName == null || configName.isEmpty()) { throw new InvalidArgumentException("Network config must have a name"); } String configVersion = getJsonValueAsString(jsonConfig.get("version")); if (configVersion == null || configVersion.isEmpty()) { throw new InvalidArgumentException("Network config must have a version"); // TODO: Validate the version } // Preload and create all peers, orderers, etc createAllPeers(); createAllOrderers(); Map<String, JsonObject> foundCertificateAuthorities = findCertificateAuthorities(); //createAllCertificateAuthorities(); createAllOrganizations(foundCertificateAuthorities); // Validate the organization for this client JsonObject jsonClient = getJsonObject(jsonConfig, "client"); String orgName = jsonClient == null ? null : getJsonValueAsString(jsonClient.get("organization")); if (orgName == null || orgName.isEmpty()) { throw new InvalidArgumentException("A client organization must be specified"); } clientOrganization = getOrganizationInfo(orgName); if (clientOrganization == null) { throw new InvalidArgumentException("Client organization " + orgName + " is not defined"); } }
private NetworkConfig(JsonObject jsonConfig) throws InvalidArgumentException, NetworkConfigurationException { this.jsonConfig = jsonConfig; // Extract the main details String configName = getJsonValueAsString(jsonConfig.get("name")); if (configName == null || configName.isEmpty()) { throw new InvalidArgumentException("Network config must have a name"); } String configVersion = getJsonValueAsString(jsonConfig.get("version")); if (configVersion == null || configVersion.isEmpty()) { throw new InvalidArgumentException("Network config must have a version"); // TODO: Validate the version } // Preload and create all peers, orderers, etc createAllPeers(); createAllOrderers(); Map<String, JsonObject> foundCertificateAuthorities = findCertificateAuthorities(); //createAllCertificateAuthorities(); createAllOrganizations(foundCertificateAuthorities); // Validate the organization for this client JsonObject jsonClient = getJsonObject(jsonConfig, "client"); String orgName = jsonClient == null ? null : getJsonValueAsString(jsonClient.get("organization")); if (orgName == null || orgName.isEmpty()) { throw new InvalidArgumentException("A client organization must be specified"); } clientOrganization = getOrganizationInfo(orgName); if (clientOrganization == null) { throw new InvalidArgumentException("Client organization " + orgName + " is not defined"); } }
String mspId = getJsonValueAsString(jsonOrg.get("mspid")); if (jsonPeers != null) { for (JsonValue peer : jsonPeers) { String peerName = getJsonValueAsString(peer); if (peerName != null) { org.addPeerName(peerName); for (JsonValue jsonCA : jsonCertificateAuthorities) { String caName = getJsonValueAsString(jsonCA);
String mspId = getJsonValueAsString(jsonOrg.get("mspid")); if (jsonPeers != null) { for (JsonValue peer : jsonPeers) { String peerName = getJsonValueAsString(peer); if (peerName != null) { org.addPeerName(peerName); for (JsonValue jsonCA : jsonCertificateAuthorities) { String caName = getJsonValueAsString(jsonCA);
for (JsonValue jsonVal : ordererNames) { String ordererName = getJsonValueAsString(jsonVal); Orderer orderer = getOrderer(client, ordererName); if (orderer == null) {