Add ability to set attributes on a SslContext (#9654)

Motivation:

Sometimes it is useful to be able to set attributes on a SslContext.

Modifications:

Add new method that will return a AttributeMap that is tied to a SslContext instance

Result:

Fixes https://github.com/netty/netty/issues/6542.
This commit is contained in:
Norman Maurer 2019-10-22 06:39:43 -07:00
parent d71661ff88
commit 7d767d08f5

View File

@ -24,6 +24,8 @@ import io.netty.channel.ChannelPipeline;
import io.netty.handler.ssl.ApplicationProtocolConfig.Protocol; import io.netty.handler.ssl.ApplicationProtocolConfig.Protocol;
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectedListenerFailureBehavior; import io.netty.handler.ssl.ApplicationProtocolConfig.SelectedListenerFailureBehavior;
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectorFailureBehavior; import io.netty.handler.ssl.ApplicationProtocolConfig.SelectorFailureBehavior;
import io.netty.util.AttributeMap;
import io.netty.util.DefaultAttributeMap;
import io.netty.util.internal.EmptyArrays; import io.netty.util.internal.EmptyArrays;
import java.security.Provider; import java.security.Provider;
@ -97,6 +99,7 @@ public abstract class SslContext {
} }
private final boolean startTls; private final boolean startTls;
private final AttributeMap attributes = new DefaultAttributeMap();
/** /**
* Returns the default server-side implementation provider currently in use. * Returns the default server-side implementation provider currently in use.
@ -862,6 +865,13 @@ public abstract class SslContext {
this.startTls = startTls; this.startTls = startTls;
} }
/**
* Returns the {@link AttributeMap} that belongs to this {@link SslContext} .
*/
public final AttributeMap attributes() {
return attributes;
}
/** /**
* Returns {@code true} if and only if this context is for server-side. * Returns {@code true} if and only if this context is for server-side.
*/ */