Ejemplo n.º 1
0
        public static object CreateSampleRequest(EppQueueCommands command, string domainName = "DOMAIN_NAME.TLD")
        {
            switch (command)
            {
            case EppQueueCommands.Login:
            {
                return(new ReqEmpty());
            }

            case EppQueueCommands.Logout:
            {
                return(new ReqEmpty());
            }

            case EppQueueCommands.Hello:
            {
                return(new ReqEmpty());
            }

            case EppQueueCommands.DomainCheck:
            {
                var req = new ReqDomainCheck(new List <string>()
                    {
                        domainName
                    });
                req.ExtLaunch = new Protocol.Launch.checkType()
                {
                    phase = new Protocol.Launch.phaseType()
                    {
                        Value = Protocol.Launch.phaseTypeValue.claims
                    }
                };
                SetVeriSignNameStoreExtension(domainName, req);
                req.ExtPremiumDomain = new Protocol.PremiumDomain.chkType()
                {
                    flag = true
                };
                req.ExtFee05 = new fee05.checkType()
                {
                    domain = new List <fee05.domainCheckType>()
                    {
                        new fee05.domainCheckType()
                        {
                            command = new fee05.commandType()
                            {
                                phase = "sunrise", Value = "create"
                            }, currency = "USD", name = domainName, period = new fee05.periodType()
                            {
                                unit = fee05.pUnitType.y, Value = 1
                            }
                        }
                    }
                };
                req.ExtFee06 = new fee06.checkType()
                {
                    domain = new List <fee06.domainCheckType>()
                    {
                        new fee06.domainCheckType()
                        {
                            command = new fee06.commandType()
                            {
                                phase = "sunrise", Value = "create"
                            }, currency = "USD", name = domainName, period = new fee06.periodType()
                            {
                                unit = fee06.pUnitType.y, Value = 1
                            }
                        }
                    }
                };
                req.ExtFee07 = new fee07.checkType()
                {
                    domain = new List <fee07.domainCheckType>()
                    {
                        new fee07.domainCheckType()
                        {
                            command = new fee07.commandType()
                            {
                                phase = "sunrise", Value = "create"
                            }, currency = "USD", name = domainName, period = new fee07.periodType()
                            {
                                unit = fee07.pUnitType.y, Value = 1
                            }
                        }
                    }
                };
                return(req);
            }

            case EppQueueCommands.DomainDelete:
            {
                var req = new ReqDomainDelete(domainName);
                SetVeriSignNameStoreExtension(domainName, req);
                return(req);
            }

            case EppQueueCommands.DomainRenew:
            {
                var req = new ReqDomainRenew(domainName, DateTime.Now.AddMonths(1), new DomainPeriod(DomainPeriod.PeriodUnits.Year, 1));
                SetVeriSignNameStoreExtension(domainName, req);
                return(req);
            }

            case EppQueueCommands.DomainInfo:
            {
                var req = new ReqDomainInfo(domainName, new AuthInfo("PASSWORD"));
                SetVeriSignNameStoreExtension(domainName, req);
                req.ExtLaunch = new Protocol.Launch.infoType()
                {
                    phase = new Protocol.Launch.phaseType()
                    {
                        Value = Protocol.Launch.phaseTypeValue.sunrise
                    }, includeMark = false
                };
                return(req);
            }

            case EppQueueCommands.DomainUpdate:
            {
                ReqDomainUpdate hArgs = new ReqDomainUpdate(domainName);

                hArgs.Rem             = new DomainAddRemType();
                hArgs.Rem.NameServers = new NameServerList();

                foreach (string s in new[] { "ns1.isimtescil.net", "ns2.isimtescil.net" })
                {
                    hArgs.Rem.NameServers.Add(new NameServerInfo(s));
                }

                hArgs.Add             = new DomainAddRemType();
                hArgs.Add.NameServers = new NameServerList();

                foreach (string s in new[] { "ns1.isimtescil.net", "ns2.isimtescil.net" })
                {
                    hArgs.Add.NameServers.Add(new NameServerInfo(s));
                }

                List <DomainContactInfo> addContacts = new List <DomainContactInfo>();
                List <DomainContactInfo> remContacts = new List <DomainContactInfo>();

                addContacts.Add(new DomainContactInfo("ADMIN_CONTACT_ID", DomainContactInfo.ContactType.Admin));

                addContacts.Add(new DomainContactInfo("BILL_CONTACT_ID", DomainContactInfo.ContactType.Billing));

                addContacts.Add(new DomainContactInfo("TECH_CONTACT_ID", DomainContactInfo.ContactType.Tech));

                hArgs.Add.Contacts = addContacts;
                if (hArgs.Rem != null)
                {
                    hArgs.Rem.Contacts = remContacts;
                }

                hArgs.Chg = new DomainChangeType("registrantID");

                SetVeriSignNameStoreExtension(domainName, hArgs);
                hArgs.ExtLaunch = new Protocol.Launch.idContainerType()
                {
                    phase = new Protocol.Launch.phaseType()
                    {
                        Value = Protocol.Launch.phaseTypeValue.sunrise
                    }
                };
                hArgs.ExtPremiumDomain = new Protocol.PremiumDomain.reassignType()
                {
                    shortName = "shortname"
                };
                hArgs.ExtRgp = new Protocol.Rgp.updateType()
                {
                    restore = new Protocol.Rgp.restoreType()
                    {
                        op = Protocol.Rgp.rgpOpType.request
                    }
                };
                hArgs.ExtKeySys = new Protocol.KeySys.updateType()
                {
                    domain = new Protocol.KeySys.domainType()
                    {
                        renewalmode = "AUTOEXPIRE"
                    }
                };

                return(hArgs);
            }

            case EppQueueCommands.DomainCreate:
            {
                //Get ContactId's
                string adminContactId  = "ADMIN_CONTACT_ID";
                string techContacId    = "TECH_CONTACT_ID";
                string billingContacId = "BILL_CONTACT_ID";

                ReqDomainCreate dArgs = new ReqDomainCreate(domainName, new AuthInfo("AUTH_PASSWORD"))
                {
                    NameServers = new NameServerList(new List <NameServerInfo>()
                        {
                            new NameServerInfo("ns1.isimtescil.net"), new NameServerInfo("ns2.isimtescil.net")
                        }),
                    RegistrationPeriod = new DomainPeriod(DomainPeriod.PeriodUnits.Year, 1),
                    Registrant         = "OWNER_CONTACT_ID",
                    Contacts           = new List <DomainContactInfo>()
                    {
                        new DomainContactInfo(adminContactId, DomainContactInfo.ContactType.Admin),
                        new DomainContactInfo(techContacId, DomainContactInfo.ContactType.Tech),
                        new DomainContactInfo(billingContacId, DomainContactInfo.ContactType.Billing)
                    }
                };

                SetVeriSignNameStoreExtension(domainName, dArgs);
                dArgs.ExtLaunch = new Protocol.Launch.createType()
                {
                    type  = Protocol.Launch.objectType.registration,
                    phase = new Protocol.Launch.phaseType()
                    {
                        Value = Protocol.Launch.phaseTypeValue.sunrise
                    },
                    notice = new Protocol.Launch.createNoticeType()
                    {
                        acceptedDate = DateTime.Now.AddDays(-30)
                    }
                };

                return(dArgs);
            }

            case EppQueueCommands.DomainTransferRequest:
            {
                var req = new ReqDomainTransferRequest()
                {
                    AuthInfo = new AuthInfo("PASSWORD"), DomainName = domainName, Period = new DomainPeriod(DomainPeriod.PeriodUnits.Year, 1)
                };
                SetVeriSignNameStoreExtension(domainName, req);
                return(req);
            }

            case EppQueueCommands.DomainTransferQuery:
            {
                var req = new ReqDomainTransferQuery()
                {
                    AuthInfo = new AuthInfo("PASSWORD"), DomainName = domainName, Period = new DomainPeriod(DomainPeriod.PeriodUnits.Year, 1)
                };
                SetVeriSignNameStoreExtension(domainName, req);
                return(req);
            }

            case EppQueueCommands.DomainTransferCancel:
            {
                var req = new ReqDomainTransferCancel()
                {
                    AuthInfo = new AuthInfo("PASSWORD"), DomainName = domainName, Period = new DomainPeriod(DomainPeriod.PeriodUnits.Year, 1)
                };
                SetVeriSignNameStoreExtension(domainName, req);
                return(req);
            }

            case EppQueueCommands.DomainTransferApprove:
            {
                var req = new ReqDomainTransferApprove()
                {
                    AuthInfo = new AuthInfo("PASSWORD"), DomainName = domainName, Period = new DomainPeriod(DomainPeriod.PeriodUnits.Year, 1)
                };
                SetVeriSignNameStoreExtension(domainName, req);
                return(req);
            }

            case EppQueueCommands.DomainTransferReject:
            {
                var req = new ReqDomainTransferReject()
                {
                    AuthInfo = new AuthInfo("PASSWORD"), DomainName = domainName, Period = new DomainPeriod(DomainPeriod.PeriodUnits.Year, 1)
                };
                SetVeriSignNameStoreExtension(domainName, req);
                return(req);
            }

            case EppQueueCommands.ContactCheck:
            {
                return(new ReqContactCheck(new List <string>()
                    {
                        "CONTACT_ID"
                    })
                    {
                        DomainName = domainName
                    });
            }

            case EppQueueCommands.ContactCreate:
            {
                return(new ReqContactCreate("CONTACT_ID",
                                            new List <PostalInfo>()
                    {
                        new PostalInfo(
                            "NAME",
                            PostalInfo.PostalType.Int,
                            new AddressInfo("CITY", "COUNTRY_CODE")
                        {
                            PostalCode = "POSTAL_CODE", Streets = new List <string>()
                            {
                                "STREET_LINE_1", "STREET_LINE_1"
                            }
                        })
                    }
                                            ,
                                            "*****@*****.**",
                                            null)
                    {
                        Fax = "FAX",
                        Voice = new VoiceInfo("PHONE"),
                        AuthInfo = new AuthInfo("PASSWORD"),
                        DomainName = domainName
                    }
                       );
            }

            case EppQueueCommands.ContactDelete:
            {
                return(new ReqContactDelete("CONTACT_ID")
                    {
                        DomainName = domainName
                    });
            }

            case EppQueueCommands.ContactUpdate:
            {
                ReqContactUpdate h = new ReqContactUpdate("CONTACT_ID")
                {
                    DomainName = domainName
                };
                h.Chg = new ContactChangeType();

                //email degiscek mi
                h.Chg.Email = "*****@*****.**";
                h.Chg.Fax   = "FAX";
                h.Chg.Voice = new VoiceInfo("PHONE");

                h.Chg.PostalInfos = new List <PostalInfo>()
                {
                    new PostalInfo(
                        "NAME",
                        PostalInfo.PostalType.Int,
                        new AddressInfo("CITY", "COUNTRY_CODE")
                        {
                            PostalCode = "POSTAL_CODE", Streets = new List <string>()
                            {
                                "STREET_LINE_1", "STREET_LINE_1"
                            }
                        })
                };

                return(h);
            }

            case EppQueueCommands.ContactInfo:
            {
                return(new ReqContactInfo("CONTACT_ID", new AuthInfo("PASSWORD"))
                    {
                        DomainName = domainName
                    });
            }

            case EppQueueCommands.ContactTransferRequest:
            {
                return(new ReqContactTransferRequest()
                    {
                        AuthInfo = new AuthInfo("PASSWORD"), DomainName = domainName, Id = "CONTACT_ID"
                    });
            }

            case EppQueueCommands.ContactTransferQuery:
            {
                return(new ReqContactTransferQuery()
                    {
                        AuthInfo = new AuthInfo("PASSWORD"), DomainName = domainName, Id = "CONTACT_ID"
                    });
            }

            case EppQueueCommands.ContactTransferCancel:
            {
                return(new ReqContactTransferCancel()
                    {
                        AuthInfo = new AuthInfo("PASSWORD"), DomainName = domainName, Id = "CONTACT_ID"
                    });
            }

            case EppQueueCommands.ContactTransferApprove:
            {
                return(new ReqContactTransferApprove()
                    {
                        AuthInfo = new AuthInfo("PASSWORD"), DomainName = domainName, Id = "CONTACT_ID"
                    });
            }

            case EppQueueCommands.ContactTransferReject:
            {
                return(new ReqContactTransferReject()
                    {
                        AuthInfo = new AuthInfo("PASSWORD"), DomainName = domainName, Id = "CONTACT_ID"
                    });
            }

            case EppQueueCommands.HostCheck:
            {
                return(new ReqHostCheck(new List <string>()
                    {
                        "HOST_NAME"
                    })
                    {
                        DomainName = domainName
                    });
            }

            case EppQueueCommands.HostCreate:
            {
                return(new ReqHostCreate("HOST_NAME", new[] { "IP1", "IP2" }.Select(x => new IpAddress(x)).ToList())
                    {
                        DomainName = domainName
                    });
            }

            case EppQueueCommands.HostDelete:
            {
                return(new ReqHostDelete("HOST_NAME")
                    {
                        DomainName = domainName
                    });
            }

            case EppQueueCommands.HostUpdate:
            {
                List <string> addAdress = new List <string>()
                {
                    "add_IP1", "add_IP2"
                };
                List <string> remAdress = new List <string>()
                {
                    "rem_IP1", "rem_IP2"
                };

                ReqHostUpdate hArgs = new ReqHostUpdate("HOST_NAME")
                {
                    DomainName = domainName
                };

                if (addAdress.Count != 0 && !string.IsNullOrEmpty(addAdress[0]))
                {
                    hArgs.Add = new HostAddRemType(addAdress.Select(x => new IpAddress(IpAddress.IpAddressType.V4, x)).ToList());
                }

                if (remAdress.Count != 0 && !string.IsNullOrEmpty(addAdress[0]))
                {
                    hArgs.Rem = new HostAddRemType(remAdress.Select(x => new IpAddress(IpAddress.IpAddressType.V4, x)).ToList());
                }

                hArgs.Chg = "NEW_HOST_NAME";

                return(hArgs);
            }

            case EppQueueCommands.HostInfo:
            {
                return(new ReqHostInfo("HOST_NAME")
                    {
                        DomainName = domainName
                    });
            }

            case EppQueueCommands.FinanceInfo:
            {
                return(new ReqFinanceInfo()
                    {
                        DomainName = domainName
                    });
            }

            case EppQueueCommands.PollRequest:
            {
                return(new ReqPollRequest {
                        DomainName = domainName, ClientTranId = "IdontKnow"
                    });
            }

            case EppQueueCommands.PollAcknowledge:
            {
                return(new ReqPollAcknowledge {
                        DomainName = domainName, MessageId = "MESSAGE_ID"
                    });
            }
            }

            throw new Exception("No such EPP command");
        }
Ejemplo n.º 2
0
 public ResDomainTransfer DomainTransferQuery(ReqDomainTransferQuery req)
 {
     return(Call <ResDomainTransfer, ReqDomainTransferQuery>(req, "DomainTransferQuery"));
 }
Ejemplo n.º 3
0
        private JobStates domainTransferQuery(Job job)
        {
            // according to https://tools.ietf.org/html/rfc5730#page-30

            var orderItem = Provider.Database.Read <OrderItem>("Id={0}", job.RelatedEntityId);
            var member    = orderItem.Order().Member();


            var memberDomain = Provider.Database.Read <MemberDomain>("DomainName={0}", orderItem.DisplayName);

            if (memberDomain == null)
            {
                throw new Exception("Domain transfer process not yet started (first request then query)");
            }

            // Aşağıdaki işlemler RFC 5730 dikkate alınarak yazılmıştır. (https://tools.ietf.org/html/rfc5730#page-35)
            var eppApi = new EppAPI();

            var req = new ReqDomainTransferQuery();

            req.DomainName = memberDomain.DomainName;
            req.AuthInfo   = new Epp.Protocol.Shared.AuthInfo {
                Password = memberDomain.AuthInfo
            };
            req.Period = new DomainPeriod
            {
                Units  = orderItem.ProductPrice().Unit == "years" ? DomainPeriod.PeriodUnits.Year : DomainPeriod.PeriodUnits.Month,
                Period = orderItem.Amount
            };

            var res = eppApi.DomainTransferQuery(req);

            if (res.TransferRequestState.ToLowerInvariant() == memberDomain.TransferState.ToString().ToLowerInvariant())
            {
                return(JobStates.TryAgain);
            }

            switch (res.TransferRequestState.ToLowerInvariant())
            {
            case "clientApproved":
                memberDomain.TransferState = TransferStates.ClientApproved;
                memberDomain.Save();
                return(JobStates.TryAgain);

            case "clientCancelled":
                memberDomain.TransferState = TransferStates.ClientCancelled;
                memberDomain.Save();
                return(JobStates.Canceled);

            case "clientRejected":
                memberDomain.TransferState = TransferStates.ClientRejected;
                memberDomain.Save();
                return(JobStates.Canceled);

            case "pending":
                memberDomain.TransferState = TransferStates.Pending;
                memberDomain.Save();
                return(JobStates.TryAgain);

            case "serverApproved":
                memberDomain.TransferState = TransferStates.ServerApproved;
                memberDomain.Save();
                var memberProduct = Provider.Database.Read <MemberProduct>("Id={0}", memberDomain.Id);
                memberProduct.EndDate = res.ExpireDate.Value;
                memberProduct.Save();
                return(JobStates.Done);

            case "serverCancelled":
                memberDomain.TransferState = TransferStates.ServerCancelled;
                memberDomain.Save();
                return(JobStates.Canceled);

            default:
                memberDomain.TransferState = TransferStates.None;
                memberDomain.Save();
                throw new Exception("Registry returned an unknown transfer status: " + res.TransferRequestState);
            }


            return(JobStates.Failed); // buraya hiç gelmemesi lazım
        }