Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

upgrade spring-social and added twitter integration

  • Loading branch information...
commit ed96bc3e722f2dcadfd374ce7bedc7adbb74ee22 1 parent 084b6a4
@jettro authored
Showing with 344 additions and 236 deletions.
  1. +50 −24 pom.xml
  2. +0 −180 src/main/java/nl/gridshore/samples/springoauth/web/ConnectController.java
  3. +65 −0 src/main/java/nl/gridshore/samples/springoauth/web/LinkedinController.java
  4. +58 −0 src/main/java/nl/gridshore/samples/springoauth/web/TwitterController.java
  5. +19 −0 src/main/resources/META-INF/spring/security-context.xml
  6. +38 −0 src/main/resources/META-INF/spring/serviceproviders-context.xml
  7. +11 −0 src/main/resources/create_schema.sql
  8. +4 −0 src/main/resources/jdbc.properties
  9. +6 −1 src/main/resources/template-config.properties
  10. +9 −7 src/main/webapp/WEB-INF/spring/servlet-context.xml
  11. +1 −1  src/main/webapp/WEB-INF/views/connect/{linkedin_connect.jsp → linkedinConnect.jsp}
  12. 0  src/main/webapp/WEB-INF/views/connect/{linkedin_connected.jsp → linkedinConnected.jsp}
  13. +10 −0 src/main/webapp/WEB-INF/views/connect/twitterConnect.jsp
  14. +9 −0 src/main/webapp/WEB-INF/views/connect/twitterConnected.jsp
  15. +1 −0  src/main/webapp/WEB-INF/views/index.jsp
  16. +3 −3 src/main/webapp/WEB-INF/views/{ → linkedin}/connections.jsp
  17. +3 −3 src/main/webapp/WEB-INF/views/{ → linkedin}/profile.jsp
  18. +12 −0 src/main/webapp/WEB-INF/views/twitter/friends.jsp
  19. +6 −0 src/main/webapp/WEB-INF/views/twitter/profile.jsp
  20. +39 −17 src/main/webapp/WEB-INF/web.xml
View
74 pom.xml
@@ -48,10 +48,11 @@
</build>
<properties>
- <slf4j.version>1.5.8</slf4j.version>
- <spring.version>3.0.4.RELEASE</spring.version>
- <spring.security.version>3.0.3.RELEASE</spring.security.version>
+ <slf4j.version>1.6.1</slf4j.version>
+ <spring.version>3.1.0.M1</spring.version>
+ <spring.security.version>3.1.0.RC1</spring.security.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <spring-social.version>1.0.0.M2</spring-social.version>
</properties>
<dependencies>
@@ -81,14 +82,49 @@
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
- <version>1.0.0.M1</version>
+ <version>${spring-social.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.springframework.social</groupId>
+ <artifactId>spring-social-linkedin</artifactId>
+ <version>${spring-social.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.social</groupId>
+ <artifactId>spring-social-twitter</artifactId>
+ <version>${spring-social.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.social</groupId>
+ <artifactId>spring-social-web</artifactId>
+ <version>${spring-social.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-core</artifactId>
+ <version>${spring.security.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-crypto</artifactId>
+ <version>${spring.security.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-web</artifactId>
+ <version>${spring.security.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-config</artifactId>
+ <version>${spring.security.version}</version>
+ </dependency>
<!-- Scribe OAuth 1.0 Consumer API -->
<dependency>
<groupId>org.scribe</groupId>
<artifactId>scribe</artifactId>
- <version>1.0.7</version>
+ <version>1.1.1</version>
</dependency>
<!-- web dependencies -->
@@ -122,26 +158,16 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.15</version>
- <exclusions>
- <exclusion>
- <groupId>com.sun.jdmk</groupId>
- <artifactId>jmxtools</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.sun.jmx</groupId>
- <artifactId>jmxri</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.jms</groupId>
- <artifactId>jms</artifactId>
- </exclusion>
- </exclusions>
+ <version>1.2.16</version>
</dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.6</version>
+ </dependency>
+
+ <!-- other dependencies -->
+
</dependencies>
<repositories>
View
180 src/main/java/nl/gridshore/samples/springoauth/web/ConnectController.java
@@ -1,180 +0,0 @@
-package nl.gridshore.samples.springoauth.web;
-
-import org.scribe.extractors.BaseStringExtractorImpl;
-import org.scribe.extractors.HeaderExtractorImpl;
-import org.scribe.extractors.TokenExtractorImpl;
-import org.scribe.model.OAuthConfig;
-import org.scribe.model.Token;
-import org.scribe.model.Verb;
-import org.scribe.model.Verifier;
-import org.scribe.oauth.OAuth10aServiceImpl;
-import org.scribe.oauth.OAuthService;
-import org.scribe.services.HMACSha1SignatureService;
-import org.scribe.services.TimestampServiceImpl;
-import org.springframework.beans.factory.annotation.Required;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.social.linkedin.LinkedInProfile;
-import org.springframework.social.linkedin.LinkedInTemplate;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.context.request.WebRequest;
-
-import java.util.List;
-
-/**
- * <p>Controller that handles all linkedin connect requests. It contains methods to request information from linkedin.
- * as well as methods to handle the authentication with linkedin using OAuth and the spring-social project.</p>
- *
- * @author Jettro Coenradie
- */
-@Controller
-@RequestMapping(value = "/connect")
-public class ConnectController {
- private static final String OAUTH_REQUEST_TOKEN_ATTRIBUTE = "oauthRequestToken";
- private static final String OAUTH_ACCESS_TOKEN_ATTRIBUTE = "oauthAccessToken";
- private String apiKey;
- private String apiSecret;
- private String callbackUrl;
-
- /**
- * Shows a page that enables you to start the connection process if you have not connected yet. If you did connect,
- * a page is shown with the actions you can perform.
- *
- * @param request Spring provided WebRequest
- * @return String representing the name of the view to show
- */
- @RequestMapping(value = "linkedin", method = RequestMethod.GET)
- public String showConnectLinkedin(WebRequest request) {
- Token accessToken = obtainAccessTokenFromSession(request);
- if (accessToken == null) {
- return "connect/linkedin_connect";
- } else {
- return "connect/linkedin_connected";
- }
- }
-
- /**
- * Redirects the use to the linkedin authentication service
- *
- * @param request Spring provided WebRequest
- * @return String representing the name of the view to show
- */
- @RequestMapping(value = "linkedin", method = RequestMethod.POST)
- public String requestConnectionLinkedin(WebRequest request) {
-
- Token requestToken = getOAuthService().getRequestToken();
- request.setAttribute(OAUTH_REQUEST_TOKEN_ATTRIBUTE, requestToken, WebRequest.SCOPE_SESSION);
-
- return "redirect:" + "https://www.linkedin.com/uas/oauth/authorize?oauth_token=" + requestToken.getToken();
- }
-
- /**
- * Handles the callback from Linkedin. Uses the RequestToken to obtain the AccessToken. The AccessToken is stored
- * in the session to be used for later on.
- *
- * @param verifier String containing a string provided by Linkedin to use for varifying the request token.
- * @param request Spring provided WebRequest
- * @return String representing the name of the view to show
- */
- @RequestMapping(value = "linkedin", method = RequestMethod.GET, params = "oauth_token")
- public String authorizeCallback(@RequestParam(value = "oauth_verifier", defaultValue = "verifier") String verifier,
- WebRequest request) {
- Token requestToken = obtainRequestTokenFromSession(request);
- Token accessToken = getOAuthService().getAccessToken(requestToken, new Verifier(verifier));
-
- request.setAttribute(OAUTH_ACCESS_TOKEN_ATTRIBUTE, accessToken, WebRequest.SCOPE_SESSION);
- return "redirect:linkedin";
-
- }
-
- /**
- * Handles the request to obtain all the connections from the current logged in user.
- *
- * @param request Spring provided WebRequest
- * @return String representing the name of the view to show
- */
- @RequestMapping(value = "linkedin/connections", method = RequestMethod.GET)
- public String connections(WebRequest request) {
- LinkedInTemplate template = createLinkedInTemplate(request);
-
- List<LinkedInProfile> connections = template.getConnections();
- request.setAttribute("connections", connections, WebRequest.SCOPE_REQUEST);
-
- return "connections";
- }
-
- /**
- * Handles the request to obtain the profile of the current logged in user
- * @param request Spring provided WebRequest
- * @return String representing the name of the view to show
- */
- @RequestMapping(value = "linkedin/profile", method = RequestMethod.GET)
- public String profile(WebRequest request) {
- LinkedInTemplate template = createLinkedInTemplate(request);
-
- LinkedInProfile userProfile = template.getUserProfile();
- request.setAttribute("profile", userProfile, WebRequest.SCOPE_REQUEST);
- return "profile";
- }
-
- private LinkedInTemplate createLinkedInTemplate(WebRequest request) {
- Token accessToken = obtainAccessTokenFromSession(request);
- if (accessToken == null) {
- throw new RuntimeException("An access token must be available here");
- }
- return new LinkedInTemplate(
- apiKey,
- apiSecret,
- accessToken.getToken(),
- accessToken.getSecret());
- }
-
- private Token obtainRequestTokenFromSession(WebRequest request) {
- return (Token) request.getAttribute(OAUTH_REQUEST_TOKEN_ATTRIBUTE, WebRequest.SCOPE_SESSION);
- }
-
- private OAuthService getOAuthService() {
- OAuthConfig config = new OAuthConfig();
- config.setRequestTokenEndpoint("https://api.linkedin.com/uas/oauth/requestToken");
- config.setAccessTokenEndpoint("https://api.linkedin.com/uas/oauth/accessToken");
- config.setAccessTokenVerb(Verb.POST);
- config.setRequestTokenVerb(Verb.POST);
- config.setApiKey(apiKey);
- config.setApiSecret(apiSecret);
- config.setCallback(callbackUrl);
-
- return new OAuth10aServiceImpl(
- new HMACSha1SignatureService(),
- new TimestampServiceImpl(),
- new BaseStringExtractorImpl(),
- new HeaderExtractorImpl(),
- new TokenExtractorImpl(),
- new TokenExtractorImpl(),
- config);
- }
-
-
- private Token obtainAccessTokenFromSession(WebRequest request) {
- return (Token) request.getAttribute(OAUTH_ACCESS_TOKEN_ATTRIBUTE, WebRequest.SCOPE_SESSION);
- }
-
- @Required
- @Value("${linkedin.api.key}")
- public void setApiKey(String apiKey) {
- this.apiKey = apiKey;
- }
-
- @Required
- @Value("${linkedin.api.secret}")
- public void setApiSecret(String apiSecret) {
- this.apiSecret = apiSecret;
- }
-
- @Required
- @Value("${linkedin.callback}")
- public void setCallbackUrl(String callbackUrl) {
- this.callbackUrl = callbackUrl;
- }
-}
View
65 src/main/java/nl/gridshore/samples/springoauth/web/LinkedinController.java
@@ -0,0 +1,65 @@
+package nl.gridshore.samples.springoauth.web;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.social.linkedin.LinkedInApi;
+import org.springframework.social.linkedin.LinkedInProfile;
+import org.springframework.social.linkedin.connect.LinkedInServiceProvider;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.context.request.WebRequest;
+
+import java.util.List;
+
+/**
+ * <p>Controller that handles all linkedin api requests. It contains methods to request information from linkedin.
+ * All authentication and authorization requests are handled by the spring provided controller
+ * {@see org.springframework.social.web.connect.ConnectController}.</p>
+ *
+ * @author Jettro Coenradie
+ */
+@Controller
+public class LinkedinController {
+
+ private LinkedInServiceProvider linkedInServiceProvider;
+
+ @Autowired
+ public LinkedinController(LinkedInServiceProvider linkedInServiceProvider) {
+ this.linkedInServiceProvider = linkedInServiceProvider;
+ }
+
+ /**
+ * Handles the request to obtain all the connections from the current logged in user.
+ *
+ * @param request Spring provided WebRequest
+ * @return String representing the name of the view to show
+ */
+ @RequestMapping(value = "/connect/linkedin/connections", method = RequestMethod.GET)
+ public String connections(WebRequest request) {
+ request.setAttribute("connections", linkedinApi().getConnections(), WebRequest.SCOPE_REQUEST);
+
+ return "linkedin/connections";
+ }
+
+ /**
+ * Handles the request to obtain the profile of the current logged in user
+ *
+ * @param request Spring provided WebRequest
+ * @return String representing the name of the view to show
+ */
+ @RequestMapping(value = "/connect/linkedin/profile", method = RequestMethod.GET)
+ public String profile(WebRequest request) {
+
+ request.setAttribute("profile", linkedinApi().getUserProfile(), WebRequest.SCOPE_REQUEST);
+ return "linkedin/profile";
+ }
+
+ private LinkedInApi linkedinApi() {
+ User principal = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+ return linkedInServiceProvider.getConnections(principal.getUsername()).get(0).getServiceApi();
+ }
+
+
+}
View
58 src/main/java/nl/gridshore/samples/springoauth/web/TwitterController.java
@@ -0,0 +1,58 @@
+package nl.gridshore.samples.springoauth.web;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.social.twitter.TwitterApi;
+import org.springframework.social.twitter.connect.TwitterServiceProvider;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.context.request.WebRequest;
+
+/**
+ * <p>Controller that handles all service calls that are twitter related. All authorization calls are handled by
+ * the spring provided {@see org.springframework.social.web.connect.ConnectController}.</p>
+ *
+ * @author Jettro Coenradie
+ */
+@Controller
+public class TwitterController {
+ private TwitterServiceProvider twitterServiceProvider;
+
+ @Autowired
+ public TwitterController(TwitterServiceProvider twitterServiceProvider) {
+ this.twitterServiceProvider = twitterServiceProvider;
+ }
+
+ /**
+ * Returns all tweets of friends of the first registered twitter account.
+ *
+ * @param request WebRequest used to store parameters to provide to the jsp
+ * @return String containing the name of the view to render
+ */
+ @RequestMapping(value = "/connect/twitter/friends", method = RequestMethod.GET)
+ public String obtainFriendTweets(WebRequest request) {
+
+ request.setAttribute("tweets", twitterApi().getFriendsTimeline(), WebRequest.SCOPE_REQUEST);
+ return "twitter/friends";
+ }
+
+ /**
+ * Returns the profile of the first registered twitter account.
+ *
+ * @param request WebRequest used to store parameters to provide to the jsp
+ * @return String containing the name of the view to render
+ */
+ @RequestMapping(value = "/connect/twitter/profile", method = RequestMethod.GET)
+ public String obtainProfile(WebRequest request) {
+
+ request.setAttribute("profile", twitterApi().getUserProfile(), WebRequest.SCOPE_REQUEST);
+ return "twitter/profile";
+ }
+
+ private TwitterApi twitterApi() {
+ User principal = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+ return twitterServiceProvider.getConnections(principal.getUsername()).get(0).getServiceApi();
+ }
+}
View
19 src/main/resources/META-INF/spring/security-context.xml
@@ -0,0 +1,19 @@
+<beans:beans xmlns="http://www.springframework.org/schema/security"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
+
+ <http auto-config='true'>
+ <intercept-url pattern="/**" access="ROLE_USER"/>
+ </http>
+
+ <authentication-manager>
+ <authentication-provider>
+ <user-service>
+ <user name="jettro" password="pwd" authorities="ROLE_USER, ROLE_ADMIN"/>
+ <user name="other" password="pwd" authorities="ROLE_USER"/>
+ </user-service>
+ </authentication-provider>
+ </authentication-manager>
+</beans:beans>
View
38 src/main/resources/META-INF/spring/serviceproviders-context.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
+
+ <context:property-placeholder location="classpath:config.properties,classpath:jdbc.properties"/>
+
+ <bean class="org.springframework.social.twitter.connect.TwitterServiceProvider">
+ <constructor-arg value="${twitter.consumerKey}" />
+ <constructor-arg value="${twitter.consumerSecret}" />
+ <constructor-arg ref="connectionRepository" />
+ </bean>
+
+ <bean class="org.springframework.social.linkedin.connect.LinkedInServiceProvider">
+ <constructor-arg value="${linkedin.api.key}"/>
+ <constructor-arg value="${linkedin.api.secret}"/>
+ <constructor-arg ref="connectionRepository"/>
+ </bean>
+
+ <!-- Configure a connection repository through which account-to-provider connections will be stored -->
+ <bean id="connectionRepository" class="org.springframework.social.connect.jdbc.JdbcConnectionRepository">
+ <constructor-arg ref="dataSource"/>
+ <constructor-arg ref="textEncryptor"/>
+ </bean>
+
+ <bean id="textEncryptor" class="org.springframework.security.crypto.encrypt.Encryptors" factory-method="noOpText"/>
+
+ <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName" value="${jdbc.driverClassName}"/>
+ <property name="url" value="${jdbc.url}"/>
+ <property name="username" value="${jdbc.username}"/>
+ <property name="password" value="${jdbc.password}"/>
+ </bean>
+
+
+</beans>
View
11 src/main/resources/create_schema.sql
@@ -0,0 +1,11 @@
+CREATE TABLE `Connection` (
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
+ `accountId` varchar(255) NOT NULL DEFAULT '',
+ `providerId` varchar(255) NOT NULL DEFAULT '',
+ `accessToken` varchar(255) NOT NULL DEFAULT '',
+ `secret` varchar(255) DEFAULT NULL,
+ `refreshToken` varchar(255) DEFAULT NULL,
+ `providerAccountId` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;;
+
View
4 src/main/resources/jdbc.properties
@@ -0,0 +1,4 @@
+jdbc.driverClassName=com.mysql.jdbc.Driver
+jdbc.url=jdbc:mysql://localhost/social
+jdbc.username=social
+jdbc.password=social
View
7 src/main/resources/template-config.properties
@@ -6,4 +6,9 @@
# https://www.linkedin.com/secure/developer
linkedin.api.key=
linkedin.api.secret=
-linkedin.callback=http://localhost:8080/connect/linkedin
+linkedin.callback=http://localhost:8080/connect/linkedin
+
+twitter.consumerKey=
+twitter.consumerSecret=
+
+application.url=
View
16 src/main/webapp/WEB-INF/spring/servlet-context.xml
@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
- http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:mvc="http://www.springframework.org/schema/mvc"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+ http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:property-placeholder location="classpath:config.properties"/>
@@ -22,4 +20,8 @@
<property name="suffix" value=".jsp"/>
</bean>
+ <bean class="org.springframework.social.web.connect.ConnectController">
+ <constructor-arg value="${application.url}"/>
+ </bean>
+
</beans>
View
2  ...webapp/WEB-INF/views/connect/linkedin_connect.jsp → .../webapp/WEB-INF/views/connect/linkedinConnect.jsp
@@ -3,7 +3,7 @@
<form action="<c:url value="/connect/linkedin" />" method="POST">
<div class="formInfo">
<h2>Connect to LinkedIn</h2>
- <p>Click the button to connect your Greenhouse account with your LinkedIn account.</p>
+ <p>Click the button to connect your account with your LinkedIn account.</p>
</div>
<input id="signin" type="submit"/>
</form>
View
0  ...bapp/WEB-INF/views/connect/linkedin_connected.jsp → ...ebapp/WEB-INF/views/connect/linkedinConnected.jsp
File renamed without changes
View
10 src/main/webapp/WEB-INF/views/connect/twitterConnect.jsp
@@ -0,0 +1,10 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<jsp:include page="../inc/header.jsp"/>
+<form action="<c:url value="/connect/twitter" />" method="POST">
+ <div class="formInfo">
+ <h2>Connect to Twitter</h2>
+ <p>Click the button to connect your account with your Twitter account.</p>
+ </div>
+ <input id="signin" type="submit"/>
+</form>
+<jsp:include page="../inc/footer.jsp"/>
View
9 src/main/webapp/WEB-INF/views/connect/twitterConnected.jsp
@@ -0,0 +1,9 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<jsp:include page="../inc/header.jsp"/>
+
+<p>Now you are connected to twitter, you can ask the following thinks:</p>
+<ul>
+ <li><a href="<c:url value="/connect/twitter/friends" />">Friends</a></li>
+ <li><a href="<c:url value="/connect/twitter/profile" />">My Profile</a></li>
+</ul>
+<jsp:include page="../inc/footer.jsp"/>
View
1  src/main/webapp/WEB-INF/views/index.jsp
@@ -2,5 +2,6 @@
Start pagina, hier vandaan kun je alles opstarten
<a href="connect/linkedin">Linkedin</a>
+<a href="connect/twitter">Twitter</a>
<jsp:include page="inc/footer.jsp"/>
View
6 src/main/webapp/WEB-INF/views/connections.jsp → ...ain/webapp/WEB-INF/views/linkedin/connections.jsp
@@ -1,6 +1,6 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<jsp:include page="inc/header.jsp"/>
-<jsp:include page="inc/navigation.jsp"/>
+<jsp:include page="../inc/header.jsp"/>
+<jsp:include page="../inc/navigation.jsp"/>
<table>
<c:forEach items="${connections}" var="connection">
<tr>
@@ -9,4 +9,4 @@
</tr>
</c:forEach>
</table>
-<jsp:include page="inc/footer.jsp"/>
+<jsp:include page="../inc/footer.jsp"/>
View
6 src/main/webapp/WEB-INF/views/profile.jsp → src/main/webapp/WEB-INF/views/linkedin/profile.jsp
@@ -1,6 +1,6 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<jsp:include page="inc/header.jsp"/>
-<jsp:include page="inc/navigation.jsp"/>
+<jsp:include page="../inc/header.jsp"/>
+<jsp:include page="../inc/navigation.jsp"/>
<table>
<tr>
<td>First name</td>
@@ -23,4 +23,4 @@
<td><c:out value="${profile.industry}" /></td>
</tr>
</table>
-<jsp:include page="inc/footer.jsp"/>
+<jsp:include page="../inc/footer.jsp"/>
View
12 src/main/webapp/WEB-INF/views/twitter/friends.jsp
@@ -0,0 +1,12 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<jsp:include page="../inc/header.jsp"/>
+<jsp:include page="../inc/navigation.jsp"/>
+<table>
+ <c:forEach items="${tweets}" var="tweet">
+ <tr>
+ <td><c:out value='${tweet.fromUser}'/></td>
+ <td><c:out value='${tweet.text}'/></td>
+ </tr>
+ </c:forEach>
+</table>
+<jsp:include page="../inc/footer.jsp"/>
View
6 src/main/webapp/WEB-INF/views/twitter/profile.jsp
@@ -0,0 +1,6 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<jsp:include page="../inc/header.jsp"/>
+<jsp:include page="../inc/navigation.jsp"/>
+<h2><c:out value='${profile.screenName}'/></h2>
+<p><img src="${profile.profileImageUrl}" align="left" alt="Profile image url"/><c:out value='${profile.description}'/></p>
+<jsp:include page="../inc/footer.jsp"/>
View
56 src/main/webapp/WEB-INF/web.xml
@@ -1,22 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
-
- <servlet>
- <servlet-name>appServlet</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <init-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/spring/servlet-context.xml</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>appServlet</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <listener>
+ <listener-class>
+ org.springframework.web.context.ContextLoaderListener
+ </listener-class>
+ </listener>
+
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>classpath:META-INF/spring/security-context.xml, classpath:META-INF/spring/serviceproviders-context.xml</param-value>
+ </context-param>
+
+
+ <filter>
+ <filter-name>springSecurityFilterChain</filter-name>
+ <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>springSecurityFilterChain</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <servlet>
+ <servlet-name>appServlet</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <init-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/spring/servlet-context.xml</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>appServlet</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
<welcome-file-list>
<welcome-file>/index.html</welcome-file>
Please sign in to comment.
Something went wrong with that request. Please try again.