@Override public HttpURLConnection openConnection(URL url, String userName, OptionsByType optionsByType) throws IOException { HttpAuthenticationType authType = optionsByType.getOrSetDefault(HttpAuthenticationType.class, HttpAuthenticationType.Basic); HttpProxy proxy = optionsByType.getOrSetDefault(HttpProxy.class, HttpProxy.none()); HttpURLConnection connection; switch (authType) { case Basic : String userPassword = userName + ":" + password; String encoding = Base64.getEncoder().encodeToString(userPassword.getBytes()); connection = proxy.openConnection(url); connection.setRequestProperty("Authorization", "Basic " + encoding); break; case NTLM : case Kerberos : default : throw new IllegalArgumentException("Unsupported HTTP authentication type " + authType); } return connection; } }
@Override public void configure(ContainerClassLoader containerClassLoader, PipedOutputStream pipedOutputStream, PipedInputStream pipedInputStream, OptionsByType optionsByType) { ClassName className = optionsByType.getOrSetDefault(ClassName.class, ClassName.of(DEFAULT_CACHE_SERVER_CLASSNAME)); ContainerBasedJavaApplicationLauncher.configureRemoteChannel(containerClassLoader, pipedOutputStream, pipedInputStream, className.getName()); } }
@Override public void configure(ContainerClassLoader containerClassLoader, PipedOutputStream pipedOutputStream, PipedInputStream pipedInputStream, OptionsByType optionsByType) { ClassName className = optionsByType.getOrSetDefault(ClassName.class, ClassName.of(DEFAULT_CACHE_SERVER_CLASSNAME)); ContainerBasedJavaApplicationLauncher.configureRemoteChannel(containerClassLoader, pipedOutputStream, pipedInputStream, className.getName()); } }
@Override public void configure(ContainerClassLoader containerClassLoader, PipedOutputStream pipedOutputStream, PipedInputStream pipedInputStream, OptionsByType optionsByType) { ClassName className = optionsByType.getOrSetDefault(ClassName.class, ClassName.of(DEFAULT_CACHE_SERVER_CLASSNAME)); ContainerBasedJavaApplicationLauncher.configureRemoteChannel(containerClassLoader, pipedOutputStream, pipedInputStream, className.getName()); } }
@Override default DisplayName getDisplayName(OptionsByType optionsByType) { ClassName className = optionsByType.get(ClassName.class); if (className == null) { return optionsByType.get(DisplayName.class); } else { // determine the short class name of the class we're launching (as a possible default) String shortClassName = className.getName(); int lastDot = shortClassName.lastIndexOf("."); shortClassName = lastDot <= 0 ? shortClassName : shortClassName.substring(lastDot + 1); if (shortClassName.isEmpty()) { return optionsByType.get(DisplayName.class); } else { return optionsByType.getOrSetDefault(DisplayName.class, DisplayName.of(shortClassName)); } } } }
@Override default DisplayName getDisplayName(OptionsByType optionsByType) { ClassName className = optionsByType.get(ClassName.class); if (className == null) { return optionsByType.get(DisplayName.class); } else { // determine the short class name of the class we're launching (as a possible default) String shortClassName = className.getName(); int lastDot = shortClassName.lastIndexOf("."); shortClassName = lastDot <= 0 ? shortClassName : shortClassName.substring(lastDot + 1); if (shortClassName.isEmpty()) { return optionsByType.get(DisplayName.class); } else { return optionsByType.getOrSetDefault(DisplayName.class, DisplayName.of(shortClassName)); } } } }
httpExchange.sendResponseHeaders(200, 0); BufferSize bufferSize = optionsByType.getOrSetDefault(BufferSize.class, new BufferSize(1000000)); int bufferBytes = bufferSize.getBufferSize();
/** * Send the specified SOAP {@link Envelope} to the SOAP service * listening on the specified {@link URL}. * * @param envelope the {@link org.w3c.soap.envelope.Envelope} to send * * @return the un-marshaled result returned from the SOAP service * * @throws IOException if an error occurs */ public List<Object> send(Envelope envelope) throws IOException { HttpURLConnection httpConnection; if (authentication == null) { HttpProxy proxy = optionsByType.getOrSetDefault(HttpProxy.class, HttpProxy.none()); httpConnection = proxy.openConnection(this.url); } else { httpConnection = authentication.openConnection(this.url, userName, optionsByType); } return send(envelope, httpConnection); }
Executable executable = optionsByType.getOrSetDefault(Executable.class, Executable.named("java")); PlatformSeparators separators = optionsByType.getOrSetDefault(PlatformSeparators.class, PlatformSeparators.forUnix());
EnvironmentVariables environmentVariables = optionsByType.getOrSetDefault(EnvironmentVariables.class, EnvironmentVariables.of(EnvironmentVariables .Source.TargetPlatform));
console = optionsByType.getOrSetDefault(ApplicationConsoleBuilder.class, Console.system()).build(displayName);
console = optionsByType.getOrSetDefault(ApplicationConsoleBuilder.class, Console.system()).build(displayName);
JavaDeployment deployment = (JavaDeployment) optionsByType.getOrSetDefault(Deployment.class, JavaDeployment.automatic()); PlatformSeparators separators = optionsByType.getOrSetDefault(PlatformSeparators.class, PlatformSeparators.forUnix());
ClassPathModifier modifier = optionsByType.getOrSetDefault(ClassPathModifier.class, ClassPathModifier.none()); String classPath = modifier.applyQuotes(remoteClassPath.toString(optionsByType.asArray()));
WindowsSoapOptions soapOptions = optionsByType.getOrSetDefault(WindowsSoapOptions.class, WindowsSoapOptions.basic());
DisplayName displayName = launchOptions.getOrSetDefault(DisplayName.class, DisplayName.of(launchOptions.get(Executable.class) .getName())); WorkingDirectory workingDirectory = launchOptions.getOrSetDefault(WorkingDirectory.class, WorkingDirectory.currentDirectory()); File directory = workingDirectory.resolve(platform, launchOptions);
WindowsShellOptions shellOptions = optionsByType.getOrSetDefault(WindowsShellOptions.class, WindowsShellOptions.basic()); ShellType shellType = ObjectFactories.SHELL.createShellType();
Shell shell = optionsByType.getOrSetDefault(Shell.class, Shell.isUnknown());
DisplayName displayName = launchOptions.getOrSetDefault(DisplayName.class, DisplayName.of(launchOptions.get(Executable.class) .getName())); WorkingDirectory workingDirectory = launchOptions.getOrSetDefault(WorkingDirectory.class, WorkingDirectory.currentDirectory()); File directory = workingDirectory.resolve(platform, launchOptions);
ApplicationController controller = launchOptions.getOrSetDefault(ApplicationController.class, metaClass instanceof ApplicationController ? (ApplicationController) metaClass