From 66349fbd80231b20bf76e369957f23c561f4690c Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 28 Apr 2017 17:28:10 +0200 Subject: [PATCH] web client uses hsadmin.properties --- .../java/de/hsadmin/model/TicketService.java | 20 ++++++++++--------- .../main/java/de/hsadmin/web/MainWindow.java | 13 ++++++------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/web/src/main/java/de/hsadmin/model/TicketService.java b/web/src/main/java/de/hsadmin/model/TicketService.java index 34efd97..e98b0ff 100644 --- a/web/src/main/java/de/hsadmin/model/TicketService.java +++ b/web/src/main/java/de/hsadmin/model/TicketService.java @@ -10,6 +10,7 @@ import java.net.URLEncoder; import javax.net.ssl.HttpsURLConnection; +import de.hsadmin.common.config.Config; import de.hsadmin.rpc.RpcException; /** @@ -21,18 +22,17 @@ import de.hsadmin.rpc.RpcException; */ public class TicketService implements Serializable { - public static final String SERVICE_URL = "https://config.hostsharing.net:443/hsar/backend"; - public static final String CAS_URL = "https://login.hostsharing.net/cas/v1/tickets"; - private static final long serialVersionUID = 1L; public String getGrantingTicket(final String user, final String password) throws RpcException { String ticket = null; try { - String userParam = "username=" + URLEncoder.encode(user, "UTF-8"); - String passwordParam = "password=" + URLEncoder.encode(password, "UTF-8"); - String encodedData = userParam + "&" + passwordParam; - URL url = new URL(CAS_URL); + final Config conf = Config.getInstance(); + final String userParam = "username=" + URLEncoder.encode(user, "UTF-8"); + final String passwordParam = "password=" + URLEncoder.encode(password, "UTF-8"); + final String encodedData = userParam + "&" + passwordParam; + final String casUrl = conf.getProperty("loginURL"); + final URL url = new URL(casUrl); final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); connection.setRequestMethod("POST"); @@ -56,8 +56,10 @@ public class TicketService implements Serializable { public String getServiceTicket(String grantingTicket) throws RpcException { String ticket = null; try { - String serviceParam = "service=" + URLEncoder.encode(SERVICE_URL, "UTF-8"); - URL url = new URL(grantingTicket); + final Config conf = Config.getInstance(); + final String backendURL = conf.getProperty("backendURL"); + final String serviceParam = "service=" + URLEncoder.encode(backendURL, "UTF-8"); + final URL url = new URL(grantingTicket); final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); connection.setRequestMethod("POST"); diff --git a/web/src/main/java/de/hsadmin/web/MainWindow.java b/web/src/main/java/de/hsadmin/web/MainWindow.java index 30cbc9a..b83263a 100644 --- a/web/src/main/java/de/hsadmin/web/MainWindow.java +++ b/web/src/main/java/de/hsadmin/web/MainWindow.java @@ -14,6 +14,8 @@ import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; +import de.hsadmin.common.config.Config; +import de.hsadmin.common.error.TechnicalException; import de.hsadmin.model.TicketService; import de.hsadmin.rpc.HSAdminSession; import de.hsadmin.rpc.ModulesManager; @@ -26,11 +28,6 @@ public class MainWindow extends CustomComponent implements HSAdminSession { private static final Logger LOG = Logger.getLogger(MainWindow.class); - public static final String[] SERVICE_URLS = new String[] { - "https://config2.hostsharing.net:443/hsar/xmlrpc/hsadmin", - "https://config.hostsharing.net:443/hsar/xmlrpc/hsadmin" - }; - final private TicketService ticketService; final private String grantingTicket; final private String username; @@ -52,11 +49,13 @@ public class MainWindow extends CustomComponent implements HSAdminSession { mainPanel.setContent(vl); try { + final Config conf = Config.getInstance(); + final String[] rpcUrls = conf.getProperty("xmlrpcURL").split(","); final MainToolbar mainToolbar = new MainToolbar(this); vl.addComponent(mainToolbar); vl.setExpandRatio(mainToolbar, 0.0f); final ModulesManagerFactory modulesManagerFactory = new ModulesManagerFactory(grantingTicket, username); - modulesManager = modulesManagerFactory.newModulesManager(SERVICE_URLS); + modulesManager = modulesManagerFactory.newModulesManager(rpcUrls); content = new HorizontalSplitPanel(); content.setSizeFull(); vl.addComponent(content); @@ -66,7 +65,7 @@ public class MainWindow extends CustomComponent implements HSAdminSession { content.setFirstComponent(entryPoints); content.setSecondComponent(new MainPanel()); content.setSplitPosition(26.6f); - } catch (RpcException e) { + } catch (RpcException | TechnicalException e) { LOG.fatal(e.getLocalizedMessage(), e); } }