Index: lams_bb_integration/build.xml =================================================================== diff -u -r840e92f9895380a9c595ef0c05e19e03a917b7bd -re5924606b9ac1343bde0ba579b2861858d2c03af --- lams_bb_integration/build.xml (.../build.xml) (revision 840e92f9895380a9c595ef0c05e19e03a917b7bd) +++ lams_bb_integration/build.xml (.../build.xml) (revision e5924606b9ac1343bde0ba579b2861858d2c03af) @@ -53,7 +53,6 @@ - Fisheye: Tag e5924606b9ac1343bde0ba579b2861858d2c03af 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 =================================================================== diff -u -r8af1746d179f41095b074fef269722c6689b39eb -re5924606b9ac1343bde0ba579b2861858d2c03af --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsPluginUtil.java (.../LamsPluginUtil.java) (revision 8af1746d179f41095b074fef269722c6689b39eb) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsPluginUtil.java (.../LamsPluginUtil.java) (revision e5924606b9ac1343bde0ba579b2861858d2c03af) @@ -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 =================================================================== diff -u -r840e92f9895380a9c595ef0c05e19e03a917b7bd -re5924606b9ac1343bde0ba579b2861858d2c03af --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision 840e92f9895380a9c595ef0c05e19e03a917b7bd) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision e5924606b9ac1343bde0ba579b2861858d2c03af) @@ -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 =================================================================== diff -u -r7b58fdefc5852be81e82efd574bd04e02ab5e349 -re5924606b9ac1343bde0ba579b2861858d2c03af --- lams_bb_integration/web/admin/config.jsp (.../config.jsp) (revision 7b58fdefc5852be81e82efd574bd04e02ab5e349) +++ lams_bb_integration/web/admin/config.jsp (.../config.jsp) (revision e5924606b9ac1343bde0ba579b2861858d2c03af) @@ -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 =================================================================== diff -u -r3c527d0998e4797bdfaefc359e036fa01a560ad9 -re5924606b9ac1343bde0ba579b2861858d2c03af --- lams_bb_integration/web/admin/config_proc.jsp (.../config_proc.jsp) (revision 3c527d0998e4797bdfaefc359e036fa01a560ad9) +++ lams_bb_integration/web/admin/config_proc.jsp (.../config_proc.jsp) (revision e5924606b9ac1343bde0ba579b2861858d2c03af) @@ -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