summaryrefslogtreecommitdiffstats
path: root/sca-cpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-07-01 06:04:43 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-07-01 06:04:43 +0000
commit8e35575af73a89217bc5f9dc14dd59428f5ee39a (patch)
tree64543577987a03490ef3d1d244f94c1385533732 /sca-cpp
parentac8bb2ddecac09d60760ef83319b627548d0fd77 (diff)
Refactor OpenID test pages and add test methods returning the user info.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@959522 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp')
-rw-r--r--sca-cpp/trunk/modules/openid/Makefile.am4
-rw-r--r--sca-cpp/trunk/modules/openid/htdocs/index.html3
-rw-r--r--sca-cpp/trunk/modules/openid/htdocs/login.html62
-rw-r--r--sca-cpp/trunk/modules/openid/htdocs/protected/index.html23
-rw-r--r--sca-cpp/trunk/modules/openid/htdocs/protected/login/index.html97
-rw-r--r--sca-cpp/trunk/modules/openid/htdocs/protected/logout/index.html (renamed from sca-cpp/trunk/modules/openid/htdocs/protected/logout.html)12
-rwxr-xr-xsca-cpp/trunk/modules/openid/openid-conf23
-rw-r--r--sca-cpp/trunk/modules/openid/openid.composite17
-rwxr-xr-xsca-cpp/trunk/modules/openid/start-test (renamed from sca-cpp/trunk/modules/openid/server-test)9
-rwxr-xr-xsca-cpp/trunk/modules/openid/stop-test22
-rw-r--r--sca-cpp/trunk/modules/openid/user-info.scm (renamed from sca-cpp/trunk/modules/openid/server-test.scm)7
11 files changed, 187 insertions, 92 deletions
diff --git a/sca-cpp/trunk/modules/openid/Makefile.am b/sca-cpp/trunk/modules/openid/Makefile.am
index 90ca3f1f6c..a28611dc41 100644
--- a/sca-cpp/trunk/modules/openid/Makefile.am
+++ b/sca-cpp/trunk/modules/openid/Makefile.am
@@ -25,8 +25,8 @@ mod_DATA = openid.prefix
openid.prefix: $(top_builddir)/config.status
echo ${MODAUTHOPENID_PREFIX} >openid.prefix
-EXTRA_DIST = openid.composite server-test.scm htdocs/index.html htdocs/login.html htdocs/protected/index.html
+EXTRA_DIST = openid.composite user-info.scm htdocs/index.html htdocs/login/index.html htdocs/logout/index.html htdocs/protected/index.html
-dist_noinst_SCRIPTS = server-test
+dist_noinst_SCRIPTS = start-test stop-test
endif
diff --git a/sca-cpp/trunk/modules/openid/htdocs/index.html b/sca-cpp/trunk/modules/openid/htdocs/index.html
index ff69115cda..1134201389 100644
--- a/sca-cpp/trunk/modules/openid/htdocs/index.html
+++ b/sca-cpp/trunk/modules/openid/htdocs/index.html
@@ -20,5 +20,6 @@
<html><body>
<h1>Unprotected area - It works!</h1>
<p><a href="protected">Protected area</a></p>
-<p><a href="login.html">Sign in</a></p>
+<p><a href="protected/login">Sign in</a></p>
+<p><a href="/protected/logout">Sign out</a></p>
</body></html>
diff --git a/sca-cpp/trunk/modules/openid/htdocs/login.html b/sca-cpp/trunk/modules/openid/htdocs/login.html
deleted file mode 100644
index b7b87aac04..0000000000
--- a/sca-cpp/trunk/modules/openid/htdocs/login.html
+++ /dev/null
@@ -1,62 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-
-<html><body>
-<h1>Sign in with an OpenID provider</h1>
-
-<form "googleSignin" action="/protected" method="GET">
-<input type="hidden" name="openid_identifier" value="https://www.google.com/accounts/o8/id"/>
-<input type="submit" value="Sign in with your Google account"/>
-</form>
-
-<form name="yahooSignin" action="/protected" method="GET">
-<input type="hidden" name="openid_identifier" value="https://me.yahoo.com/"/>
-<input type="submit" value="Sign in with your Yahoo account"/>
-
-</form>
-
-<form name="myOpenIDSignin" action="/protected" method="GET">
-<input type="hidden" name="openid_identifier" value="http://www.myopenid.com/xrds"/>
-<input type="submit" value="Sign in with your MyOpenID account"/>
-</form>
-
-<form name="verisignSignin" action="/protected" method="GET">
-<input type="hidden" name="openid_identifier" value="https://pip.verisignlabs.com/"/>
-<input type="submit" value="Sign in with your Verisign account"/>
-</form>
-
-<form name="googleAppsSignin" action="/protected" method="GET">
-<script type="text/javascript">
-function initOpenIDIdentifier() {
- document.googleAppsSignin.openid_identifier.value = 'https://www.google.com/accounts/o8/site-xrds?ns=2&hd=' + document.googleAppsSignin.domain.value;
- return true;
-}
-</script>
-<!-- Enter your Google apps domain, e.g example.com -->
-<input type="text" size="20" name="domain" value="example.com"/><br/>
-<input type="hidden" size=50 name="openid_identifier" value=""/>
-<input type="submit" onclick="initOpenIDIdentifier()" value="Sign in with a Google Apps domain"/>
-</form>
-
-<form name="xrdsEndpointSignin" action="/protected" method="GET">
-<!-- Enter your OpenID XRDS endpoint, e.g. https://www.google.com/accounts/o8/id -->
-<input type="text" size="50" name="openid_identifier" value="https://www.google.com/accounts/o8/id"/><br/>
-<input type="submit" value="Sign in with an OpenID XRDS endpoint"/>
-</form>
-</body></html>
diff --git a/sca-cpp/trunk/modules/openid/htdocs/protected/index.html b/sca-cpp/trunk/modules/openid/htdocs/protected/index.html
index 1799bc1006..4c7bc4f5a3 100644
--- a/sca-cpp/trunk/modules/openid/htdocs/protected/index.html
+++ b/sca-cpp/trunk/modules/openid/htdocs/protected/index.html
@@ -17,8 +17,25 @@
under the License.
-->
-<html><body>
+<html>
+<head>
+<script type="text/javascript" src="/js/tuscany-ref.js"></script>
+<script language="JavaScript">
+ var component = new tuscany.sca.Component("Protected");
+ var userInfo = new tuscany.sca.Reference("userInfo");
+ var user = userInfo.apply("getuser");
+ var email = userInfo.apply("getemail");
+</script>
+</head>
+<body>
<h1>Protected area - It works!</h1>
-<p><a href="hello">Hello component</a></p>
-<p><a href="logout.html">Sign out</a></p>
+<p>The following info is returned by a JSONRPC service:</p>
+<div id="user"></div>
+<div id="email"></div>
+<p><a href="/protected/info">User info</a></p>
+<p><a href="/protected/logout">Sign out</a></p>
+<script language="JavaScript">
+ document.getElementById('user').innerHTML="User: " + user;
+ document.getElementById('email').innerHTML="Email: " + email;
+</script>
</body></html>
diff --git a/sca-cpp/trunk/modules/openid/htdocs/protected/login/index.html b/sca-cpp/trunk/modules/openid/htdocs/protected/login/index.html
new file mode 100644
index 0000000000..a3c0119839
--- /dev/null
+++ b/sca-cpp/trunk/modules/openid/htdocs/protected/login/index.html
@@ -0,0 +1,97 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+
+<html><body><h1>Sign in with an OpenID provider</h1>
+
+<script type="text/javascript">
+function queryParams() {
+ qp = new Array();
+ qs = window.location.search.substring(1).split('&');
+ for (i = 0; i < qs.length; i++) {
+ e = qs[i].indexOf('=');
+ if (e > 0)
+ qp[qs[i].substring(0, e)] = unescape(qs[i].substring(e + 1));
+ }
+ return qp;
+}
+
+function openidReferrer() {
+ r = queryParams()['modauthopenid.referrer'];
+ if (typeof(r) == 'undefined')
+ return r;
+ q = r.indexOf('?');
+ if (q > 0)
+ return r.substring(0, q);
+ return r;
+}
+
+if (typeof(openidReferrer()) == 'undefined') {
+ document.location = '/protected';
+}
+
+function submitSignin(w) {
+ document.signin.openid_identifier.value = w();
+ document.signin.action = openidReferrer();
+ document.signin.submit();
+}
+
+
+function withGoogle() {
+ return 'https://www.google.com/accounts/o8/id';
+}
+
+function withYahoo() {
+ return 'https://me.yahoo.com/';
+}
+
+function withMyOpenID() {
+ return 'http://www.myopenid.com/xrds';
+}
+
+function withVerisign() {
+ return 'https://pip.verisignlabs.com/';
+}
+
+function withGoogleApps() {
+ return 'https://www.google.com/accounts/o8/site-xrds?ns=2&hd=' + document.fields.domain.value;
+}
+
+function withXRDSEndpoint() {
+ return document.fields.endpoint.value;
+}
+</script>
+
+<form name="signin" action="/protected" method="GET">
+<input type="hidden" name="openid_identifier" value="https://www.google.com/accounts/o8/id"/>
+</form>
+
+<form name="fields">
+<p>Sign in with your Google account<br/><input type="button" onclick="submitSignin(withGoogle)" value="Sign in"/></p>
+<p>Sign in with your Yahoo account<br/><input type="button" onclick="submitSignin(withYahoo)" value="Sign in"/></p>
+<p>Sign in with your MyOpenID account<br/><input type="button" onclick="submitSignin(withMyOpenID)" value="Sign in"/></p>
+<p>Sign in with your Verisign account<br/><input type="button" onclick="submitSignin(withVerisign)" value="Sign in"/></p>
+<p>Sign in with a Google apps domain<br/>
+<input type="text" size="20" name="domain" value="example.com"/><br/>
+<input type="button" onclick="submitSignin(withGoogleApps)" value="Sign in"/></p>
+<p>Sign in with an OpenID endpoint<br/>
+<input type="text" size="50" name="endpoint" value="https://www.google.com/accounts/o8/id"/><br/>
+<input type="button" onclick="submitSignin(withXRDSEndpoint)" value="Sign in"/></p>
+</form>
+
+</body></html>
diff --git a/sca-cpp/trunk/modules/openid/htdocs/protected/logout.html b/sca-cpp/trunk/modules/openid/htdocs/protected/logout/index.html
index ec8c104c92..a92bad3086 100644
--- a/sca-cpp/trunk/modules/openid/htdocs/protected/logout.html
+++ b/sca-cpp/trunk/modules/openid/htdocs/protected/logout/index.html
@@ -20,15 +20,15 @@
<html><body>
<h1>Sign out</h1>
-<form "Signout" action="/" method="GET">
+<form name="signout" action="/" method="GET">
<script type="text/javascript">
-function deleteOpenIDSessionCookie() {
- alert(document.cookie);
- document.cookie = 'open_id_session_id=;expires=' + new Date(1970,01,01).toGMTString();
- alert(document.cookie);
+function submitSignout() {
+ document.cookie = 'open_id_session_id=;expires=' + new Date(1970,01,01).toGMTString() + ';path=/';
+ document.signout.action = document.referrer;
+ document.signout.submit();
return true;
}
</script>
-<input type="submit" onclick="deleteOpenIDSessionCookie()" value="Sign out"/>
+<input type="button" onclick="submitSignout()" value="Sign out"/>
</form>
</body></html>
diff --git a/sca-cpp/trunk/modules/openid/openid-conf b/sca-cpp/trunk/modules/openid/openid-conf
index cac75549fd..5085d741cc 100755
--- a/sca-cpp/trunk/modules/openid/openid-conf
+++ b/sca-cpp/trunk/modules/openid/openid-conf
@@ -30,11 +30,30 @@ LoadModule authopenid_module $openid_prefix/modules/mod_auth_openid.so
<Location /protected>
AuthOpenIDEnabled On
-AuthOpenIDLoginPage /login.html
+AuthOpenIDCookiePath /
+AuthOpenIDLoginPage /protected/login
AuthOpenIDAXAdd EMAIL http://axschema.org/contact/email
</Location>
-<Location /login>
+<Location /components>
+AuthOpenIDEnabled On
+AuthOpenIDCookiePath /
+AuthOpenIDLoginPage /protected/login
+AuthOpenIDAXAdd EMAIL http://axschema.org/contact/email
+</Location>
+
+<Location /references>
+AuthOpenIDEnabled On
+AuthOpenIDCookiePath /
+AuthOpenIDLoginPage /protected/login
+AuthOpenIDAXAdd EMAIL http://axschema.org/contact/email
+</Location>
+
+<Location /protected/login>
+AuthOpenIDEnabled Off
+</Location>
+
+<Location /protected/logout>
AuthOpenIDEnabled Off
</Location>
diff --git a/sca-cpp/trunk/modules/openid/openid.composite b/sca-cpp/trunk/modules/openid/openid.composite
index 7310661dc0..6c829c44b1 100644
--- a/sca-cpp/trunk/modules/openid/openid.composite
+++ b/sca-cpp/trunk/modules/openid/openid.composite
@@ -22,13 +22,18 @@
targetNamespace="http://tuscany.apache.org/xmlns/sca/components"
name="openid">
- <component name="hello">
- <t:implementation.scheme script="server-test.scm"/>
- <service name="hello">
- <t:binding.jsonrpc uri="protected/hello"/>
+ <component name="Protected">
+ <t:implementation.widget location="protected/index.html"/>
+ <reference name="userInfo" target="UserInfo"/>
+ </component>
+
+ <component name="UserInfo">
+ <t:implementation.scheme script="user-info.scm"/>
+ <service name="info">
+ <t:binding.jsonrpc uri="protected/info"/>
</service>
- <property name="user">nobody</property>
- <property name="email">nobody@nowhere.org</property>
+ <property name="user">anonymous</property>
+ <property name="email">anonymous@example.com</property>
</component>
</composite>
diff --git a/sca-cpp/trunk/modules/openid/server-test b/sca-cpp/trunk/modules/openid/start-test
index f0df198901..eed21f759c 100755
--- a/sca-cpp/trunk/modules/openid/server-test
+++ b/sca-cpp/trunk/modules/openid/start-test
@@ -28,13 +28,4 @@ SCAComposite openid.composite
EOF
../../modules/http/httpd-start tmp
-sleep 2
-# Test
-#./client-test 2>/dev/null
-rc=$?
-
-# Cleanup
-#../../modules/http/httpd-stop tmp
-#sleep 2
-return $rc
diff --git a/sca-cpp/trunk/modules/openid/stop-test b/sca-cpp/trunk/modules/openid/stop-test
new file mode 100755
index 0000000000..a468b0f407
--- /dev/null
+++ b/sca-cpp/trunk/modules/openid/stop-test
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+# Cleanup
+../../modules/http/httpd-stop tmp
+
diff --git a/sca-cpp/trunk/modules/openid/server-test.scm b/sca-cpp/trunk/modules/openid/user-info.scm
index 19f914b5ce..69eb207be9 100644
--- a/sca-cpp/trunk/modules/openid/server-test.scm
+++ b/sca-cpp/trunk/modules/openid/user-info.scm
@@ -17,5 +17,10 @@
; OpenID support test case
-(define (get id user email) (list "text/html" (list "<html><body><p>Hello " (user) ", " (email) "</p></body></html>")))
+(define (get id user email) (list "text/html" (list
+ "<html><body><p>The following info is generated on the server:</p><div>User: " (user) "</div><div>Email: " (email) "</div></body></html>")))
+
+(define (getuser user email) (user))
+
+(define (getemail user email) (email))