Location: PHPKode > projects > SimpleSPML > SimpleSPML/lib/msg/password/ValidatePasswordResponse.php
<?php
require_once "lib/msg/core/Response.php";

/*
<complexType name = "ValidatePasswordResponseType">
        <complexContent>
        <extension base = "spml:ResponseType">
            <attribute name = "valid" type = "boolean" use = "optional"/>
        </extension>
    </complexContent>
</complexType>
*/

/**
 * ValidatePasswordResponse
 * 
 * Provider response to a ValidatePasswordRequest message
 * 
 * @package SimpleSPML
 * @author Alessandra Bozzo <hide@address.com>
 */
class ValidatePasswordResponse extends Response
{
    /**
	 * Indicates whether the <password> (content that
	 * was specified in the <validatePasswordRequest>)
	 * would be valid as the password that is associated
	 * with the specified object
	 * 
	 * @access protected
	 * @var XsdBoolean
	 */
    protected $valid = null;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->setBaseAttributes("valid");
    }
    
    /**
     * Return valid value
     * @access public
     * @return XsdBoolean
     */
    public function __getValid()
    {
        return $this->valid;
    }
    
    /**
     * Sets the value of valid
     * @access public
     * @param boolean $valid 
     */
    public function __setValid($valid)
    {
        if($valid)
        {
            try
            {
                $this->valid = new XsdBoolean($valid);
            }
                
            catch(Exception $e)
            {
                throw new WrongTypeException(get_class($this) . "::valid");
            }    
        }
    }
    
    /**
     * Return an array of string attributes
     * @access protected
     * @return array(string)
     */
    protected function attributesToString()
    {
        $attributes = array();
        
        if($this->valid)
            $attributes["valid"] = $this->valid->toString();
                
        return array_merge(parent::attributesToString(), $attributes);    
    }
    
    /**
     * Read the SPML message
     * @access public
     * @param SimpleXMLIterator $obj
     */
    public function readMessage($obj)
    {
        $this->checkNamespace($obj, "urn:oasis:names:tc:SPML:2:0");
        
        // Load attributes
        $this->readAttribute($obj, "valid");
        
        parent::readMessage($obj);
        
        if(!$this->isValid())
            throw new InvalidMessageException(get_class($this));
    }
    
    /**
     * Write the SPML message
     * @access public
     * @param int $level
     * @return string
     */
    public function writeMessage($level = 0)
    {
        if(!$this->isValid())
            throw new InvalidObjectException(get_class($this));
        
        $ind = $this->indentation($level);
        
        $spmlstr = $ind . '<validatePasswordResponse xmlns="urn:oasis:names:tc:SPML:2:0"';
        
        // write validatePasswordResponse attributes
        $spmlstr .= $this->writeAttributes();
                
        // write parent elements
        $spmlmidstr = parent::writeMessage($level + 1);
        
        return $this->tagCloser("validatePasswordResponse", $spmlstr, $spmlmidstr, $ind);
    }
}
?>
Return current item: SimpleSPML