}*/
for (Configuration.Interface iface : config.getInterfaces()) {
if (iface.isSecure()) {
getContext().getLogger().info("https listening on " + iface.getAddress() + ":" + iface.getPort());
Server server = getServers().add(Protocol.HTTPS, iface.getAddress().equals("*") ? null : iface.getAddress(), iface.getPort());
if (config.getKeyStorePath() != null) {
server.getContext().getParameters().add("keystorePath", config.getKeyStorePath().getAbsolutePath());
server.getContext().getParameters().add("keystorePassword", config.getKeyStorePassword());
server.getContext().getParameters().add("keyPassword", config.getKeyStorePassword());
}
} else {
getContext().getLogger().info("http listening on " + iface.getAddress() + ":" + iface.getPort());
getServers().add(Protocol.HTTP, iface.getAddress().equals("*") ? null : iface.getAddress(), iface.getPort());
}
Map<String, ConfiguredHost> confHosts = ifaceHosts.get(iface.getKey());
if (confHosts == null) {
confHosts = new TreeMap<String, ConfiguredHost>();
ifaceHosts.put(iface.getKey(), confHosts);
}
// Configure static hosts
for (String name : iface.getHosts().keySet()) {
final Configuration.Host host = iface.getHosts().get(name);
if (confHosts.get(host.getName()) != null) {
getLogger().warning("Ignoring duplicate host name " + host.getName());
} else {
Context hostContext = getContext().createChildContext();
ConfiguredHost confHost = new ConfiguredHost(hostContext, getInternalRouter(), iface, host, new Date(), true);
confHosts.put(host.getName(), confHost);
if (host.getLinks().get("autoconf") != null) {
hasStaticAutoConf = true;
}
getHosts().add(confHost.getVirtualHost());
}
}
// Configure autoconf
List<Link> autoFeeds = iface.getLinks().get("autoconf");
if (autoFeeds != null) {
for (Link link : autoFeeds) {
addAutoConfiguration(iface, link);
}
}
}
this.getDefaultHost().attach(new Restlet() {
public void handle(Request request, Response response) {
response.setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
}
});
// Add the clients
getClients().add(Protocol.FILE);
getClients().add(Protocol.HTTP);
getClients().add(Protocol.HTTPS);
for (Server server : getServers()) {
try {
server.start();
} catch (Exception ex) {
getLogger().log(Level.SEVERE,"Cannot start server.",ex);
}
}