aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/VKontakteLogin.java')
-rw-r--r--juick-www/src/main/java/com/juick/www/VKontakteLogin.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
index 509187a9..7d718c9b 100644
--- a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
+++ b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
@@ -30,13 +30,15 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.UUID;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
*
* @author Ugnich Anton
*/
public class VKontakteLogin {
-
+ private static final Logger logger = Logger.getLogger(VKontakteLogin.class.getName());
private static final String VK_APPID = "3544101";
private static final String VK_SECRET = "z2afNI8jA5lIpZ2jsTm1";
private static final String VK_REDIRECT = "http://juick.com/_vklogin";
@@ -52,7 +54,7 @@ public class VKontakteLogin {
String tokenjson = Utils.fetchURL("https://oauth.vk.com/access_token?client_id=" + VK_APPID + "&redirect_uri=" + URLEncoder.encode(VK_REDIRECT, "utf-8") + "&client_secret=" + VK_SECRET + "&code=" + URLEncoder.encode(code, "utf-8"));
if (tokenjson == null || tokenjson.isEmpty()) {
- System.err.println("VK TOKEN EMPTY");
+ logger.log(Level.SEVERE, "VK TOKEN EMPTY");
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
@@ -63,12 +65,12 @@ public class VKontakteLogin {
token = json.getString("access_token");
vkID = json.getLong("user_id");
} catch (JSONException e) {
- System.err.println("VK TOKEN EXCEPTION: " + e);
+ logger.log(Level.SEVERE, "VK TOKEN EXCEPTION: ", e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
if (token == null || vkID == 0) {
- System.err.println("VK TOKEN EMPTY: " + tokenjson);
+ logger.log(Level.SEVERE, "VK TOKEN EMPTY: " + tokenjson);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
@@ -77,7 +79,7 @@ public class VKontakteLogin {
String graph = Utils.fetchURL("https://api.vk.com/method/users.get?uids=" + vkID + "&fields=screen_name&access_token=" + token);
if (graph == null || graph.isEmpty()) {
- System.err.println("VK GRAPH ERROR");
+ logger.log(Level.SEVERE, "VK GRAPH ERROR");
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
@@ -107,9 +109,8 @@ public class VKontakteLogin {
response.setHeader("Location", "/signup?type=vk&hash=" + loginhash);
}
} catch (Exception e) {
- System.err.println("JSON ERROR: " + e);
+ logger.log(Level.SEVERE, "JSON ERROR", e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- return;
}
}