| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of the php-epp2 library. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * (c) Gunter Grodotzki <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * For the full copyright and license information, please view the LICENSE file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | namespace AfriCC\EPP\Frame\Command\Create; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use AfriCC\EPP\AddrTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use AfriCC\EPP\Frame\Command\Create as CreateCommand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use AfriCC\EPP\ObjectSpec; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use AfriCC\EPP\PeriodTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use AfriCC\EPP\Random; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use AfriCC\EPP\Validator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * @see http://tools.ietf.org/html/rfc5731#section-3.2.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | class Domain extends CreateCommand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     use PeriodTrait, AddrTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     public function setDomain($domain) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         if (!Validator::isHostname($domain)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |             throw new Exception(sprintf('%s is not a valid domain name', $domain)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $this->set('domain:name', $domain); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     public function setPeriod($period) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $this->appendPeriod('domain:period[@unit=\'%s\']', $period); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     public function addHostObj($host) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         if (!Validator::isHostname($host)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             throw new Exception(sprintf('%s is not a valid host name', $host)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $this->set('domain:ns/domain:hostObj[]', $host); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     public function addHostAttr($host, $ips = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->appendHostAttr('domain:ns/domain:hostAttr[%d]', $host, $ips); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     public function setRegistrant($registrant) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $this->set('domain:registrant', $registrant); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     public function setAdminContact($admin_contact) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $this->set('domain:contact[@type=\'admin\']', $admin_contact); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     public function setTechContact($tech_contact) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->set('domain:contact[@type=\'tech\']', $tech_contact); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     public function setBillingContact($billing_contact) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         $this->set('domain:contact[@type=\'billing\']', $billing_contact); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public function setAuthInfo($pw = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         if ($pw === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             $pw = Random::auth(12); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         $this->set('domain:authInfo/domain:pw', $pw); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         return $pw; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      * Add SecDNS dsData - RFC 5910 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      * @param int $keyTag | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * @param int $alg | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * @param int $digestType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * @param string $digest | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 95 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 96 |  |  |     public function addSecDNSdsData($keyTag, $alg, $digestType, $digest) | 
            
                                                        
            
                                    
            
            
                | 97 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 98 |  |  |         $node = $this->set('//epp:epp/epp:command/epp:extension/secDNS:create/secDNS:dsData[]'); | 
            
                                                        
            
                                    
            
            
                | 99 |  |  |         $ns = ObjectSpec::xmlns('secDNS'); | 
            
                                                        
            
                                    
            
            
                | 100 |  |  |         $keyTagNode = $this->createElementNS($ns, 'secDNS:keyTag', $keyTag); | 
            
                                                        
            
                                    
            
            
                | 101 |  |  |         $algNode = $this->createElementNS($ns, 'secDNS:alg', $alg); | 
            
                                                        
            
                                    
            
            
                | 102 |  |  |         $digestTypeNode = $this->createElementNS($ns, 'secDNS:digestType', $digestType); | 
            
                                                        
            
                                    
            
            
                | 103 |  |  |         $digestNode = $this->createElementNS($ns, 'secDNS:digest', $digest); | 
            
                                                        
            
                                    
            
            
                | 104 |  |  |         $node->appendChild($keyTagNode); | 
            
                                                        
            
                                    
            
            
                | 105 |  |  |         $node->appendChild($algNode); | 
            
                                                        
            
                                    
            
            
                | 106 |  |  |         $node->appendChild($digestTypeNode); | 
            
                                                        
            
                                    
            
            
                | 107 |  |  |         $node->appendChild($digestNode); | 
            
                                                        
            
                                    
            
            
                | 108 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 109 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 110 |  |  |  |