Permalink
Browse files

update license

  • Loading branch information...
1 parent 51f5121 commit 85057053f16aac0f8744c195fb7d583c7c9a540a Glen D Sanford committed Apr 29, 2011
Showing with 253 additions and 270 deletions.
  1. +189 −201 LICENSE
  2. +36 −20 README.markdown
  3. +0 −21 src/main/Main.iml
  4. +1 −1 src/main/java/com/twitter/joauth/VerifierResult.java
  5. +1 −1 src/main/scala/com/twitter/joauth/NonceValidator.scala
  6. +1 −1 src/main/scala/com/twitter/joauth/Normalizer.scala
  7. +1 −1 src/main/scala/com/twitter/joauth/OAuthParams.scala
  8. +1 −1 src/main/scala/com/twitter/joauth/Request.scala
  9. +1 −1 src/main/scala/com/twitter/joauth/Signer.scala
  10. +1 −1 src/main/scala/com/twitter/joauth/UnpackedRequest.scala
  11. +1 −1 src/main/scala/com/twitter/joauth/Unpacker.scala
  12. +1 −1 src/main/scala/com/twitter/joauth/UnpackerException.scala
  13. +1 −1 src/main/scala/com/twitter/joauth/UrlEncoder.scala
  14. +1 −1 src/main/scala/com/twitter/joauth/Verifier.scala
  15. +1 −1 src/main/scala/com/twitter/joauth/keyvalue/KeyValueFilter.scala
  16. +1 −1 src/main/scala/com/twitter/joauth/keyvalue/KeyValueHandler.scala
  17. +1 −1 src/main/scala/com/twitter/joauth/keyvalue/KeyValueParser.scala
  18. +1 −1 src/main/scala/com/twitter/joauth/keyvalue/OAuthKeyValueHandler.scala
  19. +1 −1 src/main/scala/com/twitter/joauth/keyvalue/Transformer.scala
  20. +1 −1 src/test/scala/com/twitter/joauth/NormalizerSpec.scala
  21. +1 −1 src/test/scala/com/twitter/joauth/OAuth1ParamsSpec.scala
  22. +1 −1 src/test/scala/com/twitter/joauth/OAuth1RequestSpec.scala
  23. +1 −1 src/test/scala/com/twitter/joauth/SignerSpec.scala
  24. +1 −1 src/test/scala/com/twitter/joauth/UnpackerSpec.scala
  25. +1 −1 src/test/scala/com/twitter/joauth/VerifierSpec.scala
  26. +1 −1 src/test/scala/com/twitter/joauth/keyvalue/KeyValueHandlerSpec.scala
  27. +1 −1 src/test/scala/com/twitter/joauth/keyvalue/KeyValueParserSpec.scala
  28. +1 −1 src/test/scala/com/twitter/joauth/testhelpers/MockRequest.scala
  29. +1 −1 src/test/scala/com/twitter/joauth/testhelpers/MockRequestFactory.scala
  30. +1 −1 src/test/scala/com/twitter/joauth/testhelpers/OAuth1TestCase.scala
  31. +1 −1 src/test/scala/com/twitter/joauth/testhelpers/ParamHelper.scala
View
390 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -27,7 +27,7 @@ The Github source repository is [here](http://github.com/9len/joauth/). Patches
## Building
-**v.1.1.2 is the last version that can be built using scala 2.7.7, and now resides in the scala27 branch. v1.2 and above require scala > 2.8.0**
+**v.1.1.2 is the last version that can be built using scala 2.7.7, and now resides in the scala27 branch. v1.2 and above require scala > 2.8.1**
*Dependencies*: servlet-api, commons-codec, and thrust (specs & mockito-all to run the tests). These dependencies are managed by the build system.
@@ -47,13 +47,13 @@ JOAuth consists of five traits, each of which is invoked with an apply method.
* The Signer trait signs a String, using the OAuth token secret and consumer secret.
* The Verifier trait verifies that a OAuth1Request is valid, checking the timestamp, nonce, and signature
-There are "Standard" and "Const" implementations of the Unpacker, Normalizer, Signer, and the Verifier traits, for easy dependency injection. Each trait has a companion object with apply methods for the default instantiation of the corresponding Standard implementations.
+There are "Standard" and "Const" implementations of the Unpacker, Normalizer, Signer, and the Verifier traits, for easy dependency injection. Each trait has a companion object with apply methods for the default instantiation of the corresponding Standard implementations.
## Usage
### Basic Usage
-Create an unpacker, and use it to unpack the thrust.Request. The Unpacker will either return an OAuth1Request or OAuth2Request object or throw an UnpackerException.
+Create an unpacker, and use it to unpack the thrust.Request. The Unpacker will either return an OAuth1Request or OAuth2Request object or throw an UnpackerException.
import com.twitter.joauth.Unpacker
@@ -68,13 +68,13 @@ Create an unpacker, and use it to unpack the thrust.Request. The Unpacker will e
case e:UnpackerException => // handle or rethrow
case _ => // handle or rethrow
}
-
+
**WARNING**: The StandardUnpacker will call the HttpRequest.getInputStream method if the method of the request is POST and the Content-Type is "application/x-www-form-urlencoded." *If you need to read the POST yourself, this will cause you problems, since getInputStream/getReader can only be called once.* There are two solutions: (1) Write an HttpServletWrapper to buffer the POST data and allow multiple calls to getInputStream, and pass the HttpServletWrapper into the Unpacker. (2) Pass a KeyValueHandler into the unpacker call (See "Getting Parameter Key/Values" below for more), which will let you get the parameters in the POST as a side effect of unpacking.
-
-Once the request is unpacked, the credentials need to be validated. For an OAuth2Request, the OAuth Access Token must be retrieved and validated by your authentication service. For an OAuth1Request the Access Token, the Consumer Key, and their respective secrets must be retrieved, and then passed to the Verifier for validation.
+
+Once the request is unpacked, the credentials need to be validated. For an OAuth2Request, the OAuth Access Token must be retrieved and validated by your authentication service. For an OAuth1Request the Access Token, the Consumer Key, and their respective secrets must be retrieved, and then passed to the Verifier for validation.
import com.twitter.joauth.{Verifier, VerifierResult}
-
+
val verify = Verifier()
verify(oAuth1Request, tokenSecret, consumerSecret) match {
case VerifierResult.BAD_NONCE => // handle bad nonce
@@ -88,8 +88,8 @@ That's it!
### Advanced Usage
#### Overriding Path and Scheme
-
-If you're building an internal authentication service, it may serve multiple endpoints, and need to calculate signatures for all of them. it may also live on a server hosting multiple services on the same port, in which case you'll need a specific endpoint for your authentication service, while simultaneously needing to validate requests as if they had their original endpoints. You can accommodate this by passing in a method for extracting the path from the HttpServletRequest, via the PathGetter trait.
+
+If you're building an internal authentication service, it may serve multiple endpoints, and need to calculate signatures for all of them. it may also live on a server hosting multiple services on the same port, in which case you'll need a specific endpoint for your authentication service, while simultaneously needing to validate requests as if they had their original endpoints. You can accommodate this by passing in a method for extracting the path from the HttpServletRequest, via the PathGetter trait.
For example, if you have an authentication service that responded to the /auth endpoint, and you are authenticating requests to an external server serving the /foo endpoint, the path of the request the authentication service receives is /auth/foo. This won't do, because the signature of the request depends on the path being /foo. We can construct a PathGetter that strips /auth out of the path.
@@ -109,7 +109,7 @@ If you're running a high throughput authentication service, you might want to av
import com.twitter.joauth.UriSchemeGetter
import com.twitter.thrust.Request
-
+
object MySchemeGetter extends UrlSchemeGetter {
def apply(request; Request): String = {
val header = request.getHeader("X-My-Scheme-Header")
@@ -121,7 +121,7 @@ If you're running a high throughput authentication service, you might want to av
You can now construct your unpacker with your Getters.
val unpack = Unpacker(new MySchemeGetter, new MyPathGetter)
-
+
if you only want to pass in one or the other, you can use the StandardSchemeGetter and StandardPathGetter classes when calling the two-argument Unpacker.apply.
#### Getting Parameter Key/Values
@@ -146,27 +146,27 @@ For example, suppose you want to get all values of a single parameter, and you w
def apply(k: String, v: String) = buffer += v
def toList = buffer.toList
}
-
+
object UrlDecodingTransformer extends Transformer {
def apply(str: String) = URLDecoder.decode(str)
}
-
+
object MyFilter extends KeyValueFilter {
def apply(k: String, v: String) = k == "SpecialKey"
}
-
+
class UrlDecodedMyValueOnlyKeyValueHandler(underlying: KeyValueHandler)
extends FilteredKeyValueHandler(
MyFilter,
new TransformingKeyValueHandler(UrlDecodingTransformer, underlying)
-
+
val unpack = Unpacker()
val handler = new ValuesOnlyKeyValueHandler
val wrappedHandler = UrlDecodedMyValueOnlyKeyValueHandler(handler)
val unpackedRequest = unpack(request, Seq(wrappedHandler))
doSomethingWith(handler.toList)
-
-Obviously it would be a little easier to just call request.getParameterValues("SpecialKey") in this example, but we hope it's not hard to see that passing custom KeyValueHandlers into the unpacker can be a powerful tool. In particular, they're an easy way to get access to POST data after the Unpacker has ruined your HttpServletRequest by calling getInputStream.
+
+Obviously it would be a little easier to just call request.getParameterValues("SpecialKey") in this example, but we hope it's not hard to see that passing custom KeyValueHandlers into the unpacker can be a powerful tool. In particular, they're an easy way to get access to POST data after the Unpacker has ruined your HttpServletRequest by calling getInputStream.
KeyValueHandlers are used in the JOAuth source code to collect OAuth and non-OAuth parameters from the GET, POST and Authorization header.
@@ -180,10 +180,10 @@ You can use the Normalizer and Signer to sign OAuth 1.0a requests.
val normalize = Normalizer()
val sign = Signer()
-
+
val normalizedRequest = normalize(scheme, host, port, verb, path, params, oAuthParams)
val signedRequest = sign(normalizedRequest, tokenSecret, consumerSecret)
-
+
The parameters are passed as a List[(String, String)], and the OAuth params are passed in an OAuthParams instance.
## Running Tests
@@ -206,4 +206,20 @@ The Github issue tracker is [here](http://github.com/9len/joauth/issues).
* Raffi Krikorian
* Mark McBride
* Marcel Molina
-* Glen Sanford
+* Glen Sanford
+
+## Copyright and License
+
+Copyright 2011 Twitter, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this work except in compliance with the License.
+ You may obtain a copy of the License in the LICENSE file, or at:
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
View
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="scala" name="Scala">
- <configuration />
- </facet>
- </component>
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$/../..">
- <sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/scala" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/../test/scala" isTestSource="true" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="library" name="managed" level="project" />
- <orderEntry type="library" name="scala" level="project" />
- </component>
-</module>
-
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
@@ -1,4 +1,4 @@
-// Copyright 2010 Twitter, Inc.
+// Copyright 2011 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at

0 comments on commit 8505705

Please sign in to comment.