From 8af37e6243106dc227a03181a3e10f0d06dda582 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Tue, 10 Mar 2009 15:24:48 +0000 Subject: [PATCH] Merged V3.1 to HEAD 13003: Fix for ETHREEOH-1241. Improved debug logging also. 13027: Fix for build failure - OKed solution from Dave/Andy git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13533 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web-scripts-application-context.xml | 4 +- .../web/scripts/bean/AbstractLoginBean.java | 8 ++-- .../alfresco/repo/web/scripts/bean/Login.java | 3 +- .../repo/web/scripts/bean/LoginPost.java | 39 +++++++++---------- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml index 1cc9f24ccf..d7b118d31e 100644 --- a/config/alfresco/web-scripts-application-context.xml +++ b/config/alfresco/web-scripts-application-context.xml @@ -188,11 +188,11 @@ - + - + diff --git a/source/java/org/alfresco/repo/web/scripts/bean/AbstractLoginBean.java b/source/java/org/alfresco/repo/web/scripts/bean/AbstractLoginBean.java index 11d063c069..fcf4e28454 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/AbstractLoginBean.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/AbstractLoginBean.java @@ -30,6 +30,7 @@ import java.util.Map; import javax.servlet.http.HttpServletResponse; import org.alfresco.repo.security.authentication.AuthenticationException; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.web.scripts.DeclarativeWebScript; import org.alfresco.web.scripts.Status; @@ -38,7 +39,7 @@ import org.alfresco.web.scripts.WebScriptRequest; /** - * common code between Get based login and POST based login + * Common code between Get based login and POST based login */ /* package scope */ abstract class AbstractLoginBean extends DeclarativeWebScript { @@ -65,7 +66,6 @@ import org.alfresco.web.scripts.WebScriptRequest; protected Map login(String username, String password) { - try { // get ticket @@ -82,7 +82,7 @@ import org.alfresco.web.scripts.WebScriptRequest; } finally { - authenticationService.clearCurrentSecurityContext(); + AuthenticationUtil.clearCurrentSecurityContext(); } } -} +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/web/scripts/bean/Login.java b/source/java/org/alfresco/repo/web/scripts/bean/Login.java index e4ab427ee4..678532d069 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/Login.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/Login.java @@ -63,5 +63,4 @@ public class Login extends AbstractLoginBean return login(username, password); } - -} +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/web/scripts/bean/LoginPost.java b/source/java/org/alfresco/repo/web/scripts/bean/LoginPost.java index f6fe863061..d9336235e8 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/LoginPost.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/LoginPost.java @@ -41,11 +41,9 @@ import org.json.JSONObject; /** * Post based login script - * */ public class LoginPost extends AbstractLoginBean { - /* (non-Javadoc) * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse) */ @@ -55,30 +53,31 @@ public class LoginPost extends AbstractLoginBean Content c = req.getContent(); if (c == null) { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Missing POST body."); + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Missing POST body."); } + // TODO accept xml type. // extract username and password from JSON object JSONObject json; - try { - json = new JSONObject(c.getContent()); - String username = json.getString("username"); - String password = json.getString("password"); - - if (username == null || username.length() == 0) - { - throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Username not specified"); - } + try + { + json = new JSONObject(c.getContent()); + String username = json.getString("username"); + String password = json.getString("password"); - if (password == null) - { - throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Password not specified"); - } + if (username == null || username.length() == 0) + { + throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Username not specified"); + } - return login(username, password); - } + if (password == null) + { + throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Password not specified"); + } + + return login(username, password); + } catch (JSONException jErr) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, @@ -90,4 +89,4 @@ public class LoginPost extends AbstractLoginBean "Unable to retrieve POST body: " + ioErr.getMessage()); } } -} +} \ No newline at end of file