hoauth 0.1.3 → 0.1.4
raw patch · 4 files changed
+17/−71 lines, 4 filesdep −HUnit
Dependencies removed: HUnit
Files
- hoauth.cabal +2/−20
- src/main/haskell/Network/Protocol/OAuth/Consumer.hs +14/−1
- src/main/haskell/Network/Protocol/OAuth/Request.hs +1/−14
- src/test/haskell/Tests.hs +0/−36
hoauth.cabal view
@@ -1,5 +1,5 @@ name: hoauth-version: 0.1.3+version: 0.1.4 category: Network,Protocol,OAuth license: BSD3 license-file: LICENSE@@ -8,7 +8,7 @@ stability: experimental build-type: Simple cabal-version: >= 1.6-tested-with: GHC==6.8.2,GHC==6.10.4+tested-with: GHC==6.10.4 synopsis: A Haskell implementation of OAuth 1.0a protocol. description: This library implements all PLAINTEXT, HMAC-SHA1 and RSA-SHA1 signatures as defined in the specification 1.0. Currently it@@ -35,24 +35,6 @@ flag test Description: Build the hoauth test suite. Default: False--executable test_hoauth- build-depends: base>=4&&<5- ,bytestring>=0.9.0.1- ,SHA>=1.4.0- ,RSA>=1.0.2- ,base64-string>=0.1- ,utf8-string>=0.3.3- ,binary>=0.5- ,time>=1.1.4- ,old-locale- ,system-uuid>=1.1.0- ,HUnit>=1.2.0.0- ghc-options: -fno-ignore-asserts -fwarn-tabs- hs-source-dirs: src/main/haskell,src/test/haskell- main-is: Tests.hs- if !flag(test)- buildable: False source-repository head type: darcs
src/main/haskell/Network/Protocol/OAuth/Consumer.hs view
@@ -27,11 +27,17 @@ -- | A pure library that implements oauth authentication protocol as defined in <http://oauth.net/core/1.0a>. -- -- Refer to <http://oauth.net/> for more information about the oauth protocol.-module Network.Protocol.OAuth.Consumer (Token(),Consumer(..),request,response,oauth_token,oauth_token_secret,oauth_extra,plaintext_signature,hmacsha1_signature) where+module Network.Protocol.OAuth.Consumer (Token(),Consumer(..),request,response,nonce_and_timestamp,oauth_token,oauth_token_secret,oauth_extra,plaintext_signature,hmacsha1_signature) where import Network.Protocol.OAuth.Request as R import qualified Data.ByteString.Lazy as B import qualified Network.Protocol.OAuth.Signature as S+import qualified Data.Time.Clock as T+import qualified Data.Time.Format as F+import qualified System.Locale as L+import qualified System.UUID.V1 as U+import qualified Text.Printf as P+import qualified Data.Binary as Bn import qualified Data.List as L import qualified Control.Monad as M @@ -78,6 +84,13 @@ in case c of (Unauthenticated ckey csec) -> M.liftM3 Authenticated (return ckey) (return csec) token (Authenticated ckey csec _) -> M.liftM3 Authenticated (return ckey) (return csec) token++-- | Generates the oauth_nonce and oauth_timestamp parameters.+nonce_and_timestamp :: Request -> IO Request+nonce_and_timestamp r = do+ timestamp <- fmap (F.formatTime L.defaultTimeLocale "%s") T.getCurrentTime+ nonce <- fmap (concatMap (P.printf "%02x") . B.unpack . Bn.encode) U.uuid+ return (r >>+ ("oauth_nonce",Just nonce) >>+ ("oauth_timestamp",Just timestamp)) _oauth :: (S.Signer s,Show s) => String -> s -> R.Request -> R.Request _oauth ckey met req = _sign met $ req >>+ ("oauth_consumer_key",Just ckey)
src/main/haskell/Network/Protocol/OAuth/Request.hs view
@@ -24,7 +24,7 @@ -- 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. -module Network.Protocol.OAuth.Request (Request(..),HTTPMethod(..),Parameter,PercentEncoding(encode,encodes,decode,decodes),nonce_and_timestamp,append_param,show_url,show_oauthurl,show_oauthheader,show_urlencoded,read_urlencoded,(>>+)) where+module Network.Protocol.OAuth.Request (Request(..),HTTPMethod(..),Parameter,PercentEncoding(encode,encodes,decode,decodes),append_param,show_url,show_oauthurl,show_oauthheader,show_urlencoded,read_urlencoded,(>>+)) where import Data.Bits as B import qualified Data.ByteString.Lazy as B1@@ -33,12 +33,6 @@ import qualified Data.Word as W import qualified Data.Char as C import qualified Data.List as L-import qualified Data.Time.Clock as T-import qualified Data.Time.Format as F-import qualified System.Locale as L-import qualified System.UUID.V1 as U-import qualified Text.Printf as P-import qualified Data.Binary as Bn -- | A pair which represents a parameter (key,value). type Parameter = (String,Maybe String)@@ -133,13 +127,6 @@ -- For convenience, it sorts the parameters first, as demands the oauth protocol. show_urlencoded :: [Parameter] -> B1.ByteString show_urlencoded = _urlencode encodes 0x26---- | Generates the oauth_nonce and oauth_timestamp parameters.-nonce_and_timestamp :: Request -> IO Request-nonce_and_timestamp r = do- timestamp <- fmap (F.formatTime L.defaultTimeLocale "%s") T.getCurrentTime- nonce <- fmap (concatMap (P.printf "%02x") . B3.unpack . Bn.encode) U.uuid- return (r >>+ ("oauth_nonce",Just nonce) >>+ ("oauth_timestamp",Just timestamp)) -- | Convenience operator to append an item in request's parameters list (>>+) :: Request -> (String,Maybe String) -> Request
− src/test/haskell/Tests.hs
@@ -1,36 +0,0 @@--- Copyright (c) 2009, Diego Souza--- All rights reserved.--- --- Redistribution and use 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 the <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 HOLDER 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.--import qualified Test.HUnit as T-import qualified Test.Network.Protocol.OAuth.Request as R-import qualified Test.Network.Protocol.OAuth.Signature as S-import qualified Test.Network.Protocol.OAuth.Consumer as C--all_tests = let fast = [R.fast_tests, S.fast_tests, C.fast_tests]- slow = [R.slow_tests, S.slow_tests, C.slow_tests]- in T.runTestTT . T.TestList . concat $ (fast ++ slow)--main = all_tests