Index: C:/Documents and Settings/folsom-1/workspace/IzPack1/src/lib/com/izforge/izpack/rules/UserCondition.java =================================================================== --- C:/Documents and Settings/folsom-1/workspace/IzPack1/src/lib/com/izforge/izpack/rules/UserCondition.java (revision 0) +++ C:/Documents and Settings/folsom-1/workspace/IzPack1/src/lib/com/izforge/izpack/rules/UserCondition.java (revision 0) @@ -0,0 +1,66 @@ +package com.izforge.izpack.rules; + +import com.izforge.izpack.util.Debug; + +import net.n3.nanoxml.XMLElement; + +/** + * Checks to see whether the user who is running the installer is the same as the user who should be + * running the installer. + * + * @author J. Chris Folsom + */ +public class UserCondition extends Condition +{ + private static final long serialVersionUID = -2076347348048202718L; + + private String expectedUsername; + + /* + * (non-Javadoc) + * + * @see com.izforge.izpack.rules.Condition#isTrue() + */ + public boolean isTrue() + { + if (this.expectedUsername == null) + { + Debug.log("Expected user name not set in user condition. Condition will return false."); + return false; + } + else + { + String actualUsername = System.getProperty("user.name"); + + return actualUsername.equals(this.expectedUsername); + } + } + + /* + * (non-Javadoc) + * + * @see com.izforge.izpack.rules.Condition#readFromXML(net.n3.nanoxml.XMLElement) + */ + public void readFromXML(XMLElement xmlcondition) + { + XMLElement userElement = xmlcondition.getFirstChildNamed("user"); + + if (userElement == null) + { + Debug.log("Condition or type \"user\" requires child element: user"); + } + else + { + XMLElement requiredUserElement = userElement.getFirstChildNamed("require-user"); + + if (requiredUserElement == null) + { + Debug.log("Element \"user\" requires child element: require-user"); + } + else + { + this.expectedUsername = requiredUserElement.getContent(); + } + } + } +} \ No newline at end of file Index: C:/Documents and Settings/folsom-1/workspace/IzPack1/src/dtd/conditions.dtd =================================================================== --- C:/Documents and Settings/folsom-1/workspace/IzPack1/src/dtd/conditions.dtd (revision 2220) +++ C:/Documents and Settings/folsom-1/workspace/IzPack1/src/dtd/conditions.dtd (working copy) @@ -1,6 +1,6 @@ - + - \ No newline at end of file + + + + \ No newline at end of file