From e828225de7636d0195db2c3c9b1701a5b2f12049 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期四, 14 九月 2023 18:01:33 +0800
Subject: [PATCH] Merge branch '滲透' of https://dev.pollex.com.tw:8443/r/pcalife/PAM into 滲透

---
 pamapi/src/main/resources/config/application-pollex.yml                                   |    1 
 pamapi/src/main/resources/config/application-dev.yml                                      |    1 
 pamapi/src/main/resources/config/application-sit.yml                                      |    1 
 pamapi/src/main/java/com/pollex/pam/security/jwt/TokenProvider.java                       |    7 ++-
 pamapi/src/main/java/com/pollex/pam/service/CustomerService.java                          |   27 ++++++++-----
 pamapi/src/main/java/com/pollex/pam/service/OtpWebService.java                            |   12 +++---
 pamapi/src/main/resources/config/application-uat.yml                                      |    1 
 pamapi/src/main/java/com/pollex/pam/config/ApplicationProperties.java                     |   12 ++++++
 pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java |    1 
 pamapi/src/main/java/com/pollex/pam/security/token/OtpAuthenticationToken.java            |    2 
 pamapi/src/main/java/com/pollex/pam/web/rest/AccountResource.java                         |   22 +++++-----
 pamapi/src/main/resources/config/application-prod.yml                                     |    1 
 12 files changed, 58 insertions(+), 30 deletions(-)

diff --git a/pamapi/src/main/java/com/pollex/pam/config/ApplicationProperties.java b/pamapi/src/main/java/com/pollex/pam/config/ApplicationProperties.java
index 371b675..a20d500 100644
--- a/pamapi/src/main/java/com/pollex/pam/config/ApplicationProperties.java
+++ b/pamapi/src/main/java/com/pollex/pam/config/ApplicationProperties.java
@@ -27,6 +27,7 @@
     private SendEmailProperties email;
     private String fileFolderPath;
     private String aesKey;
+    private String defaultPaxxword;
 
     public boolean isMockLogin() {
         return mockLogin;
@@ -125,6 +126,17 @@
 		this.aesKey = aesKey;
 	}
 	
+	@Override
+	public String getDefaultPaxxword() {
+		return defaultPaxxword;
+	}
+
+	public void setDefaultPaxxword(String defaultPaxxword) {
+		this.defaultPaxxword = defaultPaxxword;
+	}
+	
+	
+	
 	
 
 }
diff --git a/pamapi/src/main/java/com/pollex/pam/security/jwt/TokenProvider.java b/pamapi/src/main/java/com/pollex/pam/security/jwt/TokenProvider.java
index 6cff94b..9662a39 100644
--- a/pamapi/src/main/java/com/pollex/pam/security/jwt/TokenProvider.java
+++ b/pamapi/src/main/java/com/pollex/pam/security/jwt/TokenProvider.java
@@ -21,6 +21,7 @@
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
 
+import com.pollex.pam.business.config.AppProperties;
 import com.pollex.pam.business.domain.TokenBlackList;
 import com.pollex.pam.business.repository.TokenBlackListRepository;
 
@@ -44,6 +45,9 @@
 
     @Autowired
     TokenBlackListRepository tokenBlackListRepository;
+    
+    @Autowired
+	AppProperties applicationProperties;
 
     public TokenProvider(JHipsterProperties jHipsterProperties) {
         byte[] keyBytes;
@@ -95,8 +99,7 @@
             .filter(auth -> !auth.trim().isEmpty())
             .map(SimpleGrantedAuthority::new)
             .collect(Collectors.toList());
-
-        User principal = new User(claims.getSubject(), "", authorities);
+        User principal = new User(claims.getSubject(), applicationProperties.getDefaultPaxxword(), authorities);
         UsernamePasswordAuthenticationToken authInfo = new UsernamePasswordAuthenticationToken(principal, token, authorities);
         authInfo.setDetails(claims.get(AUTHORITIES_DETAILS));
 
diff --git a/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java b/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java
index b5924f2..355bfcf 100644
--- a/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java
+++ b/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java
@@ -65,6 +65,7 @@
 
             throw new RuntimeException("eService http error!, response http status code = " + responseEntity.getStatusCode());
         } catch (GeneralSecurityException e) {
+        	log.error("General Security SSL error!",e);
             throw new RuntimeException("General Security SSL error!");
         }
     }
diff --git a/pamapi/src/main/java/com/pollex/pam/security/token/OtpAuthenticationToken.java b/pamapi/src/main/java/com/pollex/pam/security/token/OtpAuthenticationToken.java
index a4c450c..8cbaf23 100644
--- a/pamapi/src/main/java/com/pollex/pam/security/token/OtpAuthenticationToken.java
+++ b/pamapi/src/main/java/com/pollex/pam/security/token/OtpAuthenticationToken.java
@@ -9,7 +9,7 @@
 
     private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
 
-    private final OtpAccount principle;
+    private transient OtpAccount principle;
     private String credentials;
 
     public OtpAuthenticationToken(OtpAccount principle, String credentials) {
diff --git a/pamapi/src/main/java/com/pollex/pam/service/CustomerService.java b/pamapi/src/main/java/com/pollex/pam/service/CustomerService.java
index 98af88a..77f2f75 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/CustomerService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/CustomerService.java
@@ -60,16 +60,23 @@
 			String account = getCustomerAccount(registDTO);
 
 			OtpTmp otpTmp = otpTmpService.findByAccountAndIndexKey(account, registDTO.getIndexKey());
-	    	if(otpTmp.getStatus() == OtpTmpStatusEnum.VERRIFIED) {
-	    		Customer customer = customerDTOMapper.toCustomer(registDTO);
-	    		customer.setDataFrom(DataFromEnum.PAM);
-	        	save(customer);
-	        	return customer;
-	    	}else {
-	    		throw new IllegalArgumentException("Invalid indexKey state error. IndexKey: "
-	    				+ registDTO.getIndexKey()
-	    				+ " => status: " + otpTmp.getStatus());
-	    	}
+	    	
+			if(otpTmp!=null) {
+				if(otpTmp.getStatus() == OtpTmpStatusEnum.VERRIFIED) {
+		    		Customer customer = customerDTOMapper.toCustomer(registDTO);
+		    		customer.setDataFrom(DataFromEnum.PAM);
+		        	save(customer);
+		        	return customer;
+		    	}else {
+		    		throw new IllegalArgumentException("Invalid indexKey state error. IndexKey: "
+		    				+ registDTO.getIndexKey()
+		    				+ " => status: " + otpTmp.getStatus());
+		    	}
+			}else {
+				throw new IllegalArgumentException("otp tmp not exist");
+			}
+			
+			
 		}
 
 	}
diff --git a/pamapi/src/main/java/com/pollex/pam/service/OtpWebService.java b/pamapi/src/main/java/com/pollex/pam/service/OtpWebService.java
index cdbfb83..d3f1874 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/OtpWebService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/OtpWebService.java
@@ -22,8 +22,8 @@
 
     public OtpResponseDTO sendByPhone(String phone) {
         OtpWeb otpWS = getOtpWebService();
-        log.debug("call OtpService sendOtpBySMS, url = {}, systemType = {}, service password = {}, phone = {}",
-            applicationProperty.getOtpWebServiceUrl(), applicationProperty.getOtpWebServiceSystemType(), applicationProperty.getOtpWebServicePassword(), phone);
+//        log.debug("call OtpService sendOtpBySMS, url = {}, systemType = {}, service password = {}, phone = {}",
+//            applicationProperty.getOtpWebServiceUrl(), applicationProperty.getOtpWebServiceSystemType(), applicationProperty.getOtpWebServicePassword(), phone);
 
         StringArray result =
             otpWS.sendOtpBySMS(applicationProperty.getOtpWebServicePassword(), applicationProperty.getOtpWebServiceSystemType(), phone);
@@ -33,8 +33,8 @@
 
     public OtpResponseDTO sendByEmail(String email) {
         OtpWeb otpWS = getOtpWebService();
-        log.debug("call OtpService sendByEmail, url = {}, systemType = {}, service password = {}, email = {}",
-            applicationProperty.getOtpWebServiceUrl(), applicationProperty.getOtpWebServiceSystemType(), applicationProperty.getOtpWebServicePassword(), email);
+//        log.debug("call OtpService sendByEmail, url = {}, systemType = {}, service password = {}, email = {}",
+//            applicationProperty.getOtpWebServiceUrl(), applicationProperty.getOtpWebServiceSystemType(), applicationProperty.getOtpWebServicePassword(), email);
 
         StringArray result =
             otpWS.sendOtpByEmail(applicationProperty.getOtpWebServicePassword(), applicationProperty.getOtpWebServiceSystemType(), email);
@@ -44,8 +44,8 @@
 
     public OtpResponseDTO verifyOTP(String indexKey, String otpCode) {
         OtpWeb otpWS = getOtpWebService();
-        log.debug("call OtpService verifyOTP, url = {}, systemType = {}, service password = {}, indexKey = {}, otpCode = {}",
-            applicationProperty.getOtpWebServiceUrl(), applicationProperty.getOtpWebServiceSystemType(), applicationProperty.getOtpWebServicePassword(), indexKey, otpCode);
+//        log.debug("call OtpService verifyOTP, url = {}, systemType = {}, service password = {}, indexKey = {}, otpCode = {}",
+//            applicationProperty.getOtpWebServiceUrl(), applicationProperty.getOtpWebServiceSystemType(), applicationProperty.getOtpWebServicePassword(), indexKey, otpCode);
 
         StringArray result =
             otpWS.verifyOtp(applicationProperty.getOtpWebServicePassword(), applicationProperty.getOtpWebServiceSystemType(), indexKey, otpCode);
diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/AccountResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/AccountResource.java
index 50319a9..04bda6b 100644
--- a/pamapi/src/main/java/com/pollex/pam/web/rest/AccountResource.java
+++ b/pamapi/src/main/java/com/pollex/pam/web/rest/AccountResource.java
@@ -65,17 +65,17 @@
         }
     }
 
-    /**
-     * {@code GET  /authenticate} : check if the user is authenticated, and return its login.
-     *
-     * @param request the HTTP request.
-     * @return the login if the user is authenticated.
-     */
-    @GetMapping("/authenticate")
-    public String isAuthenticated(HttpServletRequest request) {
-        log.debug("REST request to check if the current user is authenticated");
-        return request.getRemoteUser();
-    }
+//    /**
+//     * {@code GET  /authenticate} : check if the user is authenticated, and return its login.
+//     *
+//     * @param request the HTTP request.
+//     * @return the login if the user is authenticated.
+//     */
+//    @GetMapping("/authenticate")
+//    public String isAuthenticated(HttpServletRequest request) {
+//        log.debug("REST request to check if the current user is authenticated");
+//        return request.getRemoteUser();
+//    }
 
     /**
      * {@code GET  /account} : get the current user.
diff --git a/pamapi/src/main/resources/config/application-dev.yml b/pamapi/src/main/resources/config/application-dev.yml
index 14ce3bd..bc4db38 100644
--- a/pamapi/src/main/resources/config/application-dev.yml
+++ b/pamapi/src/main/resources/config/application-dev.yml
@@ -141,3 +141,4 @@
     method: 'POLLEX_GMAIL'
   file-folder-path: C://pam_file
   aes-key: PAMKEY1234567890
+  default-paxxword: 
diff --git a/pamapi/src/main/resources/config/application-pollex.yml b/pamapi/src/main/resources/config/application-pollex.yml
index 022e89a..c57a3fd 100644
--- a/pamapi/src/main/resources/config/application-pollex.yml
+++ b/pamapi/src/main/resources/config/application-pollex.yml
@@ -141,3 +141,4 @@
     method: 'POLLEX_GMAIL'
   file-folder-path: C://pam_file
   aes-key: PAMKEY1234567890
+  default-paxxword: 
diff --git a/pamapi/src/main/resources/config/application-prod.yml b/pamapi/src/main/resources/config/application-prod.yml
index 73f9399..66f50cc 100644
--- a/pamapi/src/main/resources/config/application-prod.yml
+++ b/pamapi/src/main/resources/config/application-prod.yml
@@ -154,3 +154,4 @@
     method: 'PAM_EMAIL_SERVICE'
   file-folder-path: /sfs_omo/AgentPhoto/
   aes-key: PAMKEY1234567890
+  default-paxxword: 
diff --git a/pamapi/src/main/resources/config/application-sit.yml b/pamapi/src/main/resources/config/application-sit.yml
index 75755f4..1bcbe41 100644
--- a/pamapi/src/main/resources/config/application-sit.yml
+++ b/pamapi/src/main/resources/config/application-sit.yml
@@ -131,3 +131,4 @@
     method: 'PAM_EMAIL_SERVICE'
   file-folder-path: /sfs_omo/AgentPhoto/
   aes-key: PAMKEY1234567890
+  default-paxxword: 
diff --git a/pamapi/src/main/resources/config/application-uat.yml b/pamapi/src/main/resources/config/application-uat.yml
index 03875c1..ef1d16f 100644
--- a/pamapi/src/main/resources/config/application-uat.yml
+++ b/pamapi/src/main/resources/config/application-uat.yml
@@ -131,3 +131,4 @@
     method: 'PAM_EMAIL_SERVICE'
   file-folder-path: /sfs_omo/AgentPhoto/
   aes-key: PAMKEY1234567890
+  default-paxxword: 

--
Gitblit v1.8.0