up
This commit is contained in:
parent
b74705ccfa
commit
b867d68e74
12
debian-service-file.txt
Normal file
12
debian-service-file.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=A Spring Boot application
|
||||
After=syslog.target
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
ExecStart=/home/projet/api/java-api-0.1.jar
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[(DANS : ) /etc/systemd/system]
|
|
@ -4,7 +4,7 @@ public class Config {
|
|||
|
||||
//ORGANIZATION
|
||||
public static final String ORG1_MSP = "Org1MSP";
|
||||
public static final String ORG1 = "Org1";
|
||||
public static final String ORG1 = "org1";
|
||||
|
||||
//ADMIN
|
||||
public static final String ADMIN = "admin";
|
||||
|
@ -16,12 +16,14 @@ public class Config {
|
|||
|
||||
|
||||
//CA
|
||||
public static final String CA_ORG1_URL = "http://vps577432.ovh.net:7054";
|
||||
public static final String CA_ORG1_URL = "http://localhost:7054";
|
||||
//public static final String CA_ORG1_URL = "http://vps577432.ovh.net:7054";
|
||||
//public static final String CA_ORG1_URL = "http://93.30.148.59:7054";
|
||||
//public static final String CA_ORG1_URL = "http://vps592802.ovh.net:7054";
|
||||
|
||||
//ORDERER
|
||||
public static final String ORDERER_URL = "grpc://vps577432.ovh.net:7050";
|
||||
public static final String ORDERER_URL = "grpc://localhost:7050";
|
||||
//public static final String ORDERER_URL = "grpc://vps577432.ovh.net:7050";
|
||||
//public static final String ORDERER_URL = "grpc://93.30.148.59:7050";
|
||||
//public static final String ORDERER_URL = "grpc://vps592802.ovh.net:7050";
|
||||
|
||||
|
@ -37,7 +39,8 @@ public class Config {
|
|||
//PEER 0
|
||||
public static final String ORG1_PEER_0 = "peer0.org1.example.com";
|
||||
|
||||
public static final String ORG1_PEER_0_URL = "grpc://vps577432.ovh.net:7051";
|
||||
public static final String ORG1_PEER_0_URL = "grpc://localhost:7051";
|
||||
//public static final String ORG1_PEER_0_URL = "grpc://vps577432.ovh.net:7051";
|
||||
//public static final String ORG1_PEER_0_URL = "grpc://93.30.148.59:7051";
|
||||
//ublic static final String ORG1_PEER_0_URL = "grpc://vps592802.ovh.net:7051";
|
||||
|
||||
|
@ -48,8 +51,8 @@ public class Config {
|
|||
|
||||
|
||||
//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";
|
||||
//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";
|
||||
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@ import java.time.Instant;
|
|||
//Class to communicate with database with ORMLite
|
||||
public class UserDao {
|
||||
private DatabaseHelper dbh = new DatabaseHelper();
|
||||
private Dao<User, String> userDao;
|
||||
|
||||
private Dao createUserDaoConnection(){
|
||||
try {
|
||||
return DaoManager.createDao(dbh.setupDatabaseConnection(),User.class);
|
||||
|
@ -24,11 +22,13 @@ public class UserDao {
|
|||
}
|
||||
|
||||
public void addUser(User user)throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
userDao.create(user);
|
||||
}
|
||||
|
||||
public boolean checkApprovedUser(String email) throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("email",email);
|
||||
|
@ -38,6 +38,7 @@ public class UserDao {
|
|||
}
|
||||
|
||||
public boolean checkVerifiedUser(String email) throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("email",email);
|
||||
|
@ -47,6 +48,7 @@ public class UserDao {
|
|||
}
|
||||
|
||||
public boolean updateUserPassword(String email, String password) throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
UpdateBuilder<User, String> updateBuilder = userDao.updateBuilder();
|
||||
updateBuilder.updateColumnValue("password",password);
|
||||
|
@ -63,6 +65,7 @@ public class UserDao {
|
|||
}
|
||||
|
||||
public void deleteUser(String email) throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
DeleteBuilder<User, String> deleteBuilder = userDao.deleteBuilder();
|
||||
deleteBuilder.where().eq("email",email);
|
||||
|
@ -70,6 +73,7 @@ public class UserDao {
|
|||
}
|
||||
|
||||
public boolean verifyUserExist(String email) throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("email",email);
|
||||
|
@ -93,6 +97,7 @@ public class UserDao {
|
|||
}
|
||||
|
||||
public User getUserWithEmail(String email) throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
if(!verifyUserExist(email)){
|
||||
return null;
|
||||
}else{
|
||||
|
@ -104,7 +109,26 @@ public class UserDao {
|
|||
}
|
||||
}
|
||||
|
||||
public User getUserWithPhone(String phone) throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("phone",phone);
|
||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
||||
return userDao.queryForFirst(preparedQuery);
|
||||
}
|
||||
|
||||
public User getUserWithMailAndPhone(String email, String phone) throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
QueryBuilder<User, String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("email",email).and().eq("phone",phone);
|
||||
PreparedQuery<User> preparedQuery = queryBuilder.prepare();
|
||||
return userDao.queryForFirst(preparedQuery);
|
||||
}
|
||||
|
||||
public User getUserWithHash(String userHash) throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
QueryBuilder<User,String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("user_hash",userHash);
|
||||
|
@ -113,6 +137,7 @@ public class UserDao {
|
|||
}
|
||||
|
||||
public int getUserIdWithHashAndEmail(String userHash, String userEmail) throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
QueryBuilder<User,String> queryBuilder = userDao.queryBuilder();
|
||||
queryBuilder.where().eq("user_hash",userHash).and().eq("email",userEmail);
|
||||
|
@ -121,8 +146,8 @@ public class UserDao {
|
|||
return userResponse.getUserId();
|
||||
}
|
||||
|
||||
|
||||
public void approveUser (String email) throws Exception {
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
UpdateBuilder<User, String> updateBuilder = userDao.updateBuilder();
|
||||
updateBuilder.updateColumnValue("approved",true);
|
||||
|
@ -133,6 +158,7 @@ public class UserDao {
|
|||
}
|
||||
|
||||
public void verifyUser (String email) throws Exception{
|
||||
Dao<User, String> userDao;
|
||||
userDao = createUserDaoConnection();
|
||||
UpdateBuilder<User, String> updateBuilder = userDao.updateBuilder();
|
||||
updateBuilder.updateColumnValue("verified",true);
|
||||
|
|
|
@ -4,6 +4,8 @@ import blockchain.query.TransactionWrapper;
|
|||
import database.user.User;
|
||||
import database.user.UserDao;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
|
||||
import javax.json.JsonArray;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -67,6 +69,20 @@ public class UserImplementation {
|
|||
return userDao.verifyUserExist(email);
|
||||
}
|
||||
|
||||
public User getUserWithEmail(String email) throws Exception{
|
||||
UserDao userDao = new UserDao();
|
||||
return userDao.getUserWithEmail(email);
|
||||
|
||||
}
|
||||
public User getUserWithPhone(String phone) throws Exception{
|
||||
UserDao userDao = new UserDao();
|
||||
return userDao.getUserWithPhone(phone);
|
||||
}
|
||||
public User getUserWithMailAndPhone(String email, String phone) throws Exception{
|
||||
UserDao userDao = new UserDao();
|
||||
return userDao.getUserWithMailAndPhone(email,phone);
|
||||
}
|
||||
|
||||
public int getUserId(String user_hash, String user_email) throws Exception{
|
||||
UserDao userDao = new UserDao();
|
||||
return userDao.getUserIdWithHashAndEmail(user_hash,user_email);
|
||||
|
|
|
@ -122,4 +122,44 @@ public class UserResource {
|
|||
public ResponseEntity updateUser(@RequestBody User user){
|
||||
return new ResponseEntity(null, HttpStatus.SERVICE_UNAVAILABLE);
|
||||
}
|
||||
|
||||
|
||||
@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);
|
||||
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 = "/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);
|
||||
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 = "/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);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||
}catch (Exception e){
|
||||
String r = "{\"response\":\""+e.getMessage()+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue