Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java
===================================================================
diff -u -rdc03f6c07b7eec19f6ab1c0ebd7b1826fbea5560 -r1568156ccc545849b14864558e2c3c360a3364d2
--- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision dc03f6c07b7eec19f6ab1c0ebd7b1826fbea5560)
+++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision 1568156ccc545849b14864558e2c3c360a3364d2)
@@ -203,15 +203,16 @@
URL url = new URL(serviceURL);
URLConnection conn = url.openConnection();
if (!(conn instanceof HttpURLConnection)) {
- logger.error("Unable to open connection to: " + serviceURL);
+ throw new RuntimeException("Unable to open connection to: " + serviceURL);
}
HttpURLConnection httpConn = (HttpURLConnection) conn;
if (httpConn.getResponseCode() != HttpURLConnection.HTTP_OK) {
- logger.error("HTTP Response Code: " + httpConn.getResponseCode() + ", HTTP Response Message: "
- + httpConn.getResponseMessage());
- return "error";
+ throw new RuntimeException(
+ "Problem with getting LAMS learning designs. LAMS server responded with HTTP response code: "
+ + httpConn.getResponseCode() + ", HTTP response message: "
+ + httpConn.getResponseMessage());
}
// InputStream is = url.openConnection().getInputStream();
Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UserDataServlet.java
===================================================================
diff -u -rda77e5e81b8436a465901f033220466923e2bdc2 -r1568156ccc545849b14864558e2c3c360a3364d2
--- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UserDataServlet.java (.../UserDataServlet.java) (revision da77e5e81b8436a465901f033220466923e2bdc2)
+++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/UserDataServlet.java (.../UserDataServlet.java) (revision 1568156ccc545849b14864558e2c3c360a3364d2)
@@ -39,128 +39,99 @@
import org.apache.log4j.Logger;
import org.lamsfoundation.ld.integration.blackboard.LamsSecurityUtil;
-
/**
- * @author Anthony Xiao
+ * @author Anthony Xiao
*/
public class UserDataServlet extends HttpServlet {
-
- private static final long serialVersionUID = 2L;
- static Logger logger = Logger.getLogger(UserDataServlet.class);
-
- /**
+
+ private static final long serialVersionUID = 2L;
+ static Logger logger = Logger.getLogger(UserDataServlet.class);
+
+ /**
* The doGet method of the servlet.
- *
+ *
* This method is called when a form has its tag value method equals to get.
*
- * @param request the request send by the client to the server
- * @param response the response send by the server to the client
- * @throws ServletException if an error occurred
- * @throws IOException if an error occurred
+ * @param request
+ * the request send by the client to the server
+ * @param response
+ * the response send by the server to the client
+ * @throws ServletException
+ * if an error occurred
+ * @throws IOException
+ * if an error occurred
*/
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException{
-
- ContextManager ctxMgr = null;
-
- //get Blackboard context
- try{
- ctxMgr = (ContextManager) BbServiceManager.lookupService(ContextManager.class);
-
-
-
- //get Parameter values
- String usernameParam = request.getParameter(Constants.PARAM_USER_ID);
- String tsParam = request.getParameter(Constants.PARAM_TIMESTAMP);
- String hashParam = request.getParameter(Constants.PARAM_HASH);
-
- //check paramaeters
- if(usernameParam == null || tsParam == null || hashParam == null){
- response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "missing expected parameters");
- return;
- }
-
- String secretKey = LamsPluginUtil.getSecretKey();
- String serverId = LamsPluginUtil.getServerId();
-
- if(!sha1(tsParam.toLowerCase() + usernameParam.toLowerCase() + serverId.toLowerCase() + secretKey.toLowerCase()).equals(hashParam)){
- response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "authentication failed");
- }
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
- //get the persistence manager
- BbPersistenceManager bbPm = BbServiceManager.getPersistenceService().getDbPersistenceManager();
-
-
-
- //get user list, but no role info since there are no course info
- UserDbLoader userLoader = (UserDbLoader) bbPm.getLoader(UserDbLoader.TYPE);
- User u = userLoader.loadByUserName(usernameParam);
-
- if(u==null){
- throw new ServletException("user not found");
- }
-
-
-
- //construct the address
- String address = u.getStreet1() + (u.getStreet1().length()==0?"":" ");
- address+= u.getStreet2() + (address.length()==0?"":" ");
- address+= u.getState() + (address.length()==0?"":" ");
- address+= u.getCountry() + (address.length()==0?"":" ");
- address+= u.getZipCode();
- //String username = u.getUserName().replaceAll();
-
-
- PrintWriter out = response.getWriter();
-
- String locale = u.getLocale();
- String loc_lang=LamsSecurityUtil.getLanguage(locale);
- String loc_cntry=LamsSecurityUtil.getCountry(locale);
-
+ ContextManager ctxMgr = null;
- // The CSV list should be the format below
- //