Niceon token발생 관련수정
This commit is contained in:
+26
-1
@@ -306,7 +306,8 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
accessToken = (OAuth2AccessTokenVO) tokenManager.getAccessTokenVO(vo.getAdapterGroupName());
|
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();
|
String oldToken = accessToken == null ? null : accessToken.getAccessToken();
|
||||||
accessToken = (OAuth2AccessTokenVO) tokenManager.retryAccessTokenVO(vo.getAdapterGroupName(), prop,
|
accessToken = (OAuth2AccessTokenVO) tokenManager.retryAccessTokenVO(vo.getAdapterGroupName(), prop,
|
||||||
oldToken);
|
oldToken);
|
||||||
@@ -321,6 +322,9 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
String encryptAlgorithm = properties.getProperty("ENCRYPT_ALGORITHM"); // jwhong
|
String encryptAlgorithm = properties.getProperty("ENCRYPT_ALGORITHM"); // jwhong
|
||||||
if (useAdapterToken && "AES256-NICEON".equals(encryptAlgorithm)) {
|
if (useAdapterToken && "AES256-NICEON".equals(encryptAlgorithm)) {
|
||||||
String niceToken = accessToken.getAccessToken();
|
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);
|
String clientId = JwtClientIdExtractor(niceToken);
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
auth = niceToken + ":" + currentTime + ":" + clientId ;
|
auth = niceToken + ":" + currentTime + ":" + clientId ;
|
||||||
@@ -868,6 +872,27 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
return jwtToken;
|
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")
|
@SuppressWarnings("deprecation")
|
||||||
private void assignPostBody(Object eaiBody, String contentType, String charset, HttpUriRequestBase method, String adapterName, String niceAuth, String inboundToken) {
|
private void assignPostBody(Object eaiBody, String contentType, String charset, HttpUriRequestBase method, String adapterName, String niceAuth, String inboundToken) {
|
||||||
if (eaiBody == null) {
|
if (eaiBody == null) {
|
||||||
|
|||||||
+8
-4
@@ -115,8 +115,6 @@ public class HttpClientAccessTokenServiceWithBase64Header implements HttpClientA
|
|||||||
uri, encode, timeout, connectionTimeout, useForwardProxy, forwardProxyUrl);
|
uri, encode, timeout, connectionTimeout, useForwardProxy, forwardProxyUrl);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// mTLS config with default connection parameters
|
// mTLS config with default connection parameters
|
||||||
boolean useMtls = StringUtils.equalsIgnoreCase(adapterProp.getProperty(HttpClientAdapterServiceKey.USE_MTLS),
|
boolean useMtls = StringUtils.equalsIgnoreCase(adapterProp.getProperty(HttpClientAdapterServiceKey.USE_MTLS),
|
||||||
"Y");
|
"Y");
|
||||||
@@ -237,17 +235,19 @@ public class HttpClientAccessTokenServiceWithBase64Header implements HttpClientA
|
|||||||
logger.debug("contentType = [" + contentType + "]");
|
logger.debug("contentType = [" + contentType + "]");
|
||||||
logger.debug("encode = [" + encode + "]");
|
logger.debug("encode = [" + encode + "]");
|
||||||
|
|
||||||
|
OAuth2AccessTokenVO accessToken = new OAuth2AccessTokenVO();
|
||||||
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
|
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
|
||||||
if (response.getCode() != 200) {
|
if (response.getCode() != 200) {
|
||||||
throw new Exception("OAuth token receive status fail value= " + response.getCode());
|
throw new Exception("OAuth token receive status fail value= " + response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info("HttpClientAccessTokenServiceWithBase64Header==>" + response.getCode());
|
||||||
|
|
||||||
HttpEntity entity = response.getEntity();
|
HttpEntity entity = response.getEntity();
|
||||||
String responseString = EntityUtils.toString(entity, encode);
|
String responseString = EntityUtils.toString(entity, encode);
|
||||||
logger.debug("oauthToken RECV = [" + responseString + "]");
|
logger.debug("Base64Header oauthToken RECV = [" + responseString + "]");
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(responseString)) {
|
if (StringUtils.isNotBlank(responseString)) {
|
||||||
OAuth2AccessTokenVO accessToken = new OAuth2AccessTokenVO();
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
JsonNode responseJSON = objectMapper.readTree(responseString);
|
JsonNode responseJSON = objectMapper.readTree(responseString);
|
||||||
@@ -272,6 +272,10 @@ public class HttpClientAccessTokenServiceWithBase64Header implements HttpClientA
|
|||||||
} else {
|
} else {
|
||||||
throw new Exception("oauth token return null");
|
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