Beispiel #1
0
        public virtual SaslServer Create(Server.Connection connection, IDictionary <string
                                                                                    , object> saslProperties, SecretManager <TokenIdentifier> secretManager)
        {
            UserGroupInformation ugi = null;
            CallbackHandler      callback;

            switch (authMethod)
            {
            case SaslRpcServer.AuthMethod.Token:
            {
                callback = new SaslRpcServer.SaslDigestCallbackHandler(secretManager, connection);
                break;
            }

            case SaslRpcServer.AuthMethod.Kerberos:
            {
                ugi = UserGroupInformation.GetCurrentUser();
                if (serverId.IsEmpty())
                {
                    throw new AccessControlException("Kerberos principal name does NOT have the expected "
                                                     + "hostname part: " + ugi.GetUserName());
                }
                callback = new SaslRpcServer.SaslGssCallbackHandler();
                break;
            }

            default:
            {
                // we should never be able to get here
                throw new AccessControlException("Server does not support SASL " + authMethod);
            }
            }
            SaslServer saslServer;

            if (ugi != null)
            {
                saslServer = ugi.DoAs(new _PrivilegedExceptionAction_159(this, saslProperties, callback
                                                                         ));
            }
            else
            {
                saslServer = saslFactory.CreateSaslServer(mechanism, protocol, serverId, saslProperties
                                                          , callback);
            }
            if (saslServer == null)
            {
                throw new AccessControlException("Unable to find SASL server implementation for "
                                                 + mechanism);
            }
            if (Log.IsDebugEnabled())
            {
                Log.Debug("Created SASL server with mechanism = " + mechanism);
            }
            return(saslServer);
        }
        public static void CallProcess(string message, Server.Connection connection)
        {
            OnProcess?.Invoke(message, connection);
            PacketBase pkt = StringToPacket(message);

            if (pkt == null)
            {
                return;
            }
            if (tcpProcessors.ContainsKey(pkt.t))
            {
                tcpProcessors[pkt.t]?.Invoke(pkt, connection);
            }
            if (tcpIdProcessors.ContainsKey(connection.NetId))
            {
                tcpIdProcessors[connection.NetId]?.Invoke(pkt, connection);
            }
        }
Beispiel #3
0
 public static void ServerSendPacket(PacketBase pkt, Server.Connection connection)
 {
     connection.Send(PacketToString(pkt));
 }
Beispiel #4
0
 public SaslDigestCallbackHandler(SecretManager <TokenIdentifier> secretManager, Server.Connection
                                  connection)
 {
     this.secretManager = secretManager;
     this.connection    = connection;
 }
Beispiel #5
0
 public void Init(Server.Connection connection)
 {
     this.connection                   = connection;
     NetworkSystem.OnProcess          += (msg, conn) => output?.Invoke(msg);
     NetworkSystem.OnProcessUDPPacket += msg => output?.Invoke(msg.message);
 }
 void IMoveProcess(IMove packet, Server.Connection connection)
 {
     inputVec = packet.input;
     ServerBoardcastPacket(new SiMove(connection.netId, targetPosition, velocityRaw, inputVec));
     connection.Send(new STimer(packet.t));
 }
 public static void CallServerDisconnection(Server.Connection connection) => OnServerDisconnection?.Invoke(connection);