Home / Type/ SslOptions Type — spring-boot Architecture

SslOptions Type — spring-boot Architecture

Architecture documentation for the SslOptions type/interface in SslOptions.java from the spring-boot codebase.

Entity Profile

Source Code

core/spring-boot/src/main/java/org/springframework/boot/ssl/SslOptions.java lines 38–123

public interface SslOptions {

	/**
	 * {@link SslOptions} that returns {@code null} results.
	 */
	SslOptions NONE = of(null, (Set<String>) null);

	/**
	 * Return if any SSL options have been specified.
	 * @return {@code true} if SSL options have been specified
	 */
	default boolean isSpecified() {
		return (getCiphers() != null) || (getEnabledProtocols() != null);
	}

	/**
	 * Return the ciphers that can be used or {@code null}. The cipher names in this set
	 * should be compatible with those supported by
	 * {@link SSLEngine#getSupportedCipherSuites()}.
	 * @return the ciphers that can be used or {@code null}
	 */
	String @Nullable [] getCiphers();

	/**
	 * Return the protocols that should be enabled or {@code null}. The protocols names in
	 * this set should be compatible with those supported by
	 * {@link SSLEngine#getSupportedProtocols()}.
	 * @return the protocols to enable or {@code null}
	 */
	String @Nullable [] getEnabledProtocols();

	/**
	 * Factory method to create a new {@link SslOptions} instance.
	 * @param ciphers the ciphers
	 * @param enabledProtocols the enabled protocols
	 * @return a new {@link SslOptions} instance
	 */
	static SslOptions of(String @Nullable [] ciphers, String @Nullable [] enabledProtocols) {
		return new SslOptions() {

			@Override
			public String @Nullable [] getCiphers() {
				return ciphers;
			}

			@Override
			public String @Nullable [] getEnabledProtocols() {
				return enabledProtocols;
			}

			@Override
			public String toString() {
				ToStringCreator creator = new ToStringCreator(this);
				creator.append("ciphers", ciphers);
				creator.append("enabledProtocols", enabledProtocols);
				return creator.toString();
			}

		};
	}

	/**
	 * Factory method to create a new {@link SslOptions} instance.
	 * @param ciphers the ciphers
	 * @param enabledProtocols the enabled protocols
	 * @return a new {@link SslOptions} instance
	 */
	static SslOptions of(@Nullable Set<String> ciphers, @Nullable Set<String> enabledProtocols) {
		return of(toArray(ciphers), toArray(enabledProtocols));
	}

	/**
	 * Helper method that provides a null-safe way to convert a {@code String[]} to a
	 * {@link Collection} for client libraries to use.
	 * @param array the array to convert
	 * @return a collection or {@code null}
	 */
	static @Nullable Set<String> asSet(String @Nullable [] array) {
		return (array != null) ? Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(array))) : null;
	}

	private static String @Nullable [] toArray(@Nullable Collection<String> collection) {
		return (collection != null) ? collection.toArray(String[]::new) : null;
	}

}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free