public AfpResultCode Process(IAfpSession session, DsiHeader dsiHeader, AfpStream requestStream, AfpStream responseStream)
        {
            UserFlags flags = requestStream.ReadEnum<UserFlags>();
            int? userId = null;

            //if (flags != UserFlags.ThisUser) {
                userId = requestStream.ReadInt32();
               // }

            UserBitmap bitmap = requestStream.ReadEnum<UserBitmap>();

            responseStream.WriteEnum(bitmap);

            foreach (UserBitmap value in bitmap.EnumerateFlags()) {
                switch (value) {
                    case UserBitmap.UserId:
                        responseStream.WriteInt32(0);
                        break;
                    case UserBitmap.Uuid:
                        responseStream.WriteBytes(new byte[16]);
                        break;
                    case UserBitmap.PrimaryGroupId:
                        responseStream.WriteInt32(0);
                        break;
                }
            }

            return AfpResultCode.FPNoErr;
        }
Exemple #2
0
        public AfpResultCode Process(IAfpSession session, DsiHeader dsiHeader, AfpStream requestStream, AfpStream responseStream)
        {
            UserFlags flags  = requestStream.ReadEnum <UserFlags>();
            int?      userId = null;

            //if (flags != UserFlags.ThisUser) {
            userId = requestStream.ReadInt32();
            // }

            UserBitmap bitmap = requestStream.ReadEnum <UserBitmap>();

            responseStream.WriteEnum(bitmap);

            foreach (UserBitmap value in bitmap.EnumerateFlags())
            {
                switch (value)
                {
                case UserBitmap.UserId:
                    responseStream.WriteInt32(0);
                    break;

                case UserBitmap.Uuid:
                    responseStream.WriteBytes(new byte[16]);
                    break;

                case UserBitmap.PrimaryGroupId:
                    responseStream.WriteInt32(0);
                    break;
                }
            }

            return(AfpResultCode.FPNoErr);
        }
        public AfpResultCode Process(IAfpSession session, DsiHeader dsiHeader, AfpStream requestStream, AfpStream responseStream)
        {
            requestStream.ReadUInt8(); // Pad

            AfpSessionTokenTypes type = requestStream.ReadEnum<AfpSessionTokenTypes>();
            int idLength = requestStream.ReadInt32();
            int? timestamp = null;

            if (type == AfpSessionTokenTypes.kLoginWithTimeAndID ||
                type == AfpSessionTokenTypes.kReconnWithTimeAndID) {
                timestamp = requestStream.ReadInt32();
            }

            Guid clientToken = new Guid(requestStream.ReadBytes((uint)idLength));

            switch (type) {
                case AfpSessionTokenTypes.kLoginWithID: {
                        // Find existing session and disconnect it.
                        IAfpSession existingSession = session.Server.FindSession(clientToken, AfpSessionSearchType.ClientIssued);

                        if (existingSession != null) {
                            existingSession.Close();
                        }

                        break;
                    }
                case AfpSessionTokenTypes.kLoginWithTimeAndID: {
                        if (!timestamp.HasValue) {
                            return AfpResultCode.FPParamErr;
                        }

                        // Find an existing session.
                        IAfpSession existingSession = session.Server.FindSession(clientToken, AfpSessionSearchType.ClientIssued);

                        if (existingSession != null && existingSession != session) {
                            // Existing session found, transfer resources if timestamp matches.
                            if (!existingSession.Timestamp.HasValue || existingSession.Timestamp.Value != timestamp.Value) {
                                // Timestamp is different, close old session.
                                existingSession.Close();
                            }
                        }

                        break;
                    }
            }

            session.Timestamp = timestamp;
            session.ClientToken = clientToken;
            session.ServerToken = Guid.NewGuid();

            byte[] token = session.ServerToken.Value.ToByteArray();

            responseStream.WriteInt32(token.Length);
            responseStream.WriteBytes(token);

            return AfpResultCode.FPNoErr;
        }
        public AfpResultCode Process(IAfpSession session, DsiHeader dsiHeader, AfpStream requestStream, AfpStream responseStream)
        {
            requestStream.ReadUInt8(); // Pad

            AfpSessionTokenTypes type = requestStream.ReadEnum <AfpSessionTokenTypes>();
            int idLength  = requestStream.ReadInt32();
            int?timestamp = null;

            if (type == AfpSessionTokenTypes.kLoginWithTimeAndID ||
                type == AfpSessionTokenTypes.kReconnWithTimeAndID)
            {
                timestamp = requestStream.ReadInt32();
            }

            Guid clientToken = new Guid(requestStream.ReadBytes((uint)idLength));

            switch (type)
            {
            case AfpSessionTokenTypes.kLoginWithID: {
                // Find existing session and disconnect it.
                IAfpSession existingSession = session.Server.FindSession(clientToken, AfpSessionSearchType.ClientIssued);

                if (existingSession != null)
                {
                    existingSession.Close();
                }

                break;
            }

            case AfpSessionTokenTypes.kLoginWithTimeAndID: {
                if (!timestamp.HasValue)
                {
                    return(AfpResultCode.FPParamErr);
                }

                // Find an existing session.
                IAfpSession existingSession = session.Server.FindSession(clientToken, AfpSessionSearchType.ClientIssued);

                if (existingSession != null && existingSession != session)
                {
                    // Existing session found, transfer resources if timestamp matches.
                    if (!existingSession.Timestamp.HasValue || existingSession.Timestamp.Value != timestamp.Value)
                    {
                        // Timestamp is different, close old session.
                        existingSession.Close();
                    }
                }

                break;
            }
            }

            session.Timestamp   = timestamp;
            session.ClientToken = clientToken;
            session.ServerToken = Guid.NewGuid();

            byte[] token = session.ServerToken.Value.ToByteArray();

            responseStream.WriteInt32(token.Length);
            responseStream.WriteBytes(token);

            return(AfpResultCode.FPNoErr);
        }