Compare commits
2 Commits
815a064cd9
...
2829d4362c
| Author | SHA1 | Date | |
|---|---|---|---|
| 2829d4362c | |||
| 5a9225e93e |
+24
-17
@@ -6,6 +6,7 @@ import java.math.BigDecimal;
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
@@ -366,20 +367,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
switch (HttpMethodType.getValue(rmethod)) {
|
||||
case GET:
|
||||
case DELETE:
|
||||
HashMap<String, String> h = getParameters(dataObject);
|
||||
URIBuilder uriBuilder = new URIBuilder(uri);
|
||||
for (Map.Entry<String, String> entry : h.entrySet()) {
|
||||
uriBuilder.addParameter(entry.getKey(), entry.getValue());
|
||||
}
|
||||
URI fullUri = uriBuilder.build();
|
||||
if (method instanceof HttpGet) {
|
||||
((HttpGet) method).setUri(fullUri);
|
||||
} else if (method instanceof HttpDelete) {
|
||||
((HttpDelete) method).setUri(fullUri);
|
||||
}
|
||||
if (logger.isDebug()) {
|
||||
logger.debug("HttpClientAdapterServiceRest] (get Method) QueryString = [" + fullUri.getQuery() + "]");
|
||||
}
|
||||
assignGetParam(dataObject, uri, method);
|
||||
break;
|
||||
case PUT:
|
||||
case POST:
|
||||
@@ -393,8 +381,9 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("HttpClientAdapterServiceRest] Request URI : " + method.getRequestUri());
|
||||
logger.debug("HttpClientAdapterServiceRest] SEND (" + vo.getAdapterGroupName() + ") method.getParams()=["
|
||||
+ method.getEntity() + "] ");
|
||||
}
|
||||
@@ -403,7 +392,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
|
||||
// 전달 header 셋팅
|
||||
// Adapter 레벨 header 보다 data로 넘어온 httpHeader를 우선 적용(header명이 같다면 덮어씀)
|
||||
assignRequestHeaders(method, httpHeader, prop);
|
||||
assignRequestHeaders(method, httpHeader, prop, tempProp);
|
||||
|
||||
int status = -1;
|
||||
|
||||
@@ -716,6 +705,24 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
}
|
||||
}
|
||||
|
||||
private void assignGetParam(Object dataObject, String uri, HttpUriRequestBase method)
|
||||
throws Exception, URISyntaxException {
|
||||
HashMap<String, String> h = getParameters(dataObject);
|
||||
URIBuilder uriBuilder = new URIBuilder(uri);
|
||||
for (Map.Entry<String, String> entry : h.entrySet()) {
|
||||
uriBuilder.addParameter(entry.getKey(), entry.getValue());
|
||||
}
|
||||
URI fullUri = uriBuilder.build();
|
||||
if (method instanceof HttpGet) {
|
||||
((HttpGet) method).setUri(fullUri);
|
||||
} else if (method instanceof HttpDelete) {
|
||||
((HttpDelete) method).setUri(fullUri);
|
||||
}
|
||||
if (logger.isDebug()) {
|
||||
logger.debug("HttpClientAdapterServiceRest] (get Method) QueryString = [" + fullUri.getQuery() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private void assignOutboundPropertyMap(Properties tempProp, int status, String responseString,
|
||||
Properties responseHeaderProp) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
@@ -896,7 +903,7 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void assignRequestHeaders(HttpUriRequestBase method, Object httpHeader, Properties prop) {
|
||||
protected void assignRequestHeaders(HttpUriRequestBase method, Object httpHeader, Properties prop, Properties tempProp) {
|
||||
if (httpHeader != null) {
|
||||
if ( httpHeader instanceof ObjectNode) {
|
||||
ObjectNode objectNode = (ObjectNode) httpHeader;
|
||||
|
||||
@@ -240,33 +240,32 @@ public class AccessTokenManagerByDB implements Lifecycle {
|
||||
|
||||
SessionManager.getInstance().getOutboundAccessToken(adapterGroupName, new Function<AccessTokenVO, AccessTokenVO>() {
|
||||
|
||||
@Override
|
||||
public AccessTokenVO apply(AccessTokenVO accessToken) {
|
||||
|
||||
long intervalTime = System.currentTimeMillis() + (credential.getIntervalSec() * 1000);
|
||||
// // 토큰이 없거나, 다음 스케줄 시간 전에 만료될 경우 재발급
|
||||
if (accessToken == null) {
|
||||
return issueToken(credential);
|
||||
} else if(accessToken.getExpiration() != null) {
|
||||
// 토큰이 있고 만료시간이 설정 된 경우
|
||||
if(accessToken.getExpiration().before(new Date(intervalTime))){
|
||||
// 다음 스케줄 전에 토큰이 만료되는 경우 재발급
|
||||
return issueToken(credential);
|
||||
@Override
|
||||
public AccessTokenVO apply(AccessTokenVO accessToken) {
|
||||
long intervalTime = System.currentTimeMillis() + (credential.getIntervalSec() * 1000);
|
||||
// // 토큰이 없거나, 다음 스케줄 시간 전에 만료될 경우 재발급
|
||||
if (accessToken == null) {
|
||||
logger.debug("Token not exists for adapter group: {}", adapterGroupName);
|
||||
return issueToken(credential);
|
||||
} else if(accessToken.getExpiration() != null) {
|
||||
// 토큰이 있고 만료시간이 설정 된 경우
|
||||
if(accessToken.getExpiration().before(new Date(intervalTime))){
|
||||
// 다음 스케줄 전에 토큰이 만료되는 경우 재발급
|
||||
logger.debug("Token expired : {}, expiration date: {}", adapterGroupName, accessToken.getExpiration());
|
||||
return issueToken(credential);
|
||||
} else {
|
||||
// 토큰이 아직 유효한 경우
|
||||
logger.debug("Token still valid until next schedule for adapter group: {}, expiration date: {}", adapterGroupName, accessToken.getExpiration());
|
||||
return accessToken;
|
||||
}
|
||||
} else {
|
||||
// 토큰이 아직 유효한 경우
|
||||
logger.debug("Token still valid until next schedule for adapter group: {}, expiration date: {}", adapterGroupName, accessToken.getExpiration());
|
||||
//토큰이 있지만 만료 시간이 없는 경우
|
||||
logger.debug("Token exists but expiration time is null for adapter group: {}", adapterGroupName);
|
||||
return accessToken;
|
||||
}
|
||||
} else {
|
||||
//토큰이 있지만 만료 시간이 없는 경우
|
||||
logger.debug("Token exists but expiration time is null for adapter group: {}", adapterGroupName);
|
||||
return accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
logger.debug("Token issuance completed for adapter group: {}", adapterGroupName);
|
||||
} catch (Exception e) {
|
||||
logger.error("Token issuance failed for adapter group: {}", adapterGroupName, e);
|
||||
|
||||
Reference in New Issue
Block a user