aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com/juick/www')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java13
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java17
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java13
3 files changed, 22 insertions, 21 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java b/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java
index 0067dbc6..e83bab92 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java
@@ -33,7 +33,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.core.env.Environment;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
@@ -56,8 +56,10 @@ public class FacebookLogin {
private static final Logger logger = LoggerFactory.getLogger(FacebookLogin.class);
- private final String FACEBOOK_APPID;
- private final String FACEBOOK_SECRET;
+ @Value("${facebook_appid}")
+ private String FACEBOOK_APPID;
+ @Value("${facebook_secret}")
+ private String FACEBOOK_SECRET;
private final String FACEBOOK_REDIRECT = "http://juick.com/_fblogin";
@Inject
private ObjectMapper jsonMapper;
@@ -68,10 +70,7 @@ public class FacebookLogin {
@Inject
UserService userService;
- @Inject
- public FacebookLogin(Environment env) {
- FACEBOOK_APPID = env.getProperty("facebook_appid");
- FACEBOOK_SECRET = env.getProperty("facebook_secret");
+ public FacebookLogin() {
serviceBuilder = new ServiceBuilder();
}
diff --git a/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java b/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java
index 8ccaecfa..741fb95f 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java
@@ -10,7 +10,7 @@ import com.github.scribejava.core.model.Verb;
import com.github.scribejava.core.oauth.OAuth10aService;
import com.juick.service.UserService;
import org.apache.commons.lang3.StringUtils;
-import org.springframework.core.env.Environment;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@@ -29,7 +29,10 @@ public class TwitterAuth {
private final static String VERIFY_URL = "https://api.twitter.com/1.1/account/verify_credentials.json";
- private String consumerKey, consumerSecret;
+ @Value("${twitter_consumer_key}")
+ private String consumerKey;
+ @Value("${twitter_consumer_secret}")
+ private String consumerSecret;
@Inject
private ObjectMapper jsonMapper;
@@ -37,10 +40,10 @@ public class TwitterAuth {
@Inject
UserService userService;
- @Inject
- public TwitterAuth(Environment env) {
- this.consumerKey = env.getProperty("twitter_consumer_key");
- this.consumerSecret = env.getProperty("twitter_consumer_secret");
+ private ServiceBuilder serviceBuilder;
+
+ public TwitterAuth() {
+ serviceBuilder = new ServiceBuilder();
}
@GetMapping("/_twitter")
@@ -65,7 +68,7 @@ public class TwitterAuth {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
- OAuth10aService oAuthService = new ServiceBuilder()
+ OAuth10aService oAuthService = serviceBuilder
.apiKey(consumerKey)
.apiSecret(consumerSecret)
.callback("http://juick.com/_twitter")
diff --git a/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java b/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java
index c8b45691..12f90388 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java
@@ -33,7 +33,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.core.env.Environment;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
@@ -53,8 +53,10 @@ import java.util.concurrent.ExecutionException;
@Controller
public class VKontakteLogin {
private static final Logger logger = LoggerFactory.getLogger(VKontakteLogin.class);
- private final String VK_APPID;
- private final String VK_SECRET;
+ @Value("${vk_appid}")
+ private String VK_APPID;
+ @Value("${vk_secret}")
+ private String VK_SECRET;
private static final String VK_REDIRECT = "http://juick.com/_vklogin";
@Inject
@@ -64,10 +66,7 @@ public class VKontakteLogin {
private ServiceBuilder serviceBuilder;
- @Inject
- public VKontakteLogin(Environment env) {
- VK_APPID = env.getProperty("vk_appid");
- VK_SECRET = env.getProperty("vk_secret");
+ public VKontakteLogin() {
serviceBuilder = new ServiceBuilder();
}