forked from mttkay/signpost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
m.kaeppler
committed
Jun 14, 2009
1 parent
89cb8fd
commit 1a462ac
Showing
56 changed files
with
3,802 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>oauth-signpost</name> | ||
<comment></comment> | ||
<projects> | ||
<project>signpost-commonshttp4</project> | ||
<project>signpost-core</project> | ||
<project>signpost-jetty6</project> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.maven.ide.eclipse.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.maven.ide.eclipse.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
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,3 @@ | ||
#Sun Jun 07 00:56:55 CEST 2009 | ||
eclipse.preferences.version=1 | ||
internal.default.compliance=default |
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,83 @@ | ||
<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>oauth.signpost</groupId> | ||
<artifactId>oauth-signpost</artifactId> | ||
<packaging>pom</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>oauth-signpost</name> | ||
<description> | ||
A simple, light-weight, and modular OAuth client library for the | ||
Java platform. | ||
</description> | ||
<url>http://code.google.com/p/oauth-signpost/</url> | ||
<issueManagement> | ||
<system>Google Code Issue Tracker</system> | ||
<url>http://code.google.com/p/oauth-signpost/issues/list</url> | ||
</issueManagement> | ||
<developers> | ||
<developer> | ||
<id>mk</id> | ||
<name>Matthias Käppler</name> | ||
<email>[email protected]</email> | ||
<url>http://matthiaskaeppler.de</url> | ||
<organization>Qype GmbH</organization> | ||
<organizationUrl>http://www.qype.com</organizationUrl> | ||
<timezone>+1</timezone> | ||
</developer> | ||
</developers> | ||
<modules> | ||
<module>signpost-core</module> | ||
<module>signpost-commonshttp4</module> | ||
<module>signpost-jetty6</module> | ||
</modules> | ||
|
||
<!-- build settings --> | ||
<build> | ||
<defaultGoal>package</defaultGoal> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.5</source> | ||
<target>1.5</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.2</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<!-- external repositories --> | ||
<repositories> | ||
<repository> | ||
<releases> | ||
<enabled>true</enabled> | ||
<updatePolicy>daily</updatePolicy> | ||
<checksumPolicy>warn</checksumPolicy> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
<updatePolicy>daily</updatePolicy> | ||
<checksumPolicy>warn</checksumPolicy> | ||
</snapshots> | ||
<id>repo2.maven.org</id> | ||
<name>repo2.maven.org</name> | ||
<url>http://repo2.maven.org/maven2</url> | ||
<layout>default</layout> | ||
</repository> | ||
</repositories> | ||
|
||
</project> |
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"/> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/> | ||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>signpost-commonshttp4</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.maven.ide.eclipse.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.maven.ide.eclipse.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
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,3 @@ | ||
#Sun Jun 07 00:56:45 CEST 2009 | ||
eclipse.preferences.version=1 | ||
internal.default.compliance=default |
3 changes: 3 additions & 0 deletions
3
signpost-commonshttp4/.settings/org.eclipse.ltk.core.refactoring.prefs
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,3 @@ | ||
#Sun Jun 07 00:58:01 CEST 2009 | ||
eclipse.preferences.version=1 | ||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false |
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,9 @@ | ||
#Sat Jun 06 17:58:11 CEST 2009 | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
fullBuildGoals=process-test-resources | ||
includeModules=false | ||
resolveWorkspaceProjects=true | ||
resourceFilterGoals=process-resources resources\:testResources | ||
skipCompilerPlugin=true | ||
version=1 |
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,55 @@ | ||
<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"> | ||
<parent> | ||
<artifactId>oauth-signpost</artifactId> | ||
<groupId>oauth.signpost</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>oauth.signpost</groupId> | ||
<artifactId>signpost-commonshttp4</artifactId> | ||
<name>signpost-commonshttp4</name> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>oauth.signpost</groupId> | ||
<artifactId>signpost-core</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpcore</artifactId> | ||
<version>4.0-beta3</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.0-beta2</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.5</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<version>1.7</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>oauth.signpost</groupId> | ||
<artifactId>signpost-core</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
25 changes: 25 additions & 0 deletions
25
signpost-commonshttp4/src/main/java/oauth/signpost/commonshttp/CommonsHttpOAuthConsumer.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,25 @@ | ||
package oauth.signpost.commonshttp; | ||
|
||
import oauth.signpost.AbstractOAuthConsumer; | ||
import oauth.signpost.http.HttpRequest; | ||
import oauth.signpost.signature.SignatureMethod; | ||
|
||
public class CommonsHttpOAuthConsumer extends AbstractOAuthConsumer { | ||
|
||
public CommonsHttpOAuthConsumer(String consumerKey, String consumerSecret, | ||
SignatureMethod signatureMethod) { | ||
super(consumerKey, consumerSecret, signatureMethod); | ||
} | ||
|
||
@Override | ||
protected HttpRequest wrap(Object request) { | ||
if (!(request instanceof org.apache.http.HttpRequest)) { | ||
throw new IllegalArgumentException( | ||
"This consumer expects requests of type " | ||
+ org.apache.http.HttpRequest.class.getCanonicalName()); | ||
} | ||
|
||
return new HttpRequestAdapter((org.apache.http.HttpRequest) request); | ||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
signpost-commonshttp4/src/main/java/oauth/signpost/commonshttp/HttpRequestAdapter.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 oauth.signpost.commonshttp; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import org.apache.http.Header; | ||
import org.apache.http.HttpEntity; | ||
import org.apache.http.HttpEntityEnclosingRequest; | ||
import org.apache.http.HttpRequest; | ||
|
||
public class HttpRequestAdapter implements oauth.signpost.http.HttpRequest { | ||
|
||
private HttpRequest request; | ||
|
||
private HttpEntity entity; | ||
|
||
public HttpRequestAdapter(HttpRequest request) { | ||
this.request = request; | ||
if (request instanceof HttpEntityEnclosingRequest) { | ||
entity = ((HttpEntityEnclosingRequest) request).getEntity(); | ||
} | ||
} | ||
|
||
public String getHeader(String name) { | ||
Header header = request.getFirstHeader(name); | ||
if (header == null) { | ||
return null; | ||
} | ||
return header.getValue(); | ||
} | ||
|
||
public String getMethod() { | ||
return request.getRequestLine().getMethod(); | ||
} | ||
|
||
public String getRequestUrl() { | ||
return request.getRequestLine().getUri(); | ||
} | ||
|
||
public void setHeader(String name, String value) { | ||
request.setHeader(name, value); | ||
} | ||
|
||
public String getContentType() { | ||
if (entity == null) { | ||
return null; | ||
} | ||
Header header = entity.getContentType(); | ||
if (header == null) { | ||
return null; | ||
} | ||
return header.getValue(); | ||
} | ||
|
||
public InputStream getMessagePayload() throws IOException { | ||
if (entity == null) { | ||
return null; | ||
} | ||
return entity.getContent(); | ||
} | ||
|
||
public boolean hasPayload() { | ||
return entity != null; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
signpost-commonshttp4/src/test/java/oauth/signpost/commonshttp/HttpRequestAdapterTest.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,22 @@ | ||
package oauth.signpost.commonshttp; | ||
|
||
import oauth.signpost.basic.HttpRequestAdapterTestBase; | ||
|
||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.entity.StringEntity; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.runners.MockitoJUnit44Runner; | ||
|
||
@RunWith(MockitoJUnit44Runner.class) | ||
public class HttpRequestAdapterTest extends HttpRequestAdapterTestBase { | ||
|
||
@Override | ||
public void prepareRequest() throws Exception { | ||
HttpPost r = new HttpPost(URL); | ||
r.setHeader(HEADER_NAME, HEADER_VALUE); | ||
StringEntity body = new StringEntity(PAYLOAD); | ||
body.setContentType(CONTENT_TYPE); | ||
r.setEntity(body); | ||
request = new HttpRequestAdapter(r); | ||
} | ||
} |
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"/> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/> | ||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>signpost-core</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.maven.ide.eclipse.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.maven.ide.eclipse.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
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,3 @@ | ||
#Sat Jun 06 17:56:02 CEST 2009 | ||
eclipse.preferences.version=1 | ||
internal.default.compliance=user |
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,9 @@ | ||
#Sat Jun 06 17:49:21 CEST 2009 | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
fullBuildGoals=process-test-resources | ||
includeModules=false | ||
resolveWorkspaceProjects=true | ||
resourceFilterGoals=process-resources resources\:testResources | ||
skipCompilerPlugin=true | ||
version=1 |
Oops, something went wrong.