Permalink
Browse files

Initial Commit

  • Loading branch information...
sachin-handiekar committed Apr 23, 2012
1 parent 50a75e3 commit 07d84c5b010626d1e2995203751be5872c3f6f9c
Showing with 1,417 additions and 7 deletions.
  1. +0 −6 .gitignore
  2. +6 −1 README.md
  3. +11 −0 spring-social-live/.classpath
  4. +36 −0 spring-social-live/.project
  5. +8 −0 spring-social-live/.settings/org.eclipse.jdt.core.prefs
  6. +4 −0 spring-social-live/.settings/org.eclipse.m2e.core.prefs
  7. +6 −0 spring-social-live/.settings/org.eclipse.wst.common.component
  8. +5 −0 spring-social-live/.settings/org.eclipse.wst.common.project.facet.core.xml
  9. +82 −0 spring-social-live/pom.xml
  10. +6 −0 spring-social-live/src/main/java/org/springframework/social/live/api/Live.java
  11. +78 −0 spring-social-live/src/main/java/org/springframework/social/live/api/LiveProfile.java
  12. +9 −0 spring-social-live/src/main/java/org/springframework/social/live/api/UserOperations.java
  13. +24 −0 ...ng-social-live/src/main/java/org/springframework/social/live/api/impl/AbstractLiveOperations.java
  14. +36 −0 spring-social-live/src/main/java/org/springframework/social/live/api/impl/LiveTemplate.java
  15. +39 −0 spring-social-live/src/main/java/org/springframework/social/live/api/impl/UserTemplate.java
  16. +40 −0 spring-social-live/src/main/java/org/springframework/social/live/connect/LiveAdapter.java
  17. +12 −0 spring-social-live/src/main/java/org/springframework/social/live/connect/LiveConnectionFactory.java
  18. +12 −0 spring-social-live/src/main/java/org/springframework/social/live/connect/LiveOAuth2Template.java
  19. +17 −0 spring-social-live/src/main/java/org/springframework/social/live/connect/LiveServiceProvider.java
  20. +11 −0 spring-social-quickstart-live/.classpath
  21. +42 −0 spring-social-quickstart-live/.project
  22. +12 −0 spring-social-quickstart-live/.settings/.jsdtscope
  23. +8 −0 spring-social-quickstart-live/.settings/org.eclipse.jdt.core.prefs
  24. +4 −0 spring-social-quickstart-live/.settings/org.eclipse.m2e.core.prefs
  25. +13 −0 spring-social-quickstart-live/.settings/org.eclipse.wst.common.component
  26. +7 −0 spring-social-quickstart-live/.settings/org.eclipse.wst.common.project.facet.core.xml
  27. +1 −0 spring-social-quickstart-live/.settings/org.eclipse.wst.jsdt.ui.superType.container
  28. +1 −0 spring-social-quickstart-live/.settings/org.eclipse.wst.jsdt.ui.superType.name
  29. +10 −0 spring-social-quickstart-live/README
  30. +137 −0 spring-social-quickstart-live/pom.xml
  31. +51 −0 ...ng-social-quickstart-live/src/main/java/org/springframework/social/quickstart/HomeController.java
  32. +13 −0 ...ve/src/main/java/org/springframework/social/quickstart/config/CustomUsersConnectionRepository.sql
  33. +58 −0 ...social-quickstart-live/src/main/java/org/springframework/social/quickstart/config/MainConfig.java
  34. +107 −0 ...cial-quickstart-live/src/main/java/org/springframework/social/quickstart/config/SocialConfig.java
  35. +58 −0 ...cial-quickstart-live/src/main/java/org/springframework/social/quickstart/config/WebMvcConfig.java
  36. +2 −0 ...quickstart-live/src/main/java/org/springframework/social/quickstart/config/application.properties
  37. +4 −0 ...cial-quickstart-live/src/main/java/org/springframework/social/quickstart/config/package-info.java
  38. +4 −0 spring-social-quickstart-live/src/main/java/org/springframework/social/quickstart/package-info.java
  39. +46 −0 ...ial-quickstart-live/src/main/java/org/springframework/social/quickstart/user/SecurityContext.java
  40. +36 −0 ...ckstart-live/src/main/java/org/springframework/social/quickstart/user/SimpleConnectionSignUp.java
  41. +42 −0 ...quickstart-live/src/main/java/org/springframework/social/quickstart/user/SimpleSignInAdapter.java
  42. +35 −0 spring-social-quickstart-live/src/main/java/org/springframework/social/quickstart/user/User.java
  43. +57 −0 ...quickstart-live/src/main/java/org/springframework/social/quickstart/user/UserCookieGenerator.java
  44. +92 −0 ...ial-quickstart-live/src/main/java/org/springframework/social/quickstart/user/UserInterceptor.java
  45. +4 −0 ...social-quickstart-live/src/main/java/org/springframework/social/quickstart/user/package-info.java
  46. +3 −0 spring-social-quickstart-live/src/main/webapp/META-INF/MANIFEST.MF
  47. +30 −0 spring-social-quickstart-live/src/main/webapp/WEB-INF/views/home.jsp
  48. +13 −0 spring-social-quickstart-live/src/main/webapp/WEB-INF/views/signin.jsp
  49. +85 −0 spring-social-quickstart-live/src/main/webapp/WEB-INF/web.xml
View
@@ -1,6 +0,0 @@
-*.class
-
-# Package Files #
-*.jar
-*.war
-*.ear
View
@@ -1,2 +1,7 @@
spring-social-live
-==================
+==================
+
+* spring-social-live - Library sources
+* spring-social-live-quickstart - Example application
+
+* Live Example: http://live-demo.cloudfoundry.com/
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="org.eclipse.jst.component.nondependency" value=""/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>spring-social-live</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="spring-social-live">
+ <wb-resource deploy-path="/" source-path="/src/main/java"/>
+ </wb-module>
+</project-modules>
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.6"/>
+ <installed facet="jst.utility" version="1.0"/>
+</faceted-project>
View
@@ -0,0 +1,82 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.springframework.social</groupId>
+ <artifactId>spring-social-live</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>spring-social-live</name>
+ <description>Spring Social extension with connection support and an API binding for Windows Live API</description>
+
+ <properties>
+ <spring.social.version>1.0.2.RELEASE</spring.social.version>
+ <spring.framework.version>3.1.1.RELEASE</spring.framework.version>
+ </properties>
+
+ <url></url>
+ <developers>
+ <developer>
+ <name>Sachin Handiekar</name>
+ <email>sach21@gmail.com</email>
+ <url>http://sachinhandiekar.com</url>
+ </developer>
+ </developers>
+
+ <repositories>
+ <repository>
+ <id>org.springframework.maven.release</id>
+ <name>Spring Maven Release Repository</name>
+ <url>http://maven.springframework.org/release</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>org.springframework.maven.milestone</id>
+ <name>Spring Maven Milestone Repository</name>
+ <url>http://maven.springframework.org/milestone</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.social</groupId>
+ <artifactId>spring-social-core</artifactId>
+ <version>${spring.social.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.9.5</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
@@ -0,0 +1,6 @@
+package org.springframework.social.live.api;
+
+public interface Live {
+ UserOperations userOperations();
+
+}
@@ -0,0 +1,78 @@
+package org.springframework.social.live.api;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class LiveProfile {
+
+ private final String id;
+
+ private final String name;
+
+ @JsonProperty("first_name")
+ private final String firstName;
+
+ @JsonProperty("last_name")
+ private final String lastName;
+
+ private final String gender;
+
+ private String link;
+
+ private String locale;
+
+ @JsonProperty("updated_time")
+ private String updatedTime;
+
+ public LiveProfile(String id, String name, String firstName, String lastName, String gender, String locale) {
+ this.id = id;
+ this.name = name;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.gender = gender;
+ }
+
+ public String getLocale() {
+ return locale;
+ }
+
+ public void setLocale(String locale) {
+ this.locale = locale;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public String getGender() {
+ return gender;
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ public String getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(String updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+}
@@ -0,0 +1,9 @@
+package org.springframework.social.live.api;
+
+public interface UserOperations {
+
+ LiveProfile getUserProfile();
+
+ LiveProfile getUserProfileWithUsername(String userName);
+
+}
@@ -0,0 +1,24 @@
+package org.springframework.social.live.api.impl;
+
+import org.springframework.social.MissingAuthorizationException;
+
+class AbstractLiveOperations {
+ private final boolean isAuthorized;
+
+ public AbstractLiveOperations(boolean isAuthorized) {
+ this.isAuthorized = isAuthorized;
+ }
+
+ protected void requireAuthorization() {
+ if (!isAuthorized) {
+ throw new MissingAuthorizationException();
+ }
+ }
+
+ protected String buildUri(String path) {
+ return API_URL_BASE + path;
+ }
+
+ private static final String API_URL_BASE = "https://apis.live.net/v5.0/";
+
+}
@@ -0,0 +1,36 @@
+package org.springframework.social.live.api.impl;
+
+import org.springframework.social.live.api.Live;
+import org.springframework.social.live.api.UserOperations;
+import org.springframework.social.oauth2.AbstractOAuth2ApiBinding;
+import org.springframework.social.support.ClientHttpRequestFactorySelector;
+
+public class LiveTemplate extends AbstractOAuth2ApiBinding implements Live {
+
+ private UserOperations userOperations;
+
+ public LiveTemplate() {
+ initialize();
+ }
+
+ public LiveTemplate(String accessToken) {
+ super(accessToken);
+ initialize();
+ }
+
+ @Override
+ public UserOperations userOperations() {
+ return userOperations;
+ }
+
+ private void initialize() {
+ super.setRequestFactory(ClientHttpRequestFactorySelector.bufferRequests(getRestTemplate().getRequestFactory()));
+ initSubApis();
+
+ }
+
+ private void initSubApis() {
+ userOperations = new UserTemplate(this, getRestTemplate(), isAuthorized());
+ }
+
+}
@@ -0,0 +1,39 @@
+package org.springframework.social.live.api.impl;
+
+import java.util.Map;
+
+import org.springframework.social.live.api.LiveProfile;
+import org.springframework.social.live.api.UserOperations;
+import org.springframework.web.client.RestTemplate;
+
+public class UserTemplate extends AbstractLiveOperations implements UserOperations {
+ private final RestTemplate restTemplate;
+
+ public UserTemplate(LiveTemplate liveTemplate, RestTemplate restTemplate, boolean authorized) {
+ super(authorized);
+ this.restTemplate = restTemplate;
+
+ }
+
+ @Override
+ public LiveProfile getUserProfile() {
+ @SuppressWarnings("unchecked")
+ Map<String, ?> user = restTemplate.getForObject(buildUri("me"), Map.class);
+ String id = String.valueOf(user.get("id"));
+ String name = String.valueOf(user.get("name"));
+ String firstName = String.valueOf(user.get("first_name"));
+ String lastName = String.valueOf(user.get("last_name"));
+ String gender = String.valueOf(user.get("gender"));
+ String locale = String.valueOf(user.get("locale"));
+
+ return new LiveProfile(id, name, firstName, lastName, gender, locale);
+
+ }
+
+ @Override
+ public LiveProfile getUserProfileWithUsername(String userName) {
+ return restTemplate.getForObject("https://apis.live.net/v5.0/" + userName, LiveProfile.class);
+
+ }
+
+}
Oops, something went wrong.

0 comments on commit 07d84c5

Please sign in to comment.