use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class GetHostAndPortCommand method getHostAndPort.
private HostAndPort getHostAndPort(HttpService httpService, VirtualServer vs, boolean securityEnabled) {
List<VirtualServer> virtualServerList = httpService.getVirtualServer();
List<NetworkListener> httpListenerList = httpService.getParent(Config.class).getNetworkConfig().getNetworkListeners().getNetworkListener();
for (VirtualServer virtualServer : virtualServerList) {
if (!virtualServer.getId().equals(vs.getId())) {
continue;
}
String vsHttpListeners = virtualServer.getNetworkListeners();
if (vsHttpListeners == null) {
continue;
}
List<String> vsHttpListenerList = StringUtils.parseStringList(vsHttpListeners, " ,");
for (String vsHttpListener : vsHttpListenerList) {
for (NetworkListener httpListener : httpListenerList) {
if (!httpListener.getName().equals(vsHttpListener)) {
continue;
}
if (!Boolean.valueOf(httpListener.getEnabled())) {
continue;
}
final Protocol protocol = httpListener.findHttpProtocol();
if (Boolean.valueOf(protocol.getSecurityEnabled()) == securityEnabled) {
String serverName = protocol.getHttp().getServerName();
if (serverName == null || serverName.trim().equals("")) {
serverName = DeploymentCommandUtils.getLocalHostName();
}
String portStr = httpListener.getPort();
String redirPort = protocol.getHttp().getRedirectPort();
if (redirPort != null && !redirPort.trim().equals("")) {
portStr = redirPort;
}
int port = Integer.parseInt(portStr);
return new HostAndPort(serverName, port, securityEnabled);
}
}
}
}
return null;
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class GetHostAndPortCommand method getHostAndPort.
private HostAndPort getHostAndPort(HttpService httpService, boolean securityEnabled) {
List<NetworkListener> httpListenerList = httpService.getParent(Config.class).getNetworkConfig().getNetworkListeners().getNetworkListener();
for (NetworkListener httpListener : httpListenerList) {
if (!Boolean.valueOf(httpListener.getEnabled())) {
continue;
}
final Protocol protocol = httpListener.findHttpProtocol();
final Http http = protocol.getHttp();
if (http.getDefaultVirtualServer().equals("__asadmin")) {
continue;
}
if (Boolean.valueOf(protocol.getSecurityEnabled()) == securityEnabled) {
String serverName = http.getServerName();
if (serverName == null || serverName.trim().equals("")) {
serverName = DeploymentCommandUtils.getLocalHostName();
}
String portStr = httpListener.getPort();
String redirPort = http.getRedirectPort();
if (redirPort != null && !redirPort.trim().equals("")) {
portStr = redirPort;
}
int port = Integer.parseInt(portStr);
return new HostAndPort(serverName, port, securityEnabled);
}
}
return null;
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class SecureAdminConfigUpgrade method createAdminNetworkListener.
private NetworkListener createAdminNetworkListener(final Transaction t, final NetworkConfig nc, final String adminListenerProtocolName) throws TransactionFailure {
final NetworkListeners nls_w = t.enroll(nc.getNetworkListeners());
final NetworkListener nl_w = nls_w.createChild(NetworkListener.class);
nls_w.getNetworkListener().add(nl_w);
nl_w.setName(ADMIN_LISTENER_NAME);
nl_w.setProtocol(adminListenerProtocolName);
nl_w.setPort(ASADMIN_LISTENER_PORT);
nl_w.setTransport(ASADMIN_LISTENER_TRANSPORT);
nl_w.setThreadPool(ASADMIN_LISTENER_THREADPOOL);
return nl_w;
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class SecureAdminConfigUpgrade method ensureConfigReady.
// private void prepareNonDASConfigs() throws TransactionFailure, PropertyVetoException {
// for (Config c : configs.getConfig()) {
// if (c.getName().equals(DAS_CONFIG_NAME)) {
// continue;
// }
// ensureConfigReady(c, SecureAdminCommand.PORT_UNIF_PROTOCOL_NAME);
// }
// }
private void ensureConfigReady(final Config c, final String adminListenerProtocol) throws TransactionFailure, PropertyVetoException {
final NetworkConfig nc = c.getNetworkConfig();
final NetworkListener nl = nc.getNetworkListener(SecureAdminCommand.ADMIN_LISTENER_NAME);
if (nl != null) {
return;
}
/*
* Create an admin-listener for this configuration.
*/
final Config config_w = writableConfig(c);
createAdminNetworkListener(transaction(), nc, adminListenerProtocol);
createAdminVirtualServer(transaction(), config_w);
}
use of org.glassfish.grizzly.config.dom.NetworkListener in project Payara by payara.
the class DeleteThreadpool method preAuthorization.
@Override
public boolean preAuthorization(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
config = CLIUtil.updateConfigIfNeeded(config, target, habitat);
threadPools = config.getThreadPools();
if (!isThreadPoolExists(threadPools)) {
report.setMessage(localStrings.getLocalString("delete.threadpool.notexists", "Thread Pool named {0} does not exist.", threadpool_id));
report.setActionExitCode(ExitCode.FAILURE);
return false;
}
pool = null;
for (ThreadPool tp : config.getThreadPools().getThreadPool()) {
if (tp.getName().equals(threadpool_id)) {
pool = tp;
}
}
List<NetworkListener> nwlsnrList = pool.findNetworkListeners();
for (NetworkListener nwlsnr : nwlsnrList) {
if (pool.getName().equals(nwlsnr.getThreadPool())) {
report.setMessage(localStrings.getLocalString("delete.threadpool.beingused", "{0} threadpool is being used in the network listener {1}", threadpool_id, nwlsnr.getName()));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return false;
}
}
return true;
}
Aggregations