diff --git a/bbb-api-demo/README b/bbb-api-demo/README new file mode 100644 index 0000000000000000000000000000000000000000..13c8b6f2174761a9a8c8450025c5007ab282317e --- /dev/null +++ b/bbb-api-demo/README @@ -0,0 +1,9 @@ +15-6-2011 +bbb_api.jsp from bigbluebutton-web is different to the one in for bbb-api-demo + +The method joinurl inside bbb_api.jsp has 3(bbb-api-demo version) or 5(bigbluebutton-web) parameters + +Now I am using the one in bbb-api-demo + +demo1.jsp demo2.jsp create.jsp and demo6 are affected and does not work + diff --git a/bbb-api-demo/build.gradle b/bbb-api-demo/build.gradle index 81aac9ddbfac2c9ee8c5cfff23521aa3db42857a..5a00d19f7203851a961531b6a40b17898fb514bd 100755 --- a/bbb-api-demo/build.gradle +++ b/bbb-api-demo/build.gradle @@ -1,5 +1,6 @@ //usePlugin 'war' usePlugin 'jetty' +version = '0.8' repositories { mavenCentral() @@ -9,6 +10,11 @@ task resolveDeps(dependsOn: configurations.default.buildArtifacts, type: Copy) { from configurations.default from configurations.default.allArtifacts*.file } + +war { + baseName = 'demotest' // leads to mywar-0.9.war + version = '' +} dependencies { // classpath group: 'org.apache.commons', name: 'commons-codec', version: '2.0' // classpath group: 'org.apache.commons', name: 'commons-fileupload', version: '2.0' diff --git a/bbb-api-demo/src/main/webapp/api-demo/demo_header.jsp b/bbb-api-demo/src/main/webapp/api-demo/demo_header.jsp deleted file mode 100755 index b5f3b61f3d210d786baf122d07e3d4f72fc08f19..0000000000000000000000000000000000000000 --- a/bbb-api-demo/src/main/webapp/api-demo/demo_header.jsp +++ /dev/null @@ -1 +0,0 @@ -<img src="/bigbluebutton/images/bbb_banner.jpg" /><br><a href="demo5.jsp">Auto Upload File</a> | <a href="demo6.jsp">Auto Upload File URL</a> diff --git a/bbb-api-demo/src/main/webapp/bbb-web/bbb_api.jsp b/bbb-api-demo/src/main/webapp/bbb-web/bbb_api.jsp deleted file mode 100644 index 3b318275be1dd1b978c77ace3b5c56941f70a317..0000000000000000000000000000000000000000 --- a/bbb-api-demo/src/main/webapp/bbb-web/bbb_api.jsp +++ /dev/null @@ -1,448 +0,0 @@ -<% -/* - 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: Fred Dixon <ffdixon@bigbluebutton.org> -*/ -%> -<%@page import="javax.xml.transform.dom.DOMSource"%> -<%@page import="javax.xml.transform.stream.StreamResult"%> -<%@page import="javax.xml.transform.OutputKeys"%> -<%@page import="javax.xml.transform.TransformerFactory"%> -<%@page import="javax.xml.transform.Transformer"%> -<%@page import="org.w3c.dom.Element"%> -<%@page import="com.sun.org.apache.xerces.internal.dom.ChildNode"%> -<%@page import="org.w3c.dom.Node"%> -<%@page import="org.w3c.dom.NodeList"%> - -<%@ page - import="java.util.*,java.io.*,java.net.*,javax.crypto.*,javax.xml.parsers.*,org.w3c.dom.Document,org.xml.sax.*" - errorPage="error.jsp" %> - -<%@ page import="org.apache.commons.codec.digest.*"%> -<%@ include file="bbb_api_conf.jsp"%> - -<%! - -// -// Create a meeting with specific -// - meetingID -// - welcome message -// - moderator password -// - viewer password -// - voiceBridge -// - logoutURL -// -public String createMeeting(String meetingID, String welcome, String moderatorPassword, String viewerPassword, Integer voiceBridge, String logoutURL) { - String base_url_create = BigBlueButtonURL + "api/create?"; - String base_url_join = BigBlueButtonURL + "api/join?"; - - String welcome_param = ""; - String checksum = ""; - - String attendee_password_param = "&attendeePW=ap"; - String moderator_password_param = "&moderatorPW=mp"; - String voice_bridge_param = ""; - String logoutURL_param = ""; - - if ( (welcome != null) && ! welcome.equals("")) { - welcome_param = "&welcome=" + urlEncode(welcome); - } - - if ( (moderatorPassword != null) && ! moderatorPassword.equals("")) { - moderator_password_param = "&moderatorPW=" + urlEncode(moderatorPassword); - } - - if ( (viewerPassword != null) && ! viewerPassword.equals("")) { - attendee_password_param = "&attendeePW=" + urlEncode(viewerPassword); - } - - if ( (voiceBridge != null) && voiceBridge > 0 ) { - voice_bridge_param = "&voiceBridge=" + urlEncode(voiceBridge.toString()); - } else { - // No voice bridge number passed, so we'll generate a random one for this meeting - Random random = new Random(); - Integer n = 70000 + random.nextInt(9999); - voice_bridge_param = "&voiceBridge=" + n; - } - - if ( (logoutURL != null) && ! logoutURL.equals("")) { - logoutURL_param = "&logoutURL=" + urlEncode(logoutURL); - } - - // - // Now create the URL - // - - String create_parameters = "name=" + urlEncode(meetingID) + "&meetingID=" + urlEncode(meetingID) - + welcome_param + attendee_password_param + moderator_password_param - + voice_bridge_param + logoutURL_param; - - Document doc = null; - - try { - // Attempt to create a meeting using meetingID - String xml = getURL(base_url_create + create_parameters + "&checksum=" + checksum("create" + create_parameters + salt) ); - doc = parseXml(xml); - } catch (Exception e) { - e.printStackTrace(); - } - - if (doc.getElementsByTagName("returncode").item(0).getTextContent() - .trim().equals("SUCCESS")) { - - - return meetingID; - } - - return "Error " + doc.getElementsByTagName("messageKey").item(0).getTextContent().trim() - + ": " + doc.getElementsByTagName("message").item(0).getTextContent().trim(); -} - - - -// -// getJoinMeetingURL() -- get join meeting URL for both viewer and moderator -// -public String getJoinMeetingURL(String username, String meetingID, String password) { - String base_url_join = BigBlueButtonURL + "api/join?"; - String join_parameters = "meetingID=" + urlEncode(meetingID) + "&fullName=" + urlEncode(username) - + "&password=" + urlEncode(password); - - return base_url_join + join_parameters + "&checksum=" + checksum("join" + join_parameters + salt); -} - - - -// -// Create a meeting and return a URL to join it as moderator -// -public String getJoinURL(String username, String meetingID, String record, String welcome, Map<String, String> metadata) { - String base_url_create = BigBlueButtonURL + "api/create?"; - String base_url_join = BigBlueButtonURL + "api/join?"; - - String welcome_param = ""; - - Random random = new Random(); - Integer voiceBridge = 70000 + random.nextInt(9999); - - if ( (welcome != null) && ! welcome.equals("")) { - welcome_param = "&welcome=" + urlEncode(welcome); - } - - // - // When creating a meeting, the 'name' parameter is the name of the meeting (not to be confused with - // the username). For example, the name could be "Fred's meeting" and the meetingID could be "ID-1234312". - // - // While name and meetinID could be different, we'll keep them the same. Why? Because calling api/create? - // with a previously used meetingID will return same meetingToken (regardless if the meeting is running or not). - // - // This means the first person to call getJoinURL with meetingID="Demo Meeting" will actually create the - // meeting. Subsequent calls will return the same meetingToken and thus subsequent users will join the same - // meeting. - // - // Note: We're hard-coding the password for moderator and attendee (viewer) for purposes of demo. - // - - String create_parameters = "name=" + urlEncode(meetingID) + "&meetingID=" + urlEncode(meetingID) - + welcome_param + "&attendeePW=ap&moderatorPW=mp&voiceBridge=" - + voiceBridge + "&record=" + record; - - if(metadata!=null){ - String metadata_params=""; - for(String metakey : metadata.keySet()){ - metadata_params = metadata_params + "&meta_" + urlEncode(metakey) + "=" + urlEncode(metadata.get(metakey)); - } - create_parameters = create_parameters + metadata_params; - } - - Document doc = null; - - try { - // Attempt to create a meeting using meetingID - String xml = getURL(base_url_create + create_parameters + "&checksum=" + checksum("create" + create_parameters + salt) ); - doc = parseXml(xml); - } catch (Exception e) { - e.printStackTrace(); - } - - if (doc.getElementsByTagName("returncode").item(0).getTextContent() - .trim().equals("SUCCESS")) { - - - // - // Now create a URL to join that meeting - // - - String join_parameters = "meetingID=" + urlEncode(meetingID) + "&fullName=" + urlEncode(username) + "&password=mp"; - - return base_url_join + join_parameters + "&checksum=" + checksum("join" + join_parameters + salt); - - } - return doc.getElementsByTagName("messageKey").item(0).getTextContent().trim() - + ": " + doc.getElementsByTagName("message").item(0).getTextContent().trim(); -} - - -// -// getJoinURLViewer() -- Get the URL to join a meeting as viewer -// -public String getJoinURLViewer(String username, String meetingID) { - - String base_url_join = BigBlueButtonURL + "api/join?"; - String join_parameters = "meetingID=" + urlEncode(meetingID) + "&fullName=" + urlEncode(username) - + "&password=ap"; - - return base_url_join + join_parameters + "&checksum=" + checksum("join" + join_parameters + salt); -} - - - -// -// checksum() -- create a hash based on the shared salt (located in bbb_api_conf.jsp) -// -public static String checksum(String s) { - String checksum = ""; - try { - checksum = org.apache.commons.codec.digest.DigestUtils.shaHex(s); - } catch (Exception e) { - e.printStackTrace(); - } - return checksum; -} - -// -// getURL() -- fetch a URL and return its contents as a String -// -public static String getURL(String url) { - StringBuffer response = null; - - try { - URL u = new URL(url); - HttpURLConnection httpConnection = (HttpURLConnection) u - .openConnection(); - - httpConnection.setUseCaches(false); - httpConnection.setDoOutput(true); - httpConnection.setRequestMethod("GET"); - - httpConnection.connect(); - int responseCode = httpConnection.getResponseCode(); - if (responseCode == HttpURLConnection.HTTP_OK) { - InputStream input = httpConnection.getInputStream(); - - // Read server's response. - response = new StringBuffer(); - Reader reader = new InputStreamReader(input, "UTF-8"); - reader = new BufferedReader(reader); - char[] buffer = new char[1024]; - for (int n = 0; n >= 0;) { - n = reader.read(buffer, 0, buffer.length); - if (n > 0) - response.append(buffer, 0, n); - } - - input.close(); - httpConnection.disconnect(); - } - } catch (Exception e) { - e.printStackTrace(); - } - - if (response != null) { - return response.toString(); - } else { - return ""; - } -} - -// -// getURLisMeetingRunning() -- return a URL that the client can use to poll for whether the given meeting is running -// -public String getURLisMeetingRunning(String meetingID) { - String base_main = "&meetingID=" + urlEncode(meetingID); - String base_url = BigBlueButtonURL + "api/isMeetingRunning?"; - String checksum =""; - - try { - checksum = DigestUtils.shaHex("isMeetingRunning" + base_main + salt); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return base_url + base_main + "&checksum=" + checksum; -} - -// -// isMeetingRunning() -- check the BigBlueButton server to see if the meeting is running (i.e. there is someone in the meeting) -// -public String isMeetingRunning(String meetingID) { - String base_main = "&meetingID=" + urlEncode(meetingID); - String base_url = BigBlueButtonURL + "api/isMeetingRunning?"; - String checksum =""; - - try { - checksum = DigestUtils.shaHex("isMeetingRunning" + base_main + salt); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - String xml = getURL(base_url + base_main + "&checksum=" + checksum); - - Document doc = null; - try { - doc = parseXml(xml); - } catch (Exception e) { - e.printStackTrace(); - } - - if (doc.getElementsByTagName("returncode").item(0).getTextContent() - .trim().equals("SUCCESS")) { - return doc.getElementsByTagName("running").item(0).getTextContent().trim(); - } - - return "false"; - -} - -public String getMeetingInfoURL(String meetingID, String password) { - String meetingParameters = "meetingID=" + urlEncode(meetingID) + "&password=" + password; - return BigBlueButtonURL + "api/getMeetingInfo?" + meetingParameters + "&checksum=" + checksum("getMeetingInfo" + meetingParameters + salt); -} - -public String getMeetingInfo(String meetingID, String password) { - try { - URLConnection hpCon = new URL(getMeetingInfoURL(meetingID, password)).openConnection(); - - InputStreamReader isr = new InputStreamReader(hpCon.getInputStream()); - BufferedReader br = new BufferedReader(isr); - String data = br.readLine(); - return data; - } catch (Exception e) { - e.printStackTrace(System.out); - return ""; - } -} - -public String getMeetingsURL() { - String meetingParameters = "random=" + new Random().nextInt(9999); - return BigBlueButtonURL + "api/getMeetings?" + meetingParameters + "&checksum=" + checksum("getMeetings" + meetingParameters + salt); -} - -// -// Calls getMeetings to obtain the list of meetings, then calls getMeetingInfo for each meeting -// and concatenates the result. -// -public String getMeetings() { - try { - - // Call the API and get the result - URLConnection hpCon = new URL(getMeetingsURL()).openConnection(); - InputStreamReader isr = new InputStreamReader(hpCon.getInputStream()); - BufferedReader br = new BufferedReader(isr); - String data = br.readLine(); - Document doc = parseXml(data); - - // tags needed for parsing xml documents - final String startTag = "<meetings>"; - final String endTag = "</meetings>"; - final String startResponse = "<response>"; - final String endResponse = "</response>"; - - // if the request succeeded, then calculate the checksum of each meeting and insert it into the document - NodeList meetingsList = doc.getElementsByTagName("meeting"); - - String newXMldocument = startTag; - for (int i = 0; i < meetingsList.getLength(); i++) { - Element meeting = (Element) meetingsList.item(i); - String meetingID = meeting.getElementsByTagName("meetingID").item(0).getTextContent(); - String password = meeting.getElementsByTagName("moderatorPW").item(0).getTextContent(); - - data = getMeetingInfo(meetingID, password); - - if (data.indexOf("<response>") != -1) { - int startIndex = data.indexOf(startResponse) + startTag.length(); - int endIndex = data.indexOf(endResponse); - newXMldocument += "<meeting>" + data.substring(startIndex, endIndex) + "</meeting>"; - } - } - newXMldocument += endTag; - - return newXMldocument; - } catch (Exception e) { - e.printStackTrace(System.out); - return null; - } -} - -// -public String endMeeting(String meetingID, String moderatorPassword) { - - String base_main = "meetingID=" + urlEncode(meetingID) + "&password=" + urlEncode(moderatorPassword); - String base_url = BigBlueButtonURL + "api/end?"; - String checksum =""; - - try { - checksum = DigestUtils.shaHex("end" + base_main + salt); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - String xml = getURL(base_url + base_main + "&checksum=" + checksum); - - Document doc = null; - try { - doc = parseXml(xml); - } catch (Exception e) { - e.printStackTrace(); - } - - if (doc.getElementsByTagName("returncode").item(0).getTextContent() - .trim().equals("SUCCESS")) { - return "true"; - } - - return "Error " + doc.getElementsByTagName("messageKey").item(0).getTextContent().trim() - + ": " + doc.getElementsByTagName("message").item(0).getTextContent().trim(); - -} - -// -// parseXml() -- return a DOM of the XML -// -public static Document parseXml(String xml) throws ParserConfigurationException, IOException, SAXException { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - Document doc = docBuilder.parse(new InputSource(new StringReader(xml))); - return doc; -} - -// -// urlEncode() -- URL encode the string -// -public static String urlEncode(String s) { - try { - return URLEncoder.encode(s, "UTF-8"); - } catch (Exception e) { - e.printStackTrace(); - } - return ""; -} -%> diff --git a/bbb-api-demo/src/main/webapp/bbb-web/demo_header.jsp b/bbb-api-demo/src/main/webapp/bbb-web/demo_header.jsp deleted file mode 100755 index de34d864268b71224952999838cfc0a1b617dc13..0000000000000000000000000000000000000000 --- a/bbb-api-demo/src/main/webapp/bbb-web/demo_header.jsp +++ /dev/null @@ -1 +0,0 @@ -<img src="/bigbluebutton/images/bbb_banner.jpg" /><br><a href="demo1.jsp">Join a Course</a> | <a href="demo2.jsp">Join a Selected Course</a> | <a href="demo3.jsp">Join a Course (password required)</a> | <a href="demo4.jsp">Activity Monitor</a> | <a href="create.jsp">Create Your Own Meeting</a> | <a href="demo6.jsp">Record Meeting</a> diff --git a/bbb-api-demo/src/main/webapp/api-demo/bbb_api.jsp b/bbb-api-demo/src/main/webapp/bbb_api.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/api-demo/bbb_api.jsp rename to bbb-api-demo/src/main/webapp/bbb_api.jsp diff --git a/bbb-api-demo/src/main/webapp/bbb_api_conf.jsp b/bbb-api-demo/src/main/webapp/bbb_api_conf.jsp new file mode 100755 index 0000000000000000000000000000000000000000..9636297e0ed038fce2316a7d99b044dc8c3f4956 --- /dev/null +++ b/bbb-api-demo/src/main/webapp/bbb_api_conf.jsp @@ -0,0 +1,14 @@ + +<%! +// This is the security salt that must match the value set in the BigBlueButton server +//String salt = "4951c2aea43e5af6d9598610b9e0b6c7"; +//String salt = "5e5ff0968546b8aaacce0462a99bca30"; +String salt = "5e5ff0968546b8aaacce0462a99bca30"; +// This is the URL for the BigBlueButton server 4951c2aea43e5af6d9598610b9e0b6c7 +String BigBlueButtonURL = "http://192.168.1.42/bigbluebutton/"; +%> + + + + + diff --git a/bbb-api-demo/src/main/webapp/bbb-web/create.jsp b/bbb-api-demo/src/main/webapp/create.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/bbb-web/create.jsp rename to bbb-api-demo/src/main/webapp/create.jsp diff --git a/bbb-api-demo/src/main/webapp/bbb-web/demo1.jsp b/bbb-api-demo/src/main/webapp/demo1.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/bbb-web/demo1.jsp rename to bbb-api-demo/src/main/webapp/demo1.jsp diff --git a/bbb-api-demo/src/main/webapp/bbb-web/demo2.jsp b/bbb-api-demo/src/main/webapp/demo2.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/bbb-web/demo2.jsp rename to bbb-api-demo/src/main/webapp/demo2.jsp diff --git a/bbb-api-demo/src/main/webapp/bbb-web/demo3.jsp b/bbb-api-demo/src/main/webapp/demo3.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/bbb-web/demo3.jsp rename to bbb-api-demo/src/main/webapp/demo3.jsp diff --git a/bbb-api-demo/src/main/webapp/bbb-web/demo4.jsp b/bbb-api-demo/src/main/webapp/demo4.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/bbb-web/demo4.jsp rename to bbb-api-demo/src/main/webapp/demo4.jsp diff --git a/bbb-api-demo/src/main/webapp/bbb-web/demo4_helper.jsp b/bbb-api-demo/src/main/webapp/demo4_helper.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/bbb-web/demo4_helper.jsp rename to bbb-api-demo/src/main/webapp/demo4_helper.jsp diff --git a/bbb-api-demo/src/main/webapp/bbb-web/demo5.jsp b/bbb-api-demo/src/main/webapp/demo5.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/bbb-web/demo5.jsp rename to bbb-api-demo/src/main/webapp/demo5.jsp diff --git a/bbb-api-demo/src/main/webapp/bbb-web/demo6.jsp b/bbb-api-demo/src/main/webapp/demo6.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/bbb-web/demo6.jsp rename to bbb-api-demo/src/main/webapp/demo6.jsp diff --git a/bbb-api-demo/src/main/webapp/api-demo/demo5.jsp b/bbb-api-demo/src/main/webapp/demo7.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/api-demo/demo5.jsp rename to bbb-api-demo/src/main/webapp/demo7.jsp diff --git a/bbb-api-demo/src/main/webapp/api-demo/demo6.jsp b/bbb-api-demo/src/main/webapp/demo8.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/api-demo/demo6.jsp rename to bbb-api-demo/src/main/webapp/demo8.jsp diff --git a/bbb-api-demo/src/main/webapp/bbb-web/demo_footer.jsp b/bbb-api-demo/src/main/webapp/demo_footer.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/bbb-web/demo_footer.jsp rename to bbb-api-demo/src/main/webapp/demo_footer.jsp diff --git a/bbb-api-demo/src/main/webapp/demo_header.jsp b/bbb-api-demo/src/main/webapp/demo_header.jsp new file mode 100755 index 0000000000000000000000000000000000000000..fc37d010e5bb3e838ba7f9b74ee6ab4366b2d402 --- /dev/null +++ b/bbb-api-demo/src/main/webapp/demo_header.jsp @@ -0,0 +1,10 @@ +<img src="/bigbluebutton/images/bbb_banner.jpg" /><br> +<a href="demo1.jsp">Join a Course</a> | + <a href="demo2.jsp">Join a Selected Course</a> | +<a href="demo3.jsp">Join a Course (password required)</a> | +<a href="demo4.jsp">Activity Monitor</a> | +<a href="create.jsp">Create Your Own Meeting</a> | +<a href="demo6.jsp">Record Meeting</a> | +<a href="demo7.jsp">Auto Upload File</a> | +<a href="demo8.jsp">Auto Upload File URL</a> + diff --git a/bbb-api-demo/src/main/webapp/bbb-web/error.jsp b/bbb-api-demo/src/main/webapp/error.jsp similarity index 100% rename from bbb-api-demo/src/main/webapp/bbb-web/error.jsp rename to bbb-api-demo/src/main/webapp/error.jsp diff --git a/bbb-api-demo/src/main/webapp/index.jsp b/bbb-api-demo/src/main/webapp/index.jsp deleted file mode 100644 index c38169bb958579c635a5c09ee2f379cc5956c0c2..0000000000000000000000000000000000000000 --- a/bbb-api-demo/src/main/webapp/index.jsp +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> -<h2>Hello World!</h2> -</body> -</html>