미사용 소스 정리
This commit is contained in:
parent
bbcf5e1a38
commit
4691b9c4b7
@ -1,164 +0,0 @@
|
|||||||
<<<<<<< HEAD
|
|
||||||
package nlib.cmm.snslogin;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
import org.apache.http.NameValuePair;
|
|
||||||
import org.apache.http.client.ClientProtocolException;
|
|
||||||
import org.apache.http.client.HttpClient;
|
|
||||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
||||||
import org.apache.http.client.methods.HttpPost;
|
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
@Controller
|
|
||||||
public class KakaoController {
|
|
||||||
|
|
||||||
private final static String K_CLIENT_ID = "dawsdasd";
|
|
||||||
|
|
||||||
public static String getAuthorizationUrl(HttpSession session,String K_REDIRECT_URI) {
|
|
||||||
String kakaoUrl = "https://kauth.kakao.com/oauth/authorize?" + "client_id=" + K_CLIENT_ID
|
|
||||||
+ "&redirect_uri="+ K_REDIRECT_URI + "&response_type=code";
|
|
||||||
return kakaoUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JsonNode getAccessToken(String autorize_code,String K_REDIRECT_URI) {
|
|
||||||
final String RequestUrl = "https://kauth.kakao.com/oauth/token";
|
|
||||||
final List<NameValuePair> postParams = new ArrayList<NameValuePair>();
|
|
||||||
postParams.add(new BasicNameValuePair("grant_type", "authorization_code"));
|
|
||||||
postParams.add(new BasicNameValuePair("client_id", K_CLIENT_ID)); // REST API KEY
|
|
||||||
postParams.add(new BasicNameValuePair("redirect_uri",K_REDIRECT_URI));
|
|
||||||
// 리다이렉트 URI
|
|
||||||
postParams.add(new BasicNameValuePair("code",autorize_code)); // 로그인 과정중 얻은 code 값
|
|
||||||
final HttpClient client = HttpClientBuilder.create().build();
|
|
||||||
final HttpPost post = new HttpPost(RequestUrl);
|
|
||||||
JsonNode returnNode = null;
|
|
||||||
try {
|
|
||||||
post.setEntity(new UrlEncodedFormEntity(postParams));
|
|
||||||
final HttpResponse response = client.execute(post);
|
|
||||||
// JSON 형태 반환값 처리
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
returnNode = mapper.readTree(response.getEntity().getContent());
|
|
||||||
} catch (UnsupportedEncodingException e){
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ClientProtocolException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace(); }
|
|
||||||
finally {
|
|
||||||
// clear resources
|
|
||||||
} return returnNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JsonNode getKakaoUserInfo(JsonNode accessToken) {
|
|
||||||
final String RequestUrl = "https://kapi.kakao.com/v2/user/me";
|
|
||||||
final HttpClient client = HttpClientBuilder.create().build();
|
|
||||||
final HttpPost post = new HttpPost(RequestUrl);
|
|
||||||
// add header
|
|
||||||
post.addHeader("Authorization", "Bearer " + accessToken);
|
|
||||||
JsonNode returnNode = null;
|
|
||||||
try {
|
|
||||||
final HttpResponse response = client.execute(post);
|
|
||||||
// JSON 형태 반환값 처리
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
returnNode = mapper.readTree(response.getEntity().getContent());
|
|
||||||
} catch (ClientProtocolException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
// clear resources
|
|
||||||
} return returnNode;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
package nlib.cmm.snslogin;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
import org.apache.http.NameValuePair;
|
|
||||||
import org.apache.http.client.ClientProtocolException;
|
|
||||||
import org.apache.http.client.HttpClient;
|
|
||||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
||||||
import org.apache.http.client.methods.HttpPost;
|
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
@Controller
|
|
||||||
public class KakaoController {
|
|
||||||
|
|
||||||
private final static String K_CLIENT_ID = "dawsdasd";
|
|
||||||
|
|
||||||
public static String getAuthorizationUrl(HttpSession session,String K_REDIRECT_URI) {
|
|
||||||
String kakaoUrl = "https://kauth.kakao.com/oauth/authorize?" + "client_id=" + K_CLIENT_ID
|
|
||||||
+ "&redirect_uri="+ K_REDIRECT_URI + "&response_type=code";
|
|
||||||
return kakaoUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JsonNode getAccessToken(String autorize_code,String K_REDIRECT_URI) {
|
|
||||||
final String RequestUrl = "https://kauth.kakao.com/oauth/token";
|
|
||||||
final List<NameValuePair> postParams = new ArrayList<NameValuePair>();
|
|
||||||
postParams.add(new BasicNameValuePair("grant_type", "authorization_code"));
|
|
||||||
postParams.add(new BasicNameValuePair("client_id", K_CLIENT_ID)); // REST API KEY
|
|
||||||
postParams.add(new BasicNameValuePair("redirect_uri",K_REDIRECT_URI));
|
|
||||||
// 리다이렉트 URI
|
|
||||||
postParams.add(new BasicNameValuePair("code",autorize_code)); // 로그인 과정중 얻은 code 값
|
|
||||||
final HttpClient client = HttpClientBuilder.create().build();
|
|
||||||
final HttpPost post = new HttpPost(RequestUrl);
|
|
||||||
JsonNode returnNode = null;
|
|
||||||
try {
|
|
||||||
post.setEntity(new UrlEncodedFormEntity(postParams));
|
|
||||||
final HttpResponse response = client.execute(post);
|
|
||||||
// JSON 형태 반환값 처리
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
returnNode = mapper.readTree(response.getEntity().getContent());
|
|
||||||
} catch (UnsupportedEncodingException e){
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ClientProtocolException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace(); }
|
|
||||||
finally {
|
|
||||||
// clear resources
|
|
||||||
} return returnNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JsonNode getKakaoUserInfo(JsonNode accessToken) {
|
|
||||||
final String RequestUrl = "https://kapi.kakao.com/v2/user/me";
|
|
||||||
final HttpClient client = HttpClientBuilder.create().build();
|
|
||||||
final HttpPost post = new HttpPost(RequestUrl);
|
|
||||||
// add header
|
|
||||||
post.addHeader("Authorization", "Bearer " + accessToken);
|
|
||||||
JsonNode returnNode = null;
|
|
||||||
try {
|
|
||||||
final HttpResponse response = client.execute(post);
|
|
||||||
// JSON 형태 반환값 처리
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
returnNode = mapper.readTree(response.getEntity().getContent());
|
|
||||||
} catch (ClientProtocolException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
// clear resources
|
|
||||||
} return returnNode;
|
|
||||||
}
|
|
||||||
>>>>>>> refs/remotes/origin/master
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package nlib.cmm.snslogin;
|
|
||||||
|
|
||||||
import com.github.scribejava.core.builder.api.DefaultApi20;
|
|
||||||
|
|
||||||
public class NaverLoginApi extends DefaultApi20{
|
|
||||||
|
|
||||||
protected NaverLoginApi(){
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class InstanceHolder{
|
|
||||||
private static final NaverLoginApi INSTANCE = new NaverLoginApi();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static NaverLoginApi instance(){
|
|
||||||
return InstanceHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAccessTokenEndpoint() {
|
|
||||||
return "https://nid.naver.com/oauth2.0/token?grant_type=authorization_code";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getAuthorizationBaseUrl() {
|
|
||||||
return "https://nid.naver.com/oauth2.0/authorize";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user