├── RequirementDoc_AccountingSystem.docx ├── BankData ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── common │ │ │ │ └── BankData │ │ │ │ ├── dao │ │ │ │ ├── OtherBankAccountDao.java │ │ │ │ ├── XConfiguration.java │ │ │ │ ├── AdminDao.java │ │ │ │ ├── AccountDao.java │ │ │ │ ├── TransferDao.java │ │ │ │ ├── CustomerDao.java │ │ │ │ └── ScheduleDao.java │ │ │ │ ├── entity │ │ │ │ ├── security │ │ │ │ │ ├── Authority.java │ │ │ │ │ ├── Role.java │ │ │ │ │ └── AdminRole.java │ │ │ │ ├── ScheduleList.java │ │ │ │ ├── CustomCustomerDetails.java │ │ │ │ ├── CustomAdminDetails.java │ │ │ │ ├── Proof.java │ │ │ │ ├── Schedule.java │ │ │ │ ├── Admin.java │ │ │ │ ├── Customer.java │ │ │ │ ├── OtherAccount.java │ │ │ │ ├── PrimaryTransaction.java │ │ │ │ └── Account.java │ │ │ │ ├── service │ │ │ │ ├── AdminService.java │ │ │ │ ├── UserSecurityService.java │ │ │ │ ├── AuthenticationProvider.java │ │ │ │ ├── SmsService.java │ │ │ │ └── TransferService.java │ │ │ │ └── BankDataApplication.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── common │ │ └── BankData │ │ └── BankDataApplicationTests.java ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── OnlineBanking ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── banking │ │ │ │ └── OnlineBanking │ │ │ │ ├── OnlineBankingApplication.java │ │ │ │ ├── controller │ │ │ │ ├── CustomerController.java │ │ │ │ ├── TransferController.java │ │ │ │ └── CustomerLoginControlller.java │ │ │ │ └── config │ │ │ │ ├── AuthenticationFilter.java │ │ │ │ ├── RequestFilter.java │ │ │ │ └── SecurityConfig.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── liquibase.properties │ └── test │ │ └── java │ │ └── com │ │ └── banking │ │ └── OnlineBanking │ │ ├── TestUtils.java │ │ └── controller │ │ ├── CustomerLoginControlllerTest.java │ │ └── TransferControllerTest.java ├── pom.xml └── mvnw.cmd ├── BackOfficeSystem ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── banking │ │ │ └── BackOfficeSystem │ │ │ └── BackOfficeSystemApplicationTests.java │ └── main │ │ ├── java │ │ └── com │ │ │ └── banking │ │ │ └── BackOfficeSystem │ │ │ ├── BackOfficeSystemApplication.java │ │ │ ├── service │ │ │ ├── UserSecurityService.java │ │ │ └── AuthenticationProvider.java │ │ │ ├── config │ │ │ ├── AuthenticationFilter.java │ │ │ ├── RequestFilter.java │ │ │ └── SecurityConfig.java │ │ │ └── controller │ │ │ ├── AdminLoginController.java │ │ │ └── AccountController.java │ │ └── resources │ │ └── application.properties ├── .gitignore ├── pom.xml └── mvnw.cmd ├── TransactionScheduling1 ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── batch │ │ │ └── TransactionScheduling │ │ │ └── TransactionSchedulingApplicationTests.java │ └── main │ │ ├── java │ │ └── com │ │ │ └── batch │ │ │ └── TransactionScheduling │ │ │ ├── config │ │ │ ├── UserItemProcessor.java │ │ │ ├── DBConfig.java │ │ │ ├── DBWriter.java │ │ │ └── BatchConfiguration.java │ │ │ ├── TransactionSchedulingApplication.java │ │ │ ├── service │ │ │ └── CronService.java │ │ │ └── Controller │ │ │ └── SchedulerController.java │ │ └── resources │ │ └── application.properties ├── .gitignore ├── pom.xml └── mvnw.cmd └── README.md /RequirementDoc_AccountingSystem.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabh-sudo/BankingSystem-Backend/HEAD/RequirementDoc_AccountingSystem.docx -------------------------------------------------------------------------------- /BankData/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabh-sudo/BankingSystem-Backend/HEAD/BankData/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /OnlineBanking/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabh-sudo/BankingSystem-Backend/HEAD/OnlineBanking/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /BackOfficeSystem/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabh-sudo/BankingSystem-Backend/HEAD/BackOfficeSystem/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /TransactionScheduling1/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saurabh-sudo/BankingSystem-Backend/HEAD/TransactionScheduling1/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /BankData/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /OnlineBanking/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /BackOfficeSystem/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /TransactionScheduling1/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/dao/OtherBankAccountDao.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.dao; 2 | 3 | import com.common.BankData.entity.OtherAccount; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface OtherBankAccountDao extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/dao/XConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.dao; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @ComponentScan 8 | public class XConfiguration { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /BankData/src/test/java/com/common/BankData/BankDataApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class BankDataApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /BackOfficeSystem/src/test/java/com/banking/BackOfficeSystem/BackOfficeSystemApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.banking.BackOfficeSystem; 2 | 3 | //import org.junit.jupiter.api.Test; 4 | //import org.springframework.boot.test.context.SpringBootTest; 5 | // 6 | //@SpringBootTest 7 | //class BackOfficeSystemApplicationTests { 8 | // 9 | // @Test 10 | // void contextLoads() { 11 | // } 12 | // 13 | //} 14 | -------------------------------------------------------------------------------- /TransactionScheduling1/src/test/java/com/batch/TransactionScheduling/TransactionSchedulingApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.batch.TransactionScheduling; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class TransactionSchedulingApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /BankData/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /TransactionScheduling1/src/main/java/com/batch/TransactionScheduling/config/UserItemProcessor.java: -------------------------------------------------------------------------------- 1 | package com.batch.TransactionScheduling.config; 2 | 3 | 4 | 5 | import com.common.BankData.entity.Schedule; 6 | import org.springframework.batch.item.ItemProcessor; 7 | 8 | 9 | public class UserItemProcessor implements ItemProcessor { 10 | 11 | @Override 12 | public Schedule process(Schedule user) throws Exception { 13 | return user; 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /OnlineBanking/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /BackOfficeSystem/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/dao/AdminDao.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.dao; 2 | 3 | 4 | import com.common.BankData.entity.Admin; 5 | import org.springframework.data.repository.CrudRepository; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.stereotype.Repository; 8 | 9 | @Repository 10 | public interface AdminDao extends CrudRepository { 11 | Admin findByUserName(String username); 12 | Admin findByToken(String token); 13 | } 14 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/security/Authority.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity.security; 2 | 3 | import org.springframework.security.core.GrantedAuthority; 4 | 5 | public class Authority implements GrantedAuthority { 6 | 7 | private final String authority; 8 | 9 | public Authority(String authority) { 10 | this.authority = authority; 11 | } 12 | 13 | @Override 14 | public String getAuthority() { 15 | return authority; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /TransactionScheduling1/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/service/AdminService.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.service; 2 | 3 | import com.common.BankData.dao.AdminDao; 4 | import com.common.BankData.entity.Admin; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service("AdminService") 9 | public class AdminService { 10 | 11 | @Autowired 12 | AdminDao adminDao; 13 | 14 | public Admin findByToken(String token) { 15 | Admin admin= adminDao.findByToken(token); 16 | return admin; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /BackOfficeSystem/src/main/java/com/banking/BackOfficeSystem/BackOfficeSystemApplication.java: -------------------------------------------------------------------------------- 1 | package com.banking.BackOfficeSystem; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.domain.EntityScan; 6 | 7 | @SpringBootApplication 8 | @EntityScan("com.common.BankData") 9 | public class BackOfficeSystemApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(BackOfficeSystemApplication.class, args); 13 | System.out.println("BackOffice Application Started"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/dao/AccountDao.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.dao; 2 | 3 | 4 | import com.common.BankData.entity.Account; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.stereotype.Repository; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import java.util.List; 11 | 12 | @Repository 13 | @Transactional 14 | public interface AccountDao extends JpaRepository { 15 | List findByAccountStatus(Integer status); 16 | 17 | Account findByAccountId(long number); 18 | 19 | 20 | 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/dao/TransferDao.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.dao; 2 | 3 | import com.common.BankData.entity.PrimaryTransaction; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.Set; 8 | 9 | @Repository 10 | public interface TransferDao extends JpaRepository { 11 | // List findByAccountId(long accountId); 12 | Set findByAccountId(long accountId); 13 | Set findByRecipientAccountNo(long accountId); 14 | // List findByRecipientAccountNo(long accountId); 15 | } 16 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/BankDataApplication.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.transaction.annotation.EnableTransactionManagement; 8 | 9 | @SpringBootApplication 10 | @Configuration 11 | @ComponentScan 12 | @EnableTransactionManagement 13 | public class BankDataApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(BankDataApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/dao/CustomerDao.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.dao; 2 | 3 | 4 | import com.common.BankData.entity.Customer; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public interface CustomerDao extends JpaRepository { 11 | Customer findByUserNameContainingIgnoreCase(String username); 12 | Customer findByUserId(long userId); 13 | Customer findByToken(String token); 14 | 15 | @Query(value = "SELECT nextval('username')", nativeQuery = 16 | true) 17 | Long getNextCustomerId(); 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /BackOfficeSystem/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | spring.datasource.driver-class-name=org.postgresql.Driver 3 | spring.datasource.url=jdbc:postgresql://localhost:5432/HdfcBank1 4 | spring.datasource.username=postgres 5 | spring.datasource.password=root 6 | #spring.datasource.schema = dev 7 | spring.jpa.hibernate.ddl-auto=update 8 | spring.jpa.hibernate.show-sql=true 9 | spring.jpa.properties.hibernate.format_sql=true 10 | spring.jpa.show-sql=true 11 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect 12 | spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy 13 | spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl 14 | spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl 15 | -------------------------------------------------------------------------------- /BankData/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=org.postgresql.Driver 2 | spring.datasource.url=jdbc:postgresql://localhost:5432/HdfcBank1 3 | spring.datasource.username=postgres 4 | spring.datasource.password=root 5 | #spring.datasource.schema = dev 6 | spring.jpa.hibernate.ddl-auto=update 7 | spring.jpa.hibernate.show-sql=true 8 | spring.jpa.properties.hibernate.format_sql=true 9 | spring.jpa.show-sql=true 10 | #server.port=8081 11 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL9Dialect 12 | spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy 13 | spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl 14 | spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl 15 | 16 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/ScheduleList.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity; 2 | 3 | 4 | import javax.persistence.Column; 5 | import javax.persistence.Entity; 6 | import javax.persistence.Id; 7 | import javax.persistence.OneToMany; 8 | import java.util.List; 9 | import java.util.Set; 10 | 11 | //@Entity 12 | public class ScheduleList { 13 | // @Id 14 | private int id; 15 | 16 | 17 | 18 | 19 | public int getId() { 20 | return id; 21 | } 22 | 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | 27 | // @Column(name = "schedule") 28 | // @OneToMany 29 | List schedule; 30 | 31 | public List getSchedule() { 32 | return schedule; 33 | } 34 | 35 | public void setSchedule(List schedule) { 36 | this.schedule = schedule; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /OnlineBanking/src/main/java/com/banking/OnlineBanking/OnlineBankingApplication.java: -------------------------------------------------------------------------------- 1 | package com.banking.OnlineBanking; 2 | 3 | import com.common.BankData.BankDataApplication; 4 | import com.common.BankData.dao.XConfiguration; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.boot.autoconfigure.domain.EntityScan; 8 | import org.springframework.context.annotation.Import; 9 | import org.springframework.scheduling.annotation.EnableScheduling; 10 | 11 | @SpringBootApplication 12 | @EntityScan("com.common.BankData") 13 | @EnableScheduling 14 | @Import({XConfiguration.class, BankDataApplication.class}) 15 | public class OnlineBankingApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(OnlineBankingApplication.class, args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/security/Role.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity.security; 2 | 3 | import javax.persistence.*; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | 7 | @Entity 8 | public class Role { 9 | 10 | @Id 11 | @GeneratedValue(strategy = GenerationType.IDENTITY) 12 | private long roleId; 13 | 14 | private String RoleName; 15 | 16 | 17 | public Role() { 18 | 19 | } 20 | 21 | 22 | // @OneToMany(mappedBy = "role", cascade = CascadeType.ALL, fetch = FetchType.LAZY) 23 | // private Set userRoles = new HashSet<>(); 24 | 25 | public long getRoleId() { 26 | return roleId; 27 | } 28 | 29 | public void setRoleId(long roleId) { 30 | this.roleId = roleId; 31 | } 32 | 33 | public String getRoleName() { 34 | return RoleName; 35 | } 36 | 37 | public void setRoleName(String roleName) { 38 | RoleName = roleName; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /OnlineBanking/src/test/java/com/banking/OnlineBanking/TestUtils.java: -------------------------------------------------------------------------------- 1 | package com.banking.OnlineBanking; 2 | 3 | import com.google.gson.Gson; 4 | 5 | import com.google.gson.GsonBuilder; 6 | import com.google.gson.reflect.TypeToken; 7 | 8 | import java.sql.Date; 9 | import java.util.List; 10 | 11 | /** 12 | * 13 | * @author bytesTree 14 | * @see BytesTree 15 | * 16 | */ 17 | public class TestUtils { 18 | 19 | @SuppressWarnings("rawtypes") 20 | public static List jsonToList(String json, TypeToken token) { 21 | Gson gson = new Gson(); 22 | return gson.fromJson(json, token.getType()); 23 | } 24 | 25 | public static String objectToJson(Object obj) { 26 | Gson gson = new Gson(); 27 | return gson.toJson(obj); 28 | } 29 | 30 | public static T jsonToObject(String json, Class classOf) { 31 | Gson gson= new GsonBuilder().setDateFormat("yyyy-MM-dd").create(); 32 | 33 | return gson.fromJson(json, classOf); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /OnlineBanking/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=org.postgresql.Driver 2 | spring.liquibase.enabled=false 3 | #liquibase.change-log=classpath:db/liquibase-changelog.xml 4 | spring.liquibase.change-log=classpath:db/changelog/sample.changeLog.xml 5 | #liquibase.change-log=classpath:db/changelog/sample.changelog.xml 6 | server.port=8081 7 | spring.datasource.url=jdbc:postgresql://localhost:5432/HdfcBank1 8 | spring.datasource.username=postgres 9 | spring.datasource.password=root 10 | #spring.datasource.schema = dev 11 | spring.jpa.hibernate.ddl-auto=none 12 | spring.jpa.hibernate.show-sql=true 13 | spring.jpa.properties.hibernate.format_sql=true 14 | spring.jpa.show-sql=true 15 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL9Dialect 16 | spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy 17 | spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl 18 | spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl 19 | -------------------------------------------------------------------------------- /OnlineBanking/src/main/java/com/banking/OnlineBanking/controller/CustomerController.java: -------------------------------------------------------------------------------- 1 | package com.banking.OnlineBanking.controller; 2 | 3 | 4 | import com.common.BankData.dao.AccountDao; 5 | import com.common.BankData.dao.ScheduleDao; 6 | import com.common.BankData.entity.PrimaryTransaction; 7 | import com.common.BankData.entity.Schedule; 8 | import com.common.BankData.entity.ScheduleList; 9 | 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | @RestController 17 | @RequestMapping("/customers") 18 | public class CustomerController { 19 | 20 | 21 | @Autowired 22 | ScheduleDao scheduleDao; 23 | 24 | @PostMapping("/scheduleTransaction") 25 | public void scheduleJob(@RequestBody ScheduleList scheduleList) 26 | { 27 | for (Schedule schedule: scheduleList.getSchedule()) { 28 | schedule.setStatus("scheduled"); 29 | 30 | scheduleDao.save(schedule); 31 | } 32 | } 33 | 34 | 35 | 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /TransactionScheduling1/src/main/java/com/batch/TransactionScheduling/TransactionSchedulingApplication.java: -------------------------------------------------------------------------------- 1 | package com.batch.TransactionScheduling; 2 | 3 | import com.common.BankData.BankDataApplication; 4 | import com.common.BankData.dao.XConfiguration; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.boot.autoconfigure.domain.EntityScan; 8 | import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; 9 | import org.springframework.context.annotation.ComponentScan; 10 | import org.springframework.context.annotation.Import; 11 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 12 | import org.springframework.scheduling.annotation.EnableScheduling; 13 | 14 | @SpringBootApplication(exclude = {SecurityAutoConfiguration.class}) 15 | @Import({XConfiguration.class, BankDataApplication.class}) 16 | @EnableScheduling 17 | public class TransactionSchedulingApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(TransactionSchedulingApplication.class, args); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /TransactionScheduling1/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8082 2 | #security.basic.enable: false 3 | #security.ignored=/** 4 | 5 | hibernate.temp.use_jdbc_metadata_defaults=false 6 | spring.batch.initialize-schema=never 7 | spring.datasource.driver-class-name=org.postgresql.Driver 8 | spring.batch.job.enabled=false 9 | spring.datasource.url=jdbc:postgresql://localhost:5432/HdfcBank1 10 | spring.datasource.username=postgres 11 | spring.datasource.password=root 12 | #spring.datasource.schema = dev 13 | spring.jpa.hibernate.ddl-auto=update 14 | spring.jpa.hibernate.show-sql=true 15 | spring.jpa.properties.hibernate.format_sql=true 16 | spring.jpa.show-sql=true 17 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL9Dialect 18 | spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy 19 | spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl 20 | spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl 21 | logging.level.org.hibernate.SQL=DEBUG 22 | logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/dao/ScheduleDao.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.dao; 2 | 3 | import com.common.BankData.entity.Schedule; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Modifying; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.data.repository.CrudRepository; 8 | import org.springframework.stereotype.Repository; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | @Repository 12 | @Transactional 13 | public interface ScheduleDao extends JpaRepository { 14 | 15 | 16 | // @Modifying 17 | // @Transactional 18 | // @Query(value="delete from schedule c where c.scheduleid = ?1") 19 | // void deleteBySchedule_id(int schedule_id); 20 | 21 | // @Modifying 22 | // @Transactional 23 | @Modifying 24 | @Transactional 25 | @Query(value="delete from schedule c where c.scheduleid = ?1") 26 | int removeByScheduleid(int scheduledid); 27 | 28 | // @Override 29 | // void deleteById(Integer integer){ 30 | // 31 | // } @Override 32 | //// void deleteById(Integer integer){ 33 | //// 34 | //// } 35 | } 36 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/security/AdminRole.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity.security; 2 | 3 | 4 | 5 | import javax.persistence.*; 6 | 7 | // 8 | ////@Entity 9 | ////@Table 10 | //public class AdminRole { 11 | // // @Id 12 | // @GeneratedValue(strategy = GenerationType.AUTO) 13 | // private long adminRoleId; 14 | // 15 | // public AdminRole(Admin user, Role role) { 16 | // this.admin = user; 17 | // this.role = role; 18 | // } 19 | // 20 | // 21 | // @ManyToOne(fetch = FetchType.EAGER) 22 | // @JoinColumn(name = "admin_id") 23 | // private Admin admin; 24 | // 25 | // 26 | // @ManyToOne(fetch = FetchType.EAGER) 27 | // @JoinColumn(name = "role_id") 28 | // private Role role; 29 | // 30 | // public long getAdminRoleId() { 31 | // return adminRoleId; 32 | // } 33 | // 34 | // public void setAdminRoleId(long adminRoleId) { 35 | // this.adminRoleId = adminRoleId; 36 | // } 37 | // 38 | // public Admin getAdmin() { 39 | // return admin; 40 | // } 41 | // 42 | // public void setAdmin(Admin admin) { 43 | // this.admin = admin; 44 | // } 45 | // 46 | // public Role getRole() { 47 | // return role; 48 | // } 49 | // 50 | // public void setRole(Role role) { 51 | // this.role = role; 52 | // } 53 | //} 54 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/service/UserSecurityService.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.service; 2 | 3 | 4 | import com.common.BankData.dao.CustomerDao; 5 | import com.common.BankData.entity.CustomCustomerDetails; 6 | import com.common.BankData.entity.Customer; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.security.core.userdetails.UserDetails; 11 | import org.springframework.security.core.userdetails.UserDetailsService; 12 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 13 | import org.springframework.stereotype.Service; 14 | 15 | @Service 16 | public class UserSecurityService implements UserDetailsService { 17 | 18 | /** The application logger */ 19 | private static final Logger LOG = LoggerFactory.getLogger(UserSecurityService.class); 20 | 21 | @Autowired 22 | private CustomerDao customerDao; 23 | 24 | @Override 25 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 26 | Customer user = customerDao.findByUserNameContainingIgnoreCase(username); 27 | if (user == null) { 28 | LOG.warn("Username {} not found", username); 29 | throw new UsernameNotFoundException("Username " + username + " not found"); 30 | } 31 | return new CustomCustomerDetails(user); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /BackOfficeSystem/src/main/java/com/banking/BackOfficeSystem/service/UserSecurityService.java: -------------------------------------------------------------------------------- 1 | package com.banking.BackOfficeSystem.service; 2 | 3 | import com.common.BankData.dao.AdminDao; 4 | import com.common.BankData.entity.Admin; 5 | import com.common.BankData.entity.CustomAdminDetails; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.security.core.userdetails.UserDetails; 10 | import org.springframework.security.core.userdetails.UserDetailsService; 11 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 12 | import org.springframework.stereotype.Service; 13 | 14 | @Service 15 | public class UserSecurityService implements UserDetailsService { 16 | 17 | /** 18 | * The application logger 19 | */ 20 | private static final Logger LOG = LoggerFactory.getLogger(UserSecurityService.class); 21 | 22 | @Autowired 23 | private AdminDao adminDao; 24 | 25 | @Override 26 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 27 | Admin user = adminDao.findByUserName(username); 28 | if (user == null) { 29 | LOG.warn("Username {} not found", username); 30 | throw new UsernameNotFoundException("Username " + username + " not found"); 31 | } 32 | return new CustomAdminDetails(user); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /TransactionScheduling1/src/main/java/com/batch/TransactionScheduling/config/DBConfig.java: -------------------------------------------------------------------------------- 1 | package com.batch.TransactionScheduling.config; 2 | 3 | 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Primary; 7 | import org.springframework.core.annotation.Order; 8 | import org.springframework.core.env.Environment; 9 | import org.springframework.jdbc.datasource.DriverManagerDataSource; 10 | import org.springframework.orm.jpa.JpaTransactionManager; 11 | import org.springframework.stereotype.Service; 12 | 13 | import javax.sql.DataSource; 14 | 15 | @Service 16 | public class DBConfig { 17 | 18 | @Autowired 19 | Environment environment; 20 | 21 | 22 | @Bean 23 | @Primary 24 | @Order(1) 25 | public DataSource datasource() { 26 | final DriverManagerDataSource dataSource = new DriverManagerDataSource(); 27 | dataSource.setDriverClassName(environment.getProperty("spring.datasource.driver-class-name")); 28 | dataSource.setUrl(environment.getProperty("spring.datasource.url")); 29 | dataSource.setUsername(environment.getProperty("spring.datasource.username")); 30 | dataSource.setPassword(environment.getProperty("spring.datasource.password")); 31 | return dataSource; 32 | } 33 | 34 | 35 | @Bean 36 | @Primary 37 | public JpaTransactionManager jpaTransactionManager() { 38 | final JpaTransactionManager transactionManager = new JpaTransactionManager(); 39 | transactionManager.setDataSource(datasource()); 40 | return transactionManager; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /BackOfficeSystem/src/main/java/com/banking/BackOfficeSystem/service/AuthenticationProvider.java: -------------------------------------------------------------------------------- 1 | package com.banking.BackOfficeSystem.service; 2 | 3 | import com.common.BankData.dao.AdminDao; 4 | import com.common.BankData.entity.Admin; 5 | import com.common.BankData.entity.CustomAdminDetails; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 8 | import org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider; 9 | import org.springframework.security.core.AuthenticationException; 10 | import org.springframework.security.core.userdetails.UserDetails; 11 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 12 | import org.springframework.stereotype.Component; 13 | 14 | @Component 15 | public class AuthenticationProvider extends AbstractUserDetailsAuthenticationProvider { 16 | 17 | @Autowired 18 | AdminDao adminDao; 19 | 20 | @Override 21 | protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken) throws AuthenticationException { 22 | 23 | } 24 | 25 | @Override 26 | protected UserDetails retrieveUser(String userName, UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken) { 27 | Object token = usernamePasswordAuthenticationToken.getCredentials(); 28 | Admin ud = adminDao.findByToken(token.toString()); 29 | if (ud == null) { 30 | throw new UsernameNotFoundException("Cannot find user with authentication token=" + token); 31 | } 32 | return new CustomAdminDetails(ud); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /TransactionScheduling1/src/main/java/com/batch/TransactionScheduling/service/CronService.java: -------------------------------------------------------------------------------- 1 | package com.batch.TransactionScheduling.service; 2 | 3 | 4 | import org.springframework.batch.core.*; 5 | import org.springframework.batch.core.launch.JobLauncher; 6 | import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; 7 | import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; 8 | import org.springframework.batch.core.repository.JobRestartException; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.scheduling.annotation.Scheduled; 11 | import org.springframework.stereotype.Service; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | 14 | import java.util.Date; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | @Service 20 | public class CronService { 21 | 22 | @Autowired 23 | private JobLauncher jobLauncher; 24 | 25 | @Autowired 26 | Job loadJob; 27 | 28 | @Scheduled(fixedRate = 60000) 29 | public BatchStatus load() throws JobParametersInvalidException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException { 30 | 31 | 32 | Map maps = new HashMap<>(); 33 | maps.put("time", new JobParameter(System.currentTimeMillis())); 34 | JobParameters parameters = new JobParameters(maps); 35 | JobExecution jobExecution = jobLauncher.run(loadJob, parameters); 36 | 37 | 38 | System.out.println("Batch is Running..."); 39 | while (jobExecution.isRunning()) { 40 | } 41 | 42 | return jobExecution.getStatus(); 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/CustomCustomerDetails.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity; 2 | 3 | 4 | import org.springframework.security.core.GrantedAuthority; 5 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 6 | import org.springframework.security.core.userdetails.UserDetails; 7 | 8 | import java.util.Collection; 9 | import java.util.stream.Collectors; 10 | 11 | public class CustomCustomerDetails extends Customer implements UserDetails { 12 | 13 | public CustomCustomerDetails(final Customer customers) 14 | { 15 | super(customers); 16 | } 17 | 18 | @Override 19 | public Collection getAuthorities() { 20 | 21 | System.out.println("getAuthorities"); 22 | // 23 | //return getAdminRole() 24 | // .stream() 25 | // .map(role -> new SimpleGrantedAuthority("ROLE_" + role.getRoleName())) 26 | // .collect(Collectors.toList()); 27 | 28 | // Set authorities = new HashSet<>(); 29 | // adminRole.forEach(ur -> authorities.add(new SimpleGrantedAuthority("ROLE_"+ur.getRoleName()))); 30 | // return authorities; 31 | // return null; 32 | return null; 33 | } 34 | 35 | @Override 36 | public String getPassword() { 37 | return getPassword(); 38 | } 39 | 40 | @Override 41 | public String getUsername() { 42 | return getUserName(); 43 | } 44 | 45 | @Override 46 | public boolean isAccountNonExpired() { 47 | return true; 48 | } 49 | 50 | @Override 51 | public boolean isAccountNonLocked() { 52 | return true; 53 | } 54 | 55 | @Override 56 | public boolean isCredentialsNonExpired() { 57 | return true; 58 | } 59 | 60 | @Override 61 | public boolean isEnabled() { 62 | return true; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/CustomAdminDetails.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity; 2 | 3 | 4 | import org.springframework.security.core.GrantedAuthority; 5 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 6 | import org.springframework.security.core.userdetails.UserDetails; 7 | 8 | import java.util.Collection; 9 | import java.util.HashSet; 10 | import java.util.Set; 11 | import java.util.stream.Collectors; 12 | 13 | public class CustomAdminDetails extends Admin implements UserDetails { 14 | 15 | public CustomAdminDetails(final Admin admins) 16 | { 17 | super(admins); 18 | } 19 | 20 | @Override 21 | public Collection getAuthorities() { 22 | 23 | System.out.println("getAuthorities"); 24 | 25 | return getAdminRole() 26 | .stream() 27 | .map(role -> new SimpleGrantedAuthority("ROLE_" + role.getRoleName())) 28 | .collect(Collectors.toList()); 29 | 30 | // Set authorities = new HashSet<>(); 31 | // adminRole.forEach(ur -> authorities.add(new SimpleGrantedAuthority("ROLE_"+ur.getRoleName()))); 32 | // return authorities; 33 | // return null; 34 | } 35 | 36 | @Override 37 | public String getPassword() { 38 | return getPasswordHash(); 39 | } 40 | 41 | @Override 42 | public String getUsername() { 43 | return getUserName(); 44 | } 45 | 46 | @Override 47 | public boolean isAccountNonExpired() { 48 | return true; 49 | } 50 | 51 | @Override 52 | public boolean isAccountNonLocked() { 53 | return true; 54 | } 55 | 56 | @Override 57 | public boolean isCredentialsNonExpired() { 58 | return true; 59 | } 60 | 61 | @Override 62 | public boolean isEnabled() { 63 | return true; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/service/AuthenticationProvider.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.service; 2 | 3 | 4 | 5 | import com.common.BankData.dao.CustomerDao; 6 | import com.common.BankData.entity.CustomCustomerDetails; 7 | import com.common.BankData.entity.Customer; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 10 | import org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider; 11 | import org.springframework.security.core.AuthenticationException; 12 | import org.springframework.security.core.userdetails.UserDetails; 13 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 14 | import org.springframework.stereotype.Component; 15 | 16 | @Component 17 | public class AuthenticationProvider extends AbstractUserDetailsAuthenticationProvider { 18 | 19 | @Autowired 20 | CustomerDao customerDao; 21 | 22 | @Override 23 | protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken) throws AuthenticationException { 24 | // 25 | } 26 | 27 | @Override 28 | protected UserDetails retrieveUser(String userName, UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken) { 29 | Object token = usernamePasswordAuthenticationToken.getCredentials(); 30 | Customer ud= customerDao.findByToken(token.toString()); 31 | if(ud==null) 32 | { 33 | throw new UsernameNotFoundException("Cannot find user with authentication token=" + token); 34 | } 35 | return new CustomCustomerDetails(ud); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /TransactionScheduling1/src/main/java/com/batch/TransactionScheduling/Controller/SchedulerController.java: -------------------------------------------------------------------------------- 1 | package com.batch.TransactionScheduling.Controller; 2 | 3 | import org.springframework.batch.core.*; 4 | import org.springframework.batch.core.launch.JobLauncher; 5 | import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; 6 | import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; 7 | import org.springframework.batch.core.repository.JobRestartException; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.scheduling.annotation.Scheduled; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | 17 | @RestController 18 | @RequestMapping("/schedule") 19 | public class SchedulerController { 20 | 21 | @Autowired 22 | private JobLauncher jobLauncher; 23 | 24 | @Autowired 25 | Job loadJob; 26 | 27 | @GetMapping("sf") 28 | public String sf() 29 | { 30 | return "helo"; 31 | } 32 | 33 | /* @Autowired 34 | Job exportUserJob ;*/ 35 | 36 | // @Scheduled(fixedRate = 20000) 37 | @GetMapping("/hello") 38 | public BatchStatus load() throws JobParametersInvalidException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException { 39 | 40 | 41 | Map maps = new HashMap<>(); 42 | maps.put("time", new JobParameter(System.currentTimeMillis())); 43 | JobParameters parameters = new JobParameters(maps); 44 | JobExecution jobExecution = jobLauncher.run(loadJob, parameters); 45 | 46 | 47 | 48 | System.out.println("Batch is Running..."); 49 | while (jobExecution.isRunning()) { 50 | } 51 | 52 | return jobExecution.getStatus(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/Proof.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonBackReference; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | import net.bytebuddy.dynamic.loading.InjectionClassLoader; 7 | 8 | import javax.persistence.*; 9 | import java.sql.Date; 10 | 11 | 12 | @Entity 13 | //@JsonIgnoreProperties(ignoreUnknown = true) 14 | public class Proof 15 | { 16 | 17 | @Id 18 | @GeneratedValue(strategy = GenerationType.AUTO) 19 | private int proofId; 20 | private long uuid; 21 | private String passportNumber; 22 | private String emailId; 23 | private Date dob; 24 | 25 | 26 | @OneToOne(mappedBy = "proof") 27 | @JsonBackReference 28 | private Account acc; 29 | 30 | public Account getAcc() { 31 | return acc; 32 | } 33 | 34 | public void setAcc(Account acc) { 35 | this.acc = acc; 36 | } 37 | 38 | private int age; 39 | 40 | public int getProofId() { 41 | return proofId; 42 | } 43 | 44 | public void setProofId(int proofId) { 45 | this.proofId = proofId; 46 | } 47 | 48 | public long getUuid() { 49 | return uuid; 50 | } 51 | 52 | public void setUuid(long uuid) { 53 | this.uuid = uuid; 54 | } 55 | 56 | public String getPassportNumber() { 57 | return passportNumber; 58 | } 59 | 60 | public void setPassportNumber(String passportNumber) { 61 | this.passportNumber = passportNumber; 62 | } 63 | 64 | public String getEmailId() { 65 | return emailId; 66 | } 67 | 68 | public void setEmailId(String emailId) { 69 | this.emailId = emailId; 70 | } 71 | 72 | public Date getDob() { 73 | return dob; 74 | } 75 | 76 | public void setDob(Date dob) { 77 | this.dob = dob; 78 | } 79 | 80 | public int getAge() { 81 | return age; 82 | } 83 | 84 | public void setAge(int age) { 85 | this.age = age; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /TransactionScheduling1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | com.batch 12 | TransactionScheduling 13 | 0.0.1-SNAPSHOT 14 | TransactionScheduling 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-batch 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-data-jpa 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | org.junit.vintage 42 | junit-vintage-engine 43 | 44 | 45 | 46 | 47 | org.springframework.batch 48 | spring-batch-test 49 | test 50 | 51 | 52 | com.common 53 | 0.0.1-SNAPSHOT 54 | BankData 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-maven-plugin 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /OnlineBanking/src/main/java/com/banking/OnlineBanking/config/AuthenticationFilter.java: -------------------------------------------------------------------------------- 1 | package com.banking.OnlineBanking.config; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 5 | import org.springframework.security.core.Authentication; 6 | import org.springframework.security.core.AuthenticationException; 7 | import org.springframework.security.core.context.SecurityContextHolder; 8 | import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; 9 | import org.springframework.security.web.util.matcher.RequestMatcher; 10 | 11 | import javax.servlet.FilterChain; 12 | import javax.servlet.ServletException; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import java.io.IOException; 16 | import java.util.Optional; 17 | 18 | public class AuthenticationFilter extends AbstractAuthenticationProcessingFilter { 19 | 20 | AuthenticationFilter(final RequestMatcher requiresAuth) { 21 | super(requiresAuth); 22 | } 23 | 24 | @Override 25 | public Authentication attemptAuthentication(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws AuthenticationException, IOException, ServletException { 26 | 27 | Optional tokenParam = Optional.ofNullable(httpServletRequest.getHeader("AUTHORIZATION")); //Authorization: Bearer TOKEN 28 | 29 | if (!(tokenParam.isPresent())) { 30 | throw new NullPointerException(); 31 | 32 | } 33 | String token= httpServletRequest.getHeader("AUTHORIZATION"); 34 | token= StringUtils.removeStart(token, "Bearer").trim(); 35 | Authentication requestAuthentication = new UsernamePasswordAuthenticationToken(token, token); 36 | return getAuthenticationManager().authenticate(requestAuthentication); 37 | 38 | } 39 | 40 | @Override 41 | protected void successfulAuthentication(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain, final Authentication authResult) throws IOException, ServletException { 42 | SecurityContextHolder.getContext().setAuthentication(authResult); 43 | chain.doFilter(request, response); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /BackOfficeSystem/src/main/java/com/banking/BackOfficeSystem/config/AuthenticationFilter.java: -------------------------------------------------------------------------------- 1 | package com.banking.BackOfficeSystem.config; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 5 | import org.springframework.security.core.Authentication; 6 | import org.springframework.security.core.AuthenticationException; 7 | import org.springframework.security.core.context.SecurityContextHolder; 8 | import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; 9 | import org.springframework.security.web.util.matcher.RequestMatcher; 10 | 11 | import javax.servlet.FilterChain; 12 | import javax.servlet.ServletException; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import java.io.IOException; 16 | import java.util.Optional; 17 | 18 | public class AuthenticationFilter extends AbstractAuthenticationProcessingFilter { 19 | 20 | AuthenticationFilter(final RequestMatcher requiresAuth) { 21 | super(requiresAuth); 22 | } 23 | 24 | @Override 25 | public Authentication attemptAuthentication(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws AuthenticationException, IOException, ServletException { 26 | 27 | Optional tokenParam = Optional.ofNullable(httpServletRequest.getHeader("AUTHORIZATION")); //Authorization: Bearer TOKEN 28 | 29 | if (!(tokenParam.isPresent())) { 30 | throw new NullPointerException(); 31 | 32 | } 33 | String token = httpServletRequest.getHeader("AUTHORIZATION"); 34 | token = StringUtils.removeStart(token, "Bearer").trim(); 35 | Authentication requestAuthentication = new UsernamePasswordAuthenticationToken(token, token); 36 | return getAuthenticationManager().authenticate(requestAuthentication); 37 | 38 | } 39 | 40 | @Override 41 | protected void successfulAuthentication(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain, final Authentication authResult) throws IOException, ServletException { 42 | SecurityContextHolder.getContext().setAuthentication(authResult); 43 | chain.doFilter(request, response); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /BackOfficeSystem/src/main/java/com/banking/BackOfficeSystem/config/RequestFilter.java: -------------------------------------------------------------------------------- 1 | package com.banking.BackOfficeSystem.config; 2 | 3 | import org.springframework.core.Ordered; 4 | import org.springframework.core.annotation.Order; 5 | import org.springframework.stereotype.Component; 6 | 7 | import javax.servlet.*; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | @Component 12 | @Order(Ordered.HIGHEST_PRECEDENCE) 13 | public class RequestFilter implements Filter { 14 | 15 | private static final String BACKOFFICE_URL = "http://localhost:4200"; // URL 16 | private static final String ONLINEBANKING_URL = "http://localhost:4201"; // OTHER URL 17 | 18 | public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) { 19 | HttpServletResponse response = (HttpServletResponse) res; 20 | HttpServletRequest request = (HttpServletRequest) req; 21 | 22 | if (BACKOFFICE_URL.equals(request.getHeader("Origin"))) { 23 | response.setHeader("Access-Control-Allow-Origin", BACKOFFICE_URL); 24 | } else if (ONLINEBANKING_URL.equals(request.getHeader("Origin"))) { 25 | response.setHeader("Access-Control-Allow-Origin", ONLINEBANKING_URL); 26 | } 27 | 28 | 29 | response.setHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE"); 30 | response.setHeader("Access-Control-Allow-Headers", "x-requested-with"); 31 | response.setHeader("Access-Control-Max-Age", "3600"); 32 | response.setHeader("Access-Control-Allow-Credentials", "true"); 33 | 34 | if (!(request.getMethod().equalsIgnoreCase("OPTIONS"))) { 35 | try { 36 | chain.doFilter(req, res); 37 | } catch (Exception e) { 38 | e.printStackTrace(); 39 | } 40 | } else { 41 | System.out.println("Pre-flight"); 42 | response.setHeader("Access-Control-Allow-Methods", "POST,GET,DELETE,PUT"); 43 | response.setHeader("Access-Control-Max-Age", "3600"); 44 | response.setHeader("Access-Control-Allow-Headers", "authorization, content-type," + 45 | "access-control-request-headers,access-control-request-method,accept,origin,authorization,x-requested-with"); 46 | response.setStatus(HttpServletResponse.SC_OK); 47 | } 48 | 49 | } 50 | 51 | public void init(FilterConfig filterConfig) { 52 | } 53 | 54 | public void destroy() { 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /TransactionScheduling1/src/main/java/com/batch/TransactionScheduling/config/DBWriter.java: -------------------------------------------------------------------------------- 1 | package com.batch.TransactionScheduling.config; 2 | 3 | 4 | import com.common.BankData.dao.AccountDao; 5 | 6 | import com.common.BankData.dao.ScheduleDao; 7 | import com.common.BankData.entity.Account; 8 | import com.common.BankData.entity.PrimaryTransaction; 9 | import com.common.BankData.entity.Schedule; 10 | import com.common.BankData.service.TransferService; 11 | import org.apache.commons.lang3.time.DateUtils; 12 | import org.springframework.batch.item.ItemWriter; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Component; 15 | import org.springframework.transaction.annotation.Transactional; 16 | 17 | 18 | import java.time.LocalDateTime; 19 | import java.util.Date; 20 | import java.util.List; 21 | 22 | @Component 23 | public class DBWriter implements ItemWriter { 24 | 25 | // @Autowired 26 | // private ScheduleDao userRepository; 27 | 28 | @Autowired 29 | ScheduleDao scheduleDao; 30 | 31 | @Autowired 32 | AccountDao accountDao; 33 | 34 | @Autowired 35 | TransferService transferService; 36 | 37 | 38 | @Override 39 | @Transactional 40 | public void write(List list) throws Exception { 41 | List ad = (List) list; 42 | Date today = new Date(); 43 | for (Schedule sd : ad 44 | ) { 45 | if (DateUtils.isSameDay(today, sd.getDates())) { 46 | 47 | long recipient = sd.getRecipientAccountNo(); 48 | Account recipientAccount = accountDao.findByAccountId(recipient); 49 | Account primaryAccount = accountDao.findByAccountId(sd.getAccountId()); 50 | PrimaryTransaction pt = new PrimaryTransaction(today, "Scheduled Transaction", "null", sd.getAmount(), sd.getRecipientName(), sd.getRecipientAccountNo(), sd.getAccountId(), null, sd.getType()); 51 | pt.setDate(today); 52 | if (recipientAccount != null) { 53 | Boolean b = transferService.addMoneyToRecipient(recipientAccount, primaryAccount, sd.getAmount(), pt); 54 | if (b) { 55 | 56 | sd.setStatus("completed"); 57 | transferService.deleteASchedule(sd); 58 | } else { 59 | sd.setStatus("failed"); 60 | scheduleDao.save(sd); 61 | } 62 | 63 | } 64 | 65 | } else { 66 | continue; 67 | 68 | } 69 | 70 | // userRepository.save(sd); 71 | } 72 | 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /OnlineBanking/src/main/java/com/banking/OnlineBanking/config/RequestFilter.java: -------------------------------------------------------------------------------- 1 | package com.banking.OnlineBanking.config; 2 | 3 | import org.springframework.core.Ordered; 4 | import org.springframework.core.annotation.Order; 5 | import org.springframework.stereotype.Component; 6 | 7 | import javax.servlet.*; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | @Component 12 | @Order(Ordered.HIGHEST_PRECEDENCE) 13 | public class RequestFilter implements Filter { 14 | 15 | private static final String BACKOFFICE_URL = "http://localhost:4200"; // URL 16 | private static final String ONLINEBANKING_URL = "http://localhost:4201"; // OTHER URL 17 | 18 | public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) { 19 | HttpServletResponse response = (HttpServletResponse) res; 20 | HttpServletRequest request = (HttpServletRequest) req; 21 | 22 | if (BACKOFFICE_URL.equals(request.getHeader("Origin"))) { 23 | response.setHeader("Access-Control-Allow-Origin", BACKOFFICE_URL); 24 | } else if (ONLINEBANKING_URL.equals(request.getHeader("Origin"))) { 25 | response.setHeader("Access-Control-Allow-Origin", ONLINEBANKING_URL); 26 | } 27 | 28 | 29 | 30 | // response.setHeader("Access-Control-Allow-Origin", "http://localhost:8082"); //8081 31 | // response.setHeader("Access-Control-Allow-Origin", "http://localhost:8084"); 32 | response.setHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE"); 33 | response.setHeader("Access-Control-Allow-Headers", "x-requested-with"); 34 | response.setHeader("Access-Control-Max-Age", "3600"); 35 | response.setHeader("Access-Control-Allow-Credentials", "true"); 36 | 37 | if (!(request.getMethod().equalsIgnoreCase("OPTIONS"))) { 38 | try { 39 | chain.doFilter(req, res); 40 | } catch(Exception e) { 41 | e.printStackTrace(); 42 | } 43 | } else { 44 | System.out.println("Pre-flight"); 45 | response.setHeader("Access-Control-Allow-Methods", "POST,GET,DELETE,PUT"); 46 | response.setHeader("Access-Control-Max-Age", "3600"); 47 | response.setHeader("Access-Control-Allow-Headers", "authorization, content-type," + 48 | "access-control-request-headers,access-control-request-method,accept,origin,authorization,x-requested-with"); 49 | response.setStatus(HttpServletResponse.SC_OK); 50 | } 51 | 52 | } 53 | 54 | public void init(FilterConfig filterConfig) {} 55 | 56 | public void destroy() {} 57 | 58 | } 59 | -------------------------------------------------------------------------------- /BackOfficeSystem/src/main/java/com/banking/BackOfficeSystem/controller/AdminLoginController.java: -------------------------------------------------------------------------------- 1 | package com.banking.BackOfficeSystem.controller; 2 | 3 | import com.common.BankData.dao.AdminDao; 4 | import com.common.BankData.entity.Admin; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.HttpHeaders; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestHeader; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | import sun.misc.BASE64Decoder; 14 | 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | import java.io.IOException; 18 | import java.util.UUID; 19 | 20 | 21 | @RequestMapping("/login/api") 22 | @RestController 23 | public class AdminLoginController { 24 | 25 | @Autowired 26 | AdminDao adminDao; 27 | 28 | @PostMapping("/secured/token") 29 | public ResponseEntity generateToken(@RequestHeader("Authorization") String authString, HttpServletRequest rs, HttpServletResponse res) throws Exception { 30 | System.out.println(authString); 31 | String decodedAuth = ""; 32 | String[] authParts = authString.split("\\s+"); 33 | String authInfo = authParts[1]; 34 | byte[] bytes = null; 35 | try { 36 | bytes = new BASE64Decoder().decodeBuffer(authInfo); 37 | } catch (IOException e) { 38 | e.printStackTrace(); 39 | // TODO Auto-generated catch block 40 | return new ResponseEntity<>("BAD REQUEST", new HttpHeaders(), HttpStatus.BAD_REQUEST); 41 | 42 | } 43 | decodedAuth = new String(bytes); 44 | System.out.println(decodedAuth); 45 | 46 | String username = decodedAuth.split(":")[0]; 47 | String enteredPassword = decodedAuth.split(":")[1]; 48 | username = username.toLowerCase(); 49 | 50 | Admin admin = adminDao.findByUserName(username); 51 | if (admin == null) { 52 | return new ResponseEntity<>("Username not found", new HttpHeaders(), HttpStatus.UNAUTHORIZED); 53 | } else { 54 | if (admin.getPasswordHash().equals(enteredPassword)) { 55 | String token = UUID.randomUUID().toString(); 56 | admin.setToken(token); 57 | adminDao.save(admin); 58 | return ResponseEntity.ok(admin); 59 | } else { 60 | return new ResponseEntity<>("Username or password is Wrong", new HttpHeaders(), HttpStatus.UNAUTHORIZED); 61 | } 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BankingSystem-Backend 2 | 3 | ## Accounting System 4 | 5 | 6 | Technology Used: 7 | Java, Spring, Spring Batch, Spring Security, PostgreSQL, Microservices, Maven, JUnit, Liquibase,Fast2SMS 8 | 9 | 10 | Functionalities: 11 | 12 | ⦁ Spring: Forms the Outline of Whole project. 13 | 14 | ⦁ Spring Security: Basic Authentication mechanism on login and Token Based Authentication for every subsequent call from the User Interface. 15 | 16 | ⦁ Junit: Unit Testing and Integration Testing available for Online Customer System. 17 | 18 | ⦁ Spring Batch: As there are scenarios where payments needs to be done on any scheduled date and multiple Transaction to be done in a single day(Eg. payment of Salaries), I have used Spring batch to ease up the Stress on the application environment. 19 | 20 | ⦁ Liquibase: Used for Managing database Entries. 21 | 22 | 23 | Working of Every Module: 24 | 25 | ## Backoffice System: 26 | 27 | 1. Admin would have two roles -Capturer and Authoriser. 28 | ```bash 29 | 30 | a. Capturer would be responsible for feeding the details of prospect customer into the System, 31 | and change the Details of Customer whenever requested by the Authoriser. 32 | 33 | b. Authoriser would be able to approve or decline the request of Account creation submitted 34 | by the capturer. Once Approved, the Customer account will be created along with 35 | Unique Account Number and credentials for login would be sent to the Phone number of 36 | Account holder.If Authoriser Decline the Request providing the reason for 37 | Disapproval of account, it would be sent back to Capturer for getting the data updated. 38 | 39 | c. Both the Capturer and Authhoriser would be able to login using their own crentials, 40 | which needs to be manually entered into the database at this point of time. 41 | 42 | ``` 43 | 44 | ## BankData: 45 | 46 | ```bash 47 | 1. BankData is a jar which which is used in other three projects. 48 | 49 | It contains the Common functionalities across the project and thus, 50 | 51 | It can be used in all the project as a library. 52 | 53 | BankData is based on following DRY(Do not repeat Yourself) principle. 54 | ``` 55 | 56 | ## OnlineBanking: 57 | 58 | 1. This Module is for Customer Facing Application. In this Customer would be able to perform many functions.Eg. 59 | 60 | a. Login into their own account using credentials received through SMS. 61 | 62 | b. Check the Balance on their Account. 63 | 64 | c. View Transaction History on all the Transaction Done till the current date. 65 | 66 | d. Schedule a Transaction(Future-Dated) 67 | 68 | ## TransactionScheduling: 69 | 70 | ``` 71 | 1. This Module is a Spring Batch Application which runs in the background, 72 | 73 | and process the future dated Transaction. There is a Cron Job running every 40 seconds 74 | 75 | which which the data which needs to be processed. It will complete the job and 76 | 77 | write the transaction log to the database. 78 | ``` 79 | 80 | Thank You! 81 | -------------------------------------------------------------------------------- /OnlineBanking/src/main/resources/liquibase.properties: -------------------------------------------------------------------------------- 1 | #### _ _ _ _ 2 | ## | | (_) (_) | 3 | ## | | _ __ _ _ _ _| |__ __ _ ___ ___ 4 | ## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ 5 | ## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ 6 | ## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| 7 | ## | | 8 | ## |_| 9 | ## 10 | ## The liquibase.properties file stores properties which do not change often, 11 | ## such as database connection information. Properties stored here save time 12 | ## and reduce risk of mistyped command line arguments. 13 | ## Learn more: https://www.liquibase.org/documentation/config_properties.html 14 | #### 15 | #### 16 | ## Note about relative and absolute paths: 17 | ## The liquibase.properties file requires paths for some properties. 18 | ## The classpath is the path/to/resources (ex. src/main/resources). 19 | ## The changeLogFile path is relative to the classpath. 20 | ## The url H2 example below is relative to 'pwd' resource. 21 | #### 22 | # Enter the path for your changelog file. 23 | changeLogFile=src/main/resources/sample.changelog.xml 24 | #classpath=/postgresql-42.2.12.jar 25 | #### Primary Database Information #### 26 | # The primary database is the database you want to use when doing an update, or for performing comparisons. 27 | diffTypes=data 28 | driver=org.postgresql.Driver 29 | # Enter the URL of the source database 30 | url=jdbc:postgresql://localhost:5432/HdfcBank1 31 | liquibase.change-log=classpath:liquibase-changeLog.xml 32 | outputChangeLogFile=src/main/resources/liquibase-outputChangeLog.xml 33 | 34 | # Enter the username for your source database. 35 | username: postgres 36 | 37 | # Enter the password for your source database. 38 | password: root 39 | 40 | 41 | 42 | #### Target Database Information #### 43 | ## The target database is the database you want to use to compare to your source database. 44 | 45 | # Enter URL for the target database 46 | #referenceUrl: jdbc:postgresql://localhost:5432/HdfcBank2 47 | 48 | # Enter the username for your target database 49 | #referenceUsername: postgres 50 | 51 | # Enter the password for your target database 52 | #referencePassword: root 53 | 54 | #### Liquibase Pro Key Information #### 55 | # Enter your Liquibase Pro key here. 56 | # If you don't have one, visit https://download.liquibase.org/liquibase-pro-trial-request-form/ to start a free trial! 57 | # liquibaseProLicenseKey: 58 | 59 | # Logging Configuration 60 | # logLevel controls the amount of logging information generated. If not set, the default logLevel is INFO. 61 | # Valid values, from least amount of logging to most, are: 62 | # OFF, ERROR, WARN, INFO, DEBUG, TRACE, ALL 63 | # If you are having problems, setting the logLevel to DEBUG and re-running the command can be helpful. 64 | # logLevel: DEBUG 65 | 66 | # The logFile property controls where logging messages are sent. If this is not set, then logging messages are 67 | # displayed on the console. If this is set, then messages will be sent to a file with the given name. 68 | # logFile: liquibase.log -------------------------------------------------------------------------------- /OnlineBanking/src/main/java/com/banking/OnlineBanking/controller/TransferController.java: -------------------------------------------------------------------------------- 1 | package com.banking.OnlineBanking.controller; 2 | 3 | 4 | import com.common.BankData.dao.AccountDao; 5 | import com.common.BankData.entity.Account; 6 | import com.common.BankData.entity.OtherAccount; 7 | import com.common.BankData.entity.PrimaryTransaction; 8 | import com.common.BankData.service.TransferService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.http.HttpHeaders; 11 | import org.springframework.http.HttpStatus; 12 | import org.springframework.http.ResponseEntity; 13 | import org.springframework.transaction.annotation.Transactional; 14 | import org.springframework.web.bind.annotation.*; 15 | 16 | import java.time.LocalDate; 17 | import java.time.LocalDateTime; 18 | import java.util.ArrayList; 19 | import java.util.Date; 20 | import java.util.List; 21 | import java.util.Set; 22 | 23 | @RestController 24 | @RequestMapping("/transfer") 25 | public class TransferController { 26 | @Autowired 27 | AccountDao accountDao; 28 | 29 | @Autowired 30 | TransferService transferService; 31 | 32 | @PostMapping("/betweenAccounts") 33 | public ResponseEntity betweenAccounts(@RequestBody PrimaryTransaction transaction) throws Exception { 34 | long recipient = transaction.getRecipientAccountNo(); 35 | Account recipientAccount = accountDao.findByAccountId(transaction.getRecipientAccountNo()); 36 | Account primaryAccount = accountDao.findByAccountId(transaction.getAccountId()); 37 | java.util.Date d = new Date(); 38 | if (recipientAccount != null) { 39 | transferService.addMoneyToRecipient(recipientAccount, primaryAccount, transaction.getAmount(), transaction); 40 | 41 | } else { 42 | OtherAccount RecipientAccount = new OtherAccount(transaction.getAmount(), (java.sql.Date) d, recipient); 43 | transferService.addMoneyToRecipientOfAnotherBank(RecipientAccount, primaryAccount, transaction.getAmount(), transaction); 44 | return ResponseEntity.ok(HttpStatus.OK); 45 | } 46 | return ResponseEntity.ok(HttpStatus.OK); 47 | } 48 | 49 | @GetMapping("/transactionHistory/{accountId}") 50 | public ResponseEntity getTransactionList(@PathVariable long accountId) { 51 | 52 | Set pt = transferService.getTransactionHistoryByAccountID(accountId); 53 | List pp = new ArrayList<>(); 54 | for (PrimaryTransaction p : pt 55 | ) { 56 | pp.add(p); 57 | } 58 | 59 | return ResponseEntity.ok(pp); 60 | 61 | } 62 | 63 | 64 | @GetMapping("/balance/{accountId}") 65 | public ResponseEntity getBalance(@PathVariable long accountId) { 66 | 67 | Account account = accountDao.findByAccountId(accountId); 68 | return ResponseEntity.ok(account); 69 | } 70 | 71 | @GetMapping("/balanceAmountOnly/{accountId}") 72 | public ResponseEntity balanceAmountOnly(@PathVariable long accountId) { 73 | 74 | Account account = accountDao.findByAccountId(accountId); 75 | return ResponseEntity.ok(account.getBalance()); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/service/SmsService.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.service; 2 | 3 | import org.springframework.stereotype.Component; 4 | import org.springframework.stereotype.Service; 5 | 6 | import javax.net.ssl.HttpsURLConnection; 7 | import java.io.BufferedReader; 8 | import java.io.InputStreamReader; 9 | import java.net.URL; 10 | import java.net.URLEncoder; 11 | import java.util.Random; 12 | 13 | @Component 14 | public class SmsService { 15 | 16 | public static void sendSms(long username,String number,String password) 17 | { 18 | try 19 | { 20 | 21 | String apiKey="Your API Key here"; 22 | String sendId="FSTSMS"; 23 | 24 | String language="english"; 25 | String route="qt"; 26 | 27 | String myUrl="https://www.fast2sms.com/dev/bulk?authorization="+apiKey+"&sender_id="+sendId+"&language="+language+"&route="+route+"&numbers="+number+"&message="+27480+"&variables={AA}|{BB}&variables_values="+username+ '|'+password; 28 | //sending get request using java.. 29 | 30 | URL url=new URL(myUrl); 31 | HttpsURLConnection con=(HttpsURLConnection)url.openConnection(); 32 | con.setRequestMethod("GET"); 33 | 34 | con.setRequestProperty("User-Agent", "Mozilla/5.0"); 35 | con.setRequestProperty("cache-control", "no-cache"); 36 | System.out.println("Wait.............."); 37 | 38 | int code=con.getResponseCode(); 39 | 40 | System.out.println("Response code : "+code); 41 | 42 | StringBuffer response=new StringBuffer(); 43 | 44 | BufferedReader br=new BufferedReader(new InputStreamReader(con.getInputStream())); 45 | 46 | while(true) 47 | { 48 | String line=br.readLine(); 49 | if(line==null) 50 | { 51 | break; 52 | } 53 | response.append(line); 54 | } 55 | 56 | System.out.println(response); 57 | 58 | 59 | }catch (Exception e) { 60 | // TODO: handle exception 61 | e.printStackTrace(); 62 | } 63 | 64 | } 65 | 66 | public static char[] generatePassword(int length) { 67 | String capitalCaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 68 | String lowerCaseLetters = "abcdefghijklmnopqrstuvwxyz"; 69 | String specialCharacters = "!@#$"; 70 | String numbers = "1234567890"; 71 | String combinedChars = capitalCaseLetters + lowerCaseLetters + specialCharacters + numbers; 72 | Random random = new Random(); 73 | char[] password = new char[length]; 74 | 75 | password[0] = lowerCaseLetters.charAt(random.nextInt(lowerCaseLetters.length())); 76 | password[1] = capitalCaseLetters.charAt(random.nextInt(capitalCaseLetters.length())); 77 | password[2] = specialCharacters.charAt(random.nextInt(specialCharacters.length())); 78 | password[3] = numbers.charAt(random.nextInt(numbers.length())); 79 | 80 | for(int i = 4; i< length ; i++) { 81 | password[i] = combinedChars.charAt(random.nextInt(combinedChars.length())); 82 | } 83 | return password; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/Schedule.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity; 2 | 3 | import com.sun.istack.Nullable; 4 | 5 | import javax.persistence.*; 6 | import java.time.*; 7 | import java.util.Date; 8 | 9 | 10 | @Entity(name="schedule") 11 | public class Schedule { 12 | 13 | @Id 14 | @GeneratedValue(strategy = GenerationType.IDENTITY) 15 | private int scheduleid; 16 | private Date dates; 17 | private long recipientAccountNo; 18 | private String status; 19 | private String recipientName; 20 | private double amount; 21 | 22 | private String schedule_type; 23 | 24 | public String getSchedule_type() { 25 | return schedule_type; 26 | } 27 | 28 | public void setSchedule_type(String schedule_type) { 29 | this.schedule_type = schedule_type; 30 | } 31 | 32 | private String type; 33 | 34 | public Schedule() { 35 | } 36 | 37 | public String getType() { 38 | return type; 39 | } 40 | 41 | public void setType(String type) { 42 | this.type = type; 43 | } 44 | @Column(nullable = true) 45 | private long accountId; 46 | 47 | public long getAccountId() { 48 | return accountId; 49 | } 50 | 51 | public void setAccountId(long accountId) { 52 | this.accountId = accountId; 53 | } 54 | 55 | public Schedule(int scheduleid, Date dates, long recipientAccountNo, String status, String recipientName, double amount, String type, long accountId) { 56 | this.scheduleid = scheduleid; 57 | this.dates = dates; 58 | this.recipientAccountNo = recipientAccountNo; 59 | this.status = status; 60 | this.recipientName = recipientName; 61 | this.amount = amount; 62 | this.type = type; 63 | this.accountId = accountId; 64 | } 65 | 66 | public Date getDates() { 67 | return dates; 68 | } 69 | 70 | public void setDates(Date dates) { 71 | this.dates = dates; 72 | } 73 | 74 | public String getRecipientName() { 75 | return recipientName; 76 | } 77 | 78 | public void setRecipientName(String recipientName) { 79 | this.recipientName = recipientName; 80 | } 81 | 82 | public double getAmount() { 83 | return amount; 84 | } 85 | 86 | public void setAmount(double amount) { 87 | this.amount = amount; 88 | } 89 | 90 | // @ManyToOne 91 | // ScheduleList scheduleList; 92 | // 93 | // public ScheduleList getScheduleList() { 94 | // return scheduleList; 95 | // } 96 | // 97 | // public void setScheduleList(ScheduleList scheduleList) { 98 | // this.scheduleList = scheduleList; 99 | // } 100 | 101 | 102 | public int getScheduleid() { 103 | return scheduleid; 104 | } 105 | 106 | public void setScheduleid(int scheduleid) { 107 | this.scheduleid = scheduleid; 108 | } 109 | 110 | public long getRecipientAccountNo() { 111 | return recipientAccountNo; 112 | } 113 | 114 | public void setRecipientAccountNo(long recipientAccountNo) { 115 | this.recipientAccountNo = recipientAccountNo; 116 | } 117 | 118 | public String getStatus() { 119 | return status; 120 | } 121 | 122 | public void setStatus(String status) { 123 | this.status = status; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/Admin.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity; 2 | 3 | 4 | 5 | 6 | import com.common.BankData.entity.security.Role; 7 | import com.fasterxml.jackson.annotation.JsonIgnore; 8 | import org.springframework.security.core.GrantedAuthority; 9 | import org.springframework.security.core.userdetails.UserDetails; 10 | 11 | import javax.persistence.*; 12 | import javax.persistence.GeneratedValue; 13 | import java.util.List; 14 | 15 | @Entity 16 | public class Admin{ 17 | 18 | 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | private long adminId; 22 | 23 | @Column(name="adminName") 24 | private String adminName; 25 | private String userName; 26 | 27 | public Admin() { 28 | 29 | } 30 | 31 | @OneToMany(cascade=CascadeType.ALL,fetch = FetchType.EAGER) 32 | @JoinTable(name = "adminRole", joinColumns = @JoinColumn(name = "adminid"), inverseJoinColumns = @JoinColumn(name = "roleid")) 33 | public List adminRole; 34 | 35 | // @OneToMany(mappedBy = "admin", cascade=CascadeType.ALL,fetch = FetchType.EAGER) 36 | // @JsonIgnore 37 | // public List adminRole; 38 | private String passwordHash; 39 | private String bankIFSC; 40 | private String token; 41 | public Admin(Admin o) { 42 | this.adminId=o.adminId; 43 | this.adminName=o.adminName; 44 | this.adminRole=o.adminRole; 45 | this.userName=o.userName; 46 | this.bankIFSC=o.bankIFSC; 47 | this.passwordHash=o.passwordHash; 48 | this.token=o.token; 49 | } 50 | 51 | 52 | public String getToken() { 53 | return token; 54 | } 55 | 56 | public void setToken(String token) { 57 | this.token = token; 58 | } 59 | 60 | public long getAdminId() { 61 | return adminId; 62 | } 63 | 64 | public void setAdminId(long adminId) { 65 | this.adminId = adminId; 66 | } 67 | 68 | public String getAdminName() { 69 | return adminName; 70 | } 71 | 72 | public List getAdminRole() { 73 | return adminRole; 74 | } 75 | 76 | public void setAdminRole(List adminRole) { 77 | this.adminRole = adminRole; 78 | } 79 | 80 | public void setAdminName(String adminName) { 81 | this.adminName = adminName; 82 | } 83 | 84 | public String getUserName() { 85 | return userName; 86 | } 87 | 88 | public void setUserName(String userName) { 89 | this.userName = userName; 90 | } 91 | 92 | // public Role getRole() { 93 | // return role; 94 | // } 95 | // 96 | // public void setRole(Role role) { 97 | // this.role = role; 98 | // } 99 | 100 | public String getPasswordHash() { 101 | return passwordHash; 102 | } 103 | 104 | public void setPasswordHash(String passwordHash) { 105 | this.passwordHash = passwordHash; 106 | } 107 | 108 | public String getBankIFSC() { 109 | return bankIFSC; 110 | } 111 | 112 | public void setBankIFSC(String bankIFSC) { 113 | this.bankIFSC = bankIFSC; 114 | } 115 | 116 | 117 | // @Override 118 | // public Collection getAuthorities() { 119 | // Set authorities = new HashSet<>(); 120 | // adminRole.forEach(ur -> authorities.add(new Authority(ur.getRoleName()))); 121 | // return authorities; 122 | // } 123 | 124 | 125 | 126 | } 127 | -------------------------------------------------------------------------------- /OnlineBanking/src/main/java/com/banking/OnlineBanking/controller/CustomerLoginControlller.java: -------------------------------------------------------------------------------- 1 | package com.banking.OnlineBanking.controller; 2 | 3 | import com.common.BankData.dao.CustomerDao; 4 | import com.common.BankData.entity.Customer; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.HttpHeaders; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.web.bind.annotation.*; 10 | import sun.misc.BASE64Decoder; 11 | 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import java.io.IOException; 15 | import java.util.Enumeration; 16 | import java.util.HashMap; 17 | import java.util.Map; 18 | import java.util.UUID; 19 | 20 | @RequestMapping("/login/customer/api") 21 | @RestController 22 | public class CustomerLoginControlller { 23 | @Autowired 24 | CustomerDao customerDao; 25 | 26 | 27 | // @PostMapping("/secured/token") 28 | // public ResponseEntity generateToken(@RequestHeader("Authorization") String authString, HttpServletRequest rs, HttpServletResponse res) throws Exception { 29 | // System.out.println(authString); 30 | 31 | 32 | @PostMapping("/secured/token") 33 | public ResponseEntity generateToken(@RequestHeader("Authorization") String authString, HttpServletRequest rs, HttpServletResponse res) throws Exception { 34 | System.out.println(authString); 35 | String[] authParts = authString.split("\\s+"); 36 | 37 | // Map map = new HashMap(); 38 | // 39 | // Enumeration headerNames = rs.getHeaderNames(); 40 | // while (headerNames.hasMoreElements()) { 41 | // String key = (String) headerNames.nextElement(); 42 | // String value = rs.getHeader(key); 43 | // map.put(key, value); 44 | // } 45 | // String header=map.get("Authorization"); 46 | // 47 | // System.out.println(header); 48 | // 49 | String decodedAuth = ""; 50 | // String[] authParts = header.split("\\s+"); 51 | String authInfo = authParts[1]; 52 | byte[] bytes = null; 53 | try { 54 | bytes = new BASE64Decoder().decodeBuffer(authInfo); 55 | } catch (IOException e) { 56 | e.printStackTrace(); 57 | // TODO Auto-generated catch block 58 | return new ResponseEntity<>("BAD REQUEST",new HttpHeaders(), HttpStatus.BAD_REQUEST); 59 | 60 | } 61 | decodedAuth = new String(bytes); 62 | String username = decodedAuth.split(":")[0]; 63 | long userId = Long.parseLong(username); 64 | 65 | String enteredPassword = decodedAuth.split(":")[1]; 66 | username=username.toLowerCase(); 67 | 68 | Customer customer = customerDao.findByUserId(userId); 69 | if(customer==null) 70 | { 71 | System.out.println("customer is null"); 72 | return new ResponseEntity<>("Username not found",new HttpHeaders(),HttpStatus.UNAUTHORIZED); 73 | } 74 | else 75 | { 76 | if(customer.getPassword().equals(enteredPassword)){ 77 | String token = UUID.randomUUID().toString(); 78 | customer.setToken(token); 79 | customerDao.save(customer); 80 | return ResponseEntity.ok(customer); 81 | } 82 | else 83 | { 84 | return new ResponseEntity<>("Username or password is Wrong",new HttpHeaders(),HttpStatus.UNAUTHORIZED); 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/Customer.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity; 2 | 3 | import org.hibernate.annotations.ColumnDefault; 4 | 5 | import javax.persistence.*; 6 | import java.security.AccessControlContext; 7 | import java.util.Set; 8 | 9 | @Entity 10 | public class Customer { 11 | 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.AUTO ) 14 | private long customerId; 15 | private String customerName; 16 | // private long accountId; 17 | private String userName; 18 | private String password; 19 | 20 | @ColumnDefault("0") 21 | private long userId; 22 | 23 | @OneToMany(cascade = CascadeType.ALL) 24 | @JoinColumn(name = "customeridref") 25 | private Set accounts; 26 | 27 | private String token; 28 | 29 | public Customer(final Customer o) { 30 | this.customerId=o.customerId; 31 | this.customerName=o.customerName; 32 | this.userName=o.userName; 33 | this.password=o.password; 34 | this.token=o.token; 35 | // this.accountId=o.accountId; 36 | this.accounts=o.accounts; 37 | 38 | 39 | 40 | } 41 | 42 | 43 | public Customer() { 44 | } 45 | 46 | public Customer(long customerId, String customerName, String userName, String password, Set accounts, String token,long userId) { 47 | this.customerId = customerId; 48 | this.customerName = customerName; 49 | this.userName = userName; 50 | this.password = password; 51 | this.accounts = accounts; 52 | this.token = token; 53 | this.userId = userId; 54 | } 55 | //this constructor is used to create a new Customer, when the account of that particular user is approved 56 | public Customer(String customerName, String userName, String password, Set accounts, String token,long userId) { 57 | this.customerName = customerName; 58 | this.userName = userName; 59 | this.password = password; 60 | this.accounts = accounts; 61 | this.token = token; 62 | this.userId=userId; 63 | } 64 | 65 | public long getUserId() { 66 | return userId; 67 | } 68 | 69 | public void setUser_id(long userId) { 70 | this.userId = userId; 71 | } 72 | 73 | public long getCustomerId() { 74 | return customerId; 75 | } 76 | 77 | public void setCustomerId(long customerId) { 78 | this.customerId = customerId; 79 | } 80 | 81 | public String getCustomerName() { 82 | return customerName; 83 | } 84 | 85 | public void setCustomerName(String customerName) { 86 | this.customerName = customerName; 87 | } 88 | 89 | // public long getAccountId() { 90 | // return accountId; 91 | // } 92 | // 93 | // public void setAccountId(long accountId) { 94 | // this.accountId = accountId; 95 | // } 96 | 97 | public String getUserName() { 98 | return userName; 99 | } 100 | 101 | public void setUserName(String userName) { 102 | this.userName = userName; 103 | } 104 | 105 | 106 | public String getPassword() { 107 | return password; 108 | } 109 | 110 | public void setPassword(String password) { 111 | this.password = password; 112 | } 113 | 114 | public Set getAccounts() { 115 | return accounts; 116 | } 117 | 118 | public void setAccounts(Set accounts) { 119 | this.accounts = accounts; 120 | } 121 | 122 | public String getToken() { 123 | return token; 124 | } 125 | 126 | public void setToken(String token) { 127 | this.token = token; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /BankData/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | com.common 12 | BankData 13 | 0.0.1-SNAPSHOT 14 | BankData 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-security 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-test 35 | test 36 | 37 | 38 | org.junit.vintage 39 | junit-vintage-engine 40 | 41 | 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-web 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-test 53 | test 54 | 55 | 56 | org.springframework.batch 57 | spring-batch-test 58 | test 59 | 60 | 61 | org.springframework.security 62 | spring-security-test 63 | test 64 | 65 | 66 | 67 | org.springframework.boot 68 | spring-boot-starter-data-jpa 69 | 70 | 71 | 72 | org.postgresql 73 | postgresql 74 | runtime 75 | 76 | 77 | 78 | 79 | org.apache.commons 80 | commons-lang3 81 | 3.9 82 | 83 | 84 | 85 | 86 | com.fasterxml.uuid 87 | java-uuid-generator 88 | 4.0.1 89 | 90 | 91 | 92 | 93 | javax.servlet 94 | servlet-api 95 | 2.5 96 | provided 97 | 98 | 99 | 100 | javax.ws.rs 101 | javax.ws.rs-api 102 | 2.1.1 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | org.springframework.boot 112 | spring-boot-maven-plugin 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/OtherAccount.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonManagedReference; 5 | import com.sun.istack.Nullable; 6 | 7 | import javax.persistence.*; 8 | import javax.ws.rs.DefaultValue; 9 | import java.sql.Date; 10 | 11 | @Entity 12 | public class OtherAccount { 13 | 14 | @Id 15 | @GeneratedValue(strategy = GenerationType.AUTO) 16 | private long id; 17 | 18 | private String bankIfsc; 19 | 20 | private String firstName; 21 | private String lastName; 22 | //@Column(name = "age") 23 | // private int age=0; 24 | 25 | //@DefaultValue("0.0") 26 | @Column(name="balance") 27 | private double balance=0.0f; 28 | 29 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") 30 | private Date date; 31 | 32 | 33 | @DefaultValue("0") 34 | private int accountStatus; 35 | 36 | 37 | // @OneToMany(mappedBy = "primaryAccount", cascade = CascadeType.ALL) 38 | // @JsonIgnore 39 | // private List primaryTransactionList; 40 | 41 | @ManyToOne 42 | private Customer customer; 43 | 44 | public Customer getCustomer() { 45 | return customer; 46 | } 47 | 48 | public void setCustomer(Customer customer) { 49 | this.customer = customer; 50 | } 51 | 52 | @Nullable 53 | private long accountId; 54 | 55 | private String remarks; 56 | 57 | public long getId() { 58 | return id; 59 | } 60 | 61 | public void setId(long id) { 62 | this.id = id; 63 | } 64 | 65 | public long getAccountId() { 66 | return accountId; 67 | } 68 | 69 | public void setAccountId(long accountId) { 70 | this.accountId = accountId; 71 | } 72 | 73 | 74 | public String getBankIfsc() { 75 | return bankIfsc; 76 | } 77 | 78 | public void setBankIfsc(String bankIfsc) { 79 | this.bankIfsc = bankIfsc; 80 | } 81 | 82 | public OtherAccount(double balance, Date date, long accountId) { 83 | this.balance = balance; 84 | this.date = date; 85 | this.accountId = accountId; 86 | } 87 | 88 | // public List getPrimaryTransactionList() { 89 | // return primaryTransactionList; 90 | // } 91 | // 92 | // public void setPrimaryTransactionList(List primaryTransactionList) { 93 | // this.primaryTransactionList = primaryTransactionList; 94 | // } 95 | 96 | public double getBalance() { 97 | return balance; 98 | } 99 | 100 | public void setBalance(double balance) { 101 | this.balance = balance; 102 | } 103 | 104 | public int getAccountStatus() { 105 | return accountStatus; 106 | } 107 | 108 | public void setAccountStatus(int accountStatus) { 109 | this.accountStatus = accountStatus; 110 | } 111 | 112 | 113 | public String getFirstName() { 114 | return firstName; 115 | } 116 | 117 | public void setFirstName(String firstName) { 118 | this.firstName = firstName; 119 | } 120 | 121 | public String getLastName() { 122 | return lastName; 123 | } 124 | 125 | public void setLastName(String lastName) { 126 | this.lastName = lastName; 127 | } 128 | 129 | 130 | public Date getDate() { 131 | return date; 132 | } 133 | 134 | public void setDate(Date date) { 135 | this.date = date; 136 | } 137 | 138 | public String getRemarks() { 139 | return remarks; 140 | } 141 | 142 | public void setRemarks(String remarks) { 143 | this.remarks = remarks; 144 | } 145 | 146 | 147 | // public void setAge(int age) { 148 | // this.age = age; 149 | // } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /BackOfficeSystem/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.5.RELEASE 9 | 10 | 11 | com.banking 12 | BackOfficeSystem 13 | 0.0.1-SNAPSHOT 14 | BackOfficeSystem 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | 24 | com.common 25 | 0.0.1-SNAPSHOT 26 | BankData 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-batch 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-security 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-web 40 | 41 | 42 | 43 | 44 | org.springframework.batch 45 | spring-batch-test 46 | test 47 | 48 | 49 | org.springframework.security 50 | spring-security-test 51 | test 52 | 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-starter-data-jpa 57 | 58 | 59 | 60 | org.postgresql 61 | postgresql 62 | runtime 63 | 64 | 65 | 66 | 67 | org.apache.commons 68 | commons-lang3 69 | 3.9 70 | 71 | 72 | 73 | 74 | com.fasterxml.uuid 75 | java-uuid-generator 76 | 4.0.1 77 | 78 | 79 | 80 | 81 | javax.servlet 82 | servlet-api 83 | 2.5 84 | provided 85 | 86 | 87 | 88 | javax.ws.rs 89 | javax.ws.rs-api 90 | 2.1.1 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | org.springframework.boot 100 | spring-boot-maven-plugin 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/PrimaryTransaction.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity; 2 | 3 | import javax.persistence.*; 4 | import java.math.BigDecimal; 5 | import java.time.LocalDateTime; 6 | import java.util.Date; 7 | 8 | @Entity 9 | public class PrimaryTransaction { 10 | 11 | @Id 12 | @GeneratedValue(strategy = GenerationType.IDENTITY) 13 | private long id; 14 | 15 | private Date date; 16 | 17 | @Column(name = "local_date_time", columnDefinition = "TIMESTAMP") 18 | private LocalDateTime localDateTime; 19 | 20 | public void setId(long id) { 21 | this.id = id; 22 | } 23 | 24 | public LocalDateTime getLocalDateTime() { 25 | return localDateTime; 26 | } 27 | 28 | public void setLocalDateTime(LocalDateTime localDateTime) { 29 | this.localDateTime = localDateTime; 30 | } 31 | 32 | private String description; 33 | 34 | private String type; 35 | private String status; 36 | private double amount; 37 | @Transient 38 | private BigDecimal availableBalance; 39 | 40 | private String recipientName; 41 | private long recipientAccountNo; 42 | @Transient 43 | private long phoneNo; 44 | 45 | 46 | 47 | 48 | 49 | 50 | private long accountId; 51 | 52 | 53 | public long getRecipientAccountNo() { 54 | return recipientAccountNo; 55 | } 56 | 57 | public void setRecipientAccountNo(long recipientAccountNo) { 58 | this.recipientAccountNo = recipientAccountNo; 59 | } 60 | 61 | // @ManyToOne 62 | // @JoinColumn(name = "primary_account_id") 63 | // @Transient 64 | // private Account primaryAccount; 65 | 66 | public PrimaryTransaction() { 67 | 68 | } 69 | 70 | public PrimaryTransaction(Date date, String description, String status, double amount, String recipientName, long recipientAccountNo, long accountId, LocalDateTime localDateTime, String type) { 71 | this.date = date; 72 | this.description = description; 73 | this.status = status; 74 | this.amount = amount; 75 | this.recipientName = recipientName; 76 | this.recipientAccountNo = recipientAccountNo; 77 | this.accountId = accountId; 78 | this.localDateTime=localDateTime; 79 | this.type=type; 80 | } 81 | 82 | public Long getId() { 83 | return id; 84 | } 85 | 86 | public void setId(Long id) { 87 | this.id = id; 88 | } 89 | 90 | public Date getDate() { 91 | return date; 92 | } 93 | 94 | public void setDate(Date date) { 95 | this.date = date; 96 | } 97 | 98 | public String getDescription() { 99 | return description; 100 | } 101 | 102 | public void setDescription(String description) { 103 | this.description = description; 104 | } 105 | 106 | public String getType() { 107 | return type; 108 | } 109 | 110 | public void setType(String type) { 111 | this.type = type; 112 | } 113 | 114 | public String getStatus() { 115 | return status; 116 | } 117 | 118 | public void setStatus(String status) { 119 | this.status = status; 120 | } 121 | 122 | public double getAmount() { 123 | return amount; 124 | } 125 | 126 | public void setAmount(double amount) { 127 | this.amount = amount; 128 | } 129 | 130 | public BigDecimal getAvailableBalance() { 131 | return availableBalance; 132 | } 133 | 134 | public void setAvailableBalance(BigDecimal availableBalance) { 135 | this.availableBalance = availableBalance; 136 | } 137 | 138 | // public Account getPrimaryAccount() { 139 | // return primaryAccount; 140 | // } 141 | // 142 | // public void setPrimaryAccount(Account primaryAccount) { 143 | // this.primaryAccount = primaryAccount; 144 | // } 145 | 146 | public String getRecipientName() { 147 | return recipientName; 148 | } 149 | 150 | public void setRecipientName(String recipientName) { 151 | this.recipientName = recipientName; 152 | } 153 | 154 | public long getPhoneNo() { 155 | return phoneNo; 156 | } 157 | 158 | public void setPhoneNo(long phoneNo) { 159 | this.phoneNo = phoneNo; 160 | } 161 | 162 | 163 | public long getAccountId() { 164 | return accountId; 165 | } 166 | 167 | public void setAccountId(long accountId) { 168 | this.accountId = accountId; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /BackOfficeSystem/src/main/java/com/banking/BackOfficeSystem/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.banking.BackOfficeSystem.config; 2 | 3 | import com.banking.BackOfficeSystem.service.AuthenticationProvider; 4 | import com.banking.BackOfficeSystem.service.UserSecurityService; 5 | import com.common.BankData.dao.AdminDao; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 10 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 11 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 12 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 13 | import org.springframework.security.config.annotation.web.builders.WebSecurity; 14 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 15 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 16 | import org.springframework.security.config.http.SessionCreationPolicy; 17 | import org.springframework.security.crypto.password.PasswordEncoder; 18 | import org.springframework.security.web.authentication.AnonymousAuthenticationFilter; 19 | import org.springframework.security.web.util.matcher.AntPathRequestMatcher; 20 | import org.springframework.security.web.util.matcher.OrRequestMatcher; 21 | import org.springframework.security.web.util.matcher.RequestMatcher; 22 | 23 | 24 | @Configuration 25 | @EnableWebSecurity 26 | @EnableJpaRepositories(basePackageClasses = AdminDao.class) 27 | @EnableGlobalMethodSecurity(prePostEnabled = true) 28 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 29 | 30 | @Autowired 31 | private UserSecurityService userSecurityService; 32 | 33 | AuthenticationProvider provider; 34 | 35 | @Bean 36 | public PasswordEncoder passwordEncoder() { 37 | return new PasswordEncoder() { 38 | @Override 39 | public String encode(CharSequence charSequence) { 40 | return charSequence.toString(); 41 | } 42 | 43 | @Override 44 | public boolean matches(CharSequence charSequence, String s) { 45 | return encode(charSequence).equals(s); 46 | } 47 | }; 48 | } 49 | 50 | private static final RequestMatcher PROTECTED_URLS = new OrRequestMatcher( 51 | new AntPathRequestMatcher("/accounts/**") 52 | ); 53 | 54 | 55 | @Bean 56 | AuthenticationFilter authenticationFilter() throws Exception { 57 | final AuthenticationFilter filter = new AuthenticationFilter(PROTECTED_URLS); 58 | filter.setAuthenticationManager(authenticationManager()); 59 | return filter; 60 | } 61 | 62 | 63 | public SecurityConfig(final AuthenticationProvider authenticationProvider) { 64 | super(); 65 | this.provider = authenticationProvider; 66 | } 67 | 68 | @Override 69 | protected void configure(final AuthenticationManagerBuilder auth) { 70 | auth.authenticationProvider(provider); 71 | } 72 | 73 | @Override 74 | public void configure(final WebSecurity webSecurity) { 75 | webSecurity.ignoring().antMatchers("/login/**"); 76 | webSecurity.ignoring().antMatchers("**/secured/**"); 77 | } 78 | 79 | 80 | @Override 81 | protected void configure(HttpSecurity http) throws Exception { 82 | 83 | http.sessionManagement() 84 | .sessionCreationPolicy(SessionCreationPolicy.STATELESS) 85 | .and() 86 | // .authenticationProvider(provider) 87 | .addFilterBefore(authenticationFilter(), AnonymousAuthenticationFilter.class) 88 | .authorizeRequests() 89 | .requestMatchers(PROTECTED_URLS) 90 | .authenticated() 91 | .and() 92 | .csrf().disable() 93 | .formLogin().disable() 94 | .logout().disable(); 95 | } 96 | 97 | 98 | @Autowired 99 | public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 100 | // auth.userDetailsService(userSecurityService).passwordEncoder(passwordEncoder()); 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /OnlineBanking/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | com.banking 12 | OnlineBanking 13 | 0.0.1-SNAPSHOT 14 | OnlineBanking 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.liquibase 24 | liquibase-core 25 | 26 | 27 | com.common 28 | 0.0.1-SNAPSHOT 29 | BankData 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-batch 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-security 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-web 43 | 44 | 45 | com.google.code.gson 46 | gson 47 | test 48 | 49 | 50 | 51 | 52 | org.springframework.batch 53 | spring-batch-test 54 | test 55 | 56 | 57 | org.springframework.security 58 | spring-security-test 59 | test 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-starter-data-jpa 65 | 66 | 67 | 68 | org.postgresql 69 | postgresql 70 | runtime 71 | 72 | 73 | 74 | 75 | org.apache.commons 76 | commons-lang3 77 | 3.9 78 | 79 | 80 | 81 | 82 | com.fasterxml.uuid 83 | java-uuid-generator 84 | 4.0.1 85 | 86 | 87 | 88 | 89 | javax.servlet 90 | servlet-api 91 | 2.5 92 | provided 93 | 94 | 95 | 96 | javax.ws.rs 97 | javax.ws.rs-api 98 | 2.1.1 99 | 100 | 101 | 102 | org.springframework.boot 103 | spring-boot-starter-test 104 | test 105 | 106 | 107 | com.banking 108 | BackOfficeSystem 109 | 0.0.1-SNAPSHOT 110 | test 111 | 112 | 113 | com.banking 114 | BackOfficeSystem 115 | 0.0.1-SNAPSHOT 116 | test 117 | 118 | 119 | org.liquibase 120 | liquibase-maven-plugin 121 | 3.4.1 122 | 123 | 124 | 125 | 126 | 127 | 128 | org.springframework.boot 129 | spring-boot-maven-plugin 130 | 131 | 132 | org.liquibase 133 | liquibase-maven-plugin 134 | 3.4.1 135 | 136 | src/main/resources/liquibase.properties 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /OnlineBanking/src/main/java/com/banking/OnlineBanking/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.banking.OnlineBanking.config; 2 | 3 | 4 | 5 | import com.common.BankData.dao.CustomerDao; 6 | import com.common.BankData.service.AuthenticationProvider; 7 | import com.common.BankData.service.UserSecurityService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 12 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 13 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 14 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 15 | import org.springframework.security.config.annotation.web.builders.WebSecurity; 16 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 17 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 18 | import org.springframework.security.config.http.SessionCreationPolicy; 19 | import org.springframework.security.crypto.password.PasswordEncoder; 20 | import org.springframework.security.web.authentication.AnonymousAuthenticationFilter; 21 | import org.springframework.security.web.util.matcher.AntPathRequestMatcher; 22 | import org.springframework.security.web.util.matcher.OrRequestMatcher; 23 | import org.springframework.security.web.util.matcher.RequestMatcher; 24 | 25 | @Configuration 26 | @EnableWebSecurity 27 | @EnableJpaRepositories(basePackageClasses = CustomerDao.class) 28 | @EnableGlobalMethodSecurity(prePostEnabled=true) 29 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 30 | 31 | @Autowired 32 | private UserSecurityService userSecurityService; 33 | 34 | AuthenticationProvider provider; 35 | 36 | // @Bean 37 | // public PasswordEncoder passwordEncoder() { 38 | // return new PasswordEncoder(){ 39 | // @Override 40 | // public String encode(CharSequence charSequence) { 41 | // return charSequence.toString(); 42 | // } 43 | // @Override 44 | // public boolean matches(CharSequence chaarSequence, String s) { 45 | // return encode(charSequence).equals(s); 46 | // } 47 | // }; 48 | // } 49 | 50 | private static final RequestMatcher PROTECTED_URLS = new OrRequestMatcher( 51 | new AntPathRequestMatcher("/accounts/**") 52 | ); 53 | 54 | 55 | private static final String[] PUBLIC_MATCHERS = { 56 | "/webjars/**", 57 | "/css/**", 58 | "/js/**", 59 | "/images/**", 60 | "/", 61 | // "/login", 62 | "/about/**", 63 | "/contact/**", 64 | "/error/**/*", 65 | "/console/**", 66 | "/signup" 67 | }; 68 | 69 | @Bean 70 | AuthenticationFilter authenticationFilter() throws Exception { 71 | final AuthenticationFilter filter = new AuthenticationFilter(PROTECTED_URLS); 72 | filter.setAuthenticationManager(authenticationManager()); 73 | return filter; 74 | } 75 | 76 | 77 | public SecurityConfig(final AuthenticationProvider authenticationProvider) { 78 | super(); 79 | this.provider = authenticationProvider; 80 | } 81 | 82 | @Override 83 | protected void configure(final AuthenticationManagerBuilder auth) { 84 | auth.authenticationProvider(provider); 85 | } 86 | 87 | @Override 88 | public void configure(final WebSecurity webSecurity) { 89 | webSecurity.ignoring().antMatchers("/login/**"); 90 | webSecurity.ignoring().antMatchers("**/secured/**"); 91 | } 92 | 93 | 94 | @Override 95 | protected void configure(HttpSecurity http) throws Exception { 96 | 97 | http.sessionManagement() 98 | .sessionCreationPolicy(SessionCreationPolicy.STATELESS) 99 | .and() 100 | .authenticationProvider(provider) 101 | .addFilterBefore(authenticationFilter(), AnonymousAuthenticationFilter.class) 102 | .authorizeRequests() 103 | .requestMatchers(PROTECTED_URLS) 104 | .authenticated() 105 | .and() 106 | .csrf().disable() 107 | .formLogin().disable() 108 | .logout().disable(); 109 | } 110 | 111 | 112 | 113 | @Autowired 114 | public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 115 | // auth.userDetailsService(userSecurityService).passwordEncoder(passwordEncoder()); 116 | } 117 | 118 | } -------------------------------------------------------------------------------- /BackOfficeSystem/src/main/java/com/banking/BackOfficeSystem/controller/AccountController.java: -------------------------------------------------------------------------------- 1 | package com.banking.BackOfficeSystem.controller; 2 | 3 | import com.common.BankData.dao.AccountDao; 4 | import com.common.BankData.dao.CustomerDao; 5 | import com.common.BankData.entity.Account; 6 | import com.common.BankData.entity.Customer; 7 | import com.common.BankData.service.SmsService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.HttpHeaders; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | import java.util.*; 15 | 16 | @RestController 17 | @RequestMapping("/accounts") 18 | public class AccountController { 19 | 20 | @Autowired 21 | AccountDao accountDao; 22 | 23 | @Autowired 24 | CustomerDao customerDao; 25 | 26 | // @Autowired 27 | // SmsService smsService; 28 | 29 | @GetMapping("/getAll") 30 | public ResponseEntity getAllAccounts() throws Exception { 31 | try { 32 | List list = new ArrayList<>(); 33 | list = accountDao.findAll(); 34 | return ResponseEntity.ok(list); 35 | } catch (Exception e) { 36 | System.out.println("Error is " + e); 37 | 38 | return new ResponseEntity<>("Username or password is Wrong", new HttpHeaders(), HttpStatus.UNAUTHORIZED); 39 | } 40 | } 41 | 42 | @PostMapping("/add") 43 | public ResponseEntity addAccount(@RequestBody Account account) throws Exception { 44 | try { 45 | Account acc = accountDao.save(account); 46 | return ResponseEntity.ok(acc); 47 | 48 | } catch (Exception e) { 49 | 50 | System.out.println("Error is " + e); 51 | return new ResponseEntity(HttpStatus.BAD_REQUEST); 52 | } 53 | } 54 | 55 | @GetMapping("/getById/{id}") 56 | public ResponseEntity getById(@PathVariable Long id) throws Exception { 57 | try { 58 | Optional acc = accountDao.findById(id); 59 | return ResponseEntity.ok(acc); 60 | 61 | } catch (Exception e) { 62 | 63 | System.out.println("Error is " + e); 64 | return new ResponseEntity(HttpStatus.BAD_REQUEST); 65 | } 66 | } 67 | 68 | @PutMapping("/update/{id}") 69 | public ResponseEntity updateAccount(@RequestBody Account account, @PathVariable long id) throws Exception { 70 | try { 71 | account.setId(id); 72 | if (account.getAccountStatus() == 3 && account.getAccountId() == 0) { 73 | 74 | boolean b = true; 75 | long number = 0; 76 | 77 | account.setId(id); 78 | account.setAccountStatus(3); 79 | while (b) { 80 | number = (long) (Math.random() * 100000000 * 1000000); 81 | Account existingAcc = accountDao.findByAccountId(number); 82 | if (existingAcc != null) { 83 | continue; 84 | } else { 85 | b = false; 86 | account.setAccountId(number); 87 | 88 | 89 | } 90 | 91 | } 92 | } 93 | Account acc1 = accountDao.saveAndFlush(account); 94 | Set accountSet = new HashSet<>(); 95 | accountSet.add(acc1); 96 | if (acc1 != null && account.getAccountStatus() == 3) { 97 | long customerId = customerDao.getNextCustomerId(); 98 | SmsService smsService = new SmsService(); 99 | char[] charPassword = smsService.generatePassword(10); 100 | String password = new String(charPassword); 101 | // String password = charPassword.toString(); 102 | Customer customer = new Customer(account.getFirstName() + account.getLastName(), 103 | account.getFirstName(), password, accountSet, null, customerId); 104 | customerDao.save(customer); 105 | String message = "your password for Bank Account is " + password; 106 | smsService.sendSms(customerId, String.valueOf(acc1.getPhoneNo()), password); 107 | 108 | 109 | } 110 | return ResponseEntity.ok(acc1); 111 | } catch (Exception e) { 112 | System.out.println("Error is " + e); 113 | return new ResponseEntity<>(e.getMessage(), new HttpHeaders(), HttpStatus.BAD_REQUEST); 114 | } 115 | } 116 | 117 | @GetMapping("/getAllByStatus/{status}") 118 | public ResponseEntity getAllByStatus(@PathVariable int status) { 119 | List list = new ArrayList<>(); 120 | 121 | try { 122 | list = accountDao.findByAccountStatus(new Integer(status)); 123 | return ResponseEntity.ok(list); 124 | } catch (Exception e) { 125 | System.out.println("Error is " + e); 126 | return new ResponseEntity<>(e.getMessage(), new HttpHeaders(), HttpStatus.BAD_REQUEST); 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/entity/Account.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | import com.fasterxml.jackson.annotation.JsonManagedReference; 7 | import com.sun.istack.Nullable; 8 | import org.hibernate.annotations.ColumnDefault; 9 | import org.hibernate.annotations.Generated; 10 | import org.hibernate.annotations.GenerationTime; 11 | 12 | import javax.persistence.*; 13 | import javax.validation.constraints.Null; 14 | import javax.ws.rs.DefaultValue; 15 | import java.sql.Date; 16 | import java.util.List; 17 | 18 | @Entity 19 | //@JsonIgnoreProperties(ignoreUnknown = true) 20 | public class 21 | Account { 22 | 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.AUTO) 25 | private long id; 26 | 27 | private String bankIfsc; 28 | 29 | private String firstName; 30 | private String lastName; 31 | 32 | @ColumnDefault("0") 33 | private long phoneNo; 34 | //@Column(name = "age") 35 | // private int age=0; 36 | 37 | // @DefaultValue("0.0") 38 | // @Column(name="balance") 39 | // private double balance=0.0f; 40 | 41 | @ColumnDefault("0.0") 42 | @Column(name="balance") 43 | private double balance=0.0f; 44 | 45 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") 46 | private Date date; 47 | 48 | 49 | @DefaultValue("0") 50 | private int accountStatus; 51 | 52 | @OneToOne(cascade=CascadeType.ALL) 53 | @JoinColumn(name="proofid") 54 | @JsonManagedReference 55 | private Proof proof; 56 | 57 | // @OneToMany(mappedBy = "primaryAccount", cascade = CascadeType.ALL) 58 | // @JsonIgnore 59 | // private List primaryTransactionList; 60 | 61 | @ManyToOne 62 | private Customer customer; 63 | 64 | public Customer getCustomer() { 65 | return customer; 66 | } 67 | 68 | public void setCustomer(Customer customer) { 69 | this.customer = customer; 70 | } 71 | 72 | @Nullable 73 | private long accountId; 74 | 75 | 76 | 77 | 78 | private String remarks; 79 | 80 | public long getPhoneNo() { 81 | return phoneNo; 82 | } 83 | 84 | public void setPhoneno(long phoneno) { 85 | this.phoneNo = phoneno; 86 | } 87 | 88 | public long getId() { 89 | return id; 90 | } 91 | 92 | public void setId(long id) { 93 | this.id = id; 94 | } 95 | 96 | public long getAccountId() { 97 | return accountId; 98 | } 99 | 100 | public void setAccountId(long accountId) { 101 | this.accountId = accountId; 102 | } 103 | 104 | 105 | public String getBankIfsc() { 106 | return bankIfsc; 107 | } 108 | 109 | public void setBankIfsc(String bankIfsc) { 110 | this.bankIfsc = bankIfsc; 111 | } 112 | 113 | 114 | 115 | // public List getPrimaryTransactionList() { 116 | // return primaryTransactionList; 117 | // } 118 | // 119 | // public void setPrimaryTransactionList(List primaryTransactionList) { 120 | // this.primaryTransactionList = primaryTransactionList; 121 | // } 122 | 123 | public double getBalance() { 124 | return balance; 125 | } 126 | 127 | public void setBalance(double balance) { 128 | this.balance = balance; 129 | } 130 | 131 | public int getAccountStatus() { 132 | return accountStatus; 133 | } 134 | 135 | public void setAccountStatus(int accountStatus) { 136 | this.accountStatus = accountStatus; 137 | } 138 | 139 | public Proof getProof() { 140 | return proof; 141 | } 142 | 143 | public void setProof(Proof proof) { 144 | this.proof = proof; 145 | } 146 | 147 | public String getFirstName() { 148 | return firstName; 149 | } 150 | 151 | public void setFirstName(String firstName) { 152 | this.firstName = firstName; 153 | } 154 | 155 | public String getLastName() { 156 | return lastName; 157 | } 158 | 159 | public void setLastName(String lastName) { 160 | this.lastName = lastName; 161 | } 162 | 163 | 164 | public Date getDate() { 165 | return date; 166 | } 167 | 168 | public void setDate(Date date) { 169 | this.date = date; 170 | } 171 | 172 | public String getRemarks() { 173 | return remarks; 174 | } 175 | 176 | public void setRemarks(String remarks) { 177 | this.remarks = remarks; 178 | } 179 | 180 | 181 | // public void setAge(int age) { 182 | // this.age = age; 183 | // } 184 | 185 | public Account(long id, String bankIfsc, String firstName, String lastName, double balance, Date date, int accountStatus, Proof proof, Customer customer, long accountId, String remarks) { 186 | this.id = id; 187 | this.bankIfsc = bankIfsc; 188 | this.firstName = firstName; 189 | this.lastName = lastName; 190 | this.balance = balance; 191 | this.date = date; 192 | this.accountStatus = accountStatus; 193 | this.proof = proof; 194 | this.customer = customer; 195 | this.accountId = accountId; 196 | this.remarks = remarks; 197 | } 198 | 199 | public Account() { 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /BankData/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /OnlineBanking/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /TransactionScheduling1/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /BankData/src/main/java/com/common/BankData/service/TransferService.java: -------------------------------------------------------------------------------- 1 | package com.common.BankData.service; 2 | 3 | 4 | import com.common.BankData.dao.AccountDao; 5 | import com.common.BankData.dao.OtherBankAccountDao; 6 | import com.common.BankData.dao.ScheduleDao; 7 | import com.common.BankData.dao.TransferDao; 8 | import com.common.BankData.entity.Account; 9 | import com.common.BankData.entity.OtherAccount; 10 | import com.common.BankData.entity.PrimaryTransaction; 11 | import com.common.BankData.entity.Schedule; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | import org.springframework.transaction.annotation.Transactional; 15 | import org.springframework.util.ObjectUtils; 16 | 17 | 18 | import javax.persistence.PersistenceUnit; 19 | import javax.transaction.TransactionScoped; 20 | import java.time.Clock; 21 | import java.time.Instant; 22 | import java.time.LocalDateTime; 23 | import java.util.*; 24 | 25 | @Service 26 | public class TransferService { 27 | 28 | @Autowired 29 | AccountDao accountDao; 30 | 31 | @Autowired 32 | OtherBankAccountDao otherBankAccountDao; 33 | @Autowired 34 | TransferDao transferDao; 35 | 36 | @Autowired 37 | ScheduleDao scheduleDao; 38 | 39 | 40 | 41 | 42 | 43 | @Transactional 44 | public Boolean addMoneyToRecipient(Account recipientAccount, Account primaryAccount, double amount, PrimaryTransaction transaction) throws Exception { 45 | 46 | 47 | try { 48 | double moneyPresent = primaryAccount.getBalance() - amount; 49 | if (moneyPresent > 0) { 50 | 51 | 52 | recipientAccount.setBalance(recipientAccount.getBalance() + amount); 53 | primaryAccount.setBalance(primaryAccount.getBalance() - amount); 54 | 55 | accountDao.save(recipientAccount); 56 | accountDao.save(primaryAccount); 57 | 58 | Date d = new Date(); 59 | Instant instant = Instant.now(); 60 | 61 | LocalDateTime ld=LocalDateTime.now(Clock.systemUTC()); 62 | 63 | PrimaryTransaction pt = new PrimaryTransaction(d, transaction.getDescription(), "completed", transaction.getAmount(), 64 | transaction.getRecipientName(), transaction.getRecipientAccountNo(), transaction.getAccountId(),ld,transaction.getType()); 65 | 66 | transferDao.save(pt); 67 | return true; 68 | 69 | } 70 | } catch (Exception e) { 71 | throw new Exception(e.getMessage()); 72 | } 73 | return false; 74 | } 75 | 76 | @Transactional 77 | public Boolean addMoneyToRecipientOfAnotherBank(OtherAccount recipientAccount, Account primaryAccount, double amount, PrimaryTransaction transaction) throws Exception { 78 | 79 | 80 | try { 81 | double moneyPresent = primaryAccount.getBalance() - amount; 82 | if (moneyPresent > 0) { 83 | 84 | 85 | recipientAccount.setBalance(recipientAccount.getBalance() + amount); 86 | primaryAccount.setBalance(primaryAccount.getBalance() - amount); 87 | 88 | otherBankAccountDao.save(recipientAccount); 89 | accountDao.save(primaryAccount); 90 | 91 | Date d = new Date(); 92 | Instant instant = Instant.now(); 93 | 94 | LocalDateTime ld=LocalDateTime.now(Clock.systemUTC()); 95 | 96 | PrimaryTransaction pt = new PrimaryTransaction(d, transaction.getDescription(), "completed", transaction.getAmount(), 97 | transaction.getRecipientName(), transaction.getRecipientAccountNo(), transaction.getAccountId(),ld,transaction.getType()); 98 | 99 | transferDao.save(pt); 100 | return true; 101 | 102 | } 103 | } catch (Exception e) { 104 | throw new Exception(e.getMessage()); 105 | } 106 | return false; 107 | } 108 | 109 | public Set getTransactionHistoryByAccountID(long accountId) { 110 | List transactionList=new ArrayList<>(); 111 | Set trans=new HashSet<>(); 112 | Set trans1=new HashSet<>(); 113 | trans=transferDao.findByAccountId(accountId); 114 | trans1=transferDao.findByRecipientAccountNo(accountId); 115 | trans.addAll(trans1); 116 | 117 | // transactionList=transferDao.findByAccountId(accountId); 118 | 119 | // List transactionList1=new ArrayList<>(); 120 | // transactionList=transferDao.findByRecipientAccountNo(accountId); 121 | // // transactionList.addAll(transactionList1); 122 | // 123 | // Optional.ofNullable(transactionList1).ifPresent(transactionList::addAll); 124 | 125 | // Collections.sort(trans, new Comparator() { 126 | // public int compare(PrimaryTransaction o1, PrimaryTransaction o2) { 127 | // if (o1.getDate() == null || o2.getDate() == null) 128 | // return 0; 129 | // return o1.getDate().compareTo(o2.getDate()); 130 | // } 131 | // }); 132 | 133 | return trans; 134 | 135 | 136 | 137 | } 138 | 139 | 140 | public void deleteASchedule(Schedule sd) { 141 | 142 | int a=scheduleDao.removeByScheduleid(sd.getScheduleid()); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /BackOfficeSystem/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.io.File; 18 | import java.io.FileInputStream; 19 | import java.io.FileOutputStream; 20 | import java.io.IOException; 21 | import java.net.Authenticator; 22 | import java.net.PasswordAuthentication; 23 | import java.net.URL; 24 | import java.nio.channels.Channels; 25 | import java.nio.channels.ReadableByteChannel; 26 | import java.util.Properties; 27 | 28 | public class MavenWrapperDownloader { 29 | 30 | private static final String WRAPPER_VERSION = "0.5.6"; 31 | /** 32 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 33 | */ 34 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 35 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 36 | 37 | /** 38 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 39 | * use instead of the default one. 40 | */ 41 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 42 | ".mvn/wrapper/maven-wrapper.properties"; 43 | 44 | /** 45 | * Path where the maven-wrapper.jar will be saved to. 46 | */ 47 | private static final String MAVEN_WRAPPER_JAR_PATH = 48 | ".mvn/wrapper/maven-wrapper.jar"; 49 | 50 | /** 51 | * Name of the property which should be used to override the default download url for the wrapper. 52 | */ 53 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 54 | 55 | public static void main(String args[]) { 56 | System.out.println("- Downloader started"); 57 | File baseDirectory = new File(args[0]); 58 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 59 | 60 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 61 | // wrapperUrl parameter. 62 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 63 | String url = DEFAULT_DOWNLOAD_URL; 64 | if (mavenWrapperPropertyFile.exists()) { 65 | FileInputStream mavenWrapperPropertyFileInputStream = null; 66 | try { 67 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 68 | Properties mavenWrapperProperties = new Properties(); 69 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 70 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 71 | } catch (IOException e) { 72 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 73 | } finally { 74 | try { 75 | if (mavenWrapperPropertyFileInputStream != null) { 76 | mavenWrapperPropertyFileInputStream.close(); 77 | } 78 | } catch (IOException e) { 79 | // Ignore ... 80 | } 81 | } 82 | } 83 | System.out.println("- Downloading from: " + url); 84 | 85 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 86 | if (!outputFile.getParentFile().exists()) { 87 | if (!outputFile.getParentFile().mkdirs()) { 88 | System.out.println( 89 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 90 | } 91 | } 92 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 93 | try { 94 | downloadFileFromURL(url, outputFile); 95 | System.out.println("Done"); 96 | System.exit(0); 97 | } catch (Throwable e) { 98 | System.out.println("- Error downloading"); 99 | e.printStackTrace(); 100 | System.exit(1); 101 | } 102 | } 103 | 104 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 105 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 106 | String username = System.getenv("MVNW_USERNAME"); 107 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 108 | Authenticator.setDefault(new Authenticator() { 109 | @Override 110 | protected PasswordAuthentication getPasswordAuthentication() { 111 | return new PasswordAuthentication(username, password); 112 | } 113 | }); 114 | } 115 | URL website = new URL(urlString); 116 | ReadableByteChannel rbc; 117 | rbc = Channels.newChannel(website.openStream()); 118 | FileOutputStream fos = new FileOutputStream(destination); 119 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 120 | fos.close(); 121 | rbc.close(); 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /TransactionScheduling1/src/main/java/com/batch/TransactionScheduling/config/BatchConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.batch.TransactionScheduling.config; 2 | 3 | 4 | 5 | import com.common.BankData.entity.Schedule; 6 | import org.springframework.batch.core.Job; 7 | import org.springframework.batch.core.Step; 8 | import org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer; 9 | import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; 10 | import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; 11 | import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; 12 | import org.springframework.batch.core.launch.support.RunIdIncrementer; 13 | import org.springframework.batch.core.repository.JobRepository; 14 | import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; 15 | import org.springframework.batch.item.database.JdbcCursorItemReader; 16 | import org.springframework.batch.item.file.FlatFileItemWriter; 17 | import org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor; 18 | import org.springframework.batch.item.file.transform.DelimitedLineAggregator; 19 | import org.springframework.beans.factory.annotation.Autowired; 20 | import org.springframework.context.annotation.Bean; 21 | import org.springframework.context.annotation.Configuration; 22 | import org.springframework.context.annotation.Primary; 23 | import org.springframework.core.annotation.Order; 24 | import org.springframework.core.env.Environment; 25 | import org.springframework.core.io.ClassPathResource; 26 | import org.springframework.jdbc.core.RowMapper; 27 | import org.springframework.jdbc.datasource.DriverManagerDataSource; 28 | import org.springframework.orm.jpa.JpaTransactionManager; 29 | import org.springframework.transaction.annotation.Transactional; 30 | 31 | import javax.sql.DataSource; 32 | import javax.ws.rs.Produces; 33 | import java.beans.PropertyVetoException; 34 | import java.sql.ResultSet; 35 | import java.sql.SQLException; 36 | 37 | import java.util.Date; 38 | 39 | 40 | @Configuration 41 | @EnableBatchProcessing 42 | public class BatchConfiguration extends DefaultBatchConfigurer { 43 | 44 | 45 | 46 | // @Autowired 47 | // Environment environment; 48 | // 49 | // 50 | // @Bean 51 | // @Primary 52 | // @Order(1) 53 | // public DataSource datasource() { 54 | // final DriverManagerDataSource dataSource = new DriverManagerDataSource(); 55 | // dataSource.setDriverClassName(environment.getProperty("spring.datasource.driver-class-name")); 56 | // dataSource.setUrl(environment.getProperty("spring.datasource.url")); 57 | // dataSource.setUsername(environment.getProperty("spring.datasource.username")); 58 | // dataSource.setPassword(environment.getProperty("spring.datasource.password")); 59 | // return dataSource; 60 | // } 61 | 62 | @Override 63 | protected JobRepository createJobRepository() throws Exception { 64 | MapJobRepositoryFactoryBean factoryBean = new MapJobRepositoryFactoryBean(); 65 | factoryBean.afterPropertiesSet(); 66 | return factoryBean.getObject(); 67 | } 68 | 69 | @Autowired 70 | public JobBuilderFactory jobBuilderFactory; 71 | 72 | @Autowired 73 | public StepBuilderFactory stepBuilderFactory; 74 | 75 | @Autowired 76 | DataSource datasource; 77 | 78 | 79 | 80 | @Autowired 81 | JpaTransactionManager trxm; 82 | 83 | 84 | @Bean 85 | public JdbcCursorItemReader reader() throws PropertyVetoException { 86 | Date today = new Date(); 87 | JdbcCursorItemReader reader = new JdbcCursorItemReader(); 88 | reader.setDataSource(datasource); 89 | reader.setSql("SELECT scheduleid,accountid,amount,dates,recipientaccountno,recipientName,status,type FROM schedule"); 90 | reader.setRowMapper(new UserRowMapper()); 91 | 92 | return reader; 93 | } 94 | 95 | 96 | public class UserRowMapper implements RowMapper{ 97 | 98 | @Override 99 | public Schedule mapRow(ResultSet rs, int rowNum) throws SQLException { 100 | Schedule schedule = new Schedule(); 101 | schedule.setScheduleid(rs.getInt("scheduleid")); 102 | schedule.setAccountId(rs.getLong("accountid")); 103 | schedule.setAmount(rs.getFloat("amount")); 104 | schedule.setDates(rs.getDate("dates")); 105 | schedule.setRecipientAccountNo(rs.getLong("recipientaccountno")); 106 | schedule.setRecipientName((rs.getString("recipientName"))); 107 | schedule.setStatus(rs.getString("status")); 108 | schedule.setType(rs.getString("type")); 109 | 110 | return schedule; 111 | } 112 | 113 | } 114 | 115 | @Bean 116 | public UserItemProcessor processor(){ 117 | return new UserItemProcessor(); 118 | } 119 | 120 | @Autowired 121 | DBWriter dbWriter; 122 | 123 | @Bean 124 | public FlatFileItemWriter writer(){ 125 | 126 | FlatFileItemWriter writer = new FlatFileItemWriter(); 127 | writer.setResource(new ClassPathResource("users.csv")); 128 | writer.setLineAggregator(new DelimitedLineAggregator() {{ 129 | setDelimiter(","); 130 | setFieldExtractor(new BeanWrapperFieldExtractor() {{ 131 | setNames(new String[] { "id", "name" }); 132 | }}); 133 | }}); 134 | 135 | return writer; 136 | } 137 | 138 | 139 | @Bean 140 | public Step step1() throws PropertyVetoException { 141 | return stepBuilderFactory.get("step1").transactionManager(trxm). chunk(10) 142 | .reader(reader()) 143 | .processor(processor()) 144 | .writer(dbWriter) 145 | .build(); 146 | } 147 | 148 | @Bean 149 | @Transactional 150 | public Job exportUserJob() throws PropertyVetoException { 151 | return jobBuilderFactory.get("exportUserJob") 152 | .incrementer(new RunIdIncrementer()) 153 | .flow(step1()) 154 | .end() 155 | .build(); 156 | } 157 | 158 | } -------------------------------------------------------------------------------- /BankData/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /BackOfficeSystem/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /OnlineBanking/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /TransactionScheduling1/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /OnlineBanking/src/test/java/com/banking/OnlineBanking/controller/CustomerLoginControlllerTest.java: -------------------------------------------------------------------------------- 1 | package com.banking.OnlineBanking.controller; 2 | 3 | import com.banking.OnlineBanking.OnlineBankingApplication; 4 | import com.banking.OnlineBanking.TestUtils; 5 | import com.common.BankData.dao.*; 6 | import com.common.BankData.entity.Account; 7 | import com.common.BankData.entity.Admin; 8 | import com.common.BankData.entity.Customer; 9 | import com.common.BankData.entity.PrimaryTransaction; 10 | import com.common.BankData.service.AuthenticationProvider; 11 | import com.common.BankData.service.TransferService; 12 | import com.fasterxml.jackson.databind.ObjectMapper; 13 | import com.google.gson.reflect.TypeToken; 14 | import org.junit.After; 15 | import org.junit.Assert; 16 | import org.junit.Before; 17 | import org.junit.Test; 18 | import org.junit.jupiter.api.extension.ExtendWith; 19 | import org.junit.runner.RunWith; 20 | import org.mockito.InjectMocks; 21 | import org.mockito.Mock; 22 | import org.mockito.MockitoAnnotations; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 25 | import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; 26 | import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; 27 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 28 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 29 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc; 30 | import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; 31 | import org.springframework.boot.test.context.SpringBootTest; 32 | import org.springframework.boot.test.mock.mockito.MockBean; 33 | import org.springframework.boot.test.web.client.TestRestTemplate; 34 | import org.springframework.http.*; 35 | import org.springframework.mock.web.MockHttpServletRequest; 36 | import org.springframework.test.context.BootstrapWith; 37 | import org.springframework.test.context.ContextConfiguration; 38 | import org.springframework.test.context.TestPropertySource; 39 | import org.springframework.test.context.junit.jupiter.SpringExtension; 40 | import org.springframework.test.context.junit4.SpringRunner; 41 | import org.springframework.test.web.servlet.MockMvc; 42 | import org.springframework.test.web.servlet.MvcResult; 43 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; 44 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers; 45 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 46 | import org.springframework.web.context.WebApplicationContext; 47 | 48 | import javax.servlet.annotation.MultipartConfig; 49 | import java.net.URI; 50 | import java.net.URISyntaxException; 51 | import java.sql.Date; 52 | import java.util.List; 53 | import java.util.Set; 54 | 55 | import static org.junit.Assert.*; 56 | import static org.mockito.ArgumentMatchers.any; 57 | import static org.mockito.Mockito.*; 58 | 59 | //@RunWith(SpringRunner.class) 60 | //@SpringBootTest 61 | //@EnableAutoConfiguration 62 | ////@MultipartConfig 63 | ////@ContextConfiguration(classes = {OnlineBankingApplication.class}) 64 | ////@WebMvcTest(value = CustomerLoginControlller.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class, BootstrapWith.class}) 65 | ////@WebMvcTest(controllers = CustomerLoginControlller.class) 66 | //@ExtendWith(SpringExtension.class) 67 | //@DataJpaTest(excludeAutoConfiguration = BootstrapWith.class) 68 | ////@SpringBootTest(classes = OnlineBankingApplication.class) 69 | //@AutoConfigureMockMvc 70 | //@AutoConfigureTestDatabase(replace= AutoConfigureTestDatabase.Replace.NONE) 71 | // 72 | //@TestPropertySource(properties = { 73 | // "spring.jpa.hibernate.ddl-auto=validate" 74 | //}) 75 | @RunWith(SpringRunner.class) 76 | @WebMvcTest(value = CustomerLoginControlller.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class, BootstrapWith.class}) 77 | //@WebMvcTest(CustomerLoginControlller.class) 78 | @EnableAutoConfiguration 79 | @MultipartConfig 80 | @ContextConfiguration(classes = {OnlineBankingApplication.class}) 81 | public class CustomerLoginControlllerTest { 82 | 83 | 84 | @Autowired 85 | private MockMvc mockMvc; 86 | 87 | // @Before 88 | // public void setUp(){ 89 | // MockitoAnnotations.initMocks(this); 90 | // } 91 | // 92 | // @Before 93 | // public void setUp() { 94 | // mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); 95 | // } 96 | 97 | 98 | // @Autowired 99 | // private MockMvc mockMvc; 100 | 101 | @MockBean 102 | AuthenticationProvider authenticationProvider; 103 | 104 | 105 | 106 | 107 | @MockBean 108 | Customer customer; 109 | 110 | @MockBean 111 | AccountDao accountDao; 112 | 113 | @MockBean 114 | TransferService transferService; 115 | 116 | @MockBean 117 | CustomerDao customerDao; 118 | 119 | @MockBean 120 | TransferDao transferDao; 121 | 122 | @MockBean 123 | OtherBankAccountDao otherBankAccountDao; 124 | 125 | @MockBean 126 | ScheduleDao scheduleDao; 127 | 128 | 129 | @MockBean 130 | AdminDao adminDao; 131 | 132 | 133 | 134 | // @Mock 135 | // PolicyService policyService; 136 | 137 | // @InjectMocks 138 | // CustomerLoginControlller customerLoginControlller; 139 | 140 | 141 | 142 | @Before 143 | public void setup() { 144 | 145 | // this must be called for the @Mock annotations above to be processed 146 | // and for the mock service to be injected into the controller under 147 | // test. 148 | // MockitoAnnotations.initMocks(this); 149 | // this.mockMvc = MockMvcBuilders.standaloneSetup(customerLoginControlller).build(); 150 | 151 | } 152 | 153 | 154 | 155 | @After 156 | public void tearDown() throws Exception { 157 | } 158 | 159 | 160 | public static String asJsonString(final Object obj) { 161 | try { 162 | return new ObjectMapper().writeValueAsString(obj); 163 | } catch (Exception e) { 164 | throw new RuntimeException(e); 165 | } 166 | } 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | @Test 175 | public void testGenerateToken() throws Exception { 176 | CustomerDao customerDao = mock(CustomerDao.class); 177 | 178 | Customer customer= new Customer(1,"Saurabh", "Saurabh", "Fnb@2021" ,null, "c6e336bf-5cb4-4c7d-9d80-dcc66738973a",0) ; 179 | when(customerDao.findByUserNameContainingIgnoreCase("Saurabh")).thenReturn(customer); 180 | 181 | 182 | // mock(customerDao); 183 | HttpHeaders headers = new HttpHeaders(); 184 | headers.set("Authorization", "Basic U2F1cmFiaDpGbmJAMjAyMQ=="); 185 | // MockHttpServletRequest request = new MockHttpServletRequest(); 186 | // request.addHeader("x-real-ip","127.0.0.1"); 187 | String header="Authorization:" +"Basic c2F1cmFiaDpGbmJAMjAyMQ=="; 188 | MvcResult result= mockMvc.perform( MockMvcRequestBuilders 189 | .post("/login/customer/api/secured/token").header("Authorization", "Basic c2F1cmFiaDpGbmJAMjAyMQ==") 190 | // .header("Authorization", "Basic c2F1cmFiaDpGbmJAMjAyMQ==") 191 | ).andReturn(); 192 | 193 | 194 | int status = result.getResponse().getStatus(); 195 | // assertEquals("Incorrect Response Status", HttpStatus.OK.value(), status); 196 | 197 | // verify that service method was called once 198 | // verify(customerDao).findByUserNameContainingIgnoreCase(any(String.class)); 199 | 200 | // Customer customer1 = TestUtils.jsonToObject(result.getResponse().getContentAsString(), Customer.class); 201 | assertEquals("Fnb@2021", customer.getPassword()); 202 | 203 | } 204 | } -------------------------------------------------------------------------------- /OnlineBanking/src/test/java/com/banking/OnlineBanking/controller/TransferControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.banking.OnlineBanking.controller; 2 | 3 | import com.banking.OnlineBanking.TestUtils; 4 | import com.banking.OnlineBanking.config.SecurityConfig; 5 | import com.common.BankData.dao.*; 6 | import com.common.BankData.entity.Account; 7 | import com.common.BankData.entity.Customer; 8 | import com.common.BankData.entity.PrimaryTransaction; 9 | import com.common.BankData.service.AdminService; 10 | import com.common.BankData.service.AuthenticationProvider; 11 | import com.common.BankData.service.TransferService; 12 | import com.fasterxml.jackson.databind.ObjectMapper; 13 | import com.google.gson.reflect.TypeToken; 14 | import org.junit.Test; 15 | import org.junit.runner.RunWith; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 18 | import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; 19 | import org.springframework.boot.test.mock.mockito.MockBean; 20 | import org.springframework.boot.test.mock.mockito.MockBeans; 21 | import org.springframework.context.annotation.ComponentScan; 22 | import org.springframework.context.annotation.Configuration; 23 | import org.springframework.http.HttpStatus; 24 | import org.springframework.http.MediaType; 25 | import org.springframework.test.context.junit4.SpringRunner; 26 | import org.springframework.test.web.servlet.MockMvc; 27 | import org.springframework.test.web.servlet.MvcResult; 28 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; 29 | 30 | import javax.servlet.annotation.MultipartConfig; 31 | import java.sql.Date; 32 | import java.util.Arrays; 33 | import java.util.HashSet; 34 | import java.util.List; 35 | import java.util.Set; 36 | 37 | 38 | import static org.junit.Assert.*; 39 | import static org.mockito.Matchers.any; 40 | import static org.mockito.Mockito.verify; 41 | import static org.mockito.Mockito.when; 42 | 43 | @RunWith(SpringRunner.class) 44 | @WebMvcTest(TransferController.class) 45 | @EnableAutoConfiguration 46 | @MultipartConfig 47 | public class TransferControllerTest { 48 | 49 | @Autowired 50 | private MockMvc mockMvc; 51 | 52 | @MockBean 53 | AuthenticationProvider authenticationProvider; 54 | 55 | // @MockBean 56 | // SecurityConfig securityConfig; 57 | 58 | @MockBean 59 | CustomerDao customerDao; 60 | 61 | @MockBean 62 | AccountDao accountDao; 63 | 64 | @MockBean 65 | TransferService transferService; 66 | 67 | @MockBean 68 | TransferDao transferDao; 69 | 70 | @MockBean 71 | OtherBankAccountDao otherBankAccountDao; 72 | 73 | @MockBean 74 | ScheduleDao scheduleDao; 75 | 76 | @MockBean 77 | AdminDao adminDao; 78 | 79 | @MockBean 80 | AdminService adminService; 81 | 82 | 83 | private final String URL = "/transfer/balance/"; 84 | 85 | public static String asJsonString(final Object obj) { 86 | try { 87 | return new ObjectMapper().writeValueAsString(obj); 88 | } catch (Exception e) { 89 | throw new RuntimeException(e); 90 | } 91 | } 92 | 93 | 94 | @Test 95 | public void betweenAccounts() throws Exception { 96 | 97 | PrimaryTransaction e1 = new PrimaryTransaction(null, "hello", "completed", 12323, "Sameer", 28339960751126l, 28339960751126l, null, "Normal Payment"); 98 | 99 | 100 | final String URLTransactionList = "/transfer/betweenAccounts"; 101 | // prepare data and mock's behaviour 102 | Set empList = buildTransaction(); 103 | // transferService.getTransactionHistoryByAccountID(accountId); 104 | // when(transferDao.findByAccountId(28339960751126L)).thenReturn((Set) empList); 105 | 106 | // execute 107 | MvcResult result = mockMvc.perform(MockMvcRequestBuilders.post(URLTransactionList).header("Authorization", "") 108 | .content(asJsonString( 109 | e1 110 | )) 111 | .contentType(MediaType.APPLICATION_JSON) 112 | .accept(MediaType.APPLICATION_JSON)) 113 | .andReturn(); 114 | 115 | // verify 116 | int status = result.getResponse().getStatus(); 117 | assertEquals("Incorrect Response Status", HttpStatus.OK.value(), status); 118 | 119 | // verify that service method was called once 120 | // verify(transferService).getTransactionHistoryByAccountID(any(Long.class)); 121 | 122 | // get the List from the Json response 123 | 124 | 125 | // Account resultEmployee = TestUtils.jsonToObject(result.getResponse().getContentAsString(), Account.class); 126 | // 127 | // 128 | // assertEquals("Incorrect Response Status", HttpStatus.OK.value(), result.getResponse().getStatus()); 129 | // assertNotNull("Employees not found", empListResult); 130 | // assertEquals("Incorrect Employee List", empList.size(), 2); 131 | 132 | } 133 | 134 | @Test 135 | public void getTransactionList() throws Exception { 136 | final String URLTransactionList = "/transfer/transactionHistory/28339960751126"; 137 | // prepare data and mock's behaviour 138 | Set empList = buildTransaction(); 139 | // transferService.getTransactionHistoryByAccountID(accountId); 140 | when(transferDao.findByAccountId(28339960751126L)).thenReturn((Set) empList); 141 | 142 | // execute 143 | MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(URLTransactionList).accept(MediaType.APPLICATION_JSON_UTF8)) 144 | .andReturn(); 145 | 146 | // verify 147 | int status = result.getResponse().getStatus(); 148 | assertEquals("Incorrect Response Status", HttpStatus.OK.value(), status); 149 | 150 | // verify that service method was called once 151 | verify(transferService).getTransactionHistoryByAccountID(any(Long.class)); 152 | 153 | // get the List from the Json response 154 | TypeToken> token = new TypeToken>() { 155 | }; 156 | @SuppressWarnings("unchecked") 157 | List empListResult = TestUtils.jsonToList(result.getResponse().getContentAsString(), token); 158 | 159 | for (PrimaryTransaction empList1 : empListResult 160 | ) { 161 | System.out.println(empList1); 162 | 163 | } 164 | 165 | 166 | // assertNotNull("Employees not found", empListResult); 167 | assertEquals("Incorrect Employee List", empList.size(), 2); 168 | } 169 | 170 | private Set buildTransaction() { 171 | PrimaryTransaction e1 = new PrimaryTransaction(null, "hello", "completed", 12323, "Sameer", 28339960751126l, 28339960751126l, null, "Normal Payment"); 172 | PrimaryTransaction e2 = new PrimaryTransaction(null, "hello", "completed", 12323, "Sameer", 28339960751126l, 28339960751126l, null, "Normal Payment"); 173 | Set trans = new HashSet<>(); 174 | // Employee e2 = new Employee(2l, "bytes2", "tree2", "Senior developer", 16000); 175 | trans.add(e1); 176 | trans.add(e2); 177 | return trans; 178 | } 179 | 180 | 181 | @Test 182 | public void getBalance() throws Exception { 183 | 184 | String str = "2020-04-06"; 185 | Date date = Date.valueOf(str); 186 | 187 | Account account = new Account(182, null, "Saurabh", "Mishra", 1553.23, date, 3, null, null, 28339960751126L, "Applied approved"); 188 | 189 | // prepare data and mock's behaviour 190 | // Employee empStub = new Employee(1l, "bytes", "tree", "developer", 12000); 191 | when(accountDao.findByAccountId(any(Long.class))).thenReturn(account); 192 | 193 | // execute 194 | MvcResult result = mockMvc 195 | .perform(MockMvcRequestBuilders.get(URL + "{id}", new Long(28339960751126l)).accept(MediaType.APPLICATION_JSON_UTF8)) 196 | .andReturn(); 197 | 198 | // verify 199 | int status = result.getResponse().getStatus(); 200 | assertEquals("Incorrect Response Status", HttpStatus.OK.value(), status); 201 | 202 | // verify that service method was called once 203 | verify(accountDao).findByAccountId(any(Long.class)); 204 | 205 | Account resultEmployee = TestUtils.jsonToObject(result.getResponse().getContentAsString(), Account.class); 206 | assertNotNull(resultEmployee); 207 | assertEquals(28339960751126l, resultEmployee.getAccountId()); 208 | } 209 | 210 | 211 | } -------------------------------------------------------------------------------- /BankData/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | --------------------------------------------------------------------------------