Compare commits
129 commits
master
...
develop-1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
656cc77c0a | ||
![]() |
cae0aec951 | ||
![]() |
48da18bfdd | ||
![]() |
ff5a7f4740 | ||
![]() |
0eed15427a | ||
![]() |
d130dd9b2e | ||
![]() |
7b9604a51a | ||
![]() |
7d3783b5a0 | ||
![]() |
e5284e0957 | ||
![]() |
998ac4526c | ||
![]() |
a8164c9c0c | ||
![]() |
b53452ba1d | ||
![]() |
264e1be827 | ||
![]() |
e5d1b705e1 | ||
![]() |
3881c0ae0e | ||
![]() |
177dbe1f0d | ||
![]() |
c6e53fd9d2 | ||
![]() |
c737f3a354 | ||
![]() |
951965bddd | ||
![]() |
8802423e2c | ||
![]() |
c4b38bf041 | ||
![]() |
f526853722 | ||
![]() |
58f866fef0 | ||
![]() |
3812808697 | ||
![]() |
b867d68e74 | ||
![]() |
b74705ccfa | ||
![]() |
0589eb6bc6 | ||
![]() |
eb23e8f019 | ||
![]() |
70a3b3328d | ||
![]() |
3893e90630 | ||
![]() |
01c38f963f | ||
![]() |
3e3492254e | ||
![]() |
e65687aa9b | ||
![]() |
253ce1996a | ||
![]() |
a08ff2d5e3 | ||
![]() |
79159487a6 | ||
![]() |
9504fff762 | ||
![]() |
7cc40b2122 | ||
![]() |
7961e25793 | ||
![]() |
ca3fbda8da | ||
![]() |
0591dda379 | ||
![]() |
debdbb52ce | ||
![]() |
2038c66f06 | ||
![]() |
16dd8584db | ||
![]() |
9167b135f5 | ||
![]() |
1302a5a3dc | ||
![]() |
959db7b991 | ||
![]() |
996c880055 | ||
![]() |
b328940037 | ||
![]() |
ef506d8be4 | ||
![]() |
14d111508e | ||
![]() |
2c6ea23968 | ||
![]() |
fe7ebfdea3 | ||
![]() |
4972d615e2 | ||
![]() |
1e479ff973 | ||
![]() |
decdb64136 | ||
![]() |
86f6abfce5 | ||
![]() |
48c0b2a340 | ||
![]() |
ef9863a8be | ||
![]() |
5df9626bc7 | ||
![]() |
3262d72ec0 | ||
![]() |
99a29d8a49 | ||
![]() |
e9ce67a6a6 | ||
![]() |
1378158e35 | ||
![]() |
5be8d03dd3 | ||
![]() |
16c97a6608 | ||
![]() |
9f20f92c02 | ||
![]() |
722ebe704e | ||
![]() |
892afd8efb | ||
![]() |
4ea0fdd202 | ||
![]() |
cb38f1a6d2 | ||
![]() |
be076b7fab | ||
![]() |
a268a44b6a | ||
![]() |
a03db07d32 | ||
![]() |
43153d954d | ||
![]() |
35619f176f | ||
![]() |
e55e7e0015 | ||
![]() |
3893526f3d | ||
![]() |
9a09bc2b4c | ||
![]() |
51d44c85ca | ||
![]() |
30c806ec0c | ||
![]() |
603c6b1ffc | ||
![]() |
ecd98a7171 | ||
![]() |
81bceffcfd | ||
![]() |
26ed8856f2 | ||
![]() |
7ccee4168f | ||
![]() |
a8bf518845 | ||
![]() |
78686fb060 | ||
![]() |
ee686187e7 | ||
![]() |
41039ddffc | ||
![]() |
843c6a034e | ||
![]() |
d877c3b39f | ||
![]() |
6896e5ee2b | ||
![]() |
982386ef7e | ||
![]() |
dcca3eaf1e | ||
![]() |
b07b6a530f | ||
![]() |
f7dfc4eea2 | ||
![]() |
a2fc218e1d | ||
![]() |
2fbfb9e218 | ||
![]() |
457c245fe5 | ||
![]() |
1ca0ea5069 | ||
![]() |
05b1827450 | ||
![]() |
c663dd5050 | ||
![]() |
2ede4c231c | ||
![]() |
584349e931 | ||
![]() |
5b66b6723c | ||
![]() |
6f88238309 | ||
![]() |
23e8ef5b1f | ||
![]() |
8bee24167c | ||
![]() |
199d122038 | ||
![]() |
4c7a65816d | ||
![]() |
f51df72704 | ||
![]() |
4f794b5bca | ||
![]() |
a50e07535c | ||
![]() |
618fa237d0 | ||
![]() |
75ba178cee | ||
![]() |
cdaf81b99d | ||
![]() |
80328999bc | ||
![]() |
2c5ef6ce29 | ||
![]() |
097d6f2d4e | ||
![]() |
18f679ff6e | ||
![]() |
501b0e4760 | ||
![]() |
f8308dff09 | ||
![]() |
217e70403b | ||
![]() |
c604474acf | ||
![]() |
2d51032d0f | ||
![]() |
04ee63a569 | ||
![]() |
82e362cacd | ||
![]() |
08d9db12aa |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -81,3 +81,4 @@ fabric.properties
|
|||
|
||||
|
||||
# End of https://www.gitignore.io/api/intellij
|
||||
target/
|
||||
|
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
2
cmd.txt
2
cmd.txt
|
@ -1 +1 @@
|
|||
mvn package && java -jar target/java-api-1.0.jar
|
||||
mvn package && java -jar target/java-api-0.1.jar
|
16
debian-service-file.txt
Normal file
16
debian-service-file.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=A Spring Boot application
|
||||
After=syslog.target
|
||||
|
||||
[Service]
|
||||
User=[user du dossier]
|
||||
ExecStart=[chemin jusqu'au .jar]
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[(DANS : ) /etc/systemd/system]
|
||||
[-rw-r--r-- 1 root root 163 nov. 22 2018 java-api.service]
|
||||
|
||||
[-rwxr-xr-x 1 root root 44823539 avril 18 20:17 java-api-0.1.jar]
|
||||
[chmod 755 java-api-0.1.jar]
|
27
demo/demo.txt
Normal file
27
demo/demo.txt
Normal file
|
@ -0,0 +1,27 @@
|
|||
@ = alt + 64
|
||||
|
||||
**** Client ****
|
||||
Nom : Fournier
|
||||
Prénom : Eric
|
||||
Phone : 0708091011
|
||||
Email : eric.fournier@mail.com
|
||||
Pwd : Eric00$
|
||||
****************
|
||||
|
||||
|
||||
**** Commerçant ****
|
||||
Nom : Chevalier
|
||||
Prénom : Didier
|
||||
Phone : 0607080910
|
||||
Email : didier.chevalier@mail.com
|
||||
Pwd : Didier11$
|
||||
****************
|
||||
|
||||
|
||||
**** Ostéopathe ****
|
||||
Nom : Perrin
|
||||
Prénom : Marc
|
||||
Phone : 0709101112
|
||||
Email : marc.perrin@mail.com
|
||||
Pwd : Marc22$
|
||||
****************
|
102
demo/monnethic_demo.txt
Normal file
102
demo/monnethic_demo.txt
Normal file
|
@ -0,0 +1,102 @@
|
|||
User : Client A
|
||||
"name":"Petit"
|
||||
"firstname":"Claire"
|
||||
"email":"c.petit@mail.com"
|
||||
"phone":"0785612459"
|
||||
"password":"c41ReP5$^é"
|
||||
"association":"gonette"
|
||||
|
||||
"user_hash":"$2a$10$ntqkPMXP06Yp478fnwKLVOsrAIkipLOBmSAdBFIGx2vjbFppKpTNa"
|
||||
"wallet_hash":"$2a$10$XnKYxUDbR0D1G5HkdJ9S2uGZ9sAQEOKtBCsmXe8vxGgob2XII.EBy"
|
||||
|
||||
|
||||
*********************************************************************************************************************
|
||||
|
||||
|
||||
User : Ostéopathe
|
||||
"name":"Georges"
|
||||
"firstname":"Patrick"
|
||||
"email":"patrick.g@mail.com"
|
||||
"phone":"0724812479"
|
||||
"password":"Gpatr014<*ù"
|
||||
"association":"gonette"
|
||||
|
||||
"user_hash":"$2a$10$SadeHP4K6HmDB.cUVU5Er.2NPGnOYoV0EGMx7FYBl592AmJF.M2Ka"
|
||||
(pro)
|
||||
"wallet_hash" : "$2a$10$YJw/./0UmHw/6F9CkZXWwOQRHemIPDAdK23acykPVTOnnw2HFmjVO"
|
||||
(perso)
|
||||
"wallet_hash": "$2a$10$xEPlmoDmfiCcSVy3ZYfOvewDHo33t/6Kja9MVM9LnR6h0XcJMy/.i"
|
||||
|
||||
|
||||
*********************************************************************************************************************
|
||||
|
||||
|
||||
User : Commerçant
|
||||
"name":"Meunier"
|
||||
"firstname":"Thomas"
|
||||
"email":"thomas.meunier@mail.com"
|
||||
"phone":"0759874562"
|
||||
"password":"Thom4$Meun00*&"
|
||||
"association":"gonette"
|
||||
|
||||
"user_hash":"$2a$10$98HK82Fhp1UYBsTcSOBXMO5xatF.XC5apXMur9so1BsjF9C81Iefu"
|
||||
(fournisseur)
|
||||
"wallet_hash": "$2a$10$FhOPkwpURWqL7PbIWESvYu3ECx./foUAK0C3aXo03nVbh32tByBFS"
|
||||
(employee)
|
||||
"wallet_hash": "$2a$10$TVVNIsBqvlVO3qqNKA1YWOpsXHBBaFj6V/FVZ5w9RdzWYZbJPL1/C"
|
||||
(change)
|
||||
"wallet_hash": "$2a$10$K3LYtgJ94mVcLz53slKH5uZWmGcp2ZvTzrF49dAeCQTamPA439riq"
|
||||
(commerce)
|
||||
"wallet_hash": "$2a$10$RTx5wmT.8qn.p6w7gO1B6OaEGbNXtNBGIDiRl/.EhhIGbUJe8ZuO2"
|
||||
|
||||
|
||||
*********************************************************************************************************************
|
||||
|
||||
|
||||
User : Association
|
||||
"name":"Gonette",
|
||||
"firstname":"Association"
|
||||
"email":"gonette-lyon@mail.com"
|
||||
"phone":"0748523694"
|
||||
"password":"gonTAssfc125$/*"
|
||||
"association":"gonette"
|
||||
|
||||
"user_hash":"$2a$10$rJ030ZF46d4GGHWew00cW.vySwPRUM/1B.itHiH/6PmoSthGH/Vm2"
|
||||
|
||||
|
||||
*********************************************************************************************************************
|
||||
|
||||
|
||||
User : Client B
|
||||
"name":"Huet"
|
||||
"firstname":"Sarah"
|
||||
"email":"s.huet@mail.com"
|
||||
"phone":"0685012398"
|
||||
"password":"rEt154d*$"
|
||||
"association":"gonette"
|
||||
|
||||
"user_hash":"$2a$10$nrEhfwofCs8PHTSBBwgNvu3acUPcvy0vOZOUh0ZUZRppUk1oTStd2"
|
||||
"wallet_hash": "$2a$10$w0rfspDySL4NwpHwlPGDXObioPbrP/nw/QhM25FxtkPv3x5H58Xye"
|
||||
|
||||
|
||||
*********************************************************************************************************************
|
||||
|
||||
|
||||
-- Demo--
|
||||
|
||||
User : Client C
|
||||
"name":"Girard"
|
||||
"firstname":"Louis"
|
||||
"email":"l.girard@mail.com"
|
||||
"phone":"0689521476"
|
||||
"password":"G1rard9*f7"
|
||||
"association":"gonette"
|
||||
|
||||
User : Client D
|
||||
"name":"Breton"
|
||||
"firstname":"Léo"
|
||||
"email":"leo.breton@mail.com"
|
||||
"phone":"0785103298"
|
||||
"password":"L3oBrto98*$"
|
||||
"association":"gonette"
|
||||
|
205
demo/monnethic_demo_setup.txt
Normal file
205
demo/monnethic_demo_setup.txt
Normal file
|
@ -0,0 +1,205 @@
|
|||
User : Client A
|
||||
"user_hash":"$2a$10$ntqkPMXP06Yp478fnwKLVOsrAIkipLOBmSAdBFIGx2vjbFppKpTNa"
|
||||
"wallet_hash":"$2a$10$XnKYxUDbR0D1G5HkdJ9S2uGZ9sAQEOKtBCsmXe8vxGgob2XII.EBy"
|
||||
|
||||
{
|
||||
"name":"Petit",
|
||||
"firstname":"Claire",
|
||||
"email":"c.petit@mail.com",
|
||||
"phone":"0785612459",
|
||||
"password":"c41ReP5$^é",
|
||||
"association":"gonette"
|
||||
}
|
||||
|
||||
{
|
||||
"user_hash":"$2a$10$ntqkPMXP06Yp478fnwKLVOsrAIkipLOBmSAdBFIGx2vjbFppKpTNa",
|
||||
"email":"c.petit@mail.com"
|
||||
}
|
||||
|
||||
{
|
||||
"type":"Course",
|
||||
"user_hash":"$2a$10$ntqkPMXP06Yp478fnwKLVOsrAIkipLOBmSAdBFIGx2vjbFppKpTNa"
|
||||
}
|
||||
|
||||
{
|
||||
"association_hash":"$2a$10$rJ030ZF46d4GGHWew00cW.vySwPRUM/1B.itHiH/6PmoSthGH/Vm2",
|
||||
"assocation_pwd":"gonTAssfc125$/*",
|
||||
"wallet_hash":"$2a$10$XnKYxUDbR0D1G5HkdJ9S2uGZ9sAQEOKtBCsmXe8vxGgob2XII.EBy",
|
||||
"amount":300.0
|
||||
}
|
||||
|
||||
|
||||
*********************************************************************************************************************
|
||||
|
||||
|
||||
User : Ostéopathe
|
||||
"user_hash":"$2a$10$SadeHP4K6HmDB.cUVU5Er.2NPGnOYoV0EGMx7FYBl592AmJF.M2Ka"
|
||||
(pro)
|
||||
"wallet_hash" : "$2a$10$YJw/./0UmHw/6F9CkZXWwOQRHemIPDAdK23acykPVTOnnw2HFmjVO"
|
||||
(perso)
|
||||
"wallet_hash": "$2a$10$xEPlmoDmfiCcSVy3ZYfOvewDHo33t/6Kja9MVM9LnR6h0XcJMy/.i"
|
||||
|
||||
|
||||
{
|
||||
"name":"Georges",
|
||||
"firstname":"Patrick",
|
||||
"email":"patrick.g@mail.com",
|
||||
"phone":"0724812479",
|
||||
"password":"Gpatr014<*ù",
|
||||
"association":"gonette"
|
||||
}
|
||||
|
||||
{
|
||||
"user_hash":"$2a$10$SadeHP4K6HmDB.cUVU5Er.2NPGnOYoV0EGMx7FYBl592AmJF.M2Ka",
|
||||
"email":"patrick.g@mail.com"
|
||||
}
|
||||
|
||||
{
|
||||
"type":"Pro",
|
||||
"user_hash":"$2a$10$SadeHP4K6HmDB.cUVU5Er.2NPGnOYoV0EGMx7FYBl592AmJF.M2Ka"
|
||||
}
|
||||
|
||||
{
|
||||
"type":"Perso",
|
||||
"user_hash":"$2a$10$SadeHP4K6HmDB.cUVU5Er.2NPGnOYoV0EGMx7FYBl592AmJF.M2Ka"
|
||||
}
|
||||
|
||||
{
|
||||
"association_hash":"$2a$10$rJ030ZF46d4GGHWew00cW.vySwPRUM/1B.itHiH/6PmoSthGH/Vm2",
|
||||
"assocation_pwd":"gonTAssfc125$/*",
|
||||
"wallet_hash":"$2a$10$YJw/./0UmHw/6F9CkZXWwOQRHemIPDAdK23acykPVTOnnw2HFmjVO",
|
||||
"amount":104.0
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
"association_hash":"$2a$10$rJ030ZF46d4GGHWew00cW.vySwPRUM/1B.itHiH/6PmoSthGH/Vm2",
|
||||
"assocation_pwd":"gonTAssfc125$/*",
|
||||
"wallet_hash":"$2a$10$xEPlmoDmfiCcSVy3ZYfOvewDHo33t/6Kja9MVM9LnR6h0XcJMy/.i",
|
||||
"amount":75.0
|
||||
}
|
||||
|
||||
|
||||
*********************************************************************************************************************
|
||||
|
||||
|
||||
User : Commerçant
|
||||
"user_hash":"$2a$10$98HK82Fhp1UYBsTcSOBXMO5xatF.XC5apXMur9so1BsjF9C81Iefu"
|
||||
(fournisseur)
|
||||
"wallet_hash": "$2a$10$FhOPkwpURWqL7PbIWESvYu3ECx./foUAK0C3aXo03nVbh32tByBFS"
|
||||
(employee)
|
||||
"wallet_hash": "$2a$10$TVVNIsBqvlVO3qqNKA1YWOpsXHBBaFj6V/FVZ5w9RdzWYZbJPL1/C"
|
||||
(change)
|
||||
"wallet_hash": "$2a$10$K3LYtgJ94mVcLz53slKH5uZWmGcp2ZvTzrF49dAeCQTamPA439riq"
|
||||
(commerce)
|
||||
"wallet_hash": "$2a$10$RTx5wmT.8qn.p6w7gO1B6OaEGbNXtNBGIDiRl/.EhhIGbUJe8ZuO2"
|
||||
|
||||
{
|
||||
"name":"Meunier",
|
||||
"firstname":"Thomas",
|
||||
"email":"thomas.meunier@mail.com",
|
||||
"phone":"0759874562",
|
||||
"password":"Thom4$Meun00*&",
|
||||
"association":"gonette"
|
||||
}
|
||||
|
||||
{
|
||||
"user_hash":"$2a$10$98HK82Fhp1UYBsTcSOBXMO5xatF.XC5apXMur9so1BsjF9C81Iefu",
|
||||
"email":"thomas.meunier@mail.com"
|
||||
}
|
||||
|
||||
{
|
||||
"type":"fournisseur",
|
||||
"user_hash":"$2a$10$98HK82Fhp1UYBsTcSOBXMO5xatF.XC5apXMur9so1BsjF9C81Iefu"
|
||||
}
|
||||
|
||||
{
|
||||
"type":"commerce",
|
||||
"user_hash":"$2a$10$98HK82Fhp1UYBsTcSOBXMO5xatF.XC5apXMur9so1BsjF9C81Iefu"
|
||||
}
|
||||
|
||||
{
|
||||
"type":"employee",
|
||||
"user_hash":"$2a$10$98HK82Fhp1UYBsTcSOBXMO5xatF.XC5apXMur9so1BsjF9C81Iefu"
|
||||
}
|
||||
|
||||
{
|
||||
"type":"change",
|
||||
"user_hash":"$2a$10$98HK82Fhp1UYBsTcSOBXMO5xatF.XC5apXMur9so1BsjF9C81Iefu"
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
"association_hash":"$2a$10$rJ030ZF46d4GGHWew00cW.vySwPRUM/1B.itHiH/6PmoSthGH/Vm2",
|
||||
"assocation_pwd":"gonTAssfc125$/*",
|
||||
"wallet_hash":"$2a$10$FhOPkwpURWqL7PbIWESvYu3ECx./foUAK0C3aXo03nVbh32tByBFS",
|
||||
"amount":3500.0
|
||||
}
|
||||
|
||||
{
|
||||
"association_hash":"$2a$10$rJ030ZF46d4GGHWew00cW.vySwPRUM/1B.itHiH/6PmoSthGH/Vm2",
|
||||
"assocation_pwd":"gonTAssfc125$/*",
|
||||
"wallet_hash":"$2a$10$TVVNIsBqvlVO3qqNKA1YWOpsXHBBaFj6V/FVZ5w9RdzWYZbJPL1/C",
|
||||
"amount":5500.0
|
||||
}
|
||||
|
||||
{
|
||||
"association_hash":"$2a$10$rJ030ZF46d4GGHWew00cW.vySwPRUM/1B.itHiH/6PmoSthGH/Vm2",
|
||||
"assocation_pwd":"gonTAssfc125$/*",
|
||||
"wallet_hash":"$2a$10$K3LYtgJ94mVcLz53slKH5uZWmGcp2ZvTzrF49dAeCQTamPA439riq",
|
||||
"amount":2400.0
|
||||
}
|
||||
|
||||
|
||||
*********************************************************************************************************************
|
||||
|
||||
|
||||
User : Association
|
||||
"user_hash":"$2a$10$rJ030ZF46d4GGHWew00cW.vySwPRUM/1B.itHiH/6PmoSthGH/Vm2"
|
||||
{
|
||||
"name":"Gonette",
|
||||
"firstname":"Association",
|
||||
"email":"gonette-lyon@mail.com",
|
||||
"phone":"0748523694",
|
||||
"password":"gonTAssfc125$/*",
|
||||
"association":"gonette"
|
||||
}
|
||||
|
||||
{
|
||||
"user_hash":"$2a$10$rJ030ZF46d4GGHWew00cW.vySwPRUM/1B.itHiH/6PmoSthGH/Vm2",
|
||||
"email":"gonette-lyon@mail.com"
|
||||
}
|
||||
|
||||
|
||||
*********************************************************************************************************************
|
||||
|
||||
|
||||
User : Client B
|
||||
"user_hash":"$2a$10$nrEhfwofCs8PHTSBBwgNvu3acUPcvy0vOZOUh0ZUZRppUk1oTStd2"
|
||||
"wallet_hash": "$2a$10$w0rfspDySL4NwpHwlPGDXObioPbrP/nw/QhM25FxtkPv3x5H58Xye"
|
||||
|
||||
{
|
||||
"name":"Huet",
|
||||
"firstname":"Sarah",
|
||||
"email":"s.huet@mail.com",
|
||||
"phone":"0685012398",
|
||||
"password":"rEt154d*$",
|
||||
"association":"gonette"
|
||||
}
|
||||
|
||||
{
|
||||
"user_hash":"$2a$10$nrEhfwofCs8PHTSBBwgNvu3acUPcvy0vOZOUh0ZUZRppUk1oTStd2",
|
||||
"email":"s.huet@mail.com"
|
||||
}
|
||||
|
||||
{
|
||||
"type":"quotidien",
|
||||
"user_hash":"$2a$10$nrEhfwofCs8PHTSBBwgNvu3acUPcvy0vOZOUh0ZUZRppUk1oTStd2"
|
||||
}
|
||||
|
||||
{
|
||||
"association_hash":"$2a$10$rJ030ZF46d4GGHWew00cW.vySwPRUM/1B.itHiH/6PmoSthGH/Vm2",
|
||||
"assocation_pwd":"gonTAssfc125$/*",
|
||||
"wallet_hash":"$2a$10$w0rfspDySL4NwpHwlPGDXObioPbrP/nw/QhM25FxtkPv3x5H58Xye",
|
||||
"amount":60.0
|
||||
}
|
10
demo/monnethic_demo_tx.txt
Normal file
10
demo/monnethic_demo_tx.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
http://5.39.76.139:10053:10053/api/rest/transaction/send
|
||||
|
||||
{
|
||||
"source_user_hash":"$2a$10$SSYkPrHCkvUDgVROEhsO4OiEjQdHbsJT5t8n8/ONCTC0Jk0qnzR7W",
|
||||
"source_user_pwd":"c41ReP5$^é",
|
||||
"transaction_from":"$2a$10$MTJ4ApYm8dxklPrp1EQO4.66zhbYhHEz29fi0nS3NaYTqnX0g3/A2",
|
||||
"transaction_to":"$2a$10$hQ0mwaT.X4vPFctgb67fsOTf1UFRym2eCgBv1tpVTM46wDnYj8gva",
|
||||
"transaction_amount":20.0,
|
||||
"transaction_unit":"gonette"
|
||||
}
|
5
demo/test.txt
Normal file
5
demo/test.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
name : Girardi
|
||||
firstname : Lola
|
||||
email : lola.girardi@mail.com
|
||||
pwd : LolaG1$
|
||||
0689547810
|
1
msp/key
Normal file
1
msp/key
Normal file
|
@ -0,0 +1 @@
|
|||
5605411d9d863fd2d58ea5000fd9651debedbb22c0c9ac89a49642a7179a39d3
|
Binary file not shown.
Binary file not shown.
49
pom.xml
49
pom.xml
|
@ -8,6 +8,8 @@
|
|||
<artifactId>java-api</artifactId>
|
||||
<version>0.1</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
|
@ -21,7 +23,7 @@
|
|||
<dependency>
|
||||
<groupId>org.hyperledger.fabric-sdk-java</groupId>
|
||||
<artifactId>fabric-sdk-java</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<version>1.4.0</version>
|
||||
</dependency>
|
||||
<!-- ***** -->
|
||||
|
||||
|
@ -34,6 +36,10 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-crypto</artifactId>
|
||||
</dependency>
|
||||
<!-- ***** -->
|
||||
|
||||
<!-- LOGGER AND TEST DEPENDENCIES -->
|
||||
|
@ -56,8 +62,46 @@
|
|||
<version>1.60</version>
|
||||
</dependency>
|
||||
<!-- ***** -->
|
||||
|
||||
<!-- ORMLITE - POSTGRE -->
|
||||
<dependency>
|
||||
<groupId>com.j256.ormlite</groupId>
|
||||
<artifactId>ormlite-core</artifactId>
|
||||
<version>5.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.j256.ormlite</groupId>
|
||||
<artifactId>ormlite-jdbc</artifactId>
|
||||
<version>5.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.2.5</version>
|
||||
</dependency>
|
||||
<!-- ***** -->
|
||||
|
||||
<!-- APACHE -->
|
||||
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<!-- ***** -->
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.sun.mail/javax.mail -->
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
@ -67,6 +111,9 @@
|
|||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<executable>true</executable>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
|
904
postman/MONNETHIC-API.postman_collection.json
Normal file
904
postman/MONNETHIC-API.postman_collection.json
Normal file
|
@ -0,0 +1,904 @@
|
|||
{
|
||||
"info": {
|
||||
"_postman_id": "fe2ac183-8378-4e3d-82c9-0cd1057d2fb7",
|
||||
"name": "MONNETHIC-API",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "USER",
|
||||
"item": [
|
||||
{
|
||||
"name": "CREATE",
|
||||
"item": [
|
||||
{
|
||||
"name": "Register User",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"name\":\"Clara\",\n\t\"firstname\":\"Sophie\",\n\t\"email\":\"sophie.clara@gmail.com\",\n\t\"password\":\"sophieClara1234$\",\n\t\"association\":\"gonette\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/user/register",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"user",
|
||||
"register"
|
||||
]
|
||||
},
|
||||
"description": "Request to Register an User into Monnethic-Project (Blockchain and Database)"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Register User To Delete",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"type": "text",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"name\":\"Toto\",\n\t\"firstname\":\"tata\",\n\t\"email\":\"toto.tata@gmail.com\",\n\t\"password\":\"tototata1234$\",\n\t\"association\":\"gonette\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/user/register",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"user",
|
||||
"register"
|
||||
]
|
||||
},
|
||||
"description": "Request to Register an User into Monnethic-Project (Blockchain and Database)"
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Register User With Phone",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"type": "text",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"name\":\"Meunier\",\n\t\"firstname\":\"Thomas\",\n\t\"email\":\"thomas.meunier@gmail.com\",\n\t\"password\":\"thomasMeunier4567$\",\n\t\"phone\":\"0102030405\",\n\t\"association\":\"gonette\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/user/register",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"user",
|
||||
"register"
|
||||
]
|
||||
},
|
||||
"description": "Request to Register an User into Monnethic-Project (Blockchain and Database)"
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
},
|
||||
{
|
||||
"name": "LOGIN",
|
||||
"item": [
|
||||
{
|
||||
"name": "User-Login",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"email\":\"thomas.meunier@gmail.com\",\n\t\"password\":\"thomasPwd158$*\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/user/login",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"user",
|
||||
"login"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
},
|
||||
{
|
||||
"name": "GET",
|
||||
"item": [
|
||||
{
|
||||
"name": "getUser",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"email\":\"toto.tata@gmail.com\",\n\t\"password\":\"tototata1234$\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/user/get",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"user",
|
||||
"get"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
},
|
||||
{
|
||||
"name": "DELETE",
|
||||
"item": [
|
||||
{
|
||||
"name": "deleteUser",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"email\":\"toto.tata@gmail.com\",\n\t\"user_hash\":\"$2a$10$mE0RJq92SmedzuMlQvX29uXT9chqpKH/45cZ9GD7aphsMdJw9..sm\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/user/delete",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"user",
|
||||
"delete"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
},
|
||||
{
|
||||
"name": "APPROVE",
|
||||
"item": [
|
||||
{
|
||||
"name": "approveUser",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"user_hash\":\"$2a$10$mE0RJq92SmedzuMlQvX29uXT9chqpKH/45cZ9GD7aphsMdJw9..sm\",\n\t\"email\":\"toto.tata@gmail.com\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/user/approve",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"user",
|
||||
"approve"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
}
|
||||
],
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "bddb7f7b-9a6f-4a71-8061-a3a1fe46fb12",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"id": "add34646-7177-4d4f-ad9e-b3eb963d5bf8",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "WALLET",
|
||||
"item": [
|
||||
{
|
||||
"name": "GET",
|
||||
"item": [
|
||||
{
|
||||
"name": "getWallet",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/wallet/getWallet?walletHash=$2a$10$8PJyraUjMoL/h.cQjJyMZedBUlcTjPjNm4j1NuqzQBTnSe2XNuGM2",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"wallet",
|
||||
"getWallet"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "walletHash",
|
||||
"value": "$2a$10$8PJyraUjMoL/h.cQjJyMZedBUlcTjPjNm4j1NuqzQBTnSe2XNuGM2"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "getUserWallets",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/wallet/getUserWallets?userHash=$2a$10$GzyMhD3n05Z2lwCnoGi2dusjKrNAmHhtn5fw1xLpes5.cEV5T7lve",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"wallet",
|
||||
"getUserWallets"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "userHash",
|
||||
"value": "$2a$10$GzyMhD3n05Z2lwCnoGi2dusjKrNAmHhtn5fw1xLpes5.cEV5T7lve"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
},
|
||||
{
|
||||
"name": "DELETE",
|
||||
"item": [
|
||||
{
|
||||
"name": "deleteWallet",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"userHash\":\"\",\n\t\"walletHash\":\"$2a$10$GzyMhD3n05Z2lwCnoGi2dusjKrNAmHhtn5fw1xLpes5.cEV5T7lve\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/wallet/delete",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"wallet",
|
||||
"delete"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "",
|
||||
"value": "",
|
||||
"disabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
},
|
||||
{
|
||||
"name": "CREATE",
|
||||
"item": [
|
||||
{
|
||||
"name": "createWallet",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"type\":\"test\",\n\t\"user_hash\":\"$2a$10$GzyMhD3n05Z2lwCnoGi2dusjKrNAmHhtn5fw1xLpes5.cEV5T7lve\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/wallet/create",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"wallet",
|
||||
"create"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
},
|
||||
{
|
||||
"name": "SETBALANCE",
|
||||
"item": [
|
||||
{
|
||||
"name": "setBalance",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"association_hash\":\"$2a$10$lPl7xCdsp.2g9fX7ytj9tONkV3PuQzG.9A9G8PfEKnIkT2KpahMme\",\n\t\"assocation_pwd\":\"asso_GonE8977&4$*-\",\n\t\"wallet_hash\":\"$2a$10$8PJyraUjMoL/h.cQjJyMZedBUlcTjPjNm4j1NuqzQBTnSe2XNuGM2\",\n\t\"amount\":1.0\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/wallet/setBalance",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"wallet",
|
||||
"setBalance"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
},
|
||||
{
|
||||
"name": "TRANSFER",
|
||||
"item": [
|
||||
{
|
||||
"name": "transferWallet",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"user_hash\":\"$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.\",\n\t\"wallet_hash\":\"$2a$10$8PJyraUjMoL/h.cQjJyMZedBUlcTjPjNm4j1NuqzQBTnSe2XNuGM2\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/wallet/transfer",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"wallet",
|
||||
"transfer"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TRANSACTION",
|
||||
"item": [
|
||||
{
|
||||
"name": "SEND",
|
||||
"item": [
|
||||
{
|
||||
"name": "sendTransaction",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"source_user_hash\":\"$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.\",\n\t\"source_user_pwd\":\"thomasPwd158$*\",\n\t\"transaction_from\":\"$2a$10$6Z4uNeOgAKhpWYGVYwPWhe6G91lIKHOCA2yYcpzS1pbJyosNNw3Gu\",\n\t\"transaction_to\":\"$2a$10$UKiTo/eqpnvlny3U5xpJ../C2WOgoxebAl3xiexAhinC8X7Jt2wY.\",\n\t\"transaction_amount\":1.0,\n\t\"transaction_unit\":\"gonette\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/transaction/send",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"transaction",
|
||||
"send"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
},
|
||||
{
|
||||
"name": "GET",
|
||||
"item": [
|
||||
{
|
||||
"name": "SENT",
|
||||
"item": [
|
||||
{
|
||||
"name": "getSent",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/transaction/get/sent?wallet_hash=$2a$10$6Z4uNeOgAKhpWYGVYwPWhe6G91lIKHOCA2yYcpzS1pbJyosNNw3Gu",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"transaction",
|
||||
"get",
|
||||
"sent"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "wallet_hash",
|
||||
"value": "$2a$10$6Z4uNeOgAKhpWYGVYwPWhe6G91lIKHOCA2yYcpzS1pbJyosNNw3Gu"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "getAllSent",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/transaction/get/allSent?user_hash=$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"transaction",
|
||||
"get",
|
||||
"allSent"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "user_hash",
|
||||
"value": "$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
},
|
||||
{
|
||||
"name": "RECEIVED",
|
||||
"item": [
|
||||
{
|
||||
"name": "getAllReceived",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/transaction/get/allReceived?user_hash=$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"transaction",
|
||||
"get",
|
||||
"allReceived"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "user_hash",
|
||||
"value": "$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "getReceived",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/transaction/get/received?wallet_hash=$2a$10$6Z4uNeOgAKhpWYGVYwPWhe6G91lIKHOCA2yYcpzS1pbJyosNNw3Gu",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"transaction",
|
||||
"get",
|
||||
"received"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "wallet_hash",
|
||||
"value": "$2a$10$6Z4uNeOgAKhpWYGVYwPWhe6G91lIKHOCA2yYcpzS1pbJyosNNw3Gu"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
},
|
||||
{
|
||||
"name": "getLatest",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/transaction/get/latest?user_hash=$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"transaction",
|
||||
"get",
|
||||
"latest"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "user_hash",
|
||||
"value": "$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "getTransaction",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/transaction/get?wallet_hash=$2a$10$UKiTo/eqpnvlny3U5xpJ../C2WOgoxebAl3xiexAhinC8X7Jt2wY.&txID=ce65025ddddcb26f6b380d54cf9d9b090550cbacadfb63b062f9336a72eeb6bc",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"transaction",
|
||||
"get"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "wallet_hash",
|
||||
"value": "$2a$10$UKiTo/eqpnvlny3U5xpJ../C2WOgoxebAl3xiexAhinC8X7Jt2wY."
|
||||
},
|
||||
{
|
||||
"key": "txID",
|
||||
"value": "ce65025ddddcb26f6b380d54cf9d9b090550cbacadfb63b062f9336a72eeb6bc"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "getAll",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/transaction/getAll?user_hash=$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"transaction",
|
||||
"getAll"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "user_hash",
|
||||
"value": "$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"_postman_isSubFolder": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SESSION",
|
||||
"item": [
|
||||
{
|
||||
"name": "sessiontStart",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"user_hash\":\"$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.\",\n\t\"user_email\":\"thomas.meunier@gmail.com\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/session/start",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"session",
|
||||
"start"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "sessionEnd",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"session_id\":1\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "http://localhost:10053/api/rest/session/end",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "10053",
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"session",
|
||||
"end"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
8
sql/sequence_session_script.sql
Normal file
8
sql/sequence_session_script.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
-- SEQUENCE: public."session_id_seq"
|
||||
|
||||
-- DROP SEQUENCE public."session_id_seq";
|
||||
|
||||
CREATE SEQUENCE public."t_session_id_seq";
|
||||
|
||||
ALTER SEQUENCE public."t_session_id_seq"
|
||||
OWNER TO monnethicadmin;
|
8
sql/sequence_transaction_script.sql
Normal file
8
sql/sequence_transaction_script.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
-- SEQUENCE: public.t_transaction_id_seq"
|
||||
|
||||
-- DROP SEQUENCE public."t_transaction_id_seq";
|
||||
|
||||
CREATE SEQUENCE public."t_transaction_id_seq";
|
||||
|
||||
ALTER SEQUENCE public."t_transaction_id_seq"
|
||||
OWNER TO monnethicadmin;
|
8
sql/sequence_user_script.sql
Normal file
8
sql/sequence_user_script.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
-- SEQUENCE: public."T_USER_user_id_seq"
|
||||
|
||||
-- DROP SEQUENCE public."T_USER_user_id_seq";
|
||||
|
||||
CREATE SEQUENCE public."t_user_id_seq";
|
||||
|
||||
ALTER SEQUENCE public."t_user_id_seq"
|
||||
OWNER TO monnethicadmin;
|
8
sql/sequence_wallet_script.sql
Normal file
8
sql/sequence_wallet_script.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
-- SEQUENCE: public."t_wallet_id_seq"
|
||||
|
||||
-- DROP SEQUENCE public."t_wallet_id_seq";
|
||||
|
||||
CREATE SEQUENCE public."t_wallet_id_seq";
|
||||
|
||||
ALTER SEQUENCE public."t_wallet_id_seq"
|
||||
OWNER TO monnethicadmin;
|
19
sql/table_session_script.sql
Normal file
19
sql/table_session_script.sql
Normal file
|
@ -0,0 +1,19 @@
|
|||
-- Table: public."T_SESSION"
|
||||
|
||||
-- DROP TABLE public."T_SESSION";
|
||||
|
||||
CREATE TABLE public."T_SESSION"
|
||||
(
|
||||
session_id integer NOT NULL DEFAULT nextval('"t_session_id_seq"'::regclass),
|
||||
user_id bigint NOT NULL,
|
||||
start_session bigint NOT NULL,
|
||||
end_session bigint,
|
||||
CONSTRAINT "T_SESSION_pkey" PRIMARY KEY (session_id)
|
||||
)
|
||||
WITH (
|
||||
OIDS = FALSE
|
||||
)
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE public."T_SESSION"
|
||||
OWNER to monnethicadmin;
|
22
sql/table_transaction_script.sql
Normal file
22
sql/table_transaction_script.sql
Normal file
|
@ -0,0 +1,22 @@
|
|||
-- Table: public."T_TRANSACTION"
|
||||
|
||||
-- DROP TABLE public."T_TRANSACTION";
|
||||
|
||||
CREATE TABLE public."T_TRANSACTION"
|
||||
(
|
||||
"transaction_id" integer NOT NULL DEFAULT nextval('"t_transaction_id_seq"'::regclass),
|
||||
"transaction_date" bigint NOT NULL,
|
||||
"transaction_from" character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
"transaction_to" character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
"transaction_hash" character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
"transaction_amount" numeric(255,5) NOT NULL,
|
||||
"transaction_unit" character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
CONSTRAINT "T_TRANSACTION_pkey" PRIMARY KEY ("transaction_id")
|
||||
)
|
||||
WITH (
|
||||
OIDS = FALSE
|
||||
)
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE public."T_TRANSACTION"
|
||||
OWNER to monnethicadmin;
|
27
sql/table_user_script.sql
Normal file
27
sql/table_user_script.sql
Normal file
|
@ -0,0 +1,27 @@
|
|||
-- Table: public."T_USER"
|
||||
|
||||
-- DROP TABLE public."T_USER";
|
||||
|
||||
CREATE TABLE public."T_USER"
|
||||
(
|
||||
user_id integer NOT NULL DEFAULT nextval('"t_user_id_seq"'::regclass),
|
||||
name character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
firstname character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
email character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
password character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
creation_date bigint NOT NULL,
|
||||
modification_date bigint NOT NULL,
|
||||
phone character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
association character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
verified boolean NOT NULL,
|
||||
approved boolean NOT NULL,
|
||||
user_hash character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
CONSTRAINT "T_USER_pkey" PRIMARY KEY (user_id)
|
||||
)
|
||||
WITH (
|
||||
OIDS = FALSE
|
||||
)
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE public."T_USER"
|
||||
OWNER to monnethicadmin;
|
23
sql/table_wallet_script.sql
Normal file
23
sql/table_wallet_script.sql
Normal file
|
@ -0,0 +1,23 @@
|
|||
-- Table: public."T_WALLET"
|
||||
|
||||
-- DROP TABLE public."T_WALLET";
|
||||
|
||||
CREATE TABLE public."T_WALLET"
|
||||
(
|
||||
wallet_id integer NOT NULL DEFAULT nextval('"t_wallet_id_seq"'::regclass),
|
||||
wallet_hash character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
user_hash character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
type character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||
balance numeric(255,5) NOT NULL,
|
||||
creation_date bigint NOT NULL,
|
||||
modification_date bigint NOT NULL,
|
||||
is_active boolean NOT NULL,
|
||||
CONSTRAINT "T_WALLET_pkey" PRIMARY KEY (wallet_id)
|
||||
)
|
||||
WITH (
|
||||
OIDS = FALSE
|
||||
)
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE public."T_WALLET"
|
||||
OWNER to monnethicadmin;
|
|
@ -1,11 +1,10 @@
|
|||
package Application;
|
||||
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;
|
||||
|
||||
|
@ -13,7 +12,7 @@ import java.util.Collections;
|
|||
public class App {
|
||||
public static void main(String [ ] args){
|
||||
SpringApplication app = new SpringApplication(App.class);
|
||||
app.setDefaultProperties(Collections.singletonMap("server.port","8083"));
|
||||
app.setDefaultProperties(Collections.singletonMap("server.port","10053"));
|
||||
app.run(args);
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package blockchain.client;
|
||||
|
||||
|
||||
import blockchain.configuration.AppConfig;
|
||||
import blockchain.configuration.Config;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
|
@ -35,6 +36,11 @@ public class ChannelClientWrapper {
|
|||
this.fabricClientWrapper=fabricClientWrapper;
|
||||
}
|
||||
|
||||
public Collection<ProposalResponse> queryByChainCode(QueryByChaincodeRequest queryByChaincodeRequest) throws InvalidArgumentException, ProposalException {
|
||||
return channel.queryByChaincode(queryByChaincodeRequest);
|
||||
}
|
||||
|
||||
|
||||
public Collection<ProposalResponse> queryByChainCode(String chaincodeName,String fuctionName, String[] args) throws InvalidArgumentException, ProposalException {
|
||||
QueryByChaincodeRequest request = fabricClientWrapper.getClient().newQueryProposalRequest();
|
||||
ChaincodeID chaincodeID = ChaincodeID.newBuilder().setName(chaincodeName).build();
|
||||
|
@ -51,15 +57,12 @@ public class ChannelClientWrapper {
|
|||
|
||||
//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);
|
||||
Peer peer = fabricClientWrapper.getClient().newPeer(Config.ORG1_PEER_0,AppConfig.getPEER_0_URL());
|
||||
Orderer orderer = fabricClientWrapper.getClient().newOrderer(Config.ORDERER_NAME,AppConfig.getORDERER_URL());
|
||||
channel.addPeer(peer);
|
||||
channel.addEventHub(eventHub);
|
||||
channel.addOrderer(orderer);
|
||||
channel.initialize();
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package blockchain.client;
|
||||
|
||||
import blockchain.configuration.AppConfig;
|
||||
import blockchain.configuration.Config;
|
||||
import blockchain.user.UserContext;
|
||||
import org.hyperledger.fabric.sdk.*;
|
||||
|
@ -28,16 +29,13 @@ public class FabricClientWrapper {
|
|||
|
||||
public ChannelClientWrapper createChannelClient(String name) throws InvalidArgumentException {
|
||||
Channel channel = client.newChannel(name);
|
||||
ChannelClientWrapper channelClientWrapper = new ChannelClientWrapper(name, channel, this);
|
||||
return channelClientWrapper;
|
||||
return new ChannelClientWrapper(name, channel, this);
|
||||
}
|
||||
|
||||
public Set<String> 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);
|
||||
client.newOrderer(Config.ORDERER_NAME,AppConfig.getORDERER_URL());
|
||||
Peer peer = client.newPeer(Config.ORG1_PEER_0,AppConfig.getPEER_0_URL());
|
||||
return client.queryChannels(peer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
59
src/main/java/blockchain/configuration/AppConfig.java
Normal file
59
src/main/java/blockchain/configuration/AppConfig.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
package blockchain.configuration;
|
||||
|
||||
public class AppConfig {
|
||||
// 0 = Actual & 1 = Back-up
|
||||
private static int ENV = 0;
|
||||
// 0 = PROD & 1 = QA & 2 = TEST
|
||||
private static int CHAINCODE_IDX = 0;
|
||||
|
||||
// ENVIRONMENT
|
||||
public static String getCA_URL(){
|
||||
if(ENV==0){
|
||||
return "http://vps577432.ovh.net:7054";
|
||||
} else {
|
||||
return "http://vps592802.ovh.net:7054";
|
||||
}
|
||||
}
|
||||
public static String getORDERER_URL(){
|
||||
if(ENV==0){
|
||||
return "grpc://vps577432.ovh.net:7050";
|
||||
}else {
|
||||
return "grpc://vps592802.ovh.net:7050";
|
||||
}
|
||||
}
|
||||
public static String getPEER_0_URL(){
|
||||
if(ENV==0){
|
||||
return "grpc://vps577432.ovh.net:7051";
|
||||
} else {
|
||||
return "grpc://vps592802.ovh.net:7051";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CHAINCODE
|
||||
public static String getCHAINCODE(){
|
||||
if(CHAINCODE_IDX==0){
|
||||
return "monnethic_prod";
|
||||
}else {
|
||||
return "monnethic_qa";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// DB
|
||||
public static String getDATABASE(){
|
||||
if(CHAINCODE_IDX==0){
|
||||
return "monnethic_prod";
|
||||
}else if(CHAINCODE_IDX==1) {
|
||||
return "monnethic_qa";
|
||||
}else{
|
||||
return "monnethic_test";
|
||||
}
|
||||
}
|
||||
|
||||
public static void setENV(int newEnv){
|
||||
ENV = newEnv;
|
||||
}
|
||||
public static String getENV(){ return String.valueOf(ENV); }
|
||||
public static void setCHAINCODE_IDX(int newChaincode){ CHAINCODE_IDX = newChaincode; }
|
||||
}
|
|
@ -1,51 +1,27 @@
|
|||
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";
|
||||
|
||||
//ORDERER NAME
|
||||
public static final String ORDERER_NAME = "orderer.example.com";
|
||||
|
||||
//CHANNEL - CHAINCODE
|
||||
//CHANNEL NAME
|
||||
public static final String CHANNEL_NAME = "mychannel";
|
||||
|
||||
public static final String CHAINCODE_NAME = "mycc";
|
||||
|
||||
//PEER 0
|
||||
//PEER 0 NAME
|
||||
public static final String ORG1_PEER_0 = "peer0.org1.example.com";
|
||||
|
||||
public static final String ORG1_PEER_0_URL = "grpc://vps577432.ovh.net:8051";
|
||||
//USER
|
||||
//public static final String UserPWD = "OelXVCdHnYPe";
|
||||
|
||||
//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";
|
||||
|
||||
}
|
||||
|
|
|
@ -2,52 +2,49 @@ package blockchain.query;
|
|||
|
||||
import blockchain.client.ChannelClientWrapper;
|
||||
import blockchain.client.FabricClientWrapper;
|
||||
import blockchain.configuration.AppConfig;
|
||||
import blockchain.configuration.Config;
|
||||
import blockchain.user.UserContext;
|
||||
import blockchain.utility.Util;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.hyperledger.fabric.sdk.ChaincodeID;
|
||||
import org.hyperledger.fabric.sdk.ChaincodeResponse;
|
||||
import org.hyperledger.fabric.sdk.ProposalResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.hyperledger.fabric.sdk.QueryByChaincodeRequest;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class QueryWrapper {
|
||||
|
||||
public String getUserBalance(String userHashId){
|
||||
public String sendQuery(String functionName,String[] args) throws Exception {
|
||||
BasicConfigurator.configure();
|
||||
UserContext user = Util.readUserContext(Config.ORG1, "admin");
|
||||
String response = null;
|
||||
try{
|
||||
UserContext userContext = Util.readUserContext(Config.ORG1,"User-org1");
|
||||
String chaincode = Config.CHAINCODE_NAME;
|
||||
FabricClientWrapper fabricClientWrapper = new FabricClientWrapper(userContext);
|
||||
|
||||
FabricClientWrapper fabricClientWrapper = new FabricClientWrapper(user);
|
||||
ChannelClientWrapper channelClientWrapper = ChannelClientWrapper.setupChannel(fabricClientWrapper);
|
||||
|
||||
String[] args = {userHashId};
|
||||
ChaincodeID chaincodeID = ChaincodeID.newBuilder().setName(AppConfig.getCHAINCODE()).build();
|
||||
QueryByChaincodeRequest queryByChaincodeRequest = fabricClientWrapper.getClient().newQueryProposalRequest();
|
||||
queryByChaincodeRequest.setArgs(args);
|
||||
queryByChaincodeRequest.setFcn(functionName);
|
||||
queryByChaincodeRequest.setChaincodeID(chaincodeID);
|
||||
queryByChaincodeRequest.setProposalWaitTime(12000);
|
||||
|
||||
Collection<ProposalResponse> responseQuery = channelClientWrapper.queryByChainCode(chaincode,"query",args);
|
||||
for(ProposalResponse pres : responseQuery){
|
||||
ChaincodeResponse.Status status = pres.getStatus();
|
||||
if(status.getStatus()!=200){
|
||||
throw new Exception(pres.getMessage());
|
||||
Collection<ProposalResponse> queryProposals;
|
||||
|
||||
try {
|
||||
queryProposals = channelClientWrapper.queryByChainCode(queryByChaincodeRequest);
|
||||
} catch (Exception e) {
|
||||
throw new Exception(e);
|
||||
}
|
||||
|
||||
response = new String(pres.getChaincodeActionResponsePayload());
|
||||
for (ProposalResponse proposalResponse : queryProposals) {
|
||||
if (!proposalResponse.isVerified() || proposalResponse.getStatus() != ChaincodeResponse.Status.SUCCESS) {
|
||||
} else {
|
||||
response = new String(proposalResponse.getChaincodeActionResponsePayload());
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(response==null) response = "Error";
|
||||
return response;
|
||||
}
|
||||
|
||||
public String getUser(String userHashId){
|
||||
return "";
|
||||
}
|
||||
|
||||
public List<String> getUserLastTransactions(String userHashId){
|
||||
List<String> transactions = new ArrayList<>();
|
||||
return transactions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,40 +2,57 @@ package blockchain.query;
|
|||
|
||||
import blockchain.client.ChannelClientWrapper;
|
||||
import blockchain.client.FabricClientWrapper;
|
||||
import blockchain.configuration.AppConfig;
|
||||
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 org.apache.log4j.BasicConfigurator;
|
||||
import org.hyperledger.fabric.sdk.*;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
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);
|
||||
public BlockEvent.TransactionEvent sendTransaction(String functionName, String[] args) throws Exception {
|
||||
BasicConfigurator.configure();
|
||||
UserContext user = Util.readUserContext(Config.ORG1,"admin");
|
||||
|
||||
ChannelClientWrapper channelClientWrapper = ChannelClientWrapper.setupChannel(fabricClientWrapper);
|
||||
Collection<ProposalResponse> successful = new LinkedList<>();
|
||||
FabricClientWrapper 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<ProposalResponse> responses = channelClientWrapper.sendTransactionProposal(tpr);
|
||||
BlockEvent.TransactionEvent event = channelClientWrapper.sendTransaction(responses);
|
||||
|
||||
return event.getTransactionID();
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
if(user != null){
|
||||
fabricClientWrapper = new FabricClientWrapper(user);
|
||||
} else {
|
||||
throw new Exception("No UserContext");
|
||||
}
|
||||
|
||||
ChannelClientWrapper channelClientWrapper = fabricClientWrapper.createChannelClient(Config.CHANNEL_NAME);
|
||||
|
||||
//INIT CHANNEL FOR QUERY
|
||||
Channel channel = channelClientWrapper.getChannel();
|
||||
Orderer orderer = fabricClientWrapper.getClient().newOrderer(Config.ORDERER_NAME,AppConfig.getORDERER_URL());
|
||||
channel.addOrderer(orderer);
|
||||
Peer peer = fabricClientWrapper.getClient().newPeer(Config.ORG1_PEER_0,AppConfig.getPEER_0_URL());
|
||||
channel.addPeer(peer);
|
||||
channel.initialize();
|
||||
//
|
||||
|
||||
//Prepare transaction
|
||||
TransactionProposalRequest tpr = fabricClientWrapper.getClient().newTransactionProposalRequest();
|
||||
ChaincodeID cid = ChaincodeID.newBuilder().setName(AppConfig.getCHAINCODE()).build();
|
||||
tpr.setChaincodeID(cid);
|
||||
tpr.setFcn(functionName);
|
||||
tpr.setArgs(args);
|
||||
tpr.setProposalWaitTime(120000);
|
||||
|
||||
Collection<ProposalResponse> invokePropResp = channel.sendTransactionProposal(tpr); //Send proposal transaction
|
||||
for(ProposalResponse response : invokePropResp){
|
||||
if (response.getStatus() == ChaincodeResponse.Status.SUCCESS) {
|
||||
successful.add(response);
|
||||
} else {
|
||||
throw new Exception("Error during insert into Blockchain");
|
||||
}
|
||||
}
|
||||
return channelClientWrapper.sendTransaction(successful); //Send successful transaction to orderer
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package blockchain.utility;
|
|||
|
||||
|
||||
import blockchain.user.UserContext;
|
||||
import database.user.User;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
@ -57,34 +58,30 @@ public class Util {
|
|||
}
|
||||
|
||||
public static UserContext readUserContext(String affiliation, String username) {
|
||||
ObjectInputStream ois = null;
|
||||
UserContext userContext = null;
|
||||
FileInputStream fileStream = null;
|
||||
ObjectInputStream in = null;
|
||||
try {
|
||||
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();
|
||||
final FileInputStream fis = new FileInputStream(filePath);
|
||||
ois = new ObjectInputStream(fis);
|
||||
userContext = (UserContext) ois.readObject();
|
||||
|
||||
logger.info("userContext : "+userContext.getName());
|
||||
|
||||
}catch (IOException e){
|
||||
logger.warn("error : "+e);
|
||||
}catch (ClassNotFoundException e){
|
||||
logger.warn("error : "+e);
|
||||
} finally {
|
||||
try {
|
||||
if (in != null)
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
try{
|
||||
if(ois!=null){
|
||||
ois.close();
|
||||
}
|
||||
}catch (IOException e){
|
||||
logger.warn("error : "+e);
|
||||
}
|
||||
try {
|
||||
if (fileStream != null)
|
||||
fileStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return userContext;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
31
src/main/java/database/DatabaseHelper.java
Normal file
31
src/main/java/database/DatabaseHelper.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
package database;
|
||||
|
||||
import blockchain.configuration.AppConfig;
|
||||
import com.j256.ormlite.jdbc.JdbcConnectionSource;
|
||||
import com.j256.ormlite.support.ConnectionSource;
|
||||
|
||||
public class DatabaseHelper {
|
||||
private static final String DATABASE_USER = "monnethicadmin";
|
||||
private static final String DATABASE_PWD = "vHEQszGXcJ6;/)}z!V";
|
||||
private final static String DATABASE_URL = "jdbc:postgresql://37.187.101.44:5432/";
|
||||
|
||||
private static JdbcConnectionSource jdbcConnectionSource;
|
||||
|
||||
public ConnectionSource setupDatabaseConnection(){
|
||||
try{
|
||||
jdbcConnectionSource = new JdbcConnectionSource(DATABASE_URL+AppConfig.getDATABASE(), DATABASE_USER, DATABASE_PWD);
|
||||
return jdbcConnectionSource;
|
||||
}catch (Exception e){
|
||||
System.out.print("\n"+e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeConnection(){
|
||||
try{
|
||||
jdbcConnectionSource.close();
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
50
src/main/java/database/Wallet/BalanceWallet.java
Normal file
50
src/main/java/database/Wallet/BalanceWallet.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package database.Wallet;
|
||||
|
||||
public class BalanceWallet {
|
||||
private String association_hash;
|
||||
private String assocation_pwd;
|
||||
private String wallet_hash;
|
||||
private double amount;
|
||||
|
||||
public BalanceWallet() {
|
||||
}
|
||||
|
||||
public BalanceWallet(String association_hash, String assocation_pwd, String wallet_hash, double amount) {
|
||||
this.association_hash = association_hash;
|
||||
this.assocation_pwd = assocation_pwd;
|
||||
this.wallet_hash = wallet_hash;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getAssociation_hash() {
|
||||
return association_hash;
|
||||
}
|
||||
|
||||
public void setAssociation_hash(String association_hash) {
|
||||
this.association_hash = association_hash;
|
||||
}
|
||||
|
||||
public String getAssocation_pwd() {
|
||||
return assocation_pwd;
|
||||
}
|
||||
|
||||
public void setAssocation_pwd(String assocation_pwd) {
|
||||
this.assocation_pwd = assocation_pwd;
|
||||
}
|
||||
|
||||
public String getWallet_hash() {
|
||||
return wallet_hash;
|
||||
}
|
||||
|
||||
public void setWallet_hash(String wallet_hash) {
|
||||
this.wallet_hash = wallet_hash;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
115
src/main/java/database/Wallet/Wallet.java
Normal file
115
src/main/java/database/Wallet/Wallet.java
Normal file
|
@ -0,0 +1,115 @@
|
|||
package database.Wallet;
|
||||
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
|
||||
@DatabaseTable(tableName = "T_WALLET")
|
||||
public class Wallet {
|
||||
@DatabaseField(generatedId = true)
|
||||
private int wallet_id;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String wallet_hash;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String user_hash;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String type;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private Double balance;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private long creation_date;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private long modification_date;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private boolean is_active;
|
||||
|
||||
//Constructors
|
||||
//Default constructor for ORMLite
|
||||
public Wallet() {
|
||||
}
|
||||
|
||||
public Wallet(String type,String user_hash){
|
||||
this.type=type;
|
||||
this.user_hash=user_hash;
|
||||
}
|
||||
|
||||
public Wallet(String wallet_hash, String user_hash, String type, boolean isActive) {
|
||||
this.wallet_hash = wallet_hash;
|
||||
this.user_hash = user_hash;
|
||||
this.type = type;
|
||||
this.is_active = isActive;
|
||||
}
|
||||
|
||||
public Wallet(String wallet_hash, String user_hash, String type, Double balance, boolean isActive) {
|
||||
this.wallet_hash = wallet_hash;
|
||||
this.user_hash = user_hash;
|
||||
this.type = type;
|
||||
this.balance = balance;
|
||||
this.is_active = isActive;
|
||||
}
|
||||
|
||||
public int getWallet_id() {
|
||||
return wallet_id;
|
||||
}
|
||||
|
||||
public void setWallet_id(int wallet_id) {
|
||||
this.wallet_id = wallet_id;
|
||||
}
|
||||
|
||||
public String getWallet_hash() {
|
||||
return wallet_hash;
|
||||
}
|
||||
public void setWallet_hash(String wallet_hash) {
|
||||
this.wallet_hash = wallet_hash;
|
||||
}
|
||||
|
||||
public String getUser_hash() {
|
||||
return user_hash;
|
||||
}
|
||||
public void setUser_hash(String user_hash) {
|
||||
this.user_hash = user_hash;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Double getBalance() {
|
||||
return balance;
|
||||
}
|
||||
public void setBalance(Double balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public boolean is_active() {
|
||||
return is_active;
|
||||
}
|
||||
|
||||
public void setIs_active(boolean is_active) {
|
||||
this.is_active = is_active;
|
||||
}
|
||||
|
||||
public long getCreation_date() {
|
||||
return creation_date;
|
||||
}
|
||||
|
||||
public void setCreation_date(long creation_date) {
|
||||
this.creation_date = creation_date;
|
||||
}
|
||||
|
||||
public long getModification_date() {
|
||||
return modification_date;
|
||||
}
|
||||
|
||||
public void setModification_date(long modification_date) {
|
||||
this.modification_date = modification_date;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{wallet_hash:"+wallet_hash+",user_hash:"+user_hash+",type:"+type+",balance:"+balance+"}";
|
||||
}
|
||||
}
|
97
src/main/java/database/Wallet/WalletDao.java
Normal file
97
src/main/java/database/Wallet/WalletDao.java
Normal file
|
@ -0,0 +1,97 @@
|
|||
package database.Wallet;
|
||||
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
import com.j256.ormlite.dao.DaoManager;
|
||||
import com.j256.ormlite.stmt.PreparedQuery;
|
||||
import com.j256.ormlite.stmt.QueryBuilder;
|
||||
import com.j256.ormlite.stmt.UpdateBuilder;
|
||||
import database.DatabaseHelper;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
public class WalletDao {
|
||||
private DatabaseHelper dbh = new DatabaseHelper();
|
||||
private Dao<Wallet, String> walletDao;
|
||||
private boolean sessionOpen = false;
|
||||
private void createWalletDaoConnection(){
|
||||
try {
|
||||
if(!sessionOpen){
|
||||
walletDao = DaoManager.createDao(dbh.setupDatabaseConnection(),Wallet.class);
|
||||
sessionOpen=true;
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addWallet(Wallet wallet)throws Exception {
|
||||
createWalletDaoConnection();
|
||||
walletDao.create(wallet);
|
||||
DatabaseHelper.closeConnection();
|
||||
}
|
||||
|
||||
public Wallet getWallet(String walletHash) throws Exception {
|
||||
createWalletDaoConnection();
|
||||
QueryBuilder<Wallet, String> queryBuilder = walletDao.queryBuilder();
|
||||
queryBuilder.where().eq("wallet_hash",walletHash).and().eq("is_active",true);
|
||||
PreparedQuery<Wallet> preparedQuery = queryBuilder.prepare();
|
||||
Wallet w = walletDao.queryForFirst(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return w;
|
||||
}
|
||||
|
||||
public void updateWalletBalance(String walletHash, double newBalance) throws Exception {
|
||||
createWalletDaoConnection();
|
||||
UpdateBuilder<Wallet, String> updateBuilder = walletDao.updateBuilder();
|
||||
long now = Instant.now().toEpochMilli();
|
||||
updateBuilder.updateColumnValue("balance",newBalance);
|
||||
updateBuilder.updateColumnValue("modification_date",now);
|
||||
updateBuilder.where().eq("wallet_hash",walletHash);
|
||||
updateBuilder.update();
|
||||
DatabaseHelper.closeConnection();
|
||||
}
|
||||
|
||||
public List<Wallet> getUserWallet(String userHash) throws Exception {
|
||||
createWalletDaoConnection();
|
||||
QueryBuilder<Wallet, String> queryBuilder = walletDao.queryBuilder();
|
||||
queryBuilder.where().eq("user_hash",userHash).and().eq("is_active",true);
|
||||
PreparedQuery<Wallet> preparedQuery = queryBuilder.prepare();
|
||||
List<Wallet> w = walletDao.query(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return w;
|
||||
}
|
||||
|
||||
public List<Wallet> getUserOldWallets(String userHash) throws Exception{
|
||||
createWalletDaoConnection();
|
||||
QueryBuilder<Wallet, String> queryBuilder = walletDao.queryBuilder();
|
||||
queryBuilder.where().eq("user_hash",userHash).and().eq("is_active",false);
|
||||
PreparedQuery<Wallet> preparedQuery = queryBuilder.prepare();
|
||||
List<Wallet> w = walletDao.query(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return w;
|
||||
}
|
||||
|
||||
public void transferWallet(String walletHash, String newUserHash) throws Exception{
|
||||
createWalletDaoConnection();
|
||||
UpdateBuilder<Wallet, String> updateBuilder = walletDao.updateBuilder();
|
||||
updateBuilder.updateColumnValue("user_hash",newUserHash);
|
||||
long now = Instant.now().toEpochMilli();
|
||||
updateBuilder.updateColumnValue("modification_date",now);
|
||||
updateBuilder.where().eq("wallet_hash",walletHash).and().eq("is_active",true);
|
||||
updateBuilder.update();
|
||||
DatabaseHelper.closeConnection();
|
||||
}
|
||||
|
||||
public void deleteWallet(String walletHash, String userHash) throws Exception{
|
||||
createWalletDaoConnection();
|
||||
UpdateBuilder<Wallet, String> updateBuilder = walletDao.updateBuilder();
|
||||
updateBuilder.updateColumnValue("is_active",false);
|
||||
long now = Instant.now().toEpochMilli();
|
||||
updateBuilder.updateColumnValue("modification_date",now);
|
||||
updateBuilder.where().eq("wallet_hash",walletHash).and().eq("user_hash",userHash);
|
||||
updateBuilder.update();
|
||||
DatabaseHelper.closeConnection();
|
||||
}
|
||||
|
||||
}
|
57
src/main/java/database/session/Session.java
Normal file
57
src/main/java/database/session/Session.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package database.session;
|
||||
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
@DatabaseTable(tableName = "T_SESSION")
|
||||
public class Session {
|
||||
@DatabaseField(generatedId = true)
|
||||
private int session_id;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private int user_id;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private long start_session;
|
||||
@DatabaseField
|
||||
private long end_session;
|
||||
|
||||
public Session(){}
|
||||
|
||||
public Session(int user_id, long start_session) {
|
||||
this.user_id = user_id;
|
||||
this.start_session = start_session;
|
||||
}
|
||||
|
||||
public int getSession_id() {
|
||||
return session_id;
|
||||
}
|
||||
|
||||
public void setSession_id(int session_id) {
|
||||
this.session_id = session_id;
|
||||
}
|
||||
|
||||
public int getUser_id() {
|
||||
return user_id;
|
||||
}
|
||||
|
||||
public void setUser_id(int user_id) {
|
||||
this.user_id = user_id;
|
||||
}
|
||||
|
||||
public long getStart_session() {
|
||||
return start_session;
|
||||
}
|
||||
|
||||
public void setStart_session(long start_session) {
|
||||
this.start_session = start_session;
|
||||
}
|
||||
|
||||
public long getEnd_session() {
|
||||
return end_session;
|
||||
}
|
||||
|
||||
public void setEnd_session(long end_session) {
|
||||
this.end_session = end_session;
|
||||
}
|
||||
|
||||
|
||||
}
|
42
src/main/java/database/session/SessionDao.java
Normal file
42
src/main/java/database/session/SessionDao.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package database.session;
|
||||
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
import com.j256.ormlite.dao.DaoManager;
|
||||
import com.j256.ormlite.stmt.UpdateBuilder;
|
||||
import database.DatabaseHelper;
|
||||
import java.time.Instant;
|
||||
|
||||
public class SessionDao {
|
||||
private DatabaseHelper dbh = new DatabaseHelper();
|
||||
private Dao<Session, String> sessionDao;
|
||||
private boolean sessionOpen = false;
|
||||
private void createSessionDaoConnection(){
|
||||
try {
|
||||
if(!sessionOpen){
|
||||
sessionDao = DaoManager.createDao(dbh.setupDatabaseConnection(),Session.class);
|
||||
sessionOpen=true;
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public int setStartSession(Session session) throws Exception {
|
||||
createSessionDaoConnection();
|
||||
sessionDao.create(session);
|
||||
int Session_id = session.getSession_id();
|
||||
DatabaseHelper.closeConnection();
|
||||
return Session_id;
|
||||
}
|
||||
|
||||
public void setEndSession(int session_id) throws Exception {
|
||||
createSessionDaoConnection();
|
||||
UpdateBuilder<Session,String> updateBuilder = sessionDao.updateBuilder();
|
||||
long now = Instant.now().toEpochMilli();
|
||||
updateBuilder.updateColumnValue("end_session",now);
|
||||
updateBuilder.where().eq("session_id",session_id);
|
||||
updateBuilder.update();
|
||||
DatabaseHelper.closeConnection();
|
||||
}
|
||||
}
|
71
src/main/java/database/transaction/SendingTransaction.java
Normal file
71
src/main/java/database/transaction/SendingTransaction.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
package database.transaction;
|
||||
|
||||
public class SendingTransaction {
|
||||
private String source_user_hash;
|
||||
private String source_user_pwd;
|
||||
private String transaction_from;
|
||||
private String transaction_to;
|
||||
private String transaction_amount;
|
||||
private String transaction_unit;
|
||||
|
||||
public SendingTransaction() {
|
||||
}
|
||||
|
||||
public SendingTransaction(String source_user_hash, String source_user_pwd, String transaction_from, String transaction_to, String transaction_amount, String transaction_unit) {
|
||||
this.source_user_hash = source_user_hash;
|
||||
this.source_user_pwd = source_user_pwd;
|
||||
this.transaction_from = transaction_from;
|
||||
this.transaction_to = transaction_to;
|
||||
this.transaction_amount = transaction_amount;
|
||||
this.transaction_unit = transaction_unit;
|
||||
}
|
||||
|
||||
|
||||
public String getSource_user_hash() {
|
||||
return source_user_hash;
|
||||
}
|
||||
|
||||
public void setSource_user_hash(String source_user_hash) {
|
||||
this.source_user_hash = source_user_hash;
|
||||
}
|
||||
|
||||
public String getSource_user_pwd() {
|
||||
return source_user_pwd;
|
||||
}
|
||||
|
||||
public void setSource_user_pwd(String source_user_pwd) {
|
||||
this.source_user_pwd = source_user_pwd;
|
||||
}
|
||||
|
||||
public String getTransaction_from() {
|
||||
return transaction_from;
|
||||
}
|
||||
|
||||
public void setTransaction_from(String transaction_from) {
|
||||
this.transaction_from = transaction_from;
|
||||
}
|
||||
|
||||
public String getTransaction_to() {
|
||||
return transaction_to;
|
||||
}
|
||||
|
||||
public void setTransaction_to(String transaction_to) {
|
||||
this.transaction_to = transaction_to;
|
||||
}
|
||||
|
||||
public String getTransaction_amount() {
|
||||
return transaction_amount;
|
||||
}
|
||||
|
||||
public void setTransaction_amount(String transaction_amount) {
|
||||
this.transaction_amount = transaction_amount;
|
||||
}
|
||||
|
||||
public String getTransaction_unit() {
|
||||
return transaction_unit;
|
||||
}
|
||||
|
||||
public void setTransaction_unit(String transaction_unit) {
|
||||
this.transaction_unit = transaction_unit;
|
||||
}
|
||||
}
|
113
src/main/java/database/transaction/Transaction.java
Normal file
113
src/main/java/database/transaction/Transaction.java
Normal file
|
@ -0,0 +1,113 @@
|
|||
package database.transaction;
|
||||
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@DatabaseTable(tableName = "T_TRANSACTION")
|
||||
public class Transaction implements Comparable<Transaction>{
|
||||
@DatabaseField(generatedId = true)
|
||||
private int transaction_id;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private long transaction_date;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String transaction_from;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String transaction_to;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String transaction_hash;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private double transaction_amount;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String transaction_unit;
|
||||
|
||||
public Transaction() {
|
||||
}
|
||||
|
||||
public Transaction(int transaction_id, long transaction_date, String transaction_from, String transaction_to, String transaction_hash, double transaction_amount, String transaction_unit) {
|
||||
this.transaction_id = transaction_id;
|
||||
this.transaction_date = transaction_date;
|
||||
this.transaction_from = transaction_from;
|
||||
this.transaction_to = transaction_to;
|
||||
this.transaction_hash = transaction_hash;
|
||||
this.transaction_amount = transaction_amount;
|
||||
this.transaction_unit = transaction_unit;
|
||||
}
|
||||
|
||||
public int getTransaction_id() {
|
||||
return transaction_id;
|
||||
}
|
||||
|
||||
public void setTransaction_id(int transaction_id) {
|
||||
this.transaction_id = transaction_id;
|
||||
}
|
||||
|
||||
public long getTransaction_date() {
|
||||
return transaction_date;
|
||||
}
|
||||
|
||||
public void setTransaction_date(long transaction_date) {
|
||||
this.transaction_date = transaction_date;
|
||||
}
|
||||
|
||||
public String getTransaction_from() {
|
||||
return transaction_from;
|
||||
}
|
||||
|
||||
public void setTransaction_from(String transaction_from) {
|
||||
this.transaction_from = transaction_from;
|
||||
}
|
||||
|
||||
public String getTransaction_to() {
|
||||
return transaction_to;
|
||||
}
|
||||
|
||||
public void setTransaction_to(String transaction_to) {
|
||||
this.transaction_to = transaction_to;
|
||||
}
|
||||
|
||||
public String getTransaction_hash() {
|
||||
return transaction_hash;
|
||||
}
|
||||
|
||||
public void setTransaction_hash(String transaction_hash) {
|
||||
this.transaction_hash = transaction_hash;
|
||||
}
|
||||
|
||||
public double getTransaction_amount() {
|
||||
return transaction_amount;
|
||||
}
|
||||
|
||||
public void setTransaction_amount(double transaction_amount) {
|
||||
this.transaction_amount = transaction_amount;
|
||||
}
|
||||
|
||||
public String getTransaction_unit() {
|
||||
return transaction_unit;
|
||||
}
|
||||
|
||||
public void setTransaction_unit(String transaction_unit) {
|
||||
this.transaction_unit = transaction_unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Transaction{" +
|
||||
"transaction_id=" + transaction_id +
|
||||
", transaction_date=" + transaction_date +
|
||||
", transaction_from='" + transaction_from + '\'' +
|
||||
", transaction_to='" + transaction_to + '\'' +
|
||||
", transaction_hash='" + transaction_hash + '\'' +
|
||||
", transaction_amount=" + transaction_amount +
|
||||
", transaction_unit='" + transaction_unit + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Transaction t){
|
||||
Date date1 = new Date(getTransaction_date());
|
||||
Date date2 = new Date(t.getTransaction_date());
|
||||
return date1.compareTo(date2);
|
||||
}
|
||||
}
|
141
src/main/java/database/transaction/TransactionDao.java
Normal file
141
src/main/java/database/transaction/TransactionDao.java
Normal file
|
@ -0,0 +1,141 @@
|
|||
package database.transaction;
|
||||
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
import com.j256.ormlite.dao.DaoManager;
|
||||
import com.j256.ormlite.stmt.PreparedQuery;
|
||||
import com.j256.ormlite.stmt.QueryBuilder;
|
||||
import database.DatabaseHelper;
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
public class TransactionDao {
|
||||
private DatabaseHelper dbh = new DatabaseHelper();
|
||||
private Dao<Transaction, String> transactionDao;
|
||||
private boolean sessionOpen = false;
|
||||
private void createTransactionDaoConnection(){
|
||||
try {
|
||||
if(!sessionOpen){
|
||||
transactionDao = DaoManager.createDao(dbh.setupDatabaseConnection(),Transaction.class);
|
||||
sessionOpen=true;
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addTransaction(Transaction transaction)throws Exception{
|
||||
createTransactionDaoConnection();
|
||||
transactionDao.create(transaction);
|
||||
DatabaseHelper.closeConnection();
|
||||
}
|
||||
|
||||
public List<Transaction> getWalletTransactions(String wallet_hash, int size)throws Exception{
|
||||
createTransactionDaoConnection();
|
||||
QueryBuilder<Transaction, String> queryBuilder = transactionDao.queryBuilder();
|
||||
queryBuilder.where().eq("transaction_from",wallet_hash).or().eq("transaction_to",wallet_hash);
|
||||
|
||||
if(size!=0){
|
||||
queryBuilder.limit(new Long(size));
|
||||
}
|
||||
|
||||
queryBuilder.orderBy("transaction_date",false);
|
||||
PreparedQuery<Transaction> preparedQuery = queryBuilder.prepare();
|
||||
List<Transaction> t = transactionDao.query(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return t;
|
||||
}
|
||||
|
||||
public Transaction getTransaction(String wallet_hash, String transaction_hash)throws Exception{
|
||||
createTransactionDaoConnection();
|
||||
QueryBuilder<Transaction, String> queryBuilder = transactionDao.queryBuilder();
|
||||
queryBuilder.where().eq("transaction_to",wallet_hash).or().eq("transaction_from",wallet_hash).and().eq("transaction_hash",transaction_hash);
|
||||
PreparedQuery<Transaction> preparedQuery = queryBuilder.prepare();
|
||||
Transaction t = transactionDao.queryForFirst(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return t;
|
||||
}
|
||||
|
||||
public List<Transaction> getSentTransactions(String wallet_hash, int number)throws Exception{
|
||||
createTransactionDaoConnection();
|
||||
QueryBuilder<Transaction, String> queryBuilder = transactionDao.queryBuilder();
|
||||
queryBuilder.where().eq("transaction_from",wallet_hash);
|
||||
|
||||
if(number!=0){
|
||||
queryBuilder.limit(new Long(number));
|
||||
}
|
||||
|
||||
queryBuilder.orderBy("transaction_date",false);
|
||||
PreparedQuery<Transaction> preparedQuery = queryBuilder.prepare();
|
||||
List<Transaction> t = transactionDao.query(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return t;
|
||||
}
|
||||
|
||||
public List<Transaction> getReceivedTransactions(String wallet_hash, int number)throws Exception{
|
||||
createTransactionDaoConnection();
|
||||
QueryBuilder<Transaction, String> queryBuilder = transactionDao.queryBuilder();
|
||||
queryBuilder.where().eq("transaction_to",wallet_hash);
|
||||
|
||||
if(number!=0){
|
||||
queryBuilder.limit(new Long(number));
|
||||
}
|
||||
|
||||
queryBuilder.orderBy("transaction_date",false);
|
||||
PreparedQuery<Transaction> preparedQuery = queryBuilder.prepare();
|
||||
List<Transaction> t = transactionDao.query(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return t;
|
||||
}
|
||||
|
||||
public List<Transaction> getAllTransactionBetweenDate(String wallet_hash, String start, String end, int number) throws Exception{
|
||||
createTransactionDaoConnection();
|
||||
QueryBuilder<Transaction, String> queryBuilder = transactionDao.queryBuilder();
|
||||
queryBuilder.where().eq("transaction_from",wallet_hash)
|
||||
.or().eq("transaction_to",wallet_hash)
|
||||
.and().between("transaction_date", new BigInteger(start), new BigInteger(end));
|
||||
|
||||
if(number!=0){
|
||||
queryBuilder.limit(new Long(number));
|
||||
}
|
||||
|
||||
queryBuilder.orderBy("transaction_date",false);
|
||||
PreparedQuery<Transaction> preparedQuery = queryBuilder.prepare();
|
||||
List<Transaction> t = transactionDao.query(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return t;
|
||||
}
|
||||
|
||||
public List<Transaction> getSentTransactionBetweenDate(String wallet_hash, String start, String end, int number) throws Exception{
|
||||
createTransactionDaoConnection();
|
||||
QueryBuilder<Transaction, String> queryBuilder = transactionDao.queryBuilder();
|
||||
queryBuilder.where().eq("transaction_from",wallet_hash).and().between("transaction_date", new BigInteger(start), new BigInteger(end));
|
||||
|
||||
if(number!=0){
|
||||
queryBuilder.limit(new Long(number));
|
||||
}
|
||||
|
||||
queryBuilder.orderBy("transaction_date",false);
|
||||
PreparedQuery<Transaction> preparedQuery = queryBuilder.prepare();
|
||||
List<Transaction> t = transactionDao.query(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return t;
|
||||
}
|
||||
|
||||
public List<Transaction> getReceivedTransactionBetweenDate(String wallet_hash, String start, String end, int number) throws Exception{
|
||||
createTransactionDaoConnection();
|
||||
QueryBuilder<Transaction, String> queryBuilder = transactionDao.queryBuilder();
|
||||
queryBuilder.where().eq("transaction_to",wallet_hash).and().between("transaction_date", new BigInteger(start), new BigInteger(end));
|
||||
|
||||
if(number!=0){
|
||||
queryBuilder.limit(new Long(number));
|
||||
}
|
||||
|
||||
queryBuilder.orderBy("transaction_date",false);
|
||||
PreparedQuery<Transaction> preparedQuery = queryBuilder.prepare();
|
||||
List<Transaction> t = transactionDao.query(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
}
|
179
src/main/java/database/user/User.java
Normal file
179
src/main/java/database/user/User.java
Normal file
|
@ -0,0 +1,179 @@
|
|||
package database.user;
|
||||
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
//Class User which represent an User in the postgresDB
|
||||
@DatabaseTable(tableName = "T_USER")
|
||||
public class User {
|
||||
@DatabaseField(generatedId = true)
|
||||
private int user_id;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String name;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String firstname;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String email;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String password;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private long creation_date;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private long modification_date;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String phone;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String association;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private boolean verified;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private boolean approved;
|
||||
@DatabaseField(canBeNull = false)
|
||||
private String user_hash;
|
||||
|
||||
//Constructors
|
||||
//Default constructor for ORMLite
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(String email, String user_hash){
|
||||
this.email = email;
|
||||
this.user_hash = user_hash;
|
||||
}
|
||||
|
||||
public User(String name, String firstname, String email, String password, String association) {
|
||||
this.name = name;
|
||||
this.firstname = firstname;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.association = association;
|
||||
}
|
||||
|
||||
public User(String name, String firstname, String email, String password, String phone, String association){
|
||||
this.name = name;
|
||||
this.firstname = firstname;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.phone = phone;
|
||||
this.association = association;
|
||||
}
|
||||
|
||||
|
||||
public User(String name, String firstname,String user_hash, String email, String password, long creation_date, long modification_date, boolean verified, boolean approved) {
|
||||
this.name = name;
|
||||
this.firstname = firstname;
|
||||
this.user_hash = user_hash;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.creation_date = creation_date;
|
||||
this.modification_date = modification_date;
|
||||
this.verified = verified;
|
||||
this.approved = approved;
|
||||
}
|
||||
|
||||
public User(String name, String firstname,String user_hash, String email, String password, long creation_date, long modification_date, String phone, String association, boolean verified, boolean approved) {
|
||||
this.name = name;
|
||||
this.firstname = firstname;
|
||||
this.user_hash = user_hash;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.creation_date = creation_date;
|
||||
this.modification_date = modification_date;
|
||||
this.phone = phone;
|
||||
this.association = association;
|
||||
this.verified = verified;
|
||||
this.approved = approved;
|
||||
}
|
||||
|
||||
|
||||
//Getters and Setters
|
||||
public int getUserId() {
|
||||
return user_id;
|
||||
}
|
||||
public void setUserId(int userId) {this.user_id = userId;}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUser_hash(){return user_hash;}
|
||||
public void setUser_hash(String user_hash){this.user_hash = user_hash;}
|
||||
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public long getCreation_date() {
|
||||
return creation_date;
|
||||
}
|
||||
public void setCreation_date(long creation_date) {
|
||||
this.creation_date = creation_date;
|
||||
}
|
||||
|
||||
public long getModification_date() {
|
||||
return modification_date;
|
||||
}
|
||||
public void setModification_date(long modification_date) {
|
||||
this.modification_date = modification_date;
|
||||
}
|
||||
|
||||
public String getPhone(){return phone;}
|
||||
public void setPhone(String phone){this.phone=phone;}
|
||||
|
||||
public String getAssociation(){return association;}
|
||||
public void setAssociation(){this.association=association;}
|
||||
|
||||
public boolean isVerified() {
|
||||
return verified;
|
||||
}
|
||||
public void setVerified(boolean verified) {
|
||||
this.verified = verified;
|
||||
}
|
||||
|
||||
public boolean isApproved() {
|
||||
return approved;
|
||||
}
|
||||
public void setApproved(boolean approved) {
|
||||
this.approved = approved;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"userId=" + user_id +
|
||||
", name='" + name + '\'' +
|
||||
", firstname='" + firstname + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
", creation_date=" + creation_date +
|
||||
", modification_date=" + modification_date +
|
||||
", phone= "+phone+
|
||||
", association= "+association+
|
||||
", verified=" + verified +
|
||||
", approved=" + approved +
|
||||
", user_hash='" + user_hash + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
165
src/main/java/database/user/UserDao.java
Normal file
165
src/main/java/database/user/UserDao.java
Normal file
|
@ -0,0 +1,165 @@
|
|||
package database.user;
|
||||
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
import com.j256.ormlite.dao.DaoManager;
|
||||
import com.j256.ormlite.stmt.DeleteBuilder;
|
||||
import com.j256.ormlite.stmt.PreparedQuery;
|
||||
import com.j256.ormlite.stmt.QueryBuilder;
|
||||
import com.j256.ormlite.stmt.UpdateBuilder;
|
||||
import database.DatabaseHelper;
|
||||
import java.time.Instant;
|
||||
|
||||
//Class to communicate with database with ORMLite
|
||||
public class UserDao {
|
||||
private DatabaseHelper dbh = new DatabaseHelper();
|
||||
private boolean sessionOpen = false;
|
||||
private Dao<User, String> userDao;
|
||||
private void createUserDaoConnection(){
|
||||
try {
|
||||
if(!sessionOpen){
|
||||
userDao = DaoManager.createDao(dbh.setupDatabaseConnection(),User.class);
|
||||
sessionOpen = true;
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addUser(User user)throws Exception {
|
||||
createUserDaoConnection();
|
||||
userDao.create(user);
|
||||
DatabaseHelper.closeConnection();
|
||||
}
|
||||
|
||||
public boolean checkApprovedUser(String email) throws Exception {
|
||||
return getUserWithEmail(email).isApproved();
|
||||
}
|
||||
|
||||
public boolean checkVerifiedUser(String email) throws Exception {
|
||||
return getUserWithEmail(email).isVerified();
|
||||
}
|
||||
|
||||
public boolean updateUserPassword(String email, String password) throws Exception {
|
||||
createUserDaoConnection();
|
||||
UpdateBuilder<User, String> updateBuilder = userDao.updateBuilder();
|
||||
updateBuilder.updateColumnValue("password",password);
|
||||
long now = Instant.now().toEpochMilli();
|
||||
updateBuilder.updateColumnValue("modification_date",now);
|
||||
updateBuilder.where().eq("email",email);
|
||||
updateBuilder.update();
|
||||
if(checkUserPassword(email, password)){
|
||||
DatabaseHelper.closeConnection();
|
||||
return true;
|
||||
}else{
|
||||
DatabaseHelper.closeConnection();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteUser(String email) throws Exception {
|
||||
createUserDaoConnection();
|
||||
DeleteBuilder<User, String> deleteBuilder = userDao.deleteBuilder();
|
||||
deleteBuilder.where().eq("email",email);
|
||||
deleteBuilder.delete();
|
||||
DatabaseHelper.closeConnection();
|
||||
}
|
||||
|
||||
public boolean verifyUserExist(String email) throws Exception {
|
||||
createUserDaoConnection();
|
||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("email",email);
|
||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
||||
User user = userDao.queryForFirst(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
if(user==null){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkUserPassword(String email, String password) throws Exception {
|
||||
User user = getUserWithEmail(email);
|
||||
if(password.equals(user.getPassword())){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public User getUserWithEmail(String email) throws Exception {
|
||||
createUserDaoConnection();
|
||||
if(!verifyUserExist(email)){
|
||||
return null;
|
||||
}else{
|
||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("email",email);
|
||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
||||
User u = userDao.queryForFirst(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return u;
|
||||
}
|
||||
}
|
||||
|
||||
public User getUserWithPhone(String phone) throws Exception {
|
||||
createUserDaoConnection();
|
||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("phone",phone);
|
||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
||||
User u = userDao.queryForFirst(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return u;
|
||||
}
|
||||
|
||||
public User getUserWithMailAndPhone(String email, String phone) throws Exception {
|
||||
createUserDaoConnection();
|
||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("email",email).and().eq("phone",phone);
|
||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
||||
User u = userDao.queryForFirst(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return u;
|
||||
}
|
||||
|
||||
public User getUserWithHash(String userHash) throws Exception {
|
||||
createUserDaoConnection();
|
||||
QueryBuilder<User,String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("user_hash",userHash);
|
||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
||||
User u = userDao.queryForFirst(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return u;
|
||||
}
|
||||
|
||||
public int getUserIdWithHashAndEmail(String userHash, String userEmail) throws Exception {
|
||||
createUserDaoConnection();
|
||||
QueryBuilder<User,String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("user_hash",userHash).and().eq("email",userEmail);
|
||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
||||
User userResponse = userDao.queryForFirst(preparedQuery);
|
||||
DatabaseHelper.closeConnection();
|
||||
return userResponse.getUserId();
|
||||
}
|
||||
|
||||
public void approveUser (String email) throws Exception {
|
||||
createUserDaoConnection();
|
||||
UpdateBuilder<User, String> updateBuilder = userDao.updateBuilder();
|
||||
updateBuilder.updateColumnValue("approved",true);
|
||||
long now = Instant.now().toEpochMilli();
|
||||
updateBuilder.updateColumnValue("modification_date",now);
|
||||
updateBuilder.where().eq("email",email);
|
||||
updateBuilder.update();
|
||||
DatabaseHelper.closeConnection();
|
||||
}
|
||||
|
||||
public void verifyUser (String email) throws Exception{
|
||||
createUserDaoConnection();
|
||||
UpdateBuilder<User, String> updateBuilder = userDao.updateBuilder();
|
||||
updateBuilder.updateColumnValue("verified",true);
|
||||
long now = Instant.now().toEpochMilli();
|
||||
updateBuilder.updateColumnValue("modification_date",now);
|
||||
updateBuilder.where().eq("email",email);
|
||||
updateBuilder.update();
|
||||
DatabaseHelper.closeConnection();
|
||||
}
|
||||
}
|
89
src/main/java/encryption/DataEncryption.java
Normal file
89
src/main/java/encryption/DataEncryption.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package encryption;
|
||||
|
||||
import com.sun.mail.util.BASE64DecoderStream;
|
||||
import com.sun.mail.util.BASE64EncoderStream;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Key;
|
||||
import static org.apache.commons.codec.binary.Hex.decodeHex;
|
||||
import static org.apache.commons.codec.binary.Hex.encodeHex;
|
||||
import static org.apache.commons.io.FileUtils.readFileToByteArray;
|
||||
import static org.apache.commons.io.FileUtils.writeStringToFile;
|
||||
|
||||
public class DataEncryption {
|
||||
private Cipher cipher;
|
||||
private SecretKey key;
|
||||
|
||||
private void generateKey(){
|
||||
try{
|
||||
File f = new File("msp/key");
|
||||
if(f.exists() && !f.isDirectory()) {
|
||||
readKey(f);
|
||||
} else {
|
||||
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
|
||||
keyGen.init(256);
|
||||
key = keyGen.generateKey();
|
||||
writeKey(key);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void readKey(File file){
|
||||
try {
|
||||
String d = new String(readFileToByteArray(file));
|
||||
char[] hex = d.toCharArray();
|
||||
byte[] encoded = decodeHex(hex);
|
||||
key = new SecretKeySpec(encoded,"AES");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeKey(Key key){
|
||||
try {
|
||||
File f = new File("msp/key");
|
||||
byte[] encoded = key.getEncoded();
|
||||
char[] hex = encodeHex(encoded);
|
||||
String d = String.valueOf(hex);
|
||||
writeStringToFile(f,d,"UTF-8");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String encryptData(String data){
|
||||
try{
|
||||
cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
generateKey();
|
||||
cipher.init(Cipher.ENCRYPT_MODE,key,new IvParameterSpec(new byte[16]));
|
||||
byte[] utf8 = data.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] enc = cipher.doFinal(utf8);
|
||||
enc = BASE64EncoderStream.encode(enc);
|
||||
return new String(enc);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String decryptData(String data){
|
||||
try{
|
||||
cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
generateKey();
|
||||
cipher.init(Cipher.DECRYPT_MODE,key,new IvParameterSpec(new byte[16]));
|
||||
byte[] dec = BASE64DecoderStream.decode(data.getBytes());
|
||||
byte[] utf8 = cipher.doFinal(dec);
|
||||
return new String(utf8, StandardCharsets.UTF_8);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
27
src/main/java/restImplementation/SessionImplementation.java
Normal file
27
src/main/java/restImplementation/SessionImplementation.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package restImplementation;
|
||||
|
||||
import database.session.Session;
|
||||
import database.session.SessionDao;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class SessionImplementation {
|
||||
|
||||
public int startSession(String user_hash, String user_email) throws Exception {
|
||||
SessionDao sessionDao = new SessionDao();
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
int userId = userImplementation.getUserId(user_hash,user_email);
|
||||
|
||||
Session session = new Session();
|
||||
session.setUser_id(userId);
|
||||
long now = Instant.now().toEpochMilli();
|
||||
session.setStart_session(now);
|
||||
|
||||
return sessionDao.setStartSession(session);
|
||||
}
|
||||
|
||||
public void endSession(int session_id) throws Exception {
|
||||
SessionDao sessionDao = new SessionDao();
|
||||
sessionDao.setEndSession(session_id);
|
||||
}
|
||||
}
|
181
src/main/java/restImplementation/TransactionImplementation.java
Normal file
181
src/main/java/restImplementation/TransactionImplementation.java
Normal file
|
@ -0,0 +1,181 @@
|
|||
package restImplementation;
|
||||
|
||||
import blockchain.query.QueryWrapper;
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import database.transaction.Transaction;
|
||||
import database.transaction.TransactionDao;
|
||||
import database.user.User;
|
||||
import database.user.UserDao;
|
||||
import org.hyperledger.fabric.sdk.BlockEvent;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonReader;
|
||||
import java.io.StringReader;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
public class TransactionImplementation {
|
||||
public HashMap sendTransaction(String sourceUserHash, String sourceUserPwd, String sourceWalletHash, String destinationWalletHash, double amount, String transactionUnit) throws Exception {
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
HashMap returnResponse = new HashMap();
|
||||
UserDao userDao = new UserDao();
|
||||
User user = userDao.getUserWithHash(sourceUserHash);
|
||||
|
||||
if(user != null){
|
||||
if(BCrypt.checkpw(sourceUserPwd, user.getPassword())){
|
||||
String response = queryWrapper.sendQuery("readWallet", new String[]{sourceWalletHash});
|
||||
|
||||
if (response != null){
|
||||
JsonReader reader = Json.createReader(new StringReader(response));
|
||||
JsonObject walletInfo = reader.readObject();
|
||||
double balance = walletInfo.getJsonNumber("balance").doubleValue();
|
||||
|
||||
if(balance-amount<0){ //CHECK WALLET BALANCE
|
||||
returnResponse.put("success",false);
|
||||
returnResponse.put("message","Not enough money");
|
||||
} else {
|
||||
//CHECK DEST WALLET
|
||||
String responseDestWallet = queryWrapper.sendQuery("readWallet", new String[]{destinationWalletHash});
|
||||
if(responseDestWallet!=null){
|
||||
BlockEvent.TransactionEvent eventResponse = transactionWrapper.sendTransaction("transaction",new String[]{sourceWalletHash,destinationWalletHash,String.valueOf(amount)});
|
||||
String txID = eventResponse.getTransactionID();
|
||||
|
||||
Transaction transaction = new Transaction();
|
||||
long now = Instant.now().toEpochMilli();
|
||||
transaction.setTransaction_date(now);
|
||||
transaction.setTransaction_from(sourceWalletHash);
|
||||
transaction.setTransaction_to(destinationWalletHash);
|
||||
transaction.setTransaction_amount(amount);
|
||||
transaction.setTransaction_hash(txID);
|
||||
transaction.setTransaction_unit(transactionUnit);
|
||||
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
transactionDao.addTransaction(transaction);
|
||||
|
||||
returnResponse.put("success",true);
|
||||
returnResponse.put("message",txID);
|
||||
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
walletImplementation.updateWalletBalance(sourceWalletHash,destinationWalletHash,amount);
|
||||
} else {
|
||||
returnResponse.put("success",false);
|
||||
returnResponse.put("message","Destination wallet doesn't exist");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
returnResponse.put("success",false);
|
||||
returnResponse.put("message","Error in user wallet");
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Exception("NOT ALLOWED");
|
||||
}
|
||||
} else {
|
||||
throw new Exception("NOT ALLOWED");
|
||||
}
|
||||
return returnResponse;
|
||||
}
|
||||
|
||||
|
||||
//GET A TRANSACTION
|
||||
public Transaction getTransaction(String wallet_hash, String transaction_hash) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getTransaction(wallet_hash,transaction_hash);
|
||||
}
|
||||
|
||||
|
||||
//GET LATEST
|
||||
public List<Transaction> getLatestTransactions(String wallet_hash) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getWalletTransactions(wallet_hash,10);
|
||||
}
|
||||
|
||||
//GET ALL
|
||||
public List<Transaction> getWalletTransactions(String wallet_hash, String size) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getWalletTransactions(wallet_hash,Integer.parseInt(size));
|
||||
}
|
||||
|
||||
|
||||
//GET ALL BETWEEN DATE
|
||||
public List<Transaction> getAllBetweenDate(String wallet_hash, String start, String end, String size) throws Exception{
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getAllTransactionBetweenDate(wallet_hash,start,end,Integer.parseInt(size));
|
||||
}
|
||||
|
||||
|
||||
//SENT
|
||||
public List<Transaction> getSentTransaction(String wallet_hash, String size) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getSentTransactions(wallet_hash, Integer.parseInt(size));
|
||||
}
|
||||
|
||||
|
||||
public List<Transaction> getSentBetweenDate(String wallet_hash, String start, String end, String size) throws Exception{
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getSentTransactionBetweenDate(wallet_hash,start,end,Integer.parseInt(size));
|
||||
}
|
||||
|
||||
|
||||
//RECEIVED
|
||||
public List<Transaction> getReceivedTransaction(String wallet_hash, String size) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getReceivedTransactions(wallet_hash, Integer.parseInt(size));
|
||||
}
|
||||
|
||||
|
||||
public List<Transaction> getReceivedBetweenDate(String wallet_hash, String start, String end, String size) throws Exception{
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
return transactionDao.getReceivedTransactionBetweenDate(wallet_hash,start,end,Integer.parseInt(size));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public List<List<Transaction>> getAllSentTransaction(String user_hash, String number) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
WalletDao walletDao = new WalletDao();
|
||||
List<List<Transaction>> transactionList = new ArrayList<>();
|
||||
List<Wallet> userWallets = walletDao.getUserWallet(user_hash);
|
||||
|
||||
for(Wallet w : userWallets){
|
||||
transactionList.add(transactionDao.getUserSentTransaction(w.getWallet_hash(),Integer.parseInt(number)));
|
||||
}
|
||||
return transactionList;
|
||||
}
|
||||
|
||||
public List<List<Transaction>> getAllReceivedTransaction(String user_hash, String number) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
WalletDao walletDao = new WalletDao();
|
||||
List<List<Transaction>> transactionList = new ArrayList<>();
|
||||
List<Wallet> userWallets = walletDao.getUserWallet(user_hash);
|
||||
|
||||
for(Wallet w : userWallets){
|
||||
transactionList.add(transactionDao.getUserReceivedTransaction(w.getWallet_hash(), Integer.parseInt(number)));
|
||||
}
|
||||
return transactionList;
|
||||
}
|
||||
|
||||
public List<Transaction> getAllTransactions(String user_hash, String number) throws Exception {
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
WalletDao walletDao = new WalletDao();
|
||||
List<Wallet> userWallets = walletDao.getUserWallet(user_hash);
|
||||
List<Transaction> allTransactions = new ArrayList<>();
|
||||
List<Transaction> returnList = new ArrayList<>();
|
||||
|
||||
for(Wallet w : userWallets){
|
||||
List<Transaction> list = transactionDao.getWalletTransactions(w.getWallet_hash(),Integer.parseInt(number));
|
||||
for(Transaction t : list){
|
||||
allTransactions.add(t);
|
||||
}
|
||||
}
|
||||
Collections.sort(allTransactions);
|
||||
for(int i=allTransactions.size()-1;i>0;i--){
|
||||
returnList.add(allTransactions.get(i));
|
||||
}
|
||||
|
||||
return returnList;
|
||||
}
|
||||
*/
|
||||
}
|
162
src/main/java/restImplementation/UserImplementation.java
Normal file
162
src/main/java/restImplementation/UserImplementation.java
Normal file
|
@ -0,0 +1,162 @@
|
|||
package restImplementation;
|
||||
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import database.user.User;
|
||||
import database.user.UserDao;
|
||||
import encryption.DataEncryption;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class UserImplementation {
|
||||
private DataEncryption dataEncryption = new DataEncryption();
|
||||
|
||||
public Map<String,String> registerUser(User user) throws Exception {
|
||||
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
UserDao userDao = new UserDao();
|
||||
|
||||
//CREATE USER HASH. TEMPORARY USER HASH IS : name+email+firstname+association
|
||||
user.setUser_hash(hashPassword(user.getName()+user.getEmail()+user.getFirstname()+user.getAssociation()));
|
||||
|
||||
//REGISTER IN BLOCKCHAIN
|
||||
if(user.getPhone()==null){
|
||||
user.setPhone("0000000000");
|
||||
}
|
||||
|
||||
String[] userInfos = new String[]{user.getUser_hash(),dataEncryption.encryptData(user.getName()),dataEncryption.encryptData(user.getFirstname()),dataEncryption.encryptData(""+user.getPhone()),user.getAssociation()};
|
||||
transactionWrapper.sendTransaction("registerUser",userInfos);
|
||||
|
||||
//REGISTER IN REPLICA DB FOR BI
|
||||
Map<String,String> response = new HashMap<>();
|
||||
User dbUser = userDao.getUserWithEmail(dataEncryption.encryptData(user.getEmail())); // check if user exist
|
||||
|
||||
if(dbUser != null){
|
||||
System.out.println("dbUser exist: "+dbUser.getUser_hash());
|
||||
response.put("response","false");
|
||||
return response;
|
||||
}else {
|
||||
user.setPassword(hashPassword(user.getPassword()));
|
||||
long now = Instant.now().toEpochMilli();
|
||||
user.setCreation_date(now);
|
||||
user.setModification_date(now);
|
||||
user.setVerified(true);
|
||||
user.setApproved(false);
|
||||
|
||||
String userName = user.getName();
|
||||
user.setName(dataEncryption.encryptData(userName));
|
||||
|
||||
String userFirstName = user.getFirstname();
|
||||
user.setFirstname(dataEncryption.encryptData(userFirstName));
|
||||
|
||||
String userPhone = user.getPhone();
|
||||
user.setPhone(dataEncryption.encryptData(userPhone));
|
||||
|
||||
String userEmail = user.getEmail();
|
||||
user.setEmail(dataEncryption.encryptData(userEmail));
|
||||
|
||||
System.out.println("addUser: "+user.getUser_hash());
|
||||
userDao.addUser(user);
|
||||
response.put("user_hash",user.getUser_hash());
|
||||
response.put("response","true");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
public void approveUser(User user) throws Exception{
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
UserDao userDao = new UserDao();
|
||||
transactionWrapper.sendTransaction("setUserPermission",new String[]{user.getUser_hash()});
|
||||
userDao.approveUser(dataEncryption.encryptData(user.getEmail()));
|
||||
}
|
||||
|
||||
public Boolean getUserApproval(String user_email) throws Exception {
|
||||
UserDao userDao = new UserDao();
|
||||
User u = userDao.getUserWithEmail(dataEncryption.encryptData(user_email));
|
||||
return u.isApproved();
|
||||
}
|
||||
|
||||
public void deleteUser(User user) throws Exception {
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
transactionWrapper.sendTransaction("deleteUser",new String[]{user.getUser_hash()});
|
||||
UserDao userDao = new UserDao();
|
||||
userDao.deleteUser(dataEncryption.encryptData(user.getEmail()));
|
||||
}
|
||||
|
||||
public Boolean getUser(String email) throws Exception{
|
||||
UserDao userDao = new UserDao();
|
||||
return userDao.verifyUserExist(dataEncryption.encryptData(email));
|
||||
}
|
||||
|
||||
public User getUserWithEmail(String email) throws Exception{
|
||||
UserDao userDao = new UserDao();
|
||||
return userDao.getUserWithEmail(dataEncryption.encryptData(email));
|
||||
}
|
||||
|
||||
public User getUserWithPhone(String phone) throws Exception{
|
||||
UserDao userDao = new UserDao();
|
||||
return userDao.getUserWithPhone(dataEncryption.encryptData(phone));
|
||||
}
|
||||
public User getUserWithMailAndPhone(String email, String phone) throws Exception{
|
||||
UserDao userDao = new UserDao();
|
||||
return userDao.getUserWithMailAndPhone(dataEncryption.encryptData(email),dataEncryption.encryptData(phone));
|
||||
}
|
||||
|
||||
public int getUserId(String user_hash, String user_email) throws Exception{
|
||||
UserDao userDao = new UserDao();
|
||||
return userDao.getUserIdWithHashAndEmail(user_hash,dataEncryption.encryptData(user_email));
|
||||
}
|
||||
|
||||
public Map<String,String> userLogger(User user) throws Exception {
|
||||
UserDao userDao = new UserDao();
|
||||
Map<String,String> response = new HashMap<>();
|
||||
|
||||
User userResponse = userDao.getUserWithEmail(dataEncryption.encryptData(user.getEmail()));
|
||||
|
||||
if(userResponse != null){
|
||||
String hash = userResponse.getPassword();
|
||||
|
||||
if(!BCrypt.checkpw(user.getPassword(), hash)){
|
||||
response.put("response","Not Allowed");
|
||||
}else{
|
||||
response.put("response","true");
|
||||
response.put("user_hash",userResponse.getUser_hash());
|
||||
}
|
||||
} else {
|
||||
response.put("response","Not Exist");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public Boolean updatePassword(String user_email, String current_password,String new_password){
|
||||
try{
|
||||
UserDao userDao = new UserDao();
|
||||
System.out.println("Get User :");
|
||||
User u = userDao.getUserWithEmail(dataEncryption.encryptData(user_email));
|
||||
System.out.println(u);
|
||||
if(u != null){
|
||||
String hash = u.getPassword();
|
||||
if(!BCrypt.checkpw(current_password, hash)){
|
||||
System.out.println("Password don't match");
|
||||
return false;
|
||||
}else{
|
||||
System.out.println("Update Password");
|
||||
userDao.updateUserPassword(dataEncryption.encryptData(user_email),hashPassword(new_password));
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private String hashPassword(String plainTextPassword){
|
||||
return BCrypt.hashpw(plainTextPassword,BCrypt.gensalt());
|
||||
}
|
||||
|
||||
|
||||
}
|
168
src/main/java/restImplementation/WalletImplementation.java
Normal file
168
src/main/java/restImplementation/WalletImplementation.java
Normal file
|
@ -0,0 +1,168 @@
|
|||
package restImplementation;
|
||||
|
||||
import blockchain.query.QueryWrapper;
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import database.Wallet.Wallet;
|
||||
import database.Wallet.WalletDao;
|
||||
import database.user.User;
|
||||
import database.user.UserDao;
|
||||
import encryption.DataEncryption;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonReader;
|
||||
import java.io.StringReader;
|
||||
import java.time.Instant;
|
||||
|
||||
public class WalletImplementation {
|
||||
private DataEncryption dataEncryption = new DataEncryption();
|
||||
|
||||
public Wallet createWallet(Wallet wallet) throws Exception {
|
||||
//Map<String,String> response = new HashMap<>();
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
WalletDao walletDao = new WalletDao();
|
||||
UserDao userDao = new UserDao();
|
||||
|
||||
User user = userDao.getUserWithHash(wallet.getUser_hash());
|
||||
wallet.setWallet_hash(generateWalletHash(user.getName()+wallet.getType()+user.getFirstname()+ RandomStringUtils.randomAlphabetic(10)));
|
||||
transactionWrapper.sendTransaction("initWallet",new String[]{wallet.getWallet_hash(),wallet.getType(),wallet.getUser_hash()}); //Create Wallet in Blockchain
|
||||
|
||||
wallet.setBalance(0.0);
|
||||
wallet.setIs_active(true);
|
||||
long now = Instant.now().toEpochMilli();
|
||||
wallet.setCreation_date(now);
|
||||
wallet.setModification_date(now);
|
||||
walletDao.addWallet(wallet); // add wallet to replica DB
|
||||
|
||||
return wallet;
|
||||
}
|
||||
|
||||
//getAllUserWallets
|
||||
public JsonArray getAllUserWallets(String userHash) throws Exception {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
JsonArray walletList = null;
|
||||
String response = queryWrapper.sendQuery("queryWalletsByOwner",new String[]{userHash});
|
||||
|
||||
if(response != null) {
|
||||
JsonReader reader = Json.createReader(new StringReader(response));
|
||||
walletList = reader.readArray();
|
||||
}
|
||||
return walletList;
|
||||
}
|
||||
|
||||
//getWallet
|
||||
public Wallet getWallet(String walletHash) throws Exception {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
String response = queryWrapper.sendQuery("readWallet",new String[]{walletHash});
|
||||
Wallet wallet = new Wallet();
|
||||
|
||||
if(response != null) {
|
||||
JsonReader reader = Json.createReader(new StringReader(response));
|
||||
JsonObject walletJson = reader.readObject();
|
||||
wallet.setWallet_hash(walletJson.getString("id"));
|
||||
wallet.setUser_hash(walletJson.getString("owner"));
|
||||
wallet.setType(walletJson.getString("walletType"));
|
||||
wallet.setBalance(walletJson.getJsonNumber("balance").doubleValue());
|
||||
}
|
||||
return wallet;
|
||||
}
|
||||
|
||||
//setBalance
|
||||
public void setBalanceToWallet(String associationHash, String associationPwd, String walletHash, double amount) throws Exception {
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
UserDao userDao = new UserDao();
|
||||
User association = userDao.getUserWithHash(associationHash);
|
||||
if(association != null){
|
||||
System.out.println("CHECK PWD");
|
||||
|
||||
if(BCrypt.checkpw(associationPwd, association.getPassword())){
|
||||
System.out.println("OK");
|
||||
double newBalance = 0.0;
|
||||
System.out.println("walletHash : "+walletHash);
|
||||
System.out.println("amount : "+amount);
|
||||
transactionWrapper.sendTransaction("setBalanceOnWallet",new String[]{walletHash,String.valueOf(amount)});
|
||||
Wallet wallet = getWallet(walletHash);
|
||||
if(wallet!=null){
|
||||
newBalance=wallet.getBalance();
|
||||
WalletDao walletDao = new WalletDao();
|
||||
walletDao.updateWalletBalance(walletHash,newBalance);
|
||||
} else {
|
||||
throw new Exception("ERROR QUERY WALLET");
|
||||
}
|
||||
}else {
|
||||
System.out.println("WRONG PDW");
|
||||
throw new Exception("NOT ALLOWED");
|
||||
}
|
||||
}else {
|
||||
throw new Exception("NOT ALLOWED");
|
||||
}
|
||||
}
|
||||
|
||||
//update DB balance after transaction
|
||||
public void updateWalletBalance(String sourceWalletHash, String destinationWalletHash, double amount) throws Exception {
|
||||
WalletDao walletDao = new WalletDao();
|
||||
double balanceWalletSource = walletDao.getWallet(sourceWalletHash).getBalance();
|
||||
double balanceWalletDestination = walletDao.getWallet(destinationWalletHash).getBalance();
|
||||
|
||||
double newBalanceWalletSource = balanceWalletSource-amount;
|
||||
double newBalanceWalletDestination = balanceWalletDestination+amount;
|
||||
|
||||
walletDao.updateWalletBalance(sourceWalletHash,newBalanceWalletSource);
|
||||
walletDao.updateWalletBalance(destinationWalletHash,newBalanceWalletDestination);
|
||||
}
|
||||
|
||||
//transfer
|
||||
public void transferWallet(String walletHash, String newUserHash) throws Exception {
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
transactionWrapper.sendTransaction("transferWallet",new String[]{walletHash,newUserHash});
|
||||
|
||||
WalletDao walletDao = new WalletDao();
|
||||
walletDao.transferWallet(walletHash,newUserHash);
|
||||
}
|
||||
|
||||
//delete
|
||||
public void deleteWallet(String user_email, String user_hash, String user_password, String wallet_hash_source, String wallet_hash_dest) throws Exception {
|
||||
UserDao userDao = new UserDao();
|
||||
User userResponse = userDao.getUserWithEmail(dataEncryption.encryptData(user_email));
|
||||
|
||||
if(userResponse != null){
|
||||
String hash = userResponse.getPassword();
|
||||
//CHECK USER PASSWORD
|
||||
if(BCrypt.checkpw(user_password, hash)){
|
||||
//GET FUND OF WALLET_HASH_SOURCE
|
||||
Double w_source_balance = getWallet(wallet_hash_source).getBalance();
|
||||
|
||||
// MOVE FUND FROM WALLET SOURCE TO WALLET DEST
|
||||
if(w_source_balance!=0){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
transactionImplementation.sendTransaction(user_hash,user_password,wallet_hash_source,wallet_hash_dest,w_source_balance,"gonette");
|
||||
}
|
||||
|
||||
// DELETE WALLET SOURCE
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
transactionWrapper.sendTransaction("deleteWallet",new String[]{wallet_hash_source});
|
||||
WalletDao walletDao = new WalletDao();
|
||||
walletDao.deleteWallet(wallet_hash_source,user_hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//getAll
|
||||
public JsonArray getAllWallets() throws Exception {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
JsonArray walletList = null;
|
||||
String response = queryWrapper.sendQuery("query_all_wallets",new String[]{});
|
||||
|
||||
if(response != null) {
|
||||
JsonReader reader = Json.createReader(new StringReader(response));
|
||||
walletList = reader.readArray();
|
||||
}
|
||||
return walletList;
|
||||
}
|
||||
|
||||
private String generateWalletHash(String walletBuilderString){
|
||||
return BCrypt.hashpw(walletBuilderString,BCrypt.gensalt());
|
||||
}
|
||||
}
|
76
src/main/java/restService/ConfigResource.java
Normal file
76
src/main/java/restService/ConfigResource.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
package restService;
|
||||
|
||||
import blockchain.configuration.AppConfig;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/rest/demo/conf")
|
||||
public class ConfigResource {
|
||||
// ENVIRONMENT
|
||||
@RequestMapping(value = "/env", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity setEnvironment(@RequestBody Map<String,String> requestParam){
|
||||
try{
|
||||
int newEnv = Integer.parseInt(requestParam.get("env"));
|
||||
AppConfig.setENV(newEnv);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("");
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/env", method = RequestMethod.GET, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getEnvironment(){
|
||||
try{
|
||||
return ResponseEntity.status(HttpStatus.OK).body("{\"env\":"+AppConfig.getENV()+"}");
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CHAINCODE
|
||||
@RequestMapping(value = "/chaincode", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity setChaincode(@RequestBody Map<String,String> requestParam){
|
||||
try{
|
||||
int newChaincode= Integer.parseInt(requestParam.get("chaincode"));
|
||||
AppConfig.setCHAINCODE_IDX(newChaincode);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("");
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/chaincode", method = RequestMethod.GET, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getChaincode(){
|
||||
try{
|
||||
return ResponseEntity.status(HttpStatus.OK).body("{\"chaincode\":\""+AppConfig.getCHAINCODE()+"\"}");
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// DATABASE
|
||||
@RequestMapping(value = "/db", method = RequestMethod.GET, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getDb(){
|
||||
try{
|
||||
return ResponseEntity.status(HttpStatus.OK).body("{\"db\":\""+AppConfig.getDATABASE()+"\"}");
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
}
|
42
src/main/java/restService/SessionResource.java
Normal file
42
src/main/java/restService/SessionResource.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package restService;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import restImplementation.SessionImplementation;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/rest/session")
|
||||
public class SessionResource {
|
||||
@RequestMapping(value = "/start", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseEntity startSession(@RequestBody Map<String,String> requestParam){
|
||||
SessionImplementation sessionImplementation = new SessionImplementation();
|
||||
try {
|
||||
String user_hash = requestParam.get("user_hash");
|
||||
String user_email = requestParam.get("user_email");
|
||||
int session_id = sessionImplementation.startSession(user_hash,user_email);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("{\"session_id\":"+session_id+"}");
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/end", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity endSession(@RequestBody Map<String,Integer> requestParam){
|
||||
SessionImplementation sessionImplementation = new SessionImplementation();
|
||||
try {
|
||||
int session_id = requestParam.get("session_id");
|
||||
sessionImplementation.endSession(session_id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("");
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
205
src/main/java/restService/TransactionResource.java
Normal file
205
src/main/java/restService/TransactionResource.java
Normal file
|
@ -0,0 +1,205 @@
|
|||
package restService;
|
||||
|
||||
import database.transaction.SendingTransaction;
|
||||
import database.transaction.Transaction;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import restImplementation.TransactionImplementation;
|
||||
import javax.validation.Valid;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/rest/transaction")
|
||||
public class TransactionResource {
|
||||
//DO TRANSACTION
|
||||
@RequestMapping(value = "/send", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseEntity doTransaction(@Valid @RequestBody SendingTransaction SendingTransaction){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try{
|
||||
HashMap mapResponse = transactionImplementation.sendTransaction(SendingTransaction.getSource_user_hash(), SendingTransaction.getSource_user_pwd(),
|
||||
SendingTransaction.getTransaction_from(),SendingTransaction.getTransaction_to(),
|
||||
Double.parseDouble(SendingTransaction.getTransaction_amount()),SendingTransaction.getTransaction_unit());
|
||||
|
||||
if(Boolean.parseBoolean(mapResponse.get("success").toString())){
|
||||
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\""+mapResponse.get("message")+"\"}");
|
||||
}else {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"response\":\""+mapResponse.get("message")+"\"}");
|
||||
}
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//GET A TRANSACTION
|
||||
@RequestMapping(value = "/get", method = RequestMethod.GET, params = {"wallet_hash","txID"},produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getTransaction(@RequestParam(value = "txID") String txID, @RequestParam(value = "wallet_hash") String wallet_hash){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
Transaction transaction = transactionImplementation.getTransaction(wallet_hash,txID);
|
||||
if(transaction!=null){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(transaction);
|
||||
} else {
|
||||
return new ResponseEntity("{\"response\":\"error\"}", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//GET LATEST
|
||||
@RequestMapping(value = "/get/latest", method = RequestMethod.GET, params = {"wallet_hash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getLatestTransaction(@RequestParam(value = "wallet_hash") String wallet_hash){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<Transaction> listTransaction = transactionImplementation.getLatestTransactions(wallet_hash);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
//GET ALL
|
||||
@RequestMapping(value = "/getTransactions", method = RequestMethod.GET, params = {"wallet_hash","size"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getWalletTransactions(@RequestParam(value = "wallet_hash") String wallet_hash, @RequestParam(value = "size") String size){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<Transaction> listTransaction = transactionImplementation.getWalletTransactions(wallet_hash,size);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
//GET ALL WITH DATE
|
||||
@RequestMapping(value = "/getTransactions", method = RequestMethod.GET, params = {"wallet_hash","start_date","end_date","size"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getWalletTransactionsWithDate(@RequestParam(value = "wallet_hash") String wallet_hash, @RequestParam(value = "start_date") String start_date,
|
||||
@RequestParam(value = "end_date") String end_date, @RequestParam(value = "size") String size){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<Transaction> listTransaction = transactionImplementation.getAllBetweenDate(wallet_hash,start_date,end_date,size);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//SENT
|
||||
//GET SENT
|
||||
@RequestMapping(value = "/get/sent", method = RequestMethod.GET, params = {"wallet_hash","size"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getSentTransaction(@RequestParam(value = "wallet_hash") String wallet_hash, @RequestParam(value = "size") String size){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<Transaction> listTransaction = transactionImplementation.getSentTransaction(wallet_hash,size);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
//GET SENT WITH DATE
|
||||
@RequestMapping(value = "/get/sent", method = RequestMethod.GET, params = {"wallet_hash","start_date","end_date","size"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getSentTransactionWithDate(@RequestParam(value = "wallet_hash") String wallet_hash, @RequestParam(value = "start_date") String start_date,
|
||||
@RequestParam(value = "end_date") String end_date, @RequestParam(value = "size") String size){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<Transaction> listTransaction = transactionImplementation.getSentBetweenDate(wallet_hash,start_date,end_date,size);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//RECEIVED
|
||||
//GET RECEIVED
|
||||
@RequestMapping(value = "/get/received", method = RequestMethod.GET, params = {"wallet_hash","size"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getReceivedTransaction(@RequestParam(value = "wallet_hash") String wallet_hash, @RequestParam(value = "size") String size){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<Transaction> listTransaction = transactionImplementation.getReceivedTransaction(wallet_hash,size);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
//GET RECEIVED WITH DATE
|
||||
@RequestMapping(value = "/get/received", method = RequestMethod.GET, params = {"wallet_hash","start_date","end_date","size"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getReceivedTransactionWithDate(@RequestParam(value = "wallet_hash") String wallet_hash, @RequestParam(value = "start_date") String start_date,
|
||||
@RequestParam(value = "end_date") String end_date, @RequestParam(value = "size") String size){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<Transaction> listTransaction = transactionImplementation.getReceivedBetweenDate(wallet_hash,start_date,end_date,size);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
//GET ALL SENT TRANSACTION
|
||||
@RequestMapping(value = "/get/allSent", method = RequestMethod.GET, params = {"user_hash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getAllSentTransaction(@RequestParam(value = "user_hash") String user_hash){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<List<Transaction>> listTransaction = transactionImplementation.getAllSentTransaction(user_hash);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
//GET ALL RECEIVED TRANSACTION
|
||||
@RequestMapping(value = "/get/allReceived", method = RequestMethod.GET, params = {"user_hash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getAllReceivedTransaction(@RequestParam(value = "user_hash") String user_hash){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<List<Transaction>> listTransaction = transactionImplementation.getAllReceivedTransaction(user_hash);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getAll", method = RequestMethod.GET, params = {"user_hash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getAllTransaction(@RequestParam(value = "user_hash") String user_hash){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<Transaction> listTransaction = transactionImplementation.getAllTransactions(user_hash);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(listTransaction);
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
183
src/main/java/restService/UserResource.java
Normal file
183
src/main/java/restService/UserResource.java
Normal file
|
@ -0,0 +1,183 @@
|
|||
package restService;
|
||||
|
||||
import database.user.User;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import restImplementation.UserImplementation;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/rest/user")
|
||||
public class UserResource {
|
||||
@RequestMapping(value = "/register", method = RequestMethod.POST,produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseEntity registerUser(@Valid @RequestBody User user){
|
||||
try{
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
Map<String,String> userHashResponse = userImplementation.registerUser(user);
|
||||
|
||||
if(Boolean.parseBoolean(userHashResponse.get("response"))){
|
||||
String r = "{\"response\":\"ok\",\"user_hash\":\""+userHashResponse.get("user_hash")+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||
}else {
|
||||
String r = "{\"response\":\"User already exist\"}";
|
||||
return ResponseEntity.status(HttpStatus.FOUND).body(r);
|
||||
}
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/approve", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity approveUser(@Valid @RequestBody User user){
|
||||
try{
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
userImplementation.approveUser(user);
|
||||
String r = "{\"response\":\"ok\",\"user_hash\":\""+user.getUser_hash()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getApproval", method = RequestMethod.GET, params = {"user_hash","user_email"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getUserApproval(@RequestParam(value = "user_hash") String user_hash, @RequestParam(value = "user_email") String user_email){
|
||||
try{
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
Boolean approval = userImplementation.getUserApproval(user_email);
|
||||
String r = "{\"response\":\"ok\",\"approval\":"+approval+"}";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||
} catch (Exception e){
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity login(@Valid @RequestBody User user){
|
||||
try{
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
Map<String,String> response = userImplementation.userLogger(user);
|
||||
switch (response.get("response")){
|
||||
case "Not Exist" : {
|
||||
String r = "{\"response\":\"Not Found\"}";
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(r);
|
||||
}
|
||||
case "Not Allowed" :{
|
||||
String r = "{\"response\":\"Wrong authentication\"}";
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(r);
|
||||
}
|
||||
case "true":{
|
||||
String r = "{\"response\":\"ok\",\"user_hash\":\""+response.get("user_hash")+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||
}
|
||||
default:{
|
||||
String r = "{\"response\":\"Error\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get", method = RequestMethod.GET, params = {"user_email"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getUser(@RequestParam(value = "user_email") String user_email){
|
||||
try{
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
Boolean response = userImplementation.getUser(user_email);
|
||||
if(response){
|
||||
return ResponseEntity.status(HttpStatus.FOUND).body("{\"response\":"+response.toString()+"}");
|
||||
}else {
|
||||
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":"+response.toString()+"}");
|
||||
}
|
||||
}catch (Exception e){
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity removeUser(@Valid @RequestBody User user){
|
||||
try{
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
userImplementation.deleteUser(user);
|
||||
String r = "{\"response\":\"ok\"}";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update/password", method = RequestMethod.POST)
|
||||
public ResponseEntity updateUser(@RequestBody Map<String,String> requestParam){
|
||||
String user_email = requestParam.get("user_email");
|
||||
String current_password = requestParam.get("current_password");
|
||||
String new_password = requestParam.get("new_password");
|
||||
System.out.println(user_email);
|
||||
System.out.println(current_password);
|
||||
System.out.println(new_password);
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
try{
|
||||
Boolean r = userImplementation.updatePassword(user_email,current_password,new_password);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\""+r.toString()+"\"}");
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\"false\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/findByEmail", method = RequestMethod.GET, params = {"email"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity findUserByEmail(@RequestParam(value = "email") String email){
|
||||
try {
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
User r = userImplementation.getUserWithEmail(email);
|
||||
String response = "{\"name\":\""+r.getName()+"\",\"firstname\":\""+r.getFirstname()+"\",\"user_hash\":\""+r.getUser_hash()+"\",\"approved\":\""+r.isApproved()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/findByPhone", method = RequestMethod.GET, params = {"phone"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity findUserByPhone(@RequestParam(value = "phone") String phone){
|
||||
try {
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
User r = userImplementation.getUserWithPhone(phone);
|
||||
String response = "{\"name\":\""+r.getName()+"\",\"firstname\":\""+r.getFirstname()+"\",\"user_hash\":\""+r.getUser_hash()+"\",\"approved\":\""+r.isApproved()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/findByEmailAndPhone", method = RequestMethod.GET, params = {"email","phone"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity findUserByEmailAndPhone(@RequestParam(value = "email") String email, @RequestParam(value = "phone") String phone){
|
||||
try {
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
User r = userImplementation.getUserWithMailAndPhone(email,phone);
|
||||
String response = "{\"name\":\""+r.getName()+"\",\"firstname\":\""+r.getFirstname()+"\",\"user_hash\":\""+r.getUser_hash()+"\",\"approved\":\""+r.isApproved()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
}
|
101
src/main/java/restService/WalletResource.java
Normal file
101
src/main/java/restService/WalletResource.java
Normal file
|
@ -0,0 +1,101 @@
|
|||
package restService;
|
||||
|
||||
import database.Wallet.BalanceWallet;
|
||||
import database.Wallet.Wallet;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import restImplementation.WalletImplementation;
|
||||
import javax.json.JsonArray;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/rest/wallet")
|
||||
public class WalletResource {
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST,produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseEntity createWallet(@Valid @RequestBody Wallet wallet){
|
||||
try{
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
Wallet walletResponse = walletImplementation.createWallet(wallet);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(walletResponse);
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUserWallets", method = RequestMethod.GET, params = {"user_hash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getWallets(@RequestParam(value = "user_hash") String user_hash){
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
JsonArray wallets = walletImplementation.getAllUserWallets(user_hash);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(wallets);
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getWallet", method = RequestMethod.GET, params = {"wallet_hash"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getWallet(@RequestParam(value = "wallet_hash") String wallet_hash){
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
Wallet walletResponse = walletImplementation.getWallet(wallet_hash);
|
||||
if(walletResponse!=null){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(walletResponse);
|
||||
}else{
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("{\"response\":null}");
|
||||
}
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/setBalance", method = RequestMethod.POST,produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity setBalance(@RequestBody BalanceWallet BalanceWallet){
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
walletImplementation.setBalanceToWallet(BalanceWallet.getAssociation_hash(), BalanceWallet.getAssocation_pwd(), BalanceWallet.getWallet_hash(),BalanceWallet.getAmount());
|
||||
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}");
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/transfer", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity transferWallet(@RequestBody Wallet wallet){
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try {
|
||||
walletImplementation.transferWallet(wallet.getWallet_hash(),wallet.getUser_hash());
|
||||
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}");
|
||||
} catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public ResponseEntity deleteWallet(@RequestBody Map<String,String> requestParam){
|
||||
String user_email = requestParam.get("user_email");
|
||||
String user_hash = requestParam.get("user_hash");
|
||||
String user_password = requestParam.get("user_password");
|
||||
String wallet_hash_source = requestParam.get("wallet_hash_source");
|
||||
String wallet_hash_dest = requestParam.get("wallet_hash_dest");
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
walletImplementation.deleteWallet(user_email,user_hash,user_password,wallet_hash_source,wallet_hash_dest);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"true\"}");
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\"false\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
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 to monnethic ! ";}
|
||||
|
||||
}
|
38
src/main/java/restService/WelcomeResource.java
Normal file
38
src/main/java/restService/WelcomeResource.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package restService;
|
||||
|
||||
import blockchain.client.CAClientWrapper;
|
||||
import blockchain.configuration.AppConfig;
|
||||
import blockchain.configuration.Config;
|
||||
import blockchain.user.UserContext;
|
||||
import org.hyperledger.fabric.sdk.Enrollment;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RestController
|
||||
public class WelcomeResource {
|
||||
@RequestMapping("/")
|
||||
public String index(){return "Welcome from Monnethic !";}
|
||||
|
||||
@RequestMapping("/bc/register/admin")
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public void registerAdminApp(){
|
||||
String caUrl = AppConfig.getCA_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);
|
||||
caClientWrapper.enrollAdmin(adminContext.getName(),Config.ADMIN_PASSWORD,adminContext.getAffiliation());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
45
src/test/java/blockchain/client/TestEnrollAdmin.java
Normal file
45
src/test/java/blockchain/client/TestEnrollAdmin.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package blockchain.client;
|
||||
|
||||
import blockchain.configuration.AppConfig;
|
||||
import blockchain.configuration.Config;
|
||||
import blockchain.user.UserContext;
|
||||
import org.hyperledger.fabric.sdk.Enrollment;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
//Test to enroll Admin
|
||||
@Ignore
|
||||
public class TestEnrollAdmin {
|
||||
@Test
|
||||
public void TestAEnrollAdmin(){
|
||||
String caUrl = AppConfig.getCA_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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
40
src/test/java/blockchain/client/TestRegisterEnrollUser.java
Normal file
40
src/test/java/blockchain/client/TestRegisterEnrollUser.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package blockchain.client;
|
||||
|
||||
import blockchain.configuration.AppConfig;
|
||||
import blockchain.configuration.Config;
|
||||
import blockchain.user.UserContext;
|
||||
import blockchain.utility.Util;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
//Test to register and enroll user
|
||||
@Ignore
|
||||
public class TestRegisterEnrollUser {
|
||||
private static Logger logger = Logger.getLogger(TestRegisterEnrollUser.class);
|
||||
//Success
|
||||
@Test
|
||||
public void RegisterEnrollUser(){
|
||||
String caUrl = AppConfig.getCA_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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
32
src/test/java/blockchain/query/QueryChannelTest.java
Normal file
32
src/test/java/blockchain/query/QueryChannelTest.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
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.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
//Test to show channels on a node
|
||||
@Ignore
|
||||
public class QueryChannelTest {
|
||||
private static Logger logger = Logger.getLogger(QueryChannelTest.class);
|
||||
|
||||
@Test
|
||||
public void TestQueryForChannels(){
|
||||
BasicConfigurator.configure();
|
||||
UserContext userContext = Util.readUserContext(Config.ORG1,"admin");
|
||||
try{
|
||||
FabricClientWrapper fabricClientWrapper = new FabricClientWrapper(userContext);
|
||||
Set<String> channels = fabricClientWrapper.queryForChannels();
|
||||
logger.info("CHANNELS : "+channels);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package blockchain.query.Transaction;
|
||||
|
||||
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hyperledger.fabric.sdk.*;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class TransactionTest {
|
||||
private static Logger logger = Logger.getLogger(TransactionTest.class);
|
||||
|
||||
@Test
|
||||
public void TestTransaction() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
String functionName = "transaction";
|
||||
String[] args = new String[]{"qerh654d5f5h46q4fdh6h65fh00","qerh654d5f5hdsf1515","200"};
|
||||
BlockEvent.TransactionEvent responseEvent = transactionWrapper.sendTransaction(functionName,args);
|
||||
String txID = responseEvent.getTransactionID();
|
||||
logger.info("Event transaction id : "+txID); //print transaction id
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
29
src/test/java/blockchain/query/User/DeleteUserTest.java
Normal file
29
src/test/java/blockchain/query/User/DeleteUserTest.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package blockchain.query.User;
|
||||
|
||||
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hyperledger.fabric.sdk.*;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class DeleteUserTest {
|
||||
private static Logger logger = Logger.getLogger(DeleteUserTest.class);
|
||||
|
||||
@Test
|
||||
public void TestDeleteUser() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
String functionName = "deleteUser";
|
||||
String[] args = new String[]{"$2a$10$ydRV2YV8tv/ytKpLs16u7u2Fc0C.f8s746wcmqRLoKbJDrh8R/1Ny"};
|
||||
BlockEvent.TransactionEvent responseEvent = transactionWrapper.sendTransaction(functionName,args);
|
||||
logger.info("Event transaction id : "+responseEvent.getTransactionID()); //print transaction id
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
40
src/test/java/blockchain/query/User/ReadUserTest.java
Normal file
40
src/test/java/blockchain/query/User/ReadUserTest.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package blockchain.query.User;
|
||||
|
||||
|
||||
import blockchain.query.QueryWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonReader;
|
||||
import java.io.StringReader;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class ReadUserTest {
|
||||
private static Logger logger = Logger.getLogger(ReadUserTest.class);
|
||||
|
||||
@Test
|
||||
public void TestQueryReadUser() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
String functionName = "readUser";
|
||||
String[] args = new String[]{"$2a$10$ydRV2YV8tv/ytKpLs16u7u2Fc0C.f8s746wcmqRLoKbJDrh8R/1Ny"};
|
||||
String response = queryWrapper.sendQuery(functionName,args);
|
||||
if(response != null){
|
||||
JsonReader reader = Json.createReader(new StringReader(response));
|
||||
JsonObject userInfo = reader.readObject();
|
||||
logger.info(userInfo.toString());
|
||||
logger.info("userAssociation : "+userInfo.getString("userAssociation"));
|
||||
logger.info("userFirstName : "+userInfo.getString("userFirstName"));
|
||||
} else {
|
||||
throw new Exception("Response is null");
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
28
src/test/java/blockchain/query/User/RegisterUserTest.java
Normal file
28
src/test/java/blockchain/query/User/RegisterUserTest.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package blockchain.query.User;
|
||||
|
||||
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hyperledger.fabric.sdk.*;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class RegisterUserTest {
|
||||
private static Logger logger = Logger.getLogger(RegisterUserTest.class);
|
||||
@Test
|
||||
public void TestRegisterUser() {
|
||||
BasicConfigurator.configure();
|
||||
try {
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
String functionName = "registerUser";
|
||||
String[] args = new String[]{"$2a$10$txHyi9ZOO0U6RLLOOQCWM.L8xafduYcFHHE93Prfu/VtV8h6EyaJm","QPk7/bB7kkxbwHoQ5UhxIw==","fBunq4eRLXDvrDUUmtWYCw==","JOdbTStvgKDN/OqvFz21NQ==","gonette"};
|
||||
BlockEvent.TransactionEvent responseEvent = transactionWrapper.sendTransaction(functionName,args);
|
||||
logger.info("Event transaction id : "+responseEvent.getTransactionID()); //print transaction id
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
29
src/test/java/blockchain/query/User/UserPermissionTest.java
Normal file
29
src/test/java/blockchain/query/User/UserPermissionTest.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package blockchain.query.User;
|
||||
|
||||
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hyperledger.fabric.sdk.*;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class UserPermissionTest {
|
||||
private static Logger logger = Logger.getLogger(UserPermissionTest.class);
|
||||
|
||||
@Test
|
||||
public void TestUserPermission() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
String functionName = "setUserPermission";
|
||||
String[] args = new String[]{"usera"};
|
||||
BlockEvent.TransactionEvent responseEvent = transactionWrapper.sendTransaction(functionName,args);
|
||||
logger.info("Event transaction id : "+responseEvent.getTransactionID()); //print transaction id
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
29
src/test/java/blockchain/query/Wallet/DeleteWalletTest.java
Normal file
29
src/test/java/blockchain/query/Wallet/DeleteWalletTest.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package blockchain.query.Wallet;
|
||||
|
||||
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hyperledger.fabric.sdk.*;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class DeleteWalletTest {
|
||||
private static Logger logger = Logger.getLogger(DeleteWalletTest.class);
|
||||
|
||||
@Test
|
||||
public void TestDeleteWallet() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
String functionName = "deleteWallet";
|
||||
String[] args = new String[]{"$2a$10$CPecvlEaza2V0ze6.Evee.S91mOJTlqZerB3eyTiH/RCLsFFyLfuS"};
|
||||
BlockEvent.TransactionEvent responseEvent = transactionWrapper.sendTransaction(functionName,args);
|
||||
logger.info("Event transaction id : "+responseEvent.getTransactionID()); //print transaction id
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
30
src/test/java/blockchain/query/Wallet/InitWalletTest.java
Normal file
30
src/test/java/blockchain/query/Wallet/InitWalletTest.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
package blockchain.query.Wallet;
|
||||
|
||||
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hyperledger.fabric.sdk.BlockEvent;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class InitWalletTest {
|
||||
private static Logger logger = Logger.getLogger(InitWalletTest.class);
|
||||
|
||||
@Test
|
||||
public void TestInitWallet() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
String functionName = "initWallet";
|
||||
//String[] args = new String[]{"qerh654d5f5hdsf1515","client","usera"};
|
||||
String[] args = new String[]{"qerh654d5f5hdsf16","fournisseur","bitman"};
|
||||
BlockEvent.TransactionEvent responseEvent = transactionWrapper.sendTransaction(functionName,args);
|
||||
logger.info("Event transaction id : "+responseEvent.getTransactionID()); //print transaction id
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package blockchain.query.Wallet;
|
||||
|
||||
|
||||
import blockchain.query.QueryWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonReader;
|
||||
import java.io.StringReader;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class QueryWalletByOwnerTest {
|
||||
private static Logger logger = Logger.getLogger(QueryWalletByOwnerTest.class);
|
||||
|
||||
@Test
|
||||
public void TestQueryWalletByOwnerTest() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
String functionName = "queryWalletsByOwner";
|
||||
//String[] args = new String[]{"$2a$10$r7jlPdeESPFd1dKjvrEmB.SoxOXh3jHtWiPTAFKB3lGSgvda.zMyC"};
|
||||
String[] args = new String[]{"$2a$10$nbpChJwXc7KnW.vylasrFeAqqmQaTyIJRkSkD1ob5l6BhL12eRcNe"};
|
||||
String response = queryWrapper.sendQuery(functionName,args);
|
||||
logger.info("response : "+response);
|
||||
|
||||
if(response != null) {
|
||||
JsonReader reader = Json.createReader(new StringReader(response));
|
||||
JsonArray walletInfo = reader.readArray();
|
||||
logger.info("walletInfo : "+walletInfo);
|
||||
|
||||
for(Object obj : walletInfo){
|
||||
JsonObject o = (JsonObject) obj;
|
||||
o = o.get("Record").asJsonObject();
|
||||
logger.info("JsonObject : "+o);
|
||||
logger.info("walletInfo ID : "+o.getString("id"));
|
||||
logger.info("walletInfo balance : "+o.getJsonNumber("balance"));
|
||||
}
|
||||
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package blockchain.query.Wallet;
|
||||
|
||||
|
||||
import blockchain.query.QueryWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class QueryWalletByTypeTest {
|
||||
private static Logger logger = Logger.getLogger(QueryWalletByTypeTest.class);
|
||||
|
||||
@Test
|
||||
public void TestQueryWalletByTypeTest() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
String functionName = "queryWalletsByType";
|
||||
String[] args = new String[]{"client"};
|
||||
String response = queryWrapper.sendQuery(functionName,args);
|
||||
logger.info("response : "+response);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package blockchain.query.Wallet;
|
||||
|
||||
|
||||
import blockchain.query.QueryWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class QueryWalletHistory {
|
||||
private static Logger logger = Logger.getLogger(QueryWalletHistory.class);
|
||||
|
||||
@Test
|
||||
public void TestQueryWalletHistory() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
String functionName = "getHistoryForWallet";
|
||||
String[] args = new String[]{"$2a$10$vnXkX4CNsRqoJyaeMLyyB.mPdqFX20pc3Ky.rfUgQeLd4GSF3xWei"};
|
||||
String response = queryWrapper.sendQuery(functionName,args);
|
||||
logger.info("response : "+response);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
72
src/test/java/blockchain/query/Wallet/ReadWalletTest.java
Normal file
72
src/test/java/blockchain/query/Wallet/ReadWalletTest.java
Normal file
|
@ -0,0 +1,72 @@
|
|||
package blockchain.query.Wallet;
|
||||
|
||||
|
||||
import blockchain.query.QueryWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonReader;
|
||||
import java.io.StringReader;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class ReadWalletTest {
|
||||
private static Logger logger = Logger.getLogger(ReadWalletTest.class);
|
||||
|
||||
|
||||
@Test
|
||||
public void SuccessTestReadWalletTest() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
String functionName = "readWallet";
|
||||
//String[] args = new String[]{"$2a$10$vnXkX4CNsRqoJyaeMLyyB.mPdqFX20pc3Ky.rfUgQeLd4GSF3xWei"};
|
||||
String[] args = new String[]{"$2a$10$fE4t.2YdLS3Gto6SSUksaurlA8m49QdysADTmb5Rs4QQeEGFMYq5C"};
|
||||
String response = queryWrapper.sendQuery(functionName,args);
|
||||
|
||||
if(response!=null){
|
||||
JsonReader reader = Json.createReader(new StringReader(response));
|
||||
JsonObject walletInfo = reader.readObject();
|
||||
double balance = walletInfo.getJsonNumber("balance").doubleValue();
|
||||
|
||||
logger.info("response : "+response);
|
||||
logger.info("balance : "+balance);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void FailTestReadWalletTest() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
String functionName = "readWallet";
|
||||
String[] args = new String[]{"tttt"};
|
||||
String response = queryWrapper.sendQuery(functionName,args);
|
||||
|
||||
if(response!=null){
|
||||
JsonReader reader = Json.createReader(new StringReader(response));
|
||||
JsonObject walletInfo = reader.readObject();
|
||||
double balance = walletInfo.getJsonNumber("balance").doubleValue();
|
||||
|
||||
logger.info("response : "+response);
|
||||
logger.info("balance : "+balance);
|
||||
} else {
|
||||
logger.warn("ERROR");
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
29
src/test/java/blockchain/query/Wallet/SetWalletSoldTest.java
Normal file
29
src/test/java/blockchain/query/Wallet/SetWalletSoldTest.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package blockchain.query.Wallet;
|
||||
|
||||
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hyperledger.fabric.sdk.*;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class SetWalletSoldTest {
|
||||
private static Logger logger = Logger.getLogger(SetWalletSoldTest.class);
|
||||
|
||||
@Test
|
||||
public void TestSetWalletSold() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
String functionName = "setSoldOnWallet";
|
||||
String[] args = new String[]{"qerh654d5f5hdsf1515","500"};
|
||||
BlockEvent.TransactionEvent responseEvent = transactionWrapper.sendTransaction(functionName,args);
|
||||
logger.info("Event transaction id : "+responseEvent.getTransactionID()); //print transaction id
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package blockchain.query.Wallet;
|
||||
|
||||
|
||||
import blockchain.query.TransactionWrapper;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hyperledger.fabric.sdk.*;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@Ignore
|
||||
public class TransferWalletTest {
|
||||
private static Logger logger = Logger.getLogger(TransferWalletTest.class);
|
||||
|
||||
@Test
|
||||
public void TestTransfertWallet() {
|
||||
BasicConfigurator.configure();
|
||||
try{
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
String functionName = "transferWallet";
|
||||
String[] args = new String[]{"qerh654d5f5h46q4fdh6h65fh00","bitman"};
|
||||
//String[] args = new String[]{"qerh654d5f5h46q4fdh6h65fh00","usera"};
|
||||
BlockEvent.TransactionEvent responseEvent = transactionWrapper.sendTransaction(functionName,args);
|
||||
logger.info("Event transaction id : "+responseEvent.getTransactionID()); //print transaction id
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
23
src/test/java/blockchain/user/UserContextTest.java
Normal file
23
src/test/java/blockchain/user/UserContextTest.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package blockchain.user;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
//Test to create a User
|
||||
@Ignore
|
||||
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());
|
||||
}
|
||||
}
|
24
src/test/java/blockchain/utility/ReadUserTest.java
Normal file
24
src/test/java/blockchain/utility/ReadUserTest.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package blockchain.utility;
|
||||
|
||||
import blockchain.configuration.Config;
|
||||
import blockchain.user.UserContext;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
//Test to Read User
|
||||
@Ignore
|
||||
public class ReadUserTest {
|
||||
@Test
|
||||
public void testReadUserOrg1(){
|
||||
try{
|
||||
UserContext userContext = Util.readUserContext(Config.ORG1, "User2-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();
|
||||
}
|
||||
}
|
||||
}
|
57
src/test/java/blockchain/utility/UtilTest.java
Normal file
57
src/test/java/blockchain/utility/UtilTest.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package blockchain.utility;
|
||||
|
||||
import blockchain.user.UserContext;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
|
||||
//Test to Read and Write user from files
|
||||
@Ignore
|
||||
@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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
23
src/test/java/crypto/CryptoTest.java
Normal file
23
src/test/java/crypto/CryptoTest.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package crypto;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
|
||||
import java.time.Instant;
|
||||
@Ignore
|
||||
public class CryptoTest {
|
||||
|
||||
@Test
|
||||
public void testHash(){
|
||||
String password = "newPassword";
|
||||
System.out.println(hashPassword(password));
|
||||
|
||||
long now = Instant.now().toEpochMilli();
|
||||
System.out.println(now);
|
||||
}
|
||||
|
||||
private String hashPassword(String plainTextPassword) {
|
||||
return BCrypt.hashpw(plainTextPassword, BCrypt.gensalt());
|
||||
}
|
||||
}
|
25
src/test/java/database/TransactionTest.java
Normal file
25
src/test/java/database/TransactionTest.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package database;
|
||||
|
||||
import database.transaction.Transaction;
|
||||
import database.transaction.TransactionDao;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Ignore
|
||||
public class TransactionTest {
|
||||
@Test
|
||||
public void getTransactionBetween(){
|
||||
TransactionDao transactionDao = new TransactionDao();
|
||||
try{
|
||||
List<Transaction> list = transactionDao.getAllTransactionBetweenDate("$2a$10$dmrOFohMnbeVzVHMGc5JnuQ7MMTObn3lHTrMSe/IonD3VTeM.muo.","1555180582250","1555186015913",2);
|
||||
for(Transaction t : list){
|
||||
System.out.println(t.toString());
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
22
src/test/java/database/UserLoginTest.java
Normal file
22
src/test/java/database/UserLoginTest.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package database;
|
||||
|
||||
import database.user.User;
|
||||
import database.user.UserDao;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@Ignore
|
||||
public class UserLoginTest {
|
||||
@Test
|
||||
public void Login(){
|
||||
try{
|
||||
String email = "thomas.meunier@gmail.com";
|
||||
UserDao userDao = new UserDao();
|
||||
User u = userDao.getUserWithEmail(email);
|
||||
System.out.println(u.toString());
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
38
src/test/java/encryption/DataEncryptionTest.java
Normal file
38
src/test/java/encryption/DataEncryptionTest.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package encryption;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Test;
|
||||
@Ignore
|
||||
public class DataEncryptionTest {
|
||||
private static Logger logger = Logger.getLogger(DataEncryptionTest.class);
|
||||
|
||||
@Test
|
||||
public void initEncryptionTest() {
|
||||
BasicConfigurator.configure();
|
||||
|
||||
DataEncryption dataEncryption = new DataEncryption();
|
||||
|
||||
|
||||
String uEmail = "toto@mail.com";
|
||||
logger.info("test: "+uEmail);
|
||||
try{
|
||||
String encrypted = dataEncryption.encryptData(uEmail);
|
||||
logger.info("encrypted: "+encrypted);
|
||||
|
||||
//String decrypted = dataEncryption.decryptData(encrypted);
|
||||
//logger.info("decrypted: "+decrypted);
|
||||
|
||||
String encrypted1 = dataEncryption.encryptData(uEmail);
|
||||
logger.info("encrypted: "+encrypted1);
|
||||
|
||||
|
||||
|
||||
} catch (Exception e){
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
154
src/test/java/restImplementation/CreateDataSetProcess.java
Normal file
154
src/test/java/restImplementation/CreateDataSetProcess.java
Normal file
|
@ -0,0 +1,154 @@
|
|||
package restImplementation;
|
||||
|
||||
import database.Wallet.Wallet;
|
||||
import database.user.User;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Ignore
|
||||
public class CreateDataSetProcess { //OK
|
||||
private static Logger logger = Logger.getLogger(CreateDataSetProcess.class);
|
||||
private static String gonetteHash = "";
|
||||
private static String userHashA = "";
|
||||
private static String userHashB = "";
|
||||
private static String walletHash1UserA = "";
|
||||
private static String walletHash2UserA = "";
|
||||
private static String walletHash1UserB = "";
|
||||
private static String walletHash2UserB = "";
|
||||
|
||||
public static void main(String [ ] args){
|
||||
|
||||
BasicConfigurator.configure();
|
||||
User association = new User("Gonette","Association","gonette-lyon@gmail.com","asso_GonE8977&4$*-","gonette");
|
||||
User userA = new User("Meunier","Thomas","thomas.meunier@gmail.com","thomasPwd158$*","gonette");
|
||||
User userB = new User("Petit","Claire","claire.petit@gmail.com","gonClaire789$*","0607080900","gonette");
|
||||
|
||||
|
||||
String assoPwd = association.getPassword();
|
||||
String userBPwd = userB.getPassword();
|
||||
/*
|
||||
registerUser(association);
|
||||
association.setUser_hash(gonetteHash);
|
||||
registerUser(userA);
|
||||
userA.setUser_hash(userHashA);
|
||||
registerUser(userB);
|
||||
userB.setUser_hash(userHashB);
|
||||
*/
|
||||
|
||||
userA.setUser_hash("$2a$10$r7jlPdeESPFd1dKjvrEmB.SoxOXh3jHtWiPTAFKB3lGSgvda.zMyC");
|
||||
userB.setUser_hash("$2a$10$nXjf7raNTCe2gdUiMCsNEegqUBQ6iihgc8LtoBUux02hL8j49b1rG");
|
||||
association.setUser_hash("$2a$10$otvlv9oGEbnOPuImSJDDw.XDb3Bl7TR/Qw7w1HIfX0je11R/0leiS");
|
||||
//approveUser(userA);
|
||||
//approveUser(userB);
|
||||
//approveUser(association);
|
||||
|
||||
|
||||
Wallet walletAUserA = new Wallet("client",userA.getUser_hash());
|
||||
Wallet walletBUserA = new Wallet("fournisseur",userA.getUser_hash());
|
||||
Wallet walletAUserB = new Wallet("client",userB.getUser_hash());
|
||||
Wallet walletBUserB = new Wallet("personnel",userB.getUser_hash());
|
||||
|
||||
//String wHash1 = createWallet(walletAUserA);
|
||||
//walletAUserA.setWallet_hash(wHash1);
|
||||
//String wHash2 = createWallet(walletBUserA);
|
||||
//walletBUserA.setWallet_hash(wHash2);
|
||||
//String wHash3 = createWallet(walletAUserB);
|
||||
//walletAUserB.setWallet_hash(wHash3);
|
||||
//String wHash4 = createWallet(walletBUserB);
|
||||
//walletBUserB.setWallet_hash(wHash4);
|
||||
walletBUserA.setWallet_hash("$2a$10$dmrOFohMnbeVzVHMGc5JnuQ7MMTObn3lHTrMSe/IonD3VTeM.muo.");
|
||||
walletAUserB.setWallet_hash("$2a$10$auM7V8D0EuftV.2TqzWgi.4MIw0EzSJ8JyE5F5GzKknzqnila.EUm");
|
||||
|
||||
|
||||
|
||||
//setBalance(association.getUser_hash(), assoPwd, walletBUserA.getWallet_hash(),120);
|
||||
//setBalance(association.getUser_hash(), assoPwd, walletAUserB.getWallet_hash(),50);
|
||||
|
||||
doTransaction(userB.getUser_hash(), userBPwd, walletAUserB.getWallet_hash(),walletBUserA.getWallet_hash(),1,userB.getAssociation());
|
||||
|
||||
}
|
||||
|
||||
private static void registerUser(User user){
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
try{
|
||||
Map<String,String> response = userImplementation.registerUser(user);
|
||||
if(Boolean.parseBoolean(response.get("response"))){
|
||||
String userHash = response.get("userHash");
|
||||
|
||||
if(user.getEmail().equals("thomas.meunier@gmail.com")){
|
||||
userHashA = userHash;
|
||||
} else if (user.getEmail().equals("gonette-lyon@gmail.com")){
|
||||
gonetteHash = userHash;
|
||||
} else {
|
||||
userHashB = userHash;
|
||||
}
|
||||
|
||||
logger.info("User: "+user.getEmail()+". User hash: "+userHash);
|
||||
}
|
||||
} catch (Exception e){
|
||||
logger.warn("Error registerUser : "+e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void approveUser(User user){
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
try{
|
||||
userImplementation.approveUser(user);
|
||||
}catch (Exception e){
|
||||
logger.warn("Error approveUser : "+e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static String createWallet(Wallet wallet){
|
||||
String wHash="";
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
Wallet walletResponse = walletImplementation.createWallet(wallet);
|
||||
if(wallet.getUser_hash().equals(userHashA) && wallet.getType().equals("client")){
|
||||
walletHash1UserA = walletResponse.getWallet_hash();
|
||||
} else if(wallet.getUser_hash().equals(userHashA) && wallet.getType().equals("fournisseur")){
|
||||
walletHash2UserA = walletResponse.getWallet_hash();
|
||||
} else if(wallet.getUser_hash().equals(userHashB) && wallet.getType().equals("personnel")){
|
||||
walletHash1UserB = walletResponse.getWallet_hash();
|
||||
} else {
|
||||
walletHash2UserB = walletResponse.getWallet_hash();
|
||||
}
|
||||
|
||||
logger.info("wallet hash: "+walletResponse.getWallet_hash());
|
||||
logger.info("wallet balance: "+walletResponse.getBalance());
|
||||
logger.info("wallet type: "+walletResponse.getType());
|
||||
logger.info("onwer: "+walletResponse.getUser_hash());
|
||||
|
||||
wHash = walletResponse.getWallet_hash();
|
||||
}catch (Exception e){
|
||||
logger.warn("Error approveUser : "+e);
|
||||
}
|
||||
return wHash;
|
||||
}
|
||||
|
||||
|
||||
private static void setBalance(String associationHash, String associationPwd, String walletHash, double amount){
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
walletImplementation.setBalanceToWallet(associationHash, associationPwd, walletHash,amount);
|
||||
}catch (Exception e){
|
||||
logger.warn("Error approveUser : "+e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void doTransaction(String sourceUserHash, String sourceUserPwd, String sourceWalletHash, String destWalletHash, double amount, String unit){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
transactionImplementation.sendTransaction(sourceUserHash, sourceUserPwd, sourceWalletHash,destWalletHash,amount,unit);
|
||||
} catch (Exception e){
|
||||
logger.warn("Error approveUser : "+e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package restImplementation;
|
||||
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@Ignore
|
||||
public class SessionImplementationTest {
|
||||
private static Logger logger = Logger.getLogger(SessionImplementationTest.class);
|
||||
|
||||
@Test
|
||||
public void testAstartSession() { //OK
|
||||
BasicConfigurator.configure();
|
||||
String userHash = "$2a$10$tdkMwJ7BQSOXO2uofu/fEOlncUfuX7SsjB.2N9KVsXJUQiarAQzpG";
|
||||
String userEmail = "TotoEmail@gmail.com";
|
||||
SessionImplementation sessionImplementation = new SessionImplementation();
|
||||
|
||||
try{
|
||||
int responseSessionId = sessionImplementation.startSession(userHash,userEmail);
|
||||
logger.info("SESSION ID : "+responseSessionId);
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBendSession(){ //OK
|
||||
BasicConfigurator.configure();
|
||||
SessionImplementation sessionImplementation = new SessionImplementation();
|
||||
try{
|
||||
sessionImplementation.endSession(1);
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,213 @@
|
|||
package restImplementation;
|
||||
|
||||
import database.transaction.Transaction;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Ignore
|
||||
public class TransactionImplementationTest {
|
||||
private static Logger logger = Logger.getLogger(TransactionImplementationTest.class);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void doMultipleTransaction(){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
|
||||
for(int i=0;i<12;i++){
|
||||
HashMap transactionResponse = transactionImplementation.sendTransaction("$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.","thomasPwd158$*",
|
||||
"$2a$10$6Z4uNeOgAKhpWYGVYwPWhe6G91lIKHOCA2yYcpzS1pbJyosNNw3Gu","$2a$10$hdvk6LuOxVOI1EXtmswh0eJco0nOJVTEaJdEKuy/6tGcdxetDbY4i",1.0,"gonette");
|
||||
if(Boolean.parseBoolean(transactionResponse.get("success").toString())){
|
||||
logger.info("transaction ID: "+transactionResponse.get("message"));
|
||||
} else {
|
||||
logger.warn("Error (else) : "+transactionResponse.get("message"));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<4;i++){
|
||||
HashMap transactionResponse = transactionImplementation.sendTransaction("$2a$10$GzyMhD3n05Z2lwCnoGi2dusjKrNAmHhtn5fw1xLpes5.cEV5T7lve","gonClaire789$*",
|
||||
"$2a$10$UKiTo/eqpnvlny3U5xpJ../C2WOgoxebAl3xiexAhinC8X7Jt2wY.","$2a$10$8PJyraUjMoL/h.cQjJyMZedBUlcTjPjNm4j1NuqzQBTnSe2XNuGM2",1.0,"gonette");
|
||||
if(Boolean.parseBoolean(transactionResponse.get("success").toString())){
|
||||
logger.info("transaction ID: "+transactionResponse.get("message"));
|
||||
} else {
|
||||
logger.warn("Error (else) : "+transactionResponse.get("message"));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<3;i++){
|
||||
HashMap transactionResponse = transactionImplementation.sendTransaction("$2a$10$GzyMhD3n05Z2lwCnoGi2dusjKrNAmHhtn5fw1xLpes5.cEV5T7lve","gonClaire789$*",
|
||||
"$2a$10$hdvk6LuOxVOI1EXtmswh0eJco0nOJVTEaJdEKuy/6tGcdxetDbY4i","$2a$10$6Z4uNeOgAKhpWYGVYwPWhe6G91lIKHOCA2yYcpzS1pbJyosNNw3Gu",1.0,"gonette");
|
||||
if(Boolean.parseBoolean(transactionResponse.get("success").toString())){
|
||||
logger.info("transaction ID: "+transactionResponse.get("message"));
|
||||
} else {
|
||||
logger.warn("Error (else) : "+transactionResponse.get("message"));
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void doTransactionA(){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
HashMap transactionResponse = transactionImplementation.sendTransaction("$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.","thomasPwd158$*",
|
||||
"$2a$10$6Z4uNeOgAKhpWYGVYwPWhe6G91lIKHOCA2yYcpzS1pbJyosNNw3Gu","$2a$10$8PJyraUjMoL/h.cQjJyMZedBUlcTjPjNm4j1NuqzQBTnSe2XNuGM2",1.0,"gonette");
|
||||
if(Boolean.parseBoolean(transactionResponse.get("success").toString())){
|
||||
logger.info("transaction ID: "+transactionResponse.get("message"));
|
||||
} else {
|
||||
logger.warn("Error (else) : "+transactionResponse.get("message"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void doTransaction(){
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
HashMap transactionResponse = transactionImplementation.sendTransaction("$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.","thomasPwd158$*",
|
||||
"$2a$10$8PJyraUjMoL/h.cQjJyMZedBUlcTjPjNm4j1NuqzQBTnSe2XNuGM2","$2a$10$6Z4uNeOgAKhpWYGVYwPWhe6G91lIKHOCA2yYcpzS1pbJyosNNw3Gu",1.0,"gonette");
|
||||
if(Boolean.parseBoolean(transactionResponse.get("success").toString())){
|
||||
logger.info("transaction ID: "+transactionResponse.get("message"));
|
||||
} else {
|
||||
logger.warn("Error (else) : "+transactionResponse.get("message"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getAllSentTransaction(){
|
||||
BasicConfigurator.configure();
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<List<Transaction>> result = transactionImplementation.getAllSentTransaction("$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.");
|
||||
//logger.info(result);
|
||||
for(List<Transaction> re : result){
|
||||
logger.info(re);
|
||||
for(Transaction t: re){
|
||||
logger.info(t);
|
||||
}
|
||||
logger.info(" other wallet");
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getSent(){
|
||||
BasicConfigurator.configure();
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<Transaction> result = transactionImplementation.getSentTransaction("$2a$10$6Z4uNeOgAKhpWYGVYwPWhe6G91lIKHOCA2yYcpzS1pbJyosNNw3Gu");
|
||||
//logger.info(result);
|
||||
for(Transaction re : result){
|
||||
logger.info(re);
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getAllReceivedTransaction(){
|
||||
BasicConfigurator.configure();
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<List<Transaction>> result = transactionImplementation.getAllReceivedTransaction("$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.");
|
||||
//logger.info(result);
|
||||
for(List<Transaction> re : result){
|
||||
logger.info(re);
|
||||
for(Transaction t: re){
|
||||
logger.info(t);
|
||||
}
|
||||
logger.info(" other wallet");
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getReceived(){
|
||||
BasicConfigurator.configure();
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try {
|
||||
List<Transaction> result = transactionImplementation.getReceivedTransaction("$2a$10$6Z4uNeOgAKhpWYGVYwPWhe6G91lIKHOCA2yYcpzS1pbJyosNNw3Gu");
|
||||
//logger.info(result);
|
||||
for(Transaction re : result){
|
||||
logger.info(re);
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getLatestTransactions(){
|
||||
BasicConfigurator.configure();
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try{
|
||||
List<Transaction> listT = transactionImplementation.getLatestTransactions("$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.");
|
||||
logger.info("size : "+listT.size());
|
||||
for(Transaction t:listT){
|
||||
|
||||
logger.info(t.getTransaction_from()+" - "+t.getTransaction_to()+" - "+new Date(t.getTransaction_date()));
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getAllTransaction(){
|
||||
BasicConfigurator.configure();
|
||||
TransactionImplementation transactionImplementation = new TransactionImplementation();
|
||||
try{
|
||||
List<Transaction> listT = transactionImplementation.getAllTransactions("$2a$10$J7B8sXULfiPfnlKRlTjqQuSrbumTyv.acB8NpxDrUQ3WmnfKdjx0.");
|
||||
logger.info("size : "+listT.size());
|
||||
for(Transaction t:listT){
|
||||
logger.info(new Date(t.getTransaction_date())+"-"+t);
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
152
src/test/java/restImplementation/UserImplementationTest.java
Normal file
152
src/test/java/restImplementation/UserImplementationTest.java
Normal file
|
@ -0,0 +1,152 @@
|
|||
package restImplementation;
|
||||
|
||||
import database.user.User;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Ignore
|
||||
public class UserImplementationTest {
|
||||
private static Logger logger = Logger.getLogger(UserImplementationTest.class);
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void ApproveUser(){
|
||||
BasicConfigurator.configure();
|
||||
String email = "sarah.huet@mail.fr";
|
||||
String user_hash = "$2a$10$ZZNA5dPX/OpR327If/ShluJtJwm6tr7WLjp8CyWLsQQvJ0QUZlzkG";
|
||||
|
||||
User u = new User(email,user_hash);
|
||||
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
try{
|
||||
userImplementation.approveUser(u);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void getUserApproval(){
|
||||
BasicConfigurator.configure();
|
||||
String email = "sarah.huet@mail.fr";
|
||||
String user_hash = "$2a$10$ZZNA5dPX/OpR327If/ShluJtJwm6tr7WLjp8CyWLsQQvJ0QUZlzkG";
|
||||
|
||||
User u = new User(email,user_hash);
|
||||
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
try{
|
||||
logger.info(userImplementation.getUserApproval(email));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void RegisterUserWithoutPhone() { //OK
|
||||
BasicConfigurator.configure();
|
||||
User userTest = new User("TotoName","TotoFirstName","TotoEmail@gmail.com","totoPassword1234$","gonette");
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
|
||||
try{
|
||||
Map<String,String> response = userImplementation.registerUser(userTest);
|
||||
logger.info("response is: "+response.get("response"));
|
||||
if(Boolean.parseBoolean(response.get("response"))){
|
||||
logger.info("User hash: "+response.get("user_hash"));
|
||||
}
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RegisterUserWithPhone() { //OK
|
||||
BasicConfigurator.configure();
|
||||
User userTest = new User("TataName","TataFirstName","TataEmail@gmail.com","tataPassword1234$","0607080900","gonette");
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
|
||||
try{
|
||||
Map<String,String> responseTest = userImplementation.registerUser(userTest);
|
||||
logger.info("response is: "+responseTest.get("response"));
|
||||
if(Boolean.parseBoolean(responseTest.get("response"))){
|
||||
logger.info("User hash: "+responseTest.get("user_hash"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void approveUser1Test() { //ok
|
||||
BasicConfigurator.configure();
|
||||
User userTest = new User("TotoEmail@gmail.com","");
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
try {
|
||||
userImplementation.approveUser(userTest);
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void approveUser2Test() { //ok
|
||||
BasicConfigurator.configure();
|
||||
User userTest = new User("TataEmail@gmail.com","");
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
try {
|
||||
userImplementation.approveUser(userTest);
|
||||
}catch (Exception e){
|
||||
logger.warn("Error: "+e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void userLoggerTest(){ //OK
|
||||
BasicConfigurator.configure();
|
||||
User userTest = new User("TataName","TataFirstName","TataEmail@gmail.com","tataPassword1234$","0607080900","gonette");
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
try{
|
||||
Map<String,String> responseTest = userImplementation.userLogger(userTest);
|
||||
if(Boolean.parseBoolean(responseTest.get("response"))){
|
||||
logger.info("User hash: "+responseTest.get("user_hash"));
|
||||
}
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void deleteUserTest(){ //OK
|
||||
BasicConfigurator.configure();
|
||||
User userTest = new User("TotoEmail@gmail.com","$2a$10$AFlLoL3MpyILTmI4CAnVce8XYagrqkqQ9Be8pVAzadNDvexbBXZHm");
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
try{
|
||||
userImplementation.deleteUser(userTest);
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package restImplementation;
|
||||
|
||||
import database.Wallet.Wallet;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Ignore
|
||||
public class WalletImplementationTest {
|
||||
private static Logger logger = Logger.getLogger(WalletImplementationTest.class);
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void CreateWalletTest() { // OK
|
||||
BasicConfigurator.configure();
|
||||
Wallet wallet = new Wallet("client","$2a$10$tdkMwJ7BQSOXO2uofu/fEOlncUfuX7SsjB.2N9KVsXJUQiarAQzpG");
|
||||
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
Map<String,String> walletResponse = walletImplementation.createWallet(wallet);
|
||||
Wallet returnWallet = new Wallet();
|
||||
returnWallet.setWallet_hash(walletResponse.get("walletHash"));
|
||||
returnWallet.setBalance(Double.parseDouble(walletResponse.get("walletSold")));
|
||||
returnWallet.setType(walletResponse.get("walletType"));
|
||||
|
||||
logger.info("wallet hash: "+returnWallet.getWallet_hash());
|
||||
logger.info("wallet sold: "+returnWallet.getBalance());
|
||||
logger.info("wallet type: "+returnWallet.getType());
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@Test
|
||||
public void TestDeleteWallet() { //OK
|
||||
BasicConfigurator.configure();
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
walletImplementation.deleteWallet("$2a$10$xhnfRbiSLkgnmLuw8uTZVONV7GuNmdDsEGVgj/nFZFkWmwF8AVKd2","$2a$10$caS/2oNhOgbZSrZqM3X4A.ethKG/g3QDwBToTSdzYTGtIHIn9YJee");
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestGetWallet(){ //OK
|
||||
BasicConfigurator.configure();
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
Wallet wallet = walletImplementation.getWallet("$2a$10$WN6ARfShm9bgRZ8s9bzZqejvL.VzZrjXRmZLj6N3U6No9G/YLVqVi");
|
||||
logger.info("Wallet hash : "+wallet.getWallet_hash());
|
||||
logger.info("Wallet owner : "+wallet.getUser_hash());
|
||||
logger.info("Wallet type : "+wallet.getType());
|
||||
logger.info("Wallet balance : "+wallet.getBalance());
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestSetBalance(){ //OK
|
||||
BasicConfigurator.configure();
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
//walletImplementation.setBalanceToWallet("$2a$10$WN6ARfShm9bgRZ8s9bzZqejvL.VzZrjXRmZLj6N3U6No9G/YLVqVi",50.0);
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestTransferWalelt(){ //OK
|
||||
BasicConfigurator.configure();
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
walletImplementation.transferWallet("$2a$10$yagSqyq3hM1XR1qfmrFHe.vclXqj0ctl2MFkMtb0FPYCdah1wvVta","$2a$10$EBoYmkW7mdss58LtrNvcg.Igtkx/Vyncnw3o0MA99SJi32UXyKgwe");
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
@Test
|
||||
public void TestGetUserWallet(){ //OK
|
||||
BasicConfigurator.configure();
|
||||
WalletImplementation walletImplementation = new WalletImplementation();
|
||||
try{
|
||||
walletImplementation.getAllUserWallets("$2a$10$r7jlPdeESPFd1dKjvrEmB.SoxOXh3jHtWiPTAFKB3lGSgvda.zMyC");
|
||||
} catch (Exception e){
|
||||
logger.warn("Error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue