diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8c95b08 --- /dev/null +++ b/.gitignore @@ -0,0 +1,83 @@ +# Created by https://www.gitignore.io/api/intellij + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + + +# End of https://www.gitignore.io/api/intellij \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..3f8ab6c --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..b26911b --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..4b661a5 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/msp/org1/User-org1.context b/msp/org1/User-org1.context new file mode 100644 index 0000000..0dbf1f5 Binary files /dev/null and b/msp/org1/User-org1.context differ diff --git a/msp/org1/admin.context b/msp/org1/admin.context new file mode 100644 index 0000000..7511448 Binary files /dev/null and b/msp/org1/admin.context differ diff --git a/msp/toto/abdel.context b/msp/toto/abdel.context new file mode 100644 index 0000000..95e9850 Binary files /dev/null and b/msp/toto/abdel.context differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..41e27e1 --- /dev/null +++ b/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + + com.monnethic + java-api + 0.1 + + + org.springframework.boot + spring-boot-starter-parent + 1.5.9.RELEASE + + + + + + + + org.hyperledger.fabric-sdk-java + fabric-sdk-java + 1.2.1 + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + + + + log4j + log4j + 1.2.17 + + + junit + junit + 4.12 + + + + + + org.bouncycastle + bcprov-jdk15on + 1.60 + + + + + + 1.8 + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/src/main/java/Application/App.java b/src/main/java/Application/App.java new file mode 100644 index 0000000..41421ed --- /dev/null +++ b/src/main/java/Application/App.java @@ -0,0 +1,31 @@ +package Application; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; + +import java.util.Arrays; +import java.util.Collections; + +@SpringBootApplication +public class App { + public static void main(String [ ] args){ + SpringApplication app = new SpringApplication(App.class); + app.setDefaultProperties(Collections.singletonMap("server.port","8083")); + app.run(args); + } + + @Bean + public CommandLineRunner commandLineRunner(ApplicationContext ctx){ + return args -> { + System.out.println("Spring Boot:"); + String[] beanNames = ctx.getBeanDefinitionNames(); + Arrays.sort(beanNames); + for (String beanName : beanNames) { + System.out.println(beanName); + } + }; + } +} diff --git a/src/main/java/blockchain/client/CAClientWrapper.java b/src/main/java/blockchain/client/CAClientWrapper.java new file mode 100644 index 0000000..fbfdd24 --- /dev/null +++ b/src/main/java/blockchain/client/CAClientWrapper.java @@ -0,0 +1,105 @@ +package blockchain.client; + +import blockchain.user.UserContext; +import blockchain.utility.Util; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; +import org.hyperledger.fabric.sdk.Enrollment; +import org.hyperledger.fabric.sdk.exception.CryptoException; +import org.hyperledger.fabric.sdk.exception.InvalidArgumentException; +import org.hyperledger.fabric.sdk.security.CryptoSuite; +import org.hyperledger.fabric_ca.sdk.HFCAClient; +import org.hyperledger.fabric_ca.sdk.RegistrationRequest; + +import java.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.util.Properties; + +public class CAClientWrapper { + private static Logger logger = Logger.getLogger(CAClientWrapper.class); + private String caUrl; + private Properties properties; + private HFCAClient hfcaClient; + private UserContext adminContext; + + public void setAdminContext(UserContext adminContext) { this.adminContext = adminContext; } + + public UserContext getAdminContext(){ return adminContext; } + + public HFCAClient getHfcaClient(){ + return hfcaClient; + } + + public CAClientWrapper(String caUrl, Properties properties) throws MalformedURLException, IllegalAccessException, InstantiationException, ClassNotFoundException, CryptoException, InvalidArgumentException, NoSuchMethodException, InvocationTargetException { + this.caUrl=caUrl; + this.properties=properties; + init(); + } + + private void init() throws MalformedURLException, IllegalAccessException, InstantiationException, ClassNotFoundException, CryptoException, InvalidArgumentException, NoSuchMethodException, InvocationTargetException { + BasicConfigurator.configure(); + CryptoSuite cryptoSuite = CryptoSuite.Factory.getCryptoSuite(); + hfcaClient = HFCAClient.createNewInstance(caUrl, properties); + hfcaClient.setCryptoSuite(cryptoSuite); + } + + public UserContext enrollAdmin(String username, String password, String affiliation) throws Exception{ + BasicConfigurator.configure(); + UserContext checkAdmin; + checkAdmin = Util.readUserContext(affiliation, username); + + //SANITY CHECK + if(adminContext.getName().isEmpty()) throw new NullPointerException(); + + if(checkAdmin!=null){ + logger.warn("Admin already enrolled, skip"); + return checkAdmin; + } + + logger.info("Try hfcaClient.enroll"); + Enrollment enrollment = hfcaClient.enroll(username,password); + + logger.info("Admin enrolled"); + adminContext.setEnrollment(enrollment); + + logger.info("Write admin in msp directory"); + Util.writeUserContext(adminContext); + return adminContext; + } + + //Method to register an User + public String registerUser(String username, String organization) throws Exception { + UserContext userContext = Util.readUserContext(organization, username); + if (userContext!=null){ + logger.warn("User already registered"); + return null; + } + RegistrationRequest rr = new RegistrationRequest(username,organization); + logger.info("registrar is : "+adminContext.getName()); + String enrollementSecret = hfcaClient.register(rr,adminContext); + logger.info("User registered"); + return enrollementSecret; + } + + //Method to enroll an User + public UserContext enrollUser(UserContext userContext, String secret) throws Exception{ + UserContext uContext = Util.readUserContext(userContext.getAffiliation(),userContext.getName()); + if(uContext!=null){ + logger.warn("User already enrolled"); + return uContext; + } + Enrollment enrollment = hfcaClient.enroll(userContext.getName(),secret); + userContext.setEnrollment(enrollment); + Util.writeUserContext(userContext); + logger.info("User enrolled"); + return userContext; + } + + //Method to revoke an User + public void revokeUser(UserContext admin, Enrollment userEnrollement, String reason) throws Exception{ + hfcaClient.revoke(admin,userEnrollement,reason); + } + + + +} diff --git a/src/main/java/blockchain/client/ChannelClientWrapper.java b/src/main/java/blockchain/client/ChannelClientWrapper.java new file mode 100644 index 0000000..4e84469 --- /dev/null +++ b/src/main/java/blockchain/client/ChannelClientWrapper.java @@ -0,0 +1,99 @@ +package blockchain.client; + + +import blockchain.configuration.Config; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; +import org.hyperledger.fabric.sdk.*; +import org.hyperledger.fabric.sdk.exception.InvalidArgumentException; +import org.hyperledger.fabric.sdk.exception.ProposalException; +import org.hyperledger.fabric.sdk.exception.TransactionException; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +public class ChannelClientWrapper { + private String name; + static private Channel channel; + private FabricClientWrapper fabricClientWrapper; + + public String getName(){ + return name; + } + + public Channel getChannel(){ + return channel; + } + + public FabricClientWrapper getFabricClientWrapper(){ + return fabricClientWrapper; + } + + public ChannelClientWrapper(String name, Channel channel, FabricClientWrapper fabricClientWrapper){ + this.name=name; + this.channel=channel; + this.fabricClientWrapper=fabricClientWrapper; + } + + public Collection queryByChainCode(String chaincodeName,String fuctionName, String[] args) throws InvalidArgumentException, ProposalException { + QueryByChaincodeRequest request = fabricClientWrapper.getClient().newQueryProposalRequest(); + ChaincodeID chaincodeID = ChaincodeID.newBuilder().setName(chaincodeName).build(); + request.setChaincodeID(chaincodeID); + request.setFcn(fuctionName); + if(args != null){ + request.setArgs(args); + } + + Collection response = channel.queryByChaincode(request); + + return response; + } + + //Method to init the channel for query + static public ChannelClientWrapper setupChannel(FabricClientWrapper fabricClientWrapper) throws InvalidArgumentException, TransactionException { + + ChannelClientWrapper channelClientWrapper = fabricClientWrapper.createChannelClient(Config.CHANNEL_NAME); + + channel = channelClientWrapper.getChannel(); + Peer peer = fabricClientWrapper.getClient().newPeer(Config.ORG1_PEER_0,Config.ORG1_PEER_0_URL); + EventHub eventHub = fabricClientWrapper.getClient().newEventHub("eventhub01", "grpc://vps577432.ovh.net:8053"); + Orderer orderer = fabricClientWrapper.getClient().newOrderer(Config.ORDERER_NAME,Config.ORDERER_URL); + channel.addPeer(peer); + channel.addEventHub(eventHub); + channel.addOrderer(orderer); + channel.initialize(); + + return channelClientWrapper; + } + + //Wrapper for channel.sendTransactionProposal + public Collection sendTransactionProposal (TransactionProposalRequest transactionProposalRequest){ + try{ + return channel.sendTransactionProposal(transactionProposalRequest); + }catch (Exception e){ + e.printStackTrace(); + return null; + } + } + + //Wrapper for channel.sendTransaction + public BlockEvent.TransactionEvent sendTransaction(Collection proposalResponses){ + Logger logger = Logger.getLogger(ChannelClientWrapper.class); + BasicConfigurator.configure(); + try{ + + List invalid = proposalResponses.stream().filter(r -> r.isInvalid()).collect(Collectors.toList()); + if (!invalid.isEmpty()) { + invalid.forEach(response -> { + logger.error(response.getMessage()); + }); + } + + return channel.sendTransaction(proposalResponses).get(); + }catch (Exception e){ + e.printStackTrace(); + return null; + } + } + +} \ No newline at end of file diff --git a/src/main/java/blockchain/client/FabricClientWrapper.java b/src/main/java/blockchain/client/FabricClientWrapper.java new file mode 100644 index 0000000..30b7cb4 --- /dev/null +++ b/src/main/java/blockchain/client/FabricClientWrapper.java @@ -0,0 +1,43 @@ +package blockchain.client; + +import blockchain.configuration.Config; +import blockchain.user.UserContext; +import org.hyperledger.fabric.sdk.*; +import org.hyperledger.fabric.sdk.exception.CryptoException; +import org.hyperledger.fabric.sdk.exception.InvalidArgumentException; +import org.hyperledger.fabric.sdk.exception.ProposalException; +import org.hyperledger.fabric.sdk.exception.TransactionException; +import org.hyperledger.fabric.sdk.security.CryptoSuite; + +import java.lang.reflect.InvocationTargetException; +import java.util.Set; + +public class FabricClientWrapper { + private HFClient client; + + public HFClient getClient(){ + return client; + } + + public FabricClientWrapper(UserContext userContext) throws CryptoException, InvalidArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException { + CryptoSuite cryptoSuite = CryptoSuite.Factory.getCryptoSuite(); + client = HFClient.createNewInstance(); + client.setCryptoSuite(cryptoSuite); + client.setUserContext(userContext); + } + + public ChannelClientWrapper createChannelClient(String name) throws InvalidArgumentException { + Channel channel = client.newChannel(name); + ChannelClientWrapper channelClientWrapper = new ChannelClientWrapper(name, channel, this); + return channelClientWrapper; + } + + public Set queryForChannels() throws InvalidArgumentException, IllegalArgumentException, ProposalException { + client.newChannel(Config.CHANNEL_NAME); + client.newOrderer(Config.ORDERER_NAME,Config.ORDERER_URL); + //Peer peer = client.newPeer(Config.ORG_PEER,Config.ORG_PEER_URL); + Peer peer = client.newPeer(Config.ORG1_PEER_0,Config.ORG1_PEER_0_URL); + return client.queryChannels(peer); + } + +} diff --git a/src/main/java/blockchain/configuration/Config.java b/src/main/java/blockchain/configuration/Config.java new file mode 100644 index 0000000..f9b46b0 --- /dev/null +++ b/src/main/java/blockchain/configuration/Config.java @@ -0,0 +1,51 @@ +package blockchain.configuration; + +public class Config { + + //ORGANIZATION + public static final String ORG1_MSP = "Org1MSP"; + + public static final String ORG1 = "org1"; + + //ADMIN + public static final String ADMIN = "admin"; + + public static final String ADMIN_PASSWORD = "adminpw"; + + //USER + public static final String UserPWD = "ZIidLJHQbLcC"; + + //CA + public static final String CA_ORG1_URL = "http://vps577432.ovh.net:7054"; + + //ORDERER + public static final String ORDERER_URL = "grpc://vps577432.ovh.net:7050"; + + public static final String ORDERER_NAME = "orderer.example.com"; + + //CHANNEL - CHAINCODE + public static final String CHANNEL_NAME = "mychannel"; + + public static final String CHAINCODE_NAME = "mycc"; + + //PEER 0 + public static final String ORG1_PEER_0 = "peer0.org1.example.com"; + + public static final String ORG1_PEER_0_URL = "grpc://vps577432.ovh.net:8051"; + + //PEER 1 + public static final String ORG_PEER = "peer1.org1.example.com"; + + public static final String ORG_PEER_URL = "grpc://vps592802.ovh.net:9051"; + + //EVENTHUB + public static final String ORG_PEER_EVENT_URL = "grpc://vps592802.ovh.net:9053"; + + //ADMIN FILE TEST + public static final String ADMIN_FILE_PATH = "msp/AdminFiles"; + + public static final String ADMIN_KEY_PATH = ADMIN_FILE_PATH+"/keystore"; + + public static final String ADMIN_CERT_PATH = ADMIN_FILE_PATH+"/admincerts"; + +} diff --git a/src/main/java/blockchain/query/QueryWrapper.java b/src/main/java/blockchain/query/QueryWrapper.java new file mode 100644 index 0000000..8507b79 --- /dev/null +++ b/src/main/java/blockchain/query/QueryWrapper.java @@ -0,0 +1,53 @@ +package blockchain.query; + +import blockchain.client.ChannelClientWrapper; +import blockchain.client.FabricClientWrapper; +import blockchain.configuration.Config; +import blockchain.user.UserContext; +import blockchain.utility.Util; +import org.hyperledger.fabric.sdk.ChaincodeResponse; +import org.hyperledger.fabric.sdk.ProposalResponse; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class QueryWrapper { + + public String getUserBalance(String userHashId){ + String response = null; + try{ + UserContext userContext = Util.readUserContext(Config.ORG1,"User-org1"); + String chaincode = Config.CHAINCODE_NAME; + FabricClientWrapper fabricClientWrapper = new FabricClientWrapper(userContext); + + ChannelClientWrapper channelClientWrapper = ChannelClientWrapper.setupChannel(fabricClientWrapper); + + String[] args = {userHashId}; + + Collection responseQuery = channelClientWrapper.queryByChainCode(chaincode,"query",args); + for(ProposalResponse pres : responseQuery){ + ChaincodeResponse.Status status = pres.getStatus(); + if(status.getStatus()!=200){ + throw new Exception(pres.getMessage()); + } + + response = new String(pres.getChaincodeActionResponsePayload()); + } + }catch (Exception e){ + e.printStackTrace(); + } + + if(response==null) response = "Error"; + return response; + } + + public String getUser(String userHashId){ + return ""; + } + + public List getUserLastTransactions(String userHashId){ + List transactions = new ArrayList<>(); + return transactions; + } +} diff --git a/src/main/java/blockchain/query/TransactionWrapper.java b/src/main/java/blockchain/query/TransactionWrapper.java new file mode 100644 index 0000000..f1b62eb --- /dev/null +++ b/src/main/java/blockchain/query/TransactionWrapper.java @@ -0,0 +1,41 @@ +package blockchain.query; + +import blockchain.client.ChannelClientWrapper; +import blockchain.client.FabricClientWrapper; +import blockchain.configuration.Config; +import blockchain.user.UserContext; +import blockchain.utility.Util; +import org.hyperledger.fabric.sdk.BlockEvent; +import org.hyperledger.fabric.sdk.ChaincodeID; +import org.hyperledger.fabric.sdk.ProposalResponse; +import org.hyperledger.fabric.sdk.TransactionProposalRequest; + +import java.util.Collection; + +public class TransactionWrapper { + + public String sendTransaction(String from, String to, String amount){ + try{ + UserContext userContext = Util.readUserContext(Config.ORG1,"User-org1"); + String chaincode = Config.CHAINCODE_NAME; + FabricClientWrapper fabricClientWrapper = new FabricClientWrapper(userContext); + + ChannelClientWrapper channelClientWrapper = ChannelClientWrapper.setupChannel(fabricClientWrapper); + + TransactionProposalRequest tpr = fabricClientWrapper.getClient().newTransactionProposalRequest(); + ChaincodeID cid = ChaincodeID.newBuilder().setName(Config.CHAINCODE_NAME).build(); + tpr.setChaincodeID(cid); + tpr.setFcn("invoke"); + tpr.setArgs(new String[]{from,to,amount}); + + Collection responses = channelClientWrapper.sendTransactionProposal(tpr); + BlockEvent.TransactionEvent event = channelClientWrapper.sendTransaction(responses); + + return event.getTransactionID(); + + }catch (Exception e){ + e.printStackTrace(); + return null; + } + } +} diff --git a/src/main/java/blockchain/user/CAEnrollement.java b/src/main/java/blockchain/user/CAEnrollement.java new file mode 100644 index 0000000..f923bab --- /dev/null +++ b/src/main/java/blockchain/user/CAEnrollement.java @@ -0,0 +1,27 @@ +package blockchain.user; + +import org.hyperledger.fabric.sdk.Enrollment; + +import java.io.Serializable; +import java.security.PrivateKey; + +public class CAEnrollement implements Enrollment, Serializable { + private static final long serialVersionUID = 550416591376968096L; + private PrivateKey privateKey; + private String cert; + + public CAEnrollement(PrivateKey pkey, String signedPem){ + this.privateKey=pkey; + this.cert=signedPem; + } + + @Override + public PrivateKey getKey() { + return privateKey; + } + + @Override + public String getCert() { + return cert; + } +} diff --git a/src/main/java/blockchain/user/UserContext.java b/src/main/java/blockchain/user/UserContext.java new file mode 100644 index 0000000..47fa4dd --- /dev/null +++ b/src/main/java/blockchain/user/UserContext.java @@ -0,0 +1,72 @@ +package blockchain.user; + +import org.hyperledger.fabric.sdk.Enrollment; +import org.hyperledger.fabric.sdk.User; + +import java.io.Serializable; +import java.util.Set; + +public class UserContext implements User, Serializable { + + private static final long serialVersionUID = 1L; + protected String name; + protected Set roles; + protected String account; + protected String affiliation; + protected Enrollment enrollment; + protected String mspId; + + public void setName(String name){ + this.name=name; + } + + public void setRoles(Set roles){ + this.roles=roles; + } + + public void setAccount(String account) { + this.account = account; + } + + public void setAffiliation(String affiliation) { + this.affiliation = affiliation; + } + + public void setEnrollment(Enrollment enrollment) { + this.enrollment = enrollment; + } + + public void setMspId(String mspId) { + this.mspId = mspId; + } + + @Override + public String getName() { + return name; + } + + @Override + public Set getRoles() { + return roles; + } + + @Override + public String getAccount() { + return account; + } + + @Override + public String getAffiliation() { + return affiliation; + } + + @Override + public Enrollment getEnrollment() { + return enrollment; + } + + @Override + public String getMspId() { + return mspId; + } +} diff --git a/src/main/java/blockchain/utility/Util.java b/src/main/java/blockchain/utility/Util.java new file mode 100644 index 0000000..6fe9074 --- /dev/null +++ b/src/main/java/blockchain/utility/Util.java @@ -0,0 +1,90 @@ +package blockchain.utility; + + +import blockchain.user.UserContext; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; + +import java.io.*; + +//Class to Read and Write user / admin to msp directory +public class Util { + private static Logger logger = Logger.getLogger(Util.class); + + public static void writeUserContext(UserContext userContext) { + BasicConfigurator.configure(); + + ObjectOutputStream out = null; + FileOutputStream fileOutputStream = null; + try { + logger.info("Write user "+userContext.getName()+" of "+userContext.getAffiliation()); + + String directoryPath = "msp/" + userContext.getAffiliation(); + String filePath = directoryPath + "/" + userContext.getName() + ".context"; + File directory = new File(directoryPath); + + if (!directory.exists()){ + logger.info("Create directory at path "+directoryPath); + directory.mkdirs(); + } + + File file = new File(filePath); + fileOutputStream = new FileOutputStream(file); + out = new ObjectOutputStream(fileOutputStream); + logger.info("Try write object for user "+userContext.getName()); + out.writeObject(userContext); + } catch (IOException e) { + logger.error("1st IOException"); + e.printStackTrace(); + } finally { + try { + if (out != null){ + logger.info("Close ObjectOutputStream"); + out.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + if (fileOutputStream != null) { + logger.info("Close fileOutputStream"); + fileOutputStream.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public static UserContext readUserContext(String affiliation, String username) { + UserContext userContext = null; + FileInputStream fileStream = null; + ObjectInputStream in = null; + try { + String filePath = "msp/" + affiliation + "/" + username + ".context"; + File file = new File(filePath); + if (file.exists()) { + fileStream = new FileInputStream(filePath); + in = new ObjectInputStream(fileStream); + userContext = (UserContext) in.readObject(); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (in != null) + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + try { + if (fileStream != null) + fileStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return userContext; + } + } + +} diff --git a/src/main/java/restService/WelcomeController.java b/src/main/java/restService/WelcomeController.java new file mode 100644 index 0000000..723d6ed --- /dev/null +++ b/src/main/java/restService/WelcomeController.java @@ -0,0 +1,12 @@ +package restService; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class WelcomeController { + + @RequestMapping("/") + public String index(){return "Welcome from Monnethic !";} + +} \ No newline at end of file diff --git a/src/test/java/blockchain/client/TestEnrollAdmin.java b/src/test/java/blockchain/client/TestEnrollAdmin.java new file mode 100644 index 0000000..1101fe3 --- /dev/null +++ b/src/test/java/blockchain/client/TestEnrollAdmin.java @@ -0,0 +1,42 @@ +package blockchain.client; + +import blockchain.configuration.Config; +import blockchain.user.UserContext; +import org.hyperledger.fabric.sdk.Enrollment; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +//Test to enroll Admin +public class TestEnrollAdmin { + @Test + public void TestAEnrollAdmin(){ + String caUrl = Config.CA_ORG1_URL; + try { + CAClientWrapper caClientWrapper = new CAClientWrapper(caUrl,null); + + UserContext adminContext = new UserContext(); + adminContext.setName(Config.ADMIN); + adminContext.setAffiliation(Config.ORG1); + adminContext.setMspId(Config.ORG1_MSP); + + caClientWrapper.setAdminContext(adminContext); + + UserContext verifyUser = caClientWrapper.getAdminContext(); + assertEquals(Config.ADMIN, verifyUser.getName()); + assertEquals(Config.ORG1, verifyUser.getAffiliation()); + assertEquals(Config.ORG1_MSP, verifyUser.getMspId()); + + //ENROLL AND WRITE ADMIN + adminContext = caClientWrapper.enrollAdmin(adminContext.getName(),Config.ADMIN_PASSWORD,adminContext.getAffiliation()); + + //Check Admin Enrollement + Enrollment enrollment = adminContext.getEnrollment(); + System.out.println("admin cert : "+enrollment.getCert()); + System.out.println("admin keys : "+enrollment.getKey()); + }catch (Exception e){ + e.printStackTrace(); + } + + } +} diff --git a/src/test/java/blockchain/client/TestRegisterEnrollUser.java b/src/test/java/blockchain/client/TestRegisterEnrollUser.java new file mode 100644 index 0000000..db7bc3c --- /dev/null +++ b/src/test/java/blockchain/client/TestRegisterEnrollUser.java @@ -0,0 +1,37 @@ +package blockchain.client; + +import blockchain.configuration.Config; +import blockchain.user.UserContext; +import blockchain.utility.Util; +import org.apache.log4j.Logger; +import org.junit.Test; + +//Test to register and enroll user +public class TestRegisterEnrollUser { + private static Logger logger = Logger.getLogger(TestRegisterEnrollUser.class); + //Success + @Test + public void RegisterEnrollUser(){ + String caUrl = Config.CA_ORG1_URL; + try{ + CAClientWrapper caClientWrapper = new CAClientWrapper(caUrl,null); + UserContext admin = Util.readUserContext(Config.ORG1,Config.ADMIN); + caClientWrapper.setAdminContext(admin); + UserContext userContext = new UserContext(); + + userContext.setName("User-org1"); + userContext.setAffiliation(Config.ORG1); + userContext.setMspId(Config.ORG1_MSP); + String userSecret = caClientWrapper.registerUser(userContext.getName(),userContext.getAffiliation()); + logger.info("uSecret : "+userSecret); + userContext = caClientWrapper.enrollUser(userContext,userSecret); + logger.info("userContext enrollement : "+userContext.getEnrollment()); + + }catch (Exception e){ + e.printStackTrace(); + } + + + } + +} diff --git a/src/test/java/blockchain/query/ChaincodeTransactionTest.java b/src/test/java/blockchain/query/ChaincodeTransactionTest.java new file mode 100644 index 0000000..db982fa --- /dev/null +++ b/src/test/java/blockchain/query/ChaincodeTransactionTest.java @@ -0,0 +1,75 @@ +package blockchain.query; + +import blockchain.client.ChannelClientWrapper; +import blockchain.client.FabricClientWrapper; +import blockchain.configuration.Config; +import blockchain.user.UserContext; +import blockchain.utility.Util; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; +import org.hyperledger.fabric.sdk.*; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +//Test for transaction +public class ChaincodeTransactionTest { + private static Logger logger = Logger.getLogger(ChaincodeTransactionTest.class); + @Test + public void TestATransaction(){ + BasicConfigurator.configure(); + + //UserContext user = Util.readUserContext(Config.ORG1,"User-org1"); + UserContext user = Util.readUserContext(Config.ORG1,Config.ADMIN); + + try{ + + String chaincode = Config.CHAINCODE_NAME; + FabricClientWrapper fabricClientWrapper = new FabricClientWrapper(user); + ChannelClientWrapper channelClientWrapper = fabricClientWrapper.createChannelClient(Config.CHANNEL_NAME); + + Channel channel = channelClientWrapper.getChannel(); + //OLD PEER + //Peer peer = fabricClientWrapper.getClient().newPeer(Config.ORG_PEER,Config.ORG_PEER_URL); + //EventHub eventHub = fabricClientWrapper.getClient().newEventHub("eventhub01", Config.ORG_PEER_EVENT_URL); + //Orderer orderer = fabricClientWrapper.getClient().newOrderer(Config.ORDERER_NAME,Config.ORDERER_URL); + + Peer peer = fabricClientWrapper.getClient().newPeer(Config.ORG1_PEER_0,Config.ORG1_PEER_0_URL); + EventHub eventHub = fabricClientWrapper.getClient().newEventHub("eventhub01", "grpc://vps577432.ovh.net:8053"); + Orderer orderer = fabricClientWrapper.getClient().newOrderer(Config.ORDERER_NAME,Config.ORDERER_URL); + channel.addPeer(peer); + channel.addEventHub(eventHub); + channel.addOrderer(orderer); + channel.initialize(); + + + + TransactionProposalRequest tpr = fabricClientWrapper.getClient().newTransactionProposalRequest(); + ChaincodeID cid = ChaincodeID.newBuilder().setName(Config.CHAINCODE_NAME).build(); + tpr.setChaincodeID(cid); + tpr.setFcn("invoke"); + tpr.setArgs(new String[]{"a","b","20"}); //send 20 from a to b + + Collection responses = channel.sendTransactionProposal(tpr); + List invalid = responses.stream().filter(r -> r.isInvalid()).collect(Collectors.toList()); + + if (!invalid.isEmpty()) { + invalid.forEach(response -> { + logger.error(response.getMessage()); + }); + } + + + BlockEvent.TransactionEvent event = channel.sendTransaction(responses).get(); + logger.info("Event transaction id : "+event.getTransactionID()); //print transaction id + + }catch (Exception e){ + e.printStackTrace(); + } + } +} diff --git a/src/test/java/blockchain/query/CreateChaincodeUserTest.java b/src/test/java/blockchain/query/CreateChaincodeUserTest.java new file mode 100644 index 0000000..cac587a --- /dev/null +++ b/src/test/java/blockchain/query/CreateChaincodeUserTest.java @@ -0,0 +1,62 @@ +package blockchain.query; + +import blockchain.client.ChannelClientWrapper; +import blockchain.client.FabricClientWrapper; +import blockchain.configuration.Config; +import blockchain.user.UserContext; +import blockchain.utility.Util; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; +import org.hyperledger.fabric.sdk.*; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +//Test to create user on chaincode -> don't work, can't use function "Init" +public class CreateChaincodeUserTest { + private static Logger logger = Logger.getLogger(QueryTest.class); + + @Test + public void TestCreateUser(){ + BasicConfigurator.configure(); + UserContext user = Util.readUserContext(Config.ORG1,Config.ADMIN); + + try{ + String chaincode = Config.CHAINCODE_NAME; + FabricClientWrapper fabricClientWrapper = new FabricClientWrapper(user); + ChannelClientWrapper channelClientWrapper = fabricClientWrapper.createChannelClient(Config.CHANNEL_NAME); + + Channel channel = channelClientWrapper.getChannel(); + //OLD + //Peer peer = fabricClientWrapper.getClient().newPeer(Config.ORG_PEER,Config.ORG_PEER_URL); + //EventHub eventHub = fabricClientWrapper.getClient().newEventHub("eventhub01", Config.ORG_PEER_EVENT_URL); + //Orderer orderer = fabricClientWrapper.getClient().newOrderer(Config.ORDERER_NAME,Config.ORDERER_URL); + + Peer peer = fabricClientWrapper.getClient().newPeer(Config.ORG1_PEER_0,Config.ORG1_PEER_0_URL); + EventHub eventHub = fabricClientWrapper.getClient().newEventHub("eventhub01", "grpc://vps577432.ovh.net:8053"); + Orderer orderer = fabricClientWrapper.getClient().newOrderer(Config.ORDERER_NAME,Config.ORDERER_URL); + + channel.addPeer(peer); + channel.addEventHub(eventHub); + channel.addOrderer(orderer); + channel.initialize(); + + String[] args = {"user1","200","user2","180"}; + + Collection responseQuery = channelClientWrapper.queryByChainCode(chaincode,"init",args); + for(ProposalResponse pres : responseQuery){ + ChaincodeResponse.Status status = pres.getStatus(); + if(status.getStatus()!=200){ + throw new Exception(pres.getMessage()); + } + String stringResponse = new String(pres.getChaincodeActionResponsePayload()); + logger.info("RESPONSE : "+stringResponse); + } + + }catch (Exception e){ + e.printStackTrace(); + } + } +} diff --git a/src/test/java/blockchain/query/QueryChannelTest.java b/src/test/java/blockchain/query/QueryChannelTest.java new file mode 100644 index 0000000..4f3d4b8 --- /dev/null +++ b/src/test/java/blockchain/query/QueryChannelTest.java @@ -0,0 +1,34 @@ +package blockchain.query; + +import blockchain.client.FabricClientWrapper; +import blockchain.configuration.Config; +import blockchain.user.UserContext; +import blockchain.utility.Util; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; +import org.hyperledger.fabric.sdk.Peer; +import org.junit.Test; + +import java.util.Set; + +//Test to show channels on a node +public class QueryChannelTest { + private static Logger logger = Logger.getLogger(QueryTest.class); + + @Test + public void testQ(){ + BasicConfigurator.configure(); + UserContext userContext = Util.readUserContext(Config.ORG1,"User-org1"); + + try{ + FabricClientWrapper fabricClientWrapper = new FabricClientWrapper(userContext); + Set channels = fabricClientWrapper.queryForChannels(); + + logger.info("CHANNELS : "+channels); + + }catch(Exception e){ + e.printStackTrace(); + } + + } +} diff --git a/src/test/java/blockchain/query/QueryTest.java b/src/test/java/blockchain/query/QueryTest.java new file mode 100644 index 0000000..7b66897 --- /dev/null +++ b/src/test/java/blockchain/query/QueryTest.java @@ -0,0 +1,48 @@ +package blockchain.query; + +import blockchain.client.ChannelClientWrapper; +import blockchain.client.FabricClientWrapper; +import blockchain.configuration.Config; +import blockchain.user.UserContext; +import blockchain.utility.Util; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; +import org.hyperledger.fabric.sdk.*; +import org.junit.Test; +import java.util.Collection; + + +//Test to get balance of a User +public class QueryTest { + private static Logger logger = Logger.getLogger(QueryTest.class); + + @Test + public void TestAQueryChannels() { + BasicConfigurator.configure(); + + //UserContext user = Util.readUserContext(Config.ORG1,Config.ADMIN); + UserContext user = Util.readUserContext(Config.ORG1,"User-org1"); + + try{ + String chaincode = Config.CHAINCODE_NAME; + FabricClientWrapper fabricClientWrapper = new FabricClientWrapper(user); + + ChannelClientWrapper channelClientWrapper = ChannelClientWrapper.setupChannel(fabricClientWrapper); + + String[] args1 = {"a"}; + + Collection responseQuery = channelClientWrapper.queryByChainCode(chaincode,"query",args1); + for(ProposalResponse pres : responseQuery){ + ChaincodeResponse.Status status = pres.getStatus(); + if(status.getStatus()!=200){ + throw new Exception(pres.getMessage()); + } + String stringResponse = new String(pres.getChaincodeActionResponsePayload()); + logger.info("RESPONSE : "+stringResponse); + } + + }catch (Exception e){ + e.printStackTrace(); + } + } +} diff --git a/src/test/java/blockchain/queryWrapper/QueryWrapperTest.java b/src/test/java/blockchain/queryWrapper/QueryWrapperTest.java new file mode 100644 index 0000000..aa4d5ff --- /dev/null +++ b/src/test/java/blockchain/queryWrapper/QueryWrapperTest.java @@ -0,0 +1,18 @@ +package blockchain.queryWrapper; + +import blockchain.query.QueryWrapper; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; +import org.junit.Test; + +public class QueryWrapperTest { + private static Logger logger = Logger.getLogger(QueryWrapperTest.class); + @Test + public void TestGerUserBalance() { + BasicConfigurator.configure(); + QueryWrapper queryWrapper = new QueryWrapper(); + String response = queryWrapper.getUserBalance("a"); + logger.info(response); + } + +} diff --git a/src/test/java/blockchain/queryWrapper/TransactionWrapperTest.java b/src/test/java/blockchain/queryWrapper/TransactionWrapperTest.java new file mode 100644 index 0000000..da77485 --- /dev/null +++ b/src/test/java/blockchain/queryWrapper/TransactionWrapperTest.java @@ -0,0 +1,26 @@ +package blockchain.queryWrapper; + +import blockchain.query.QueryWrapper; +import blockchain.query.TransactionWrapper; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; +import org.junit.Test; + +public class TransactionWrapperTest { + private static Logger logger = Logger.getLogger(TransactionWrapperTest.class); + + @Test + public void TestTransaction() { + BasicConfigurator.configure(); + QueryWrapper queryWrapper = new QueryWrapper(); + TransactionWrapper transactionWrapper = new TransactionWrapper(); + String responseTransaction = transactionWrapper.sendTransaction("a","b","15"); //do transaction + logger.info("TRANSACTION ID : "+responseTransaction); + + String responseUserB = queryWrapper.getUserBalance("b"); //check new balance of user b + logger.info("BALANCE USER B : "+responseUserB); + + String responseUserA = queryWrapper.getUserBalance("a"); //check new balance of user a + logger.info("BALANCE USER A :"+responseUserA); + } +} diff --git a/src/test/java/blockchain/user/UserContextTest.java b/src/test/java/blockchain/user/UserContextTest.java new file mode 100644 index 0000000..7d0133a --- /dev/null +++ b/src/test/java/blockchain/user/UserContextTest.java @@ -0,0 +1,21 @@ +package blockchain.user; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +//Test to create a User +public class UserContextTest { + @Test + public void TestACreateUser(){ + UserContext userContext = new UserContext(); + userContext.setName("admin"); + userContext.setAffiliation("org1"); + userContext.setMspId("MspidOrg1"); + userContext.setEnrollment(null); + + assertEquals("org1",userContext.getAffiliation()); + assertEquals("admin",userContext.getName()); + assertEquals(null,userContext.getEnrollment()); + } +} diff --git a/src/test/java/blockchain/utility/ReadUserTest.java b/src/test/java/blockchain/utility/ReadUserTest.java new file mode 100644 index 0000000..e3ad3f4 --- /dev/null +++ b/src/test/java/blockchain/utility/ReadUserTest.java @@ -0,0 +1,22 @@ +package blockchain.utility; + +import blockchain.configuration.Config; +import blockchain.user.UserContext; +import org.junit.Test; + +//Test to Read User +public class ReadUserTest { + @Test + public void testReadUserOrg1(){ + try{ + UserContext userContext = Util.readUserContext(Config.ORG1, "User-org1"); + System.out.println(userContext.getAffiliation()); + System.out.println(userContext.getMspId()); + System.out.println(userContext.getEnrollment().getCert()); + System.out.println(userContext.getEnrollment().getKey()); + System.out.println(userContext.getName()); + }catch (Exception e){ + e.printStackTrace(); + } + } +} diff --git a/src/test/java/blockchain/utility/UtilTest.java b/src/test/java/blockchain/utility/UtilTest.java new file mode 100644 index 0000000..a6ac75f --- /dev/null +++ b/src/test/java/blockchain/utility/UtilTest.java @@ -0,0 +1,55 @@ +package blockchain.utility; + +import blockchain.user.UserContext; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +//Test to Read and Write user from files +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class UtilTest { + private static Logger logger = Logger.getLogger(UtilTest.class); + + @Test + public void TestAReadNullUser(){ + BasicConfigurator.configure(); + + logger.info("----- START TEST READ NULL USER ----"); + UserContext uc = Util.readUserContext("tata","abdel"); + if(uc!=null){ + logger.info("UserContext is : "+uc.toString()); + }else{ + logger.info("UserContext doesn't exist"); + } + } + + + @Test + public void TestBWriteUser(){ + BasicConfigurator.configure(); + logger.info("----- START TEST WRITE NULL USER ----"); + UserContext user = new UserContext(); + user.setName("abdel"); + user.setAffiliation("toto"); + user.setEnrollment(null); + user.setMspId("test"); + + Util.writeUserContext(user); + + } + + @Test + public void TestCReadCreatedUser(){ + BasicConfigurator.configure(); + logger.info("----- START TEST READ CREATED USER ----"); + UserContext uc = Util.readUserContext("toto","abdel"); + if(uc!=null){ + logger.info("UserContext is : "+uc.toString()); + }else{ + logger.info("UserContext doesn't exist"); + } + } + +} diff --git a/target/classes/Application/App.class b/target/classes/Application/App.class new file mode 100644 index 0000000..9bffa88 Binary files /dev/null and b/target/classes/Application/App.class differ diff --git a/target/classes/blockchain/client/CAClientWrapper.class b/target/classes/blockchain/client/CAClientWrapper.class new file mode 100644 index 0000000..2a0e140 Binary files /dev/null and b/target/classes/blockchain/client/CAClientWrapper.class differ diff --git a/target/classes/blockchain/client/ChannelClientWrapper.class b/target/classes/blockchain/client/ChannelClientWrapper.class new file mode 100644 index 0000000..4f571c9 Binary files /dev/null and b/target/classes/blockchain/client/ChannelClientWrapper.class differ diff --git a/target/classes/blockchain/client/FabricClientWrapper.class b/target/classes/blockchain/client/FabricClientWrapper.class new file mode 100644 index 0000000..37ad9e3 Binary files /dev/null and b/target/classes/blockchain/client/FabricClientWrapper.class differ diff --git a/target/classes/blockchain/configuration/Config.class b/target/classes/blockchain/configuration/Config.class new file mode 100644 index 0000000..f560ca1 Binary files /dev/null and b/target/classes/blockchain/configuration/Config.class differ diff --git a/target/classes/blockchain/query/QueryWrapper.class b/target/classes/blockchain/query/QueryWrapper.class new file mode 100644 index 0000000..1b44d9d Binary files /dev/null and b/target/classes/blockchain/query/QueryWrapper.class differ diff --git a/target/classes/blockchain/query/TransactionWrapper.class b/target/classes/blockchain/query/TransactionWrapper.class new file mode 100644 index 0000000..73d8e1a Binary files /dev/null and b/target/classes/blockchain/query/TransactionWrapper.class differ diff --git a/target/classes/blockchain/user/CAEnrollement.class b/target/classes/blockchain/user/CAEnrollement.class new file mode 100644 index 0000000..39c636c Binary files /dev/null and b/target/classes/blockchain/user/CAEnrollement.class differ diff --git a/target/classes/blockchain/user/UserContext.class b/target/classes/blockchain/user/UserContext.class new file mode 100644 index 0000000..88c8e70 Binary files /dev/null and b/target/classes/blockchain/user/UserContext.class differ diff --git a/target/classes/blockchain/utility/Util.class b/target/classes/blockchain/utility/Util.class new file mode 100644 index 0000000..933bc89 Binary files /dev/null and b/target/classes/blockchain/utility/Util.class differ diff --git a/target/classes/restService/WelcomeController.class b/target/classes/restService/WelcomeController.class new file mode 100644 index 0000000..d8eabe7 Binary files /dev/null and b/target/classes/restService/WelcomeController.class differ diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..df7824d --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,11 @@ +restService\WelcomeController.class +blockchain\user\UserContext.class +blockchain\client\CAClientWrapper.class +blockchain\utility\Util.class +blockchain\client\ChannelClientWrapper.class +blockchain\user\CAEnrollement.class +Application\App.class +blockchain\configuration\Config.class +blockchain\query\QueryWrapper.class +blockchain\query\TransactionWrapper.class +blockchain\client\FabricClientWrapper.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..34b86a6 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,11 @@ +B:\SCIENCES U\GroupProject\java-api\src\main\java\blockchain\client\ChannelClientWrapper.java +B:\SCIENCES U\GroupProject\java-api\src\main\java\blockchain\client\FabricClientWrapper.java +B:\SCIENCES U\GroupProject\java-api\src\main\java\blockchain\user\CAEnrollement.java +B:\SCIENCES U\GroupProject\java-api\src\main\java\blockchain\client\CAClientWrapper.java +B:\SCIENCES U\GroupProject\java-api\src\main\java\blockchain\query\QueryWrapper.java +B:\SCIENCES U\GroupProject\java-api\src\main\java\restService\WelcomeController.java +B:\SCIENCES U\GroupProject\java-api\src\main\java\Application\App.java +B:\SCIENCES U\GroupProject\java-api\src\main\java\blockchain\configuration\Config.java +B:\SCIENCES U\GroupProject\java-api\src\main\java\blockchain\query\TransactionWrapper.java +B:\SCIENCES U\GroupProject\java-api\src\main\java\blockchain\user\UserContext.java +B:\SCIENCES U\GroupProject\java-api\src\main\java\blockchain\utility\Util.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..221c910 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1,11 @@ +blockchain\query\QueryTest.class +blockchain\queryWrapper\QueryWrapperTest.class +blockchain\query\QueryChannelTest.class +blockchain\queryWrapper\TransactionWrapperTest.class +blockchain\utility\UtilTest.class +blockchain\client\TestEnrollAdmin.class +blockchain\query\ChaincodeTransactionTest.class +blockchain\utility\ReadUserTest.class +blockchain\client\TestRegisterEnrollUser.class +blockchain\query\CreateChaincodeUserTest.class +blockchain\user\UserContextTest.class diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..91dce2d --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1,11 @@ +B:\SCIENCES U\GroupProject\java-api\src\test\java\blockchain\client\TestRegisterEnrollUser.java +B:\SCIENCES U\GroupProject\java-api\src\test\java\blockchain\query\QueryTest.java +B:\SCIENCES U\GroupProject\java-api\src\test\java\blockchain\client\TestEnrollAdmin.java +B:\SCIENCES U\GroupProject\java-api\src\test\java\blockchain\query\CreateChaincodeUserTest.java +B:\SCIENCES U\GroupProject\java-api\src\test\java\blockchain\queryWrapper\TransactionWrapperTest.java +B:\SCIENCES U\GroupProject\java-api\src\test\java\blockchain\utility\UtilTest.java +B:\SCIENCES U\GroupProject\java-api\src\test\java\blockchain\query\QueryChannelTest.java +B:\SCIENCES U\GroupProject\java-api\src\test\java\blockchain\query\ChaincodeTransactionTest.java +B:\SCIENCES U\GroupProject\java-api\src\test\java\blockchain\utility\ReadUserTest.java +B:\SCIENCES U\GroupProject\java-api\src\test\java\blockchain\queryWrapper\QueryWrapperTest.java +B:\SCIENCES U\GroupProject\java-api\src\test\java\blockchain\user\UserContextTest.java diff --git a/target/surefire/surefirebooter2244873732484001783.jar b/target/surefire/surefirebooter2244873732484001783.jar new file mode 100644 index 0000000..2c9c94d Binary files /dev/null and b/target/surefire/surefirebooter2244873732484001783.jar differ diff --git a/target/test-classes/blockchain/client/TestEnrollAdmin.class b/target/test-classes/blockchain/client/TestEnrollAdmin.class new file mode 100644 index 0000000..e323018 Binary files /dev/null and b/target/test-classes/blockchain/client/TestEnrollAdmin.class differ diff --git a/target/test-classes/blockchain/client/TestRegisterEnrollUser.class b/target/test-classes/blockchain/client/TestRegisterEnrollUser.class new file mode 100644 index 0000000..d05214f Binary files /dev/null and b/target/test-classes/blockchain/client/TestRegisterEnrollUser.class differ diff --git a/target/test-classes/blockchain/query/ChaincodeTransactionTest.class b/target/test-classes/blockchain/query/ChaincodeTransactionTest.class new file mode 100644 index 0000000..584e906 Binary files /dev/null and b/target/test-classes/blockchain/query/ChaincodeTransactionTest.class differ diff --git a/target/test-classes/blockchain/query/CreateChaincodeUserTest.class b/target/test-classes/blockchain/query/CreateChaincodeUserTest.class new file mode 100644 index 0000000..d18a495 Binary files /dev/null and b/target/test-classes/blockchain/query/CreateChaincodeUserTest.class differ diff --git a/target/test-classes/blockchain/query/QueryChannelTest.class b/target/test-classes/blockchain/query/QueryChannelTest.class new file mode 100644 index 0000000..c92b0e8 Binary files /dev/null and b/target/test-classes/blockchain/query/QueryChannelTest.class differ diff --git a/target/test-classes/blockchain/query/QueryTest.class b/target/test-classes/blockchain/query/QueryTest.class new file mode 100644 index 0000000..35fa21a Binary files /dev/null and b/target/test-classes/blockchain/query/QueryTest.class differ diff --git a/target/test-classes/blockchain/queryWrapper/QueryWrapperTest.class b/target/test-classes/blockchain/queryWrapper/QueryWrapperTest.class new file mode 100644 index 0000000..9e060b4 Binary files /dev/null and b/target/test-classes/blockchain/queryWrapper/QueryWrapperTest.class differ diff --git a/target/test-classes/blockchain/queryWrapper/TransactionWrapperTest.class b/target/test-classes/blockchain/queryWrapper/TransactionWrapperTest.class new file mode 100644 index 0000000..ca8a34f Binary files /dev/null and b/target/test-classes/blockchain/queryWrapper/TransactionWrapperTest.class differ diff --git a/target/test-classes/blockchain/user/UserContextTest.class b/target/test-classes/blockchain/user/UserContextTest.class new file mode 100644 index 0000000..cfa4362 Binary files /dev/null and b/target/test-classes/blockchain/user/UserContextTest.class differ diff --git a/target/test-classes/blockchain/utility/ReadUserTest.class b/target/test-classes/blockchain/utility/ReadUserTest.class new file mode 100644 index 0000000..4e2f922 Binary files /dev/null and b/target/test-classes/blockchain/utility/ReadUserTest.class differ diff --git a/target/test-classes/blockchain/utility/UtilTest.class b/target/test-classes/blockchain/utility/UtilTest.class new file mode 100644 index 0000000..f95febe Binary files /dev/null and b/target/test-classes/blockchain/utility/UtilTest.class differ