|
|
@@ -12,6 +12,7 @@ import com.style24.front.support.security.session.TsfSession;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.core.env.Environment;
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
@@ -43,7 +44,8 @@ public class KaKaoLogin {
|
|
|
@Autowired
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
- public static final String PROTOCOL = "http://";
|
|
|
+ @Value("${has-ssl}")
|
|
|
+ private String hasSsl;
|
|
|
|
|
|
private String callBackUrl;
|
|
|
private String restApiKey;
|
|
|
@@ -52,6 +54,7 @@ public class KaKaoLogin {
|
|
|
private String userInfoUrl;
|
|
|
private String authorizeUrl;
|
|
|
private String unlinkUrl;
|
|
|
+ private String protocal;
|
|
|
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
@@ -63,6 +66,14 @@ public class KaKaoLogin {
|
|
|
authorizeUrl = env.getProperty("kakao.authorizeUrl");
|
|
|
unlinkUrl = env.getProperty("kakao.unlinkUrl");
|
|
|
|
|
|
+ boolean isSslServer = Boolean.parseBoolean(hasSsl);
|
|
|
+
|
|
|
+ if (isSslServer) {
|
|
|
+ protocal = "https://";
|
|
|
+ } else {
|
|
|
+ protocal = "http://";
|
|
|
+ }
|
|
|
+
|
|
|
log.debug("\n\n---- Kakao initialization started ----");
|
|
|
log.debug("callBackUrl: [{}]", callBackUrl);
|
|
|
log.debug("restApiKey: [{}]", restApiKey);
|
|
|
@@ -82,7 +93,7 @@ public class KaKaoLogin {
|
|
|
*/
|
|
|
public String getAuthorizeUrl(String state) {
|
|
|
StringBuilder apiUrlBuilder = new StringBuilder();
|
|
|
- String redirectUri = GagaFileUtil.getConcatenationPath(PROTOCOL + TsfSession.getHttpServletRequest().getServerName(), callBackUrl);
|
|
|
+ String redirectUri = GagaFileUtil.getConcatenationPath(protocal + TsfSession.getHttpServletRequest().getServerName(), callBackUrl);
|
|
|
apiUrlBuilder.append(authorizeUrl)
|
|
|
.append("?client_id=")
|
|
|
.append(restApiKey)
|
|
|
@@ -105,7 +116,7 @@ public class KaKaoLogin {
|
|
|
*/
|
|
|
public GagaMap getAccessTocken(String code, String state) {
|
|
|
GagaMap resultMap = new GagaMap();
|
|
|
- String redirectUri = GagaFileUtil.getConcatenationPath(PROTOCOL + TsfSession.getHttpServletRequest().getServerName(), callBackUrl);
|
|
|
+ String redirectUri = GagaFileUtil.getConcatenationPath(protocal + TsfSession.getHttpServletRequest().getServerName(), callBackUrl);
|
|
|
String requestGb = "";
|
|
|
try {
|
|
|
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|