Niceon token발생 관련수정
This commit is contained in:
+26
-1
@@ -306,7 +306,8 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
accessToken = (OAuth2AccessTokenVO) tokenManager.getAccessTokenVO(vo.getAdapterGroupName());
|
||||
|
||||
// 토큰이 없거나 만료 됐으면 재발급
|
||||
if (accessToken == null || accessToken.isExpired()) {
|
||||
//if (accessToken == null || accessToken.isExpired()) {
|
||||
if (accessToken == null || accessToken.isExpired() || accessToken.getAccessToken() == null ) { // jwhong
|
||||
String oldToken = accessToken == null ? null : accessToken.getAccessToken();
|
||||
accessToken = (OAuth2AccessTokenVO) tokenManager.retryAccessTokenVO(vo.getAdapterGroupName(), prop,
|
||||
oldToken);
|
||||
@@ -321,6 +322,9 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
String encryptAlgorithm = properties.getProperty("ENCRYPT_ALGORITHM"); // jwhong
|
||||
if (useAdapterToken && "AES256-NICEON".equals(encryptAlgorithm)) {
|
||||
String niceToken = accessToken.getAccessToken();
|
||||
if ( niceToken == null || niceToken == "") {
|
||||
throw new Exception("NiceOn Token is empty, toke failed to be issued, TOKEN = [" + niceToken + "]");
|
||||
}
|
||||
String clientId = JwtClientIdExtractor(niceToken);
|
||||
long currentTime = System.currentTimeMillis();
|
||||
auth = niceToken + ":" + currentTime + ":" + clientId ;
|
||||
@@ -868,6 +872,27 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
return jwtToken;
|
||||
}
|
||||
|
||||
private static Map<String, String> parseInboundHeader(String str) {
|
||||
java.util.HashMap<String, String> map = new java.util.HashMap<>();
|
||||
if (str == null || str.isEmpty()) return map;
|
||||
|
||||
// 중괄호 제거
|
||||
str = str.trim();
|
||||
if (str.startsWith("{") && str.endsWith("}")) {
|
||||
str = str.substring(1, str.length() - 1);
|
||||
}
|
||||
|
||||
// key=value 쌍 분리
|
||||
String[] pairs = str.split(",");
|
||||
for (String pair : pairs) {
|
||||
String[] kv = pair.split("=", 2);
|
||||
if (kv.length == 2) {
|
||||
map.put(kv[0].trim(), kv[1].trim());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void assignPostBody(Object eaiBody, String contentType, String charset, HttpUriRequestBase method, String adapterName, String niceAuth, String inboundToken) {
|
||||
if (eaiBody == null) {
|
||||
|
||||
+8
-4
@@ -115,8 +115,6 @@ public class HttpClientAccessTokenServiceWithBase64Header implements HttpClientA
|
||||
uri, encode, timeout, connectionTimeout, useForwardProxy, forwardProxyUrl);
|
||||
|
||||
|
||||
|
||||
|
||||
// mTLS config with default connection parameters
|
||||
boolean useMtls = StringUtils.equalsIgnoreCase(adapterProp.getProperty(HttpClientAdapterServiceKey.USE_MTLS),
|
||||
"Y");
|
||||
@@ -237,17 +235,19 @@ public class HttpClientAccessTokenServiceWithBase64Header implements HttpClientA
|
||||
logger.debug("contentType = [" + contentType + "]");
|
||||
logger.debug("encode = [" + encode + "]");
|
||||
|
||||
OAuth2AccessTokenVO accessToken = new OAuth2AccessTokenVO();
|
||||
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
|
||||
if (response.getCode() != 200) {
|
||||
throw new Exception("OAuth token receive status fail value= " + response.getCode());
|
||||
}
|
||||
|
||||
logger.info("HttpClientAccessTokenServiceWithBase64Header==>" + response.getCode());
|
||||
|
||||
HttpEntity entity = response.getEntity();
|
||||
String responseString = EntityUtils.toString(entity, encode);
|
||||
logger.debug("oauthToken RECV = [" + responseString + "]");
|
||||
logger.debug("Base64Header oauthToken RECV = [" + responseString + "]");
|
||||
|
||||
if (StringUtils.isNotBlank(responseString)) {
|
||||
OAuth2AccessTokenVO accessToken = new OAuth2AccessTokenVO();
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode responseJSON = objectMapper.readTree(responseString);
|
||||
@@ -272,6 +272,10 @@ public class HttpClientAccessTokenServiceWithBase64Header implements HttpClientA
|
||||
} else {
|
||||
throw new Exception("oauth token return null");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("[HttpClientAccessTokenServiceWithBase64Header] retrieve accessToken exception :" + e.getMessage());
|
||||
return accessToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user