Пример #1
0
 private bool _shouldNotTransform()
 {
     return(Origin.Contains("Host=") ||
            Origin.Contains("Port=") ||
            Origin.Contains("Database=") ||
            Origin.Contains("Username="******"Password="));
 }
        protected override bool CheckAuthentication(Context context)
        {
            if (context.ReceivedByteCount > 8)
            {
                var handshake =
                    new ClientHandshake(new ArraySegment <byte>(context.Buffer, context.ReceivedByteCount - 8, 8),
                                        context.Header);
                // See if our header had the required information
                if (handshake.IsValid())
                {
                    // Optionally check Origin and Location if they're set.
                    if (!String.IsNullOrEmpty(Origin))
                    {
                        var expectedOrigin = Origin;
                        if (!Origin.Contains("://"))
                        {
                            expectedOrigin = "http://" + Origin;
                        }

                        if (!handshake.Origin.Equals(expectedOrigin, StringComparison.InvariantCultureIgnoreCase))
                        {
                            return(false);
                        }
                    }
                    if (!String.IsNullOrEmpty(Destination))
                    {
                        if (handshake.Host != Destination + ":" + context.Server.Port)
                        {
                            return(false);
                        }
                    }
                    // Generate response handshake for the client
                    var serverShake = GenerateResponseHandshake(handshake, context.Server);
                    // Send the response handshake
                    SendServerHandshake(serverShake, context);
                    return(true);
                }
            }
            return(false);
        }
Пример #3
0
        public IActionResult OnPost()
        {
            PageInit();
            if (ErpEntity == null)
            {
                return(NotFound());
            }

            try
            {
                if (String.IsNullOrWhiteSpace(Origin) || !Origin.Contains("$"))
                {
                    throw new ValidationException("Origin field is required!");
                }
                if (String.IsNullOrWhiteSpace(Target) || !Target.Contains("$"))
                {
                    throw new ValidationException("Target field is required!");
                }
                var  originSections = Origin.Split('$');
                Guid originEntityId = new Guid(originSections[0]);
                Guid originFieldId  = new Guid(originSections[1]);

                var  targetSections = Target.Split('$');
                Guid targetEntityId = new Guid(targetSections[0]);
                Guid targetFieldId  = new Guid(targetSections[1]);

                var            relMan      = new EntityRelationManager();
                EntityRelation newRelation = new EntityRelation
                {
                    Id             = Guid.NewGuid(),
                    Name           = Name,
                    Label          = Name,            //Label, Boz: removed for convinience
                    Description    = "",              //Description, Boz: removed for convinience
                    System         = IsSystem,
                    OriginEntityId = originEntityId,
                    OriginFieldId  = originFieldId,
                    TargetEntityId = targetEntityId,
                    TargetFieldId  = targetFieldId,
                    RelationType   = Type
                };


                var response = relMan.Create(newRelation);
                if (!response.Success)
                {
                    var exception = new ValidationException(response.Message);
                    exception.Errors = response.Errors.MapTo <ValidationError>();
                    throw exception;
                }
                return(Redirect($"/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/l"));
            }
            catch (ValidationException ex)
            {
                Validation.Message = ex.Message;
                Validation.Errors  = ex.Errors;
            }
            catch (Exception ex)
            {
                Validation.Message = ex.Message;
                Validation.Errors.Add(new ValidationError("", ex.Message, isSystem: true));
            }

            ErpRequestContext.PageContext = PageContext;

            BeforeRender();
            return(Page());
        }
Пример #4
0
 public bool Contains(T item)
 {
     lock (Locker) { return(Origin.Contains(item)); }
 }