use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class AbstractRemoteCertificateManagementCommand method resolveKeyStore.
/**
* Resolves the keystore location and the password required to access it.
*/
protected void resolveKeyStore() {
Config config = servers.getServer(target).getConfig();
if (listener != null) {
// Check if listener is an HTTP listener
List<Protocol> protocols = config.getNetworkConfig().getProtocols().getProtocol();
for (Protocol protocol : protocols) {
if (protocol.getName().equals(listener)) {
Ssl sslConfig = protocol.getSsl();
if (sslConfig != null) {
if (StringUtils.ok(sslConfig.getKeyStore())) {
keystore = new File(TranslatedConfigView.expandConfigValue(sslConfig.getKeyStore()));
keystorePassword = TranslatedConfigView.expandConfigValue(sslConfig.getKeyStorePassword()).toCharArray();
}
}
}
}
if (keystore == null) {
// Check if listener is an IIOP listener
List<IiopListener> listeners = iiopService.getIiopListener();
for (IiopListener listener : listeners) {
if (listener.getId().equals(listener)) {
Ssl sslConfig = listener.getSsl();
if (StringUtils.ok(sslConfig.getKeyStore())) {
keystore = new File(TranslatedConfigView.expandConfigValue(sslConfig.getKeyStore()));
keystorePassword = TranslatedConfigView.expandConfigValue(sslConfig.getKeyStorePassword()).toCharArray();
}
}
}
}
}
// Default to getting it from the JVM options if no non-default value found
if (keystore == null) {
List<String> jvmOptions = config.getJavaConfig().getJvmOptions();
for (String jvmOption : jvmOptions) {
if (jvmOption.startsWith("-Djavax.net.ssl.keyStore")) {
keystore = new File(TranslatedConfigView.expandConfigValue(jvmOption.substring(jvmOption.indexOf("=") + 1)));
}
}
}
// If it's STILL null, just go with default
if (keystore == null) {
keystore = serverEnvironment.getJKS();
}
// If the password hasn't been set, go with master
if (keystorePassword == null) {
MasterPasswordImpl masterPasswordService = serviceLocator.getService(MasterPasswordImpl.class);
keystorePassword = masterPasswordService.getMasterPassword();
}
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class AbstractRemoteCertificateManagementCommand method resolveTrustStore.
/**
* Resolves the truststore location and the password required to access it.
*/
protected void resolveTrustStore() {
Config config = servers.getServer(target).getConfig();
if (listener != null) {
// Check if listener is an HTTP listener
List<Protocol> protocols = config.getNetworkConfig().getProtocols().getProtocol();
for (Protocol protocol : protocols) {
if (protocol.getName().equals(listener)) {
Ssl sslConfig = protocol.getSsl();
if (sslConfig != null) {
if (StringUtils.ok(sslConfig.getTrustStore())) {
truststore = new File(TranslatedConfigView.expandConfigValue(sslConfig.getTrustStore()));
truststorePassword = TranslatedConfigView.expandConfigValue(sslConfig.getTrustStorePassword()).toCharArray();
}
}
}
}
if (truststore == null) {
// Check if listener is an IIOP listener
List<IiopListener> listeners = iiopService.getIiopListener();
for (IiopListener listener : listeners) {
if (listener.getId().equals(listener)) {
Ssl sslConfig = listener.getSsl();
if (StringUtils.ok(sslConfig.getTrustStore())) {
truststore = new File(TranslatedConfigView.expandConfigValue(sslConfig.getTrustStore()));
truststorePassword = TranslatedConfigView.expandConfigValue(sslConfig.getTrustStorePassword()).toCharArray();
}
}
}
}
}
// Default to getting it from the JVM options if no non-default value found
if (truststore == null) {
List<String> jvmOptions = config.getJavaConfig().getJvmOptions();
for (String jvmOption : jvmOptions) {
if (jvmOption.startsWith("-Djavax.net.ssl.trustStore")) {
truststore = new File(TranslatedConfigView.expandConfigValue(jvmOption.substring(jvmOption.indexOf("=") + 1)));
}
}
}
// If it's STILL null, just go with default
if (truststore == null) {
truststore = serverEnvironment.getTrustStore();
}
// If the password hasn't been set, go with master
if (truststorePassword == null) {
MasterPasswordImpl masterPassword = serviceLocator.getService(MasterPasswordImpl.class);
truststorePassword = masterPassword.getMasterPassword();
}
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class CertificateManagementRestApiHandlers method getAllListenerNamesAndUrls.
/**
* Gets the names of all HTTP and IIOP listeners for the target instance and the links to them.
* @param contextPath The root context path
* @param config The config of the target instance
* @param serviceLocator The ServiceLocator to get additional HK2 services from
* @param listeners The list of listeners to populate
* @param usedByLinks The map of usedBy links to populate
*/
private static void getAllListenerNamesAndUrls(String contextPath, Config config, ServiceLocator serviceLocator, List<String> listeners, Map<String, String> usedByLinks) {
List<Protocol> protocols = config.getNetworkConfig().getProtocols().getProtocol();
String httpConfigUrl = contextPath + "/web/grizzly/networkListenerEdit.jsf?configName=" + config.getName() + "&cancelTo=web/grizzly/networkListeners.jsf";
for (Protocol protocol : protocols) {
listeners.add(protocol.getName());
usedByLinks.put(protocol.getName(), httpConfigUrl + "&name=" + protocol.getName());
}
IiopService iiopService = serviceLocator.getService(IiopService.class);
String iiopConfigUrl = contextPath + "/corba/sslEdit.jsf?configName=" + config.getName();
List<IiopListener> iiopListeners = iiopService.getIiopListener();
for (IiopListener listener : iiopListeners) {
listeners.add(listener.getId());
usedByLinks.put(listener.getId(), iiopConfigUrl + "&name=" + listener.getId());
}
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class CreateHttp method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the parameter names and the values the parameter
* values.
*
* @param context information
*/
public void execute(AdminCommandContext context) {
Target targetUtil = services.getService(Target.class);
Config newConfig = targetUtil.getConfig(target);
if (newConfig != null) {
config = newConfig;
}
final ActionReport report = context.getActionReport();
// check for duplicates
Protocols protocols = config.getNetworkConfig().getProtocols();
Protocol protocol = null;
for (Protocol p : protocols.getProtocol()) {
if (protocolName.equals(p.getName())) {
protocol = p;
}
}
if (protocol == null) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_FAIL_PROTOCOL_NOT_FOUND), protocolName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (protocol.getHttp() != null) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_FAIL_DUPLICATE), protocolName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
// Add to the <network-config>
try {
ConfigSupport.apply(new SingleConfigCode<Protocol>() {
public Object run(Protocol param) throws TransactionFailure {
Http http = param.createChild(Http.class);
final FileCache cache = http.createChild(FileCache.class);
cache.setEnabled("false");
http.setFileCache(cache);
http.setDefaultVirtualServer(defaultVirtualServer);
http.setDnsLookupEnabled(dnsLookupEnabled == null ? null : dnsLookupEnabled.toString());
http.setMaxConnections(maxConnections);
http.setRequestTimeoutSeconds(requestTimeoutSeconds);
http.setTimeoutSeconds(timeoutSeconds);
http.setXpoweredBy(xPoweredBy == null ? null : xPoweredBy.toString());
http.setServerHeader(serverHeader == null ? null : serverHeader.toString());
http.setXframeOptions(xFrameOptions == null ? null : xFrameOptions.toString());
http.setServerName(serverName);
// HTTP2 options
http.setHttp2Enabled(http2Enabled.toString());
if (http2MaxConcurrentStreams != null) {
http.setHttp2MaxConcurrentStreams(http2MaxConcurrentStreams.toString());
}
if (http2InitialWindowSizeInBytes != null) {
http.setHttp2InitialWindowSizeInBytes(http2InitialWindowSizeInBytes.toString());
}
if (http2MaxFramePayloadSizeInBytes != null) {
http.setHttp2MaxFramePayloadSizeInBytes(http2MaxFramePayloadSizeInBytes.toString());
}
if (http2MaxHeaderListSizeInBytes != null) {
http.setHttp2MaxHeaderListSizeInBytes(http2MaxHeaderListSizeInBytes.toString());
}
if (http2StreamsHighWaterMark != null) {
http.setHttp2StreamsHighWaterMark(http2StreamsHighWaterMark.toString());
}
if (http2CleanPercentage != null) {
http.setHttp2CleanPercentage(http2CleanPercentage.toString());
}
if (http2CleanFrequencyCheck != null) {
http.setHttp2CleanFrequencyCheck(http2CleanFrequencyCheck.toString());
}
if (http2DisableCipherCheck != null) {
http.setHttp2DisableCipherCheck(http2DisableCipherCheck.toString());
}
if (http2PushEnabled != null) {
http.setHttp2PushEnabled(http2PushEnabled.toString());
}
param.setHttp(http);
return http;
}
}, protocol);
} catch (TransactionFailure e) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_REDIRECT_FAIL), protocolName, e.getMessage() == null ? "No reason given." : e.getMessage()));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.glassfish.grizzly.config.dom.Protocol in project Payara by payara.
the class CreateProtocol method execute.
/**
* Executes the command with the command parameters passed as Properties where the keys are the paramter names and
* the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
Target targetUtil = services.getService(Target.class);
Config newConfig = targetUtil.getConfig(target);
if (newConfig != null) {
config = newConfig;
}
final ActionReport report = context.getActionReport();
// check for duplicates
NetworkConfig networkConfig = config.getNetworkConfig();
Protocols protocols = networkConfig.getProtocols();
for (Protocol protocol : protocols.getProtocol()) {
if (protocolName != null && protocolName.equalsIgnoreCase(protocol.getName())) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_PROTOCOL_FAIL_DUPLICATE), protocolName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
// Add to the <network-config>
try {
create(protocols, protocolName, securityEnabled);
} catch (TransactionFailure e) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_PROTOCOL_FAIL), protocolName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
} catch (Exception e) {
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_PROTOCOL_FAIL), protocolName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Aggregations