public synchronized void startListener() throws SCServiceException, SCMPValidatorException {
if (this.listening == true) {
throw new SCServiceException("Listener is already started not allowed to start again.");
}
if (this.scHost == null) {
throw new SCMPValidatorException("Host must be set.");
}
if (this.connectionType == null) {
throw new SCMPValidatorException("ConnectionType must be set.");
}
ValidatorUtility.validateInt(Constants.MIN_PORT_VALUE, this.scPort, Constants.MAX_PORT_VALUE, SCMPError.HV_WRONG_PORTNR);
ValidatorUtility.validateInt(Constants.MIN_PORT_VALUE, this.listenerPort, Constants.MAX_PORT_VALUE,
SCMPError.HV_WRONG_PORTNR);
if (this.scPort == this.listenerPort) {
throw new SCMPValidatorException("SC port and listener port must not be the same.");
}
if (this.nics == null || this.nics.size() == 0) {
nics = new ArrayList<String>();
try {
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets)) {
Enumeration<InetAddress> inetAdresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAdresses)) {
if (inetAddress instanceof Inet6Address) {
// ignore IPV6 addresses, bind not possible on this NIC
continue;
}
nics.add(inetAddress.getHostAddress());
LOGGER.debug("SCServer listens on " + inetAddress.getHostAddress());
}
}
} catch (Exception e) {
LOGGER.fatal("unable to detect network interface", e);
throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE, "Wrong interface.");
}
}
ListenerConfiguration listenerConfig = new ListenerConfiguration(SCSessionServer.class.getSimpleName());
listenerConfig.setConnectionType(this.connectionType.getValue());