zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #24116
[Merge] lp:~zorba-coders/zorba/bug-1188052-oauth-update into lp:zorba/oauth-module
Chris Hillery has proposed merging lp:~zorba-coders/zorba/bug-1188052-oauth-update into lp:zorba/oauth-module.
Requested reviews:
Zorba Coders (zorba-coders)
Related bugs:
Bug #1188052 in Zorba: "Update non-core module "oauth""
https://bugs.launchpad.net/zorba/+bug/1188052
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1188052-oauth-update/+merge/173872
--
https://code.launchpad.net/~zorba-coders/zorba/bug-1188052-oauth-update/+merge/173872
Your team Zorba Coders is requested to review the proposed merge of lp:~zorba-coders/zorba/bug-1188052-oauth-update into lp:zorba/oauth-module.
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2012-04-12 08:44:46 +0000
+++ src/CMakeLists.txt 2013-07-10 07:39:27 +0000
@@ -12,11 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# all external module libraries are generated in the directory
-# of the corresponding .xq file
-MESSAGE(STATUS "Add com")
+DECLARE_ZORBA_MODULE (URI "http://zorba.io/modules/oauth"; VERSION 1.0 FILE "client.xq")
DECLARE_ZORBA_SCHEMA (URI "http://www.zorba-xquery.com/schemas/oauth/parameters"; FILE "parameters.xsd")
DECLARE_ZORBA_SCHEMA (URI "http://www.zorba-xquery.com/schemas/oauth/service-provider"; FILE "service-provider.xsd")
-ADD_SUBDIRECTORY(com)
-MESSAGE(STATUS "End modules")
+
=== renamed file 'src/com/zorba-xquery/www/modules/oauth/client.xq' => 'src/client.xq'
--- src/com/zorba-xquery/www/modules/oauth/client.xq 2013-06-15 23:33:19 +0000
+++ src/client.xq 2013-07-10 07:39:27 +0000
@@ -19,16 +19,16 @@
(:~
: This module provides the functions necessary to acquire access to the personal
: resources of a user through the open standard called
- : <a href="http://oauth.net/"; target="_blank">OAuth</a>.
+ : <a href="http://oauth.net/"; target="_blank">OAuth</a>.<p/>
: The application/mashup creator does not need to know the
- : specifics of <a href="http://oauth.net/"; target="_blank">OAuth</a> to use this module.
+ : specifics of OAuth to use this module.<p/>
: @author Stephanie Russell
: @author <a href="mailto:william.candillon@xxxxxxxxxx";>William Candillon</a>
: @see <a href="http://oauth.net/"; target="_blank">OAuth Website</a>
: @project Zorba/OAuth/Client
:
:)
-module namespace oauth = "http://www.zorba-xquery.com/modules/oauth/client";;
+module namespace oauth = "http://zorba.io/modules/oauth";;
import module namespace ra = "http://www.zorba-xquery.com/modules/random";;
import module namespace hmac = "http://www.zorba-xquery.com/modules/cryptography/hmac#2.0";;
@@ -37,11 +37,6 @@
import module namespace base64 = "http://www.zorba-xquery.com/modules/converters/base64";;
-(:~
- : Use err module functions for throwing errors.
- :)
-import module namespace oerr = "http://www.zorba-xquery.com/modules/oauth/error";;
-
import schema namespace sp = "http://www.zorba-xquery.com/schemas/oauth/service-provider";;
import schema namespace p = "http://www.zorba-xquery.com/schemas/oauth/parameters";;
@@ -52,10 +47,36 @@
declare option op:disable "f:trace";
-declare option ver:module-version "2.0";
-
-(:~
- : Utility function to build a service provider object.
+declare option ver:module-version "1.0";
+
+
+(:~
+ : Error code for unsupported signing method
+ :)
+declare %private variable $oauth:UNSUPPORTED_SIGNING_METHOD as xs:QName :=
+ xs:QName("oauth:UNSUPPORTED_SIGNING_METHOD");
+
+(:~
+ : Error code for attempt to access unauthorized resource
+ :)
+declare %private variable $oauth:UNAUTHORIZED as xs:QName :=
+ xs:QName("oauth:UNAUTHORIZED");
+
+(:~
+ : Error code for HTTP error from server
+ :)
+declare %private variable $oauth:SERVER_ERROR as xs:QName :=
+ xs:QName("oauth:SERVER_ERROR");
+
+(:~
+ : Error code for unknown parameter
+ :)
+declare %private variable $oauth:UNKNOWN_PARAMETER as xs:QName :=
+ xs:QName("oauth:UNKNOWN_PARAMETER");
+
+
+(:~
+ : Utility function to build a service provider object.<p/>
: This object contains the information required by the
: OAuth client to interact with an OAuth service provider.
: For instance the following expression:
@@ -132,7 +153,7 @@
};
(:~
- : Create an OAuth Parameters instance.
+ : Create an OAuth Parameters instance.<p/>
: Instances of OAuth parameters are used to
: contain value/pair data such as <em>oauth_token</em>
: and <em>oauth_token_secret</em>.
@@ -146,6 +167,7 @@
: <p:parameter name="oauth_token" value="#" />
: </p:parameters>
: </pre>
+ :
: @param $name parameter name
: @param $value parameter value
: @return instance of the OAuth parameters XML schema.
@@ -161,7 +183,7 @@
};
(:~
- : Adds an OAuth parameter to an OAuth Parameters instance.
+ : Adds an OAuth parameter to an OAuth Parameters instance.<p/>
: Instances of OAuth parameters are used to
: contain value/pair data such as <em>oauth_token</em>
: and <em>oauth_token_secret</em>.
@@ -199,17 +221,18 @@
};
(:~
- : This function returns the string value of the parameters whose key matches a $string input.
- : @param $params element parameters
- : @param $string string as the "key" name
- : @return string value of the parameter with key $string
- :
+ : This function returns the string value of the parameters whose key matches a $string input.<p/>
+ : Example:
: <pre class="ace-static" ace-mode="xquery">
: let $params := oauth:parameters("oauth_token", "token")
: let $params := oauth:add-parameter($params, "oauth_token_secret", "secret")
: let $token-secret := oauth:parameter($params, "oauth_token_secret")
: return $token-secret
: </pre>
+ : @param $params element parameters
+ : @param $string string as the "key" name
+ : @return string value of the parameter with key $string
+ : @error oauth:UNKNOWN_PARAMETER if $string is not in $params
:)
declare function oauth:parameter($params as schema-element(p:parameters), $string as xs:string) as xs:string
{
@@ -221,14 +244,14 @@
return $value
return
if(empty($value)) then
- error($oerr:OC005, concat("Parameter not found: ", $string))
+ error($oauth:UNKNOWN_PARAMETER, concat("Parameter not found: ", $string))
else
xs:string($value)
};
(:~
- : This function allows the client to obtain a set of temporary credentials from the service provider by making an authenticated HTTP request to the Temporary Credential Request endpoint.
+ : This function allows the client to obtain a set of temporary credentials from the service provider by making an authenticated HTTP request to the Temporary Credential Request endpoint.<p/>
: This function is provided for convenience for <a href="#request-token-2">request-token#2</a>.
: Invoking this function is equivalent to:
: <pre class="ace-static" ace-mode="xquery">
@@ -246,7 +269,7 @@
};
(:~
- : This function allows the client to obtain a set of temporary credentials from the service provider by making an authenticated HTTP request to the Temporary Credential Request endpoint.
+ : This function allows the client to obtain a set of temporary credentials from the service provider by making an authenticated HTTP request to the Temporary Credential Request endpoint.<p/>
: This function is provided for convenience.
: @see http://tools.ietf.org/html/rfc5849#section-2.1
: @param $service-provider Information about the service provider
@@ -286,7 +309,7 @@
};
(:~
- : This function allows the client to obtain a set of token credentials from the service provider by making an authenticated HTTP request to the Token Request endpoint.
+ : This function allows the client to obtain a set of token credentials from the service provider by making an authenticated HTTP request to the Token Request endpoint.<p/>
: This function is provided for convenience.
: @see http://tools.ietf.org/html/rfc5849#section-2.3
: @param $service-provider Contains service provider information
@@ -329,7 +352,7 @@
(:~
- : This function allows the client access to the protected resources of the user.
+ : This function allows the client access to the protected resources of the user.<p/>
: This function is provided for convenience.
: @see http://tools.ietf.org/html/rfc5849#section-3
: @param $protected-resource (Not schema-validated) http:request element with http method and href.
@@ -510,14 +533,15 @@
: @see http://tools.ietf.org/html/rfc5849#section-3.4.3
:)
else if($oauth-signature-method = "RSA-SHA1")
- then error($oerr:OC001, concat("Method not implemented yet: ", $oauth-signature-method))
+ then error($oauth:UNSUPPORTED_SIGNING_METHOD, concat("Method not implemented yet: ", $oauth-signature-method))
(:
: PLAINTEXT
: @see http://tools.ietf.org/html/rfc5849#section-3.4.4
:)
else if($oauth-signature-method = "PLAINTEXT")
then $key
- else error(xs:QName("oerr:OC001"), concat("Unsupported signing method: ", $oauth-signature-method))
+ else error($oauth:UNSUPPORTED_SIGNING_METHOD,
+ concat("Unsupported signing method: ", $oauth-signature-method))
};
(:~
@@ -587,8 +611,8 @@
: @param $url Target URL
: @param $additional-parameters Parameters specific to a certain step (request-token, authorize, access-token, protected-resource) of the OAuth authorization
: @return correctly parsed parameters, or an error if http response status is not 200 OK
- : @error XQP0021(oerr:OC003) if we receive http 401 error from the server.
- : @error XQP0021(oerr:OC004) if we receive http 500 error from the server.
+ : @error oauth:UNAUTHORIZED if we receive http 401 error from the server.
+ : @error oauth:SERVER_ERROR if we receive http 500 error from the server.
:)
declare %private %an:sequential function oauth:format-request(
$consumer-key as xs:string,
@@ -647,11 +671,12 @@
}
else if ($status eq 401) then
error(
- xs:QName("oerr:OC003"),
+ $oauth:UNAUTHORIZED,
concat("Authorization header unauthorized: ", $body)
)
else
- error($oerr:OC004, concat("Service Provider Error ", $status, ": ", $body))
+ error($oauth:SERVER_ERROR,
+ concat("Service Provider Error ", $status, ": ", $body))
};
=== removed directory 'src/com'
=== removed file 'src/com/CMakeLists.txt'
--- src/com/CMakeLists.txt 2011-10-06 08:19:09 +0000
+++ src/com/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
-# Copyright 2006-2008 The FLWOR Foundation.
-#
-# 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
-#
-# 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.
-ADD_SUBDIRECTORY(zorba-xquery)
=== removed directory 'src/com/zorba-xquery'
=== removed file 'src/com/zorba-xquery/CMakeLists.txt'
--- src/com/zorba-xquery/CMakeLists.txt 2011-10-06 08:19:09 +0000
+++ src/com/zorba-xquery/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
-# Copyright 2006-2008 The FLWOR Foundation.
-#
-# 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
-#
-# 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.
-ADD_SUBDIRECTORY(www)
=== removed directory 'src/com/zorba-xquery/www'
=== removed file 'src/com/zorba-xquery/www/CMakeLists.txt'
--- src/com/zorba-xquery/www/CMakeLists.txt 2011-10-06 08:19:09 +0000
+++ src/com/zorba-xquery/www/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
-# Copyright 2006-2008 The FLWOR Foundation.
-#
-# 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
-#
-# 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.
-ADD_SUBDIRECTORY(modules)
=== removed directory 'src/com/zorba-xquery/www/modules'
=== removed file 'src/com/zorba-xquery/www/modules/CMakeLists.txt'
--- src/com/zorba-xquery/www/modules/CMakeLists.txt 2011-10-06 08:19:09 +0000
+++ src/com/zorba-xquery/www/modules/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
-# Copyright 2006-2008 The FLWOR Foundation.
-#
-# 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
-#
-# 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.
-ADD_SUBDIRECTORY(oauth)
=== removed directory 'src/com/zorba-xquery/www/modules/oauth'
=== removed file 'src/com/zorba-xquery/www/modules/oauth/CMakeLists.txt'
--- src/com/zorba-xquery/www/modules/oauth/CMakeLists.txt 2012-12-14 07:16:30 +0000
+++ src/com/zorba-xquery/www/modules/oauth/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-# Copyright 2006-2008 The FLWOR Foundation.
-#
-# 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
-#
-# 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.
-
-DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/oauth/client"; VERSION 2.0 FILE "client.xq")
-
-DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/oauth/error"; VERSION 1.0 FILE "error.xq")
=== removed file 'src/com/zorba-xquery/www/modules/oauth/error.xq'
--- src/com/zorba-xquery/www/modules/oauth/error.xq 2013-06-15 19:43:50 +0000
+++ src/com/zorba-xquery/www/modules/oauth/error.xq 1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
-xquery version "1.0";
-
-(:
- : Copyright 2006-2009 The FLWOR Foundation.
- :
- : 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
- :
- : 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.
- :)
-
-(:~
- : Module that defines the errors raised in Oauth modules.
- :
- : @author Stephanie Russell
- : @project Zorba/OAuth/Errors
- :
- :)
-module namespace oerr = "http://www.zorba-xquery.com/modules/oauth/error";;
-
-declare namespace ver = "http://www.zorba-xquery.com/options/versioning";;
-declare option ver:module-version "1.0";
-
-(:~
- : Errors namespace URI.
- :)
-declare variable $oerr:errNS as xs:string := "http://www.zorba-xquery.com/modules/oauth/errors";;
-
-(:~
- : xs:QName with namespace URI="http://www.zorba-xquery.com/modules/oauth/errors"; and local name 'OC001'. This signing method is not implemented yet.
-:)
-declare variable $oerr:OC001 as xs:QName := xs:QName("oerr:OC001");
-
-(:~
- : xs:QName with namespace URI="http://www.zorba-xquery.com/modules/oauth/errors"; and local name 'OC002'. This signing method is not supported.
-:)
-declare variable $oerr:OC002 as xs:QName := xs:QName("oerr:OC002");
-
-(:~
- : xs:QName with namespace URI="http://www.zorba-xquery.com/modules/oauth/errors"; and local name 'OC003'. Http 401 error.
-:)
-declare variable $oerr:OC003 as xs:QName := xs:QName("oerr:OC003");
-
-(:~
- : xs:QName with namespace URI="http://www.zorba-xquery.com/modules/oauth/errors"; and local name 'OC004'. Http 500 error.
-:)
-declare variable $oerr:OC004 as xs:QName := xs:QName("oerr:OC004");
-
-(:~
- : xs:QName with namespace URI="http://www.zorba-xquery.com/modules/oauth/errors"; and local name 'OC004'. Http 500 error.
-:)
-declare variable $oerr:OC005 as xs:QName := xs:QName("oerr:OC005");
\ No newline at end of file
Follow ups