web client uses hsadmin.properties

This commit is contained in:
Peter Hormanns 2017-04-28 17:28:10 +02:00
parent 91cce7a8d9
commit 806039220b
2 changed files with 17 additions and 16 deletions

View File

@ -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");

View File

@ -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);
}
}