Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MERGE] Add @SuppressWarnings #37

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class CloudinaryComponent {
@Autowired
private CloudinaryConfig cloudinary;

@SuppressWarnings("rawtypes")
public Map Cloudinary(MultipartFile file) {
try {
Map res = this.cloudinary.cloudinary().uploader().upload(file.getBytes(),
Expand All @@ -36,6 +37,7 @@ public Map Cloudinary(MultipartFile file) {
return null;
}

@SuppressWarnings("rawtypes")
public Map CloudinaryPDF(byte[] pdfBytes) {
try {
Map res = this.cloudinary.cloudinary().uploader().upload(pdfBytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class AppointmentReminder {
@Autowired
private Environment environment;

@SuppressWarnings("unchecked")
@Scheduled(cron = "0 0 8 * * *") // Chạy mỗi ngày vào lúc 8 giờ sáng
// @Scheduled(cron = "*/5 * * * * *") // Mỗi 5 giây
private void checkAppointments() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.tuantran.IMPROOK_CARE.configs.twilio.TwilioSmsSender;
import com.tuantran.IMPROOK_CARE.dto.SmsRequestDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

Expand All @@ -19,7 +18,6 @@
public class SmsService {
private final SmsSender smsSender;

@Autowired
public SmsService(@Qualifier("twilio") TwilioSmsSender smsSender) {
this.smsSender = smsSender;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class AuthTokenFilter extends OncePerRequestFilter {

private static final Logger LOGGER = LoggerFactory.getLogger(AuthTokenFilter.class);

@SuppressWarnings("null")
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
Expand All @@ -41,11 +42,10 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
String username = jwtUtils.getUserNameFromJwtToken(jwt);

UserDetails userDetails = userService.loadUserByUsername(username);
UsernamePasswordAuthenticationToken authentication =
new UsernamePasswordAuthenticationToken(
userDetails,
null,
userDetails.getAuthorities());
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(
userDetails,
null,
userDetails.getAuthorities());
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));

SecurityContextHolder.getContext().setAuthentication(authentication);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
*/
package com.tuantran.IMPROOK_CARE.configs.jwt;

import com.tuantran.IMPROOK_CARE.models.User;
import com.tuantran.IMPROOK_CARE.service.UserService;
import java.security.Key;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

import io.jsonwebtoken.*;
Expand All @@ -25,6 +23,7 @@
public class JwtUtils {

private static final Logger logger = LoggerFactory.getLogger(JwtUtils.class);
@SuppressWarnings("unused")
private static final long REFRESH_TOKEN_EXPIRATION_DATE = 30 * 24 * 60 * 60 * 1000;

@Value("${bezkoder.app.jwtSecret}")
Expand All @@ -40,11 +39,11 @@ public String generateJwtToken(UserDetails UserDetails) {

UserDetails userPrincipal = userService.loadUserByUsername(UserDetails.getUsername());

// String username = UserDetails.getUsername();
// User user = userService.findUserByUsername(username);
// Date currentDate = new Date();
//
// Date expireDate = new Date(currentDate.getTime() + jwtExpirationMs);
// String username = UserDetails.getUsername();
// User user = userService.findUserByUsername(username);
// Date currentDate = new Date();
//
// Date expireDate = new Date(currentDate.getTime() + jwtExpirationMs);

return Jwts.builder()
.setSubject((userPrincipal.getUsername()))
Expand All @@ -53,18 +52,18 @@ public String generateJwtToken(UserDetails UserDetails) {
.signWith(key(), SignatureAlgorithm.HS256)
.compact();
}
// public String generateJwtToken(Authentication authentication) {
//
// UserDetails userPrincipal = (UserDetails) authentication.getPrincipal();
//
// return Jwts.builder()
// .setSubject((userPrincipal.getUsername()))
// .setIssuedAt(new Date())
// .setExpiration(new Date((new Date()).getTime() + jwtExpirationMs))
// .signWith(key(), SignatureAlgorithm.HS256)
// .compact();
// }

// public String generateJwtToken(Authentication authentication) {
//
// UserDetails userPrincipal = (UserDetails) authentication.getPrincipal();
//
// return Jwts.builder()
// .setSubject((userPrincipal.getUsername()))
// .setIssuedAt(new Date())
// .setExpiration(new Date((new Date()).getTime() + jwtExpirationMs))
// .signWith(key(), SignatureAlgorithm.HS256)
// .compact();
// }

private Key key() {
return Keys.hmacShaKeyFor(Decoders.BASE64.decode(jwtSecret));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.twilio.Twilio;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

/**
Expand All @@ -20,15 +19,14 @@ public class TwilioInitializer {

private final static Logger LOGGER = LoggerFactory.getLogger(TwilioInitializer.class);

@SuppressWarnings("unused")
private final TwilioConfiguration twilioConfiguration;

@Autowired
public TwilioInitializer(TwilioConfiguration twilioConfiguration) {
this.twilioConfiguration = twilioConfiguration;
Twilio.init(
twilioConfiguration.getAccountSid(),
twilioConfiguration.getAuthToken()
);
twilioConfiguration.getAuthToken());
LOGGER.info("Twilio initialized ... with account sid {} ", twilioConfiguration.getAccountSid());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.twilio.type.PhoneNumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
Expand All @@ -22,7 +21,6 @@ public class TwilioSmsSender implements SmsSender {

private final TwilioConfiguration twilioConfiguration;

@Autowired
public TwilioSmsSender(TwilioConfiguration twilioConfiguration) {
this.twilioConfiguration = twilioConfiguration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@Configuration
@EnableWebSocket
public class WebSocketVideoConfig implements WebSocketConfigurer {
@SuppressWarnings("null")
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(videoChatHandler(), "/api/public/video-chat/").setAllowedOrigins("*");
Expand All @@ -34,13 +35,15 @@ class VideoChatHandler extends TextWebSocketHandler {
private final List<WebSocketSession> sessions = new CopyOnWriteArrayList<>();
private final AtomicBoolean isPolitePeer = new AtomicBoolean(true);

@SuppressWarnings("null")
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
String jsonResponse = "{\"polite\": \"" + isPolitePeer.getAndSet(!isPolitePeer.get()) + "\"}";
session.sendMessage(new TextMessage(jsonResponse));
sessions.add(session);
}

@SuppressWarnings("null")
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
for (WebSocketSession s : sessions) {
Expand All @@ -50,6 +53,7 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message)
}
}

@SuppressWarnings("null")
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
System.out.println("INSIDE CLOSING STATE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public static String Sha256(String message) {
return digest;
}

//Util for VNPAY
// Util for VNPAY
@SuppressWarnings({ "unchecked", "rawtypes" })
public static String hashAllFields(Map fields) {
List fieldNames = new ArrayList(fields.keySet());
Collections.sort(fieldNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

@SuppressWarnings("null")
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/api/public/webSocket/").setAllowedOriginPatterns("*").withSockJS();
registry.addEndpoint("/api/public/notification/").setAllowedOriginPatterns("*").withSockJS();
}

@SuppressWarnings("null")
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.setApplicationDestinationPrefixes("/app");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ public ResponseEntity<?> hardDeleteMedicalSchedule(

}

@SuppressWarnings("unchecked")
@DeleteMapping("/auth/prescriptionId/{prescriptionId}/hard-delete/medical-schedule/")
@CrossOrigin
public ResponseEntity<?> hardDeleteMedicalScheduleByPrescriptionId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.google.gson.JsonObject;
Expand All @@ -17,7 +16,7 @@
import com.tuantran.IMPROOK_CARE.dto.VnpayReturnDTO;

import java.net.HttpURLConnection;
import java.net.MalformedURLException;
// import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -59,6 +58,7 @@ public class ApiVNPAYController {
@Autowired
private VNPAYConfig vnpayConfig;

@SuppressWarnings({ "unchecked", "rawtypes" })
@PostMapping("/public/pay/")
@CrossOrigin
public String getPay(@Valid @RequestBody VNPAYDTO vnpayDTO) throws UnsupportedEncodingException {
Expand Down Expand Up @@ -130,6 +130,7 @@ public String getPay(@Valid @RequestBody VNPAYDTO vnpayDTO) throws UnsupportedEn
return paymentUrl;
}

@SuppressWarnings({ "unchecked", "rawtypes" })
@PostMapping("/public/pay-return/")
@CrossOrigin
public String getPay_return(@Valid @RequestBody VnpayReturnDTO vnpayReturnDTO) throws UnsupportedEncodingException {
Expand Down Expand Up @@ -201,6 +202,7 @@ public String getPay_return(@Valid @RequestBody VnpayReturnDTO vnpayReturnDTO) t
return paymentUrl;
}

@SuppressWarnings({ "unchecked", "rawtypes", "static-access" })
@GetMapping("/public/processReturnVNPAY/")
@CrossOrigin
public ResponseEntity<?> processReturnVNPAY(HttpServletRequest request) {
Expand Down