Class AuthenticationHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
net.minecraft.server.jsonrpc.security.AuthenticationHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

@Sharable public class AuthenticationHandler extends io.netty.channel.ChannelDuplexHandler
  • Field Details

    • LOGGER

      private final org.slf4j.Logger LOGGER
    • AUTHENTICATED_KEY

      private static final io.netty.util.AttributeKey<Boolean> AUTHENTICATED_KEY
    • ATTR_WEBSOCKET_ALLOWED

      private static final io.netty.util.AttributeKey<Boolean> ATTR_WEBSOCKET_ALLOWED
    • SUBPROTOCOL_VALUE

      private static final String SUBPROTOCOL_VALUE
      See Also:
    • SUBPROTOCOL_HEADER_PREFIX

      private static final String SUBPROTOCOL_HEADER_PREFIX
      See Also:
    • BEARER_PREFIX

      public static final String BEARER_PREFIX
      See Also:
    • securityConfig

      private final SecurityConfig securityConfig
    • allowedOrigins

      private final Set<String> allowedOrigins
  • Constructor Details

    • AuthenticationHandler

      public AuthenticationHandler(SecurityConfig pSecurityConfig, String pAllowedOrigins)
  • Method Details

    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext pContext, Object pRequest) throws Exception
      Specified by:
      channelRead in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception
    • write

      public void write(io.netty.channel.ChannelHandlerContext pContext, Object pMessage, io.netty.channel.ChannelPromise pPromise) throws Exception
      Specified by:
      write in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      write in class io.netty.channel.ChannelDuplexHandler
      Throws:
      Exception
    • performSecurityChecks

      private AuthenticationHandler.SecurityCheckResult performSecurityChecks(io.netty.handler.codec.http.HttpRequest pRequest)
    • isAllowedOriginHeader

      private boolean isAllowedOriginHeader(io.netty.handler.codec.http.HttpRequest pRequest)
    • parseTokenInAuthorizationHeader

      private @Nullable String parseTokenInAuthorizationHeader(io.netty.handler.codec.http.HttpRequest pRequest)
    • parseTokenInSecWebsocketProtocolHeader

      private @Nullable String parseTokenInSecWebsocketProtocolHeader(io.netty.handler.codec.http.HttpRequest pRequest)
    • isValidApiKey

      public boolean isValidApiKey(String pApiKey)
    • getClientIp

      private String getClientIp(io.netty.channel.ChannelHandlerContext pContext)
    • sendUnauthorizedResponse

      private void sendUnauthorizedResponse(io.netty.channel.ChannelHandlerContext pContext, String pMessage)