Index: lams_bb_integration/build.xml =================================================================== RCS file: /usr/local/cvsroot/lams_bb_integration/build.xml,v diff -u -r1.12 -r1.13 --- lams_bb_integration/build.xml 25 Nov 2014 23:29:56 -0000 1.12 +++ lams_bb_integration/build.xml 3 Dec 2014 20:35:43 -0000 1.13 @@ -53,7 +53,6 @@ - Fisheye: Tag 1.2 refers to a dead (removed) revision in file `lams_bb_integration/conf/main.properties'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsPluginUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/Attic/LamsPluginUtil.java,v diff -u -r1.2 -r1.3 --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsPluginUtil.java 22 Aug 2007 06:16:00 -0000 1.2 +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsPluginUtil.java 3 Dec 2014 20:35:43 -0000 1.3 @@ -22,7 +22,6 @@ */ package org.lamsfoundation.ld.integration.blackboard; - import java.util.Properties; import java.io.File; import java.io.FileInputStream; @@ -32,31 +31,28 @@ import blackboard.platform.plugin.PlugInException; import blackboard.platform.plugin.PlugInUtil; - - /** * - * This class basically manages the lams.properties file on the BB server - * This file contains the LAMS server URL, server ID and secret key - * These values allow the communication between the two servers + * This class basically manages the lams.properties file on the BB server This file contains the LAMS server URL, server + * ID and secret key These values allow the communication between the two servers * * @author Luke Foxton */ public class LamsPluginUtil { - + public static final String VENDOR_ID = "lams"; public static final String PLUGIN_HANDLE = "lamscontent"; public static final String CONTENT_HANDLE = "resource/x-lams-lamscontent"; public static final String FILE_PROPERTIES = "lams.properties"; - + public static final String PROP_LAMS_SECRET_KEY = "LAMS_SERVER_SKEY"; public static final String PROP_LAMS_SERVER_ID = "LAMS_SERVER_ID"; public static final String PROP_LAMS_URL = "LAMS_SERVER_URL"; public static final String PROP_REQ_SRC = "BB_REQ_SRC"; - + public static final String PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL = "LAMS_SERVER_TIME_REFRESH_INTERVAL"; + private static Properties lamsProperties = null; - - + /** * Returns the properties file that contains the server name, key and connection URL * @@ -66,91 +62,99 @@ * @throws IOException */ public static Properties getProperties() { - if(lamsProperties != null) - return lamsProperties; - - //load LAMS Configuration File - try{ - File configFile = new File(PlugInUtil.getConfigDirectory(VENDOR_ID, PLUGIN_HANDLE).getPath() + File.separator + FILE_PROPERTIES); - Properties p = new Properties(); - - if(configFile.exists()) - p.load(new FileInputStream(configFile)); - else{ - p.setProperty(PROP_LAMS_URL, ""); - p.setProperty(PROP_LAMS_SECRET_KEY, ""); - p.setProperty(PROP_LAMS_SERVER_ID, ""); - p.setProperty(PROP_REQ_SRC, ""); - } - - lamsProperties = p; - return p; - } catch(PlugInException e){ - throw new RuntimeException(e); - } catch(FileNotFoundException e){ - throw new RuntimeException(e); - } catch(IOException e){ - throw new RuntimeException(e); - } + if (lamsProperties != null) + return lamsProperties; + + // load LAMS Configuration File + try { + File configFile = new File(PlugInUtil.getConfigDirectory(VENDOR_ID, PLUGIN_HANDLE).getPath() + + File.separator + FILE_PROPERTIES); + Properties p = new Properties(); + + if (configFile.exists()) + p.load(new FileInputStream(configFile)); + else { + p.setProperty(PROP_LAMS_URL, ""); + p.setProperty(PROP_LAMS_SECRET_KEY, ""); + p.setProperty(PROP_LAMS_SERVER_ID, ""); + p.setProperty(PROP_REQ_SRC, ""); + p.setProperty(PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL, "24"); + } + + lamsProperties = p; + return p; + } catch (PlugInException e) { + throw new RuntimeException(e); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } } - + /** - * Save a Properties file as the LAMS properties file + * Save a Properties file as the LAMS properties file * * @param p * @throws PlugInException * @throws FileNotFoundException * @throws IOException */ public static void setProperties(Properties p) { - try{ - lamsProperties = p; - - FileOutputStream configFile = - new FileOutputStream(PlugInUtil.getConfigDirectory(VENDOR_ID, PLUGIN_HANDLE).getPath() + - File.separator + FILE_PROPERTIES); - p.store(configFile, "LAMS configuration"); - configFile.close(); - } catch(PlugInException e){ - throw new RuntimeException(e); - } catch(FileNotFoundException e){ - throw new RuntimeException(e); - } catch(IOException e){ - throw new RuntimeException(e); - } + try { + lamsProperties = p; + + FileOutputStream configFile = new FileOutputStream(PlugInUtil.getConfigDirectory(VENDOR_ID, PLUGIN_HANDLE) + .getPath() + File.separator + FILE_PROPERTIES); + p.store(configFile, "LAMS configuration"); + configFile.close(); + } catch (PlugInException e) { + throw new RuntimeException(e); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } } - + /** * * @return the secret key from lams.properties */ - public static String getSecretKey(){ - return getProperties().getProperty(PROP_LAMS_SECRET_KEY); + public static String getSecretKey() { + return getProperties().getProperty(PROP_LAMS_SECRET_KEY); } - + /** * * @return the secret url from lams.properties */ - public static String getServerUrl(){ - return getProperties().getProperty(PROP_LAMS_URL); + public static String getServerUrl() { + return getProperties().getProperty(PROP_LAMS_URL); } - + /** * * @return the server id from lams.properties */ - public static String getServerId(){ - return getProperties().getProperty(PROP_LAMS_SERVER_ID); + public static String getServerId() { + return getProperties().getProperty(PROP_LAMS_SERVER_ID); } - + /** * * @return the request source from lams.properties */ - public static String getReqSrc(){ - return getProperties().getProperty(PROP_REQ_SRC); + public static String getReqSrc() { + return getProperties().getProperty(PROP_REQ_SRC); } + /** + * + * @return the LAMS server time refresh interval from lams.properties + */ + public static String getLamsServerTimeRefreshInterval() { + return getProperties().getProperty(PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL); + } } Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/Attic/LamsSecurityUtil.java,v diff -u -r1.16 -r1.17 --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java 25 Nov 2014 23:29:56 -0000 1.16 +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java 3 Dec 2014 20:35:43 -0000 1.17 @@ -61,24 +61,6 @@ public class LamsSecurityUtil { private static Logger logger = Logger.getLogger(LamsSecurityUtil.class); - - /** - * How often it should refresh LAMS server time. Measured in hours. - */ - private static long INTERVAL; - - static { - //set default value - INTERVAL = 24; - - Properties props = new Properties(); - try { - props.load(LamsSecurityUtil.class.getResourceAsStream("/main.properties")); - INTERVAL = Long.parseLong(props.getProperty("lams.server.time.refresh.interval")); - } catch (IOException e) { - logger.error("Error loading propertis from main.properties file due to " + e.getMessage()); - } - } /** * Generates login requests to LAMS for author, monitor and learner @@ -398,7 +380,8 @@ long lastUpdateTime = (lastUpdateTimeStr == null) ? -1 : Long.parseLong(lastUpdateTimeStr); long lamsServerTime; - if ((lamsServerTimeDeltaStr == null) || (lastUpdateTime + INTERVAL * 60 * 60 * 1000 < now)) { + long lamsServerTimeRefreshInterval = getLamsServerTimeRefreshInterval() * 60 * 60 * 1000; + if ((lamsServerTimeDeltaStr == null) || (lastUpdateTime + lamsServerTimeRefreshInterval < now)) { // refresh time from LAMS server String serverAddr = getServerAddress(); @@ -491,6 +474,25 @@ public static String getReqSrc() { return LamsPluginUtil.getProperties().getProperty(LamsPluginUtil.PROP_REQ_SRC); } + + /** + * + * @return the LAMS server time refresh interval from lams.properties + */ + public static long getLamsServerTimeRefreshInterval() { + //set default value + long lamsServerTimeRefreshInterval = 24; + + try { + String lamsServerTimeRefreshIntervalStr = LamsPluginUtil.getProperties().getProperty( + LamsPluginUtil.PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL); + lamsServerTimeRefreshInterval = Long.parseLong(lamsServerTimeRefreshIntervalStr); + } catch (NumberFormatException e) { + logger.warn("Wrong format of PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL from lams.properties"); + } + + return lamsServerTimeRefreshInterval; + } // generate authentication hash code to validate parameters public static String generateAuthenticationHash(String datetime, String login, String serverId) { Index: lams_bb_integration/web/admin/config.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_bb_integration/web/admin/config.jsp,v diff -u -r1.4 -r1.5 --- lams_bb_integration/web/admin/config.jsp 26 Feb 2014 16:39:51 -0000 1.4 +++ lams_bb_integration/web/admin/config.jsp 3 Dec 2014 20:35:43 -0000 1.5 @@ -32,6 +32,7 @@ String lamsServerId = p.getProperty("LAMS_SERVER_ID", ""); String SecretKey = p.getProperty("LAMS_SERVER_SKEY", ""); String ReqSrc = p.getProperty("BB_REQ_SRC"); + String lamsServerTimeRefreshInterval = p.getProperty("LAMS_SERVER_TIME_REFRESH_INTERVAL"); //Add port to the url if the port is in the blackboard url int bbport = request.getServerPort(); @@ -67,7 +68,10 @@ -

For further information on how to configure these settings, see this tutorial.

+ + + +

For further information on how to configure these settings, see this tutorial.

Index: lams_bb_integration/web/admin/config_proc.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_bb_integration/web/admin/Attic/config_proc.jsp,v diff -u -r1.2 -r1.3 --- lams_bb_integration/web/admin/config_proc.jsp 21 Sep 2011 17:42:25 -0000 1.2 +++ lams_bb_integration/web/admin/config_proc.jsp 3 Dec 2014 20:35:43 -0000 1.3 @@ -36,12 +36,14 @@ String lamsServerSkey = request.getParameter("lams_server_skey"); String lamsServerId = request.getParameter("lams_server_id"); String bbReqSrc = request.getParameter("bb_req_src"); + String lamsServerTimeRefreshInterval = request.getParameter("lams_server_time_refresh_interval"); // Save the properties to Blackboard p.setProperty(LamsPluginUtil.PROP_LAMS_URL, lamsServerUrl); p.setProperty(LamsPluginUtil.PROP_LAMS_SECRET_KEY, lamsServerSkey); p.setProperty(LamsPluginUtil.PROP_LAMS_SERVER_ID, lamsServerId); - p.setProperty("BB_REQ_SRC", bbReqSrc); + p.setProperty(LamsPluginUtil.PROP_REQ_SRC, bbReqSrc); + p.setProperty(LamsPluginUtil.PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL, lamsServerTimeRefreshInterval); // Persist the properties object LamsPluginUtil.setProperties(p); @@ -70,6 +72,7 @@ LAMS_SERVER_SKEY: <%= lamsServerSkey %>
LAMS_SERVER_ID: <%= lamsServerId %>
BB_REQ_SRC: <%= bbReqSrc %> + LAMS_SERVER_TIME_REFRESH_INTERVAL: <%= lamsServerTimeRefreshInterval %> \ No newline at end of file