Permalink
Browse files

v0.1 of SDK

  • Loading branch information...
0 parents commit cb094c96b99ca2bdc174fe63307deda4e25ec8a8 @sh1mmer sh1mmer committed Apr 30, 2010
Oops, something went wrong.
@@ -0,0 +1,227 @@
+To obtain keys for your YOS application please visit:
+
+http://developer.yahoo.com/dashboard/
+
+================================================================================
+
+To build:
+Invoke mvn package
+
+================================================================================
+
+
+Quick start:
+
+1) Copy yossdk-0.1.0.jar, and dependent jars to WEB-INF/lib
+2) Add com.yahoo.yos.oauth.YahooFilter servlet filter to web.xml, for example:
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd" >
+
+<web-app>
+ <display-name>sample</display-name>
+ <filter>
+ <filter-name>YOSFilter</filter-name>
+ <filter-class>com.yahoo.yos.YahooFilter</filter-class>
+
+ <!--
+ optional param -
+ underlying oauth client class
+ possible values:
+ net.oauth.client.URLConnectionClient (default)
+ net.oauth.client.httpclient3.HttpClient3
+ net.oauth.client.httpclient4.HttpClient4
+ -->
+ <init-param>
+ <param-name>oauthConnectionClass</param-name>
+ <param-value>net.oauth.client.httpclient4.HttpClient4</param-value>
+ </init-param>
+ <!--
+ optional param -
+ redirect end-user if an access token is not found, set to false if you
+ are only making two-legged oauth calls e.g. oauth calls without an
+ access token to retrieve public information
+ defauts to true
+ -->
+ <init-param>
+ <param-name>redirect</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ </filter>
+
+ <!--
+ The URL where the filter is mapped to will redirect the user to Yahoo for
+ authorization if an OAuth authorization token has not been obtained for the
+ user. Should correspond to your callback url
+ -->
+
+ <filter-mapping>
+ <filter-name>YOSFilter</filter-name>
+ <url-pattern>/login.jsp</url-pattern>
+ </filter-mapping>
+</web-app>
+
+3) Sample JSP:
+
+<%@ page import="com.yahoo.yos.YahooSession" %><%@ page import="net.oauth.OAuthProblemException" %><%@ page import="org.json.JSONObject" %><%
+ YahooSession state = (YahooSession) request.getAttribute("yahooSession");
+ if ("POST".equals(request.getMethod())) {
+ String format = request.getParameter("format");
+ try {
+ if ("yql".equals(request.getParameter("form"))) {
+ String method = request.getParameter("method");
+ String url = request.getParameter("url");
+ String callback = request.getParameter("callback");
+ String query = request.getParameter("query");
+
+ String[] params = null;
+ if ("xml".equals(format)) {
+ response.setContentType("text/xml");
+ params = new String[] {"q", query, "format", format};
+ } else {
+ response.setContentType("text/plain");
+ params = new String[] {"q", query, "format", format, "callback", callback};
+ }
+ String output = state.invokeString(url, method, params);
+ out.println(output);
+ } else if ("yap".equals(request.getParameter("form"))) {
+ String method = request.getParameter("method");
+ String url = request.getParameter("url");
+ String content = request.getParameter("content");
+ String[] params = {"format", format, "content", content};
+ if ("xml".equals(format)) {
+ response.setContentType("text/xml");
+ out.println(state.invokeStringWithBody(url, method, content, params));
+ } else {
+ response.setContentType("text/plain");
+ JSONObject object = new JSONObject(state.invokeStringWithBody(url, method, content, params));
+ out.println("JSON Object:");
+ out.println(object.toString(10));
+ }
+ } else {
+ out.println("<html><body>unknown form</body></html>");
+ }
+ } catch (Exception e) {
+ response.setContentType("text/plain");
+ e.printStackTrace();
+ }
+ } else if ("GET".equals(request.getMethod()) && "true".equals(request.getParameter("clear"))) {
+ state.clearSession(request, response);
+ } else {
+%>
+<html>
+<body>
+<h1>YAP:</h1>
+
+<a href="./test.jsp?clear=true">logout</a>
+
+<br/>
+
+<form name="yap" method="post" action="test.jsp">
+ <input type="hidden" name="form" value="yap"/>
+ Method:
+ <select name="method">
+ <option>GET</option>
+ <option selected="true">PUT</option>
+ <option>POST</option>
+ </select>
+ <br/>
+ URL: <input name="url" type="text" size="75"
+ value="http://social.yahooapis.com/v1/user/<%= state.getGUID() %>/presence/presence"/>
+ <br/>
+ Content: <textarea name="content" rows="10" cols="50">
+ {
+ "status": "Reading paper"
+ }
+</textarea>
+ <br/>
+ Format:
+ <select name="format">
+ <option>xml</option>
+ <option>json</option>
+ </select>
+ <br/>
+ <input type="submit"/>
+</form>
+
+<h1>YQL:</h1>
+
+<form name="yql" method="post" action="test.jsp">
+ <input type="hidden" name="form" value="yql"/>
+ Method:
+ <select name="method">
+ <option>GET</option>
+ <option>PUT</option>
+ <option>POST</option>
+ </select>
+ <br/>
+ URL: <input name="url" type="text" size="75" value="http://query.yahooapis.com/v1/yql"/>
+ <br/>
+ Query: <input name="query" type="text" size="75" value="select * from social.profile where guid=me"/>
+ <br/>
+ Format:
+ <select name="format">
+ <option>xml</option>
+ <option>json</option>
+ </select>
+ <br/>
+ Callback: <input name="callback" type="text" size="10" value="foo"/>
+ <br/>
+ <input type="submit"/>
+</form>
+</body>
+</html>
+<%
+ }
+%>
+
+
+================================================================================
+
+
+
+
+This project only accepts contributions licensed under the BSD open source license. See the Open Source Initiative's approved template below.
+Each file submitted should contain the following information in the header:
+
+// Created by [contributor]
+// Copyright (c) [enter owning person entity, year]. All Rights Reserved.
+// Licensed under the BSD (revised) open source license.
+
+Here is the Open Source Initiative BSD License Template (http://opensource.org/licenses/bsd-license.php ):
+
+-------------------------------------
+Copyright (c) <YEAR>, <OWNER>
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms, with
+or without modification, are permitted provided that the following
+conditions are met:
+
+* Redistributions of source code must retain the above
+ copyright notice, this list of conditions and the
+ following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+* Neither the name of <ORGANIZATION> nor the names of its
+ contributors may be used to endorse or promote products
+ derived from this software without specific prior
+ written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------
163 pom.xml
@@ -0,0 +1,163 @@
+<!--
+
+// Created by Sumit Shah on 7/02/09.
+// Copyright (c) 2009 Yahoo! Inc. All rights reserved.
+//
+// The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license.
+
+-->
+
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.yahoo.yos</groupId>
+ <artifactId>sdk</artifactId>
+ <packaging>jar</packaging>
+ <version>0.1.0</version>
+ <name>YOS SDK</name>
+ <url>http://developer.yahoo.com</url>
+ <repositories>
+ <repository>
+ <id>oauth</id>
+ <name>Google Code OAuth Maven Repo</name>
+ <layout>default</layout>
+ <url>http://oauth.googlecode.com/svn/code/maven</url>
+ </repository>
+ </repositories>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/src.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <!--
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ -->
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- apache 2.0 http://mojo.codehaus.org/shitty-maven-plugin/license.html -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>shitty-maven-plugin</artifactId>
+ <version>1.0-alpha-3</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>clean</goal>
+ <goal>install</goal>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <!-- apache 2.0 http://code.google.com/p/oauth/ -->
+ <groupId>net.oauth.core</groupId>
+ <artifactId>oauth</artifactId>
+ <version>20090825</version>
+ </dependency>
+ <dependency>
+ <groupId>net.oauth.core</groupId>
+ <artifactId>oauth-provider</artifactId>
+ <version>20090531</version>
+ </dependency>
+ <dependency>
+ <groupId>net.oauth.core</groupId>
+ <artifactId>oauth-httpclient4</artifactId>
+ <version>20090913</version>
+ </dependency>
+ <dependency>
+ <groupId>net.oauth.core</groupId>
+ <artifactId>oauth-httpclient3</artifactId>
+ <version>20090617</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ </dependency>
+ <dependency>
+ <!-- the json license http://www.json.org/license.html -->
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20080701</version>
+ </dependency>
+ <dependency>
+ <!-- apache 2.0 http://code.google.com/p/testng/ -->
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.8</version>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ </dependency>
+ <dependency>
+ <!-- MIT license http://code.google.com/p/mockito/ -->
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <!-- MIT license http://www.slf4j.org/license.html -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.6</version>
+ </dependency>
+ <dependency>
+ <!-- MIT license http://www.slf4j.org/license.html -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.6</version>
+ </dependency>
+ </dependencies>
+</project>
@@ -0,0 +1 @@
+integration-test
Oops, something went wrong.

0 comments on commit cb094c9

Please sign in to comment.