first commit 04/09/2024

This commit is contained in:
2024-09-04 23:47:46 +01:00
commit d5b0cc996c
38 changed files with 1968 additions and 0 deletions
Executable
+112
View File
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>saslPay</groupId>
<artifactId>saslPay</artifactId>
<version>2.0.0</version>
<packaging>jar</packaging>
<name>saslPay</name>
<description>sasl Pay</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.8.0</version>
</dependency>
<!-- For Spring Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!--<scope>5.1.38</scope>-->
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.5.3.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.5.3.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<!-- For Spring Security -->
<dependency>
<groupId>com.jbase.jremote</groupId>
<artifactId>jremote</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework</groupId>-->
<!-- <artifactId>spring-tx</artifactId>-->
<!-- <version>5.3.15</version>-->
<!-- </dependency>-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
+13
View File
@@ -0,0 +1,13 @@
package com.saslpay;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SaslPay {
public static void main(String[] args) {
SpringApplication.run(SaslPay.class, args);
}
}
@@ -0,0 +1,29 @@
//package com.saslpay.authenticator;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
//@RestController
//@RequestMapping("/cbs/security")
//public class GetAuthDetails {
// String authToken;
//
// @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE, value = "/getToken")
// public String getToken(@RequestHeader(value="User-Agent") String userAgent,@RequestHeader(value="username") String username,
// @RequestHeader(value = "password") String password) {
//
// JbcProcessor jbcProcessor = new JbcProcessor();
//
// String getToken = "getToken|" + username + "!!" + password;
//
// try {
// authToken = jbcProcessor.callRoutine(getToken);
// } catch (NullPointerException e) {
// authToken = "{\"errorMsg\" :\"" + e.getLocalizedMessage() + " - Contact Sinapi\"}";
// return authToken;
// }
// return authToken;
// }
//}
@@ -0,0 +1,84 @@
package com.saslpay.authenticator;
import com.saslpay.config.JwtTokenUtil;
import com.saslpay.datacapture.JwtRequest;
import com.saslpay.datacapture.JwtResponse;
import com.saslpay.entities.UserEntity;
import com.saslpay.impl.JwtUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.DisabledException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;
import org.json.simple.JSONObject;
import java.time.LocalDateTime;
import java.sql.Date;
import java.sql.Time;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@RestController
@RequestMapping("/cbs")
@CrossOrigin
public class JwtAuthenticationController {
LocalDate localDate;
LocalDateTime tokenInitTime;
@Autowired
private AuthenticationManager authenticationManager;
@Autowired
private JwtTokenUtil jwtTokenUtil;
@Autowired
private JwtUserDetailsService userDetailsService;
// @RequestMapping(value = "security/getToken", method = RequestMethod.GET)
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE, value = "security/getToken")
public String createAuthenticationToken( String userAgent,@RequestHeader(value="username") String username, @RequestHeader(value = "password") String password) throws Exception {
// public String createAuthenticationToken(@RequestBody JwtRequest authenticationRequest) throws Exception {
authenticate(username, password);
//authenticate(authenticationRequest.getUsername(), authenticationRequest.getPassword());
final UserDetails userDetails = userDetailsService
// .loadUserByUsername(authenticationRequest.getUsername());
.loadUserByUsername(username);
localDate = LocalDate.parse(new Date(System.currentTimeMillis()).toString(), DateTimeFormatter.ISO_LOCAL_DATE);
tokenInitTime = localDate.atTime(new Time((System.currentTimeMillis())).toLocalTime());
tokenInitTime = tokenInitTime.plusHours(24);
final String token = jwtTokenUtil.generateToken(userDetails);
JSONObject object = new JSONObject();
object.put("authToken", token);
object.put("Status", "00");
object.put("validUntil", tokenInitTime.toString());
return "" + object + "";
// return ResponseEntity.ok(new JwtResponse(token));
}
@RequestMapping(value = "/register", method = RequestMethod.POST)
public ResponseEntity<?> saveUser(@RequestBody UserEntity user) throws Exception {
return ResponseEntity.ok(userDetailsService.save(user));
}
private void authenticate(String username, String password) throws Exception {
try {
authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password));
} catch (DisabledException e) {
throw new Exception("USER_DISABLED", e);
} catch (BadCredentialsException e) {
throw new Exception("INVALID_CREDENTIALS", e);
}
}
}
+23
View File
@@ -0,0 +1,23 @@
package com.saslpay.config;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
@Service
public class
BeanUtil implements ApplicationContextAware {
private static ApplicationContext context;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}
public static <T> T getBean(Class<T> beanClass) {
return context.getBean(beanClass);
}
}
+29
View File
@@ -0,0 +1,29 @@
package com.saslpay.config;
import com.saslpay.datacapture.AccountDataCapture;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class BuildRoute extends RouteBuilder {
@Value("${interface.in.folder}") String inFolder;
public void configure() {
inFolder = "file:" + "./app/intxns" + "?delete=true&readLock=changed&readLockMinAge=5s";
from(inFolder).routeId("Account Update").log("Updating Account").streamCaching().process(exchange -> {
String body = exchange.getIn().getBody(String.class);
// inFileName = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
AccountDataCapture accountDataCapture = new AccountDataCapture();
accountDataCapture.importer(body);
}).log("Account Update Completed");
// outFolder = "file:" + outFolder + "?delete=true&readLock=changed&readLockMinAge=5s";
// from(outFolder).log("out...").streamCaching().process(exchange -> {
// String body = exchange.getIn().getBody(String.class);
// outFileName = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
// }).log("processing... " + outFileName + " done...");
}
}
+33
View File
@@ -0,0 +1,33 @@
package com.saslpay.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ConfigClass {
@Value("${t24.host}")
public String host;
@Value("${t24.jbcRoutine}")
public String jbcRoutine;
@Value("${t24.port}")
public int port;
@Bean
public String getJbcRoutine() {
return jbcRoutine;
}
@Bean
public int getPort() {
return port;
}
@Bean
public String getHost(){
return host;
}
}
+48
View File
@@ -0,0 +1,48 @@
package com.saslpay.config;
import com.jbase.jremote.DefaultJConnectionFactory;
import com.jbase.jremote.JConnection;
import com.jbase.jremote.JRemoteException;
import com.saslpay.log.SaslPayLog;
public class ConnectionClass {
static JConnection conn;
static DefaultJConnectionFactory jbaseConn = new DefaultJConnectionFactory();;
boolean statement;
ConfigClass configClass = BeanUtil.getBean(ConfigClass.class);
String host = configClass.getHost();
int port = configClass.getPort();
public JConnection tafcConnect() {
jbaseConn.setHost(host);
jbaseConn.setPort(port);
SaslPayLog saslPayLog = new SaslPayLog();
if (conn != null) {
try {
statement = conn.echo(1);
} catch (JRemoteException e) {
saslPayLog.log("{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}");
}finally {
if (!statement) {
conn = null;
}
}
} else {
try{
saslPayLog.log("Connecting to " + host + "...");
conn = jbaseConn.getConnection();
saslPayLog.log("Connected to " + host);
}catch (NullPointerException | JRemoteException e){
saslPayLog.log("{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}");
}
}
return conn;
}
}
+76
View File
@@ -0,0 +1,76 @@
package com.saslpay.config;
import org.hibernate.jpa.HibernatePersistenceProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.sql.DataSource;
import java.util.Properties;
@Configuration
@EnableJpaRepositories(basePackages = "com.saslpay.*", transactionManagerRef = "jpaTransactionManager")
@PropertySource(value = {"classpath:application.properties"})
@EnableTransactionManagement
public class JpaConfig {
private static final String[] ENTITYMANAGER_PACKAGES_TO_SCAN = {"com.saslpay.*"};
@Autowired
private Environment env;
String dialect;
@Bean
public DataSource dataSource() {
String username = env.getProperty("spring.datasource.username");
String password = env.getProperty("spring.datasource.password");
// String driverClass = env.getProperty("spring.datasource.driver");
String url = env.getProperty("spring.datasource.url");
dialect = env.getProperty("spring.jpa.database-platform");
return DataSourceBuilder.create().username(username).password(password).url(url).build();
//driverClassName(driverClass).build();
}
@Bean
public JpaTransactionManager jpaTransactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
return transactionManager;
}
//adding for future use
private HibernateJpaVendorAdapter vendorAdaptor() {
return new HibernateJpaVendorAdapter();
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setJpaVendorAdapter(vendorAdaptor());
entityManagerFactoryBean.setDataSource(dataSource());
entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class);
entityManagerFactoryBean.setPackagesToScan(ENTITYMANAGER_PACKAGES_TO_SCAN);
entityManagerFactoryBean.setJpaProperties(addProperties());
return entityManagerFactoryBean;
}
private Properties addProperties() {
Properties properties = new Properties();
properties.setProperty("hibernate.hbm2ddl.auto", "none");
properties.setProperty("hibernate.dialect", dialect);
properties.setProperty("hibernate.show_sql", "false");
// we can add
return properties;
}
}
@@ -0,0 +1,27 @@
package com.saslpay.config;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
@Component
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable {
private static final long serialVersionUID = -7858869558953243875L;
@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException authException) {
try {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
} catch (IOException e) {
e.getLocalizedMessage();
}
}
}
+78
View File
@@ -0,0 +1,78 @@
package com.saslpay.config;
import com.saslpay.impl.JwtUserDetailsService;
import io.jsonwebtoken.ExpiredJwtException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Component
public class JwtRequestFilter extends OncePerRequestFilter {
@Autowired
private JwtUserDetailsService jwtUserDetailsService;
@Autowired
private JwtTokenUtil jwtTokenUtil;
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
final String requestTokenHeader = request.getHeader("Authorization");
String username = null;
String jwtToken = null;
// JWT Token is in the form "Bearer token". Remove Bearer word and get
// only the Token
//if (requestTokenHeader != null && requestTokenHeader.startsWith("Bearer ")) {
if (requestTokenHeader != null) {
// jwtToken = requestTokenHeader.substring(7);
jwtToken = requestTokenHeader;
try {
username = jwtTokenUtil.getUsernameFromToken(jwtToken);
} catch (IllegalArgumentException e) {
System.out.println("Unable to get JWT Token");
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unable To Get Token");
} catch (ExpiredJwtException e) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Token Expired");
System.out.println("JWT Token has expired");
}
} else {
//response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid Token");
logger.warn("JWT Token does not begin with Bearer String");
}
// Once we get the token validate it.
if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
UserDetails userDetails = this.jwtUserDetailsService.loadUserByUsername(username);
// if token is valid configure Spring Security to manually set
// authentication
if (jwtTokenUtil.validateToken(jwtToken, userDetails)) {
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(
userDetails, null, userDetails.getAuthorities());
usernamePasswordAuthenticationToken
.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
// After setting the Authentication in the context, we specify
// that the current user is authenticated. So it passes the
// Spring Security Configurations successfully.
SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
}
}
chain.doFilter(request, response);
}
}
+74
View File
@@ -0,0 +1,74 @@
package com.saslpay.config;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
@Component
public class JwtTokenUtil implements Serializable {
private static final long serialVersionUID = -2550185165626007488L;
public static final long JWT_TOKEN_VALIDITY = 24 * 60 * 60;
@Value("${jwt.secret}")
private String secret;
//retrieve username from jwt token
public String getUsernameFromToken(String token) {
return getClaimFromToken(token, Claims::getSubject);
}
//retrieve expiration date from jwt token
public Date getExpirationDateFromToken(String token) {
return getClaimFromToken(token, Claims::getExpiration);
}
public <T> T getClaimFromToken(String token, Function<Claims, T> claimsResolver) {
final Claims claims = getAllClaimsFromToken(token);
return claimsResolver.apply(claims);
}
//for retrieveing any information from token we will need the secret key
private Claims getAllClaimsFromToken(String token) {
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
}
//check if the token has expired
private Boolean isTokenExpired(String token) {
final Date expiration = getExpirationDateFromToken(token);
return expiration.before(new Date());
}
//generate token for user
public String generateToken(UserDetails userDetails) {
Map<String, Object> claims = new HashMap<>();
return doGenerateToken(claims, userDetails.getUsername());
}
//while creating the token -
//1. Define claims of the token, like Issuer, Expiration, Subject, and the ID
//2. Sign the JWT using the HS512 algorithm and secret key.
//3. According to JWS Compact Serialization(https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-41#section-3.1)
// compaction of the JWT to a URL-safe string
private String doGenerateToken(Map<String, Object> claims, String subject) {
return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis()))
.setExpiration(new Date(System.currentTimeMillis() + JWT_TOKEN_VALIDITY * 1000))
.signWith(SignatureAlgorithm.HS512, secret).compact();
}
//validate token
public Boolean validateToken(String token, UserDetails userDetails) {
final String username = getUsernameFromToken(token);
return (username.equals(userDetails.getUsername()) && !isTokenExpired(token));
}
}
+75
View File
@@ -0,0 +1,75 @@
package com.saslpay.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
final UserDetailsService jwtUserDetailsService;
final JwtRequestFilter jwtRequestFilter;
@Override
protected AuthenticationManager authenticationManager() {
return null;
}
public WebSecurityConfig(JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint, UserDetailsService jwtUserDetailsService, JwtRequestFilter jwtRequestFilter) {
this.jwtAuthenticationEntryPoint = jwtAuthenticationEntryPoint;
this.jwtUserDetailsService = jwtUserDetailsService;
this.jwtRequestFilter = jwtRequestFilter;
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// configure AuthenticationManager so that it knows from where to load
// user for matching credentials
// Use BCryptPasswordEncoder
auth.userDetailsService(jwtUserDetailsService).passwordEncoder(passwordEncoder());
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
// We don't need CSRF for this example
httpSecurity.csrf().disable()
// dont authenticate this particular request
.authorizeRequests().antMatchers("/cbs/security/getToken", "/cbs/register").permitAll().
// all other requests need to be authenticated
anyRequest().authenticated().and().
// make sure we use stateless session; session won't be used to
// store user's state.
exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint).and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
// Add a filter to validate the tokens with every request
httpSecurity.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
}
}
@@ -0,0 +1,35 @@
package com.saslpay.controller;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/get/accountCustomerDetails")
public class AccontCustomerDetails {
String accountCustomerDetails;
SaslPayLog saslPayLog = new SaslPayLog();
@GetMapping(value="/{account}" , produces = MediaType.APPLICATION_JSON_VALUE)
public String getAccountCustomerDetails(@PathVariable String account) {
JbcProcessor jbcProcessor = new JbcProcessor();
String request = "getCusAc|" + account;
saslPayLog.log(account);
try {
accountCustomerDetails = jbcProcessor.callRoutine(request);
} catch (NullPointerException e) {
accountCustomerDetails = "{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}";
saslPayLog.log("{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}");
return accountCustomerDetails;
}
saslPayLog.log(accountCustomerDetails);
return accountCustomerDetails;
}
}
+34
View File
@@ -0,0 +1,34 @@
package com.saslpay.controller;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/get/accountList")
public class AccountList {
String accountList;
SaslPayLog saslPayLog = new SaslPayLog();
@GetMapping(value="/{account}" , produces = MediaType.APPLICATION_JSON_VALUE)
public String getAccountCustomerDetails(@PathVariable String account) {
JbcProcessor jbcProcessor = new JbcProcessor();
String request = "getAcList|" + account;
saslPayLog.log(account);
try {
accountList = jbcProcessor.callRoutine(request);
} catch (NullPointerException e) {
accountList = "{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}";
return accountList;
}
saslPayLog.log(accountList);
return accountList;
}
}
+34
View File
@@ -0,0 +1,34 @@
package com.saslpay.controller;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/get/balance")
public class BalanceRequest {
String accountBalance;
SaslPayLog saslPayLog = new SaslPayLog();
@GetMapping(value="/{account}" , produces = MediaType.APPLICATION_JSON_VALUE)
public String getBalance(@PathVariable String account) {
JbcProcessor jbcProcessor = new JbcProcessor();
String request = "reqBalance|" + account;
saslPayLog.log(account);
try {
accountBalance = jbcProcessor.callRoutine(request);
} catch (NullPointerException e) {
accountBalance = "{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}";
return accountBalance;
}
saslPayLog.log(accountBalance);
return accountBalance;
}
}
+33
View File
@@ -0,0 +1,33 @@
package com.saslpay.controller;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/get/branchList")
public class BranchList {
String branchList;
SaslPayLog saslPayLog = new SaslPayLog();
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public String getAccountCustomerDetails() {
JbcProcessor jbcProcessor = new JbcProcessor();
String request = "getBranchList";
try {
branchList = jbcProcessor.callRoutine(request);
} catch (NullPointerException e) {
branchList = "{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}";
saslPayLog.log("{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}");
return branchList;
}
saslPayLog.log(branchList);
return branchList;
}
}
+33
View File
@@ -0,0 +1,33 @@
package com.saslpay.controller;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/get/customerDetails")
public class CustomerDetails {
String customerDetails;
SaslPayLog saslPayLog = new SaslPayLog();
@GetMapping(value="/{customerNo}" , produces = MediaType.APPLICATION_JSON_VALUE)
public String getCustomerDetails(@PathVariable String customerNo) {
JbcProcessor jbcProcessor = new JbcProcessor();
String request = "getCusDets|" + customerNo;
saslPayLog.log(customerNo);
try {
customerDetails = jbcProcessor.callRoutine(request);
} catch (NullPointerException e) {
customerDetails = "{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}";
return customerDetails;
}
saslPayLog.log(customerDetails);
return customerDetails;
}
}
+81
View File
@@ -0,0 +1,81 @@
package com.saslpay.controller;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/post")
public class ExternalReversal {
String errorMessage;
String txnCode;
String ourTxnRef;
String otherTxnRef;
String hold;
String bankWallet;
String customerName;
String customerBranch;
String drAccount;
String crAccount;
String txnCurrency;
String txnAmount;
String txnCharge;
String txnNarration;
String reversal;
String api;
String requestType;
String txnRef;
String ftRef;
SaslPayLog saslPayLog = new SaslPayLog();
@PostMapping(value ="/extreversal" ,produces = MediaType.APPLICATION_JSON_VALUE)
public String reversal(@RequestBody String request) {
JbcProcessor jbcProcessor = new JbcProcessor();
JsonElement jsonElementAuth = JsonParser.parseString(request);
JsonObject jsonObjectAuth = jsonElementAuth.getAsJsonObject();
saslPayLog.log(request);
try {
txnCode = jsonObjectAuth.get("txnCode").getAsString();
api = jsonObjectAuth.get("api").getAsString();
requestType = jsonObjectAuth.get("requestType").getAsString();
ftRef = jsonObjectAuth.get("ourTxnRef").getAsString();
txnRef = jsonObjectAuth.get("otherTxnRef").getAsString();
hold = jsonObjectAuth.get("hold").getAsString();
bankWallet = jsonObjectAuth.get("bankWallet").getAsString();
customerName = jsonObjectAuth.get("customerName").getAsString();
customerBranch = jsonObjectAuth.get("customerBranch").getAsString();
drAccount = jsonObjectAuth.get("drAccount").getAsString();
crAccount = jsonObjectAuth.get("crAccount").getAsString();
txnCurrency = jsonObjectAuth.get("txnCurrency").getAsString();
txnAmount = jsonObjectAuth.get("txnAmount").getAsString();
txnCharge = jsonObjectAuth.get("txnCharge").getAsString();
txnNarration = jsonObjectAuth.get("txnNarration").getAsString();
}catch (NullPointerException e){
errorMessage = e.getLocalizedMessage();
}
String passedString = txnCode + "!!" + api + "!!" + requestType + "!!" + ftRef + "!!" + txnRef + "!!" + hold + "!!" + bankWallet + "!!" + customerName + "!!" +
customerBranch + "!!" + drAccount + "!!" + crAccount + "!!" + txnCurrency + "!!" + txnAmount + "!!" +
txnCharge + "!!" + txnNarration;
request = "extReversal|" + passedString;
try {
reversal = jbcProcessor.callRoutine(request);
} catch (NullPointerException e) {
reversal = "{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}";
return reversal;
}
saslPayLog.log(reversal);
return reversal;
}
}
+85
View File
@@ -0,0 +1,85 @@
package com.saslpay.controller;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/post")
public class ExternalTransfer {
String errorMessage;
String txnCode;
String txnRef;
String ftRef;
String hold;
String bankWallet;
String customerName;
String customerBranch;
String drAccount;
String crAccount;
String txnCurrency;
String txnAmount;
String txnCharge;
String txnNarration;
String transfer;
String api;
String requestType;
String elevyCharge;
SaslPayLog saslPayLog = new SaslPayLog();
@PostMapping(value ="/exttransfer" ,produces = MediaType.APPLICATION_JSON_VALUE)
public String transfer(@RequestBody String request) {
JbcProcessor jbcProcessor = new JbcProcessor();
JsonElement jsonElementAuth = JsonParser.parseString(request);
JsonObject jsonObjectAuth = jsonElementAuth.getAsJsonObject();
saslPayLog.log(request);
try {
txnCode = jsonObjectAuth.get("txnCode").getAsString();
api = jsonObjectAuth.get("api").getAsString();
requestType = jsonObjectAuth.get("requestType").getAsString();
ftRef = jsonObjectAuth.get("ourTxnRef").getAsString();
txnRef = jsonObjectAuth.get("otherTxnRef").getAsString();
hold = jsonObjectAuth.get("hold").getAsString();
bankWallet = jsonObjectAuth.get("bankWallet").getAsString();
customerName = jsonObjectAuth.get("customerName").getAsString();
customerBranch = jsonObjectAuth.get("customerBranch").getAsString();
drAccount = jsonObjectAuth.get("drAccount").getAsString();
crAccount = jsonObjectAuth.get("crAccount").getAsString();
txnCurrency = jsonObjectAuth.get("txnCurrency").getAsString();
txnAmount = jsonObjectAuth.get("txnAmount").getAsString();
txnCharge = jsonObjectAuth.get("txnCharge").getAsString();
txnNarration = jsonObjectAuth.get("txnNarration").getAsString();
elevyCharge = jsonObjectAuth.get("elevyCharge").getAsString();
}catch (NullPointerException e){
errorMessage = e.getLocalizedMessage();
}
String passedString = txnCode + "!!" + api + "!!" + requestType + "!!" + ftRef + "!!" + txnRef + "!!" + hold + "!!" + bankWallet + "!!" + customerName + "!!" +
customerBranch + "!!" + drAccount + "!!" + crAccount + "!!" + txnCurrency + "!!" + txnAmount + "!!" +
txnCharge + "!!" + txnNarration + "!!"+ elevyCharge;
request = "extTransfer|" + passedString;
try {
transfer = jbcProcessor.callRoutine(request);
} catch (NullPointerException e) {
transfer = "{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}";
return transfer;
}
saslPayLog.log(transfer);
return transfer;
}
}
+46
View File
@@ -0,0 +1,46 @@
package com.saslpay.controller;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/post")
public class InternalReversal {
String reversal;
String errorMessage;
String txnRef;
String otherTxnRef;
SaslPayLog saslPayLog = new SaslPayLog();
@PostMapping(value ="/intreversal" ,produces = MediaType.APPLICATION_JSON_VALUE)
public String reversal(@RequestBody String request) {
JbcProcessor jbcProcessor = new JbcProcessor();
JsonElement jsonElementAuth = JsonParser.parseString(request);
JsonObject jsonObjectAuth = jsonElementAuth.getAsJsonObject();
saslPayLog.log(request);
try {
txnRef = jsonObjectAuth.get("ourTxnRef").getAsString();
otherTxnRef = jsonObjectAuth.get("otherTxnRef").getAsString();
}catch (NullPointerException e){
errorMessage = e.getLocalizedMessage();
}
request = "intReversal|" + txnRef +" !!"+ otherTxnRef;
reversal = jbcProcessor.callRoutine(request);
saslPayLog.log(reversal);
return reversal;
}
}
+61
View File
@@ -0,0 +1,61 @@
package com.saslpay.controller;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/post")
public class InternalTransfer {
String transfer;
String drAccount;
String crAccount;
String currency;
String txnAmount;
String txnNarration;
String errorMessage;
String txnRef;
String elevyCharge;
SaslPayLog saslPayLog = new SaslPayLog();
@PostMapping(value ="/inttransfer" ,produces = MediaType.APPLICATION_JSON_VALUE )
public String transfer(@RequestBody String request) {
JbcProcessor jbcProcessor = new JbcProcessor();
JsonElement jsonElementAuth = JsonParser.parseString(request);
JsonObject jsonObjectAuth = jsonElementAuth.getAsJsonObject();
saslPayLog.log(request);
try {
txnRef = jsonObjectAuth.get("txnRef").getAsString();
drAccount = jsonObjectAuth.get("drAccount").getAsString();
crAccount = jsonObjectAuth.get("crAccount").getAsString();
currency = jsonObjectAuth.get("currency").getAsString();
txnAmount = jsonObjectAuth.get("txnAmount").getAsString();
txnNarration = jsonObjectAuth.get("txnNarration").getAsString();
elevyCharge = jsonObjectAuth.get("elevyCharge").getAsString();
}catch (NullPointerException e){
errorMessage = e.getLocalizedMessage();
}
String passedString = txnRef + "!!" + drAccount + "!!" + crAccount + "!!" + currency + "!!" + txnAmount + "!!" + txnNarration + "!!" + elevyCharge;
request = "intTransfer|" + passedString;
try {
transfer = jbcProcessor.callRoutine(request);
} catch (NullPointerException e) {
transfer = "{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}";
return transfer;
}
saslPayLog.log(transfer);
return transfer;
}
}
+30
View File
@@ -0,0 +1,30 @@
package com.saslpay.controller;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/get/levycheck")
public class LevyCheck {
String levyDetails;
SaslPayLog saslPayLog = new SaslPayLog();
@GetMapping(value ="/{account}" ,produces = MediaType.APPLICATION_JSON_VALUE )
public String levy(@PathVariable String account) {
JbcProcessor jbcProcessor = new JbcProcessor();
String request = "checkLevy|" + account;
try {
levyDetails = jbcProcessor.callRoutine(request);
} catch (NullPointerException e) {
levyDetails = "{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}";
return levyDetails;
}
return levyDetails;
}
}
+53
View File
@@ -0,0 +1,53 @@
package com.saslpay.controller;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/post")
public class LevyPay {
String txnCode;
String account;
String chgAmt;
String transfer;
SaslPayLog saslPayLog = new SaslPayLog();
@PostMapping(value ="/levyCharge" ,produces = MediaType.APPLICATION_JSON_VALUE)
public String transfer(@RequestBody String request) {
saslPayLog.log(request);
JbcProcessor jbcProcessor = new JbcProcessor();
JsonElement jsonElementAuth = JsonParser.parseString(request);
JsonObject jsonObjectAuth = jsonElementAuth.getAsJsonObject();
try {
txnCode = jsonObjectAuth.get("txnCode").getAsString();
account = jsonObjectAuth.get("account").getAsString();
chgAmt = jsonObjectAuth.get("chgAmt").getAsString();
} catch (NullPointerException e){
e.getLocalizedMessage();
};
String passedString = txnCode + "!!" + account + "!!" + chgAmt;
request = "levyCharge|" + passedString;
try {
transfer = jbcProcessor.callRoutine(request);
} catch (NullPointerException e) {
transfer = "{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}";
return transfer;
}
saslPayLog.log(transfer);
return transfer;
}
}
+35
View File
@@ -0,0 +1,35 @@
package com.saslpay.controller;
import com.saslpay.log.SaslPayLog;
import com.saslpay.t24jbc.JbcProcessor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/cbs/get/stmt")
public class MiniStatement {
String stmt;
SaslPayLog saslPayLog = new SaslPayLog();
@GetMapping(value="/{account}" , produces = MediaType.APPLICATION_JSON_VALUE)
public String stmt(@PathVariable String account) {
JbcProcessor jbcProcessor = new JbcProcessor();
String request = "reqStatement|" + account;
saslPayLog.log(account);
try {
stmt = jbcProcessor.callRoutine(request);
} catch (NullPointerException e) {
stmt = "{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}";
return stmt;
}
saslPayLog.log(stmt);
return stmt;
}
}
@@ -0,0 +1,71 @@
package com.saslpay.datacapture;
import com.saslpay.config.BeanUtil;
import com.saslpay.entities.T24DataEntity;
import com.saslpay.impl.T24DataServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Component
public class AccountDataCapture {
@PersistenceContext
EntityManager entityManager;
@Autowired
T24DataServiceImpl t24DataServiceImpl;
T24DataEntity t24DataEntity = new T24DataEntity();
public void importer(String body){
t24DataServiceImpl = BeanUtil.getBean(T24DataServiceImpl.class);
entityManager = BeanUtil.getBean(EntityManager.class);
String accountId = StringUtils.substringBetween(body,"<accountId>","</accountId>");
String category = StringUtils.substringBetween(body,"<category>","</category>");
String customerNo = StringUtils.substringBetween(body,"<customerNo>","</customerNo>");
String customerName = StringUtils.substringBetween(body,"<customerName>","</customerName>");
String customerType = StringUtils.substringBetween(body,"<customerType>","</customerType>");
String customerId = StringUtils.substringBetween(body,"<customerId>","</customerId>");
String phoneNumber = StringUtils.substringBetween(body,"<phoneNumber>","</phoneNumber>");
String branch = StringUtils.substringBetween(body,"<branch>","</branch>");
String branchName = StringUtils.substringBetween(body,"<branchName>","</branchName>");
String dob = StringUtils.substringBetween(body,"<dob>","</dob>");
String emailAddress = StringUtils.substringBetween(body,"<emailAddress>","</emailAddress>");
String gender = StringUtils.substringBetween(body,"<gender>","</gender>");
String acStatus = StringUtils.substringBetween(body,"<acStatus>","</acStatus>");
String accountBalance = StringUtils.substringBetween(body,"<accountBalance>","</accountBalance>");
String maxCreditBalance = StringUtils.substringBetween(body,"<maxCreditBalance>","</maxCreditBalance>");
String maxDebitBalance = StringUtils.substringBetween(body,"<maxDebitBalance>","</maxDebitBalance>");
String debitAllowed = StringUtils.substringBetween(body,"<debitAllowed>","</debitAllowed>");
String creditAllowed = StringUtils.substringBetween(body,"<creditAllowed>","</creditAllowed>");
String ussdSubscribed = StringUtils.substringBetween(body,"<ussdSubscribed>","</ussdSubscribed>");
t24DataEntity.setAccountId(accountId);
t24DataEntity.setCategory(category);
t24DataEntity.setCustomerNo(customerNo);
t24DataEntity.setCustomerName(customerName);
t24DataEntity.setCustomerType(customerType);
t24DataEntity.setCustomerId(customerId);
t24DataEntity.setPhoneNumber(phoneNumber);
t24DataEntity.setBranch(branch);
t24DataEntity.setBranchName(branchName);
t24DataEntity.setDob(dob);
t24DataEntity.setEmailAddress(emailAddress);
t24DataEntity.setGender(gender);
t24DataEntity.setAcStatus(acStatus);
t24DataEntity.setAccountBalance(Float.valueOf(accountBalance));
t24DataEntity.setMaxCreditBalance(Float.valueOf(maxCreditBalance));
t24DataEntity.setMaxDebitBalance(Float.valueOf(maxDebitBalance));
t24DataEntity.setDebitAllowed(debitAllowed);
t24DataEntity.setCreditAllowed(creditAllowed);
t24DataEntity.setUssdSubscribed(ussdSubscribed);
t24DataServiceImpl.save(t24DataEntity);
}
}
+38
View File
@@ -0,0 +1,38 @@
package com.saslpay.datacapture;
import java.io.Serializable;
public class JwtRequest implements Serializable {
private static final long serialVersionUID = 5926468583005150707L;
private String username;
private String password;
//need default constructor for JSON Parsing
public JwtRequest()
{
}
public JwtRequest(String username, String password) {
this.setUsername(username);
this.setPassword(password);
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
}
+17
View File
@@ -0,0 +1,17 @@
package com.saslpay.datacapture;
import java.io.Serializable;
public class JwtResponse implements Serializable {
private static final long serialVersionUID = -8091879091924046844L;
private final String jwttoken;
public JwtResponse(String jwttoken) {
this.jwttoken = jwttoken;
}
public String getToken() {
return this.jwttoken;
}
}
+290
View File
@@ -0,0 +1,290 @@
package com.saslpay.entities;
import javax.persistence.*;
import java.sql.Timestamp;
@Entity
@Table(name = "t24Data")
public class T24DataEntity {
private String accountId;
private String category;
private String customerNo;
private String customerName;
private String customerType;
private String customerId;
private String phoneNumber;
private String branch;
private String branchName;
private String dob;
private String emailAddress;
private String gender;
private String acStatus;
private Float accountBalance;
private Float maxCreditBalance;
private Float maxDebitBalance;
private String debitAllowed;
private String creditAllowed;
private String ussdSubscribed;
private Timestamp timeStamp;
@Id
@Column(name = "accountId", nullable = false, length = 13)
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
@Basic
@Column(name = "category", nullable = true, length = 5)
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
@Basic
@Column(name = "customerNo", nullable = false, length = 35)
public String getCustomerNo() {
return customerNo;
}
public void setCustomerNo(String customerNo) {
this.customerNo = customerNo;
}
@Basic
@Column(name = "customerName", nullable = true, length = 35)
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
@Basic
@Column(name = "customerType", nullable = true, length = 2)
public String getCustomerType() {
return customerType;
}
public void setCustomerType(String customerType) {
this.customerType = customerType;
}
@Basic
@Column(name = "customerId", nullable = true, length = 35)
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
@Basic
@Column(name = "phoneNumber", nullable = true, length = 16)
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
@Basic
@Column(name = "branch", nullable = true, length = 35)
public String getBranch() {
return branch;
}
public void setBranch(String branch) {
this.branch = branch;
}
@Basic
@Column(name = "branchName", nullable = true, length = 35)
public String getBranchName() {
return branchName;
}
public void setBranchName(String branchName) {
this.branchName = branchName;
}
@Basic
@Column(name = "dob", nullable = true)
public String getDob() {
return dob;
}
public void setDob(String dob) {
this.dob = dob;
}
@Basic
@Column(name = "emailAddress", nullable = true, length = 35)
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
@Basic
@Column(name = "gender", nullable = true, length = 10)
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
@Basic
@Column(name = "acStatus", nullable = true, length = 11)
public String getAcStatus() {
return acStatus;
}
public void setAcStatus(String acStatus) {
this.acStatus = acStatus;
}
@Basic
@Column(name = "accountBalance", nullable = true, precision = 2)
public Float getAccountBalance() {
return accountBalance;
}
public void setAccountBalance(Float accountBalance) {
this.accountBalance = accountBalance;
}
@Basic
@Column(name = "maxCreditBalance", nullable = true, precision = 2)
public Float getMaxCreditBalance() {
return maxCreditBalance;
}
public void setMaxCreditBalance(Float maxCreditBalance) {
this.maxCreditBalance = maxCreditBalance;
}
@Basic
@Column(name = "maxDebitBalance", nullable = true, precision = 2)
public Float getMaxDebitBalance() {
return maxDebitBalance;
}
public void setMaxDebitBalance(Float maxDebitBalance) {
this.maxDebitBalance = maxDebitBalance;
}
@Basic
@Column(name = "debitAllowed", nullable = true, length = 11)
public String getDebitAllowed() {
return debitAllowed;
}
public void setDebitAllowed(String debitAllowed) {
this.debitAllowed = debitAllowed;
}
@Basic
@Column(name = "creditAllowed", nullable = true, length = 11)
public String getCreditAllowed() {
return creditAllowed;
}
public void setCreditAllowed(String creditAllowed) {
this.creditAllowed = creditAllowed;
}
@Basic
@Column(name = "ussdSubscribed", nullable = true, length = 2)
public String getUssdSubscribed() {
return ussdSubscribed;
}
public void setUssdSubscribed(String ussdSubscribed) {
this.ussdSubscribed = ussdSubscribed;
}
@Basic
@Column(name = "timeStamp", nullable = true)
public Timestamp getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(Timestamp timeStamp) {
this.timeStamp = timeStamp;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
T24DataEntity that = (T24DataEntity) o;
if (accountId != null ? !accountId.equals(that.accountId) : that.accountId != null) return false;
if (category != null ? !category.equals(that.category) : that.category != null) return false;
if (customerNo != null ? !customerNo.equals(that.customerNo) : that.customerNo != null) return false;
if (customerName != null ? !customerName.equals(that.customerName) : that.customerName != null) return false;
if (customerType != null ? !customerType.equals(that.customerType) : that.customerType != null) return false;
if (customerId != null ? !customerId.equals(that.customerId) : that.customerId != null) return false;
if (phoneNumber != null ? !phoneNumber.equals(that.phoneNumber) : that.phoneNumber != null) return false;
if (branch != null ? !branch.equals(that.branch) : that.branch != null) return false;
if (branchName != null ? !branchName.equals(that.branchName) : that.branchName != null) return false;
if (dob != null ? !dob.equals(that.dob) : that.dob != null) return false;
if (emailAddress != null ? !emailAddress.equals(that.emailAddress) : that.emailAddress != null) return false;
if (gender != null ? !gender.equals(that.gender) : that.gender != null) return false;
if (acStatus != null ? !acStatus.equals(that.acStatus) : that.acStatus != null) return false;
if (accountBalance != null ? !accountBalance.equals(that.accountBalance) : that.accountBalance != null)
return false;
if (maxCreditBalance != null ? !maxCreditBalance.equals(that.maxCreditBalance) : that.maxCreditBalance != null)
return false;
if (maxDebitBalance != null ? !maxDebitBalance.equals(that.maxDebitBalance) : that.maxDebitBalance != null)
return false;
if (debitAllowed != null ? !debitAllowed.equals(that.debitAllowed) : that.debitAllowed != null) return false;
if (creditAllowed != null ? !creditAllowed.equals(that.creditAllowed) : that.creditAllowed != null)
return false;
if (ussdSubscribed != null ? !ussdSubscribed.equals(that.ussdSubscribed) : that.ussdSubscribed != null)
return false;
if (timeStamp != null ? !timeStamp.equals(that.timeStamp) : that.timeStamp != null) return false;
return true;
}
@Override
public int hashCode() {
int result = accountId != null ? accountId.hashCode() : 0;
result = 31 * result + (category != null ? category.hashCode() : 0);
result = 31 * result + (customerNo != null ? customerNo.hashCode() : 0);
result = 31 * result + (customerName != null ? customerName.hashCode() : 0);
result = 31 * result + (customerType != null ? customerType.hashCode() : 0);
result = 31 * result + (customerId != null ? customerId.hashCode() : 0);
result = 31 * result + (phoneNumber != null ? phoneNumber.hashCode() : 0);
result = 31 * result + (branch != null ? branch.hashCode() : 0);
result = 31 * result + (branchName != null ? branchName.hashCode() : 0);
result = 31 * result + (dob != null ? dob.hashCode() : 0);
result = 31 * result + (emailAddress != null ? emailAddress.hashCode() : 0);
result = 31 * result + (gender != null ? gender.hashCode() : 0);
result = 31 * result + (acStatus != null ? acStatus.hashCode() : 0);
result = 31 * result + (accountBalance != null ? accountBalance.hashCode() : 0);
result = 31 * result + (maxCreditBalance != null ? maxCreditBalance.hashCode() : 0);
result = 31 * result + (maxDebitBalance != null ? maxDebitBalance.hashCode() : 0);
result = 31 * result + (debitAllowed != null ? debitAllowed.hashCode() : 0);
result = 31 * result + (creditAllowed != null ? creditAllowed.hashCode() : 0);
result = 31 * result + (ussdSubscribed != null ? ussdSubscribed.hashCode() : 0);
result = 31 * result + (timeStamp != null ? timeStamp.hashCode() : 0);
return result;
}
}
+63
View File
@@ -0,0 +1,63 @@
package com.saslpay.entities;
import javax.persistence.*;
@Entity
@Table(name = "user")
public class UserEntity {
private float userId;
private String username;
private String password;
@Id
@Column(name = "userId", nullable = false, precision = 0)
public float getUserId() {
return userId;
}
public void setUserId(float userId) {
this.userId = userId;
}
@Basic
@Column(name = "username", nullable = false, length = 15)
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Basic
@Column(name = "password", nullable = false, length = 200)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UserEntity that = (UserEntity) o;
if (Float.compare(that.userId, userId) != 0) return false;
if (username != null ? !username.equals(that.username) : that.username != null) return false;
if (password != null ? !password.equals(that.password) : that.password != null) return false;
return true;
}
@Override
public int hashCode() {
int result = (userId != +0.0f ? Float.floatToIntBits(userId) : 0);
result = 31 * result + (username != null ? username.hashCode() : 0);
result = 31 * result + (password != null ? password.hashCode() : 0);
return result;
}
}
+40
View File
@@ -0,0 +1,40 @@
package com.saslpay.impl;
import com.saslpay.entities.UserEntity;
import com.saslpay.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@Service
public class JwtUserDetailsService implements UserDetailsService {
@Autowired
private UserRepository userDao;
@Autowired
PasswordEncoder bcryptEncoder;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UserEntity user = userDao.findByUsername(username);
if (user == null) {
throw new UsernameNotFoundException("User not found with username: " + username);
}
return new User(user.getUsername(), user.getPassword(),
new ArrayList<>());
}
public UserEntity save(UserEntity user) {
UserEntity newUser = new UserEntity();
newUser.setUsername(user.getUsername());
newUser.setPassword(bcryptEncoder.encode(user.getPassword()));
return userDao.save(newUser);
}
}
+75
View File
@@ -0,0 +1,75 @@
package com.saslpay.impl;
import com.saslpay.repository.T24DataRepository;
import com.saslpay.service.T24DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
import java.util.Optional;
@Service("T24DataService")
@Transactional
public class T24DataServiceImpl implements T24DataService {
@Autowired
private T24DataRepository t24DataRepository;
@PersistenceContext
EntityManager entityManager;
private Object T24DataEntity;
// @Override
// public T24DataEntity saveT24DataEntity(T24DataEntity t24DataEntity) {
// T24DataEntity response = t24DataRepository.save(t24DataEntity);
// return response;
// }
// @Override
// public T24DataEntity getT24DataEntity(String id) {
// T24DataEntity t24DataEntity = entityManager.find(T24DataEntity.class, id);
// return t24DataEntity;
// }
@Override
public List<com.saslpay.entities.T24DataEntity> findAll() {
return t24DataRepository.findAll();
}
@Override
public Optional<com.saslpay.entities.T24DataEntity> findById(String id) {
t24DataRepository.findById(id);
return t24DataRepository.findById(id);
}
// @Override
// public Optional<T24DataEntity> deleteById(String id) {
// t24DataRepository.deleteById(id);
// return Optional.empty();
// }
//"SELECT * FROM `t24Data` WHERE `customerNo` = '111247'"
//"SELECT * FROM `t24Data` WHERE `accountId'` = '01070011124701'
// @Override
// public List<T24DataEntity> deleteAll() {
// t24DataRepository.deleteAll();
// return null;
// }
// @Override
// public T24DataEntity update(T24DataEntity t24DataEntity) {
// return null;
// }
@Override
public com.saslpay.entities.T24DataEntity save(com.saslpay.entities.T24DataEntity t24DataEntity) {
t24DataRepository.save(t24DataEntity);
return t24DataEntity;
}
}
+12
View File
@@ -0,0 +1,12 @@
package com.saslpay.log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SaslPayLog {
public void log(String log){
Logger logger = LoggerFactory.getLogger(SaslPayLog.class);
logger.info(log);
}
}
@@ -0,0 +1,11 @@
package com.saslpay.repository;
import com.saslpay.entities.T24DataEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface T24DataRepository extends JpaRepository<T24DataEntity, String> {
}
+12
View File
@@ -0,0 +1,12 @@
package com.saslpay.repository;
import com.saslpay.entities.UserEntity;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UserRepository extends CrudRepository<UserEntity, Integer> {
UserEntity findByUsername(String username);
}
+29
View File
@@ -0,0 +1,29 @@
package com.saslpay.service;
import com.saslpay.entities.T24DataEntity;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public interface T24DataService {
// T24DataEntity saveT24DataEntity(T24DataEntity t24DataEntity);
// T24DataEntity getT24DataEntity(String id);
List<T24DataEntity> findAll();
Optional<T24DataEntity> findById(String id);
// Optional<T24DataEntity> deleteById(String id);
// List<T24DataEntity> deleteAll();
// T24DataEntity update(T24DataEntity t24DataEntity);
T24DataEntity save(T24DataEntity t24DataEntity);
}
+36
View File
@@ -0,0 +1,36 @@
package com.saslpay.t24jbc;
import com.saslpay.log.SaslPayLog;
import com.saslpay.config.BeanUtil;
import com.saslpay.config.ConfigClass;
import com.saslpay.config.ConnectionClass;
import com.jbase.jremote.JDynArray;
import com.jbase.jremote.JRemoteException;
import com.jbase.jremote.JSubroutineParameters;
public class JbcProcessor {
SaslPayLog saslPayLog = new SaslPayLog();
ConnectionClass connectionClass = new ConnectionClass();
ConfigClass configClass = BeanUtil.getBean(ConfigClass.class);
String jbcRoutine = configClass.getJbcRoutine();
public String callRoutine(String inputData) {
JSubroutineParameters t24Data = new JSubroutineParameters();
JSubroutineParameters routineData = new JSubroutineParameters();
routineData.add(new JDynArray(inputData));
try {
t24Data = connectionClass.tafcConnect().call(jbcRoutine, routineData);
} catch (JRemoteException | NullPointerException e) {
saslPayLog.log("{\"errorMsg\" :\"" + "Failed to Connect" + " - Contact Sinapi\"}");
}
return String.valueOf(t24Data.get(0).get(1));
}
}
+13
View File
@@ -0,0 +1,13 @@
package com.saslpay;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class MobileApplicationTests {
@Test
void contextLoads() {
}
}