/** * Sets a {@link SessionProtocol} and its port number only if it has not been specified before. */ SamlPortConfigBuilder setSchemeAndPortIfAbsent(ServerPort serverPort) { requireNonNull(serverPort, "serverPort"); if (serverPort.hasHttps()) { setSchemeIfAbsent(SessionProtocol.HTTPS); } else if (serverPort.hasHttp()) { setSchemeIfAbsent(SessionProtocol.HTTP); } else { throw new IllegalArgumentException("unexpected session protocol: " + serverPort.protocols()); } // Do not set a port if the port number is 0 which means that the port will be automatically chosen. final int port = serverPort.localAddress().getPort(); if (isValidPort(port)) { setPortIfAbsent(port); } return this; }
/** * Sets a {@link SessionProtocol} and its port number only if it has not been specified before. */ SamlPortConfigBuilder setSchemeAndPortIfAbsent(ServerPort serverPort) { requireNonNull(serverPort, "serverPort"); if (serverPort.hasHttps()) { setSchemeIfAbsent(SessionProtocol.HTTPS); } else if (serverPort.hasHttp()) { setSchemeIfAbsent(SessionProtocol.HTTP); } else { throw new IllegalArgumentException("unexpected session protocol: " + serverPort.protocols()); } // Do not set a port if the port number is 0 which means that the port will be automatically chosen. final int port = serverPort.localAddress().getPort(); if (isValidPort(port)) { setPortIfAbsent(port); } return this; }