diff --git a/bbb-api-demo/src/main/webapp/bbb_jopenid.jsp b/bbb-api-demo/src/main/webapp/bbb_jopenid.jsp new file mode 100644 index 0000000000000000000000000000000000000000..0808254dbc50aa044b489f11201b4d9b364c2e06 --- /dev/null +++ b/bbb-api-demo/src/main/webapp/bbb_jopenid.jsp @@ -0,0 +1,87 @@ +<!-- + +BigBlueButton - http://www.bigbluebutton.org + +Copyright (c) 2008-2009 by respective authors (see below). All rights reserved. + +BigBlueButton is free software; you can redistribute it and/or modify it under the +terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 3 of the License, or (at your option) any later +version. + +BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with BigBlueButton; if not, If not, see <http://www.gnu.org/licenses/>. + +Author: Jesus Federico <jesus@123it.ca> + +--> +<%@ page import="java.util.*,java.io.*,java.text.*" errorPage="error.jsp" %> +<%@ page import="org.expressme.openid.*,org.expressme.openid.OpenIdManager" %> + +<%! +static final long ONE_HOUR = 3600000L; +static final long TWO_HOUR = ONE_HOUR * 2L; +static final String ATTR_MAC = "openid_mac"; +static final String ATTR_ALIAS = "openid_alias"; + +private OpenIdManager manager = new OpenIdManager(); + +void showAuthentication(PrintWriter pw, Authentication auth) { + pw.print("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Test JOpenID</title></head><body><h1>You have successfully signed on!</h1>"); + pw.print("<p>Identity: " + auth.getIdentity() + "</p>"); + pw.print("<p>Email: " + auth.getEmail() + "</p>"); + pw.print("<p>Full name: " + auth.getFullname() + "</p>"); + pw.print("<p>First name: " + auth.getFirstname() + "</p>"); + pw.print("<p>Last name: " + auth.getLastname() + "</p>"); + pw.print("<p>Gender: " + auth.getGender() + "</p>"); + pw.print("<p>Language: " + auth.getLanguage() + "</p>"); + pw.print("</body></html>"); + pw.flush(); +} + + +void checkNonce(String nonce) { + // check response_nonce to prevent replay-attack: + if (nonce==null || nonce.length()<20) + throw new OpenIdException("Verify failed."); + // make sure the time of server is correct: + long nonceTime = getNonceTime(nonce); + long diff = Math.abs(System.currentTimeMillis() - nonceTime); + if (diff > ONE_HOUR) + throw new OpenIdException("Bad nonce time."); + if (isNonceExist(nonce)) + throw new OpenIdException("Verify nonce failed."); + storeNonce(nonce, nonceTime + TWO_HOUR); +} + +// simulate a database that store all nonce: +private Set<String> nonceDb = new HashSet<String>(); + +// check if nonce is exist in database: +boolean isNonceExist(String nonce) { + return nonceDb.contains(nonce); +} + +// store nonce in database: +void storeNonce(String nonce, long expires) { + nonceDb.add(nonce); +} + +long getNonceTime(String nonce) { + try { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") + .parse(nonce.substring(0, 19) + "+0000") + .getTime(); + } + catch(ParseException e) { + throw new OpenIdException("Bad nonce time."); + } +} + + +%> + diff --git a/bbb-api-demo/src/main/webapp/demo_header.jsp b/bbb-api-demo/src/main/webapp/demo_header.jsp index 85e08d4290d7d72fb3d5d7bb69cd0cd43e454ece..65e6e899a75ba2ee6b7b622b617d615d2208cacd 100755 --- a/bbb-api-demo/src/main/webapp/demo_header.jsp +++ b/bbb-api-demo/src/main/webapp/demo_header.jsp @@ -13,5 +13,8 @@ <a href="demo4.jsp">Activity Monitor</a> -<a href="demo_mozilla_persona.jsp">Login with Persona</a> +<a href="demo_mozilla_persona.jsp">Login with Persona</a> + +<a href="demo_openid.jsp">Login with Openid</a> + diff --git a/bbb-api-demo/src/main/webapp/demo_openid.jsp b/bbb-api-demo/src/main/webapp/demo_openid.jsp new file mode 100644 index 0000000000000000000000000000000000000000..c73bc41b39a494c8dc94f3f6a632836b6aa0c726 --- /dev/null +++ b/bbb-api-demo/src/main/webapp/demo_openid.jsp @@ -0,0 +1,171 @@ +<!-- + +BigBlueButton - http://www.bigbluebutton.org + +Copyright (c) 2008-2009 by respective authors (see below). All rights reserved. + +BigBlueButton is free software; you can redistribute it and/or modify it under the +terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 3 of the License, or (at your option) any later +version. + +BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. + +Author: Jesus Federico <jesus@123it.ca> + +--> + +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<% + request.setCharacterEncoding("UTF-8"); + response.setCharacterEncoding("UTF-8"); +%> +<!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>Join Demo Meeting using OpenID</title> +<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> +<script type="text/javascript"> + $(function() { + var form = $('#form1'); + $('#google').click(function() { + $("<input>").attr({ + 'type':'hidden', + 'name':'connect', + 'value':'google' + }).appendTo(form); + $('#form1').submit(); + return false; + }); + $('#yahoo').click(function() { + $("<input>").attr({ + 'type':'hidden', + 'name':'connect', + 'value':'yahoo' + }).appendTo(form); + $('#form1').submit(); + return false; + }); + $('#custom').click(function() { + $("<input>").attr({ + 'type':'hidden', + 'name':'connect', + 'value':'custom' + }).appendTo(form); + $('#form1').submit(); + return false; + }); + }); +</script> +</head> +<body> + +<%@ include file="bbb_api.jsp"%> +<%@ include file="bbb_jopenid.jsp"%> + +<% +if (request.getParameterMap().isEmpty()) { + // + // Assume we want to create a meeting + // +%> +<%@ include file="demo_header.jsp"%> + +<h2>Join Demo Meeting using openID</h2> + +<FORM id="form1" NAME="form1" METHOD="GET" ACTION="#"> +<table cellpadding="5" cellspacing="5" style="width: 400px; "> + <tbody> + <tr> + <td> </td> + <td style="text-align: left "> + <a href="#" id="google" title="Sign-in with Google OpenID"> + <img src="images/google.png" alt="Sign in"></br> + </a> + </td> + </tr> + <tr> + <td> </td> + <td style="text-align: left "> + <a href="#" id="yahoo" title="Sign-in with Yahoo OpenID"> + <img src="images/yahoo.png" alt="Sign in"></br> + </a> + </td> + </tr> + <!-- + <tr> + <td> </td> + <td style="text-align: left "> + <a href="#" id="custom" title="Sign-in with Custom OpenID"> + <img src="images/openid.png" alt="Sign in"></br> + </a> + </td> + </tr> + --> + </tbody> +</table> +</FORM> + +<% +} else if (request.getParameter("connect")!=null ) { + manager.setRealm("http://demo.bigbluebutton.org"); + manager.setReturnTo("http://demo.bigbluebutton.org/demo/demo_openid.jsp"); + Endpoint endpoint = null; + + if (request.getParameter("connect").equals("google")) { + endpoint = manager.lookupEndpoint("Google"); + + } else if (request.getParameter("connect").equals("yahoo")) { + endpoint = manager.lookupEndpoint("Yahoo"); + + } else if (request.getParameter("connect").equals("custom")) { + endpoint = manager.lookupEndpoint("Google"); + //endpoint = manager.lookupEndpoint("Custom"); + + } + + Association association = manager.lookupAssociation(endpoint); + request.getSession().setAttribute(ATTR_MAC, association.getRawMacKey()); + request.getSession().setAttribute(ATTR_ALIAS, endpoint.getAlias()); + String url = manager.getAuthenticationUrl(endpoint, association); + response.sendRedirect(url); + +} else if (request.getParameter("openid.ns")!=null && !request.getParameter("openid.ns").equals("")) { + + byte[] mac_key = (byte[]) request.getSession().getAttribute(ATTR_MAC); + String alias = (String) request.getSession().getAttribute(ATTR_ALIAS); + Authentication authentication = manager.getAuthentication(request, mac_key, alias); + String joinURL = getJoinURL(authentication.getFullname(), "Demo Meeting", null, null, null, null ); + + if (joinURL.startsWith("http://")) { +%> + +<script language="javascript" type="text/javascript"> + window.location.href="<%=joinURL%>"; +</script> + +<% + } else { +%> + +Error: getJoinURL() failed +<p/> +<%=joinURL %> + +<% + } +} +%> + + +<%@ include file="demo_footer.jsp"%> + +</body> +</html> diff --git a/bbb-api-demo/src/main/webapp/images/google.png b/bbb-api-demo/src/main/webapp/images/google.png new file mode 100644 index 0000000000000000000000000000000000000000..2bdd16251e89ed7ef4a874ff111089e456e50d07 Binary files /dev/null and b/bbb-api-demo/src/main/webapp/images/google.png differ diff --git a/bbb-api-demo/src/main/webapp/images/openid.png b/bbb-api-demo/src/main/webapp/images/openid.png new file mode 100644 index 0000000000000000000000000000000000000000..99e084db46872588d77d2e5f102f6be78947508c Binary files /dev/null and b/bbb-api-demo/src/main/webapp/images/openid.png differ diff --git a/bbb-api-demo/src/main/webapp/images/yahoo.png b/bbb-api-demo/src/main/webapp/images/yahoo.png new file mode 100644 index 0000000000000000000000000000000000000000..b42d897b9cf4682dff05c754adbd97062767bca9 Binary files /dev/null and b/bbb-api-demo/src/main/webapp/images/yahoo.png differ