add security
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
@@ -29,11 +29,11 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Validation -->
|
<!-- Validation -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
@@ -62,6 +62,11 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Database Driver -->
|
<!-- Database Driver -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
@@ -133,7 +138,26 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
<version>2.5.0</version>
|
<version>2.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JWT Runtime Implementations -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-api</artifactId>
|
||||||
|
<version>0.11.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-impl</artifactId>
|
||||||
|
<version>0.11.5</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
|
<version>0.11.5</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Test -->
|
<!-- Test -->
|
||||||
@@ -172,8 +196,8 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
<finalName>BBPS</finalName>
|
<finalName>BBPS</finalName>
|
||||||
</build>
|
</build>
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.billpaymentservice.bbps.config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
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.stereotype.Service;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.entites.UsersDetails;
|
||||||
|
import com.billpaymentservice.bbps.repository.UsersDetailsRepository;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CustomUserDetailsService implements UserDetailsService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UsersDetailsRepository userRepo;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDetails loadUserByUsername(String userMobNo) throws UsernameNotFoundException {
|
||||||
|
|
||||||
|
String normalizedEmail = userMobNo;
|
||||||
|
|
||||||
|
Optional<UsersDetails> adminOptional = userRepo.findByUserMobNo(normalizedEmail);
|
||||||
|
|
||||||
|
if (adminOptional.isPresent()) {
|
||||||
|
UsersDetails user = adminOptional.get();
|
||||||
|
return new User(user.getUserEmailId(), user.getUserMobNo(), new ArrayList<>());
|
||||||
|
} else {
|
||||||
|
throw new UsernameNotFoundException("User not found with MobNo: " + userMobNo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.billpaymentservice.bbps.config;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.springframework.security.core.AuthenticationException;
|
||||||
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void commence(HttpServletRequest request, HttpServletResponse response,
|
||||||
|
AuthenticationException authException) throws IOException, ServletException {
|
||||||
|
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access denied");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.billpaymentservice.bbps.config;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
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 io.jsonwebtoken.ExpiredJwtException;
|
||||||
|
import io.jsonwebtoken.MalformedJwtException;
|
||||||
|
import jakarta.servlet.FilterChain;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class JwtFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JwtUtil jwtUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomUserDetailsService userDetailsService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
|
||||||
|
throws ServletException, IOException {
|
||||||
|
|
||||||
|
final String authorizationHeader = request.getHeader("Authentication");
|
||||||
|
|
||||||
|
String email = null;
|
||||||
|
String jwt = null;
|
||||||
|
|
||||||
|
if (authorizationHeader != null && authorizationHeader.startsWith("Bearer ")) {
|
||||||
|
jwt = authorizationHeader.substring(7);
|
||||||
|
try {
|
||||||
|
email = jwtUtil.extractUsername(jwt);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
System.out.println("unable to get jwt tokken");
|
||||||
|
} catch (ExpiredJwtException e) {
|
||||||
|
System.out.println("Jwt Exception jwt tokken");
|
||||||
|
} catch (MalformedJwtException e) {
|
||||||
|
System.out.println("invelid jwt token");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (email != null && SecurityContextHolder.getContext().getAuthentication() == null) {
|
||||||
|
|
||||||
|
UserDetails userDetails = this.userDetailsService.loadUserByUsername(email);
|
||||||
|
|
||||||
|
|
||||||
|
if (jwtUtil.validateToken(jwt, userDetails)) {
|
||||||
|
|
||||||
|
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(
|
||||||
|
userDetails, null, userDetails.getAuthorities());
|
||||||
|
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
|
||||||
|
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
System.out.println("JWT Filter: Token validation failed for user - " + email);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
filterChain.doFilter(request, response);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package com.billpaymentservice.bbps.config;
|
||||||
|
|
||||||
|
import java.security.Key;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
import io.jsonwebtoken.Jwts;
|
||||||
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
|
import io.jsonwebtoken.io.Decoders;
|
||||||
|
import io.jsonwebtoken.security.Keys;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class JwtUtil {
|
||||||
|
|
||||||
|
@Value("${jwt.secret}")
|
||||||
|
private String secret;
|
||||||
|
|
||||||
|
private Key getSigningKey() {
|
||||||
|
byte[] keyBytes = Decoders.BASE64.decode(secret);
|
||||||
|
return Keys.hmacShaKeyFor(keyBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Access Token - 2 Hours
|
||||||
|
private final long jwtExpirationInMs = 1000 * 60 * 60 * 2; // 2 hours
|
||||||
|
|
||||||
|
// Refresh Token - 7 Days
|
||||||
|
private final long refreshExpirationDateInMs = 1000L * 60 * 60 * 24 * 7; // 7 days
|
||||||
|
|
||||||
|
private final Map<String, Date> tokenBlacklist = new HashMap<>();
|
||||||
|
|
||||||
|
public String doGenerateRefreshToken(Map<String, Object> claims, String subject) {
|
||||||
|
return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis()))
|
||||||
|
.setExpiration(new Date(System.currentTimeMillis() + refreshExpirationDateInMs))
|
||||||
|
.signWith(getSigningKey(), SignatureAlgorithm.HS512).compact();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String extractUsername(String token) {
|
||||||
|
return extractClaim(token, Claims::getSubject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date extractExpiration(String token) {
|
||||||
|
return extractClaim(token, Claims::getExpiration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T extractClaim(String token, Function<Claims, T> claimsResolver) {
|
||||||
|
final Claims claims = extractAllClaims(token);
|
||||||
|
return claimsResolver.apply(claims);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Claims extractAllClaims(String token) {
|
||||||
|
return Jwts.parserBuilder().setSigningKey(getSigningKey()).build().parseClaimsJws(token).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Boolean isTokenExpired(String token) {
|
||||||
|
return extractExpiration(token).before(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateToken(String username, String mid) {
|
||||||
|
Map<String, Object> claims = new HashMap<>();
|
||||||
|
claims.put("mid", mid);
|
||||||
|
claims.put("expiryTime", new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 10).toString());
|
||||||
|
return createToken(claims, username.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createToken(Map<String, Object> claims, String subject) {
|
||||||
|
return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis()))
|
||||||
|
.setExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 10))
|
||||||
|
.signWith(getSigningKey(), SignatureAlgorithm.HS512).compact();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createToken1(String subject) {
|
||||||
|
return Jwts.builder().setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis()))
|
||||||
|
.setExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 10))
|
||||||
|
.signWith(getSigningKey(), SignatureAlgorithm.HS512).compact();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean validateToken(String token, UserDetails userDetails) {
|
||||||
|
final String username = extractUsername(token);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void invalidateToken(String token) {
|
||||||
|
tokenBlacklist.put(token, new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTokenBlacklisted(String token) {
|
||||||
|
Date invalidationTime = tokenBlacklist.get(token);
|
||||||
|
return invalidationTime != null && invalidationTime.before(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateToken(String mobileNo) {
|
||||||
|
return createToken1(mobileNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,16 +2,52 @@ package com.billpaymentservice.bbps.config;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
import org.springframework.web.cors.CorsConfigurationSource;
|
import org.springframework.web.cors.CorsConfigurationSource;
|
||||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@EnableWebSecurity
|
||||||
public class SecurityConfig {
|
public class SecurityConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JwtFilter jwtFilter;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
|
|
||||||
|
http.csrf(csrf -> csrf.disable()).cors(cors -> cors.configurationSource(corsConfigurationSource()))
|
||||||
|
.authorizeHttpRequests(auth -> auth
|
||||||
|
.requestMatchers("/masterData/**",
|
||||||
|
"/v3/api-docs/**",
|
||||||
|
"/swagger-ui/**",
|
||||||
|
"/swagger-ui.html",
|
||||||
|
"/swagger-resources/**",
|
||||||
|
"/webjars/**",
|
||||||
|
"/error")
|
||||||
|
.permitAll().requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() // <-- Correct way
|
||||||
|
.anyRequest().authenticated())
|
||||||
|
.exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint))
|
||||||
|
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
|
||||||
|
|
||||||
|
http.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class);
|
||||||
|
|
||||||
|
return http.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CorsConfigurationSource corsConfigurationSource() {
|
public CorsConfigurationSource corsConfigurationSource() {
|
||||||
CorsConfiguration config = new CorsConfiguration();
|
CorsConfiguration config = new CorsConfiguration();
|
||||||
|
|||||||
@@ -16,9 +16,11 @@ import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
|
|||||||
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
|
import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.DispositionRequest;
|
import com.billpaymentservice.bbps.dto.request.DispositionRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.LoginRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
|
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.MasterRequest;
|
import com.billpaymentservice.bbps.dto.request.MasterRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.PlanRequest;
|
import com.billpaymentservice.bbps.dto.request.PlanRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.response.AuthResponse;
|
||||||
import com.billpaymentservice.bbps.service.MasterDataService;
|
import com.billpaymentservice.bbps.service.MasterDataService;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@@ -146,4 +148,14 @@ public class MasterDataController {
|
|||||||
return ResponseEntity.ok(masterDataService.fetchPlanByCategories(requestModel));
|
return ResponseEntity.ok(masterDataService.fetchPlanByCategories(requestModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/loginWithoutDecryption")
|
||||||
|
public ResponseEntity<AuthResponse> login(@RequestBody LoginRequest loginRequest) {
|
||||||
|
try {
|
||||||
|
AuthResponse authResponse = masterDataService.authenticateUser(loginRequest);
|
||||||
|
return ResponseEntity.ok(authResponse);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(500).body(AuthResponse.builder().status("Unauthorized")
|
||||||
|
.message("An unexpected error occurred").statusCode(500).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class UserDetailsDTO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String userEmailId;
|
||||||
|
|
||||||
|
private String userMobNo;
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
private String userAge;
|
||||||
|
}
|
||||||
@@ -11,7 +11,5 @@ public class ComplaintRequestDTO extends BaseClass {
|
|||||||
private String ticketDisposition; // Complaint disposition
|
private String ticketDisposition; // Complaint disposition
|
||||||
private String ticketDispositionCode; // Type of complaint
|
private String ticketDispositionCode; // Type of complaint
|
||||||
private String txnId; // Transaction ID (optional)
|
private String txnId; // Transaction ID (optional)
|
||||||
private String billerId; // Client Req ID (optional);
|
|
||||||
private String billerName;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.request;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class LoginRequest {
|
||||||
|
|
||||||
|
@NotBlank(message = "Mobile number is required")
|
||||||
|
@Pattern(regexp = "^[6-9]\\d{9}$", message = "Invalid mobile number. It must be 10 digits and start with 6, 7, 8, or 9.")
|
||||||
|
private String mobileNumber;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.response;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class AuthResponse {
|
||||||
|
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private int statusCode;
|
||||||
|
|
||||||
|
private Object data;
|
||||||
|
|
||||||
|
private String anotherData;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public AuthResponse(String status, String message, int statusCode, String token) {
|
||||||
|
|
||||||
|
this.status = status;
|
||||||
|
this.message = message;
|
||||||
|
this.statusCode = statusCode;
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthResponse(String token, String status, String message, int statusCode, Object data) {
|
||||||
|
this.token = token;
|
||||||
|
this.status = status;
|
||||||
|
this.message = message;
|
||||||
|
this.statusCode = statusCode;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.billpaymentservice.bbps.entites;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.audit.Auditable;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Entity
|
||||||
|
@Table(name = "user_details")
|
||||||
|
public class UsersDetails extends Auditable<String> {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "user_email_id")
|
||||||
|
private String userEmailId;
|
||||||
|
|
||||||
|
@Column(name = "user_mob_no")
|
||||||
|
private String userMobNo;
|
||||||
|
|
||||||
|
@Column(name = "user_name")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Column(name = "user_age")
|
||||||
|
private String userAge;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.billpaymentservice.bbps.repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.entites.UsersDetails;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface UsersDetailsRepository extends JpaRepository<UsersDetails, Long> {
|
||||||
|
|
||||||
|
Optional<UsersDetails> findByUserMobNo(String userMobNo);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,9 +5,11 @@ import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
|
|||||||
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
|
import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.DispositionRequest;
|
import com.billpaymentservice.bbps.dto.request.DispositionRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.LoginRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
|
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.MasterRequest;
|
import com.billpaymentservice.bbps.dto.request.MasterRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.PlanRequest;
|
import com.billpaymentservice.bbps.dto.request.PlanRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.response.AuthResponse;
|
||||||
|
|
||||||
public interface MasterDataService {
|
public interface MasterDataService {
|
||||||
|
|
||||||
@@ -35,4 +37,6 @@ public interface MasterDataService {
|
|||||||
|
|
||||||
public ResponseModel getTicketDispositions(DispositionRequest dispositionDetailRequest);
|
public ResponseModel getTicketDispositions(DispositionRequest dispositionDetailRequest);
|
||||||
|
|
||||||
|
public AuthResponse authenticateUser(LoginRequest loginRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.billpaymentservice.bbps.serviceImpl;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -31,10 +32,12 @@ import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
|||||||
import com.billpaymentservice.bbps.entites.ComplaintStatusOptionsMaster;
|
import com.billpaymentservice.bbps.entites.ComplaintStatusOptionsMaster;
|
||||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||||
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
||||||
|
import com.billpaymentservice.bbps.entites.TransactionMaster;
|
||||||
import com.billpaymentservice.bbps.exception.CustomException;
|
import com.billpaymentservice.bbps.exception.CustomException;
|
||||||
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
||||||
import com.billpaymentservice.bbps.repository.ComplainRepository;
|
import com.billpaymentservice.bbps.repository.ComplainRepository;
|
||||||
import com.billpaymentservice.bbps.repository.ComplaintOptionsStatusMasterRepository;
|
import com.billpaymentservice.bbps.repository.ComplaintOptionsStatusMasterRepository;
|
||||||
|
import com.billpaymentservice.bbps.repository.TransactionMasterRepository;
|
||||||
import com.billpaymentservice.bbps.service.ComplainService;
|
import com.billpaymentservice.bbps.service.ComplainService;
|
||||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||||
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
||||||
@@ -61,6 +64,7 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
private final BillerMapperHelper mapperHelper;
|
private final BillerMapperHelper mapperHelper;
|
||||||
private final ComplainRepository complainRepository;
|
private final ComplainRepository complainRepository;
|
||||||
private final ComplaintOptionsStatusMasterRepository complaintStatusMasterRepository;
|
private final ComplaintOptionsStatusMasterRepository complaintStatusMasterRepository;
|
||||||
|
private final TransactionMasterRepository transactionMasterRepository;
|
||||||
|
|
||||||
// moved to class-level
|
// moved to class-level
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
@@ -69,7 +73,8 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
public ComplainServiceImpl(RestClient restClient, HttpService httpService, Helper helper,
|
public ComplainServiceImpl(RestClient restClient, HttpService httpService, Helper helper,
|
||||||
BharatConnectMasterRepository beneficiaryDetailsRepository, BillerMapperHelper mapperHelper,
|
BharatConnectMasterRepository beneficiaryDetailsRepository, BillerMapperHelper mapperHelper,
|
||||||
ComplainRepository complainRepository,
|
ComplainRepository complainRepository,
|
||||||
ComplaintOptionsStatusMasterRepository complaintStatusMasterRepository) {
|
ComplaintOptionsStatusMasterRepository complaintStatusMasterRepository,
|
||||||
|
TransactionMasterRepository transactionMasterRepository) {
|
||||||
this.restClient = restClient;
|
this.restClient = restClient;
|
||||||
this.httpService = httpService;
|
this.httpService = httpService;
|
||||||
this.helper = helper;
|
this.helper = helper;
|
||||||
@@ -77,7 +82,7 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
this.mapperHelper = mapperHelper;
|
this.mapperHelper = mapperHelper;
|
||||||
this.complainRepository = complainRepository;
|
this.complainRepository = complainRepository;
|
||||||
this.complaintStatusMasterRepository = complaintStatusMasterRepository;
|
this.complaintStatusMasterRepository = complaintStatusMasterRepository;
|
||||||
|
this.transactionMasterRepository = transactionMasterRepository;
|
||||||
// initialize shared ObjectMapper once
|
// initialize shared ObjectMapper once
|
||||||
this.objectMapper = new ObjectMapper();
|
this.objectMapper = new ObjectMapper();
|
||||||
this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
@@ -110,10 +115,20 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
BBPSConstant.HTTP_POST, null);
|
BBPSConstant.HTTP_POST, null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
Optional<TransactionMaster> dataById = transactionMasterRepository.findById(complainRequestDTO.getTxnId());
|
||||||
|
if (dataById == null || dataById.isEmpty()) {
|
||||||
|
LOGGER.warn("Master Data By Id is null");
|
||||||
|
throw new CustomException("Master Data is required", "FAILED", BBPSConstant.BADREQUEST, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
TransactionMaster transData = dataById.get();
|
||||||
// Inject tenantId + agentId into request JSON
|
// Inject tenantId + agentId into request JSON
|
||||||
ObjectNode root = (ObjectNode) objectMapper.readTree(forwardJson);
|
ObjectNode root = (ObjectNode) objectMapper.readTree(forwardJson);
|
||||||
root.put("tenantId", headersData.getTenantId());
|
root.put("tenantId", headersData.getTenantId());
|
||||||
root.put("agentId", headersData.getAgentId());
|
root.put("agentId", headersData.getAgentId());
|
||||||
|
root.put("billerId", transData.getBillerId());
|
||||||
|
root.put("billerName", transData.getBillerName());
|
||||||
|
|
||||||
String finalJson = root.toString();
|
String finalJson = root.toString();
|
||||||
LOGGER.info("[{}] Final Request Sent to API | reqId={} | payload={}", apiName, requestId, finalJson);
|
LOGGER.info("[{}] Final Request Sent to API | reqId={} | payload={}", apiName, requestId, finalJson);
|
||||||
|
|||||||
@@ -2,28 +2,35 @@ package com.billpaymentservice.bbps.serviceImpl;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.modelmapper.ModelMapper;
|
import org.modelmapper.ModelMapper;
|
||||||
import org.modelmapper.convention.MatchingStrategies;
|
import org.modelmapper.convention.MatchingStrategies;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.config.JwtUtil;
|
||||||
import com.billpaymentservice.bbps.dto.CustomParamDTO;
|
import com.billpaymentservice.bbps.dto.CustomParamDTO;
|
||||||
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
|
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
|
||||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||||
import com.billpaymentservice.bbps.dto.MasterApiResponse;
|
import com.billpaymentservice.bbps.dto.MasterApiResponse;
|
||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
|
import com.billpaymentservice.bbps.dto.UserDetailsDTO;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
|
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
|
import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.DispositionRequest;
|
import com.billpaymentservice.bbps.dto.request.DispositionRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.LoginRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
|
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.MasterRequest;
|
import com.billpaymentservice.bbps.dto.request.MasterRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.PlanRequest;
|
import com.billpaymentservice.bbps.dto.request.PlanRequest;
|
||||||
import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
|
import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
|
||||||
|
import com.billpaymentservice.bbps.dto.response.AuthResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.BillerDataResponse;
|
import com.billpaymentservice.bbps.dto.response.BillerDataResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.BillerResponse;
|
import com.billpaymentservice.bbps.dto.response.BillerResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.ChannelsListResponse;
|
import com.billpaymentservice.bbps.dto.response.ChannelsListResponse;
|
||||||
@@ -42,6 +49,7 @@ import com.billpaymentservice.bbps.entites.DispositionDetails;
|
|||||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||||
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
||||||
import com.billpaymentservice.bbps.entites.PlanResponses;
|
import com.billpaymentservice.bbps.entites.PlanResponses;
|
||||||
|
import com.billpaymentservice.bbps.entites.UsersDetails;
|
||||||
import com.billpaymentservice.bbps.exception.CustomException;
|
import com.billpaymentservice.bbps.exception.CustomException;
|
||||||
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
||||||
import com.billpaymentservice.bbps.repository.BillerDataRepository;
|
import com.billpaymentservice.bbps.repository.BillerDataRepository;
|
||||||
@@ -50,6 +58,7 @@ import com.billpaymentservice.bbps.repository.DispositionRepository;
|
|||||||
import com.billpaymentservice.bbps.repository.InboundTraceLogRepository;
|
import com.billpaymentservice.bbps.repository.InboundTraceLogRepository;
|
||||||
import com.billpaymentservice.bbps.repository.MerchantRepository;
|
import com.billpaymentservice.bbps.repository.MerchantRepository;
|
||||||
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
|
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
|
||||||
|
import com.billpaymentservice.bbps.repository.UsersDetailsRepository;
|
||||||
import com.billpaymentservice.bbps.service.MasterDataService;
|
import com.billpaymentservice.bbps.service.MasterDataService;
|
||||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||||
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
||||||
@@ -80,6 +89,11 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
private final InboundTraceLogRepository inboundTraceLogRepository;
|
private final InboundTraceLogRepository inboundTraceLogRepository;
|
||||||
private final OutboundTraceLogRepository outboundTraceLogRepository;
|
private final OutboundTraceLogRepository outboundTraceLogRepository;
|
||||||
private final CustomParamRepository customParamReposiotory;
|
private final CustomParamRepository customParamReposiotory;
|
||||||
|
@Autowired
|
||||||
|
private UsersDetailsRepository userRepo;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JwtUtil jwtUtil;
|
||||||
|
|
||||||
public MasterDataServiceImpl(MerchantRepository merchantRegisterRepo, HttpService httpService,
|
public MasterDataServiceImpl(MerchantRepository merchantRegisterRepo, HttpService httpService,
|
||||||
HttpClientApi httpClientApi, Helper helper, BillerDataRepository billerDataRespository,
|
HttpClientApi httpClientApi, Helper helper, BillerDataRepository billerDataRespository,
|
||||||
@@ -224,7 +238,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
throw new CustomException("Invalid JSON received from API");
|
throw new CustomException("Invalid JSON received from API");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
|
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
|
||||||
String apiName = BBPSConstant.API_GET_CUSTOMER_PARAM_BY_BILLER_ID;
|
String apiName = BBPSConstant.API_GET_CUSTOMER_PARAM_BY_BILLER_ID;
|
||||||
@@ -366,7 +380,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerName={} | category={}", apiName, requestId, mid,
|
LOGGER.info("[{}] START | reqId={} | mid={} | billerName={} | category={}", apiName, requestId, mid,
|
||||||
masterRequest.getBillerName(), masterRequest.getCategory());
|
masterRequest.getBillerName(), masterRequest.getCategory());
|
||||||
|
|
||||||
String txnID = helper.generateTxnId(15);
|
String txnID = helper.generateTxnId(15);
|
||||||
String fullUrl = String.format("%s%s?billerName=%s&category=%s&page=%d&pagesize=%d", masterRegisterUrl,
|
String fullUrl = String.format("%s%s?billerName=%s&category=%s&page=%d&pagesize=%d", masterRegisterUrl,
|
||||||
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
|
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
|
||||||
masterRequest.getPageNo(), masterRequest.getPageSize());
|
masterRequest.getPageNo(), masterRequest.getPageSize());
|
||||||
@@ -472,7 +486,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
if (entities != null) {
|
if (entities != null) {
|
||||||
dispositionRepository.saveAll(entities);
|
dispositionRepository.saveAll(entities);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
LOGGER.warn("No disposition found in response to save.");
|
LOGGER.warn("No disposition found in response to save.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,4 +882,40 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthResponse authenticateUser(LoginRequest loginRequest) {
|
||||||
|
LOGGER.info("Processing login for Request: " + loginRequest);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String mobileNo = loginRequest.getMobileNumber();
|
||||||
|
|
||||||
|
Optional<UsersDetails> byAdminEmail = userRepo.findByUserMobNo(mobileNo);
|
||||||
|
|
||||||
|
if (byAdminEmail.isPresent()) {
|
||||||
|
UsersDetails user = byAdminEmail.get();
|
||||||
|
String token = jwtUtil.generateToken(user.getUserMobNo());
|
||||||
|
|
||||||
|
LOGGER.info("Generated JWT token for mobileNo: " + mobileNo);
|
||||||
|
|
||||||
|
Object userDetailsDTO = null;
|
||||||
|
|
||||||
|
if (user != null) {
|
||||||
|
userDetailsDTO = UserDetailsDTO.builder().id(user.getId()).userEmailId(user.getUserEmailId())
|
||||||
|
.userMobNo(user.getUserMobNo()).userName(user.getUserName()).userAge(user.getUserAge())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
return new AuthResponse(token, "Success", "Login Done", 200, userDetailsDTO);
|
||||||
|
} else {
|
||||||
|
return new AuthResponse("", "User Not Found", "Authentication failed", 401, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
System.out.println("Error occurred during login for mobile no: " + loginRequest.getMobileNumber()
|
||||||
|
+ " Exception: " + ex.getMessage());
|
||||||
|
|
||||||
|
return AuthResponse.builder().status("Unauthorized").message("Authentication failed: " + ex.getMessage())
|
||||||
|
.statusCode(401).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.billpaymentservice.bbps.swagger;
|
package com.billpaymentservice.bbps.swagger;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -9,7 +7,8 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import io.swagger.v3.oas.models.info.Contact;
|
import io.swagger.v3.oas.models.info.Contact;
|
||||||
import io.swagger.v3.oas.models.info.Info;
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
import io.swagger.v3.oas.models.servers.Server;
|
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SwaggerConfig {
|
public class SwaggerConfig {
|
||||||
@@ -21,12 +20,14 @@ public class SwaggerConfig {
|
|||||||
private String serverDescription;
|
private String serverDescription;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public OpenAPI openAPI() {
|
public OpenAPI customOpenAPI() {
|
||||||
return new OpenAPI()
|
return new OpenAPI().addSecurityItem(new SecurityRequirement().addList("Authentication"))
|
||||||
.info(new Info().title("BBPS API").description("Spring Boot REST API for BBPS System API Documentation")
|
.components(new io.swagger.v3.oas.models.Components().addSecuritySchemes("Authentication",
|
||||||
.version("1.0.0").contact(new Contact().name("BBPS ")))
|
new SecurityScheme().name("Authentication").type(SecurityScheme.Type.APIKEY)
|
||||||
.servers(List.of(new Server().url(serverUrl).description(serverDescription)));
|
.in(SecurityScheme.In.HEADER)))
|
||||||
|
.info(new Info().title("Spring Boot REST API").description("Spring Boot REST API for BBPS")
|
||||||
|
.version("1.0.0").contact(new Contact().name("Globots").url(serverUrl)
|
||||||
|
.email("info@merchantpanel.com")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1044,9 +1044,6 @@ public class BillerMapperHelper {
|
|||||||
|
|
||||||
public FetchComplaintForwardRequest fetchComplaintForwardRequestMap(ComplaintRequestDTO complainRequestDTO) {
|
public FetchComplaintForwardRequest fetchComplaintForwardRequestMap(ComplaintRequestDTO complainRequestDTO) {
|
||||||
FetchComplaintForwardRequest forward = new FetchComplaintForwardRequest();
|
FetchComplaintForwardRequest forward = new FetchComplaintForwardRequest();
|
||||||
|
|
||||||
forward.setBillerId(complainRequestDTO.getBillerId());
|
|
||||||
forward.setBillerName(complainRequestDTO.getBillerName());
|
|
||||||
forward.setTicketDescription(complainRequestDTO.getTicketDescription());
|
forward.setTicketDescription(complainRequestDTO.getTicketDescription());
|
||||||
forward.setTicketDisposition(complainRequestDTO.getTicketDisposition());
|
forward.setTicketDisposition(complainRequestDTO.getTicketDisposition());
|
||||||
forward.setTicketDispositionCode(complainRequestDTO.getTicketDispositionCode());
|
forward.setTicketDispositionCode(complainRequestDTO.getTicketDispositionCode());
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ swagger.server.description=Local Development Server
|
|||||||
spring.profiles.active=local
|
spring.profiles.active=local
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# DataSource
|
# DataSource
|
||||||
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
|
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
|
||||||
spring.datasource.username=postgres
|
spring.datasource.username=postgres
|
||||||
@@ -44,7 +45,8 @@ logging.level.io.github.resilience4j.retry=DEBUG
|
|||||||
master.data.url = https://bbps-staging.digiledge.in/agent/cou-master/masters
|
master.data.url = https://bbps-staging.digiledge.in/agent/cou-master/masters
|
||||||
agent.data.url=https://bbps-staging.digiledge.in/agent/bill-payment-new
|
agent.data.url=https://bbps-staging.digiledge.in/agent/bill-payment-new
|
||||||
payment.data.url=https://bbps-staging.digiledge.in/couapp
|
payment.data.url=https://bbps-staging.digiledge.in/couapp
|
||||||
complaint.data.url=https://bbps-staging.digiledge.in
|
complaint.data.url=https://bbps-staging.digiledge.in/agent/bill-payment-new
|
||||||
|
|
||||||
|
|
||||||
# throw NoHandlerFoundException for 404s
|
# throw NoHandlerFoundException for 404s
|
||||||
spring.mvc.throw-exception-if-no-handler-found=true
|
spring.mvc.throw-exception-if-no-handler-found=true
|
||||||
@@ -55,6 +57,9 @@ spring.web.resources.add-mappings=false
|
|||||||
# (optional) to avoid path match issues on Spring Boot 2.6+
|
# (optional) to avoid path match issues on Spring Boot 2.6+
|
||||||
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
|
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
|
||||||
|
|
||||||
|
jwt.secret=6C756148487475787A414646736D4B6E444E585A766145396E6A4555594A595566657A6E434D62536856674A704C494F6C6E666B366A4A6A6D5630323564716C614F
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Resilience4j Retry
|
# Resilience4j Retry
|
||||||
resilience4j.retry.instances.callbackService.max-attempts=1
|
resilience4j.retry.instances.callbackService.max-attempts=1
|
||||||
|
|||||||
Reference in New Issue
Block a user