private function CreateServiceTA($service)
	{
		//Creating TRA
		$TRA = new SimpleXMLElement(
		'<?xml version="1.0" encoding="UTF-8"?>' .
		'<loginTicketRequest version="1.0">'.
		'</loginTicketRequest>');
		$TRA->addChild('header');
		$TRA->header->addChild('uniqueId',date('U'));
		$TRA->header->addChild('generationTime',date('c',date('U')-600));
		$TRA->header->addChild('expirationTime',date('c',date('U')+600));
		$TRA->addChild('service',$service);
		$TRA->asXML($this->TA_FOLDER.'TRA-'.$this->options['CUIT'].'-'.$service.'.xml');

		//Signing TRA
		$STATUS = openssl_pkcs7_sign($this->TA_FOLDER."TRA-".$this->options['CUIT'].'-'.$service.".xml", $this->TA_FOLDER."TRA-".$this->options['CUIT'].'-'.$service.".tmp", "file://".$this->CERT,
			array("file://".$this->PRIVATEKEY, $this->PASSPHRASE),
			array(),
			!PKCS7_DETACHED
		);
		if (!$STATUS) {return FALSE;}
		$inf = fopen($this->TA_FOLDER."TRA-".$this->options['CUIT'].'-'.$service.".tmp", "r");
		$i = 0;
		$CMS="";
		while (!feof($inf)) {
			$buffer=fgets($inf);
			if ( $i++ >= 4 ) {$CMS.=$buffer;}
		}
		fclose($inf);
		unlink($this->TA_FOLDER."TRA-".$this->options['CUIT'].'-'.$service.".xml");
		unlink($this->TA_FOLDER."TRA-".$this->options['CUIT'].'-'.$service.".tmp");

		//Request TA to WSAA
		$client = new SoapClient($this->WSAA_WSDL, array(
		'soap_version'   => SOAP_1_2,
		'location'       => $this->WSAA_URL,
		'trace'          => 1,
		'exceptions'     => 0
		)); 
		$results=$client->loginCms(array('in0'=>$CMS));
		if (is_soap_fault($results)) 
			throw new Exception("SOAP Fault: ".$results->faultcode."\n".$results->faultstring."\n", 4);

		$TA = $results->loginCmsReturn;

		if (file_put_contents($this->TA_FOLDER.'TA-'.$this->options['CUIT'].'-'.$service.'.xml', $TA)) 
			return TRUE;
		else
			throw new Exception('Error writing "TA-'.$this->options['CUIT'].'-'.$service.'.xml"', 5);
	}
private function CreateServiceTA($service)
	{
		//Creating TRA
		$TRA = new SimpleXMLElement(
		'<?xml version="1.0" encoding="UTF-8"?>' .
		'<loginTicketRequest version="1.0">'.
		'</loginTicketRequest>');
		$TRA->addChild('header');
		$TRA->header->addChild('uniqueId',date('U'));
		$TRA->header->addChild('generationTime',date('c',date('U')-600));
		$TRA->header->addChild('expirationTime',date('c',date('U')+600));
		$TRA->addChild('service',$service);
		$TRA->asXML($this->TA_FOLDER.'TRA-'.$this->options['CUIT'].'-'.$service.'.xml');

		//Signing TRA
		$STATUS = openssl_pkcs7_sign($this->TA_FOLDER."TRA-".$this->options['CUIT'].'-'.$service.".xml", $this->TA_FOLDER."TRA-".$this->options['CUIT'].'-'.$service.".tmp", "file://".$this->CERT,
			array("file://".$this->PRIVATEKEY, $this->PASSPHRASE),
			array(),
			!PKCS7_DETACHED
		);
		if (!$STATUS) {return FALSE;}
		$inf = fopen($this->TA_FOLDER."TRA-".$this->options['CUIT'].'-'.$service.".tmp", "r");
		$i = 0;
		$CMS="";
		while (!feof($inf)) {
			$buffer=fgets($inf);
			if ( $i++ >= 4 ) {$CMS.=$buffer;}
		}
		fclose($inf);
		unlink($this->TA_FOLDER."TRA-".$this->options['CUIT'].'-'.$service.".xml");
		unlink($this->TA_FOLDER."TRA-".$this->options['CUIT'].'-'.$service.".tmp");

		//Request TA to WSAA
		$client = new SoapClient($this->WSAA_WSDL, array(
		'soap_version'   => SOAP_1_2,
		'location'       => $this->WSAA_URL,
		'trace'          => 1,
		'exceptions'     => 0
		)); 
		$results=$client->loginCms(array('in0'=>$CMS));
		if (is_soap_fault($results)) 
			throw new Exception("SOAP Fault: ".$results->faultcode."\n".$results->faultstring."\n", 4);

		$TA = $results->loginCmsReturn;

		if (file_put_contents($this->TA_FOLDER.'TA-'.$this->options['CUIT'].'-'.$service.'.xml', $TA)) 
			return TRUE;
		else
			throw new Exception('Error writing "TA-'.$this->options['CUIT'].'-'.$service.'.xml"', 5);
	}
private function CreateServiceTA ( $ service ) { //Creating TRA $ TRA = new SimpleXMLElement ( '<?xml version="1.0" encoding="UTF-8"?>' . '<loginTicketRequest version="1.0">' . '</loginTicketRequest>' ) ; $ TRA -> addChild ( 'header' ) ; $ TRA -> header -> addChild ( 'uniqueId' , date ( 'U' ) ) ; $ TRA -> header -> addChild ( 'generationTime' , date ( 'c' , date ( 'U' ) - 600 ) ) ; $ TRA -> header -> addChild ( 'expirationTime' , date ( 'c' , date ( 'U' ) + 600 ) ) ; $ TRA -> addChild ( 'service' , $ service ) ; $ TRA -> asXML ( $ this -> TA_FOLDER . 'TRA-' . $ this -> options [ 'CUIT' ] . '-' . $ service . '.xml' ) ; //Signing TRA $ STATUS = openssl_pkcs7_sign ( $ this -> TA_FOLDER . "TRA-" . $ this -> options [ 'CUIT' ] . '-' . $ service . ".xml" , $ this -> TA_FOLDER . "TRA-" . $ this -> options [ 'CUIT' ] . '-' . $ service . ".tmp" , "file://" . $ this -> CERT , array ( "file://" . $ this -> PRIVATEKEY , $ this -> PASSPHRASE ) , array ( ) , ! PKCS7_DETACHED ) ; if ( ! $ STATUS ) { return FALSE ; } $ inf = fopen ( $ this -> TA_FOLDER . "TRA-" . $ this -> options [ 'CUIT' ] . '-' . $ service . ".tmp" , "r" ) ; $ i = 0 ; $ CMS = "" ; while ( ! feof ( $ inf ) ) { $ buffer = fgets ( $ inf ) ; if ( $ i ++ >= 4 ) { $ CMS .= $ buffer ; } } fclose ( $ inf ) ; unlink ( $ this -> TA_FOLDER . "TRA-" . $ this -> options [ 'CUIT' ] . '-' . $ service . ".xml" ) ; unlink ( $ this -> TA_FOLDER . "TRA-" . $ this -> options [ 'CUIT' ] . '-' . $ service . ".tmp" ) ; //Request TA to WSAA $ client = new SoapClient ( $ this -> WSAA_WSDL , array ( 'soap_version' => SOAP_1_2 , 'location' => $ this -> WSAA_URL , 'trace' => 1 , 'exceptions' => 0 ) ) ; $ results = $ client -> loginCms ( array ( 'in0' => $ CMS ) ) ; if ( is_soap_fault ( $ results ) ) throw new Exception ( "SOAP Fault: " . $ results -> faultcode . "\n" . $ results -> faultstring . "\n" , 4 ) ; $ TA = $ results -> loginCmsReturn ; if ( file_put_contents ( $ this -> TA_FOLDER . 'TA-' . $ this -> options [ 'CUIT' ] . '-' . $ service . '.xml' , $ TA ) ) return TRUE ; else throw new Exception ( 'Error writing "TA-' . $ this -> options [ 'CUIT' ] . '-' . $ service . '.xml"' , 5 ) ; }
Create an TA from WSAA

Request to WSAA for a tokent authorization for service and save this
in a xml file

@since 0.1

@param string $service Service for token authorization

@throws Exception if an error occurs creating token authorization

@return true if token authorization is created success
Create an TA from WSAA