mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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.yadav@shapeblue.com>
This commit is contained in:
parent
6ec1a1b604
commit
224dc9f8e5
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user