Niceon 암호화 key 생성 수정
This commit is contained in:
+40
-10
@@ -91,7 +91,7 @@ import com.kjbank.encrypt.exchange.crypto.AES256GCMCipher;
|
|||||||
import com.kjbank.encrypt.exchange.crypto.ECDHESA256Cipher;
|
import com.kjbank.encrypt.exchange.crypto.ECDHESA256Cipher;
|
||||||
import com.eactive.eai.authserver.service.OAuth2Manager;
|
import com.eactive.eai.authserver.service.OAuth2Manager;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. 기능 : EAI HTTP OutBound 용 어댑터로 수동 시스템의 HTTP 웹 컴포넌트를 GET/POST 방식으로 호출할 수 있는
|
* 1. 기능 : EAI HTTP OutBound 용 어댑터로 수동 시스템의 HTTP 웹 컴포넌트를 GET/POST 방식으로 호출할 수 있는
|
||||||
@@ -325,9 +325,10 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
if ( niceToken == null || niceToken == "") {
|
if ( niceToken == null || niceToken == "") {
|
||||||
throw new Exception("NiceOn Token is empty, TOKEN failed to be issued, TOKEN = [" + niceToken + "]");
|
throw new Exception("NiceOn Token is empty, TOKEN failed to be issued, TOKEN = [" + niceToken + "]");
|
||||||
}
|
}
|
||||||
String clientId = JwtClientIdExtractor(niceToken);
|
String clientId = accessToken.getClientId(); // HttpClientAccessTokenServiceWithBase64NiceOn 서 넣어줌
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
auth = niceToken + ":" + currentTime + ":" + clientId ;
|
auth = niceToken + ":" + currentTime + ":" + clientId ;
|
||||||
|
logger.debug("HttpClientAdapterServiceRest] NiceOn auth = [" + auth + "]");
|
||||||
auth = Base64.getEncoder().encodeToString(auth.getBytes("UTF-8"));
|
auth = Base64.getEncoder().encodeToString(auth.getBytes("UTF-8"));
|
||||||
|
|
||||||
setNiceOnAuthHeaders(method, auth);
|
setNiceOnAuthHeaders(method, auth);
|
||||||
@@ -853,21 +854,50 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
jwtToken = authorization.substring(7); // "Bearer " 이후의 JWT만 추출
|
jwtToken = authorization.substring(7); // "Bearer " 이후의 JWT만 추출
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String headerRelay = PropManager.getInstance().getProperty("HEADER_RELAY_ADAPTER","adapter.name");
|
||||||
|
Set<String> values = new HashSet<>(Arrays.asList(headerRelay.split(",")));
|
||||||
|
String inputAdapter = tempProp.getProperty(HttpAdapterServiceKey.OUT_ADAPTER_GROUP_NAME, "");
|
||||||
|
|
||||||
|
String[] parts = inputAdapter.split("_");
|
||||||
|
String target = parts[1]; // adapter name의 앞의 3자리
|
||||||
|
String adapterName = target.substring(0, 3);
|
||||||
|
|
||||||
|
if (values.contains(adapterName)) {
|
||||||
|
|
||||||
|
/* 업체정보 */
|
||||||
|
String clientId = JwtClientIdExtractor(jwtToken);
|
||||||
|
method.setHeader("clientId", clientId);
|
||||||
|
|
||||||
|
/* APIM 거래추적자 */
|
||||||
|
String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID, "");
|
||||||
|
method.setHeader("traceId", uuid);
|
||||||
|
|
||||||
|
/* GUID */
|
||||||
|
String guid = tempProp.getProperty(TransactionContextKeys.GUID, "");
|
||||||
|
method.setHeader("guid", guid);
|
||||||
|
|
||||||
|
/* 최초요청시간 */
|
||||||
|
String receivedTimestamp = tempProp.getProperty(HttpAdapterServiceKey.INBOUND_REQUESTED_TIME, "");
|
||||||
|
method.setHeader("receivedTimestamp", receivedTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 업체정보 */
|
/* 업체정보 */
|
||||||
String clientId = JwtClientIdExtractor(jwtToken);
|
//String clientId = JwtClientIdExtractor(jwtToken);
|
||||||
method.setHeader("clientId", clientId);
|
//method.setHeader("clientId", clientId);
|
||||||
|
|
||||||
/* APIM 거래추적자 */
|
/* APIM 거래추적자 */
|
||||||
String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID, "");
|
//String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID, "");
|
||||||
method.setHeader("traceId", uuid);
|
//method.setHeader("traceId", uuid);
|
||||||
|
|
||||||
/* GUID */
|
/* GUID */
|
||||||
String guid = tempProp.getProperty(TransactionContextKeys.GUID, "");
|
//String guid = tempProp.getProperty(TransactionContextKeys.GUID, "");
|
||||||
method.setHeader("guid", guid);
|
//method.setHeader("guid", guid);
|
||||||
|
|
||||||
/* 최초요청시간 */
|
/* 최초요청시간 */
|
||||||
String receivedTimestamp = tempProp.getProperty(HttpAdapterServiceKey.INBOUND_REQUESTED_TIME, "");
|
//String receivedTimestamp = tempProp.getProperty(HttpAdapterServiceKey.INBOUND_REQUESTED_TIME, "");
|
||||||
method.setHeader("receivedTimestamp", receivedTimestamp);
|
//method.setHeader("receivedTimestamp", receivedTimestamp);
|
||||||
|
|
||||||
return jwtToken;
|
return jwtToken;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public interface HttpAdapterServiceKey {
|
|||||||
static final String INBOUND_REQUESTED_TIME = "INBOUND_REQUESTED_TIME"; // jwhong
|
static final String INBOUND_REQUESTED_TIME = "INBOUND_REQUESTED_TIME"; // jwhong
|
||||||
static final String GUID = "GUID"; // jwhong
|
static final String GUID = "GUID"; // jwhong
|
||||||
static final String API_SERVICE_CODE = "API_SERVICE_CODE"; // jwhong
|
static final String API_SERVICE_CODE = "API_SERVICE_CODE"; // jwhong
|
||||||
|
static final String OUT_ADAPTER_GROUP_NAME = "OUT_ADAPTER_GROUP_NAME"; // jwhong
|
||||||
|
|
||||||
//응답 처리 용 표준 전문 오브젝트
|
//응답 처리 용 표준 전문 오브젝트
|
||||||
static final String STANDARD_MESSAGE_OBJECT = "STANDARD_MESSAGE_OBJECT";
|
static final String STANDARD_MESSAGE_OBJECT = "STANDARD_MESSAGE_OBJECT";
|
||||||
|
|||||||
+27
-21
@@ -115,12 +115,11 @@ public class HttpClientAccessTokenServiceWithBase64NiceOn implements HttpClientA
|
|||||||
uri, encode, timeout, connectionTimeout, useForwardProxy, forwardProxyUrl);
|
uri, encode, timeout, connectionTimeout, useForwardProxy, forwardProxyUrl);
|
||||||
|
|
||||||
List<NameValuePair> formParams = new ArrayList<>();
|
List<NameValuePair> formParams = new ArrayList<>();
|
||||||
formParams.add(new BasicNameValuePair("client_id", oAuthCredentialVo.getClientId()));
|
//formParams.add(new BasicNameValuePair("client_id", oAuthCredentialVo.getClientId()));
|
||||||
formParams.add(new BasicNameValuePair("client_secret", oAuthCredentialVo.getClientSecret()));
|
//formParams.add(new BasicNameValuePair("client_secret", oAuthCredentialVo.getClientSecret()));
|
||||||
formParams.add(new BasicNameValuePair("scope", oAuthCredentialVo.getScope()));
|
|
||||||
formParams.add(new BasicNameValuePair("grant_type", oAuthCredentialVo.getGrantType()));
|
formParams.add(new BasicNameValuePair("grant_type", oAuthCredentialVo.getGrantType()));
|
||||||
|
formParams.add(new BasicNameValuePair("scope", oAuthCredentialVo.getScope()));
|
||||||
String postParameters = "client_id=" + oAuthCredentialVo.getClientId() + "&client_secret=" + oAuthCredentialVo.getClientSecret() + "&scope=" + oAuthCredentialVo.getScope() + "&grant_type=" + oAuthCredentialVo.getGrantType();
|
//String postParameters = "grant_type=" + oAuthCredentialVo.getGrantType() + "&scope=" + oAuthCredentialVo.getScope();
|
||||||
|
|
||||||
|
|
||||||
// mTLS config with default connection parameters
|
// mTLS config with default connection parameters
|
||||||
@@ -198,9 +197,9 @@ public class HttpClientAccessTokenServiceWithBase64NiceOn implements HttpClientA
|
|||||||
|
|
||||||
try (CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connectionManager).build();) {
|
try (CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connectionManager).build();) {
|
||||||
HttpPost httpPost = new HttpPost(uri);
|
HttpPost httpPost = new HttpPost(uri);
|
||||||
//httpPost.setEntity(new UrlEncodedFormEntity(formParams, charset));
|
httpPost.setEntity(new UrlEncodedFormEntity(formParams, charset));
|
||||||
httpPost.setEntity(new StringEntity(postParameters, StandardCharsets.UTF_8));
|
//httpPost.setEntity(new StringEntity(postParameters, StandardCharsets.UTF_8));
|
||||||
httpPost.setHeader("Content-Type", contentType+" charset=" + encode);
|
httpPost.setHeader("Content-Type", contentType+";charset=" + encode); // 중간에 ; 주어야 함
|
||||||
|
|
||||||
//HTTP HEADER에 client id, client secret를 base64Encode 한 후 추가
|
//HTTP HEADER에 client id, client secret를 base64Encode 한 후 추가
|
||||||
String cId = oAuthCredentialVo.getClientId();
|
String cId = oAuthCredentialVo.getClientId();
|
||||||
@@ -228,32 +227,38 @@ public class HttpClientAccessTokenServiceWithBase64NiceOn implements HttpClientA
|
|||||||
.setResponseTimeout(Timeout.ofMilliseconds(timeout)).build();
|
.setResponseTimeout(Timeout.ofMilliseconds(timeout)).build();
|
||||||
httpPost.setConfig(requestConfig);
|
httpPost.setConfig(requestConfig);
|
||||||
|
|
||||||
logger.debug("uri = [" + uri + "]");
|
logger.debug("uri = [" + uri + "]");
|
||||||
logger.debug("oauthClientId = [" + oAuthCredentialVo.getClientId() + "]");
|
logger.debug("oauthClientId = [" + oAuthCredentialVo.getClientId() + "]");
|
||||||
logger.debug("oauthClientSecret = [" + oAuthCredentialVo.getClientSecret() + "]");
|
logger.debug("oauthClientSecret = [" + oAuthCredentialVo.getClientSecret() + "]");
|
||||||
logger.debug("oauthScope = [" + oAuthCredentialVo.getScope() + "]");
|
logger.debug("oauthScope = [" + oAuthCredentialVo.getScope() + "]");
|
||||||
logger.debug("oauthGrantType = [" + oAuthCredentialVo.getGrantType() + "]");
|
logger.debug("oauthGrantType = [" + oAuthCredentialVo.getGrantType() + "]");
|
||||||
logger.debug("oauthauthValue = [" + authValue + "]");
|
logger.debug("oauthauthValue = [" + authValue + "]");
|
||||||
logger.debug("oauthauthEncodedAuth = [" + encodedAuth + "]");
|
logger.debug("oauthauthEncodedAuth = [" + encodedAuth + "]");
|
||||||
logger.debug("contentType = [" + contentType + "]");
|
logger.debug("contentType = [" + contentType + "]");
|
||||||
logger.debug("encode = [" + encode + "]");
|
logger.debug("encode = [" + encode + "]");
|
||||||
|
|
||||||
OAuth2AccessTokenVO accessToken = new OAuth2AccessTokenVO();
|
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("NiceOn token receive status fail value= " + response.getCode());
|
throw new Exception("NiceOn token receive status fail value== " + response.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("HttpClientAccessTokenServiceWithBase64NiceOn==>" + response.getCode());
|
logger.info("HttpClientAccessTokenServiceWithBase64NiceOn==>" + response.getCode());
|
||||||
|
|
||||||
HttpEntity entity = response.getEntity();
|
HttpEntity entity = response.getEntity();
|
||||||
String responseString = EntityUtils.toString(entity, encode);
|
String responseString = EntityUtils.toString(entity, encode);
|
||||||
logger.debug("Base64NiceOn oauthToken RECV = [" + responseString + "]");
|
logger.debug("Base64NiceOn oauthToken RECV == [" + responseString + "]");
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(responseString)) {
|
if (StringUtils.isNotBlank(responseString)) {
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
JsonNode responseJSON = objectMapper.readTree(responseString);
|
JsonNode responseJSONRtn = objectMapper.readTree(responseString);
|
||||||
|
JsonNode responseJSON = null;
|
||||||
|
String gwRsltCd = responseJSONRtn.get("dataHeader").get("GW_RSLT_CD").asText();
|
||||||
|
|
||||||
|
if ("1200".equals(gwRsltCd)) {
|
||||||
|
responseJSON = responseJSONRtn.get("dataBody");
|
||||||
|
}
|
||||||
|
|
||||||
if (responseJSON.has("access_token") && responseJSON.has("token_type")
|
if (responseJSON.has("access_token") && responseJSON.has("token_type")
|
||||||
&& responseJSON.has("expires_in") && responseJSON.has("scope")) {
|
&& responseJSON.has("expires_in") && responseJSON.has("scope")) {
|
||||||
@@ -263,13 +268,14 @@ public class HttpClientAccessTokenServiceWithBase64NiceOn implements HttpClientA
|
|||||||
long expiresIn = responseJSON.get("expires_in").asLong();
|
long expiresIn = responseJSON.get("expires_in").asLong();
|
||||||
accessToken.setExpiration(new Date(currentTime + expiresIn * 1000L));
|
accessToken.setExpiration(new Date(currentTime + expiresIn * 1000L));
|
||||||
accessToken.setScope(responseJSON.get("scope").asText());
|
accessToken.setScope(responseJSON.get("scope").asText());
|
||||||
|
accessToken.setClientId(cId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responseJSON.has("client_use_code")) {
|
if (responseJSON.has("client_use_code")) {
|
||||||
accessToken.setClientUseCode(responseJSON.get("client_use_code").asText());
|
accessToken.setClientUseCode(responseJSON.get("client_use_code").asText());
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("oauthToken =" + accessToken.toString());
|
logger.debug("NiceOn oauthToken =" + accessToken.toString());
|
||||||
|
|
||||||
return accessToken;
|
return accessToken;
|
||||||
} else {
|
} else {
|
||||||
@@ -277,7 +283,7 @@ public class HttpClientAccessTokenServiceWithBase64NiceOn implements HttpClientA
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error("[HttpClientAccessTokenServiceWithBase64NiceOn] retrieve accessToken exception :" + e.getMessage());
|
logger.error("[HttpClientAccessTokenServiceWithBase64NiceOn] retrieve accessToken exception :" + e.getMessage());
|
||||||
return accessToken;
|
return accessToken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public class OAuth2AccessTokenVO implements AccessTokenVO, Serializable
|
|||||||
private Date expiration;
|
private Date expiration;
|
||||||
private String scope;
|
private String scope;
|
||||||
private String clientUseCode;
|
private String clientUseCode;
|
||||||
|
private String clientId;
|
||||||
|
|
||||||
public OAuth2AccessTokenVO() {
|
public OAuth2AccessTokenVO() {
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ public class OAuth2AccessTokenVO implements AccessTokenVO, Serializable
|
|||||||
this.expiration = oAuth2AccessTokenVO.getExpiration();
|
this.expiration = oAuth2AccessTokenVO.getExpiration();
|
||||||
this.scope = oAuth2AccessTokenVO.getScope();
|
this.scope = oAuth2AccessTokenVO.getScope();
|
||||||
this.clientUseCode = oAuth2AccessTokenVO.getClientUseCode();
|
this.clientUseCode = oAuth2AccessTokenVO.getClientUseCode();
|
||||||
|
this.clientId = oAuth2AccessTokenVO.getClientId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAccessToken() {
|
public String getAccessToken() {
|
||||||
@@ -92,6 +94,14 @@ public class OAuth2AccessTokenVO implements AccessTokenVO, Serializable
|
|||||||
public void setClientUseCode(String clientUseCode) {
|
public void setClientUseCode(String clientUseCode) {
|
||||||
this.clientUseCode = clientUseCode;
|
this.clientUseCode = clientUseCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getClientId() {
|
||||||
|
return clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientId(String clientId) {
|
||||||
|
this.clientId = clientId;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return ReflectionToStringBuilder.toString(this, ToStringStyle.DEFAULT_STYLE);
|
return ReflectionToStringBuilder.toString(this, ToStringStyle.DEFAULT_STYLE);
|
||||||
|
|||||||
Reference in New Issue
Block a user