diff --git a/bbb-api-demo/src/main/webapp/demo_header.jsp b/bbb-api-demo/src/main/webapp/demo_header.jsp index c53b5688e37a9141dee03347ad4715435166e2b5..c85f7306006e8960056903adf99b39baf464f565 100755 --- a/bbb-api-demo/src/main/webapp/demo_header.jsp +++ b/bbb-api-demo/src/main/webapp/demo_header.jsp @@ -20,4 +20,6 @@ <a href="demo_openid.jsp">Login with Openid</a> <a href="demo11.jsp">Javascript API</a> + +<a href="mobile.jsp">Mobile Demo</a>   diff --git a/bbb-api-demo/src/main/webapp/mobile.jsp b/bbb-api-demo/src/main/webapp/mobile.jsp old mode 100644 new mode 100755 index 036abebe4b0512e3f77682b048df14580c89e010..9c45ba2e3d250328187acaacb0dc1e459bde4535 --- a/bbb-api-demo/src/main/webapp/mobile.jsp +++ b/bbb-api-demo/src/main/webapp/mobile.jsp @@ -1,51 +1,119 @@ -<% -/* - BigBlueButton - http://www.bigbluebutton.org - - Copyright (c) 2011 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: Felipe Cecagno <fcecagno@gmail.com> -*/ -%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<!-- + +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: Chad Pilkey <capilkey@gmail.org> + +--> + +<%@ 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 From Mobile</title> +</head> + +<body> + +<%@ include file="bbb_api.jsp"%> + +<% +if (request.getParameterMap().isEmpty()) { + // + // Assume we want to create a meeting + // + %> +<%@ include file="demo_header.jsp"%> + +<h2>Join Demo Meeting From Mobile</h2> -<%@page import="org.apache.commons.httpclient.HttpClient"%> -<%@page import="org.apache.commons.httpclient.HttpMethod"%> -<%@page import="org.apache.commons.httpclient.methods.GetMethod"%> +You must have the BigBlueButton mobile client installed on your device for this demo to work. +<br /><br /> +<FORM NAME="form1" METHOD="GET"> +<table cellpadding="5" cellspacing="5" style="width: 400px; "> + <tbody> + <tr> + <td> + </td> + <td style="text-align: right; "> + Full Name:</td> + <td style="width: 5px; "> + </td> + <td style="text-align: left "> + <input type="text" autofocus required name="username" /></td> + </tr> + <tr> + <td> + </td> + <td> + </td> + <td> + </td> + <td> + <input type="submit" value="Join" /></td> + </tr> + </tbody> +</table> +<INPUT TYPE=hidden NAME=action VALUE="create"> +</FORM> -<%@ include file="mobile_api.jsp"%> <% - String result = error(E_INVALID_URL); - if (request.getParameterMap().isEmpty()) { - result = success("mobileSupported", "This server supports mobile devices."); - } else if (request.getParameter("action") == null) { - // return the default result - } else if (request.getParameter("action").equals("getTimestamp")) { - result = getTimestamp(request); - } else if (request.getParameter("action").equals("getMeetings")) { - result = mobileGetMeetings(request); - } else if (request.getParameter("action").equals("join")) { - result = mobileJoinMeeting(request); - } else if (request.getParameter("action").equals("create")) { - result = mobileCreate(request); +} else if (request.getParameter("action").equals("create")) { + + // + // Got an action=create + // + + String username = request.getParameter("username"); + String url = BigBlueButtonURL.replace("bigbluebutton/","demo/"); + // String preUploadPDF = "<?xml version='1.0' encoding='UTF-8'?><modules><module name='presentation'><document url='"+url+"pdfs/sample.pdf'/></module></modules>"; + + String joinURL = getJoinURL(request.getParameter("username"), "Demo Meeting", "false", null, null, null); + + if (joinURL.startsWith("http://")) { + joinURL = joinURL.replace("http", "bigbluebutton"); +%> + +<script language="javascript" type="text/javascript"> + window.location.href="<%=joinURL%>"; +</script> + +<% + } else { +%> + +Error: getJoinURL() failed +<p/> +<%=joinURL %> + +<% } +} %> -<%=result%> + + +<%@ include file="demo_footer.jsp"%> + +</body> +</html> diff --git a/bbb-api-demo/src/main/webapp/mobile_api.jsp b/bbb-api-demo/src/main/webapp/mobile_api.jsp deleted file mode 100644 index 9dfabc81923f39c02ba6c6a52576dc1033678e6a..0000000000000000000000000000000000000000 --- a/bbb-api-demo/src/main/webapp/mobile_api.jsp +++ /dev/null @@ -1,182 +0,0 @@ -<% -/* - BigBlueButton - http://www.bigbluebutton.org - - Copyright (c) 2011 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: Felipe Cecagno <fcecagno@gmail.com> -*/ -%> -<%@ include file="bbb_api.jsp"%> -<%@ include file="mobile_conf.jsp"%> - -<%@page import="org.apache.commons.httpclient.HttpClient"%> -<%@page import="org.apache.commons.httpclient.HttpMethod"%> -<%@page import="org.apache.commons.httpclient.methods.GetMethod"%> - -<%! - public final int E_OK = 0; - public final int E_CHECKSUM_NOT_INFORMED = 1; - public final int E_INVALID_CHECKSUM = 2; - public final int E_INVALID_TIMESTAMP = 3; - public final int E_EMPTY_SECURITY_KEY = 4; - public final int E_MISSING_PARAM_MEETINGID = 5; - public final int E_MISSING_PARAM_FULLNAME = 6; - public final int E_MISSING_PARAM_PASSWORD = 7; - public final int E_MISSING_PARAM_TIMESTAMP = 8; - public final int E_INVALID_URL = 9; - - public String error(int code) { - switch(code) { - case E_CHECKSUM_NOT_INFORMED: - case E_INVALID_CHECKSUM: - return error("checksumError", "You did not pass the checksum security check."); - case E_INVALID_TIMESTAMP: - return error("invalidTimestamp", "You did not pass the timestamp check."); - case E_EMPTY_SECURITY_KEY: - return error("emptySecurityKey", "The mobile security key is empty. Please contact the administrator."); - case E_MISSING_PARAM_MEETINGID: - return error("missingParamMeetingID", "You must specify a meeting ID for the meeting."); - case E_MISSING_PARAM_FULLNAME: - return error("missingParamFullName", "You must specify a name for the attendee who will be joining the meeting."); - case E_MISSING_PARAM_PASSWORD: - return error("invalidPassword", "You either did not supply a password or the password supplied is neither the attendee or moderator password for this conference."); - case E_MISSING_PARAM_TIMESTAMP: - return error("missingParamTimestamp", "You must specify the timestamp provided by the server when you called the method getTimestamp."); - case E_INVALID_URL: - return error("invalidAction", "The requested URL is unavailable."); - default: - return error("unknownError", "An unexpected error occurred"); - } - } - - private String getRequestURL(HttpServletRequest request) { - return request.getQueryString(); - } - - private String removeChecksum(String requestURL) { - return requestURL.substring(0, requestURL.lastIndexOf("&checksum=")); - } - - private String addValidChecksum(String requestURL) { - return requestURL + "&checksum=" + checksum(requestURL + mobileSalt); - } - - private int isRequestValid(HttpServletRequest request) { - // if there's no checksum parameter, the request isn't valid - if (request.getParameter("checksum") == null) - return E_CHECKSUM_NOT_INFORMED; - - // check the timestamp for all the requests except getTimestamp - if (!request.getParameter("action").equals("getTimestamp")) { - String requestTimestamp = request.getParameter("timestamp"); - if (requestTimestamp == null) - return E_MISSING_PARAM_TIMESTAMP; - - Long requestTimestampL = Long.valueOf(requestTimestamp); - // the timestamp is valid for 60 seconds - if (Math.abs(getTimestamp() - requestTimestampL) > 60) - return E_INVALID_TIMESTAMP; - } - - if (mobileSalt.isEmpty()) - return E_EMPTY_SECURITY_KEY; - - String requestURL = getRequestURL(request); - String urlWithoutChecksum = removeChecksum(requestURL); - String urlWithChecksum = addValidChecksum(urlWithoutChecksum); - return (requestURL.equals(urlWithChecksum)? E_OK: E_INVALID_CHECKSUM); - } - - private String mountResponse(String returncode, String messageKey, String message) { - return "<response><returncode>" + returncode + "</returncode><messageKey>" + messageKey + "</messageKey><message>" + message + "</message></response>"; - } - - public String success(String messageKey, String message) { - return mountResponse("SUCCESS", messageKey, message); - } - - public String error(String messageKey, String message) { - return mountResponse("FAILED", messageKey, message); - } - - private long getTimestamp() { - return (System.currentTimeMillis() / 1000L); - } - - public String getTimestamp(HttpServletRequest request) { - int code = isRequestValid(request); - if (code != E_OK) - return error(code); - - return "<response><returncode>SUCCESS</returncode><timestamp>" + getTimestamp() + "</timestamp></response>"; - } - - public String mobileGetMeetings(HttpServletRequest request) { - int code = isRequestValid(request); - if (code != E_OK) - return error(code); - - return getMeetings(); - } - - public String mobileJoinMeeting(HttpServletRequest request) { - int code = isRequestValid(request); - if (code != E_OK) - return error(code); - - String meetingID = request.getParameter("meetingID"); - if (meetingID == null) return error(E_MISSING_PARAM_MEETINGID); - - String fullName = request.getParameter("fullName"); - if (fullName == null) return error(E_MISSING_PARAM_FULLNAME); - - String password = request.getParameter("password"); - if (password == null) return error(E_MISSING_PARAM_PASSWORD); - - String result = error("failedJoin", "Couldn't join the meeting."); - String joinUrl = getJoinMeetingURL(fullName, meetingID, password, null); - String enterUrl = BigBlueButtonURL + "api/enter"; - try { - HttpClient client = new HttpClient(); - HttpMethod method = new GetMethod(joinUrl); - client.executeMethod(method); - method.releaseConnection(); - - method = new GetMethod(enterUrl); - client.executeMethod(method); - result = method.getResponseBodyAsString(); - method.releaseConnection(); - } catch (Exception e) { - } - return result; - } - - public String mobileCreate(HttpServletRequest request) { - int code = isRequestValid(request); - if (code != E_OK) - return error(code); - - String meetingID = request.getParameter("meetingID"); - if (meetingID == null) return error(E_MISSING_PARAM_MEETINGID); - - return createMeeting(meetingID, "", "", "", "", 0, BigBlueButtonURL); - } - - // it's just for testing purposes - private String fixURL(HttpServletRequest request) { - return addValidChecksum(removeChecksum(getRequestURL(request))); - } -%> diff --git a/bbb-api-demo/src/main/webapp/mobile_conf.jsp b/bbb-api-demo/src/main/webapp/mobile_conf.jsp deleted file mode 100644 index 7ee04df0ee0662ce81b542d644fb3316d010c0c2..0000000000000000000000000000000000000000 --- a/bbb-api-demo/src/main/webapp/mobile_conf.jsp +++ /dev/null @@ -1,6 +0,0 @@ - -<%! -// This is the mobile security salt that must be used to check the requests on mobile.jsp -String mobileSalt = ""; -%> -