use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class FindHttpProtocolResource method get.
@GET
@Produces({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_FORM_URLENCODED })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_FORM_URLENCODED })
public ActionReportResult get() {
Dom dom = getEntity();
NetworkListener nl = dom.createProxy(NetworkListener.class);
Protocol p = nl.findHttpProtocol();
RestActionReporter ar = new RestActionReporter();
ar.setActionExitCode(ActionReport.ExitCode.SUCCESS);
ar.getTopMessagePart().getProps().put("protocol", p.getName());
return new ActionReportResult("find-http-protocol", ar, new OptionsResult());
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class CreateSsl method findOrCreateProtocol.
public Protocol findOrCreateProtocol(final String name, final boolean create) throws TransactionFailure {
NetworkConfig networkConfig = config.getNetworkConfig();
Protocol protocol = networkConfig.findProtocol(name);
if (protocol == null && create) {
protocol = (Protocol) ConfigSupport.apply(new SingleConfigCode<Protocols>() {
@Override
public Object run(Protocols param) throws TransactionFailure {
Protocol newProtocol = param.createChild(Protocol.class);
newProtocol.setName(name);
newProtocol.setSecurityEnabled("true");
param.getProtocol().add(newProtocol);
return newProtocol;
}
}, habitat.<Protocols>getService(Protocols.class));
}
return protocol;
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class ProtocolSslConfigHandler method create.
// ------------------------------------------- Methods from SslConfigHandler
@Override
public void create(final CreateSsl command, final ActionReport report) {
try {
final Protocol protocol = command.findOrCreateProtocol(command.listenerId, false);
if (protocol == null) {
report.setMessage(LOCAL_STRINGS.getLocalString("create.ssl.protocol.notfound.fail", "Unable to find protocol {0}.", command.listenerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
} else {
ConfigSupport.apply(new SingleConfigCode<Protocol>() {
@Override
public Object run(Protocol param) throws TransactionFailure {
Ssl newSsl = param.createChild(Ssl.class);
param.setSecurityEnabled("true");
command.populateSslElement(newSsl);
param.setSsl(newSsl);
return newSsl;
}
}, protocol);
}
} catch (TransactionFailure transactionFailure) {
command.reportError(report, transactionFailure);
return;
}
command.reportSuccess(report);
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class RuntimeRootImpl method getRESTBaseURL.
public String getRESTBaseURL() throws MalformedURLException {
final Protocol protocol = networkConfig().getProtocols().findProtocol(ADMIN_LISTENER_NAME);
final String scheme = Boolean.parseBoolean(protocol.getSecurityEnabled()) ? "https" : "http";
final String host = "localhost";
URL url = new URL(scheme, host, getRESTPort(), "/" + get_asadmin());
return url.toString() + "/";
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class AdminRESTConfigUpgrade method postConstruct.
@Override
public void postConstruct() {
for (Config config : configs.getConfig()) {
// we only want to handle configs that have an admin listener
try {
if (config.getAdminListener() == null) {
LogRecord lr = new LogRecord(Level.FINE, String.format("Skipping config %s. No admin listener.", config.getName()));
lr.setLoggerName(getClass().getName());
EarlyLogHandler.earlyMessages.add(lr);
continue;
}
} catch (IllegalStateException ise) {
/*
* I've only seen the exception rather than
* getAdminListener returning null. This should
* typically happen for any config besides
* <server-config>, but we'll proceed if any
* config has an admin listener.
*/
LogRecord lr = new LogRecord(Level.FINE, String.format("Skipping config %s. getAdminListener threw: %s", config.getName(), ise.getLocalizedMessage()));
lr.setLoggerName(getClass().getName());
EarlyLogHandler.earlyMessages.add(lr);
continue;
}
Protocols ps = config.getNetworkConfig().getProtocols();
if (ps != null) {
for (Protocol p : ps.getProtocol()) {
Http h = p.getHttp();
if (h != null && "__asadmin".equals(h.getDefaultVirtualServer())) {
try {
ConfigSupport.apply(new HttpConfigCode(), h);
} catch (TransactionFailure tf) {
LogRecord lr = new LogRecord(Level.SEVERE, "Could not upgrade http element for admin console: " + tf);
lr.setLoggerName(getClass().getName());
EarlyLogHandler.earlyMessages.add(lr);
}
}
}
}
}
}
Aggregations