コード例 #1
0
ファイル: HostingAPI.cs プロジェクト: fizikci/DomainMarketing
        public ReturnMethod DeleteDomain(ReqDomainInfo domainInfo)
        {
            var req = new ReqDomainInfo()
            {
                ServiceSettings = domainInfo.ServiceSettings, MemberId = memberId, DomainInfo = domainInfo.DomainInfo
            };

            return(this.Call <ReturnMethod, ReqDomainInfo>(req, "DeleteDomain"));
        }
コード例 #2
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");
        }
コード例 #3
0
ファイル: EppAPI.cs プロジェクト: fizikci/DomainMarketing
 public ResDomainInfo DomainInfo(ReqDomainInfo req)
 {
     return(Call <ResDomainInfo, ReqDomainInfo>(req, "DomainInfo"));
 }
コード例 #4
0
        private JobStates domainRestore(Job job)
        {
            // according to https://tools.ietf.org/html/rfc3915

            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("MemberDomain record not found. If a domain name is not in our database, cannot be restored.");
            }

            var eppApi = new EppAPI();

            var req = new ReqDomainInfo();

            req.DomainName = memberDomain.DomainName;

            var res = eppApi.DomainInfo(req);

            // eğer domain state OK ise restore işlemi tamamlanmıştır
            if (res.Statuses.FirstOrDefault(s => s.Status == Epp.Protocol.Shared.Status.Ok) != null)
            {
                var memberProduct = Provider.Database.Read <MemberProduct>("Id={0}", memberDomain.Id);
                if (memberProduct == null)
                {
                    //null olmaması gerekir ama bir hatadan dolayı null ise hemen create edelim. bi sakınca yok
                    memberProduct = new MemberProduct
                    {
                        StartDate   = res.CreationDate.Value,
                        OrderItemId = job.RelatedEntityId,
                        MemberId    = member.Id,
                    };
                }

                memberProduct.EndDate = res.ExpirationDate.Value;
                memberProduct.Save();

                memberDomain.RegistryStatus = res.Statuses.StringJoin(",");
                memberDomain.RGPStatus      = res.ExtRgp == null ? statusValueType.NONE : res.ExtRgp.rgpStatus.FirstOrDefault().s;

                memberDomain.Save();

                return(JobStates.Done);
            }

            // eğer domain state OK değilse, pendingDelete de değilse, restore'da ne işin var kardeşim?
            if (res.Statuses.FirstOrDefault(s => s.Status == Epp.Protocol.Shared.Status.PendingDelete) == null)
            {
                throw new Exception("A domain with no pendingDelete status cannot be restored.");
            }

            // eğer domain redemptionPeriod'da ise, restore request komutunu göndeririz
            if (res.ExtRgp.rgpStatus.FirstOrDefault(s => s.s == statusValueType.redemptionPeriod) != null)
            {
                var reqRestore = new ReqDomainUpdate
                {
                    DomainName = memberDomain.DomainName,
                    ExtRgp     = new DealerSafe.DTO.Epp.Protocol.Rgp.updateType
                    {
                        restore = new DealerSafe.DTO.Epp.Protocol.Rgp.restoreType
                        {
                            op = DealerSafe.DTO.Epp.Protocol.Rgp.rgpOpType.request
                        }
                    }
                };

                var resRestore = eppApi.DomainUpdate(reqRestore);

                job.StartDate = Provider.Database.Now.AddMinutes(10);

                return(JobStates.TryAgain);
            }

            // eğer domain pendingRestore'da ise, restore report komutunu göndeririz
            if (res.ExtRgp.rgpStatus.FirstOrDefault(s => s.s == statusValueType.pendingRestore) != null)
            {
                var reqReport = new ReqDomainUpdate
                {
                    DomainName = memberDomain.DomainName,
                    ExtRgp     = new DealerSafe.DTO.Epp.Protocol.Rgp.updateType
                    {
                        restore = new DealerSafe.DTO.Epp.Protocol.Rgp.restoreType
                        {
                            op = DealerSafe.DTO.Epp.Protocol.Rgp.rgpOpType.report
                        }
                    }
                };

                var resRestore = eppApi.DomainUpdate(reqReport);

                job.StartDate = Provider.Database.Now.AddMinutes(10);

                return(JobStates.TryAgain);
            }

            job.StartDate = Provider.Database.Now.AddMinutes(10);
            return(JobStates.TryAgain);
        }