Showing
11 changed files
with
445 additions
and
14 deletions
| ... | @@ -10,12 +10,30 @@ public class PropertiesConfig { | ... | @@ -10,12 +10,30 @@ public class PropertiesConfig { |
| 10 | @Value("${fcl.login.url}") | 10 | @Value("${fcl.login.url}") |
| 11 | private String fclLoginUrl; | 11 | private String fclLoginUrl; |
| 12 | 12 | ||
| 13 | - @Value("${fcl.twidx.url}") | 13 | + @Value("${fcl.preClearIndex.url}") |
| 14 | - private String twIdxUrl; | 14 | + private String preClearIndexUrl; |
| 15 | + | ||
| 16 | + @Value("${fcl.interface.userinfo}") | ||
| 17 | + private String userInfoUrl; | ||
| 15 | 18 | ||
| 16 | @Value("${fcl.login.redjrectLogin}") | 19 | @Value("${fcl.login.redjrectLogin}") |
| 17 | private String redjrectLogin; | 20 | private String redjrectLogin; |
| 18 | 21 | ||
| 19 | @Value("${spring.profiles.env}") | 22 | @Value("${spring.profiles.env}") |
| 20 | private String env; | 23 | private String env; |
| 24 | + | ||
| 25 | + @Value("${fcl.interface.token.url}") | ||
| 26 | + private String fclTokenUrl; | ||
| 27 | + | ||
| 28 | + @Value("${fcl.interface.token.grant_type}") | ||
| 29 | + private String fclGrantType; | ||
| 30 | + | ||
| 31 | + @Value("${fcl.interface.token.client_id}") | ||
| 32 | + private String fclClientId; | ||
| 33 | + | ||
| 34 | + @Value("${fcl.interface.token.client_secret}") | ||
| 35 | + private String fclClientSecret; | ||
| 36 | + | ||
| 37 | + @Value("${fcl.interface.token.scope}") | ||
| 38 | + private String fclScope; | ||
| 21 | } | 39 | } | ... | ... |
| ... | @@ -15,10 +15,12 @@ import com.fedex.connect.common.model.sys.User; | ... | @@ -15,10 +15,12 @@ import com.fedex.connect.common.model.sys.User; |
| 15 | import com.fedex.connect.manager.common.enums.FCLSessionInfoEnum; | 15 | import com.fedex.connect.manager.common.enums.FCLSessionInfoEnum; |
| 16 | import com.fedex.connect.manager.controller.base.BaseController; | 16 | import com.fedex.connect.manager.controller.base.BaseController; |
| 17 | import com.fedex.connect.manager.controller.sys.ISysAuthController; | 17 | import com.fedex.connect.manager.controller.sys.ISysAuthController; |
| 18 | +import com.fedex.connect.manager.data.dto.FclInfoDto; | ||
| 18 | import com.fedex.connect.manager.data.dto.LogLoginDto; | 19 | import com.fedex.connect.manager.data.dto.LogLoginDto; |
| 19 | import com.fedex.connect.manager.data.dto.LoginRequest; | 20 | import com.fedex.connect.manager.data.dto.LoginRequest; |
| 20 | import com.fedex.connect.manager.data.dto.SysUserDto; | 21 | import com.fedex.connect.manager.data.dto.SysUserDto; |
| 21 | import com.fedex.connect.manager.enums.ResponseCode; | 22 | import com.fedex.connect.manager.enums.ResponseCode; |
| 23 | +import com.fedex.connect.manager.util.LoginControllerUtils; | ||
| 22 | import com.fedex.connect.manager.util.ParamConfigUtil; | 24 | import com.fedex.connect.manager.util.ParamConfigUtil; |
| 23 | import com.google.gson.JsonObject; | 25 | import com.google.gson.JsonObject; |
| 24 | import io.jsonwebtoken.Claims; | 26 | import io.jsonwebtoken.Claims; |
| ... | @@ -57,6 +59,9 @@ public class SysAuthController extends BaseController implements ISysAuthControl | ... | @@ -57,6 +59,9 @@ public class SysAuthController extends BaseController implements ISysAuthControl |
| 57 | @Autowired | 59 | @Autowired |
| 58 | private ParamConfigUtil paramConfigUtil; | 60 | private ParamConfigUtil paramConfigUtil; |
| 59 | 61 | ||
| 62 | + @Autowired | ||
| 63 | + private LoginControllerUtils loginControllerUtils; | ||
| 64 | + | ||
| 60 | @Value("${fcl.interface.logurl}") | 65 | @Value("${fcl.interface.logurl}") |
| 61 | private String fclIndexLoginUrl; | 66 | private String fclIndexLoginUrl; |
| 62 | 67 | ||
| ... | @@ -98,7 +103,7 @@ public class SysAuthController extends BaseController implements ISysAuthControl | ... | @@ -98,7 +103,7 @@ public class SysAuthController extends BaseController implements ISysAuthControl |
| 98 | res.sendRedirect(redirectUrl); | 103 | res.sendRedirect(redirectUrl); |
| 99 | } | 104 | } |
| 100 | }else { | 105 | }else { |
| 101 | - res.sendRedirect(propertiesConfig.getTwIdxUrl()); | 106 | + res.sendRedirect(propertiesConfig.getPreClearIndexUrl()); |
| 102 | } | 107 | } |
| 103 | 108 | ||
| 104 | } catch (IOException e) { | 109 | } catch (IOException e) { |
| ... | @@ -123,9 +128,13 @@ public class SysAuthController extends BaseController implements ISysAuthControl | ... | @@ -123,9 +128,13 @@ public class SysAuthController extends BaseController implements ISysAuthControl |
| 123 | if (StringUtils.isBlank(fcl_token_key)){ | 128 | if (StringUtils.isBlank(fcl_token_key)){ |
| 124 | return; | 129 | return; |
| 125 | } | 130 | } |
| 126 | - JsonObject jsonObject = sysAuthService.getFclToken(fcl_token_key); | 131 | + JsonObject tokenInfo = sysAuthService.getFclToken(fcl_token_key); |
| 127 | - String fcl_uuid = jsonObject.get(FCLSessionInfoEnum.FCL_UUID.getCode()).getAsString(); | 132 | + /** |
| 128 | - String fcl_contactname = jsonObject.get(FCLSessionInfoEnum.FCL_CONTACTNAME.getCode()).getAsString().replaceAll("\"",""); | 133 | + * 获取fcl相关信息 |
| 134 | + */ | ||
| 135 | + FclInfoDto fclInfoDto = loginControllerUtils.getFclInfo(tokenInfo); | ||
| 136 | + String fcl_uuid = fclInfoDto.getFclUuid(); | ||
| 137 | + String fcl_contactname = fclInfoDto.getFclContactname(); | ||
| 129 | 138 | ||
| 130 | User loginUser = sysUserService.findUserByFcl(fcl_uuid); | 139 | User loginUser = sysUserService.findUserByFcl(fcl_uuid); |
| 131 | if (loginUser == null){ | 140 | if (loginUser == null){ |
| ... | @@ -141,7 +150,6 @@ public class SysAuthController extends BaseController implements ISysAuthControl | ... | @@ -141,7 +150,6 @@ public class SysAuthController extends BaseController implements ISysAuthControl |
| 141 | } | 150 | } |
| 142 | } | 151 | } |
| 143 | //如果名称和原来不一样,则更新 | 152 | //如果名称和原来不一样,则更新 |
| 144 | - | ||
| 145 | if(StringUtils.isNotBlank(fcl_contactname) && !fcl_contactname.equals(loginUser.getUserName())){ | 153 | if(StringUtils.isNotBlank(fcl_contactname) && !fcl_contactname.equals(loginUser.getUserName())){ |
| 146 | String encode_fcl_contactname = StringUtils.trimToEmpty(fcl_contactname); | 154 | String encode_fcl_contactname = StringUtils.trimToEmpty(fcl_contactname); |
| 147 | if (StringUtils.isNotBlank(encode_fcl_contactname)){ | 155 | if (StringUtils.isNotBlank(encode_fcl_contactname)){ |
| ... | @@ -159,20 +167,18 @@ public class SysAuthController extends BaseController implements ISysAuthControl | ... | @@ -159,20 +167,18 @@ public class SysAuthController extends BaseController implements ISysAuthControl |
| 159 | loginRequest.setRememberMe(true); | 167 | loginRequest.setRememberMe(true); |
| 160 | ResponseVo tokenResult = sysAuthService.createAccessToken(loginRequest, loginUser); | 168 | ResponseVo tokenResult = sysAuthService.createAccessToken(loginRequest, loginUser); |
| 161 | 169 | ||
| 162 | - | ||
| 163 | DictionaryEntries dicUserLoginType = cacheSystem.getDicUserLoginType(UserLoginTypeEnum.FCLLOGINREGISTRATION.getCode()); | 170 | DictionaryEntries dicUserLoginType = cacheSystem.getDicUserLoginType(UserLoginTypeEnum.FCLLOGINREGISTRATION.getCode()); |
| 164 | //记录日志 | 171 | //记录日志 |
| 165 | LogLoginDto dto = new LogLoginDto(loginUser.getId(), dicUserLoginType.getId(), | 172 | LogLoginDto dto = new LogLoginDto(loginUser.getId(), dicUserLoginType.getId(), |
| 166 | UserLoginTypeEnum.LOGIN.getMsg()); | 173 | UserLoginTypeEnum.LOGIN.getMsg()); |
| 167 | logLoginService.saveLoginLog(dto); | 174 | logLoginService.saveLoginLog(dto); |
| 168 | - | ||
| 169 | try{ | 175 | try{ |
| 170 | if (tokenResult.isSuccess()){ | 176 | if (tokenResult.isSuccess()){ |
| 171 | String redirectUrl = String.format("%s?token=%s&uid=%s", propertiesConfig.getRedjrectLogin(), tokenResult.getData(), loginUser.getId()); | 177 | String redirectUrl = String.format("%s?token=%s&uid=%s", propertiesConfig.getRedjrectLogin(), tokenResult.getData(), loginUser.getId()); |
| 172 | res.sendRedirect(redirectUrl); | 178 | res.sendRedirect(redirectUrl); |
| 173 | log.info("wlgnLogin____________________finish:"+redirectUrl); | 179 | log.info("wlgnLogin____________________finish:"+redirectUrl); |
| 174 | }else { | 180 | }else { |
| 175 | - res.sendRedirect(propertiesConfig.getTwIdxUrl()); | 181 | + res.sendRedirect(propertiesConfig.getPreClearIndexUrl()); |
| 176 | } | 182 | } |
| 177 | } catch (IOException e) { | 183 | } catch (IOException e) { |
| 178 | log.error("FCL客户登录初始化 | 发生异常 | 异常如下:",e); | 184 | log.error("FCL客户登录初始化 | 发生异常 | 异常如下:",e); | ... | ... |
| 1 | +package com.fedex.connect.manager.data.dto; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * @Author mt | ||
| 7 | + * @Description fcl登录信息 | ||
| 8 | + * @Date 2025/5/26 | ||
| 9 | + */ | ||
| 10 | +@Data | ||
| 11 | +public class FclInfoDto { | ||
| 12 | + //fcl身份认证oauth | ||
| 13 | + String oAuthSecret; | ||
| 14 | + //fdxLogin信息 | ||
| 15 | + String fdxLogin; | ||
| 16 | + //用户uuid | ||
| 17 | + String fclUuid; | ||
| 18 | + //用户名称 | ||
| 19 | + String fclContactname; | ||
| 20 | + //用户登录账号 | ||
| 21 | + private String userId; | ||
| 22 | + //用户邮箱 | ||
| 23 | + private String emailAddress; | ||
| 24 | +} |
server/manager-server/src/main/java/com/fedex/connect/manager/data/vo/FCLTokenResponseVo.java
0 → 100644
| 1 | +package com.fedex.connect.manager.data.vo; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * FCL接口获取token响应对象 | ||
| 7 | + */ | ||
| 8 | +@Data | ||
| 9 | +public class FCLTokenResponseVo { | ||
| 10 | + | ||
| 11 | + private String access_token; | ||
| 12 | + private String token_type; | ||
| 13 | + private Long expires_in; | ||
| 14 | + private String scope; | ||
| 15 | + | ||
| 16 | + public String getAuthorization(){ | ||
| 17 | + return this.toString(this.token_type) + " " + this.toString(this.access_token); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + private String toString(String str) { | ||
| 21 | + return str == null ? "" : str; | ||
| 22 | + } | ||
| 23 | +} |
| 1 | +package com.fedex.connect.manager.data.vo; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import com.alibaba.fastjson.JSONObject; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import java.io.Serializable; | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * @Author mt | ||
| 12 | + * @Description FCL接口获取用户信息-响应数据对象 | ||
| 13 | + * @Date 2025/5/26 | ||
| 14 | + */ | ||
| 15 | +@Data | ||
| 16 | +public class FCLUserInfoVo implements Serializable { | ||
| 17 | + | ||
| 18 | + private String transactionId; | ||
| 19 | + private OutPut output; | ||
| 20 | + | ||
| 21 | + @Data | ||
| 22 | + public static class OutPut implements Serializable{ | ||
| 23 | + UserProfile userProfile; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Data | ||
| 27 | + public static class UserProfile implements Serializable{ | ||
| 28 | + private Boolean profileLocked; | ||
| 29 | + private LoginInformation loginInformation; | ||
| 30 | + private UserProfileAddress userProfileAddress; | ||
| 31 | + private String lastProfileModifiedDate; | ||
| 32 | + private String uuid; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @Data | ||
| 36 | + public static class LoginInformation implements Serializable{ | ||
| 37 | + /** | ||
| 38 | + * 用户账号信息 | ||
| 39 | + */ | ||
| 40 | + private String userId; | ||
| 41 | + private Boolean emailAsUserId; | ||
| 42 | + private SecretQuestion secretQuestion; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Data | ||
| 46 | + public static class SecretQuestion implements Serializable{ | ||
| 47 | + private String code; | ||
| 48 | + private String text; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Data | ||
| 52 | + public static class UserProfileAddress implements Serializable{ | ||
| 53 | + private Contact contact; | ||
| 54 | + private ContactAncillaryDetail contactAncillaryDetail; | ||
| 55 | + private Address address; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Data | ||
| 59 | + public static class Contact implements Serializable{ | ||
| 60 | + private PersonName personName; | ||
| 61 | + private String companyName; | ||
| 62 | + private String phoneNumber; | ||
| 63 | + private String faxNumber; | ||
| 64 | + private String emailAddress; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @Data | ||
| 68 | + public static class PersonName implements Serializable{ | ||
| 69 | + private String firstName; | ||
| 70 | + private String middleName; | ||
| 71 | + private String lastName; | ||
| 72 | + } | ||
| 73 | + @Data | ||
| 74 | + public static class ContactAncillaryDetail implements Serializable{ | ||
| 75 | + private List<PhoneNumberDetails> phoneNumberDetails; | ||
| 76 | + | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Data | ||
| 80 | + public static class PhoneNumberDetails implements Serializable{ | ||
| 81 | + private String type; | ||
| 82 | + private Number number; | ||
| 83 | + private JSONObject permissions; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + @Data | ||
| 87 | + public static class Number implements Serializable{ | ||
| 88 | + private String countryCode; | ||
| 89 | + private String localNumber; | ||
| 90 | + } | ||
| 91 | + @Data | ||
| 92 | + public static class Address implements Serializable{ | ||
| 93 | + private List<String> streetLines; | ||
| 94 | + private String city; | ||
| 95 | + private String stateOrProvinceCode; | ||
| 96 | + private String postalCode; | ||
| 97 | + private String countryCode; | ||
| 98 | + private Boolean residential; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | +} | ||
| 102 | + |
| 1 | +package com.fedex.connect.manager.data.vo; | ||
| 2 | + | ||
| 3 | +import lombok.AllArgsConstructor; | ||
| 4 | +import lombok.Data; | ||
| 5 | +import lombok.NoArgsConstructor; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @Author mt | ||
| 9 | + * @Description 调取用户信息返回VO | ||
| 10 | + * @Date 2025/5/26 | ||
| 11 | + */ | ||
| 12 | +@Data | ||
| 13 | +@NoArgsConstructor | ||
| 14 | +@AllArgsConstructor | ||
| 15 | +public class UserDataApiVo { | ||
| 16 | + private String userId; | ||
| 17 | + private String emailAddress; | ||
| 18 | + private String uuid; | ||
| 19 | + private String userName; | ||
| 20 | +} |
server/manager-server/src/main/java/com/fedex/connect/manager/util/LoginControllerUtils.java
0 → 100644
| 1 | +package com.fedex.connect.manager.util; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.fedex.connect.manager.common.enums.FCLSessionInfoEnum; | ||
| 5 | +import com.fedex.connect.manager.config.PropertiesConfig; | ||
| 6 | +import com.fedex.connect.manager.data.dto.FclInfoDto; | ||
| 7 | +import com.fedex.connect.manager.data.vo.FCLTokenResponseVo; | ||
| 8 | +import com.fedex.connect.manager.data.vo.FCLUserInfoVo; | ||
| 9 | +import com.fedex.connect.manager.data.vo.UserDataApiVo; | ||
| 10 | +import com.google.gson.JsonObject; | ||
| 11 | +import lombok.extern.slf4j.Slf4j; | ||
| 12 | +import org.apache.commons.lang3.StringUtils; | ||
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | +import org.springframework.http.*; | ||
| 15 | +import org.springframework.stereotype.Component; | ||
| 16 | +import org.springframework.util.LinkedMultiValueMap; | ||
| 17 | +import org.springframework.util.MultiValueMap; | ||
| 18 | +import org.springframework.web.client.RestTemplate; | ||
| 19 | + | ||
| 20 | +import java.net.URLDecoder; | ||
| 21 | +import java.util.*; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * @Author mt | ||
| 25 | + * @Description 登录相关util | ||
| 26 | + * @Date 2025/5/26 | ||
| 27 | + */ | ||
| 28 | +@Slf4j | ||
| 29 | +@Component | ||
| 30 | +public class LoginControllerUtils { | ||
| 31 | + /** | ||
| 32 | + * 普通访问 | ||
| 33 | + */ | ||
| 34 | + @Autowired | ||
| 35 | + private RestTemplate restTemplate; | ||
| 36 | + @Autowired | ||
| 37 | + private PropertiesConfig propertiesConfig; | ||
| 38 | + | ||
| 39 | + public FclInfoDto getFclInfo(JsonObject tokenInfo){ | ||
| 40 | + FclInfoDto fclInfoDto = new FclInfoDto(); | ||
| 41 | + String secretValue; | ||
| 42 | + String fdxLogin; | ||
| 43 | + try { | ||
| 44 | + secretValue = this.getOauthSecret(tokenInfo); | ||
| 45 | + fdxLogin = this.getFdxLogin(tokenInfo); | ||
| 46 | + FCLTokenResponseVo fclInterfaceToken = this.getFclInterfaceToken(); | ||
| 47 | + HttpHeaders headers = new HttpHeaders(); | ||
| 48 | + headers.set("Authorization", fclInterfaceToken.getAuthorization()); | ||
| 49 | + List<String> cookieList = new ArrayList<>(); | ||
| 50 | + if (StringUtils.isNotBlank(fdxLogin)) { | ||
| 51 | + cookieList.add("fdx_login=" + fdxLogin); | ||
| 52 | + } | ||
| 53 | + if (StringUtils.isNotBlank(secretValue)){ | ||
| 54 | + cookieList.add(secretValue); | ||
| 55 | + } | ||
| 56 | + headers.set("Cookie", StringUtils.join(cookieList, ";")); | ||
| 57 | + HttpEntity<String> entity = new HttpEntity("", headers); | ||
| 58 | + log.info("apiExchange | entity: {}", JSON.toJSONString(entity)); | ||
| 59 | + ResponseEntity<String> resp = restTemplate.exchange(propertiesConfig.getUserInfoUrl(), HttpMethod.GET, entity, String.class); | ||
| 60 | + log.info("apiExchange | resp: {}", JSON.toJSONString(resp)); | ||
| 61 | + String body = resp.getBody(); | ||
| 62 | + FCLUserInfoVo fclUserInfoResponse = JSON.parseObject(body, FCLUserInfoVo.class); | ||
| 63 | + //获取email和userId | ||
| 64 | + UserDataApiVo userDataApiVo = this.createUserDataApiVo(fclUserInfoResponse); | ||
| 65 | + fclInfoDto.setFclContactname(userDataApiVo.getUserName()); | ||
| 66 | + String fcl_uuid = this.getUuid(tokenInfo,userDataApiVo.getUuid()); | ||
| 67 | + String fcl_contactname = this.decodeMultiLevelUrl(this.getFclContactName(tokenInfo,userDataApiVo.getUserName())); | ||
| 68 | + fclInfoDto.setFclUuid(fcl_uuid); | ||
| 69 | + fclInfoDto.setFclContactname(fcl_contactname); | ||
| 70 | + fclInfoDto.setOAuthSecret(secretValue); | ||
| 71 | + fclInfoDto.setFdxLogin(fdxLogin); | ||
| 72 | + fclInfoDto.setUserId(userDataApiVo.getUserId()); | ||
| 73 | + fclInfoDto.setEmailAddress(userDataApiVo.getEmailAddress()); | ||
| 74 | + }catch(Exception ex){ | ||
| 75 | + log.error("apiExchange | fdxLogin: {}, secretValue: {} url: {}, userId: {} |具体原因: " | ||
| 76 | + , fclInfoDto.getFdxLogin(), fclInfoDto.getOAuthSecret(), propertiesConfig.getUserInfoUrl(),fclInfoDto.getUserId()); | ||
| 77 | + ex.printStackTrace(); | ||
| 78 | + } | ||
| 79 | + return fclInfoDto; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * @Author mt | ||
| 84 | + * @Description 构建获取用户信息Vo | ||
| 85 | + * @Date 2025/5/26 | ||
| 86 | + * @param fclUserInfoResponse | ||
| 87 | + * @return com.fedex.connect.manager.data.vo.UserDataApiVo | ||
| 88 | + */ | ||
| 89 | + public UserDataApiVo createUserDataApiVo(FCLUserInfoVo fclUserInfoResponse) { | ||
| 90 | + FCLUserInfoVo.UserProfile userProfile = fclUserInfoResponse.getOutput().getUserProfile(); | ||
| 91 | + Optional<String> userId = Optional.ofNullable(userProfile) | ||
| 92 | + .map(FCLUserInfoVo.UserProfile::getLoginInformation) | ||
| 93 | + .map(FCLUserInfoVo.LoginInformation::getUserId); | ||
| 94 | + | ||
| 95 | + Optional<String> emailAddress = Optional.ofNullable(userProfile) | ||
| 96 | + .map(FCLUserInfoVo.UserProfile::getUserProfileAddress) | ||
| 97 | + .map(FCLUserInfoVo.UserProfileAddress::getContact) | ||
| 98 | + .map(FCLUserInfoVo.Contact::getEmailAddress) | ||
| 99 | + .filter(email -> !email.isEmpty()); | ||
| 100 | + | ||
| 101 | + Optional<String> uuid = Optional.ofNullable(userProfile) | ||
| 102 | + .map(FCLUserInfoVo.UserProfile :: getUuid); | ||
| 103 | + | ||
| 104 | + Optional<String> firstNameOpt = Optional.ofNullable(userProfile) | ||
| 105 | + .map(FCLUserInfoVo.UserProfile::getUserProfileAddress) | ||
| 106 | + .map(FCLUserInfoVo.UserProfileAddress::getContact) | ||
| 107 | + .map(FCLUserInfoVo.Contact::getPersonName) | ||
| 108 | + .map(personName -> personName.getFirstName()); | ||
| 109 | + | ||
| 110 | + Optional<String> lastNameOpt = Optional.ofNullable(userProfile) | ||
| 111 | + .map(FCLUserInfoVo.UserProfile::getUserProfileAddress) | ||
| 112 | + .map(FCLUserInfoVo.UserProfileAddress::getContact) | ||
| 113 | + .map(FCLUserInfoVo.Contact::getPersonName) | ||
| 114 | + .map(personName -> personName.getLastName()); | ||
| 115 | + String userName = null; | ||
| 116 | + if (firstNameOpt.isPresent() && lastNameOpt.isPresent()){ | ||
| 117 | + userName = firstNameOpt.get() + "+" + lastNameOpt.get(); | ||
| 118 | + }else if (firstNameOpt.isPresent()){ | ||
| 119 | + userName = firstNameOpt.get(); | ||
| 120 | + }if (lastNameOpt.isPresent()){ | ||
| 121 | + userName = lastNameOpt.get(); | ||
| 122 | + } | ||
| 123 | + return new UserDataApiVo(userId.orElse(null), emailAddress.orElse(null),uuid.orElse(null),userName); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + | ||
| 127 | + public FCLTokenResponseVo getFclInterfaceToken(){ | ||
| 128 | + HttpHeaders headers = new HttpHeaders(); | ||
| 129 | + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
| 130 | + MultiValueMap<String,String> postParameters = new LinkedMultiValueMap<>(); | ||
| 131 | + postParameters.put("client_id", Collections.singletonList(propertiesConfig.getFclClientId())); | ||
| 132 | + postParameters.put("client_secret", Collections.singletonList(propertiesConfig.getFclClientSecret())); | ||
| 133 | + postParameters.put("scope", Collections.singletonList(propertiesConfig.getFclScope())); | ||
| 134 | + postParameters.put("grant_type", Collections.singletonList(propertiesConfig.getFclGrantType())); | ||
| 135 | + HttpEntity<String> entity = new HttpEntity(postParameters,headers); | ||
| 136 | + String fclTokenUrl = propertiesConfig.getFclTokenUrl(); | ||
| 137 | + ResponseEntity<FCLTokenResponseVo> resp = restTemplate.exchange(fclTokenUrl, HttpMethod.POST, entity, FCLTokenResponseVo.class); | ||
| 138 | + return resp.getBody(); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + /** | ||
| 142 | + * @Author mt | ||
| 143 | + * @Description 获取fdxLogin | ||
| 144 | + * @Date 2025/5/26 | ||
| 145 | + * @param tokenInfo | ||
| 146 | + * @return java.lang.String | ||
| 147 | + */ | ||
| 148 | + private String getFdxLogin(JsonObject tokenInfo) { | ||
| 149 | + if (tokenInfo == null) { | ||
| 150 | + return ""; | ||
| 151 | + } | ||
| 152 | + /** | ||
| 153 | + * 先获取fdx_login | ||
| 154 | + */ | ||
| 155 | + return Optional.ofNullable(tokenInfo.get(FCLSessionInfoEnum.FDX_LOGIN.getCode())) | ||
| 156 | + .map(Object::toString) | ||
| 157 | + .orElse(""); | ||
| 158 | + | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + /** | ||
| 162 | + * @Author mt | ||
| 163 | + * @Description 获取oauthSecret | ||
| 164 | + * @Date 2025/5/26 | ||
| 165 | + * @param tokenInfo | ||
| 166 | + * @return java.lang.String | ||
| 167 | + */ | ||
| 168 | + private String getOauthSecret(JsonObject tokenInfo){ | ||
| 169 | + Object secretValue = tokenInfo.get(FCLSessionInfoEnum.FCL_OAUTH.getCode()); | ||
| 170 | + if (secretValue != null) { | ||
| 171 | + return FCLSessionInfoEnum.FCL_OAUTH.getCode() + "=" + secretValue.toString(); | ||
| 172 | + } | ||
| 173 | + return ""; | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + /** | ||
| 177 | + * @Author mt | ||
| 178 | + * @Description 安全获取用户名 | ||
| 179 | + * @Date 2025/5/26 | ||
| 180 | + * @param tokenInfo | ||
| 181 | + * @param userName | ||
| 182 | + * @return java.lang.String | ||
| 183 | + */ | ||
| 184 | + private String getFclContactName(JsonObject tokenInfo,String userName){ | ||
| 185 | + String fcl_contactname = ""; | ||
| 186 | + | ||
| 187 | + if (tokenInfo != null) { | ||
| 188 | + Object contactObj = tokenInfo.get(FCLSessionInfoEnum.FCL_CONTACTNAME.getCode()); | ||
| 189 | + if (contactObj != null) { | ||
| 190 | + fcl_contactname = contactObj.toString().replace("\"", ""); | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + if (StringUtils.isBlank(fcl_contactname) && StringUtils.isNotBlank(userName)){ | ||
| 194 | + fcl_contactname = userName; | ||
| 195 | + } | ||
| 196 | + return fcl_contactname; | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + /** | ||
| 200 | + * @Author mt | ||
| 201 | + * @Description 获取uuid | ||
| 202 | + * @Date 2025/5/26 | ||
| 203 | + * @param tokenInfo | ||
| 204 | + * @param uuidApi | ||
| 205 | + * @return java.lang.String | ||
| 206 | + */ | ||
| 207 | + private String getUuid(JsonObject tokenInfo, String uuidApi) { | ||
| 208 | + return Optional.ofNullable(tokenInfo) | ||
| 209 | + .map(info -> info.get(FCLSessionInfoEnum.FCL_UUID.getCode())) | ||
| 210 | + .map(Objects::toString) | ||
| 211 | + .orElseGet(() -> Optional.ofNullable(uuidApi) | ||
| 212 | + .orElse("")); | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + /** | ||
| 216 | + * @Author mt | ||
| 217 | + * @Description 对用户名进行解码处理 | ||
| 218 | + * @Date 2025/5/26 | ||
| 219 | + * @param encodedStr | ||
| 220 | + * @return java.lang.String | ||
| 221 | + */ | ||
| 222 | + private String decodeMultiLevelUrl(String encodedStr) { | ||
| 223 | + if (StringUtils.isBlank(encodedStr)){ | ||
| 224 | + return ""; | ||
| 225 | + } | ||
| 226 | + String current = encodedStr; | ||
| 227 | + String previous; | ||
| 228 | + do { | ||
| 229 | + previous = current; | ||
| 230 | + try { | ||
| 231 | + current = URLDecoder.decode(current, "UTF-8"); | ||
| 232 | + } catch (Exception e) { | ||
| 233 | + return current; | ||
| 234 | + } | ||
| 235 | + } while (!current.equals(previous)); | ||
| 236 | + return current; | ||
| 237 | + } | ||
| 238 | +} |
| ... | @@ -33,7 +33,7 @@ fcl: | ... | @@ -33,7 +33,7 @@ fcl: |
| 33 | url: | 33 | url: |
| 34 | https://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnLogin | 34 | https://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnLogin |
| 35 | redjrectLogin: https://iclear-connectuat.apac.fedex.com/ipc/#/redjrectLogin | 35 | redjrectLogin: https://iclear-connectuat.apac.fedex.com/ipc/#/redjrectLogin |
| 36 | - twidx: | 36 | + preClearIndex: |
| 37 | url: http://iclear-connectuat.apac.fedex.com | 37 | url: http://iclear-connectuat.apac.fedex.com |
| 38 | interface: | 38 | interface: |
| 39 | logurl: https://www.fedex.com/secure-login/en-us/#/login-credentials?redirectUrl=http://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnForward | 39 | logurl: https://www.fedex.com/secure-login/en-us/#/login-credentials?redirectUrl=http://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnForward | ... | ... |
| ... | @@ -26,7 +26,7 @@ fcl: | ... | @@ -26,7 +26,7 @@ fcl: |
| 26 | login: | 26 | login: |
| 27 | url: https://exportdeclaration-tw.apac.fedex.com/icleartw/auth/wlgnLogin | 27 | url: https://exportdeclaration-tw.apac.fedex.com/icleartw/auth/wlgnLogin |
| 28 | redjrectLogin: https://exportdeclaration-tw.apac.fedex.com/IcTw/#/redjrectLogin | 28 | redjrectLogin: https://exportdeclaration-tw.apac.fedex.com/IcTw/#/redjrectLogin |
| 29 | - twidx: | 29 | + preClearIndex: |
| 30 | url: https://exportdeclaration-tw.apac.fedex.com | 30 | url: https://exportdeclaration-tw.apac.fedex.com |
| 31 | interface: | 31 | interface: |
| 32 | logurl: https://www.fedex.com/secure-login/zh-tw/#/login-credentials?redirectUrl=https://exportdeclaration-tw.apac.fedex.com/icleartw/auth/wlgnForward | 32 | logurl: https://www.fedex.com/secure-login/zh-tw/#/login-credentials?redirectUrl=https://exportdeclaration-tw.apac.fedex.com/icleartw/auth/wlgnForward | ... | ... |
| ... | @@ -27,7 +27,7 @@ fcl: | ... | @@ -27,7 +27,7 @@ fcl: |
| 27 | url: | 27 | url: |
| 28 | https://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnLogin | 28 | https://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnLogin |
| 29 | redjrectLogin: https://iclear-connectuat.apac.fedex.com/ipc/#/redjrectLogin | 29 | redjrectLogin: https://iclear-connectuat.apac.fedex.com/ipc/#/redjrectLogin |
| 30 | - twidx: | 30 | + preClearIndex: |
| 31 | url: http://iclear-connectuat.apac.fedex.com | 31 | url: http://iclear-connectuat.apac.fedex.com |
| 32 | interface: | 32 | interface: |
| 33 | logurl: https://www.fedex.com/secure-login/en-us/#/login-credentials?redirectUrl=http://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnForward | 33 | logurl: https://www.fedex.com/secure-login/en-us/#/login-credentials?redirectUrl=http://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnForward | ... | ... |
| ... | @@ -26,7 +26,7 @@ fcl: | ... | @@ -26,7 +26,7 @@ fcl: |
| 26 | url: | 26 | url: |
| 27 | https://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnLogin | 27 | https://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnLogin |
| 28 | redjrectLogin: https://iclear-connectuat.apac.fedex.com/ipc/#/redjrectLogin | 28 | redjrectLogin: https://iclear-connectuat.apac.fedex.com/ipc/#/redjrectLogin |
| 29 | - twidx: | 29 | + preClearIndex: |
| 30 | url: http://iclear-connectuat.apac.fedex.com | 30 | url: http://iclear-connectuat.apac.fedex.com |
| 31 | interface: | 31 | interface: |
| 32 | logurl: https://www.fedex.com/secure-login/en-us/#/login-credentials?redirectUrl=http://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnForward | 32 | logurl: https://www.fedex.com/secure-login/en-us/#/login-credentials?redirectUrl=http://iclear-connectuat.apac.fedex.com/manager-server/auth/wlgnForward | ... | ... |
-
Please register or login to post a comment