• teague_dai
    了解作者
  • GO
    开发工具
  • 63KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 10 积分
    下载积分
  • 0
    下载次数
  • 2020-08-30 10:55
    上传日期
Fabcar,不推荐使用基本资产转让示例
fabcar.zip
内容介绍
/* SPDX-License-Identifier: Apache-2.0 */ package org.example; import java.nio.file.Paths; import java.security.PrivateKey; import java.util.Properties; import java.util.Set; import org.hyperledger.fabric.gateway.Wallet; import org.hyperledger.fabric.gateway.Wallets; import org.hyperledger.fabric.gateway.Identities; import org.hyperledger.fabric.gateway.Identity; import org.hyperledger.fabric.gateway.X509Identity; import org.hyperledger.fabric.sdk.Enrollment; import org.hyperledger.fabric.sdk.User; import org.hyperledger.fabric.sdk.security.CryptoSuite; import org.hyperledger.fabric.sdk.security.CryptoSuiteFactory; import org.hyperledger.fabric_ca.sdk.HFCAClient; import org.hyperledger.fabric_ca.sdk.RegistrationRequest; public class RegisterUser { static { System.setProperty("org.hyperledger.fabric.sdk.service_discovery.as_localhost", "true"); } public static void main(String[] args) throws Exception { // Create a CA client for interacting with the CA. Properties props = new Properties(); props.put("pemFile", "../../test-network/organizations/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem"); props.put("allowAllHostNames", "true"); HFCAClient caClient = HFCAClient.createNewInstance("https://localhost:7054", props); CryptoSuite cryptoSuite = CryptoSuiteFactory.getDefault().getCryptoSuite(); caClient.setCryptoSuite(cryptoSuite); // Create a wallet for managing identities Wallet wallet = Wallets.newFileSystemWallet(Paths.get("wallet")); // Check to see if we've already enrolled the user. if (wallet.get("appUser") != null) { System.out.println("An identity for the user \"appUser\" already exists in the wallet"); return; } X509Identity adminIdentity = (X509Identity)wallet.get("admin"); if (adminIdentity == null) { System.out.println("\"admin\" needs to be enrolled and added to the wallet first"); return; } User admin = new User() { @Override public String getName() { return "admin"; } @Override public Set<String> getRoles() { return null; } @Override public String getAccount() { return null; } @Override public String getAffiliation() { return "org1.department1"; } @Override public Enrollment getEnrollment() { return new Enrollment() { @Override public PrivateKey getKey() { return adminIdentity.getPrivateKey(); } @Override public String getCert() { return Identities.toPemString(adminIdentity.getCertificate()); } }; } @Override public String getMspId() { return "Org1MSP"; } }; // Register the user, enroll the user, and import the new identity into the wallet. RegistrationRequest registrationRequest = new RegistrationRequest("appUser"); registrationRequest.setAffiliation("org1.department1"); registrationRequest.setEnrollmentID("appUser"); String enrollmentSecret = caClient.register(registrationRequest, admin); Enrollment enrollment = caClient.enroll("appUser", enrollmentSecret); Identity user = Identities.newX509Identity("Org1MSP", adminIdentity.getCertificate(), adminIdentity.getPrivateKey()); wallet.put("appUser", user); System.out.println("Successfully enrolled user \"appUser\" and imported it into the wallet"); } }
评论
    相关推荐
    • hyperledger-fabric-desktop:general-purpose hyperledger-fabric de
      Hyperledger Fabric桌面 Hyperledger Fabric Desktop是一个开箱即用的桌面应用程序,旨在帮助人们轻松使用和管理Fabric网络。 主要特点 跨平台:适用于Windows,Mac和Linux。 易于安装。 用户友好的GUI:易于使用。...
    • hyperledger-fabric
      超级账本织物 Hyperledger Fabric 2.2版课程信息(2021年5月)
    • hyperledger fabric 1.2.0版本.rar
      Hyperledge fabric 环境搭建需要的2个二进制文件,1.2.0版本的(包含:hyperledger-fabric-linux-amd64-1.2.0.tar.gz 和 hyperledger-fabric-ca-linux-amd64-1.2.0.tar),官方下载,哇~~,真是慢的要死啦。...
    • gohfc:Go编写的Hyperledger Fabric SDK
      GOHFC-Golang Hyperledger Fabric客户端 这是使用最低要求以纯Golang编写的Hyperledger Fabric的SDK。 这不是官方的SDK,也不遵循Hyperledger团队提供的官方SDK API准则。 有关官方SDK的列表,请参考官方Hyperledger...
    • hyperledger fabric nodejs
      超级账本fabric nodejs接口程序,参考fabric-samples实例
    • Hyperledger Fabric 源码 例子 依赖工具
      Hyperledger Fabric 源码 例子 依赖工具 其中包含自动搭建开发环境脚本
    • hyperledger-fabric环境
      hyperledger-fabric1.0搭建好的环境,里面有bin文件夹,以及其他生成的文件
    • generator-fabric:Hyperledger Fabric的Yeoman生成器
      Hyperledger Fabric的Yeoman生成器。 该Yeoman生成器可用于生成Hyperledger Fabric的链码或智能合约。 可以生成用Go或JavaScript编写的链码,同时还提供实验性TypeScript支持。 安装 您必须安装Yeoman,这很容易: ...
    • hyperledger-fabricHyperledger结构
      Hyperledger Fabric 1.4.0 先决条件 帕拉facilitar,disponibilizei OS comandosnecessários对configurarØAMBIENTE德desenvolvimento,MAS recomendo fortemente阙acesse对SE familiarizar COM口requisitosbá...