Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade spring-social and added twitter integration
- Loading branch information
Showing
20 changed files
with
344 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
180 changes: 0 additions & 180 deletions
180
src/main/java/nl/gridshore/samples/springoauth/web/ConnectController.java
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
src/main/java/nl/gridshore/samples/springoauth/web/LinkedinController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.