Location: PHPKode > projects > SimpleSPML > SimpleSPML/lib/msg/password/ExpirePasswordRequest.php
<?php
require_once "lib/msg/core/Request.php";
require_once "lib/msg/core/PSOIdentifier.php";

/*
 <complexType name = "ExpirePasswordRequestType">
    <complexContent>
        <extension base = "spml:RequestType">
            <sequence>
                <element name = "psoID" type = "spml:PSOIdentifierType" />
            </sequence>
            <attribute name = "remainingLogins" type = "int" use = "optional" default = "1" />
        </extension>
    </complexContent>
</complexType>
*/

/**
 * ExpirePasswordRequest
 * 
 * A requestor must send a <expirePasswordRequest> to
 * a provider in order to (ask the provider to) mark
 * as no longer valid the password that is associated
 * with an existing object
 * 
 * @package SimpleSPML
 * @author Alessandra Bozzo <hide@address.com>
 */
class ExpirePasswordRequest extends Request
{
    /**
	 * Specifies a number of grace logins that the
	 * target system or application should permit
	 * 
	 * @access protected
	 * @var XsdInt
	 */
    protected $remainingLogins = null;
    
    /**
	 * Object identifier
	 * 
	 * @access protected
	 * @var Core::PSOIdentifier
	 */
    protected $psoID = null;
    
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->setBaseAttributes("remainingLogins");
        $this->setBaseElements("psoID");
        
        $this->remainingLogins = new XsdInt(1);
        
        parent::__construct();
    }
    
    /**
     * Return remainingLogins value
     * @access public
     * @return XsdInt
     */
    public function __getRemainingLogins()
    {
        return $this->remainingLogins;
    }
    
    /**
     * Return psoID value
     * @access public
     * @return Core::PSOIdentifier
     */
    public function __getPsoID()
    {
        return $this->psoID;
    }
    
    /**
     * Sets the value of remainingLogins
     * @access public
     * @param int $remainingLogins 
     */
    public function __setRemainingLogins($remainingLogins)
    {
        if($remainingLogins)
        {
            try
            {
                $this->remainingLogins = new XsdInt($remainingLogins);
            }
            
            catch(Exception $e)
            {
                throw new WrongTypeException(get_class($this) . "::remainingLogins");
            }
        }
    }
    
    /**
     * Sets the value of psoID
     * @access public
     * @param Core::PSOIdentifier $psoID 
     */
    public function __setPsoID($psoID)
    {
        if(!$psoID)
            throw new MissingParameterException(get_class($this) . "::psoID");
            
        if(!($psoID instanceof PSOIdentifier))
            throw new WrongTypeException(get_class($this) . "::psoID");
            
        $this->psoID = $psoID;
    }
    
    /**
     * Return an array of string attributes
     * @access protected
     * @return array(string)
     */
    protected function attributesToString()
    {
        $attributes = array("remainingLogins" => $this->remainingLogins->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, "remainingLogins");
                        
        // Load elements
        $children = $obj->children();
        
        // psoID
        if(!$children->psoID)
			throw new MalformedMessageException(get_class($this) . "::psoID");
                
        $psoID = new PSOIdentifier();
        $psoID->readMessage($children->psoID);
        $this->setElement("psoID", $psoID);
        unset($children->psoID);
        
        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 . '<expirePasswordRequest xmlns="urn:oasis:names:tc:SPML:2:0"';
        
        // write expirePasswordRequest attributes
        $spmlstr .= $this->writeAttributes();
                
        // write parent elements
        $spmlmidstr = parent::writeMessage($level + 1);
        
        // write expirePasswordRequest elements
        $spmlmidstr .= $this->psoID->writeElement("psoID", $level + 1);
        
        return $this->tagCloser("expirePasswordRequest", $spmlstr, $spmlmidstr, $ind);
    }
    
    /**
     * Check if the object is valid
     * @access public
     * @return boolean
     */
    public function isValid()
    {
        return(($this->psoID != null) && parent::isValid());
    }
}
?>
Return current item: SimpleSPML