From bc169d4b132891052cc8c642e18e642afd04464f Mon Sep 17 00:00:00 2001 From: Lior Nachmias Date: Mon, 26 Feb 2018 18:21:23 +0200 Subject: Webseal fix Change-Id: Ic6de1f490e72b05b057d246dd70a2eae6524458d Issue-ID: SDC-550 Signed-off-by: Lior Nachmias --- utils/webseal-simulator/sdc-simulator/startup.sh | 1 + .../org/openecomp/sdc/webseal/simulator/Login.java | 2 +- .../sdc/webseal/simulator/RequestsClient.java | 19 +++++++++---------- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'utils') diff --git a/utils/webseal-simulator/sdc-simulator/startup.sh b/utils/webseal-simulator/sdc-simulator/startup.sh index 48b6a0d505..029126d183 100644 --- a/utils/webseal-simulator/sdc-simulator/startup.sh +++ b/utils/webseal-simulator/sdc-simulator/startup.sh @@ -11,6 +11,7 @@ if [[ $rc != 0 ]]; then fi JAVA_OPTIONS=" ${JAVA_OPTIONS} \ + -Xdebug -agentlib:jdwp=transport=dt_socket,address=5000,server=y,suspend=n -Xmx128m -Xms128m -Xss1m \ -Dconfig.home=${JETTY_BASE}/config/sdc-simulator \ -Dlog.home=${JETTY_BASE}/logs \ -Dlogback.configurationFile=${JETTY_BASE}/config/sdc-simulator/logback.xml \ diff --git a/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/Login.java b/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/Login.java index 78aca50e95..0f6cd8a5c4 100644 --- a/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/Login.java +++ b/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/Login.java @@ -111,7 +111,7 @@ public class Login extends HttpServlet { System.out.println("Login -> doPOst userId=" + userId); User user = getUser(userId, password); if (user == null) { - response.sendError(500, "ERROR: userId or password incorect"); + response.sendError(500, "ERROR: userId or password incorrect"); // doGet(request, response); } else { System.out.println("Login -> doPOst redirext to /sdc1 (to proxy)"); diff --git a/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/RequestsClient.java b/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/RequestsClient.java index a5e4a8a0eb..4cfacecb12 100644 --- a/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/RequestsClient.java +++ b/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/RequestsClient.java @@ -26,12 +26,10 @@ public class RequestsClient extends HttpServlet { @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { - String hostname = request.getParameter("hostname") != null ? request.getParameter("hostname") : "127.0.0.1"; - String port = request.getParameter("port") != null ? request.getParameter("port") : "8080"; String adminId = request.getParameter("adminId") != null ? request.getParameter("adminId") : "jh0003"; - String createAll = request.getParameter("all"); - + String url = Conf.getInstance().getFeHost() + "/sdc1/feProxy/rest/v1/user"; + PrintWriter writer = response.getWriter(); int resultCode; @@ -39,7 +37,7 @@ public class RequestsClient extends HttpServlet { if ("true".equals(createAll)) { Map users = Conf.getInstance().getUsers(); for (User user : users.values()) { - resultCode = createUser(response, user.getUserId(), user.getRole().toUpperCase(), user.getFirstName(), user.getLastName(), user.getEmail(), hostname, port, adminId); + resultCode = createUser(response, user.getUserId(), user.getRole().toUpperCase(), user.getFirstName(), user.getLastName(), user.getEmail(), url, adminId); writer.println("User "+ user.getFirstName() + " " + user.getLastName() + getResultMessage(resultCode) + "
"); } } else { @@ -48,7 +46,9 @@ public class RequestsClient extends HttpServlet { String firstName = request.getParameter("firstName"); String lastName = request.getParameter("lastName"); String email = request.getParameter("email"); - resultCode = createUser(response, userId, role, firstName, lastName, email, hostname, port, adminId); + + resultCode = createUser(response, userId, role, firstName, lastName, email, url, adminId); + writer.println("User "+ firstName + " " + lastName +getResultMessage(resultCode)); } @@ -60,12 +60,11 @@ public class RequestsClient extends HttpServlet { return 201 == resultCode? " created successfuly":" not created ("+ resultCode +")"; } - private int createUser(final HttpServletResponse response, String userId, String role, String firstName, String lastName, String email, String hostname, String port, String adminId) throws IOException { + private int createUser(final HttpServletResponse response, String userId, String role, String firstName, String lastName, String email, String url, String adminId) throws IOException { response.setContentType("text/html"); - // Fill the data of the request - String url = "http://" + hostname + ":" + port + "/sdc2/rest/v1/user"; - String body = "{'firstName':'" + firstName + "', 'lastName':'" + lastName + "', 'userId':'" + userId + "', 'email':'" + email + "','role':'" + role + "'}"; + String body = "{\"firstName\":\"" + firstName + "\", \"lastName\":\"" + lastName + "\", \"userId\":\"" + userId + "\", \"email\":\"" + email + "\",\"role\":\"" + role + "\"}"; + HashMap headers = new HashMap(); headers.put("Content-Type", "application/json"); headers.put("USER_ID", adminId); -- cgit 1.2.3-korg