APIAuthenticator: refactor signature of APIAuthenticator interface's authenticate
Pass HttpServletResponse as it can be useful for authenticators which need to have their own writer interface/method Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/224dc9f8 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/224dc9f8 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/224dc9f8 Branch: refs/heads/master Commit: 224dc9f8e548c222baff92db8b352af46c495ac2 Parents: 6ec1a1b Author: Rohit Yadav <rohit.ya...@shapeblue.com> Authored: Tue Aug 12 09:15:24 2014 +0200 Committer: Rohit Yadav <rohit.ya...@shapeblue.com> Committed: Tue Aug 12 12:01:31 2014 +0200 ---------------------------------------------------------------------- server/src/com/cloud/api/ApiServlet.java | 2 +- server/src/com/cloud/api/auth/APIAuthenticator.java | 3 ++- .../src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java | 2 +- .../src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/224dc9f8/server/src/com/cloud/api/ApiServlet.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java index d94894a..d09d426 100644 --- a/server/src/com/cloud/api/ApiServlet.java +++ b/server/src/com/cloud/api/ApiServlet.java @@ -178,7 +178,7 @@ public class ApiServlet extends HttpServlet { } try { - responseString = apiAuthenticator.authenticate(command, params, session, remoteAddress, responseType, auditTrailSb); + responseString = apiAuthenticator.authenticate(command, params, session, remoteAddress, responseType, auditTrailSb, resp); } catch (ServerApiException e) { httpResponseCode = e.getErrorCode().getHttpCode(); responseString = e.getMessage(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/224dc9f8/server/src/com/cloud/api/auth/APIAuthenticator.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/auth/APIAuthenticator.java b/server/src/com/cloud/api/auth/APIAuthenticator.java index a0f669e..90cd7ec 100644 --- a/server/src/com/cloud/api/auth/APIAuthenticator.java +++ b/server/src/com/cloud/api/auth/APIAuthenticator.java @@ -18,6 +18,7 @@ package com.cloud.api.auth; import org.apache.cloudstack.api.ServerApiException; +import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.Map; @@ -34,7 +35,7 @@ import java.util.Map; public interface APIAuthenticator { public String authenticate(String command, Map<String, Object[]> params, HttpSession session, String remoteAddress, String responseType, - StringBuilder auditTrailSb) throws ServerApiException; + StringBuilder auditTrailSb, final HttpServletResponse resp) throws ServerApiException; public APIAuthenticationType getAPIType(); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/224dc9f8/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java b/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java index 5fa8e9e..fe04ed9 100644 --- a/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java +++ b/server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java @@ -152,7 +152,7 @@ public class DefaultLoginAPIAuthenticatorCmd extends BaseCmd implements APIAuthe } @Override - public String authenticate(String command, Map<String, Object[]> params, HttpSession session, String remoteAddress, String responseType, StringBuilder auditTrailSb) throws ServerApiException { + public String authenticate(String command, Map<String, Object[]> params, HttpSession session, String remoteAddress, String responseType, StringBuilder auditTrailSb, final HttpServletResponse resp) throws ServerApiException { // FIXME: ported from ApiServlet, refactor and cleanup final String[] username = (String[])params.get(ApiConstants.USERNAME); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/224dc9f8/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java b/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java index ab4e162..a5802bf 100644 --- a/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java +++ b/server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java @@ -25,6 +25,7 @@ import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.LogoutCmdResponse; import org.apache.log4j.Logger; +import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.Map; @@ -55,7 +56,7 @@ public class DefaultLogoutAPIAuthenticatorCmd extends BaseCmd implements APIAuth } @Override - public String authenticate(String command, Map<String, Object[]> params, HttpSession session, String remoteAddress, String responseType, StringBuilder auditTrailSb) throws ServerApiException { + public String authenticate(String command, Map<String, Object[]> params, HttpSession session, String remoteAddress, String responseType, StringBuilder auditTrailSb, final HttpServletResponse resp) throws ServerApiException { auditTrailSb.append("=== Logging out ==="); LogoutCmdResponse response = new LogoutCmdResponse(); response.setDescription("success");