Author: [email protected] Date: Tue Nov 15 17:02:06 2011 New Revision: 1723 Log:
Added: sandbox/ivol/openid-server/ sandbox/ivol/openid-server/pom.xml sandbox/ivol/openid-server/src/ sandbox/ivol/openid-server/src/main/ sandbox/ivol/openid-server/src/main/java/ sandbox/ivol/openid-server/src/main/java/org/ sandbox/ivol/openid-server/src/main/java/org/amdatu/ sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/ sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/ sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/ sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/osgi/ sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/osgi/Activator.java sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/service/ sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/service/OpenIDServerImpl.java sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/service/WebResourceProvider.java sandbox/ivol/openid-server/src/main/resources/ sandbox/ivol/openid-server/src/main/resources/jsp/ sandbox/ivol/openid-server/src/main/resources/jsp/login.jsp sandbox/ivol/openid-server/src/main/resources/jsp/openidlogin.jsp sandbox/ivol/openid-server/src/main/resources/openid.xrds Added: sandbox/ivol/openid-server/pom.xml ============================================================================== --- (empty file) +++ sandbox/ivol/openid-server/pom.xml Tue Nov 15 17:02:06 2011 @@ -0,0 +1,222 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2010, 2011 The Amdatu 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.verning permissions and limitations + under the License. +--> +<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> + <parent> + <groupId>org.amdatu.auth</groupId> + <artifactId>org.amdatu.auth</artifactId> + <version>0.2.1-SNAPSHOT</version> + </parent> + <artifactId>org.amdatu.auth.openid.server</artifactId> + <packaging>bundle</packaging> + <name>Amdatu Auth - OpenID server</name> + <description>Implements an OpenID Provider.</description> + + <dependencies> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.dispatcher</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.httpcontext</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.jsp</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.resource</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.web</groupId> + <artifactId>org.amdatu.web.jaxrs</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.cassandra</groupId> + <artifactId>org.amdatu.cassandra.listener</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.cassandra</groupId> + <artifactId>org.amdatu.cassandra.application</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.cassandra</groupId> + <artifactId>org.amdatu.cassandra.persistencemanager</artifactId> + <type>bundle</type> + </dependency> + <dependency> + <groupId>org.amdatu.cassandra</groupId> + <artifactId>org.amdatu.cassandra.listener</artifactId> + <type>bundle</type> + <version>0.2.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.amdatu.cassandra</groupId> + <artifactId>org.amdatu.cassandra.application</artifactId> + <type>bundle</type> + <version>0.2.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.amdatu.cassandra</groupId> + <artifactId>org.amdatu.cassandra.persistencemanager</artifactId> + <type>bundle</type> + <version>0.2.0</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20090211</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.openid4java</groupId> + <artifactId>openid4java-nodeps</artifactId> + <version>0.9.5</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + <version>3.1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.1.1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>1.3</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>net.sourceforge.nekohtml</groupId> + <artifactId>nekohtml</artifactId> + <version>1.9.14</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + <version>2.8.1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>xml-apis</groupId> + <artifactId>xml-apis</artifactId> + <version>1.3.03</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.amdatu.libraries</groupId> + <artifactId>org.amdatu.libraries.utilities</artifactId> + <scope>compile</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <configuration> + <instructions> + <Bundle-Activator>org.amdatu.auth.openid.server.osgi.Activator</Bundle-Activator> + <Bundle-SymbolicName>org.amdatu.auth.openid.server</Bundle-SymbolicName> + <Embed-Dependency>*;scope=compile</Embed-Dependency> + <Export-Package> + org.amdatu.auth.openid.server, + </Export-Package> + <Private-Package> + org.openid4java, + org.openid4java.*, + org.apache.commons.httpclient, + org.apache.commons.httpclient.*, + org.apache.commons.codec, + org.apache.commons.codec.*, + org.apache.commons.logging, + org.apache.commons.logging.*, + org.apache.xerces.*, + org.cyberneko.html, + org.cyberneko.html.*, + org.apache.html.dom, + org.apache.wml, + org.apache.wml.dom, + org.apache.xml.serialize, + org.amdatu.auth.openid.server.osgi, + org.amdatu.auth.openid.server.service, + </Private-Package> + <Import-Package> + !net.sf.ehcache, + !org.apache.avalon.*, + !org.apache.axiom.*, + !org.apache.log, + !org.apache.log4j, + !org.apache.xml.resolver, + !org.apache.xml.resolver.readers, + !org.eclipse.higgins.*, + !org.openxri.*, + !org.springframework.*, + !sun.*, + * + </Import-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <!-- Profile that will copy the jar to the configured amdatu.deploy.directory when + the deploy profile is activated --> + <id>deploy</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <build> + <defaultGoal>install</defaultGoal> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> Added: sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/osgi/Activator.java ============================================================================== --- (empty file) +++ sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/osgi/Activator.java Tue Nov 15 17:02:06 2011 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2010, 2011 The Amdatu 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. + */ +package org.amdatu.auth.openid.server.osgi; + +import java.util.Dictionary; +import java.util.Hashtable; + +import org.amdatu.auth.openid.server.service.OpenIDServerImpl; +import org.amdatu.auth.openid.server.service.WebResourceProvider; +import org.amdatu.libraries.utilities.osgi.ServiceDependentActivator; +import org.amdatu.web.dispatcher.DispatcherService; +import org.amdatu.web.httpcontext.ResourceProvider; +import org.amdatu.web.jsp.JspSupport; +import org.amdatu.web.resource.ResourceSupport; +import org.amdatu.web.rest.jaxrs.JaxRsSpi; +import org.amdatu.web.rest.jaxrs.RESTService; +import org.apache.felix.dm.DependencyManager; +import org.osgi.framework.BundleContext; +import org.osgi.service.log.LogService; + +public class Activator extends ServiceDependentActivator { + /** + * Context id of the Authorization HTTP Context. + */ + public static final String CONTEXTID = "amdatu-authorization"; + + /** + * URL alias hosting the login gadget. + */ + public static final String ALIAS = "/openid/server"; + + /** + * URL alias hosting the JSPs. + */ + public static final String JSP_ALIAS = ALIAS + "/jsp"; + + /** + * URL alias hosting the statics. + */ + public static final String RES_ALIAS = ALIAS + "/static"; + + @Override + protected Class<?>[] getRequiredServices() { + return new Class<?>[] {JaxRsSpi.class}; + } + + @Override + public void initWithDependencies(final BundleContext context, final DependencyManager manager) throws Exception { + // Create and register the REST gadget management service + manager.add( + createComponent() + .setInterface(new String[] {RESTService.class.getName()}, null) + .setImplementation(OpenIDServerImpl.class) + .add(createServiceDependency().setService(LogService.class).setRequired(true))); + + // Register the Web resource provider + Dictionary<String, Object> properties = new Hashtable<String, Object>(); + properties.put(DispatcherService.CONTEXT_ID_KEY, CONTEXTID); + properties.put(JspSupport.JSP_ALIAS_KEY, JSP_ALIAS); + properties.put(ResourceSupport.RESOURCE_ALIAS_KEY, RES_ALIAS); + manager.add(createComponent().setInterface(ResourceProvider.class.getName(), properties) + .setImplementation(WebResourceProvider.class) + .add(createServiceDependency().setService(LogService.class).setRequired(true))); + } + + @Override + public void destroy(final BundleContext bundleContext, final DependencyManager dependencyManager) throws Exception { + } +} Added: sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/service/OpenIDServerImpl.java ============================================================================== --- (empty file) +++ sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/service/OpenIDServerImpl.java Tue Nov 15 17:02:06 2011 @@ -0,0 +1,234 @@ +package org.amdatu.auth.openid.server.service; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URI; +import java.net.URL; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.ws.rs.Consumes; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.CacheControl; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.amdatu.web.rest.jaxrs.RESTService; +import org.openid4java.consumer.ConsumerException; +import org.openid4java.message.DirectError; +import org.openid4java.message.Message; +import org.openid4java.message.ParameterList; +import org.openid4java.server.ServerManager; +import org.osgi.framework.BundleContext; +import org.osgi.service.log.LogService; + +@Path("openid/server") +public class OpenIDServerImpl implements RESTService { + // HTTP caching for this REST interface + protected static CacheControl NO_CACHE_CONTROL; + static { + NO_CACHE_CONTROL = new CacheControl(); + NO_CACHE_CONTROL.setNoCache(true); // No cache + } + + private static CacheControl MAXAGE_CACHE_CONTROL; + static { + MAXAGE_CACHE_CONTROL = new CacheControl(); + MAXAGE_CACHE_CONTROL.setMaxAge(300); // 5 minutes + } + + // This is the XRDS document returned by the Yadis discovery service + private final static String YADIS_CONTENT_TYPE = "application/xrds+xml"; + private final static String XRDS_LOCATION_HEADER = "X-XRDS-Location"; + + private LogService m_logService; + private BundleContext m_bundleContext; + + private String m_xrdsDocument; + + // instantiate a ServerManager object + public ServerManager manager = new ServerManager(); + + public OpenIDServerImpl() { + manager.setOPEndpointUrl("http://localhost:3737/rest/openid/server"); + } + + public void start() throws ConsumerException, IOException { + loadXRDS(); + m_logService.log(LogService.LOG_INFO, "OpenID server started."); + } + + private void loadXRDS() throws IOException { + // Load the XRDS file + URL xrdsUrl = m_bundleContext.getBundle().getResource("/openid.xrds"); + BufferedReader reader = null; + InputStreamReader isReader = null; + StringBuilder sb = new StringBuilder(); + try { + isReader = new InputStreamReader(xrdsUrl.openConnection().getInputStream()); + reader = new BufferedReader(isReader); + String line = null; + while ((line = reader.readLine()) != null) { + sb.append(line); + sb.append("\n"); + } + } + finally { + if (reader != null) { + reader.close(); + } + } + m_xrdsDocument = sb.toString(); + } + + @GET + @Path("status") + @Produces({MediaType.TEXT_PLAIN}) + public String status() { + return "OpenID server online"; + } + + @HEAD + /** + * This HEAD method is invoked by Yadis discovery (See 7.3-2 of the OpenID 2.0 spec) + * and returns the URL to the XRDS document in the XRDS location header. + */ + public Response getXRDSUrl() throws Exception { + String xrdsUrl = "http://localhost:3737/rest/openid/server"; + return Response.ok().header(XRDS_LOCATION_HEADER, xrdsUrl).cacheControl(NO_CACHE_CONTROL).build(); + } + + @GET + @Produces(YADIS_CONTENT_TYPE) + /** + * This GET method is invoked by Yadis discovery (See 7.3-2 of the OpenID 2.0 spec) + * and returns the lookup identifiers in an XRDS document. + */ + public Response getXRDSDocument() throws Exception { + return Response.ok(m_xrdsDocument).cacheControl(NO_CACHE_CONTROL).build(); + } + + @GET + @Path("authenticate") + public String authenticate(@Context final HttpServletRequest httpReq, + @Context final HttpServletResponse httpResp) throws Exception { + return processRequest(httpReq, httpResp); + } + + // See also openid4java-0.9.5.593\samples\simple-openid\src\main\webapp\provider.jsp + private String processRequest(HttpServletRequest httpReq, HttpServletResponse httpResp) throws Exception { + Message response; + String responseText; + HttpSession session = httpReq.getSession(true); + + ParameterList reqParams; + + // Completing the authz and authn process by redirecting here + if ("complete".equals(httpReq.getParameter("_action"))) { + reqParams = (ParameterList) session.getAttribute("parameterlist"); // On a redirect from the OP authn & authz sequence + } + else { + reqParams = new ParameterList(httpReq.getParameterMap()); + } + + String mode = reqParams.hasParameter("openid.mode") ? + reqParams.getParameterValue("openid.mode") : null; + + if ("associate".equals(mode)) { + // --- process an association request --- + response = manager.associationResponse(reqParams); + responseText = response.keyValueFormEncoding(); + } + else if ("checkid_setup".equals(mode) + || "checkid_immediate".equals(mode)) { + // Verify if the user is already authenticated. If not, we redirect the user to + // our login form which will post login credentials to /rest/openid/server/login + if ((session.getAttribute("authenticatedAndApproved") == null) || + (((Boolean) session.getAttribute("authenticatedAndApproved")) == Boolean.FALSE)) { + session.setAttribute("parameterlist", reqParams); + httpResp.sendRedirect("/openid/server/jsp/login.jsp"); + return null; + } + + String userSelectedId = (String) session.getAttribute("openid.claimed_id"); + String userSelectedClaimedId = (String) session.getAttribute("openid.identity"); + Boolean authenticatedAndApproved = (Boolean) session.getAttribute("authenticatedAndApproved"); + + // FIXME: temp logout for test purposes + session.setAttribute("authenticatedAndApproved", Boolean.FALSE); + + // --- process an authentication request --- + response = manager.authResponse(reqParams, + userSelectedId, + userSelectedClaimedId, + authenticatedAndApproved.booleanValue()); + + if (response instanceof DirectError) + return directResponse(httpResp, response.keyValueFormEncoding()); + else { + // caller will need to decide which of the following to use: + + // option1: GET HTTP-redirect to the return_to URL + return response.getDestinationUrl(true); + + // option2: HTML FORM Redirection + // RequestDispatcher dispatcher = + // getServletContext().getRequestDispatcher("formredirection.jsp"); + // httpReq.setAttribute("prameterMap", response.getParameterMap()); + // httpReq.setAttribute("destinationUrl", response.getDestinationUrl(false)); + // dispatcher.forward(request, response); + // return null; + } + } + else if ("check_authentication".equals(mode)) { + // --- processing a verification request --- + response = manager.verify(reqParams); + responseText = response.keyValueFormEncoding(); + } + else { + // --- error response --- + response = DirectError.createDirectError("Unknown request"); + responseText = response.keyValueFormEncoding(); + } + + // return the result to the user + return responseText; + } + + @POST + @Path("login") + @Consumes("application/x-www-form-urlencoded") + public Response login(@Context final HttpServletRequest request, @Context final HttpServletResponse response, + @FormParam("userid") final String userid) { + try { + // TODO: verify login credentials. For now we accept it all + HttpSession session = request.getSession(true); + session.setAttribute("authenticatedAndApproved", Boolean.TRUE); + session.setAttribute("openid.claimed_id", userid); + + String redirect = "http://localhost:3737/rest/openid/server/authenticate?_action=complete"; + return Response.status(302).location(new URI(redirect)).cacheControl(NO_CACHE_CONTROL).build(); + } + catch (Exception e) { + throw new WebApplicationException(e); + } + } + + private String directResponse(HttpServletResponse httpResp, String response) throws IOException { + ServletOutputStream os = httpResp.getOutputStream(); + os.write(response.getBytes()); + os.close(); + + return null; + } +} Added: sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/service/WebResourceProvider.java ============================================================================== --- (empty file) +++ sandbox/ivol/openid-server/src/main/java/org/amdatu/auth/openid/server/service/WebResourceProvider.java Tue Nov 15 17:02:06 2011 @@ -0,0 +1,44 @@ +package org.amdatu.auth.openid.server.service; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; + +import org.amdatu.auth.openid.server.osgi.Activator; +import org.amdatu.web.httpcontext.ResourceProvider; +import org.osgi.framework.BundleContext; +import org.osgi.service.log.LogService; + +public class WebResourceProvider implements ResourceProvider { + private static final String LOCAL_DEV_DIR = "D:\\Amdatu-svn\\sandbox\\ivol\\openid-client\\src\\main\\resources\\jsp\\"; + + // Service dependencies, injected by the Felix dependency manager + private volatile LogService m_logService; + private volatile BundleContext m_bundleContext; + + /** + * The init() method is invoked by the Felix dependency manager. + */ + public void start() { + m_logService.log(LogService.LOG_INFO, getClass().getName() + " service started"); + } + + public URL getResource(final String name) { + final String pathPrefix = Activator.ALIAS + "/"; + if (name != null && name.startsWith(pathPrefix)) { + if (name.contains("/src/")) { + String fileName = name.substring(name.lastIndexOf("/src/") + "/src/".length()); + File file = new File(LOCAL_DEV_DIR + fileName); + try { + return file.toURL(); + } + catch (MalformedURLException e) { + } + } + return m_bundleContext.getBundle().getResource(name.substring(pathPrefix.length())); + } + return null; + + + } +} Added: sandbox/ivol/openid-server/src/main/resources/jsp/login.jsp ============================================================================== --- (empty file) +++ sandbox/ivol/openid-server/src/main/resources/jsp/login.jsp Tue Nov 15 17:02:06 2011 @@ -0,0 +1,14 @@ +<%@ page session="true" %> +<%@ page import="java.util.List, org.openid4java.message.AuthSuccess, org.openid4java.server.InMemoryServerAssociationStore, org.openid4java.message.DirectError,org.openid4java.message.Message,org.openid4java.message.ParameterList, org.openid4java.discovery.Identifier, org.openid4java.discovery.DiscoveryInformation, org.openid4java.message.ax.FetchRequest, org.openid4java.message.ax.FetchResponse, org.openid4java.message.ax.AxMessage, org.openid4java.message.*, org.openid4java.OpenIDException, java.util.List, java.io.IOException, javax.servlet.http.HttpSession, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.openid4java.server.ServerManager, org.openid4java.consumer.InMemoryConsumerAssociationStore, org.openid4java.consumer.VerificationResult" %> + + +<h1>OpenID Login</h1> +<p> +NB: you can login with any userid you want + +<form method="POST" action="http://localhost:3737/rest/openid/server/login"> + Login with userid: + <input type="edit" name="userid"/> + <input type="submit"/> +</form> +</p> \ No newline at end of file Added: sandbox/ivol/openid-server/src/main/resources/jsp/openidlogin.jsp ============================================================================== --- (empty file) +++ sandbox/ivol/openid-server/src/main/resources/jsp/openidlogin.jsp Tue Nov 15 17:02:06 2011 @@ -0,0 +1,139 @@ +<%-- + Copyright (c) 2010, 2011 The Amdatu 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.verning permissions and limitations + under the License. +--%> + +<%@ page language="java" session="false" buffer="none" %> + +<c:set var="contextPath" value="${pageContext.request.contextPath}"/> +<c:set var="surveyUrl" value="${baseUrl}/rest/survey"/> + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <title>OpenID login</title> + <script type="text/javascript" src="${contextPath}/dashboard/static/js/lib/jquery-1.4.2.min.js"></script> + </head> + + <body> + <h3>Select your favorite OpenID provider</h3> + <p> + <table border="1"> + <tr> + <td> + <a href="#" onclick="javascript:login('google');"> + <img src="http://www.wilmakarels.nl/images/image/picasa/google-photo/google-photo.jpg" width="200px"/> + </a> + </td> + <td onclick="javascript:login('yahoo');"> + <a href="#" onclick="javascript:login('yahoo');"> + <img src="http://www.networking4all.com/img/gallery/news/yahoo.jpg" width="200px" /> + </a> + </td> + <td> + <a href="#" onclick="javascript:login('novell');"> + <img src="http://aleksspirkoski.files.wordpress.com/2011/09/novell.gif" width="200px" /> + </a> + </td> + </tr> + <tr> + <td> + <a href="#" onclick="javascript:login('hyves');"> + <img src="http://2.bp.blogspot.com/--oZl8IH-ujg/TZMLS5HTDrI/AAAAAAAAAOw/Vcb4znQdPv0/s1600/Hyves.png" width="200px" /> + </a> + </td> + <td> + <a href="#" onclick="javascript:login('myid');"> + <img src="http://r.myid.net/v1/images/share/logo.gif" width="200px" /> + </a> + </td> + <td> + <a href="#" onclick="javascript:login('myopenid');"> + <img src="http://michaelweisser.com/images/new_myopenid_logo_header.png" width="200px" /> + </a> + </td> + </tr> + <tr> + <td> + <a href="#" onclick="javascript:login('myspace');"> + <img src="http://www.deedeeyork.com/wp-admin/images/icons/myspace.gif" width="200px" /> + </a> + </td> + </tr> + </table> + </p> + + </body> +</html> + +<script type="text/javascript"> + var googleUri = "https://www.google.com/accounts/o8/id"; + var yahooUri = "https://me.yahoo.com"; + var novellUri = "http://www.novell.com/openid/"; + var hyvesUri = "http://www.hyves.nl/"; + var myidUri = "https://myid.net/"; + var myopenidUri = "https://myopenid.com/"; + var myspaceuri = "https://api.myspace.com/openid"; + + function login(openIdProvider) { + var openIdUri; + if (openIdProvider == "google") { + openIdUri = googleUri; + } + else if (openIdProvider == "yahoo") { + openIdUri = yahooUri; + } + else if (openIdProvider == "novell") { + openIdUri = novellUri; + } + else if (openIdProvider == "hyves") { + openIdUri = hyvesUri; + } + else if (openIdProvider == "myid") { + openIdUri = myidUri; + } + else if (openIdProvider == "myopenid") { + myopenidUri = novellUri; + } + else if (openIdProvider == "myspace") { + openIdUri = myspaceuri; + } + + var postdata = { + uri: openIdUri + }; + + var url = "/rest/openid/login"; + jQuery.ajax({ + url: url, + type: "POST", + data: postdata, + dataType: "json", + async:true, + success: function(data, textStatus, xhr) { + if (xhr.status == 278) { + var redirectUri = xhr.getResponseHeader("redirecturi"); + window.location.href = redirectUri; + //window.location.href = xhr.replace(/\?.*$/, "?next="+window.location.pathname); + } + }, + + + } + ); + } + +</script> Added: sandbox/ivol/openid-server/src/main/resources/openid.xrds ============================================================================== --- (empty file) +++ sandbox/ivol/openid-server/src/main/resources/openid.xrds Tue Nov 15 17:02:06 2011 @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)" xmlns:openid="http://openid.net/xmlns/1.0"> + <XRD xmlns="xri://$xrd*($v*2.0)"> + + <!-- OpenID 2.0 login service --> + <Service priority="10"> + <Type>http://specs.openid.net/auth/2.0/signon</Type> + <URI>http://localhost:3737/rest/openid/server/authenticate</URI> + </Service> + + </XRD> +</xrds:XRDS> \ No newline at end of file _______________________________________________ Amdatu-commits mailing list [email protected] http://lists.amdatu.org/mailman/listinfo/amdatu-commits
