Index: fedd/abac-src/rtml/src/edu/stanford/CVS/Entries
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+D
Index: fedd/abac-src/rtml/src/edu/stanford/CVS/Entries.Log
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/CVS/Entries.Log	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/CVS/Entries.Log	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+A D/rt////
Index: fedd/abac-src/rtml/src/edu/stanford/CVS/Repository
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+rtml/src/edu/stanford
Index: fedd/abac-src/rtml/src/edu/stanford/CVS/Root
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+:ext:jjacobs@src.columbia.sparta.com/cvs/abac
Index: fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Entries
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,2 @@
+/Test1.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+D
Index: fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Entries.Log
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Entries.Log	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Entries.Log	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,4 @@
+A D/credential////
+A D/datatype////
+A D/parser////
+A D/util////
Index: fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Repository
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+rtml/src/edu/stanford/rt
Index: fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Root
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+:ext:jjacobs@src.columbia.sparta.com/cvs/abac
Index: fedd/abac-src/rtml/src/edu/stanford/rt/Test1.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/Test1.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/Test1.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,48 @@
+package edu.stanford.rt;
+
+import java.io.FileInputStream;
+import java.io.File;
+
+import edu.stanford.rt.credential.RTContext;
+import edu.stanford.rt.credential.CredentialStore;
+import edu.stanford.rt.credential.DomainSpecification;
+import edu.stanford.rt.parser.RTParser;
+import edu.stanford.rt.util.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ */
+public class Test1
+{
+
+	public static void main(String argv[])
+	{
+		if (argv.length != 1)
+		{
+			System.out.println("java edu.stanford.rt.Main file_name");
+			System.exit(1);
+		}
+
+		try
+		{
+			RTParser rt = new RTParser();
+            // System domain is created here.
+			RTContext context = new RTContext(rt);
+			CredentialStore store = new CredentialStore(rt);
+
+			rt.parseCredentialStore(
+				new FileInputStream(new File(argv[0])),
+				context,
+				store);
+
+            System.out.println(context.toString("  "));
+            System.out.println(store.toString("  "));
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+
+	}
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/ApplicationDomain.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/ApplicationDomain.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/ApplicationDomain.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,216 @@
+package edu.stanford.rt.credential;
+
+import java.util.Iterator;
+
+import edu.stanford.rt.datatype.*;
+import edu.stanford.rt.util.*;
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>ApplicationDomain</code> element.
+ *
+ */
+public class ApplicationDomain extends DomainSpecification
+{
+	/**
+	 * Attribute uri (required).
+	 */
+	private String uri;
+
+	/**
+	 * A flag indicates whether this domain is the built-in system one.
+	 */
+	private boolean isSystemDomain = false;
+
+	/**
+	 * Constructor for ApplicationDomain.
+	 * @param uri
+	 * @param isSystemDomain
+	 * @param context
+	 * @throws DomainSpecException
+	 */
+	public ApplicationDomain(
+		String uri,
+		boolean isSystemDomain,
+		RTContext context)
+		throws DomainSpecException
+	{
+		super(context);
+		this.uri = uri;
+		this.isSystemDomain = isSystemDomain;
+	}
+	/**
+	 * Method getUri.
+	 * @return String
+	 */
+	public String getUri()
+	{
+		return uri;
+	}
+
+	/**
+	 * Method lookupType.
+	 *  Look up the DataType declaration by given typeName 
+     *  in the current domain. If cannot find one and this domain is 
+     *  not system domain, then look up in the system domain.
+	 * @param typeName
+	 * @return DataType
+	 * @throws DomainSpecException
+	 *      if cannot find a DataType declaration by the given name.
+	 */
+	public DataType lookupType(String typeName)
+		throws DomainSpecException
+	{
+		//RTUtil.debugInfo(" lookupType()>>>> isSystemDomain = " + isSystemDomain);
+		DataType type = super.lookupType(typeName);
+
+		if (!isSystemDomain && type == null)
+		{
+			type =
+				getContext().getSystemDomain().lookupType(typeName);
+		}
+		if (type == null)
+		{
+			throw new DomainSpecException(
+				"Type '" + typeName + "' not found.");
+		}
+		return type;
+	}
+
+	/**
+	 * Method lookupRoleDeclaration.
+	 *      Look up the role declaration by given roleName in the 
+     *  current domain. If cannot find one and this domain is not system
+     *  domain, then look it up in system domain.
+	 * @param roleName
+	 * @return RoleDeclaration
+	 * @throws DomainSpecException
+	 *      if cannot find one.
+	 */
+	public RoleDeclaration lookupRoleDeclaration(String roleName)
+		throws DomainSpecException
+	{
+		RTUtil.debugInfo(
+			"DomainSpecification(id="
+				+ ((getHashID() == null)
+					? "null"
+					: getHashID().toString())
+				+ ") looking up role '"
+				+ roleName
+				+ "'");
+
+		RoleDeclaration role = super.lookupRoleDeclaration(roleName);
+		if (!isSystemDomain && role == null)
+		{
+			role =
+				getContext().getSystemDomain().lookupRoleDeclaration(
+					roleName);
+		}
+		if (role == null)
+		{
+			throw new DomainSpecException(
+				"Role '" + roleName + "' has not been declared.");
+		}
+		return role;
+	}
+
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+
+		sb.append(thisIndent).append(
+			"ApplicationDomain:  hashID = "
+				+ getHashID().toString()
+				+ "\n");
+		sb.append(thisIndent + "  ").append("uri = ").append(
+			uri).append(
+			"\n");
+		sb
+			.append(thisIndent + "  ")
+			.append("PrincipalType = ")
+			.append(getPrincipalType())
+			.append("\n");
+
+		sb.append(thisIndent + "  ").append("Imported Domains: \n");
+		try
+		{
+			Iterator it = getImportedDomains().keyIterator();
+			while (it.hasNext())
+			{
+				String key = (String) it.next();
+				ApplicationDomain value =
+					(ApplicationDomain) getImportedDomains().get(key);
+				sb.append(thisIndent + "    ").append(key).append(
+					"\n");
+				sb.append(thisIndent + "    ").append(
+					value.getUri()).append(
+					"\n");
+
+			}
+		}
+		catch (DomainSpecException e)
+		{
+			e.printStackTrace();
+		}
+
+		sb.append(thisIndent + "  ").append("Type Declarations: \n");
+		try
+		{
+			Iterator it = getTypeDeclarations().keyIterator();
+			while (it.hasNext())
+			{
+				String key = (String) it.next();
+				DataType value =
+					(DataType) getTypeDeclarations().get(key);
+
+				sb
+					.append(thisIndent + "    ")
+					.append(key)
+                    .append("\n")
+					.append(value.toString(thisIndent + "    "))
+					.append("\n");
+			}
+		}
+		catch (DomainSpecException e)
+		{
+			e.printStackTrace();
+		}
+
+		sb.append(thisIndent + "  ").append("Role Declarations: \n");
+		try
+		{
+			Iterator it = getRoleDeclarations().keyIterator();
+			while (it.hasNext())
+			{
+				String key = (String) it.next();
+				RoleDeclaration value =
+					(RoleDeclaration) getRoleDeclarations().get(key);
+				sb.append(thisIndent + "    ").append(key).append(
+					"\n");
+				sb.append(
+					value.toString(thisIndent + "    ")).append(
+					"\n");
+			}
+		}
+		catch (DomainSpecException e)
+		{
+			e.printStackTrace();
+		}
+		return sb.toString();
+	} // end of toString()
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.credential.DomainSpecification#setHashID(HashID)
+	 */
+	public synchronized void setHashID(HashID hashID)
+		throws DomainSpecException
+	{
+		if (isComplete())
+			throw new DomainSpecException("ApplicationDomain unmodifiable.");
+		if (hashID.getHashType() != HashID.APPLICATION_DOMAIN)
+			throw new DomainSpecException("Wrong type of hash id");
+		super.setHashID(hashID);
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/CVS/Entries
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,24 @@
+/ApplicationDomain.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/CredException.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/CredentialDomain.java/1.3/Wed Jan 15 01:56:21 2003//
+/CredentialStore.java/1.2/Wed Jan 15 01:56:21 2003//
+/DataValuePrincipal.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/DelegationRole.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/DomainSpecException.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/DomainSpecification.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/HashID.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/IssuerAndRoleDeclaration.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/LinkedRole.java/1.2/Mon Jan 13 01:33:59 2003//
+/OrderedMap.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/Principal.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/PrincipalExpression.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/PublicKeyPrincipal.java/1.2/Fri Jan 10 20:22:45 2003//
+/PublicKeyPrincipalInfo.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/RTContext.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/Role.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/RoleDeclaration.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/RoleDefinition.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/RoleIntersection.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/RoleTerm.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/ValidityTime.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+D
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/CVS/Repository
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+rtml/src/edu/stanford/rt/credential
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/CVS/Root
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+:ext:jjacobs@src.columbia.sparta.com/cvs/abac
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/CredException.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/CredException.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/CredException.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,13 @@
+package edu.stanford.rt.credential;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ */
+public class CredException extends java.lang.Exception
+{
+    public CredException(String msg)
+    {
+        super(msg);
+    }
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/CredentialDomain.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/CredentialDomain.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/CredentialDomain.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,321 @@
+package edu.stanford.rt.credential;
+
+import java.util.*;
+
+import org.w3c.dom.Element;
+
+import edu.stanford.rt.datatype.*;
+import edu.stanford.rt.util.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ *
+ * Implementation of <code>Credential</code> element.  Only one CredentialDomain object is associated with each Credential 
+ * object.
+*/
+public class CredentialDomain extends DomainSpecification
+{
+	/**
+	 * Issuer of the associated Credential.
+	 */
+	private Principal issuer;
+
+	/** 
+	 * validity time of the associated Credential.
+	 */
+	private ValidityTime validityTime;
+
+	/**
+	 *  maps String (principal shortName) to Principal object
+	 */
+	private HashMap principals;
+
+    /**
+     *  reverse lookup of Principal instances in this CredentialDomain
+     */
+    private HashMap shortNames;
+
+	/**
+	 * list of role defined in this credential.
+	 */
+	private ArrayList roleDefinitions;
+
+	/**
+	 * the XML Element of the associated Credential.
+	 */
+	private Element credentialElement;
+
+	/**
+	 * Constructor for CredentialDomain.
+	 */
+	public CredentialDomain(
+		Element credentialElement,
+		RTContext rtContext)
+		throws DomainSpecException
+	{
+		super(rtContext);
+		this.credentialElement = credentialElement;
+		this.principals = new HashMap();
+        this.shortNames = new HashMap();
+		this.roleDefinitions = new ArrayList();
+	}
+
+	/**
+	 * Method addPrincipal.
+	 * @param shortName
+	 * @param principal
+	 * @throws DomainSpecException
+	 */
+	public void addPrincipal(String shortName, Principal principal)
+		throws DomainSpecException
+	{
+		RTUtil.debugInfo("addPrincipal() shortName = " + shortName);
+		if (principals.get(shortName) != null)
+			throw new DomainSpecException(
+				"Duplicated principal entries for shortName '"
+					+ shortName
+					+ "'");
+		principals.put(shortName, principal);
+        shortNames.put(principal, shortName);
+	}
+
+	/**
+	 * Method getPrincipal.
+	 * @param shortName
+	 * @return Principal
+	 *  returns null if cannot find one.
+	 */
+	public Principal getPrincipal(String shortName)
+	{
+		return (Principal) principals.get(shortName);
+	}
+
+    /**
+     * Method getPrincipal.
+     * @param principal An instance of a principal object, currently a hash
+     * @return the short name id used for human readable formatting
+     *  returns <CODE>null</CODE> if cannot find one.
+     */
+    public String getPrincipal(Principal principal) {
+        return (String)shortNames.get(principal);
+    }
+
+	/**
+	 * Method setIssuer.
+	 * @param issuer
+	 */
+	public void setIssuer(Principal issuer)
+	{
+		this.issuer = issuer;
+	}
+	/**
+	 * Returns the issuer.
+	 * @return Principal
+	 */
+	public Principal getIssuer()
+	{
+		return issuer;
+	}
+
+	/**
+	 * Returns the validityTime.
+	 * @return ValidityTime
+	 */
+	public ValidityTime getValidityTime()
+	{
+		return validityTime;
+	}
+	/**
+	 * Method setValidityTime.
+	 * @param validityTime
+	 */
+	public void setValidityTime(ValidityTime validityTime)
+	{
+		this.validityTime = validityTime;
+	}
+
+    /**
+     * accessor method for retrieving the underlying DOM object
+     */
+    public Element getCredentialElement() {
+        return credentialElement;
+    }
+
+	/**
+	 * Method toString.
+	 * @param indent
+	 * @return String
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+
+		sb.append(thisIndent).append(
+			"CredentialDomain:   hashID = "
+				+ getHashID().toString()
+				+ "\n");
+		sb
+			.append(thisIndent + "  ")
+			.append("PrincipalType = ")
+			.append(getPrincipalType())
+			.append("\n");
+
+		sb.append(thisIndent + "  ").append("Imported Domains: \n");
+		try
+		{
+			Iterator it = getImportedDomains().keyIterator();
+			while (it.hasNext())
+			{
+				String key = (String) it.next();
+				ApplicationDomain value =
+					(ApplicationDomain) getImportedDomains().get(key);
+				sb.append(thisIndent + "    ").append(key).append(
+					"\n");
+				sb.append(thisIndent + "    ").append(
+					value.getUri()).append(
+					"\n");
+			}
+
+		}
+		catch (DomainSpecException e)
+		{
+			e.printStackTrace();
+		}
+
+		sb.append(thisIndent + "  ").append("Type Declarations: \n");
+		try
+		{
+			Iterator it = getTypeDeclarations().keyIterator();
+			while (it.hasNext())
+			{
+				String key = (String) it.next();
+				DataType value =
+					(DataType) getTypeDeclarations().get(key);
+				sb.append(thisIndent + "    ").append(key).append(
+					"\n");
+				sb.append(
+					value.toString(thisIndent + "    ")).append(
+					"\n");
+			}
+		}
+		catch (DomainSpecException e)
+		{
+			e.printStackTrace();
+		}
+
+		sb.append(thisIndent + "  ").append("Role Declarations: \n");
+		try
+		{
+			Iterator it = getRoleDeclarations().keyIterator();
+			while (it.hasNext())
+			{
+				String key = (String) it.next();
+				RoleDeclaration value =
+					(RoleDeclaration) getRoleDeclarations().get(key);
+				sb.append(thisIndent + "    ").append(key).append(
+					"\n");
+				sb.append(
+					value.toString(thisIndent + "    ")).append(
+					"\n");
+			}
+		}
+		catch (DomainSpecException e)
+		{
+			e.printStackTrace();
+		}
+		return sb.toString();
+	} // end of toString()
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.credential.DomainSpecification#setHashID(HashID)
+	 */
+	public void setHashID(HashID hashID) throws DomainSpecException
+	{
+		if (isComplete())
+			throw new DomainSpecException("CredentialDomain unmodifiable.");
+		if (hashID.getHashType() != HashID.CREDENTIAL_DOMAIN)
+			throw new DomainSpecException("Wrong type of hash id");
+		super.setHashID(hashID);
+	}
+
+	/**
+	 * Method roleDefinitionIterator.
+	 * @return Iterator
+	 */
+	public Iterator roleDefinitionIterator()
+	{
+		return roleDefinitions.iterator();
+	}
+
+	/**
+	 * Add a new role definition.
+	 * @param roleDefinition The roleDefinition to set
+	 */
+	public void addRoleDefinition(RoleDefinition roleDefinition)
+	{
+		this.roleDefinitions.add(roleDefinition);
+	}
+	/**
+	 * Method lookupType.
+	 *      Look up the DataType declaration by given typeName in the current domain.
+	 *  if cannot find one then look it up in system domain.
+	 * @param typeName
+	 * @return DataType
+	 * @throws DomainSpecException
+	 *      if cannot find a DataType declaration by the given name.
+	 */
+	public DataType lookupType(String typeName)
+		throws DomainSpecException
+	{
+		//RTUtil.debugInfo(" lookupType()>>>> isSystemDomain = " + isSystemDomain);
+		DataType type = super.lookupType(typeName);
+		if (type == null)
+		{
+			type =
+				getContext().getSystemDomain().lookupType(typeName);
+		}
+		if (type == null)
+		{
+			throw new DomainSpecException(
+				"Type '" + typeName + "' not found.");
+		}
+		return type;
+	}
+
+	/**
+	 * Method lookupRoleDeclaration.
+	 *      Look up the role declaration by given roleName in the current domain.
+	 *  If cannot find one then look it up in system domain.
+	 * @param roleName
+	 * @return RoleDeclaration
+	 * @throws DomainSpecException
+	 *      if cannot find one.
+	 */
+	public RoleDeclaration lookupRoleDeclaration(String roleName)
+		throws DomainSpecException
+	{
+		RTUtil.debugInfo(
+			"DomainSpecification(id="
+				+ ((getHashID() == null)
+					? "null"
+					: getHashID().toString())
+				+ ") looking up role '"
+				+ roleName
+				+ "'");
+
+		RoleDeclaration role = super.lookupRoleDeclaration(roleName);
+		if (role == null)
+		{
+			role =
+				getContext().getSystemDomain().lookupRoleDeclaration(
+					roleName);
+		}
+		if (role == null)
+		{
+			throw new DomainSpecException(
+				"Role '" + roleName + "' has not been declared.");
+		}
+		return role;
+	}
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/CredentialStore.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/CredentialStore.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/CredentialStore.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,258 @@
+package edu.stanford.rt.credential;
+
+import org.w3c.dom.Element;
+
+import java.util.*;
+
+import edu.stanford.rt.parser.RTParser;
+import edu.stanford.rt.util.*;
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * This class stores all the <code>CredentialDomain</code>, and 
+ * <code>RoleDefinition</code> index information.
+ * <p>
+ * A special principal is stored in the credential store to ....
+ * <p>
+ * 
+ */
+public class CredentialStore extends RTContext
+{
+	/**
+	 */
+	private Principal specialPrincipal;
+
+	/**
+	 * A map of <code>CredentialDomain</code> objects. A CredentialDomain 
+	 * contains all the info about a <code>Credential</code>.<br>
+	 * 
+	 * Key: <code>HashID</code> <br>
+	 * Value: <code>CredentialDomain</code>
+	 */
+	private HashMap credentialDomains;
+
+	/**
+	 * A set of <code>RoleDefinition</code> objects, including all 
+	 * roles defined in the <code>Credential</code> included in this 
+	 * <code>CredentialStore</code>.
+	 */
+	private HashSet roleDefinitions;
+
+	/**
+	 * Role definitions indexed by issuer. <br>
+	 * 
+	 * Key: <code>Principal</code>: the issuer <br>
+	 * Value: an ArrayList of <code>RoleDefinition</code>.
+	 */
+	private HashMap indexByIssuer;
+
+	/**
+	 * Role definitions indexed by issuer and role declaration. 
+	 * The issuer is the issuer of the credential and the role
+	 * declaration is the one corresponding to the head role term in the
+	 * role definition.
+	 * <br>
+	 * 
+	 * Key: <code>IssuerAndRoleDeclaration</code> <br>
+	 * Value: an ArrayList of <code>RoleDefinition</code>
+	 */
+	private HashMap indexByIssuerAndRoleDeclaration;
+
+	/**
+	 * Constructor for CredentialStore.
+	 */
+	public CredentialStore(RTParser rtParser) throws Exception
+	{
+		super(rtParser);
+		this.credentialDomains = new HashMap();
+		this.roleDefinitions = new HashSet();
+		this.indexByIssuer = new HashMap();
+		this.indexByIssuerAndRoleDeclaration = new HashMap();
+	}
+
+	/** public accesses method for iterating through all the domains */
+	public HashMap getCredentialDomains() {
+		return credentialDomains;
+	}
+
+	/**
+	 * Returns the specialPrincipal.
+	 * @return Principal
+	 */
+	public Principal getSpecialPrincipal()
+	{
+		return specialPrincipal;
+	}
+
+	/**
+	 * Sets the specialPrincipal.
+	 * @param specialPrincipal The specialPrincipal to set
+	 */
+	public void setSpecialPrincipal(Principal specialPrincipal)
+	{
+		this.specialPrincipal = specialPrincipal;
+	}
+
+	/**
+	 * Method getCredentialDomain.
+	 * @param id
+	 * @return CredentialDomain
+	 */
+	public CredentialDomain getCredentialDomain(HashID id)
+	{
+		return (CredentialDomain) credentialDomains.get(id);
+	}
+
+	/**
+	 * Method getCredentialDomain.
+	 * @param id
+	 * @return CredentialDomain
+	 */
+	public CredentialDomain getCredentialDomain(String id)
+	{
+		return getCredentialDomain(
+			new HashID(HashID.CREDENTIAL_DOMAIN, id));
+	}
+
+	/**
+	 * Method roleDefinitionIterator.
+	 *      returns an Iterator for the set of role definitions.
+	 * @return Iterator
+	 */
+	public Iterator roleDefinitionIterator()
+	{
+		return roleDefinitions.iterator();
+	}
+
+	/**
+	 * Method getIndexByIssuer.
+	 *      returns a list of role definitions by the given issuer.
+	 * @param issuer
+	 * @return ArrayList
+	 */
+	public ArrayList getIndexByIssuer(Principal issuer)
+	{
+		return (ArrayList) indexByIssuer.get(issuer);
+	}
+
+	/**
+	 * Method getIndexByIssuerAndRoleDeclaration.
+	 * @param issuerAndRoleDeclaration
+	 * @return ArrayList
+	 */
+	public ArrayList getIndexByIssuerAndRoleDeclaration(
+        IssuerAndRoleDeclaration issuerAndRoleDeclaration)
+	{
+		return (ArrayList) indexByIssuerAndRoleDeclaration.get(
+			issuerAndRoleDeclaration);
+	}
+
+	/**
+	 * Method addCredentialDomain.
+	 * @param id
+	 * @param credentialDomain
+	 * @throws DomainSpecException
+	 */
+	public synchronized void addCredentialDomain(
+		HashID id,
+		CredentialDomain credentialDomain)
+		throws DomainSpecException
+	{
+		RTUtil.debugInfo(
+			"CredentialStore.addCredentialDomain() .... ");
+		RTUtil.debugInfo("      id = " + id.toString());
+		RTUtil.debugInfo(credentialDomain.toString("  "));
+		if (this.credentialDomains.get(id) != null)
+			throw new DomainSpecException("Duplicated credentials in CredentialStore.");
+		this.credentialDomains.put(id, credentialDomain);
+		// get role definitions from the credential domain just added and 
+		// add them to the credential store.
+		Iterator it = credentialDomain.roleDefinitionIterator();
+		while (it.hasNext())
+		{
+			addRoleDefinition((RoleDefinition) it.next());
+		}
+	}
+	/**
+	 * Adds a new role definition to the roleDefinitions.
+	 * @param roleDefinition The roleDefinition to set
+	 */
+	private synchronized void addRoleDefinition(
+        RoleDefinition roleDefinition)
+		throws DomainSpecException
+	{
+		if (this.roleDefinitions.contains(roleDefinition))
+			throw new DomainSpecException("Duplicated role definition. ");
+		this.roleDefinitions.add(roleDefinition);
+		addIndexByIssuer(roleDefinition);
+		addIndexByIssuerAndRoleDeclaration(roleDefinition);
+
+	}
+	/**
+	 * Method addIndexByIssuer.
+	 * @param roleDefinition
+	 */
+	private synchronized void addIndexByIssuer(RoleDefinition roleDefinition)
+	{
+		Role head = roleDefinition.getHead();
+		Principal issuer = head.getPrincipal();
+		ArrayList list = getIndexByIssuer(issuer);
+		if (list == null)
+			list = new ArrayList();
+		if (!list.contains(roleDefinition))
+			list.add(roleDefinition);
+		// update the map entry.
+		indexByIssuer.put(issuer, list);
+	}
+	/**
+	 * Method addIndexByIssuerAndRoleDeclaration.
+	 * @param roleDefinition
+	 */
+	private synchronized void addIndexByIssuerAndRoleDeclaration(RoleDefinition roleDefinition)
+	{
+		Role head = roleDefinition.getHead();
+		Principal issuer = head.getPrincipal();
+		RoleDeclaration roleDec = head.getRoleDeclaration();
+		IssuerAndRoleDeclaration index =
+			new IssuerAndRoleDeclaration(issuer, roleDec);
+		ArrayList list = getIndexByIssuerAndRoleDeclaration(index);
+		if (list == null)
+			list = new ArrayList();
+		if (!list.contains(roleDefinition))
+			list.add(roleDefinition);
+		indexByIssuerAndRoleDeclaration.put(index, list);
+	}
+
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+
+		sb.append(
+			"********* CrendentialStore: **********\n\n");
+
+		sb.append(thisIndent).append("Credential Domains: \n");
+		Set entries = credentialDomains.entrySet();
+		Iterator it = entries.iterator();
+		while (it.hasNext())
+		{
+			Map.Entry entry = (Map.Entry) it.next();
+			CredentialDomain credDomain =
+				(CredentialDomain) entry.getValue();
+			sb.append(credDomain.toString(thisIndent));
+			sb.append("\n");
+		}
+
+		sb.append(thisIndent).append("Role definitions: \n");
+		it = roleDefinitionIterator();
+		while (it.hasNext())
+		{
+			RoleDefinition roleDef = (RoleDefinition) it.next();
+			sb.append(roleDef.toString(thisIndent));
+			sb.append("\n");
+		}
+
+		return sb.toString();
+
+	}
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/DataValuePrincipal.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/DataValuePrincipal.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/DataValuePrincipal.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,89 @@
+package edu.stanford.rt.credential;
+import edu.stanford.rt.datatype.*;
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ *
+ * This class handles <code>Principal</code> element, which consists of 
+ * IntegerValue or StringValue.
+ */
+public class DataValuePrincipal extends Principal
+{
+	/**
+	 * the principal value, which could be an integer or a string.
+	 */
+	private DataValue value;
+
+	/**
+	 * Constructor for DataValuePrincipal.
+	 * 
+	 *   Contruct a Principal object using a DataValue object. 
+	 *   DomainSpecException  is thrown if value passed in is not an instance of
+	 *   IntegerValue, StringValue, or KeyValue.
+	 *   <br>
+	 *   <code>IllegalArgumentException</code> is thrown if value
+	 *   is not of <code>IntegerValue</code> or <code>StringValue</code> type.
+	*/
+	public DataValuePrincipal(DataValue value)
+	{
+		if (!(value instanceof IntegerValue)
+			&& !(value instanceof StringValue))
+			throw new IllegalArgumentException("Illegal argument");
+
+		this.value = value;
+	}
+	/**
+	 * Method getValue.
+	 * @return DataValue
+	 */
+	public DataValue getValue()
+	{
+		return value;
+	}
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	public String toString()
+	{
+		return value.toString();
+	}
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	public int hashCode()
+	{
+		return value.hashCode();
+	}
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(Object)
+	 */
+	public boolean equals(Object value)
+	{
+		if (!(value instanceof IntegerValue)
+			&& !(value instanceof StringValue))
+			return false;
+            
+		if (value instanceof IntegerValue)
+		{
+			if (!(value instanceof IntegerValue))
+				return false;
+			else
+				return this.hashCode() == value.hashCode();
+		}
+		else
+		{
+			if (!(value instanceof StringValue))
+				return false;
+			else
+				return this.hashCode() == value.hashCode();
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.credential.PrincipalExpression#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		return thisIndent + "DataValuePrincipal: " + value.toString();
+	}
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/DelegationRole.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/DelegationRole.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/DelegationRole.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,54 @@
+package edu.stanford.rt.credential;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ *
+ * Implementation of <code>SimpleDelegation</code> element.
+ * A <code>DelegationRole</code> has a required part <code>delegateTo</code>
+ * and an optional part <code>control</code>.
+ */
+public class DelegationRole implements PrincipalExpression
+{
+	/**
+	 *  to whom to delegate the authority.
+	 */
+	private PrincipalExpression delegateTo; // required element.
+
+	/**
+	 * depth of the allowed further delegation.
+	 */
+	private Role control;
+
+	/**
+	 * Constructor for DelegationRole.
+	 */
+	public DelegationRole(
+		PrincipalExpression delegateTo,
+		Role control)
+	{
+		this.delegateTo = delegateTo;
+		this.control = control;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.credential.PrincipalExpression#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("Delegation Role: \n");
+		sb.append(thisIndent + "  ").append(
+			delegateTo.toString()).append(
+			"\n");
+		sb
+			.append(thisIndent + "  ")
+			.append(
+				(control == null)
+					? ""
+					: control.toString(thisIndent + "  "))
+			.append("\n");
+		return sb.toString();
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/DomainSpecException.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/DomainSpecException.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/DomainSpecException.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,13 @@
+package edu.stanford.rt.credential;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ */
+public class DomainSpecException extends java.lang.Exception
+{
+    public DomainSpecException(String msg)
+    {
+        super(msg);
+    }
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/DomainSpecification.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/DomainSpecification.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/DomainSpecification.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,458 @@
+package edu.stanford.rt.credential;
+
+import java.util.*;
+
+import edu.stanford.rt.datatype.*;
+import edu.stanford.rt.credential.*;
+import edu.stanford.rt.util.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ *
+ * This class stores the common information about an <code>ApplicationDomain</code> or
+ * a <code>CredentialDomain</code>. The info includes the following:
+ * principal type, imported application domains, type declarations, 
+ * role declarations, hash id, RTML context, and the parsing status.
+ * 
+ */
+public class DomainSpecification
+{
+    /**
+     * Principal type
+     */
+	private SimpleType principalType;
+
+	/**
+	 * Stores all imported domains in this domain, 
+	 * mapping string (domain name) to ApplicationDomain object.
+	 */
+	private OrderedMap importedDomains;
+
+	/**
+	 * Stores all type decalarations in this domain, 
+	 * mapping string(type name) to type declaration object.
+	 */
+	private OrderedMap typeDeclarations;
+
+	/**
+	 * Stores all role declarations in this domain,
+	 * mapping string(role name) to role declaration object.
+	 */
+	private OrderedMap roleDeclarations;
+
+	/**
+	 *  A flag indicates the parsing status of the domain.
+	 */
+	private boolean completeState;
+
+	/** The hash value of the domain. */
+	private HashID hashID;
+
+    /**
+     * RTML Context
+     */
+	private RTContext context;
+
+	/**
+	 * Constuctor for DomainSpecification.
+	    Contructs a DomainSpecification object with the specific uri. 
+	    Include System DomainSpecification for non-system DomainSpecification
+		object.
+	 * @param uri
+	 * @param isSystemDomain
+	 * @param context
+	 * @throws DomainSpecException
+	 */
+	DomainSpecification(RTContext context) throws DomainSpecException
+	{
+		this.completeState = false;
+		this.importedDomains =
+			new OrderedMap(String.class, DomainSpecification.class);
+		this.typeDeclarations =
+			new OrderedMap(String.class, DataType.class);
+		this.roleDeclarations =
+			new OrderedMap(String.class, RoleDeclaration.class);
+		this.context = context;
+	}
+
+	//	/**
+	//	    Copies over the type declarations and role declarations from the 
+	//	    included domain specification objects.
+	//	*/
+	//	private void includeDomain(DomainSpecification ds)
+	//		throws DomainSpecException
+	//	{
+	//		SimpleType prinType = ds.getPrincipalType();
+	//		if (prinType != null)
+	//		{
+	//			if (this.principalType == null)
+	//			{
+	//				this.principalType = prinType;
+	//			}
+	//			else if (!prinType.equals(this.principalType))
+	//			{
+	//				throw new DomainSpecException("Pincipal Type Conflict!");
+	//			}
+	//		}
+	//		typeDeclarations.putAll(ds.getTypeDeclarations());
+	//		roleDeclarations.putAll(ds.getRoleDeclarations());
+	//	}
+
+	/**
+	 * Method importDomain.
+	 * 		Add a newly imported domain map.
+	 * @param name
+     *      the short name to refer to spec with the domain.
+	 * @param spec
+	 * @throws DomainSpecException
+	 */
+	public synchronized void importDomain(
+		String name,
+		ApplicationDomain spec)
+		throws DomainSpecException
+	{
+		importedDomains.put(name, spec);
+	}
+
+	/**
+	 * Method addType.
+	 * 		Add a new type declaration to the domain.<br>
+	 * @param type
+	 * @throws DomainSpecException
+	 * 		DomainSpecException when a duplicated type declaration, 
+	 *      i.e. a type declaration with the same name and same data 
+	 *      type, is added.
+	 */
+	public synchronized void addType(DataType type)
+		throws DomainSpecException
+	{
+		String typeName = type.getName();
+		if (typeExistsInSystemDomain(typeName))
+			throw new DomainSpecException(
+				"Type '"
+					+ typeName
+					+ "' already declared in system domain");
+		typeDeclarations.put(typeName, type);
+	}
+
+	/**
+	 * Method addType.
+	 * 		Add XML built-in type.
+	 * @param typeName
+	 * @throws DomainSpecException
+	 */
+	public synchronized void addType(String typeName)
+		throws DomainSpecException
+	{
+		if (typeExistsInSystemDomain(typeName))
+			throw new DomainSpecException(
+				"Type '"
+					+ typeName
+					+ "' already declared in system domain");
+		typeDeclarations.put(typeName, null);
+	}
+
+	/**
+	 * Method addRole.
+	 * 		Add a new role declaration to the domain.
+	 * @param role
+	 * @throws DomainSpecException
+	 */
+	public synchronized void addRole(RoleDeclaration role)
+		throws DomainSpecException
+	{
+		RTUtil.debugInfo(
+			"DomainSpecification(id="
+				+ getHashID().toString()
+				+ ") adding role '"
+				+ role.getName()
+				+ "'");
+
+		String roleName = role.getName();
+		if (roleExistsInSystemDomain(roleName))
+			throw new DomainSpecException(
+				"Role '"
+					+ roleName
+					+ "' already declared in system domain");
+		roleDeclarations.put(roleName, role);
+	}
+
+	/**
+	 * Method setPrincipalType.
+	 * @param prinType
+	 * @throws DomainSpecException
+	 */
+	public synchronized void setPrincipalType(SimpleType prinType)
+		throws DomainSpecException
+	{
+		if (this.principalType == null)
+			this.principalType = prinType;
+		else if (!prinType.equals(this.principalType))
+			throw new DomainSpecException("Pincipal Type Conflict!");
+	}
+
+	/**
+	 * Method isComplete.
+     *  checks whether the parsing is completed.
+	 * @return boolean
+	 */
+	public boolean isComplete()
+	{
+		return completeState;
+	}
+
+	/**
+	 * Method setComplete.
+     *      marks the parsing status as complete, so no modification 
+     *      is allowed for imported domains, type declarations , and 
+     *      role declarations maps.
+	 */
+	public synchronized void setComplete()
+	{
+		completeState = true;
+		importedDomains.setUneditable();
+		typeDeclarations.setUneditable();
+		roleDeclarations.setUneditable();
+	}
+
+	/**
+	 * Method lookupImportedDomain.
+	 * 		Lookup an imported domain by the given domainRef 
+     *      in the currnt domain.
+	 * @param domainRef
+	 * @return DomainSpecification
+	 * @throws DomainSpecException
+     *      if cannot find one
+	 */
+	public DomainSpecification lookupImportedDomain(String domainRef)
+		throws DomainSpecException
+	{
+		DomainSpecification spec =
+			(DomainSpecification) importedDomains.get(domainRef);
+		if (spec == null)
+		{
+			throw new DomainSpecException(
+				"Domain '" + domainRef + "' not found.");
+		}
+
+		return spec;
+	}
+
+	/**
+	 * Method lookupType.
+	 * 		Look up the DataType declaration by given typeName 
+     *      in the current domain.
+	 * @param typeName
+	 * @return DataType
+     *  returns null if cannot find one.
+	 * @throws DomainSpecException
+	 * 		if cannot find a DataType declaration by the given name.
+	 */
+	public DataType lookupType(String typeName)
+		throws DomainSpecException
+    {
+        return (DataType) typeDeclarations.get(typeName);
+    }
+
+	/**
+	 * Method lookupType.
+	 * 		Look up the DataType declaration by given typeName in the given domain.
+	 * @param domainRef
+	 * 		specifies which domain to look up in. If domainRef is null or an
+	 * 		empty string, then look up in the current domain.
+	 * @param typeName
+	 * @return DataType
+	 * @throws DomainSpecException
+	 * 		if cannot find a DataType with given name.
+	 */
+	public DataType lookupType(String domainRef, String typeName)
+		throws DomainSpecException
+	{
+		DataType type;
+
+		if (domainRef == null || domainRef.length() == 0)
+		{
+			type = this.lookupType(typeName);
+		}
+		else
+		{
+			DomainSpecification importedSpec =
+				this.lookupImportedDomain(domainRef);
+			type = importedSpec.lookupType(typeName);
+		}
+		return type;
+	}
+
+	/**
+	 * Method lookupRoleDeclaration.
+	 * 		Look up the role declaration by given roleName in the current domain.
+	 * @param roleName
+	 * @return RoleDeclaration
+     *  returns null if cannot find one.
+	 * @throws DomainSpecException
+	 * 		if cannot find one.
+	 */
+	public RoleDeclaration lookupRoleDeclaration(String roleName)
+		throws DomainSpecException
+    {
+        return (RoleDeclaration) roleDeclarations.get(roleName);
+    }
+
+	/**
+	 * Method lookupRoleDeclaration.
+	 * 		looks up a role declaration by given roleName in the given domain.
+	 * @param domainRef
+	 * 		specifies which domain to look up in.  If domainRef is null or an
+	 * 		empty string, then look up in the current domain.
+	 * @param roleName
+	 * @return RoleDeclaration
+	 * @throws DomainSpecException
+	 * 		if cannot find a one.
+	 */
+	public RoleDeclaration lookupRoleDeclaration(
+		String domainRef,
+		String roleName)
+		throws DomainSpecException
+	{
+		RoleDeclaration role;
+
+		if (domainRef == null || domainRef.length() == 0)
+		{
+			role = this.lookupRoleDeclaration(roleName);
+		}
+		else
+		{
+			DomainSpecification importedSpec =
+				this.lookupImportedDomain(domainRef);
+			role = importedSpec.lookupRoleDeclaration(roleName);
+		}
+		return role;
+	}
+
+	/**
+	 * Method getContext.
+	 * @return RTContext
+	 */
+	public RTContext getContext()
+	{
+		return context;
+	}
+	/**
+	 * Method getTypeDeclarations.
+	 * @return OrderedMap
+	 * @throws DomainSpecException
+     *  when parsing is not completed.
+	 */
+	public OrderedMap getTypeDeclarations()
+		throws DomainSpecException
+	{
+		if (!isComplete())
+			throw new DomainSpecException("Still parsing current domain specification");
+		return typeDeclarations;
+	}
+
+	/**
+	 * Method getRoleDeclarations.
+	 * @return OrderedMap
+	 * @throws DomainSpecException
+     *  when parsing is not completed.
+	 */
+	public OrderedMap getRoleDeclarations()
+		throws DomainSpecException
+	{
+		if (!isComplete())
+			throw new DomainSpecException("Still parsing current domain specification");
+		return roleDeclarations;
+	}
+
+	/**
+	 * Method getImportedDomains.
+	 * @return OrderedMap
+	 * @throws DomainSpecException
+     *  when parsing is not completed.
+	 */
+	public OrderedMap getImportedDomains() throws DomainSpecException
+	{
+		if (!isComplete())
+			throw new DomainSpecException("Still parsing current domain specification");
+		return importedDomains;
+
+	}
+
+	/**
+	 * Method getPrincipalType.
+	 * @return SimpleType
+	 */
+	public SimpleType getPrincipalType()
+	{
+		return this.principalType;
+	}
+
+	/**
+	 * Returns the hashID.
+	 * @return ApplicationDomainHashID
+	 */
+	public HashID getHashID()
+	{
+		return this.hashID;
+	}
+
+	/**
+	 * Sets the hashID.
+	 * @param hashID The hashID to set
+	 */
+	public synchronized void setHashID(HashID hashID)
+		throws DomainSpecException
+	{
+		this.hashID = hashID;
+	}
+
+	/**
+	 * Method typeExistsInSystemDomain.
+     *  checks whether a DataType with given typeName is already 
+     *  declcared in system domain.
+	 * @param typeName
+	 * @return boolean
+	 */
+	private boolean typeExistsInSystemDomain(String typeName)
+	{
+		if (context == null)
+			return false;
+
+		try
+		{
+			DataType t =
+				context.getSystemDomain().lookupType(typeName);
+			return true;
+		}
+		catch (DomainSpecException e)
+		{
+			return false;
+		}
+	}
+
+	/**
+	 * Method roleExistsInSystemDomain.
+     *  checks whether a RoleDeclaration with given roleName is already 
+     *  declcared in system domain.
+	 * @param roleName
+	 * @return boolean
+	 */
+	private boolean roleExistsInSystemDomain(String roleName)
+	{
+		if (context == null)
+			return false;
+
+		try
+		{
+			RoleDeclaration r =
+				context.getSystemDomain().lookupRoleDeclaration(
+					roleName);
+			return true;
+		}
+		catch (DomainSpecException e)
+		{
+			return false;
+		}
+	}
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/HashID.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/HashID.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/HashID.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,84 @@
+package edu.stanford.rt.credential;
+
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * HashID is the identifier of a <code>DomainSpecification</code> element.
+ * It is represented by the "id" attribute of the element.
+ *
+ */
+public class HashID
+{
+	/** 
+     * ApplicationDomain type of hash id 
+     */
+	static public final int APPLICATION_DOMAIN = 1;
+	/** 
+     * CredentialDomain type of hash id 
+     */
+	static public final int CREDENTIAL_DOMAIN = 2;
+    /**
+     * the hash value for the element.
+     */	
+	private String hashValue;
+    /**
+     * type of the hash id.
+     */
+	private int hashType;
+	
+	/**
+	 * Constructor for HashID
+	 */
+	public HashID(int hashType, String hashValue)
+	{
+		this.hashType = hashType;
+		this.hashValue = hashValue;
+	}
+	
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	public int hashCode()
+	{
+		return hashValue.hashCode();
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(Object)
+	 */
+	public boolean equals(Object id)
+	{
+        if(! (id instanceof HashID))
+            return false;
+
+        HashID hashid = (HashID) id;
+		return    this.hashType == hashid.getHashType() 
+			  &&   this.hashCode() == hashid.hashCode();
+	}
+	/**
+	 * Returns the hashType.
+	 * @return int
+	 */
+	public int getHashType()
+	{
+		return hashType;
+	}
+
+	/**
+	 * Returns the hashValue.
+	 * @return String
+	 */
+	public String getHashValue()
+	{
+		return hashValue;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+    public String toString()
+    {
+        return hashValue;
+    }
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/IssuerAndRoleDeclaration.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/IssuerAndRoleDeclaration.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/IssuerAndRoleDeclaration.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,44 @@
+package edu.stanford.rt.credential;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ *
+ * An object which includes a <code>Principal</code> and 
+ * a <code>RoleDeclaration</code> object. It is used as an index 
+ * to index the role definitions in <code>CredentialStore</code>.
+ */
+public class IssuerAndRoleDeclaration
+{
+	private Principal issuer;
+	private RoleDeclaration roleDeclaration;
+	
+	/**
+	 * Constructor for IssuerAndRoleDeclaration.
+	 */
+	public IssuerAndRoleDeclaration(Principal issuer, 
+			RoleDeclaration roleDeclaration)
+	{
+		this.issuer = issuer;
+		this.roleDeclaration = roleDeclaration;
+	}
+
+
+	/**
+	 * Returns the issuer.
+	 * @return Principal
+	 */
+	public Principal getIssuer()
+	{
+		return issuer;
+	}
+
+	/**
+	 * Returns the roleDeclaration.
+	 * @return RoleDeclaration
+	 */
+	public RoleDeclaration getRoleDeclaration()
+	{
+		return roleDeclaration;
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/LinkedRole.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/LinkedRole.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/LinkedRole.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,57 @@
+package edu.stanford.rt.credential;
+
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>LinkedRole</code> element.
+ */
+public class LinkedRole implements PrincipalExpression
+{
+	private RoleTerm roleTerm1; // required element.
+	private RoleTerm roleTerm2; // required element.
+
+    /**
+     * Constructor for LinkedRole.
+     */
+	public LinkedRole(RoleTerm term1, RoleTerm term2)
+	{
+		roleTerm1 = term1;
+		roleTerm2 = term2;
+	}
+
+    /**
+     * Accessor method for the role terms. 
+     */
+    public RoleTerm getRoleTermAt(int index) {
+        switch(index) {
+        case 0: 
+            return roleTerm1;
+        case 1: 
+            return roleTerm2;
+        default: 
+            return null;
+        }
+    } 
+
+    /**
+	 * @see edu.stanford.rt.credential.PrincipalExpression#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("Linked Role: \n");
+		sb
+			.append(thisIndent + "  ")
+			.append(roleTerm1.toString(thisIndent + "  "))
+			.append("\n");
+		sb
+			.append(thisIndent + "  ")
+			.append(roleTerm2.toString(thisIndent + "  "))
+			.append("\n");
+		return sb.toString();
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/OrderedMap.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/OrderedMap.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/OrderedMap.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,224 @@
+package edu.stanford.rt.credential;
+
+import java.util.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ *  OrderedMap maintains a map from key to values and the ordering 
+ *  of the keys.
+ * 
+ */
+public class OrderedMap
+{
+	/** key type */
+	private Class keyClass;
+	/** value type */
+	private Class valueClass;
+	/**  map for the key-value pairs */
+	private HashMap dataMap;
+	/** also stores the keys as they are added to the list, 
+	 * so that we can remember the ordering of the keys.
+	 */
+	private ArrayList keyList;
+	/** whether this map is editable   */
+	private boolean editable;
+	/** defualt map capacity */
+	private static final int DEFAULT_SIZE = 10;
+
+	/**
+	 * Constructor for OrderedMap.
+	 * 
+	 *   Constructs a OrderedMap object with size default to 10.
+	 *   Both key and value are of Object type.
+	 */
+	public OrderedMap()
+	{
+		this(DEFAULT_SIZE, Object.class, Object.class);
+	}
+
+	/**
+	 * Constructor for OrderedMap.
+	 *   Constructs a OrderedMap object with given size.
+	 *   Both key and value are of Object type.
+	 */
+	public OrderedMap(int size)
+	{
+		this(size, Object.class, Object.class);
+	}
+
+	/**
+	 * Constructor for OrderedMap.
+	 *  Constructs a OrderedMap object with size default to 10.
+	 *  The key and value type are specified by the given keyClass and 
+	 *   valueClass, respectively.
+	 */
+	public OrderedMap(Class keyClass, Class valueClass)
+	{
+		this(DEFAULT_SIZE, keyClass, valueClass);
+	}
+
+	/**
+	 * Constructor for OrderedMap.
+	 *   Constructs a OrderedMap object with given size.
+	 *   The key and value type are specified by the given keyClass and 
+	 *   valueClass, respectively.
+	 */
+	public OrderedMap(int size, Class keyClass, Class valueClass)
+	{
+		this.keyClass = keyClass;
+		this.valueClass = valueClass;
+		this.dataMap = new HashMap(size);
+		this.keyList = new ArrayList(size);
+		this.editable = true;
+	}
+
+	/**
+	 * Method constainsKey.
+	 *   Returns true if there is a mapping for the given key.
+	 * @param key
+	 * @return boolean
+	 */
+	public synchronized boolean constainsKey(Object key)
+	{
+		return dataMap.containsKey(key);
+	}
+
+	/**
+	 * Method put.
+     *   Add a new key-value mapping entry to the map.
+     *   Exception is thrown if the map is not editable, the key is null,
+     *   or the given key or value's type does not match the specified 
+     *   key type or value type.  Exception will also be thrown if trying
+     *   to add duplicated key-value pair.
+	 * @param key
+	 * @param value
+	 * @throws DomainSpecException
+	 */
+	public synchronized void put(Object key, Object value)
+		throws DomainSpecException
+	{
+		if (!editable)
+			throw new DomainSpecException("Adding to unmodifiable map");
+
+		if (key == null)
+			throw new DomainSpecException("Wrong key value: null.");
+
+		if (!keyClass.isInstance(key))
+			throw new DomainSpecException("Wrong key type");
+
+		if (value != null && !valueClass.isInstance(value))
+			throw new DomainSpecException("Wrong value type");
+
+		myPut(key, value);
+	}
+
+	private void myPut(Object key, Object value)
+		throws DomainSpecException
+	{
+		//RTUtil.debugInfo("myPut() > key  = " + key.toString());
+
+		if (dataMap.get(key) != null)
+		{
+			//RTUtil.debugInfo("myPut() > " + dataMap.get(key).toString());
+			throw new DomainSpecException("Duplicate mapping");
+		}
+		dataMap.put(key, value);
+		keyList.add(key);
+	}
+
+	/**
+	    Copies all the mapping entries to this map, perserving the 
+	    original ordering of the entries.
+	    
+	    Exception is thrown when the key type or value type of the given 
+	    map does not match that of this map, or when duplicated entries 
+	    are detected.
+	*/
+	public synchronized void putAll(OrderedMap map)
+		throws DomainSpecException
+	{
+		if (!this.keyClass.equals(map.getKeyClass())
+			|| !this.valueClass.equals(map.getValueClass()))
+		{
+			throw new DomainSpecException("Illegal key/value type.");
+		}
+		Iterator it = map.keyIterator();
+		while (it.hasNext())
+		{
+			Object key = it.next();
+			Object value = map.get(key);
+			myPut(key, value);
+		}
+		// Do not call setUneditable mothod here!
+	}
+
+	/**
+	    marks this map as uneditable.
+	*/
+	public synchronized void setUneditable()
+	{
+		editable = false;
+	}
+
+	/**
+	    Returns true if the map is editable.
+	*/
+	public boolean isEditable()
+	{
+		return editable;
+	}
+
+	/** Returns the size of this map */
+	public synchronized int size()
+	{
+		return keyList.size();
+	}
+
+	/** Returns iterator to the list of keys in the map.*/
+	public synchronized Iterator keyIterator()
+	{
+		return keyList.iterator();
+	}
+
+	/**
+	    Returns the value for the given key and returns null if there is 
+	    no mapping for the given key .
+	    
+	    Exception is thrown when the type of given key does not match the 
+	    specified key type of this map. 
+	*/
+	public Object get(Object key) throws DomainSpecException
+	{
+		if (!keyClass.isInstance(key))
+			throw new DomainSpecException("Wrong key type");
+
+		return dataMap.get(key);
+	}
+
+	/** Returns an unmodifiable view of all the keys. */
+	public synchronized List keyList()
+	{
+		// returns a unmodifiable version of the keys
+		return Collections.unmodifiableList(keyList);
+	}
+
+	/** Returns an unmodifiable view of this map. */
+	public synchronized Map valueMap()
+	{
+		return Collections.unmodifiableMap(dataMap);
+	}
+
+	/** Returns the key type. */
+	public Class getKeyClass()
+	{
+		return keyClass;
+	}
+
+	/** Returns the value type */
+	public Class getValueClass()
+	{
+		return valueClass;
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/Principal.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/Principal.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/Principal.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,16 @@
+package edu.stanford.rt.credential;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ *
+ * An empty super class for <code>PublicKeyPrincipal</code> and 
+ * <code>DataValuePrincipal</code>.
+ * 
+ */
+public class Principal implements PrincipalExpression
+{
+    public String toString(String indent)
+    {
+        return indent;
+    }
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/PrincipalExpression.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/PrincipalExpression.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/PrincipalExpression.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,14 @@
+package edu.stanford.rt.credential;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ *
+    A marker interface. 
+    
+    A PrincipalExpression can be the following:
+    A Principal, a Role, a LinkedRole, or a RoleIntersection.
+ */
+public interface PrincipalExpression extends java.io.Serializable
+{
+    public String toString(String indent);
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/PublicKeyPrincipal.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/PublicKeyPrincipal.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/PublicKeyPrincipal.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,49 @@
+package edu.stanford.rt.credential;
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ *
+ * This class handles <code>Principal</code> element which consists of
+ * ds:KeyValue. Instead of storing the key vlaue, we store the 
+ * hashValue of the key value. The key value is stored in 
+ * <code>PublicKeyPrincipalInfo</code>.
+ */
+public class PublicKeyPrincipal extends Principal
+{
+	/**
+	 * Hash value for the public key stored in this principal
+	 */
+	private String hashValue;
+	/** Contructor of PublicKeyPrincipal */
+	public PublicKeyPrincipal(String hashValue)
+	{
+		this.hashValue = hashValue;
+	}
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(Object)
+	 */
+	public boolean equals(Object principal)
+	{
+		if (!(principal instanceof PublicKeyPrincipal))
+			return false;
+		return this.hashCode() == principal.hashCode();
+	}
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	public int hashCode()
+	{
+		return hashValue.hashCode();
+	}
+    
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.credential.PrincipalExpression#toString(String)
+	 */
+    public String toString(String indent)
+    {
+        String thisIndent = indent + "  ";
+        return thisIndent + "PublicKeyPrincipal: " + hashValue;
+    }
+
+    /** pretty printing for debugging */
+    public String toString() { return hashValue; }
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/PublicKeyPrincipalInfo.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/PublicKeyPrincipalInfo.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/PublicKeyPrincipalInfo.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,40 @@
+package edu.stanford.rt.credential;
+
+import java.security.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ *
+ * This class stores the public key information about a principal.
+ */
+public class PublicKeyPrincipalInfo
+{
+	private PublicKey publicKey;
+	
+	/**
+     * Constructor for PublicKeyPrincipalInfo
+	 */
+	public PublicKeyPrincipalInfo(PublicKey publicKey)
+	{
+		this.publicKey = publicKey;
+	}
+	/**
+	 * Returns the publicKey.
+	 * @return PublicKey
+	 */
+	public PublicKey getPublicKey()
+	{
+		return publicKey;
+	}
+
+	/**
+	 * Method toString.
+	 * @param indent
+	 * @return String
+	 */
+    public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+        return thisIndent + publicKey.toString();
+	}
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/RTContext.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/RTContext.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/RTContext.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,185 @@
+package edu.stanford.rt.credential;
+
+//imports Apache Xerces API
+import org.apache.xerces.parsers.DOMParser;
+
+import org.xml.sax.InputSource;
+import org.w3c.dom.*;
+
+import java.util.*;
+import java.io.*;
+
+import edu.stanford.rt.parser.RTParser;
+import edu.stanford.rt.util.*;
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ * RTContext contains the info about <code>ApplicationDomainSecification</code>s and 
+ * <code>Principal</code>s in the system.
+ */
+public class RTContext
+{
+	/**
+	 * Index for <code>ApplicationDomain</code> objects.<br>
+	 * 
+	 * Key: <code>HashID</code> <br>
+	 * Value: <code>ApplicationDomain</code>
+	 */
+	private HashMap applicationDomains;
+
+	/**
+	 * Index for <code>Principal</code> objects.<br>
+	 * 
+	 * Key: <code>PublicKeyPrincipal</code> <br>
+	 * Value: <code>PublicKeyPrincipalInfo</code>
+	 */
+	private HashMap principals;
+
+	/**
+	 * The built-in system domain. 
+	 */
+	private ApplicationDomain systemDomain;
+
+	/**
+	 * Constructor for RTContext.
+	 */
+	public RTContext(RTParser rtParser) throws Exception
+	{
+		this.applicationDomains = new HashMap();
+		this.principals = new HashMap();
+        // others need to call parseSystemDomain(InputStream).        
+		this.systemDomain = rtParser.createSystemDomain();
+	}
+
+	/**
+	 * Method getSystemDomain.
+	 * @return ApplicationDomain
+	 */
+	public ApplicationDomain getSystemDomain()
+	{
+		return systemDomain;
+	}
+
+	/**
+	 * Method getApplicationDomain.
+	 * @param id
+	 * @return ApplicationDomain
+	 */
+	public ApplicationDomain getApplicationDomain(String id)
+	{
+		return getApplicationDomain(
+			new HashID(HashID.APPLICATION_DOMAIN, id));
+	}
+
+	/**
+	 * Method getApplicationDomain.
+	 * @param id
+	 * @return ApplicationDomain
+	 */
+	public ApplicationDomain getApplicationDomain(HashID id)
+	{
+		RTUtil.debugInfo("RTContex.getApplicationDomain() .... ");
+		RTUtil.debugInfo("      id = " + id.toString());
+		return (ApplicationDomain) applicationDomains.get(id);
+	}
+
+	/**
+	 * Method addApplicationDomain.
+	 * @param id
+	 * @param appDomain
+	 * @throws DomainSpecException
+	 */
+	public synchronized void addApplicationDomain(
+		HashID id,
+		ApplicationDomain appDomain)
+		throws DomainSpecException
+	{
+//		RTUtil.debugInfo("RTContex.addApplicationDomain() .... ");
+//		RTUtil.debugInfo("      id = " + id.toString());
+//		RTUtil.debugInfo("&&&&& ");
+//		RTUtil.debugInfo(appDomain.toString(" "));
+//		RTUtil.debugInfo("&&&&& ");
+
+		if (this.applicationDomains.get(id) != null)
+			throw new DomainSpecException("Duplicated domains in CredentialStore.");
+		this.applicationDomains.put(id, appDomain);
+	}
+
+	/**
+	 * Method getPrincipal.
+	 * @param id
+	 * @return PublicKeyPrincipalInfo
+	 */
+	public PublicKeyPrincipalInfo getPrincipal(PublicKeyPrincipal id)
+	{
+		return (PublicKeyPrincipalInfo) principals.get(id);
+	}
+
+	/**
+	 * Method addPrincipals.
+	 * @param id
+     *  the hash value of the principal
+	 * @param principal
+     *  the public key info of the principal
+	 * @throws DomainSpecException
+	 */
+	public synchronized void addPrincipal(
+		PublicKeyPrincipal id,
+		PublicKeyPrincipalInfo principal)
+		throws DomainSpecException
+	{
+		if (this.principals.get(id) != null)
+			throw new DomainSpecException("Duplicated");
+		this.principals.put(id, principal);
+	}
+	/**
+	 * Method hasDomainWithID.
+     *  checks if there is an ApplicationDomain object with given hash id.
+	 * @param idref
+	 * @return boolean
+	 */
+	public boolean hasDomainWithID(String idref)
+	{
+		boolean exists = true;
+		if (getApplicationDomain(idref) == null)
+			exists = false;
+		return exists;
+	}
+
+	public String toString(String indent)
+	{
+		StringBuffer sb = new StringBuffer();
+		String thisIndent = indent + "  ";
+
+		sb.append(
+			"********** RTContext: **********\n\n");
+		sb.append(thisIndent).append("System Domain: \n");
+		sb.append(systemDomain.toString(thisIndent));
+
+		sb.append(thisIndent).append("Imported Domains: \n");
+		Set entries = applicationDomains.entrySet();
+		Iterator it = entries.iterator();
+		while (it.hasNext())
+		{
+			Map.Entry entry = (Map.Entry) it.next();
+			ApplicationDomain domain =
+				(ApplicationDomain) entry.getValue();
+			sb.append(domain.toString(thisIndent));
+            sb.append("\n");
+		}
+
+		sb.append(thisIndent).append("Principals: \n");
+		entries = principals.entrySet();
+		it = entries.iterator();
+		while (it.hasNext())
+		{
+			Map.Entry entry = (Map.Entry) it.next();
+			PublicKeyPrincipalInfo principal =
+				(PublicKeyPrincipalInfo) entry.getValue();
+			sb.append(principal.toString(thisIndent));
+            sb.append("\n");
+		}
+
+		return sb.toString();
+	}
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/Role.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/Role.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/Role.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,87 @@
+package edu.stanford.rt.credential;
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>Role</code> object in RTML.
+ * A role consists of 2 parts: a principal and a role term. 
+ */
+public class Role implements PrincipalExpression
+{
+	private Principal principal; // required element.
+	private RoleTerm roleTerm; // required element.
+	/**
+	 * Constructor for Role.
+	 */
+	public Role(Principal principal, RoleTerm roleTerm)
+	{
+		this.principal = principal;
+		this.roleTerm = roleTerm;
+	}
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	public int hashCode()
+	{
+		return getPrincipal().hashCode() * 2 + getName().hashCode();
+	}
+	/**
+	 * Two roles are equal if both their principals are equal and 
+	 * the role names are equal.
+	 * 
+	 */
+	public boolean equals(Object o)
+	{
+		return (o instanceof Role)
+			&& getPrincipal().equals(((Role) o).getPrincipal())
+			&& getName().equals(((Role) o).getName());
+	}
+	/**
+	 * Returns the principal.
+	 * @return Principal
+	 */
+	public Principal getPrincipal()
+	{
+		return principal;
+	}
+	/**
+	 * Returns the roleTerm.
+	 * @return RoleTerm
+	 */
+	public RoleTerm getRoleTerm()
+	{
+		return roleTerm;
+	}
+	/**
+	 * Method getRoleDeclaration.
+	 * @return RoleDeclaration
+	 * 		The corresponding role declaration.
+	 */
+	public RoleDeclaration getRoleDeclaration()
+	{
+		return roleTerm.getRoleDeclaration();
+	}
+	/**
+	 * Method getName.
+	 * @return String
+	 * 		The role name.
+	 */
+	public String getName()
+	{
+		return roleTerm.getRoleDeclaration().getName();
+	}
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.credential.PrincipalExpression#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("Role: \n");
+		if (principal != null)
+			sb.append(principal.toString(thisIndent + "  ")).append(
+				"\n");
+		sb.append(roleTerm.toString(thisIndent + "  ")).append("\n");
+		return sb.toString();
+	}
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleDeclaration.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleDeclaration.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleDeclaration.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,565 @@
+package edu.stanford.rt.credential;
+import java.util.*;
+import edu.stanford.rt.util.*;
+import edu.stanford.rt.datatype.*;
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ *  All the information about a declared role.  In RTML, this is 
+ *  represented by a <code>RoleDeclaration</code> element in a 
+ *  <code>ApplicationDomainSpecification</code> document.
+ * 
+ *	Issue: Do not support identity yet.
+ */
+public class RoleDeclaration
+	implements Constants, java.io.Serializable
+{
+    /**
+     * Issuer traces types
+     */
+	static public HashMap issuerTracesTypes;
+    /**
+     * Subject traces types
+     */
+	static public HashMap subjectTracesTypes;
+	static {
+		issuerTracesTypes = new HashMap(4);
+		issuerTracesTypes.put("all", new Integer(ISSUER_TRACES_ALL));
+		issuerTracesTypes.put("def", new Integer(ISSUER_TRACES_DEF));
+		issuerTracesTypes.put(
+			"rule",
+			new Integer(ISSUER_TRACES_RULE));
+		issuerTracesTypes.put(
+			"none",
+			new Integer(ISSUER_TRACES_NONE));
+		subjectTracesTypes = new HashMap(3);
+		subjectTracesTypes.put(
+			"all",
+			new Integer(SUBJECT_TRACES_ALL));
+		subjectTracesTypes.put(
+			"fact",
+			new Integer(SUBJECT_TRACES_FACT));
+		subjectTracesTypes.put(
+			"none",
+			new Integer(SUBJECT_TRACES_NONE));
+	}
+    /**
+     * Default issuer traces type: rule
+     */
+	static public int DEFAULT_ISSUER_TYPE = ISSUER_TRACES_RULE;
+    /**
+     * Defualt issuer traces type: fact.
+     */
+	static public int DEFAULT_SUBJECT_TYPE = SUBJECT_TRACES_FACT;
+	/**
+	 * Role declaration context. 
+	 * <br>
+	 * The <code>DomainSpecification</code> in which the current role
+	 * is declared.
+	 */
+	private DomainSpecification context;
+	/** Role name. <br>
+	 * In RTML: attribute <code>name</code>.
+	 */
+	private String name;
+	/** Default is DEFAULT_ISSUER_TYPE <br>
+	 *  In RTML: attribute <code>issuerTracesType</code>.
+	 */
+	private int issuerTracesType = DEFAULT_ISSUER_TYPE;
+	/** Default is DEFAULT_SUBJECT_TYPE <br>
+	 *  In RTML: attribute <code>subjectTracesType</code>.
+	 */
+	private int subjectTracesType = DEFAULT_SUBJECT_TYPE;
+	/**  Default is 1 <br>
+	 * In RTML: attribute <code>dimension</code>.
+	 */
+	private int dimension = 1;
+	/** Default is false. <br>
+	 * In RTML: attribute <code>isIdentity</code>.
+	 */
+	private boolean isIdentity = false;
+	/** Maps String (parameter name) to DataType (parameter type). */
+	private OrderedMap parameterDeclarations;
+	/** Declaration type: Restriction, Extension, Projection or Plain. */
+	private int declarationType;
+	/** BaseRole Element for Restriction, Extension, Projection. */
+	private RoleDeclaration baseRole;
+	/** This map keeps track of the ordersing of the flattend name-prefixes.
+	 A name-prefix is colon-separated name concatenation.*/
+	private HashMap prefixToPositions;
+	private HashMap positionToPrefixes;
+    
+    // Role declaration types
+	static private final int RESTRICTION = 1;
+	static private final int EXTENSION = 2;
+	static private final int PROJECTION = 3;
+	static private final int PLAIN = 4;
+	/**
+	 *  Private contructor ensures that no one else can contruct a RoleDeclaration
+	 *  object and the state of a RoleDeclaration object is complete (unmodifiable)
+	 *  once it is created. <br>
+	 * 	And the newly created RoleDeclaration's parameter-postion mapping is also
+	 * 	calculated.
+	 * @param context
+	 * @param name
+	 * @param issuerTracesType
+	 * @param subjectTracesType
+	 * @param dimension
+	 * @param isIdentity
+	 * @param declarationType
+	 * @param baseRole
+	 * @param parameterDeclarations
+	 * @throws DomainSpecException
+	 */
+	private RoleDeclaration(
+		DomainSpecification context,
+		String name,
+		int issuerTracesType,
+		int subjectTracesType,
+		int dimension,
+		boolean isIdentity,
+		int declarationType,
+		RoleDeclaration baseRole,
+		OrderedMap parameterDeclarations)
+		throws DomainSpecException
+	{
+		this.context = context;
+		this.name = name;
+		this.issuerTracesType = issuerTracesType;
+		this.subjectTracesType = subjectTracesType;
+		this.dimension = dimension;
+		this.isIdentity = isIdentity;
+		this.declarationType = declarationType;
+		this.baseRole = baseRole;
+		this.parameterDeclarations = parameterDeclarations;
+		this.parameterDeclarations.setUneditable();
+		this.prefixToPositions = new HashMap();
+		this.positionToPrefixes = new HashMap();
+		// Compute parameters, which includes all parameters of base role plus 
+		// those in "this" role.
+		calculatePrefixPositions(
+			new StringBuffer(name),
+			0,
+			this.parameterDeclarations,
+			this.prefixToPositions,
+			this.positionToPrefixes);
+	}
+	/**
+	 * Method createRestrictionRole.
+	 * 		Public interface to construct a <code>Restriction</code> type 
+	 * 		<code>RoleDeclaration</code> object.
+	 * @param name
+	 * @param isIdentity
+	 * @param baseRole
+	 * @param newParameters
+	 * @return RoleDeclaration
+	 * @throws DomainSpecException
+	 */
+	public static RoleDeclaration createRestrictionRole(
+		DomainSpecification context,
+		String name,
+		boolean isIdentity,
+		RoleDeclaration baseRole,
+		OrderedMap newParameters)
+		throws DomainSpecException
+	{
+		if (baseRole == null)
+			throw new DomainSpecException("");
+		int issuerTracesType = baseRole.getIssuerTracesType();
+		int subjectTracesType = baseRole.getSubjectTracesType();
+		int dimension = baseRole.getDimension();
+		OrderedMap parameterDeclarations =
+			new OrderedMap(String.class, DataType.class);
+		parameterDeclarations.putAll(
+			baseRole.getParameterDeclarations());
+		parameterDeclarations.putAll(parameterDeclarations);
+		return new RoleDeclaration(
+			context,
+			name,
+			issuerTracesType,
+			subjectTracesType,
+			dimension,
+			isIdentity,
+			RESTRICTION,
+			baseRole,
+			parameterDeclarations);
+	}
+	/**
+	 * Method createExtensionRole.
+	 * 		Public interface to construct an <code>Extension</code> type 
+	 * 		<code>RoleDeclaration</code> object.
+	 * @param name
+	 * @param isIdentity
+	 * @param baseRole
+	 * @param newParameters
+	 * @return RoleDeclaration
+	 * @throws DomainSpecException
+	 */
+	public static RoleDeclaration createExtensionRole(
+		DomainSpecification context,
+		String name,
+		boolean isIdentity,
+		RoleDeclaration baseRole,
+		OrderedMap newParameters)
+		throws DomainSpecException
+	{
+		if (baseRole == null)
+			throw new DomainSpecException("");
+		int issuerTracesType = baseRole.getIssuerTracesType();
+		int subjectTracesType = baseRole.getSubjectTracesType();
+		int dimension = baseRole.getDimension();
+		OrderedMap parameterDeclarations =
+			new OrderedMap(String.class, DataType.class);
+		parameterDeclarations.putAll(
+			baseRole.getParameterDeclarations());
+		parameterDeclarations.putAll(parameterDeclarations);
+		return new RoleDeclaration(
+			context,
+			name,
+			issuerTracesType,
+			subjectTracesType,
+			dimension,
+			isIdentity,
+			EXTENSION,
+			baseRole,
+			parameterDeclarations);
+	}
+	/**
+	 * Method createProjectionRole.
+	 * 		Public interface to construct a <code>Projection</code> type 
+	 * 		<code>RoleDeclaration</code> object.
+	 * @param name
+	 * @param isIdentity
+	 * @param baseRole
+	 * @param parameterNames
+	 * @return RoleDeclaration
+	 * @throws DomainSpecException
+	 */
+	public static RoleDeclaration createProjectionRole(
+		DomainSpecification context,
+		String name,
+		boolean isIdentity,
+		RoleDeclaration baseRole,
+		String[] parameterNames)
+		throws DomainSpecException
+	{
+		if (baseRole == null)
+			throw new DomainSpecException("");
+		int issuerTracesType = baseRole.getIssuerTracesType();
+		int subjectTracesType = baseRole.getSubjectTracesType();
+		int dimension = baseRole.getDimension();
+		OrderedMap parameterDeclarations =
+			new OrderedMap(String.class, DataType.class);
+		OrderedMap baseRoleParameters =
+			baseRole.getParameterDeclarations();
+		for (int i = 0; i < parameterNames.length; i++)
+		{
+			DataType type =
+				baseRole.getParameterType(parameterNames[i]);
+			parameterDeclarations.put(parameterNames[i], type);
+		}
+		return new RoleDeclaration(
+			context,
+			name,
+			issuerTracesType,
+			subjectTracesType,
+			dimension,
+			isIdentity,
+			PROJECTION,
+			baseRole,
+			parameterDeclarations);
+	}
+	/**
+	 * Method createPlainRole.
+	 * Public interface to construct a <code>Plain</code> type of 
+     * <code>RoleDeclaration</code> object. <code>Identity</code> is not supported.
+	 * @param name
+	 * @param issuerTracesType
+	 * @param subjectTracesType
+	 * @param dimension
+	 * @param isIdentity
+	 * @param newParameters
+	 * @return RoleDeclaration
+	 * @throws DomainSpecException
+	 */
+	public static RoleDeclaration createPlainRole(
+		DomainSpecification context,
+		String name,
+		int issuerTracesType,
+		int subjectTracesType,
+		int dimension,
+		boolean isIdentity,
+		OrderedMap newParameters)
+		throws DomainSpecException
+	{
+		return new RoleDeclaration(
+			context,
+			name,
+			issuerTracesType,
+			subjectTracesType,
+			dimension,
+			isIdentity,
+			PLAIN,
+			null,
+			newParameters);
+	}
+	/** Returns the role declaration context. */
+	public DomainSpecification getContext()
+	{
+		return context;
+	}
+	/** Returns the role name. */
+	public String getName()
+	{
+		return name;
+	}
+	/** Returns the value for <code>issuerTracesType</code>. */
+	public int getIssuerTracesType()
+	{
+		return issuerTracesType;
+	}
+	/** Returns the value for <code>subjectTracesType</code>. */
+	public int getSubjectTracesType()
+	{
+		return subjectTracesType;
+	}
+	/**
+	 * Returns the value for <code>dimension</code>.
+	 */
+	public int getDimension()
+	{
+		return dimension;
+	}
+	/** Returns the base role object. */
+	public RoleDeclaration getBaseRole()
+	{
+		return baseRole;
+	}
+	/** Checks whether this role is an identity-based role. */
+	public boolean isIdentity()
+	{
+		return isIdentity;
+	}
+	/**
+	 * Method getParameterDeclarations.
+	 * @return OrderedMap
+	 *	 	Returns an OrderedMap of parameter declarations in 
+	 *  this role declaration object. <br>
+	 *  For Restriction or Extension type <code>RoleDeclaration</code>, 
+	 *  the map contains parameters declared both in base role and this role.
+	 *  For Projection type <code>RoleDeclaration</code>, 
+	 *  the map contains only those paraeters declared in base role with 
+	 *  matching names with this role's declared parameters.
+	 * 
+	 * @throws DomainSpecException
+	 */
+	public synchronized OrderedMap getParameterDeclarations()
+		throws DomainSpecException
+	{
+		if (parameterDeclarations.isEditable())
+			throw new IllegalStateException("Parameter declarations are not finalized.");
+		return parameterDeclarations;
+	}
+	/**
+	 * Method getParameterType.
+	 * @param paramName name of the declared parameter.
+	 * @return DataType type of the declared parameter.
+	 * @throws DomainSpecException 
+	 */
+	public DataType getParameterType(String paramName)
+		throws DomainSpecException
+	{
+		return (DataType) parameterDeclarations.get(paramName);
+	}
+	/** Returns a unmodifiable view of prefix-to-position map.*/
+	public synchronized Map getPrefixToPositions()
+	{
+		return Collections.unmodifiableMap(prefixToPositions);
+	}
+	/** Returns a unmodifiable view of position-to-prefix map.*/
+	public synchronized Map getPositionToPrefixes()
+	{
+		return Collections.unmodifiableMap(positionToPrefixes);
+	}
+	/** Returns the total number of the prefixes in the map.*/
+	public int getTotalPrefixes()
+	{
+		return prefixToPositions.size();
+	}
+	/**
+	 * Method getPosition.
+	 * @param prefix 
+	 * 		the prefix to get the position with.
+	 * @return int
+	 * 		the postition of the given prefix.
+	 */
+	public int getPosition(String prefix)
+	{
+		Integer pos = (Integer) prefixToPositions.get(prefix);
+		return pos.intValue();
+	}
+	/**
+	 * Method getPrefix.
+	 * @param position 
+	 * 		the position to get prefix with.
+	 * @return String
+	 * 		the prefix at the given position.
+	 */
+	public String getPrefix(int position)
+	{
+		return (String) positionToPrefixes.get(new Integer(position));
+	}
+	/**
+	 * Method toString.
+	 * @param indent
+	 * @return String
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+
+		sb.append(thisIndent).append("RoleDeclaration: ").append(
+			name).append(
+			"\n");
+		sb
+			.append(thisIndent + "  ")
+			.append("issuerTracesType = ")
+			.append(getIssuerTracesTypeString(issuerTracesType))
+			.append("\n");
+		sb
+			.append(thisIndent + "  ")
+			.append("subjectTracesType = ")
+			.append(getSubjectTracesTypeString(subjectTracesType))
+			.append("\n");
+
+		sb.append(thisIndent + "  ").append("Parameters: \n");
+		Iterator it = parameterDeclarations.keyIterator();
+		while (it.hasNext())
+		{
+			String key = (String) it.next();
+			sb.append(thisIndent + "    ").append(key);
+			try
+			{
+				DataType value =
+					(DataType) parameterDeclarations.get(key);
+				sb.append("    ").append(value.getName()).append(
+					"\n");
+			}
+			catch (DomainSpecException e)
+			{
+				e.printStackTrace();
+			}
+		}
+		return sb.toString();
+	}
+
+    /**
+     * Method calculatePrefixPositions.
+     * @param prefix        
+     *      current prefix. Prefix is a lolon-saparated string, which 
+     *      is the concatenation of role name and parameter names.
+     * @param position  
+     *      the current position of the prefix.
+     * @param paramDeclarations 
+     *      all parameters declared in this role.
+     * @param prefixToPositionMap
+     *      a HashMap which maps a prefix to its position.
+     * @param positionToPrefixMap
+     *      a HashMap which maps a position to its prefix
+     * @throws DomainSpecException
+     *      
+     */
+    private synchronized void calculatePrefixPositions(
+        StringBuffer prefix,
+        int position,
+        OrderedMap paramDeclarations,
+        HashMap prefixToPositionMap,
+        HashMap positionToPrefixMap)
+        throws DomainSpecException
+    {
+        RTUtil.debugInfo(
+            "RoleDeclaration.calculatePrefixPositions(, ,  , , ) ....");
+        //        RTUtil.debugInfo("prefix = " + prefix);   
+        Iterator paramNameIt = paramDeclarations.keyIterator();
+        StringBuffer newPrefix = new StringBuffer(prefix.toString());
+        while (paramNameIt.hasNext())
+        {
+            newPrefix.append(COLON);
+            String paramName = (String) paramNameIt.next();
+            newPrefix.append(paramName);
+            RTUtil.debugInfo("newPrefix = " + newPrefix.toString());
+            DataType paramType = getParameterType(paramName);
+            if (paramType instanceof RecordType)
+            {
+                OrderedMap fieldDeclarations =
+                    ((RecordType) paramType).getFieldDeclarations();
+                calculatePrefixPositions(
+                    newPrefix,
+                    position++,
+                    fieldDeclarations,
+                    prefixToPositionMap,
+                    positionToPrefixMap);
+                position++;
+            }
+            else
+            {
+                position++;
+                RTUtil.debugInfo("position = " + position);
+                prefixToPositionMap.put(
+                    newPrefix.toString(),
+                    new Integer(position));
+                positionToPrefixMap.put(
+                    new Integer(position),
+                    newPrefix.toString());
+            }
+            //RTUtil.debugInfo("**** prefix = " + prefix.toString());
+            newPrefix = new StringBuffer(prefix.toString());
+            //RTUtil.debugInfo("newPrefix 2 = " + newPrefix.toString());
+        }
+    }
+
+	private String getIssuerTracesTypeString(int issuerTracesType)
+	{
+		String res = null;
+		switch (issuerTracesType)
+		{
+			case ISSUER_TRACES_ALL :
+				res = "all";
+				break;
+			case ISSUER_TRACES_DEF :
+				res = "def";
+				break;
+			case ISSUER_TRACES_RULE :
+				res = "rule";
+				break;
+			case ISSUER_TRACES_NONE :
+				res = "none";
+				break;
+			default :
+				res = "rule";
+				break;
+		}
+		return res;
+	}
+	private String getSubjectTracesTypeString(int subjectTracesType)
+	{
+		String res = null;
+		switch (subjectTracesType)
+		{
+			case SUBJECT_TRACES_ALL :
+				res = "all";
+				break;
+			case SUBJECT_TRACES_FACT :
+				res = "fact";
+				break;
+			case SUBJECT_TRACES_NONE :
+				res = "none";
+				break;
+			default :
+				res = "fact";
+				break;
+		}
+		return res;
+	}
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleDefinition.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleDefinition.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleDefinition.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,82 @@
+package edu.stanford.rt.credential;
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ *
+ * Implementation of role definition in RTML, which is represented by 
+ * <code>Definition</code> group element.
+ * 
+ * A role definition has a head and a body.
+ */
+public class RoleDefinition
+{
+	/**
+	 * Role head.
+	 */
+	private Role head; // always a local role
+	/**
+	 * Role body.
+	 */
+	private PrincipalExpression body;
+	/**
+	 * role definition context
+	 */
+	private CredentialDomain context;
+
+	/**
+	 * Constructor for RoleDefinition.
+	 */
+	public RoleDefinition(
+		CredentialDomain context,
+		Role head,
+		PrincipalExpression body)
+	{
+		this.context = context;
+		this.head = head;
+		this.body = body;
+	}
+	/**
+	 * Returns the body.
+	 * @return PrincipalExpression
+	 */
+	public PrincipalExpression getBody()
+	{
+		return body;
+	}
+	/**
+	 * Returns the head.
+	 * @return Role
+	 */
+	public Role getHead()
+	{
+		return head;
+	}
+
+	/**
+	 * Method getContext.
+	 * @return CredentialDomain
+	 */
+	public CredentialDomain getContext() throws DomainSpecException
+	{
+		if (!context.isComplete())
+			throw new DomainSpecException("Incomplete CredentialDomain");
+		return context;
+	}
+
+	/**
+	 * Method toString.
+	 * @param indent
+	 * @return String
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("Role Definition: \n");
+		sb.append(thisIndent + "  ").append("Head: \n");
+		sb.append(head.toString(thisIndent + "  ")).append("\n");
+		sb.append(thisIndent + "  ").append("Body: \n");
+		sb.append(body.toString(thisIndent + "  ")).append("\n");
+		return sb.toString();
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleIntersection.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleIntersection.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleIntersection.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,99 @@
+package edu.stanford.rt.credential;
+
+import java.util.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>IntersectionContainment</code> element.
+ * 
+ */
+public class RoleIntersection implements PrincipalExpression
+{
+    /**
+     * list of members in this intersection.
+     */
+	private ArrayList parts; // required element.
+
+    /**
+     * Constuctor for an empty RoleIntersection.
+     */
+	public RoleIntersection()
+	{
+		parts = new ArrayList();
+	}
+
+    /**
+     * Constructor for RoleIntersection
+     */
+	public RoleIntersection(List p)
+	{
+		if (p == null || p.size() == 0)
+			throw new IllegalArgumentException("RoleIntersection: empty parts.");
+		// copy over 
+		parts = new ArrayList();
+		Iterator it = p.iterator();
+		while (it.hasNext())
+		{
+			Object pr = it.next();
+			if (!(pr instanceof RoleTerm) && !(pr instanceof Role))
+				throw new IllegalArgumentException("RoleIntersection: wrong element type");
+			parts.add(pr);
+		}
+	}
+
+	/**
+	 * Method getParts.
+     * returns an unmodifiable view of the members.
+	 * @return List
+	 */
+	public List getParts()
+	{
+		return Collections.unmodifiableList(parts);
+	}
+
+	/**
+	 * Method and.
+     *  AND operation.
+	 * @param part
+	 * @throws CredException
+	 */
+	public void and(Object part) throws CredException
+	{
+		if (!(part instanceof RoleTerm) && !(part instanceof Role))
+			throw new CredException("Illegal part type");
+
+		// add this new part to the set.
+		if (!parts.contains(part))
+			parts.add(part);
+
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.credential.PrincipalExpression#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("Role Intersection: \n");
+		for (int i = 0; i < parts.size(); i++)
+		{
+			if ((parts.get(i)) instanceof Role)
+			{
+				sb.append(
+					((Role) parts.get(i)).toString(
+						thisIndent + "  "));
+			}
+			else if ((parts.get(i)) instanceof RoleTerm)
+			{
+				sb.append(
+					((RoleTerm) parts.get(i)).toString(
+						thisIndent + "  "));
+			}
+			sb.append("\n");
+		}
+		return sb.toString();
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleTerm.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleTerm.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/RoleTerm.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,152 @@
+package edu.stanford.rt.credential;
+
+import java.util.*;
+
+import edu.stanford.rt.util.*;
+import edu.stanford.rt.datatype.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>RoleTerm</code> element.  Each RoleTerm object 
+ * has  a reference to its corresponding RoleDeclaration object and stores 
+ * its parameter values, if any.
+ * 
+ */
+public class RoleTerm
+{
+	// The corresponding role declaration.
+	private RoleDeclaration roleDeclaration;
+
+	// Stores parameter values according to the prefix positions in role declaration.
+	private ValueSet[] paramValues;
+
+    /**
+     * Constructor for RoleTerm.
+     * 
+     * @param roleDeclaration
+     *      corresponding role declaration.
+     */
+	public RoleTerm(RoleDeclaration roleDeclaration)
+	{
+		this.roleDeclaration = roleDeclaration;
+		this.paramValues =
+			new ValueSet[roleDeclaration.getTotalPrefixes() + 1];
+		this.paramValues[0] = null;
+	}
+
+	/**
+	 * Returns the roleDeclaration.
+	 * @return RoleDeclaration  
+	 * 		The corresonding role decalration for this role term.
+	 */
+	public RoleDeclaration getRoleDeclaration()
+	{
+		return roleDeclaration;
+	}
+
+	/**
+	 * Method putParameterValue.
+     *      puts parameter value according to the position of the 
+     *      its prefix.
+	 * @param prefix
+     *      the parameter prefix
+	 * @param parameterValue
+     *      the parameter value
+	 */
+	public void putParameterValue(
+		String prefix,
+		ValueSet parameterValue)
+	{
+		//RTUtil.debugInfo("RoleTerm.putParameterValue().roleDeclaration = " 
+		//          +roleDeclaration.getName());
+		RTUtil.debugInfo(
+			"RoleTerm.putParameterValue().prefix = " + prefix);
+
+		int index = roleDeclaration.getPosition(prefix);
+		RTUtil.debugInfo(
+			"RoleTerm.putParameterValue().index = " + index);
+		// empty element for index 0
+		paramValues[index] = parameterValue;
+	}
+
+	/**
+	 * Method getParameterValue.
+	 * @param prefix
+	 * @return ValueSet
+	 */
+	public ValueSet getParameterValue(String prefix)
+	{
+		int index = roleDeclaration.getPosition(prefix);
+		return paramValues[index];
+	}
+
+	/**
+	 * Method getParameterValueAt.
+	 * @param index
+	 * @return ValueSet
+	 */
+	public ValueSet getParameterValueAt(int index)
+	{
+		return paramValues[index];
+	}
+
+	/**
+	 * Method getParameterType.
+	 * @param parameterName
+	 * @return DataType
+	 * @throws DomainSpecException
+	 */
+	public DataType getParameterType(String parameterName)
+		throws DomainSpecException
+	{
+		return roleDeclaration.getParameterType(parameterName);
+	}
+
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("RoleTerm: \n");
+		sb.append(thisIndent + "  ").append(
+			"Corresponding role declaration: ");
+		sb.append(roleDeclaration.getName()).append("\n");
+		sb.append(thisIndent + "  ").append("Parameters: \n");
+		for (int i = 1; i < paramValues.length; i++)
+		{
+			if (paramValues[i] != null
+				&& !isParameterValueNull(paramValues[i]))
+				sb
+					.append(thisIndent + "    ")
+					.append(paramValues[i].toString(thisIndent))
+					.append("\n");
+		}
+
+		return sb.toString();
+	}
+    
+    /**
+     * Method isParameterValueNull.
+     *      checks if the parameter value is null. It can be null when 
+     *      the parameter has <code>Equals</code> or <code>Special Principal</code>
+     *      child element.
+     * @param paramValue
+     * @return boolean
+     */
+    public boolean isParameterValueNull(ValueSet paramValue)
+    {
+        if (paramValue == null)
+            return true;
+
+        if (!(paramValue instanceof TreeValueSet)
+            && !(paramValue instanceof IntervalValueSet)
+            && !(paramValue instanceof SetValueSet)
+            && !(paramValue instanceof SingletonValueSet))
+            return true;
+        else
+            return false;
+    }
+
+
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/credential/ValidityTime.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/credential/ValidityTime.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/credential/ValidityTime.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,47 @@
+package edu.stanford.rt.credential;
+
+import java.util.Date;
+
+import edu.stanford.rt.util.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ * TODO
+ */
+public class ValidityTime
+{
+    private Date issueAt;
+    private Date validFrom;
+    private Date validTo;
+    
+    public ValidityTime(Date issueAt, Date validFrom, Date validTo)
+    {
+        if(issueAt==null)
+            throw new IllegalArgumentException("issueAt is null");
+        if(validFrom==null)
+            throw new IllegalArgumentException("validFrom is null");
+        if(validTo==null)
+            throw new IllegalArgumentException("validTo is null");
+
+        this.issueAt = issueAt;
+        this.validFrom = validFrom;
+        this.validTo = validTo;
+    }
+    
+    public Date getIssueAt()
+    {
+        return issueAt;
+    }
+    
+    public Date getValidFrom()
+    {
+        return validFrom;
+    }
+
+    public Date getValidTo()
+    {
+        return validTo;
+    }
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Entries
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,26 @@
+/DataType.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/DataValue.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/DecimalType.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/DecimalValue.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/EnumType.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/EnumValue.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/IntegerType.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/IntegerValue.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/IntervalValueSet.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/KeyType.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/KeyValue.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/OrderedType.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/PrincipalValue.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/RecordType.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/SetValueSet.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/SimpleType.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/SingletonValueSet.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/StringType.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/StringValue.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/TimeType.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/TimeValue.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/TreeType.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/TreeValue.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/TreeValueSet.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/ValueSet.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+D
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Entries.Log
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Entries.Log	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Entries.Log	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+A D/todo////
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Repository
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+rtml/src/edu/stanford/rt/datatype
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Root
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+:ext:jjacobs@src.columbia.sparta.com/cvs/abac
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DataType.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DataType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DataType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,40 @@
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ *  DataType is the super class of all data type classes in RTML. 
+ *   Every data type must have a type name. 
+ */
+public abstract class DataType
+{
+    /** The name of the defined type */
+    private String name; 
+
+    DataType(String name) 
+    {
+        this.name = name;
+    }
+
+    /** Return the name of this type. */
+    public String getName()
+    {
+        return name;
+    }
+    
+	/**
+	 * Method toString.
+	 * @param indent
+	 * @return String
+	 */
+    public String toString(String indent)
+    {
+        return indent + "  " + name;
+    }
+    
+    public String toString()
+    {
+        return name;
+    }
+}
+    
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DataValue.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DataValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DataValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,12 @@
+
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * DataValue is the interface for all data value defined in 
+ * DomainSpecification of RT XML.
+ */
+public interface DataValue
+{
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DecimalType.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DecimalType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DecimalType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,122 @@
+
+package edu.stanford.rt.datatype;
+
+import edu.stanford.rt.util.*;
+
+/**
+    DecimalType defines the decimal type. The name for this type is "DecimalType".
+    It has the following attributes: min, max, base, and step.
+    
+    TODO
+*/
+public class DecimalType extends OrderedType
+{
+    private double min;
+    private double max;
+    private boolean includeMin = true;
+    private boolean includeMax = true;
+    private double base;
+    private double step;
+
+    /**
+        
+    */
+    public DecimalType (String name, double min, double ma, 
+                boolean includeMin,boolean includeMax, 
+                double base, double step)
+        throws IllegalArgumentException
+    {
+        super(name);
+        
+        //throw new UnsupportedException();
+
+        // Check to make sure that at least one value is legal
+        if (min > max) {
+            throw new IllegalArgumentException("DecimalType: min > max");
+        }
+        if(base < min || base > max) {
+            throw new IllegalArgumentException(
+                "DecimalType: base in not within min and max");
+        }
+        if (step <= 0) {
+            throw new IllegalArgumentException("DecimalType: step <= 0");
+        }
+
+        double x = (min - base) % step;
+        if (x>0 && (min + step - x) > max) {
+            throw new IllegalArgumentException(
+                "DecimalType: First legal value is out of bound.");
+        } 
+        
+        this.min = min;
+        this.max = max;
+        this.includeMin = includeMin;
+        this.includeMax = includeMax;
+        this.base = base;
+        this.step = step;
+    }
+    
+    public double getMin()
+    {
+        return min;
+    }
+    public double getMax()
+    {
+        return max;
+    }
+    public boolean isMinIncluded()
+    {
+        return includeMin;
+    }
+    public boolean isMaxIncluded()
+    {
+        return includeMax;
+    }
+    public double getBase()
+    {
+        return base;
+    }
+    public double getStep()
+    {
+        return step;
+    }
+    
+    public boolean isValidValue(DataValue v)
+    {
+        if (!(v instanceof DecimalValue)) {
+            return false;
+        }
+        
+        double l = ((DecimalValue)v).getValue();
+        if (l >= min && l<= max && ((l-base) % step == 0)) {
+            return true;
+        }
+        return false;
+    }
+    
+    public int compares(DataValue value1, DataValue value2)
+    {
+        if(!(value1 instanceof DecimalValue) ||
+           !(value2 instanceof DecimalValue) )
+           throw new IllegalArgumentException(
+           "Wrong argument type");
+        
+        double val1 = ((DecimalValue)value1).getValue();
+        double val2 = ((DecimalValue)value2).getValue();
+        
+        if(val1 < val2)
+            return -1;
+        else if(val1 > val2)
+            return 1;
+        else
+            return 0;
+    }
+    
+    public String toString(String indent)
+    {
+        String thisIndent = indent+"  ";
+        return thisIndent + "DecimalType: \n";
+    }
+    
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DecimalValue.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DecimalValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/DecimalValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,32 @@
+package edu.stanford.rt.datatype;
+
+/**
+    An object which holds an double value.
+    
+    TODO
+*/
+public class DecimalValue implements DataValue
+{
+    double value;
+    
+    public DecimalValue(String value)
+    {
+        this.value = Double.parseDouble(value);
+    }
+    
+    public DecimalValue(double value)
+    {
+        this.value = value;
+    }
+    
+    public double getValue()
+    {
+        return value;
+    }
+    
+    public String toString()
+    {
+        return String.valueOf(value);
+    }
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/EnumType.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/EnumType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/EnumType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,197 @@
+package edu.stanford.rt.datatype;
+
+import java.util.*;
+
+import edu.stanford.rt.credential.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ *
+ * Represents <code>EnumType</code> element in DomainSpecification.
+ * Each <code>EnumType</code> declaration object knows its legal values
+ * and the ordering of the values if the values are ordered.
+ */
+public class EnumType extends OrderedType
+{
+    /** the number of values this type has*/
+	private int size;
+    
+	/** Defines the ordering of values.*/
+	private DataType valueType;
+
+    /** are  values  case-sensitive?*/
+	private boolean ignoreCase;
+    
+    /** are values  ordered in any way?*/
+	private boolean ordered;
+
+	/** the list of values in their natural order, i.e. the order that 
+        being added to the list*/
+	private ArrayList values;
+
+	/** We also store the values in a hash set to speed up 
+        membership tests.*/
+	private HashSet valuesCopy;
+
+	/**
+	 * Constructor for EnumType.
+	 */
+	public EnumType(
+		String name,
+		DataType valueType,
+		OrderedMap enumValues,
+		boolean ignoreCase,
+		boolean ordered,
+		int size)
+		throws IllegalArgumentException
+	{
+		super(name);
+		this.valueType = valueType;
+
+		if (size != 0)
+			this.size = size;
+		else
+			this.size = enumValues.size();
+		if (this.size <= 0)
+		{
+			throw new IllegalArgumentException("EnumType constructor error: empty values.");
+		}
+
+		if (!enumValues.getKeyClass().equals(String.class))
+		{
+			throw new IllegalArgumentException("EnumType constructor error: non-string value.");
+		}
+
+		this.values = new ArrayList(enumValues.keyList());
+		this.valuesCopy = new HashSet(enumValues.keyList());
+		this.ignoreCase = ignoreCase;
+		this.ordered = ordered;
+	}
+
+	/**
+	 * Method setValueType.
+	 * @param type
+	 */
+	public void setValueType(DataType type)
+	{
+		valueType = type;
+	}
+
+    /**
+     * Method getValueType.
+     * @return DataType
+     */
+    public DataType getValueType()
+    {
+        return valueType;
+    }
+
+	/**
+	 * Method getValues.<p>
+     *      returns an unmodifiable view of the legal values.
+	 * @return List
+	 */
+	public synchronized List getValues()
+	{
+		return Collections.unmodifiableList(values);
+	}
+
+	/**
+	 * Method contains.<p>
+     *      checks whether the given value is part of the legal values.
+	 * @param value
+	 * @return boolean
+	 */
+	public boolean contains(String value)
+	{
+		return valuesCopy.contains(value);
+	}
+
+	/**
+	 * Method getSize.<p>
+     *      returns the actual number of legal values defined 
+     *      for this type.
+	 * @return int
+	 */
+	public int getSize()
+	{
+		return size;
+	}
+
+	/**
+	 * Method isIgnoreCase.<p>
+	 * @return boolean
+	 */
+	public boolean isIgnoreCase()
+	{
+		return ignoreCase;
+	}
+	/**
+	 * Method isOrdered.
+	 * @return boolean
+	 */
+	public boolean isOrdered()
+	{
+		return ordered;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.SimpleType#isValidValue(DataValue)
+	 */
+	public boolean isValidValue(DataValue v)
+	{
+		if (!(v instanceof EnumValue))
+			return false;
+		String val = ((EnumValue) v).getValue();
+		if (!valuesCopy.contains(val))
+			return false;
+		return true;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.OrderedType#compares(DataValue, DataValue)
+	 */
+	public int compares(DataValue value1, DataValue value2)
+	{
+		if (!(value1 instanceof EnumValue)
+			|| !(value2 instanceof EnumValue))
+			throw new IllegalArgumentException("Wrong argument type");
+
+		String val1 = ((EnumValue) value1).getValue();
+		String val2 = ((EnumValue) value2).getValue();
+
+		return val1.compareTo(val2);
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.DataType#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("EnumType:   ").append(
+			getName()).append(
+			"\n");
+		sb.append(thisIndent+"  ").append(" {");
+		Iterator it = values.iterator();
+		while (it.hasNext())
+		{
+			sb.append("\"").append((String) it.next()).append("\"  ");
+		}
+		sb.append("} \n");
+
+		sb
+			.append(thisIndent + "  ")
+			.append("valueType: ")
+			.append(
+				(valueType == null)
+					? "null"
+					: valueType.toString(thisIndent + "  "))
+			.append("\n");
+
+		return sb.toString();
+
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/EnumValue.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/EnumValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/EnumValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,38 @@
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>EnumValue</code> element.
+ * 
+ */
+public class EnumValue implements DataValue
+{
+    private String value;
+    
+    /**
+     * Constructor for EnumValue.
+     */
+    public EnumValue(String value)
+    {
+        this.value = value;
+    }
+    
+	/**
+	 * Method getValue.
+	 * @return String
+	 */
+    public String getValue()
+    {
+        return value;
+    }
+    
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+    public String toString()
+    {
+        return value;
+    }
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/IntegerType.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/IntegerType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/IntegerType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,179 @@
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>IntegerType</code> element
+ */
+public class IntegerType extends OrderedType
+{
+	private long min;
+	private long max;
+	private boolean includeMin = true;
+	private boolean includeMax = true;
+	private long base;
+	private long step;
+
+	/**
+	 * Constructor for IntegerType.
+	 */
+	public IntegerType(
+		String name,
+		long min,
+		long max,
+		boolean includeMin,
+		boolean includeMax,
+		long base,
+		long step)
+		throws IllegalArgumentException
+	{
+		super(name);
+
+		// Check to make sure that at least one value is legal
+		if (min > max)
+		{
+			throw new IllegalArgumentException("IntegerType: min > max");
+		}
+		if (base < min || base > max)
+		{
+			throw new IllegalArgumentException("IntegerType: base in not within min and max");
+		}
+		if (step <= 0)
+		{
+			throw new IllegalArgumentException("IntegerType: step <= 0");
+		}
+
+		long x = (min - base) % step;
+		if (x > 0 && (min + step - x) > max)
+		{
+			throw new IllegalArgumentException("IntegerType: First legal value is out of bound.");
+		}
+
+		this.min = min;
+		this.max = max;
+		this.includeMin = includeMin;
+		this.includeMax = includeMax;
+		this.base = base;
+		this.step = step;
+	}
+
+	/**
+	 * Method getMin.
+	 * @return long
+	 */
+	public long getMin()
+	{
+		return min;
+	}
+	/**
+	 * Method getMax.
+	 * @return long
+	 */
+	public long getMax()
+	{
+		return max;
+	}
+	/**
+	 * Method isMinIncluded.
+	 * @return boolean
+	 */
+	public boolean isMinIncluded()
+	{
+		return includeMin;
+	}
+	/**
+	 * Method isMaxIncluded.
+	 * @return boolean
+	 */
+	public boolean isMaxIncluded()
+	{
+		return includeMax;
+	}
+	/**
+	 * Method getBase.
+	 * @return long
+	 */
+	public long getBase()
+	{
+		return base;
+	}
+	/**
+	 * Method getStep.
+	 * @return long
+	 */
+	public long getStep()
+	{
+		return step;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.SimpleType#isValidValue(DataValue)
+	 */
+	public boolean isValidValue(DataValue v)
+	{
+		if (!(v instanceof IntegerValue))
+		{
+			return false;
+		}
+
+		long l = ((IntegerValue) v).getValue();
+		if (l >= min && l <= max && ((l - base) % step == 0))
+		{
+			return true;
+		}
+		return false;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.OrderedType#compares(DataValue, DataValue)
+	 */
+	public int compares(DataValue value1, DataValue value2)
+	{
+		if (!(value1 instanceof IntegerValue)
+			|| !(value2 instanceof IntegerValue))
+			throw new IllegalArgumentException("Wrong argument type");
+
+		long val1 = ((IntegerValue) value1).getValue();
+		long val2 = ((IntegerValue) value2).getValue();
+
+		if (val1 < val2)
+			return -1;
+		else if (val1 > val2)
+			return 1;
+		else
+			return 0;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.DataType#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("IntegerType: ").append(
+			getName());
+
+		if (includeMin)
+			sb.append(" [");
+		else
+			sb.append(" (");
+		sb.append(min);
+		sb.append(", ");
+		sb.append(max);
+
+		if (includeMax)
+			sb.append("]");
+		else
+			sb.append(") ");
+		if (base != 0)
+			sb.append("base=" + base);
+		if (step != 1)
+			sb.append(", step=" + step);
+		sb.append("\n");
+
+		return sb.toString();
+
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/IntegerValue.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/IntegerValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/IntegerValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,46 @@
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>IntegerValue</code> element.
+ */
+public class IntegerValue implements DataValue
+{
+    private long value;
+    
+    /**
+     * Constructor for IntegerValue.
+     */
+    public IntegerValue(long v)
+    {
+        value = v;
+    }
+
+    /**
+     * Constructor for IntegerValue.
+     */
+    public IntegerValue(String v)
+    {
+        value = (Long.getLong(v)).longValue();
+    }
+    
+    
+	/**
+	 * Method getValue.
+	 * @return long
+	 */
+    public long getValue()
+    {
+        return value;
+    }
+    
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+    public String toString()
+    {
+        return String.valueOf(value);
+    }
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/IntervalValueSet.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/IntervalValueSet.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/IntervalValueSet.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,111 @@
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>Inteval</code> element.
+ * 
+ * An IntervalValueSet represents an Interval value.  It has a min value and
+ * a max value.  When min is null, it means that the lower side is 
+ * unbounded.  When max is null, the upper side is unbounded.  When min
+ * is not null, includeMin can be true.  Similarly, when max is not null,
+ * includeMax can be true.
+ */
+public class IntervalValueSet extends ValueSet
+{
+	private DataValue min;
+	private DataValue max;
+	private boolean includeMin;
+	private boolean includeMax;
+
+    /**
+     * Constructor of IntervalValueSet.
+     */
+	public IntervalValueSet(
+		OrderedType type,
+		DataValue min,
+		DataValue max)
+	{
+        super(type);
+
+        if(! (type instanceof OrderedType))
+            throw new IllegalArgumentException("Wrong data type");            
+		if (min != null && !type.isValidValue(min))
+			throw new IllegalArgumentException("Illegal min value");
+		if (max != null && !type.isValidValue(max))
+			throw new IllegalArgumentException("Illegal max value");
+
+		this.min = min;
+		this.max = max;
+		if (this.min != null)
+			this.includeMin = true;
+		if (this.max != null)
+			this.includeMax = true;
+	}
+
+	/**
+	 * Method getMin.
+	 * @return DataValue
+	 */
+	public DataValue getMin()
+	{
+		return min;
+	}
+
+	/**
+	 * Method getMax.
+	 * @return DataValue
+	 */
+	public DataValue getMax()
+	{
+		return max;
+	}
+
+	/**
+	 * Method isMinIncluded.
+	 * @return boolean
+	 */
+	public boolean isMinIncluded()
+	{
+		return includeMin;
+	}
+
+	/**
+	 * Method isMaxIncluded.
+	 * @return boolean
+	 */
+	public boolean isMaxIncluded()
+	{
+		return includeMax;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.ValueSet#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("IntervalValueSet: \n");
+		sb.append(thisIndent + "  ").append(
+			getType().toString()).append(
+			"\n");
+		sb.append(thisIndent + "  ");
+		if (includeMin)
+			sb.append(" [");
+		else
+			sb.append(" (");
+		sb.append(min.toString());
+		sb.append(", ");
+		sb.append(max.toString());
+
+		if (includeMax)
+			sb.append("]");
+		else
+			sb.append(") ");
+		sb.append("\n");
+
+		return sb.toString();
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/KeyType.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/KeyType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/KeyType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,33 @@
+package edu.stanford.rt.datatype;
+
+/**
+ *  Note: This class is not useable. 
+ * 
+    There could be multiple KeyTypes in the system; however, they 
+    can never be mixed.  Therefore, one cannot declare 
+    is the super class of all data type classes that can have
+    a simple value, it requires its subclasses to check for legal values 
+*/
+public class KeyType extends SimpleType
+{
+    public static final String DSA = "DSAKeyType";
+    public static final String RSA = "RSAKeyType";
+
+    public KeyType(String name)
+    {
+        super(name);
+    }
+
+    /** Check if the DataValue o is a legal value for its type. */
+    public boolean isValidValue(DataValue value)
+    {
+        if(! (value instanceof KeyValue))
+            return false;
+           
+        // TODO, some other test????
+        
+        return true;
+    }
+    
+   
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/KeyValue.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/KeyValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/KeyValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,96 @@
+package edu.stanford.rt.datatype;
+
+import java.security.PublicKey;
+import java.security.KeyFactory;
+import java.security.NoSuchAlgorithmException;
+
+import java.security.spec.DSAPublicKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+import java.security.spec.InvalidKeySpecException;
+
+import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.RSAPublicKey;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ *  Note: This class is not useable. 
+ */
+public class KeyValue implements DataValue
+{
+    private KeyType type;
+    
+    private PublicKey value;
+    
+    public KeyValue(KeyType type, PublicKey value)
+    {
+        this.type = type;
+        this.value = value;
+    }
+
+    public KeyType getType()
+    {
+        return type;
+    }
+        
+    public PublicKey getValue()
+    {
+        return value;
+    }
+
+    public String toString()
+    {
+        KeyFactory kf = null;
+        StringBuffer sb = new StringBuffer();
+
+        if(value instanceof DSAPublicKey)
+        {
+            try
+            {
+                kf = KeyFactory.getInstance("DSA");
+                DSAPublicKeySpec dsaPubKeySpec = 
+                    (DSAPublicKeySpec)kf.getKeySpec(value, DSAPublicKeySpec.class);
+                sb.append("DSA Public Key: \n")
+                    .append("\nG = ").append(dsaPubKeySpec.getG())
+                    .append("\nP = ").append(dsaPubKeySpec.getP())
+                    .append("\nQ = ").append(dsaPubKeySpec.getQ())
+                    .append("\nY = ").append(dsaPubKeySpec.getY());
+            } 
+            catch(NoSuchAlgorithmException e1)
+            {
+                e1.printStackTrace();
+            }
+            catch(InvalidKeySpecException e2)
+            {
+                e2.printStackTrace();
+            }
+        }
+        else if(value instanceof RSAPublicKey)
+        {
+            try
+            {
+                kf = KeyFactory.getInstance("RSA");
+                RSAPublicKeySpec rsaPubKeySpec = 
+                    (RSAPublicKeySpec)kf.getKeySpec(value, RSAPublicKeySpec.class);
+                sb.append("DSA Public Key: \n")
+                    .append("\nModulus = ").append(rsaPubKeySpec.getModulus())
+                    .append("\nExponent = ").append(rsaPubKeySpec.getPublicExponent());
+            } 
+            catch(NoSuchAlgorithmException e1)
+            {
+                e1.printStackTrace();
+            }
+            catch(InvalidKeySpecException e2)
+            {
+                e2.printStackTrace();
+            }
+        }
+        else
+        {
+            // TODO: any
+        }
+        
+        return sb.toString();
+    }
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/OrderedType.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/OrderedType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/OrderedType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,25 @@
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ *  OrderedType is the super class of all totally ordered simple 
+ *  data types: IntegerType, DecimalType, EnumType, StringType, TimeType.
+ *  It requires its subclasses to be able to compare for legal values 
+ */
+public abstract class OrderedType extends SimpleType
+{
+    OrderedType(String name)
+    {
+        super(name);
+    }
+    
+	/**
+	 * Method compares.
+     *      Compares two DataValue objects.
+	 * @param value1
+	 * @param value2
+	 * @return int
+	 */
+    abstract int compares(DataValue value1, DataValue value2);
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/PrincipalValue.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/PrincipalValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/PrincipalValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,43 @@
+package edu.stanford.rt.datatype;
+
+import edu.stanford.rt.credential.*;
+import edu.stanford.rt.datatype.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>PrincipalValue</code> group element. It has a 
+ * <code>Principal</code> value.
+ * 
+ */
+public class PrincipalValue implements DataValue
+{
+    Principal value;
+    /**
+     * Constructor for PrincipalValue.
+     */
+    public PrincipalValue(Principal value)
+    {
+        this.value = value;
+    }
+
+	/**
+	 * Method getValue.
+	 * @return Principal
+	 */
+    public Principal getValue()
+    {
+        return value;
+    }
+        
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        sb.append(value.toString()).append("\n");
+        return sb.toString();
+    }
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/RecordType.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/RecordType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/RecordType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,92 @@
+package edu.stanford.rt.datatype;
+
+import java.util.*;
+
+import edu.stanford.rt.credential.*;
+import edu.stanford.rt.util.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ *  Implementation of the <code>RecordType</code> element in 
+ *  <code>DomainSpecification</code>. 
+ */
+public class RecordType extends DataType
+{
+	/** Maps String (field name) to DataType (field type).*/
+	private OrderedMap fieldDeclarations; //required element.
+
+    /** the number of fields declared for this RecordType declaration.*/
+	private int size;
+
+    /**
+     * constructor for RecordType.
+     */
+	public RecordType(String name, OrderedMap fieldDeclarations)
+		throws DomainSpecException
+	{
+		super(name);
+		int size = fieldDeclarations.size();
+		this.fieldDeclarations =
+			new OrderedMap(size, String.class, DataType.class);
+		this.fieldDeclarations.putAll(fieldDeclarations);
+		this.fieldDeclarations.setUneditable();
+	}
+
+	/**
+	 * Method getFieldDeclarations.
+	 * @return OrderedMap
+	 */
+	public OrderedMap getFieldDeclarations()
+	{
+		if (fieldDeclarations.isEditable())
+			throw new IllegalStateException("Field declarations are not finalized.");
+		return fieldDeclarations;
+	}
+
+	/**
+	 * Method getFieldType.
+     *      returns DataType for the field with given fieldName.
+	 * @param fieldName
+	 * @return DataType
+	 * @throws DomainSpecException
+	 */
+	public DataType getFieldType(String fieldName)
+		throws DomainSpecException
+	{
+		return (DataType) fieldDeclarations.get(fieldName);
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.DataType#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("RecordType: ").append(
+			getName()).append(
+			"\n");
+		sb.append(thisIndent+"  ").append("Fields: \n");
+		Iterator it = fieldDeclarations.keyIterator();
+		while (it.hasNext())
+		{
+			String key = (String) it.next();
+			sb.append(thisIndent + "    ").append(key);
+			DataType value = null;
+			try
+			{
+				value = getFieldType(key);
+                sb.append("    ");
+				sb.append(value.toString()).append("\n");
+			}
+			catch (DomainSpecException e)
+			{
+				e.printStackTrace();
+			}
+
+		}
+		return sb.toString();
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/SetValueSet.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/SetValueSet.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/SetValueSet.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,110 @@
+package edu.stanford.rt.datatype;
+
+import java.util.*;
+
+import edu.stanford.rt.credential.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+    A SetValueSet object contains a set of DataValue objects, which are 
+    instances of  IntegerValue, DecimalValue, StringValue, EnumValue, 
+    or PrincipalValue. All members have the same type.
+ */
+public class SetValueSet extends ValueSet
+{
+	private HashSet values;
+
+	/**
+	 * Constructor for an empty SetValueSet object.
+	 */
+	public SetValueSet(SimpleType type)
+	{
+		super(type);
+		this.values = new HashSet();
+
+	}
+
+	/**
+	 * Constructor for SetValueSet.
+	 */
+	public SetValueSet(SimpleType type, HashSet values)
+		throws DomainSpecException
+	{
+		super(type);
+		this.values = new HashSet();
+
+		Iterator it = values.iterator();
+		while (it.hasNext())
+		{
+			Object o = it.next();
+			if (o == null)
+				continue;
+
+			if (!(o instanceof IntegerValue)
+				&& !(o instanceof DecimalValue)
+				&& !(o instanceof StringValue)
+				&& !(o instanceof EnumValue)
+				&& !(o instanceof PrincipalValue))
+			{
+				throw new DomainSpecException("Illegal argument type");
+			}
+
+			this.values.add((DataValue) o);
+		}
+
+	}
+
+	/**
+	    Add a data value to this set.
+	    Exception is thrown if the given value is not an instance of 
+	    IntegerValue, DecimalValue, StringValue, EnumValue, or PrincipalValue.
+	*/
+	public synchronized void addValue(DataValue value)
+		throws DomainSpecException
+	{
+		if (value != null)
+		{
+			if (!(value instanceof IntegerValue)
+				|| !(value instanceof DecimalValue)
+				|| !(value instanceof StringValue)
+				|| !(value instanceof EnumValue)
+				|| !(value instanceof PrincipalValue))
+			{
+				throw new DomainSpecException("Illegal argument type");
+			}
+
+			this.values.add(value);
+		}
+	}
+
+	/** Returns an unmodifiable view of the values.*/
+	public Set getValues()
+	{
+		return Collections.unmodifiableSet(values);
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.ValueSet#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("SetValueSet: \n");
+		sb.append(thisIndent + "  ").append(
+			getType().toString()).append(
+			"\n");
+		Iterator it = values.iterator();
+		while (it.hasNext())
+		{
+			DataValue value = (DataValue) it.next();
+			sb.append(thisIndent + "  ").append(
+				value.toString()).append(
+				"\n");
+		}
+
+		return sb.toString();
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/SimpleType.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/SimpleType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/SimpleType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,18 @@
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+    SimpleType is the super class of all data type classes that can have
+    a simple value, it requires its subclasses to check for legal values. 
+ */
+public abstract class SimpleType extends DataType
+{
+    protected SimpleType(String name)
+    {
+        super(name);
+    }
+    
+    /** Check if the DataValue o is a legal value for its type. */
+    abstract public boolean isValidValue(DataValue o);
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/SingletonValueSet.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/SingletonValueSet.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/SingletonValueSet.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,50 @@
+package edu.stanford.rt.datatype;
+
+import edu.stanford.rt.util.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ * A SingletonValueSet object is a value set that 
+ * conatins a single value of <code>SimpleType</code>.
+ */
+public class SingletonValueSet extends ValueSet
+{
+    private DataValue value;
+
+    /**
+     * Constructor for SingletonValueSet.
+     */
+    public SingletonValueSet(SimpleType type, DataValue value)
+    {
+        super(type);
+        if (! type.isValidValue(value)) 
+        {
+            throw new IllegalArgumentException("Value type does not match");
+        }
+        this.value = value;
+    }
+
+	/**
+	 * Method getValue.
+	 * @return DataValue
+	 */
+    public DataValue getValue()
+    {
+        return this.value;
+    }
+    
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.ValueSet#toString(String)
+	 */
+    public String toString(String indent)
+    {
+        String thisIndent = indent + "  ";
+        StringBuffer sb = new StringBuffer();
+        sb.append(thisIndent).append("SingletonValueSet: \n");
+        sb.append(thisIndent+"  ").append(getType().toString()).append("\n");
+        sb.append(thisIndent+"  ").append(value.toString());
+        return sb.toString();
+    }
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/StringType.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/StringType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/StringType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,96 @@
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>StringType</code> element
+ * 
+ */
+public class StringType extends OrderedType
+{
+	private boolean ignoreCase;
+	private boolean ordered;
+
+    /**
+     * Constructor for StringType.
+     */
+	public StringType(
+		String name,
+		boolean ignoreCase,
+		boolean ordered)
+	{
+		super(name);
+		this.ignoreCase = ignoreCase;
+		this.ordered = ordered;
+	}
+
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.SimpleType#isValidValue(DataValue)
+	 */
+	public boolean isValidValue(DataValue value)
+	{
+		if (!(value instanceof StringValue))
+			return false;
+		return true;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.OrderedType#compares(DataValue, DataValue)
+	 */
+	public int compares(DataValue value1, DataValue value2)
+	{
+		if (!(value1 instanceof StringValue)
+			|| !(value2 instanceof StringValue))
+			throw new IllegalArgumentException("Wrong argument type");
+
+		String val1 = ((StringValue) value1).getValue();
+		String val2 = ((StringValue) value2).getValue();
+
+		if (ignoreCase)
+			return val1.toLowerCase().compareTo(val2.toLowerCase());
+		else
+			return val1.compareTo(val2);
+	}
+
+	/**
+	 * Method isIgnoreCase.
+	 * @return boolean
+	 */
+	public boolean isIgnoreCase()
+	{
+		return ignoreCase;
+	}
+	/**
+	 * Method isOrdered.
+	 * @return boolean
+	 */
+	public boolean isOrdered()
+	{
+		return ordered;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.DataType#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+
+		sb
+			.append(thisIndent)
+			.append("StringType: ")
+			.append(getName())
+			.append("  ")
+			.append("ignoreCase = ")
+			.append(ignoreCase)
+			.append("  ")
+			.append("ordered = ")
+			.append(ordered)
+			.append("\n");
+
+		return sb.toString();
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/StringValue.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/StringValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/StringValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,38 @@
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>StringValue</code> element.
+ *  An StringValue object which holds a String value.
+ */
+public class StringValue implements DataValue
+{
+    private String value;
+    
+    /**
+     * Constructor for StringValue.
+     */
+    public StringValue(String v)
+    {
+        value = v;
+    }
+    
+	/**
+	 * Method getValue.
+	 * @return String
+	 */
+    public String getValue()
+    {
+        return value;
+    }
+    
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+    public String toString()
+    {
+        return value;
+    }
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TimeType.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TimeType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TimeType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,56 @@
+package edu.stanford.rt.datatype;
+
+import java.util.Date;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * DataType for time values in RTML. It's a wrapper class for XML built-in
+ * date time type.
+ */
+public class TimeType extends OrderedType
+{
+    /**
+     * Constructor for TimeType.
+     */
+    public TimeType(String name)
+    {
+        super(name);
+    }
+    
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.SimpleType#isValidValue(DataValue)
+	 */
+    public boolean isValidValue(DataValue value)
+    {
+        if(! (value instanceof TimeValue))
+            return false;
+
+        return true;
+    }
+    
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.OrderedType#compares(DataValue, DataValue)
+	 */
+    public int compares(DataValue value1, DataValue value2)
+    {
+//        if( !(value1 instanceof TimeValue) ||
+//            !(value2 instanceof TimeValue) )
+//            throw new IllegalArgumentException("Wrong argument type");
+//            
+//        Date date1 = ((TimeValue)value1).getValue();
+//        Date date2 = ((TimeValue)value2).getValue();
+//        return date1.compareTo(date2);
+        return 0;
+    }
+    
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.DataType#toString(String)
+	 */
+    public String toString(String indent)
+    {
+        String thisIndent = indent + "  ";
+        return thisIndent + getName()+"\n";
+    }
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TimeValue.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TimeValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TimeValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,55 @@
+package edu.stanford.rt.datatype;
+
+import java.util.Date;
+import java.text.DateFormat;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Implementation of <code>TimeValue</code> in RTML
+ * 
+ */
+public class TimeValue implements DataValue
+{
+    // Which XML Schema datetype is for this TimeValue?
+    private String type;
+    
+    // The corresponding Java Date object for this TimeValue.
+    private Date value;
+
+    /**
+     * Constructor for TimeValue.
+     */
+    public TimeValue(String type, Date value)
+    {
+        this.type = type;
+        this.value = value;
+    }
+    
+	/**
+	 * Method getValue.
+	 * @return Date
+	 */
+    public Date getValue()
+    {
+        return value;
+    }
+    
+	/**
+	 * Method getTypeName.
+	 * @return String
+	 */
+    public String getType()
+    {
+        return type;
+    }
+    
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+    public String toString()
+    {
+        return DateFormat.getDateInstance().format(value);
+    }
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TreeType.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TreeType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TreeType.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,79 @@
+package edu.stanford.rt.datatype;
+
+import java.util.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ * Implementation of <code>TreeType</code> element
+ * 
+ */
+public class TreeType extends SimpleType
+{
+    /** separator of the tree type. */
+	private String separator; // required attr.
+    /** ordering of the tree type */
+	private boolean rootFirst;
+
+    /**
+     * Constructor for TreeType
+     */
+	public TreeType(String name, String separator, boolean rootFirst)
+	{
+		super(name);
+		this.separator = separator;
+		rootFirst = rootFirst;
+	}
+
+	/**
+	 * Method isRootFirst.
+	 * @return boolean
+	 */
+	public boolean isRootFirst()
+	{
+		return rootFirst;
+	}
+
+	/**
+	 * Method getSeparator.
+	 * @return String
+	 */
+	public String getSeparator()
+	{
+		return separator;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.SimpleType#isValidValue(DataValue)
+	 */
+	public boolean isValidValue(DataValue v)
+	{
+		if (!(v instanceof TreeValue))
+			return false;
+		return true;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.DataType#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+		StringBuffer sb = new StringBuffer();
+		sb
+			.append(thisIndent)
+			.append("TreeType: ")
+			.append(getName())
+			.append("  ")
+			.append("separator=")
+			.append(separator)
+			.append("  ")
+			.append("order=")
+			.append(rootFirst ? "rootFirst" : "leafFirst")
+			.append("\n");
+
+		return sb.toString();
+
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TreeValue.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TreeValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TreeValue.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,77 @@
+package edu.stanford.rt.datatype;
+
+import java.util.*;
+
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ * Implementation of <code>TreeValue</code> element.
+ * 
+ */
+public class TreeValue implements DataValue
+{
+    private ArrayList value;
+    private TreeType type;
+
+    /**
+     * Constructor for TreeValue
+     */
+    public TreeValue(TreeType type, List v)
+        throws IllegalArgumentException
+    {
+        this.type = type;
+       
+        if(v == null || v.size() ==0)
+            throw new IllegalArgumentException("Empty tree value");
+
+        value = new ArrayList();
+        Iterator it = v.iterator();
+        while(it.hasNext())
+        {
+            String val = (String)it.next();
+            value.add(val);
+        }
+    }
+
+	/**
+	 * Method getValue.
+     *      returns an unmodifiable view of value part list.
+	 * @return List
+	 */
+    public List getValue()
+    {
+        return Collections.unmodifiableList(value);
+    }
+    
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        String separator = type.getSeparator();
+        boolean rootFirst = type.isRootFirst();
+        int size = value.size();
+        if(rootFirst)
+        {
+            for(int i=0; i<size; i++)
+            {
+                String val = (String)value.get(i);
+                sb.append(val);
+                if(i != (size-1))  sb.append(separator);
+            }
+        }
+        else
+        {
+            for(int i=size-1; i>=0; i--)
+            {
+                String val = (String)value.get(i);
+                sb.append(val);
+                if(i != 0)  sb.append(separator);
+            }
+        }
+        return sb.toString();
+    }
+    
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TreeValueSet.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TreeValueSet.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TreeValueSet.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,74 @@
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+    A TreeValueSet object contains a TreeValue and can be 
+    used to express the concept such as including all the 
+    sub-directories of the current directory by specifying
+    whether the current value is included, the children of 
+    the current value or the descendant of the current value
+    are included.
+ */
+public class TreeValueSet extends ValueSet
+{
+	/** tree value */
+	private TreeValue value;
+
+	/** is current tree value included?*/
+	private boolean currentIncluded;
+	/** is the children included?*/
+	private boolean childrenIncluded;
+	/** is the descendant incuded?  If it is true, then childrenIncluded is also true.*/
+	private boolean descendantIncluded;
+
+	/**
+	 * Constructor of TreeValueSet
+	 */
+	public TreeValueSet(
+		TreeType type,
+		TreeValue value,
+		boolean currentIncluded,
+		boolean childrenIncluded,
+		boolean descendantIncluded)
+	{
+		super(type);
+
+		this.value = value;
+		this.currentIncluded = currentIncluded;
+		this.childrenIncluded = childrenIncluded;
+		if (descendantIncluded && !childrenIncluded)
+			throw new IllegalArgumentException("descendantIncluded implicits childrenIncluded.");
+		this.descendantIncluded = descendantIncluded;
+	}
+
+	/* (non-Javadoc)
+	 * @see edu.stanford.rt.datatype.ValueSet#toString(String)
+	 */
+	public String toString(String indent)
+	{
+		String thisIndent = indent + "  ";
+
+		StringBuffer sb = new StringBuffer();
+		sb.append(thisIndent).append("TreeValueSet: \n");
+		sb.append(thisIndent + "  ").append(
+			getType().toString()).append(
+			"\n");
+		sb.append(thisIndent + "  ").append(value.toString()).append(
+			"\n");
+		sb
+			.append(thisIndent)
+			.append("currentIncluded=")
+			.append(currentIncluded)
+			.append("  ")
+			.append("childrenIncluded=")
+			.append(childrenIncluded)
+			.append("  ")
+			.append("descendantIncluded=")
+			.append(descendantIncluded)
+			.append("\n");
+
+		return sb.toString();
+	}
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/ValueSet.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/ValueSet.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/ValueSet.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,42 @@
+package edu.stanford.rt.datatype;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ * A ValueSet object represents a set of values of a certain type.
+ */
+public class ValueSet
+{
+    /** value type */
+    private DataType type;
+
+    /**
+     * Constructor for ValueSet
+     */
+    public ValueSet(DataType type)
+    {
+        this.type = type;
+    }
+    
+	/**
+	 * Method getType.
+     *  returns the value type.
+	 * @return DataType
+	 */
+    public DataType getType()
+    {
+        return type;
+    }
+    
+	/**
+	 * Method toString.
+	 * @param indent
+	 * @return String
+	 */
+    public String toString(String indent)
+    {
+        return type.toString(indent+indent);
+    }
+    
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/CVS/Entries
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,2 @@
+/DecimalType.java1/1.1.1.1/Fri Nov 22 17:37:55 2002//
+D
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/CVS/Repository
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+rtml/src/edu/stanford/rt/datatype/todo
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/CVS/Root
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+:ext:jjacobs@src.columbia.sparta.com/cvs/abac
Index: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/DecimalType.java1
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/DecimalType.java1	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/datatype/todo/DecimalType.java1	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,92 @@
+
+package edu.stanford.rt.datatype;
+
+// Not yet implemented
+
+/**
+    IntegerType defines the integer type. The name for this type is "IntegerType".
+    It has the following attributes: min, max, base, and step.
+    
+*/
+public class DecimalType extends SimpleType
+{
+    private long min;
+    private long max;
+    private boolean minIncluded = true;
+    private boolean maxIncluded = true;
+    private long base;
+    private long step;
+
+    /**
+          
+    */
+    public DecimalType (String n, long mi, boolean mii, 
+                    long ma, boolean mai, long b, long s)
+        throws IllegalArgumentException
+    {
+        super(n);
+        
+        // Check to make sure that at least one value is legal
+        if (mi > ma) {
+            throw new IllegalArgumentException("IntegerType: min > max");
+        }
+        if(b < mi || b > ma) {
+            throw new IllegalArgumentException(
+                "IntegerType: base in not within min and max");
+        }
+        if (s <= 0) {
+            throw new IllegalArgumentException("IntegerType: step <= 0");
+        }
+
+        long x = (mi - rem) % s;
+        if (x>0 && (mi + s-x)>ma) {
+            throw new IllegalArgumentException(
+                "IntegerType: First legal value is out of bound.");
+        } 
+        
+        min = mi;
+        max = ma;
+        minIncluded = mii;
+        maxIncluded = mai;
+        base = b;
+        step = s;
+    }
+    
+    public long getMin()
+    {
+        return min;
+    }
+    public long getMax()
+    {
+        return max;
+    }
+    public boolean isMinIncluded()
+    {
+        return minIncluded;
+    }
+    public boolean isMaxIncluded()
+    {
+        return maxIncluded;
+    }
+    public long getBase()
+    {
+        return base;
+    }
+    public long getStep()
+    {
+        return step;
+    }
+    
+    public boolean isValidValue(DataValue v)
+    {
+        if (!(v instanceof DecimalValue)) {
+            return false;
+        }
+        
+        double l = ((DecimalValue)v).getValue();
+        if (l >= min && l<= max && ((l-remainder) % step == 0)) {
+            return true;
+        }
+        return false;
+    }
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/parser/CVS/Entries
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/parser/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/parser/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,4 @@
+/ParsingErrorHandler.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+/RTParser.java/1.4/Wed Feb 26 21:33:53 2003//
+/TagNameConstants.java/1.1.1.1/Fri Nov 22 17:37:55 2002//
+D
Index: fedd/abac-src/rtml/src/edu/stanford/rt/parser/CVS/Repository
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/parser/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/parser/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+rtml/src/edu/stanford/rt/parser
Index: fedd/abac-src/rtml/src/edu/stanford/rt/parser/CVS/Root
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/parser/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/parser/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+:ext:jjacobs@src.columbia.sparta.com/cvs/abac
Index: fedd/abac-src/rtml/src/edu/stanford/rt/parser/ParsingErrorHandler.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/parser/ParsingErrorHandler.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/parser/ParsingErrorHandler.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,63 @@
+package edu.stanford.rt.parser;
+
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+
+public class ParsingErrorHandler implements ErrorHandler
+{
+    /** Warning. */
+    public void warning(SAXParseException ex)
+    {
+        System.out.println(
+            "[Warning] "
+                + getLocationString(ex)
+                + ": "
+                + ex.getMessage());
+    }
+
+    /** Error. */
+    public void error(SAXParseException ex)
+    {
+        System.out.println(
+            "[Error] "
+                + getLocationString(ex)
+                + ": "
+                + ex.getMessage());
+    }
+
+    /** Fatal error. */
+    public void fatalError(SAXParseException ex) throws SAXException
+    {
+        System.out.println(
+            "[Fatal Error] "
+                + getLocationString(ex)
+                + ": "
+                + ex.getMessage());
+        throw ex;
+    }
+
+    /** Returns a string of the location. */
+    private String getLocationString(SAXParseException ex)
+    {
+        StringBuffer str = new StringBuffer();
+
+        String systemId = ex.getSystemId();
+        if (systemId != null)
+        {
+            int index = systemId.lastIndexOf('/');
+            if (index != -1)
+                systemId = systemId.substring(index + 1);
+            str.append(systemId);
+        }
+        str.append(':');
+        str.append(ex.getLineNumber());
+        str.append(':');
+        str.append(ex.getColumnNumber());
+
+        return str.toString();
+
+    }
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/parser/RTParser.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/parser/RTParser.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/parser/RTParser.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,2525 @@
+package edu.stanford.rt.parser;
+
+//imports Apache Xerces API
+import org.apache.xerces.parsers.DOMParser;
+import org.xml.sax.InputSource;
+import org.w3c.dom.*;
+
+// imports XML Security PublicKey api
+import org.apache.xml.security.keys.content.keyvalues.DSAKeyValue;
+import org.apache.xml.security.keys.content.keyvalues.RSAKeyValue;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+
+import java.io.*;
+import java.util.*;
+
+import edu.stanford.rt.datatype.*;
+import edu.stanford.rt.credential.*;
+import edu.stanford.rt.util.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ * RTParser parses a XML-format CredentialStore document and transforms
+ * the various elements into their corresponding Java objects.
+ */
+public class RTParser implements TagNameConstants, Constants
+{
+	/** The DOM parser this transformer uses*/
+	private DOMParser parser;
+
+	/** 
+	 * Constructor for RTParser.
+	 */
+	public RTParser() throws Exception
+	{
+		parser = new DOMParser();
+		parser.setFeature(
+			"http://apache.org/xml/features/validation/schema",
+			true);
+		parser.setErrorHandler(new ParsingErrorHandler());
+	}
+
+	/**
+	 * Method createSystemDomain.
+	 *      The method for creating system domain. 
+	 *      *** Only useful for our parser.
+	 * @return ApplicationDomain
+	 * @throws Exception
+	 */
+	public synchronized ApplicationDomain createSystemDomain()
+		throws Exception
+	{
+        String spec = 
+            System.getProperty("edu.stanford.rt.SystemDomain",
+                               "C:\\rtml\\schemas\\systemSpec.xml");
+		return parseSystemDomain(new FileInputStream(new File(spec)));
+	}
+
+	/**
+	 * Method parseSystemDomain. <br>
+	 *      parses system domain from a XML input source, typically a 
+	 *      XML file. The system domain element in the source should be
+	 *      the root element.
+	 * @param in
+	 * @return ApplicationDomain
+	 * @throws Exception
+	 */
+	public synchronized ApplicationDomain parseSystemDomain(InputStream in)
+		throws Exception
+	{
+		parser.parse(new InputSource(in));
+		Document document = parser.getDocument();
+		Element root = document.getDocumentElement();
+		return transformSystemDomain(root);
+	}
+
+	/**
+	 * Method parseSystemDomain. <br>
+	 *      parses system domain from a XML input source, typically a 
+	 *      XML file. The system domain element in the source should be
+	 *      the root element.
+	 * @param in
+	 * @return CredentialDomain
+	 * @throws Exception
+	 */
+        public synchronized CredentialDomain 
+	    parseCredentialDomain(InputStream in, RTContext context) 
+	    throws Exception
+        {
+	    parser.parse(new InputSource(in));
+	    Document document = parser.getDocument();
+		Element root = document.getDocumentElement();
+		return transformCredential(root, context);
+	}
+
+
+	/**
+	 * Method transformSystemDomain.<br>
+	 *    transforms the XML element to the built-in system 
+	 *    <code>ApplicationDomain</code>.
+	 * @param root
+	 *      XML element of system domain.
+	 * @return ApplicationDomain
+	 * @throws DomainSpecException
+	 */
+	public synchronized ApplicationDomain transformSystemDomain(Element root)
+		throws DomainSpecException
+	{
+		if (!root.getTagName().equals(APP_DOMAIN_SPEC))
+			throw new DomainSpecException("Not an ApplicationDomainSpecification element.");
+		String uri = root.getAttribute(URI);
+		ApplicationDomain spec =
+			new ApplicationDomain(uri, true, null);
+		String hashID = root.getAttribute(ID);
+		if (hashID.length() == 0)
+		{
+			// compute the hashID ourselves.
+			// hashID = getHash(spec);
+		}
+		HashID id = new HashID(HashID.APPLICATION_DOMAIN, hashID);
+		spec.setHashID(id);
+		// Add XML schema date types
+		spec.addType(new TimeType("dateTime"));
+		spec.addType(new TimeType("date"));
+		spec.addType(new TimeType("time"));
+		spec.addType(new TimeType("gYear"));
+		spec.addType(new TimeType("gYearMonth"));
+		spec.addType(new TimeType("gMonth"));
+		spec.addType(new TimeType("gMonthDay"));
+		spec.addType(new TimeType("gDay"));
+		Element[] elements = RTParser.getChildElements(root);
+		for (int i = 0; i < elements.length; i++)
+		{
+			Element childEle = elements[i];
+			String childName = childEle.getTagName();
+			if (childName.equals(INTEGER_TYPE))
+			{
+				IntegerType intType =
+					transformIntegerTypeDeclaration(childEle);
+				spec.addType(intType);
+			}
+			else if (childName.equals(DECIMAL_TYPE))
+			{
+				DecimalType decimalType =
+					transformDecimalTypeDeclaration(childEle);
+				spec.addType(decimalType);
+			}
+			else if (childName.equals(STRING_TYPE))
+			{
+				StringType stringType =
+					transformStringTypeDeclaration(childEle);
+				spec.addType(stringType);
+			}
+			else if (childName.equals(ENUM_TYPE))
+			{
+				EnumType enumType =
+					transformEnumTypeDeclaration(childEle, spec);
+				spec.addType(enumType);
+			}
+			else if (childName.equals(RECORD_TYPE))
+			{
+				RecordType recordType =
+					transformRecordTypeDeclaration(childEle, spec);
+				spec.addType(recordType);
+			}
+			else if (childName.equals(TREE_TYPE))
+			{
+				TreeType treeType =
+					transformTreeTypeDeclaration(childEle);
+				spec.addType(treeType);
+			}
+		} // end of for()...
+		spec.setComplete();
+		return spec;
+	}
+
+	/**
+	 * Method getFirstChildElement.<br>
+	        Returns the first child element of ELEMENT_NODE type for the 
+	        given parent element. 
+	 * @param parent
+	 * @return Element
+	 */
+	static public Element getFirstChildElement(Element parent)
+	{
+		Element ele = null;
+		NodeList nodes = parent.getChildNodes();
+		int n = nodes.getLength();
+		for (int i = 0; i < n; i++)
+		{
+			Node node = nodes.item(i);
+			short type = node.getNodeType();
+			if (type != org.w3c.dom.Node.ELEMENT_NODE)
+				continue;
+			ele = (Element) node;
+			break;
+		}
+		return ele;
+	}
+
+	/**
+	 * Method getFirstChildElementByTagName.<br>
+	 *   returns the first child element with the given tag name.
+	 * @param parent
+	 * @param tagName
+	 * @return Element
+	 */
+	/**
+	*/
+	static public Element getFirstChildElementByTagName(
+		Element parent,
+		String tagName)
+	{
+		Element ele = null;
+		NodeList nodes = parent.getElementsByTagName(tagName);
+		ele = (Element) nodes.item(0);
+		return ele;
+	}
+
+	/**
+	 * Method getChildElements.<br>
+	 *      returns an array of child elements of ELEMNENT_NODE type.
+	 * @param parent
+	 * @return Element[]
+	 */
+	static public Element[] getChildElements(Element parent)
+	{
+		ArrayList elements = new ArrayList();
+		NodeList nodes = parent.getChildNodes();
+		int n = nodes.getLength();
+		for (int i = 0; i < n; i++)
+		{
+			Node node = nodes.item(i);
+			short type = node.getNodeType();
+			if (type != org.w3c.dom.Node.ELEMENT_NODE)
+				continue;
+			elements.add((Element) node);
+		}
+		// put into an array of Elements.
+		int size = elements.size();
+		Element[] eleArray = new Element[size];
+		for (int i = 0; i < size; i++)
+		{
+			eleArray[i] = (Element) elements.get(i);
+		}
+		return eleArray;
+	}
+
+	/**
+	 * Method parseCredentialStore.<br>
+	 * parses credential store from an XML input source, typically an 
+	 * XML file. The <code>CredentialStore</code> element should be a
+	 * root element. 
+	 * @param in
+	 * @param rtContext
+	 *      the context in which the parsing occurs.
+	 * @param credentialStore
+	 *      the credential store being constructed.
+	 * @throws DomainSpecException
+	 */
+	public synchronized void parseCredentialStore(
+		InputStream in,
+		RTContext rtContext,
+		CredentialStore credentialStore)
+		throws Exception
+	{
+		parser.parse(new InputSource(in));
+		Document document = parser.getDocument();
+		Element root = document.getDocumentElement();
+		transformCredentialStore(root, rtContext, credentialStore);
+	}
+
+	/**
+	 * Method transformCredentialStore.<br>
+	 * @param root
+	 *  the XML element of credential store
+	 * @param rtContext
+	 * @param credentialStore
+	 * @throws DomainSpecException
+	 * @throws CredException
+	 */
+	public synchronized void transformCredentialStore(
+		Element root,
+		RTContext rtContext,
+		CredentialStore credentialStore)
+		throws DomainSpecException, CredException
+	{
+		String rootTag = root.getTagName();
+		if (!rootTag.equals(CREDENTIAL_STORE))
+		{
+			throw new DomainSpecException("Not a CredentialStore document.");
+		}
+		Element[] elements = getChildElements(root);
+		for (int i = 0; i < elements.length; i++)
+		{
+			String tag = elements[i].getTagName();
+			if (tag.equals(APP_DOMAIN_SPEC))
+			{
+				ApplicationDomain spec =
+					transformDomain(elements[i], rtContext);
+				HashID id = spec.getHashID();
+				rtContext.addApplicationDomain(id, spec);
+			}
+			else if (tag.equals(PRINCIPAL_INFO))
+			{
+				// TODO
+				// rtContext.addPrincipal(PublickeyPrincipal, PublicKeyPrincipalInfo);
+			}
+			else if (tag.equals(CREDENTIAL))
+			{
+				CredentialDomain credentialDomain =
+					transformCredential(elements[i], rtContext);
+				HashID id = credentialDomain.getHashID();
+				credentialStore.addCredentialDomain(
+					id,
+					credentialDomain);
+			}
+//			else if (tag.equals(ACCESS_RULE))
+//			{
+//				CredentialDomain accessRuleDomain =
+//					transformAccessRule(elements[i], rtContext);
+//				HashID id = accessRuleDomain.getHashID();
+//				credentialStore.addCredentialDomain(
+//					id,
+//					accessRuleDomain);
+//			}
+		}
+	}
+
+	/**
+	 * Method transformDomain.<br>
+	 *      parses non-system <code>ApplicationDomain</code>.
+	 * @param ele
+	 *  the <code>ApplicationDomain</code> element
+	 * @param rtContext
+	 *  the context in which the transformation occurs.
+	 * @return ApplicationDomain
+	 * @throws DomainSpecException
+	 */
+	public synchronized ApplicationDomain transformDomain(
+		Element ele,
+		RTContext rtContext)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(APP_DOMAIN_SPEC))
+			throw new DomainSpecException("Not an ApplicationDomainSpecification element");
+		String uri = ele.getAttribute(URI);
+		//		if (uri.length() == 0)
+		//			throw new DomainSpecException(
+		//				missing_attr_value + "'uri'");
+		ApplicationDomain spec =
+			new ApplicationDomain(uri, false, rtContext);
+		String hashID = ele.getAttribute(ID);
+		if (hashID.length() == 0)
+		{
+			// compute the hashID ourselves.
+			// hashID = getHash(spec);
+		}
+		HashID id = new HashID(HashID.APPLICATION_DOMAIN, hashID);
+		spec.setHashID(id);
+		Element[] elements = getChildElements(ele);
+		for (int i = 0; i < elements.length; i++)
+		{
+			Element childEle = elements[i];
+			String childName = childEle.getTagName();
+			if (childName.equals(IMPORT_DOMAIN))
+			{
+				String name = childEle.getAttribute(NAME);
+				if (name.length() == 0)
+					throw new DomainSpecException(
+						missing_attr_value + "'name'");
+				String importedUri = childEle.getAttribute(URI);
+				String idref = childEle.getAttribute(IDREF);
+				if (idref.length() == 0)
+					throw new DomainSpecException(
+						missing_attr_value + "'idref'");
+				ApplicationDomain importedDomain =
+					locateDomain(idref, importedUri, rtContext);
+				spec.importDomain(name, importedDomain);
+			}
+			else if (childName.equals(INTEGER_TYPE))
+			{
+				IntegerType intType =
+					transformIntegerTypeDeclaration(childEle);
+				spec.addType(intType);
+			}
+			else if (childName.equals(DECIMAL_TYPE))
+			{
+				DecimalType decimalType =
+					transformDecimalTypeDeclaration(childEle);
+				spec.addType(decimalType);
+			}
+			else if (childName.equals(ENUM_TYPE))
+			{
+				EnumType enumType =
+					transformEnumTypeDeclaration(childEle, spec);
+				spec.addType(enumType);
+			}
+			else if (childName.equals(STRING_TYPE))
+			{
+				StringType stringType =
+					transformStringTypeDeclaration(childEle);
+				spec.addType(stringType);
+			}
+			else if (childName.equals(RECORD_TYPE))
+			{
+				RecordType recordType =
+					transformRecordTypeDeclaration(childEle, spec);
+				spec.addType(recordType);
+			}
+			else if (childName.equals(TREE_TYPE))
+			{
+				TreeType treeType =
+					transformTreeTypeDeclaration(childEle);
+				spec.addType(treeType);
+			}
+			else if (childName.equals(PRINCIPAL_TYPE))
+			{
+				// This element specifies the principal type for the entire system
+				// Later on, the principal value can be checked against the type 
+				// defined here.
+				SimpleType prinType =
+					transformPrincipalTypeDeclaration(childEle, spec);
+				spec.setPrincipalType(prinType);
+			}
+			else if (childName.equals(ROLE_DECLARATION))
+			{
+				RoleDeclaration role =
+					transformRoleDeclaration(childEle, spec);
+				spec.addRole(role);
+			}
+		} //end of for( )....
+		spec.setComplete();
+		return spec;
+	} //==== End of parseDomainSpec()
+	/**
+	   Parses non-system domain specification object from a file pointed by the 
+	   given uri.
+	*/
+	//	private void parseDomainSpec(String uri)
+	//	{
+	//		DomainSpecification spec = null;
+	//		try
+	//		{
+	//			DOMParser parser = new DOMParser();
+	//			parser.setFeature(
+	//				"http://apache.org/xml/features/validation/schema",
+	//				true);
+	//			parser.parse(new InputSource(new FileInputStream(new File(uri))));
+	//			Document doc = parser.getDocument();
+	//			transform(doc);
+	//		}
+	//		catch (SAXException e)
+	//		{
+	//			System.out.println("error in setting up parser feature");
+	//		}
+	//		catch (Exception ex)
+	//		{
+	//			ex.printStackTrace();
+	//		}
+	//	}
+	//
+	//	private void transform(Document document) throws Exception
+	//	{
+	//		Element root = document.getDocumentElement();
+	//		String rootTag = root.getTagName();
+	//
+	//	}
+	/**
+	 * Method locateDomain.<br>
+	 * @param rtContext
+	 * @param idref
+	 *      the hash value of the target 
+	 *      <code>ApplicationDomainSpecification</code> object.
+	 * @param uri
+	 * @return ApplicationDomain
+	 * @throws DomainSpecException
+	 *  if cannot find the domain by the given idref.
+	 */
+	private ApplicationDomain locateDomain(
+		String idref,
+		String uri,
+		RTContext rtContext)
+		throws DomainSpecException
+	{
+		ApplicationDomain spec = null;
+		if (!rtContext.hasDomainWithID(idref))
+		{
+			//TODO: load domain from given uri, which is optional.
+			//parseDomainSpec(uri);
+			//spec = (DomainSpecification)applicationDomains.get(uri);
+			throw new DomainSpecException(
+				"Cannot find domain with id '" + idref + "'.");
+		}
+		else
+		{
+			spec = rtContext.getApplicationDomain(idref);
+		}
+		if (!spec.isComplete())
+		{
+			throw new DomainSpecException("Circular Dependency");
+		}
+		return spec;
+	}
+	/*###########################################################
+	    #####
+	    ##### Parsing DateType Declaration in DomainSpecification
+	    #####
+	#############################################################*/
+	/**
+	 * Method transformIntegerTypeDeclaration.<br>
+	 * 
+	 * Parses IntegerType declaration in ADSD.
+	 * Returns an IntegerType object by parsing element:<br>
+	    <pre>
+	        &lt;IntegerType name="" min="" max=""/&gt;
+	    </pre>
+	 * @param ele
+	 * @return IntegerType
+	 * @throws DomainSpecException
+	 */
+	private IntegerType transformIntegerTypeDeclaration(Element ele)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(INTEGER_TYPE))
+			throw new DomainSpecException("Not an IntegerType element");
+		String name = ele.getAttribute(NAME);
+		String minStr = ele.getAttribute(MIN);
+		String maxStr = ele.getAttribute(MAX);
+		if (name.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'name'");
+		if (minStr.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'min'");
+		if (maxStr.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'max'");
+		long min = Long.parseLong(minStr);
+		long max = Long.parseLong(maxStr);
+		//        RTUtil.debugInfo("name = " + name);
+		//        RTUtil.debugInfo("min = " + ele.getAttribute(MIN));
+		//        RTUtil.debugInfo("max = " + ele.getAttribute(MAX));
+		//        RTUtil.debugInfo("base = " + ele.getAttribute(BASE));
+		//        RTUtil.debugInfo("step = " + ele.getAttribute(STEP));
+		//        RTUtil.debugInfo("includeMin = " + ele.getAttribute(INCLUDE_MIN));
+		//        RTUtil.debugInfo("includeMax = " + ele.getAttribute(INCLUDE_MAX));
+		boolean includeMin =
+			RTUtil.parseBoolean(ele.getAttribute(INCLUDE_MIN), true);
+		boolean includeMax =
+			RTUtil.parseBoolean(ele.getAttribute(INCLUDE_MAX), true);
+		long base = RTUtil.parseLong(ele.getAttribute(BASE), 0);
+		long step = RTUtil.parseLong(ele.getAttribute(STEP), 1);
+		return new IntegerType(
+			name,
+			min,
+			max,
+			includeMin,
+			includeMax,
+			base,
+			step);
+	}
+	/**
+	 * Method transformDecimalTypeDeclaration.<br>
+	 * Parses DecimalType declaration in ADSD.
+	    Returns a DecimalType object by parsing element:
+	    <pre>
+	        &lt;DecimalType name="" min="" max=""/&gt;
+	    </pre>
+	 * @param ele
+	 * @return DecimalType
+	 * @throws DomainSpecException
+	 */
+	private DecimalType transformDecimalTypeDeclaration(Element ele)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(DECIMAL_TYPE))
+			throw new DomainSpecException("Not a DecimalType element");
+		// TODO
+		throw new UnsupportedOperationException(
+			no_support_for + "'DecimalType'");
+	}
+	/**
+	 * Method transformStringTypeDeclaration.<br>
+     * Parses StringType declaration in ADSD.
+        Returns a StringType object by parsing element:<br>
+        <pre>
+            &lt;StringType name="" ignoreCase="false" ordered="false"/&gt;
+        </pre>
+	 * @param ele
+	 * @return StringType
+	 * @throws DomainSpecException
+	 */
+	private StringType transformStringTypeDeclaration(Element ele)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(STRING_TYPE))
+			throw new DomainSpecException("Not a StringType element");
+		String name = ele.getAttribute(NAME);
+		if (name.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'name'");
+		boolean ignoreCase =
+			RTUtil.parseBoolean(ele.getAttribute(IGNORE_CASE), false);
+		boolean ordered =
+			RTUtil.parseBoolean(ele.getAttribute(ORDERED), false);
+		return new StringType(name, ignoreCase, ordered);
+	}
+	/**
+	 * Method transformEnumTypeDeclaration.<br>
+     * Parses EnumType declaration in ADSD.
+        Returns an EnumType object by parsing element:<br>
+        <pre>
+            &lt;EnumType name="" ignoreCase="false" ordered="false"/&gt;
+                &lt;EnumValue&gt;Monday&lt;/EnumValue&gt;
+                &lt;EnumValue&gt;Wednesday&lt;/EnumValue&gt;
+                &lt;EnumValue&gt;Friday&lt;/EnumValue&gt;
+                ...
+            &lt;/EnumType&gt;
+        </pre>
+	 * @param ele
+	 * @param currentSpec
+	 * @return EnumType
+	 * @throws DomainSpecException
+	 */
+	private EnumType transformEnumTypeDeclaration(
+		Element ele,
+		DomainSpecification currentSpec)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(ENUM_TYPE))
+			throw new DomainSpecException("Not an EnumType element");
+		OrderedMap enumValues =
+			new OrderedMap(String.class, Object.class);
+		DataType valueType = null;
+		String name = ele.getAttribute(NAME);
+		if (name.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'name'");
+		boolean ignoreCase =
+			RTUtil.parseBoolean(ele.getAttribute(IGNORE_CASE), false);
+		boolean ordered =
+			RTUtil.parseBoolean(ele.getAttribute(ORDERED), false);
+		int size = RTUtil.parseInt(ele.getAttribute(SIZE), 0);
+		Element[] elements = getChildElements(ele);
+		for (int i = 0; i < elements.length; i++)
+		{
+			Element child = elements[i];
+			String childName = child.getTagName();
+			if (childName.equals(TYPE)) // nameRef type
+			{
+				// QQ: This element has been removed , as of 8/28/02
+				String domain = child.getAttribute(DOMAIN);
+				String n = child.getAttribute(NAME);
+				valueType = currentSpec.lookupType(domain, n);
+			}
+			else if (childName.equals(ENUM_VALUE))
+			{
+				String value =
+					transformEnumValue(null, child).getValue();
+				//RTUtil.debugInfo("value = " + value);
+				enumValues.put(value, null);
+			}
+		}
+		return new EnumType(
+			name,
+			valueType,
+			enumValues,
+			ignoreCase,
+			ordered,
+			size);
+	}
+	/**
+	 * Method transformTreeTypeDeclaration.<br>
+     * Parses TreeType declaration in ADSD.
+        Returns a TreeType object by parsing element:<br>
+        <pre>
+            &lt;TreeType name="DNSType" sparator="." order="rootLast"/&gt;
+        </pre>
+	 * @param ele
+	 * @return TreeType
+	 * @throws DomainSpecException
+	 */
+	private TreeType transformTreeTypeDeclaration(Element ele)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(TREE_TYPE))
+			throw new DomainSpecException("Not a TreeType element");
+		String name = ele.getAttribute(NAME);
+		String separator = ele.getAttribute(SEPARATOR);
+		String order = ele.getAttribute(ORDER);
+		if (name.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'name'");
+		if (separator.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'sepatator'");
+		if (order.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'order'");
+		//        RTUtil.debugInfo("name = " +name);
+		//        RTUtil.debugInfo("separator = " + separator);
+		//        RTUtil.debugInfo("order = " + order);
+		return new TreeType(
+			name,
+			separator,
+			order.equals(ROOT_FIRST));
+	}
+	/**
+	 * Method transformRecordTypeDeclaration.<br>
+     * Parses RecordType declaration in ADSD.
+        Returns a RecordType object by parsing element:
+        <pre>
+            &lt;RecordType name="record"&gt;
+                &lt;Field name="field1"&gt;
+                    &lt;Type domain="" name=""/&gt;
+                &lt;/Field&gt;
+                &lt;Field name="field2"&gt;
+                    &lt;Type domain="" name=""/&gt;
+                &lt;/Field&gt;
+                ...
+            &lt;/RecordType&gt;
+        </pre>
+	 * @param ele
+	 * @param currentSpec
+	 * @return RecordType
+	 * @throws DomainSpecException
+	 */
+	private RecordType transformRecordTypeDeclaration(
+		Element ele,
+		DomainSpecification currentSpec)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(RECORD_TYPE))
+			throw new DomainSpecException("Not a RecordType element");
+		String name = ele.getAttribute(NAME);
+		if (name.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'name'");
+		RTUtil.debugInfo(
+			"parseRecordTypeDeclaration() > name = " + name);
+		NodeList childNodes = ele.getElementsByTagName(FIELD);
+		int size = childNodes.getLength();
+		if (size < 1)
+			throw new DomainSpecException("No fields specified for the RecordType element.");
+		OrderedMap fieldDeclarations =
+			new OrderedMap(size, String.class, DataType.class);
+		for (int i = 0; i < size; i++)
+		{
+			Element field = (Element) childNodes.item(i);
+			String fieldName = field.getAttribute(NAME);
+			if (fieldName.length() == 0)
+				throw new DomainSpecException(
+					missing_attr_value + "'name'");
+			Element typeRefEle =
+				getFirstChildElementByTagName(field, TYPE);
+			String typeName = typeRefEle.getAttribute(NAME);
+			if (typeName.length() == 0)
+				throw new DomainSpecException(
+					missing_attr_value + "'name'");
+			String typeDomain = typeRefEle.getAttribute(DOMAIN);
+			RTUtil.debugInfo("fieldName = " + fieldName);
+			//            RTUtil.debugInfo("typeName = " + typeName);
+			//            RTUtil.debugInfo("typeDomain = " + typeDomain);
+			DataType fieldType =
+				currentSpec.lookupType(typeDomain, typeName);
+			fieldDeclarations.put(fieldName, fieldType);
+		}
+		return new RecordType(name, fieldDeclarations);
+	}
+	/**
+	 * Method transformPrincipalTypeDeclaration.<br>
+        Parses PrincipalType declaration in ADSD.
+        
+        Returns a SimpleType object by parsing element:
+        <pre>
+            &lt;PrincialType name="prinType"&gt;
+                &lt;TypeRef domain="" name=""/&gt;
+            &lt;/PrincialType&gt;
+        </pre>
+	 * @param ele
+	 * @param currentSpec
+	 * @return SimpleType
+	 * @throws DomainSpecException
+	 */
+	private SimpleType transformPrincipalTypeDeclaration(
+		Element ele,
+		DomainSpecification currentSpec)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(PRINCIPAL_TYPE))
+			throw new DomainSpecException("Not a PrincipalType element");
+		Element typeRefEle = getFirstChildElementByTagName(ele, TYPE);
+		String domain = typeRefEle.getAttribute(DOMAIN);
+		String name = typeRefEle.getAttribute(NAME);
+		if (name.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'name'");
+		return (SimpleType) currentSpec.lookupType(domain, name);
+	}
+	/**
+	 * Method transformRoleDeclaration.<br>
+     * Parses RoleDeclaration in ADSD.
+        Returns a RoleDeclaration object by parsing element:
+        <pre>
+            &lt;RoleDeclaration name="record"&gt;
+                &lt;Parameter name="param1"&gt;
+                    &lt;Type domain="" name=""/&gt;
+                &lt;/Parameter&gt;
+                &lt;Parameter name="param2"&gt;
+                    &lt;Type domain="" name=""/&gt;
+                &lt;/Parameter&gt;
+                ...
+            &lt;/RoleDeclaration&gt;
+        </pre>
+	 * @param ele
+	 * @param currentSpec
+     *  the DomainSpecification in which the role is declared.
+	 * @return RoleDeclaration
+	 * @throws DomainSpecException
+	 */
+	private RoleDeclaration transformRoleDeclaration(
+		Element ele,
+		DomainSpecification currentSpec)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(ROLE_DECLARATION))
+			throw new DomainSpecException("Not a RoleDeclaration element");
+		String roleName = ele.getAttribute(NAME);
+		if (roleName.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'name'");
+		RTUtil.debugInfo(
+			"parseRoleDeclaration > roleName = " + roleName);
+		boolean isIdentity =
+			RTUtil.parseBoolean(ele.getAttribute(IS_IDENTITY), false);
+
+		int issuerT = RoleDeclaration.DEFAULT_ISSUER_TYPE;
+		int subjectT = RoleDeclaration.DEFAULT_SUBJECT_TYPE;
+
+		RoleDeclaration roleDeclaration = null;
+
+		Element[] elements = getChildElements(ele);
+		int n = elements.length;
+		OrderedMap parameterDeclarations =
+			new OrderedMap(n, String.class, DataType.class);
+		for (int i = 0; i < n; i++)
+		{
+			Element childEle = elements[i];
+			String childName = childEle.getTagName();
+			if (childName.equals(RESTRICTION))
+			{
+				Element baseRoleEle =
+					getFirstChildElementByTagName(
+						childEle,
+						BASE_ROLE);
+				String baseRoleName = baseRoleEle.getAttribute(NAME);
+				if (baseRoleName.length() == 0)
+					throw new DomainSpecException(
+						missing_attr_value + "'name'");
+				String baseRoleDomain =
+					baseRoleEle.getAttribute(DOMAIN);
+				// get base role
+				RoleDeclaration baseRole =
+					currentSpec.lookupRoleDeclaration(
+						baseRoleDomain,
+						baseRoleName);
+				// get new parameters
+				NodeList paramNodes =
+					childEle.getElementsByTagName(PARAMETER);
+				OrderedMap newParameters =
+					transformParameters(paramNodes, currentSpec);
+				roleDeclaration =
+					RoleDeclaration.createRestrictionRole(
+						currentSpec,
+						roleName,
+						isIdentity,
+						baseRole,
+						newParameters);
+			}
+			else if (childName.equals(EXTENSION))
+			{
+				Element baseRoleEle =
+					getFirstChildElementByTagName(
+						childEle,
+						BASE_ROLE);
+				String baseRoleName = baseRoleEle.getAttribute(NAME);
+				if (baseRoleName.length() == 0)
+					throw new DomainSpecException(
+						missing_attr_value + "'name'");
+				String baseRoleDomain =
+					baseRoleEle.getAttribute(DOMAIN);
+				RoleDeclaration baseRole =
+					currentSpec.lookupRoleDeclaration(
+						baseRoleDomain,
+						baseRoleName);
+				NodeList paramNodes =
+					childEle.getElementsByTagName(PARAMETER);
+				OrderedMap newParameters =
+					transformParameters(paramNodes, currentSpec);
+				roleDeclaration =
+					RoleDeclaration.createExtensionRole(
+						currentSpec,
+						roleName,
+						isIdentity,
+						baseRole,
+						newParameters);
+			}
+			else if (childName.equals(PROJECTION))
+			{
+				Element baseRoleEle =
+					getFirstChildElementByTagName(
+						childEle,
+						BASE_ROLE);
+				String baseRoleName = baseRoleEle.getAttribute(NAME);
+				if (baseRoleName.length() == 0)
+					throw new DomainSpecException(
+						missing_attr_value + "'name'");
+				String baseRoleDomain =
+					baseRoleEle.getAttribute(DOMAIN);
+				RoleDeclaration baseRole =
+					currentSpec.lookupRoleDeclaration(
+						baseRoleDomain,
+						baseRoleName);
+				NodeList paramNodes =
+					childEle.getElementsByTagName(PARAMETER);
+				int num = paramNodes.getLength();
+				String[] newParamNames = new String[n];
+				for (int j = 0; j < num; j++)
+				{
+					Element e = (Element) paramNodes.item(j);
+					newParamNames[j] = e.getAttribute(NAME);
+				}
+
+				roleDeclaration =
+					RoleDeclaration.createProjectionRole(
+						currentSpec,
+						roleName,
+						isIdentity,
+						baseRole,
+						newParamNames);
+			}
+			else if (childName.equals(PLAIN))
+			{
+				String issuerTraces =
+					childEle.getAttribute(ISSUER_TRACES);
+				String subjectTraces =
+					childEle.getAttribute(SUBJECT_TRACES);
+				if (issuerTraces.length() != 0)
+				{
+					issuerT =
+						((Integer) (RoleDeclaration
+							.issuerTracesTypes
+							.get(issuerTraces.toLowerCase())))
+							.intValue();
+				}
+				if (subjectTraces.length() != 0)
+				{
+					subjectT =
+						((Integer) (RoleDeclaration
+							.subjectTracesTypes
+							.get(subjectTraces.toLowerCase())))
+							.intValue();
+				}
+				int dimension =
+					RTUtil.parseInt(
+						childEle.getAttribute(DIMENSION),
+						1);
+				Element identityRoleEle =
+					getFirstChildElementByTagName(childEle, IDENTITY);
+				/*  TODO
+				String idBaseRoleName = identityRoleEle.getAttribute(NAME);
+				if (idBaseRoleName.length() == 0)
+					throw new DomainSpecException(
+						missing_attr_value + "'name'");
+				String idBaseRoleDomain = identityRoleEle.getAttribute(DOMAIN);
+				RoleDeclaration idBaseRole =
+					currentSpec.lookupRoleDeclaration(
+						idBaseRoleDomain,
+						idBaseRoleName);
+				*/
+
+				NodeList paramNodes =
+					childEle.getElementsByTagName(PARAMETER);
+				OrderedMap newParameters =
+					transformParameters(paramNodes, currentSpec);
+				roleDeclaration =
+					RoleDeclaration.createPlainRole(
+						currentSpec,
+						roleName,
+						issuerT,
+						subjectT,
+						dimension,
+						isIdentity,
+						newParameters);
+			}
+
+		} // end of for loop
+		return roleDeclaration;
+	}
+	/**
+	 * Method transformParameters.<br>
+	 *  parses <code>Parameter</code> declarations in <code>RoleDeclaration</code> element.
+	 * @param nodes
+     *  the list of <code>Parameter</code> elements
+	 * @return OrderedMap
+     *  an OrderedMap of parameter declarations with parameter names as keys.
+	 */
+	private OrderedMap transformParameters(
+		NodeList nodes,
+		DomainSpecification currentSpec)
+		throws DomainSpecException
+	{
+		OrderedMap parameterDeclarations =
+			new OrderedMap(String.class, DataType.class);
+		int n = nodes.getLength();
+		for (int i = 0; i < n; i++)
+		{
+			Element childEle = (Element) nodes.item(i);
+			String paramName = childEle.getAttribute(NAME);
+			RTUtil.debugInfo("paramName = " + paramName);
+			Element typeRefEle =
+				getFirstChildElementByTagName(childEle, TYPE);
+			String domain = typeRefEle.getAttribute(DOMAIN);
+			//RTUtil.debugInfo("typeDomain = " + domain);
+			String name = typeRefEle.getAttribute(NAME);
+			//RTUtil.debugInfo("typeName = " + name);
+			DataType paramType = currentSpec.lookupType(domain, name);
+			parameterDeclarations.put(paramName, paramType);
+		}
+		return parameterDeclarations;
+	}
+
+	/*###########################################################
+	    #####
+	    ##### Parsing Credential or AccessRule
+	    #####
+	#############################################################*/
+	/**
+	 * Method transformCredential.<br>
+	 *   Returns a <code>CredentialDomain</code> object by parsing element:
+	 *   <pre>
+	 *       &lt;Credential&gt;
+	 *           ...
+	 *       &lt;/Credential&gt;
+	 *   </pre>
+	 * @param ele
+	 * @param rtContext
+	 * @return CredentialDomain
+	 * @throws DomainSpecException
+	 * @throws CredException
+	 */
+	public synchronized CredentialDomain transformCredential(
+		Element ele,
+		RTContext rtContext)
+		throws DomainSpecException, CredException
+	{
+		if (!ele.getTagName().equals(CREDENTIAL))
+			throw new DomainSpecException("Not a Credential element.");
+		String hashID = ele.getAttribute(ID);
+		if (hashID.length() == 0)
+		{
+			//compute hashID
+		}
+		RTUtil.debugInfo("HashID = " + hashID);
+		CredentialDomain credDomain =
+			new CredentialDomain(ele, rtContext);
+		HashID id = new HashID(HashID.CREDENTIAL_DOMAIN, hashID);
+		credDomain.setHashID(id);
+
+		Principal issuer = null;
+
+		Element[] elements = getChildElements(ele);
+		for (int i = 0; i < elements.length; i++)
+		{
+			Element child = elements[i];
+			String tagName = child.getTagName();
+			//RTUtil.debugInfo("***** tagName = " + tagName);
+			if (tagName.equals(PREAMBLE))
+			{
+				Element[] preambleElements = getChildElements(child);
+				for (int j = 0; j < preambleElements.length; j++)
+				{
+					Element preambleChild = preambleElements[j];
+					String preambleChildTag =
+						preambleChild.getTagName();
+					if (preambleChildTag.equals(IMPORT_DOMAIN))
+						// 0 or more
+					{
+						//short name for the imported domain in the scope of this credential.
+						String name =
+							preambleChild.getAttribute(NAME);
+						if (name.length() == 0)
+							throw new DomainSpecException(
+								missing_attr_value + "'name'");
+						RTUtil.debugInfo(
+							"ImportDomain's name = " + name);
+						String uri = preambleChild.getAttribute(URI);
+						RTUtil.debugInfo(
+							"ImportDomain's uri = " + uri);
+						String idref =
+							preambleChild.getAttribute(IDREF);
+						if (idref.length() == 0)
+							throw new DomainSpecException(
+								missing_attr_value + "'idref'");
+						ApplicationDomain importedDomain =
+							locateDomain(idref, uri, rtContext);
+						credDomain.importDomain(name, importedDomain);
+					}
+					else if (preambleChildTag.equals(PRINCIPAL))
+						// 0 or more
+					{
+						// To improve readability, the principal, which could be quite long,
+						// are included in the Preamble so that they can be referred to
+						// in a compact way elsewhere in the credential by using PrincipalRef.
+						RTUtil.debugInfo("parsing principle.....");
+						transformPrincipalValue(
+							preambleChild,
+							credDomain);
+					}
+				} // end for()..
+			}
+			else if (tagName.equals(ISSUER))
+			{
+				Element[] prinEle = getChildElements(child);
+				if (prinEle.length != 1)
+					throw new DomainSpecException(
+						improper_sub_element_for + "'Issuer'");
+				issuer =
+					transformPrincipalValue(prinEle[0], credDomain)
+						.getValue();
+				credDomain.setIssuer(issuer);
+			}
+			//			else if (tagName.equals(CREDENTIAL_IDENTIFIER))
+			//			{
+			//				// TODO
+			//				throw new UnsupportedOperationException(
+			//					no_support_for + "'CredentialIdentifier'");
+			//			}
+			else if (tagName.equals(VALIDITY_TIME))
+			{
+				//TODO
+				//ValidityTime validityTime = parseValidityTime(child);
+				//credDomain.setValidityTime(validityTime);
+			}
+			else if (tagName.equals(VALIDITY_RULE))
+			{
+				// TODO
+				throw new UnsupportedOperationException(
+					no_support_for + "'ValidityRule'");
+			}
+			else // ROLE_DEFINITION
+				{
+				RoleDefinition roleDef =
+					transformRoleDefinition(
+						issuer,
+						credDomain,
+						child);
+				credDomain.addRoleDefinition(roleDef);
+			}
+		} //===== End of for(int i=0; i<numOfchildren; i++)....
+		credDomain.setComplete();
+		return credDomain;
+	} //===== End of parseCredential()
+	/*
+	    Returns an AccessRule object by parsing element:
+	    <pre>
+	        &lt;AccessRule&gt;
+	            ...
+	        &lt;/AccessRule&gt;
+	    </pre>
+	*/
+	public synchronized CredentialDomain transformAccessRule(
+		Element ele,
+		RTContext rtContext)
+		throws DomainSpecException, CredException
+	{
+		if (!ele.getTagName().equals(ACCESS_RULE))
+			throw new DomainSpecException("Not an AccessRule element.");
+		String hashID = ele.getAttribute(ID);
+		if (hashID.length() == 0)
+		{
+			//compute hashID
+		}
+
+		CredentialDomain ruleDomain =
+			new CredentialDomain(ele, rtContext);
+		HashID id = new HashID(HashID.CREDENTIAL_DOMAIN, hashID);
+		ruleDomain.setHashID(id);
+
+		Principal issuer = null;
+		Element[] elements = getChildElements(ele);
+		for (int i = 0; i < elements.length; i++)
+		{
+			Element child = elements[i];
+			String tagName = child.getTagName();
+			if (tagName.equals(PREAMBLE))
+			{
+				Element[] preambleElements = getChildElements(child);
+				for (int j = 0; j < preambleElements.length; j++)
+				{
+					Element preambleChild = preambleElements[j];
+					String preambleChildTag =
+						preambleChild.getTagName();
+					if (preambleChildTag.equals(IMPORT_DOMAIN))
+						// 0 or more
+					{
+						String name =
+							preambleChild.getAttribute(NAME);
+						if (name.length() == 0)
+							throw new DomainSpecException(
+								missing_attr_value + "'name'");
+						String uri = preambleChild.getAttribute(URI);
+						String idref =
+							preambleChild.getAttribute(IDREF);
+						if (idref.length() == 0)
+							throw new DomainSpecException(
+								missing_attr_value + "'idref'");
+						ApplicationDomain importedDomain =
+							locateDomain(idref, uri, rtContext);
+						ruleDomain.importDomain(name, importedDomain);
+					}
+					else if (preambleChildTag.equals(PRINCIPAL))
+						// 0 or more
+					{
+						transformPrincipalValue(
+							preambleChild,
+							ruleDomain);
+					}
+				} // end for()..
+			}
+			else if (tagName.equals(RULE_IDENTIFIER))
+			{
+				// TODO
+				throw new UnsupportedOperationException(
+					no_support_for + "'RuleIdentifier'");
+			}
+			else if (tagName.equals(VALIDITY_TIME))
+			{
+				//                ValidityTime validityTime = parseValidityTime(child);
+				//                accessRule.setValidityTime(validityTime);
+			}
+			else
+			{
+				RoleDefinition roleDef =
+					transformRoleDefinition(
+						issuer,
+						ruleDomain,
+						child);
+				ruleDomain.addRoleDefinition(roleDef);
+			}
+		} // End of for(int i=0; i<numOfchildren; i++)....
+		ruleDomain.setComplete();
+		return ruleDomain;
+	} // End of parseAccessRule()
+
+	//	private parsePrincipalInfo()
+	//	{
+	//				java.security.PublicKey key = null;
+	//
+	//				Element[] principalElements = getChildElements(elements[0]);
+	//				if (principalElements.length != 1)
+	//					throw new DomainSpecException(
+	//						improper_sub_element_for + "'ds:KeyValue'");
+	//				String tagName = principalElements[0].getTagName();
+	//				if (tagName.equals(DSA_KEY_VALUE))
+	//				{
+	//					try
+	//					{
+	//						DSAKeyValue keyvalue =
+	//							new DSAKeyValue(principalElements[0], null);
+	//						key = keyvalue.getPublicKey();
+	//					}
+	//					catch (XMLSecurityException e)
+	//					{
+	//						e.printStackTrace();
+	//						throw new DomainSpecException(e.getMessage());
+	//					}
+	//
+	//					res =
+	//						new Principal(
+	//							new KeyValue(new KeyType(KeyType.DSA), key));
+	//				}
+	//				else if (tagName.equals(RSA_KEY_VALUE))
+	//				{
+	//					try
+	//					{
+	//						RSAKeyValue keyvalue =
+	//							new RSAKeyValue(principalElements[0], null);
+	//						key = keyvalue.getPublicKey();
+	//					}
+	//					catch (XMLSecurityException e)
+	//					{
+	//						e.printStackTrace();
+	//						throw new DomainSpecException(e.getMessage());
+	//					}
+	//					res =
+	//						new Principal(
+	//							new KeyValue(new KeyType(KeyType.RSA), key));
+	//				}
+	//				else // any ###other
+	//					{
+	//					// TODO 
+	//				}
+	//		
+	//	}
+	//	QQ: Currently CredentialDomain is credential-specific. The good part is that 
+	//	    the naming needs to be only unique in terms of one credential. However,
+	//	    it might be more efficient to have some sort of global environment to 
+	//	    keep the information commonly shared, such as principal keyvalue.
+	//	    For example, in the credential preambel, we could define principals 
+	//	    in advance for this credential. But different credentials are very 
+	//	    likely to use same principals. If we have a global env to keep it, then 
+	//	    we don't need to pass the credDomain around.
+	/**
+	 * Method transformPrincipalValue.<br>
+	 * @param ele
+	 * @param credDomain
+	 * @return PrincipalValue
+	 * @throws DomainSpecException
+	 */
+	private PrincipalValue transformPrincipalValue(
+		Element ele,
+		CredentialDomain credDomain)
+		throws DomainSpecException
+	{
+		String tag = ele.getTagName();
+		if (!tag.equals(PRINCIPAL) && !tag.equals(PRINCIPAL_REF))
+			throw new DomainSpecException("Not a Principal element");
+		Principal res = null;
+		PrincipalValue value = null;
+		String id = null;
+		SimpleType principalType = credDomain.getPrincipalType();
+		if (tag.equals(PRINCIPAL))
+		{
+			id = ele.getAttribute(SHORT_NAME);
+			Element[] elements = getChildElements(ele);
+			if (elements.length != 1)
+				throw new DomainSpecException(
+					improper_sub_element_for + "'Principal'");
+			String eleTag = elements[0].getTagName();
+			if (eleTag.equals(INTEGER_VALUE))
+			{
+				res =
+					new DataValuePrincipal(
+						transformIntegerValue(
+							(IntegerType) principalType,
+							elements[0]));
+			}
+			else if (eleTag.equals(STRING_VALUE))
+			{
+				res =
+					new DataValuePrincipal(
+						transformStringValue(
+							(StringType) principalType,
+							elements[0]));
+			}
+			else if (eleTag.equals(KEY_HASH))
+			{
+				Node textNode = elements[0].getFirstChild();
+				if (textNode.getNodeType()
+					!= org.w3c.dom.Node.TEXT_NODE)
+					throw new DomainSpecException("Wrong elements for StringValue");
+				String hashValue = textNode.getNodeValue();
+				res = new PublicKeyPrincipal(hashValue);
+			}
+			credDomain.addPrincipal(id, res);
+		}
+		else if (tag.equals(PRINCIPAL_REF))
+		{
+			id = ele.getAttribute(SHORT_NAME);
+			RTUtil.debugInfo("shortName = " + id);
+			res = credDomain.getPrincipal(id);
+			if (res == null)
+				throw new DomainSpecException("Principal not found");
+			value = new PrincipalValue(res);
+		}
+		return value;
+	}
+	/**
+	 * Method transformRoleDefinition.<br>
+     * Returns a role definition object.
+    
+        <p>
+        A role definition may be one the the following elements, i.e. 
+        <b>SimpleMember, SimpleContainment, LinkedContainment, IntersectionContainment,
+        ProductContainment, ExclusiveProductContainment, SimpleDelegation, or
+        AdvancedDelegation</b>.  Each role definition has a head and a body. The head 
+        part is defined by a HeadRoleTerm. The difference between the above 8 
+        elements lies in the body part. 
+        
+        <P>
+        The product role definition represented by <b>ProductContainment</b> and 
+        <b>ExclusiveProductContainment</b> has not been supported yet.
+	 * @param issuer
+	 * @param credDomain
+	 * @param ele
+	 * @return RoleDefinition
+	 * @throws CredException
+	 * @throws DomainSpecException
+	 */
+	private RoleDefinition transformRoleDefinition(
+		Principal issuer,
+		CredentialDomain credDomain,
+		Element ele)
+		throws CredException, DomainSpecException
+	{
+		RTUtil.debugInfo("parseRoleDefinition().... ");
+		String tag = ele.getTagName();
+		RTUtil.debugInfo("parseRoleDefinition()'s tag = " + tag);
+		if (!tag.equals(SIMPLE_MEMBER)
+			&& !tag.equals(SIMPLE_CONTAINMENT)
+			&& !tag.equals(LINKED_CONTAINMENT)
+			&& !tag.equals(INTERSECTION_CONTAINMENT)
+			&& !tag.equals(PRODUCT_CONTAINMENT)
+			&& !tag.equals(EXCLUSIVE_PRODUCT_CONTAINMENT)
+			&& !tag.equals(SIMPLE_DELEGATION)
+			&& !tag.equals(ADVANCED_DELEGATION))
+			throw new DomainSpecException("Not a proper role definition element");
+		RoleDefinition roleDefinition = null;
+		if (tag.equals(SIMPLE_DELEGATION)
+			|| tag.equals(ADVANCED_DELEGATION))
+		{
+			Element[] elements = getChildElements(ele);
+			if (elements.length < 2 || elements.length > 3)
+				throw new DomainSpecException(
+					improper_sub_element_for + "delegation role");
+			Element headElement = elements[0];
+			Element delegateToElement = elements[1];
+			Element controlElement = null; // optional
+			if (elements.length == 3)
+				controlElement = elements[2];
+			Role head =
+				new Role(
+					issuer,
+					transformRoleTerm(headElement, credDomain));
+			DelegationRole body =
+				transformDelegation(
+					issuer,
+					credDomain,
+					delegateToElement,
+					controlElement);
+			roleDefinition =
+				new RoleDefinition(credDomain, head, body);
+		}
+		else
+		{
+			Element[] elements = getChildElements(ele);
+			if (elements.length != 2)
+				throw new DomainSpecException(
+					improper_sub_element_for + "role definition");
+			Element headElement = elements[0];
+			Element bodyElement = elements[1];
+			Role head =
+				new Role(
+					issuer,
+					transformRoleTerm(headElement, credDomain));
+			PrincipalExpression body =
+				transformBody(issuer, credDomain, bodyElement);
+			roleDefinition =
+				new RoleDefinition(credDomain, head, body);
+		}
+		return roleDefinition;
+	}
+	/**
+	 * Method transformBody.<br>
+     * Returns a PrincipalExpression for the body of a role definition.
+        <P>
+        The body can be one of the following: PrincipalValue, RoleTerm, 
+        ExternalRole, LinkedRole, Intersection, Product, or a Delegation.
+    
+        The method handles all types of the role definition body except the 
+        Delegation role body.
+	 * @param issuer
+	 * @param credDomain
+	 * @param ele
+	 * @return PrincipalExpression
+	 * @throws CredException
+	 * @throws DomainSpecException
+	 */
+	private PrincipalExpression transformBody(
+		Principal issuer,
+		CredentialDomain credDomain,
+		Element ele)
+		throws CredException, DomainSpecException
+	{
+		String tag = ele.getTagName();
+		RTUtil.debugInfo("parseBody() tag = " + tag);
+		PrincipalExpression prinExp = null;
+		if (tag.startsWith(PRINCIPAL))
+		{
+			prinExp =
+				transformPrincipalValue(ele, credDomain).getValue();
+		}
+		else if (tag.equals(ROLE_TERM))
+		{
+			RoleTerm roleTerm = transformRoleTerm(ele, credDomain);
+			prinExp = new Role(issuer, roleTerm);
+		}
+		else if (tag.equals(EXTERNAL_ROLE))
+		{
+			prinExp = transformExternalRole(ele, credDomain);
+		}
+		else if (tag.equals(LINKED_ROLE))
+		{
+			NodeList nodes = ele.getElementsByTagName(ROLE_TERM);
+			if (nodes.getLength() != 2)
+				throw new DomainSpecException(
+					improper_sub_element_for + "'LinkedRole'");
+			Element roleTermEle1 = (Element) nodes.item(0);
+			Element roleTermEle2 = (Element) nodes.item(1);
+			prinExp =
+				new LinkedRole(
+					transformRoleTerm(roleTermEle1, credDomain),
+					transformRoleTerm(roleTermEle2, credDomain));
+		}
+		else if (tag.equals(INTERSECTION))
+		{
+			prinExp = transformRoleIntersection(ele, credDomain);
+		}
+		else if (tag.equals(PRODUCT))
+		{
+			// TODO
+			throw new UnsupportedOperationException(
+				no_support_for + "'Product'");
+		}
+		else if (tag.equals(EXCLUSIVE_PRODUCT))
+		{
+			// TODO
+			throw new UnsupportedOperationException(
+				no_support_for + "'ExclusiveProduct");
+		}
+		return prinExp;
+	}
+	/**
+	 * Method transformDelegation.<br>
+        Returns a DelegationRole object for the body of a role definition 
+        by parsing element: <br>
+        <pre>
+            &lt;SimpleDelegation&gt;
+                ...
+            &lt;/SimpleDelegation&gt;
+            
+            Or
+            
+            &lt;AdvancedDelegation&gt;
+                ...
+            &lt;/AdvancedDelegation&gt;
+        </pre>
+	 * @param issuer
+	 * @param credDomain
+	 * @param delegationElement
+	 * @param controlElement
+	 * @return DelegationRole
+	 * @throws DomainSpecException
+	 * @throws CredException
+	 */
+	private DelegationRole transformDelegation(
+		Principal issuer,
+		CredentialDomain credDomain,
+		Element delegationElement,
+		Element controlElement)
+		throws DomainSpecException, CredException
+	{
+		if (!delegationElement.getTagName().equals(DELEGATE_TO))
+			throw new DomainSpecException("Not a delegateTo element");
+		if (controlElement != null
+			&& !controlElement.getTagName().equals(CONTROL))
+			throw new DomainSpecException("Not a Control element");
+		PrincipalExpression delegateTo = null;
+		Role control = null;
+		// delegateTo
+		Element[] elements = getChildElements(delegationElement);
+		for (int i = 0; i < elements.length; i++)
+		{
+			Element child = elements[i];
+			String childName = child.getTagName();
+			if (childName.startsWith(PRINCIPAL))
+			{
+				delegateTo =
+					transformPrincipalValue(child, credDomain)
+						.getValue();
+			}
+			else if (childName.equals(ROLE_TERM))
+			{
+				RoleTerm roleTerm =
+					transformRoleTerm(child, credDomain);
+				delegateTo = new Role(issuer, roleTerm);
+			}
+			else
+			{
+				throw new DomainSpecException(
+					improper_sub_element_for + "'DelegatTo'");
+			}
+		}
+		// control
+		if (controlElement != null)
+		{
+			elements = getChildElements(controlElement);
+			for (int i = 0; i < elements.length; i++)
+			{
+				Element child = elements[i];
+				String childName = child.getTagName();
+				if (childName.equals(ROLE_TERM))
+				{
+					RoleTerm roleTerm =
+						transformRoleTerm(child, credDomain);
+					control = new Role(issuer, roleTerm);
+				}
+				else if (childName.equals(EXTERNAL_ROLE))
+				{
+					control =
+						transformExternalRole(child, credDomain);
+				}
+				else
+				{
+					throw new DomainSpecException(
+						improper_sub_element_for + "'Control'");
+				}
+			}
+		}
+		return new DelegationRole(delegateTo, control);
+	}
+	/**
+	 * Method transformExternalRole.<br>
+     * Returns an ExternalRole object by parsing element:
+        <pre>
+            &lt;ExternalRole&gt;
+                ...
+            &lt;/ExternalRole&gt;
+        </pre>
+	 * @param ele
+	 * @param credDomain
+	 * @return Role
+	 * @throws CredException
+	 * @throws DomainSpecException
+	 */
+	private Role transformExternalRole(
+		Element ele,
+		CredentialDomain credDomain)
+		throws CredException, DomainSpecException
+	{
+		if (!ele.getTagName().equals(EXTERNAL_ROLE))
+			throw new DomainSpecException("Not an ExternalRole element.");
+		Element[] elements = getChildElements(ele);
+		if (elements.length != 2)
+			throw new DomainSpecException(
+				improper_sub_element_for + "'ExternalRole'");
+		Element prinEle = elements[0];
+		Element roleTermEle = elements[1];
+		return new Role(
+			transformPrincipalValue(prinEle, credDomain).getValue(),
+			transformRoleTerm(roleTermEle, credDomain));
+	}
+	/**
+	 * Method transformRoleIntersection.<br>
+     * Returns an ExternalRole object by parsing element:
+        <pre>
+            &lt;Intersection&gt;
+                ...
+            &lt;/Intersection&gt;
+        </pre>
+	 * @param ele
+	 * @param credDomain
+	 * @return RoleIntersection
+	 * @throws CredException
+	 * @throws DomainSpecException
+	 */
+	private RoleIntersection transformRoleIntersection(
+		Element ele,
+		CredentialDomain credDomain)
+		throws CredException, DomainSpecException
+	{
+		if (!ele.getTagName().equals(INTERSECTION))
+			throw new DomainSpecException("Not an Intersection element.");
+		RoleIntersection ri = new RoleIntersection();
+		Element[] elements = getChildElements(ele);
+		int n = elements.length;
+		for (int i = 0; i < n; i++)
+		{
+			Element child = elements[i];
+			String childTag = child.getTagName();
+			if (childTag.equals(ROLE_TERM))
+			{
+				ri.and(transformRoleTerm(child, credDomain));
+			}
+			else if (childTag.equals(EXTERNAL_ROLE))
+			{
+				ri.and(transformExternalRole(child, credDomain));
+			}
+			else
+			{
+				throw new DomainSpecException(
+					improper_sub_element_for + "'Intersection'");
+			}
+		}
+		return ri;
+	}
+	/**
+	 * Method transformRoleTerm.<br>
+     * Returns a RoleTerm object by parsing element:
+        <pre>
+            &lt;RoleTerm&gt;
+                ...
+            &lt;/RoleTerm&gt; 
+        </pre>
+	 * @param ele
+	 * @param credDomain
+	 * @return RoleTerm
+	 * @throws CredException
+	 * @throws DomainSpecException
+	 */
+	private RoleTerm transformRoleTerm(
+		Element ele,
+		CredentialDomain credDomain)
+		throws CredException, DomainSpecException
+	{
+		if (!ele.getTagName().equals(HEAD_ROLE_TERM)
+			&& !ele.getTagName().equals(ROLE_TERM))
+			throw new DomainSpecException("Not a RoleTerm element.");
+		String roleName = ele.getAttribute(NAME);
+		if (roleName.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'name'");
+		String domain = ele.getAttribute(DOMAIN);
+		RTUtil.debugInfo("**** roleName = " + roleName);
+		RTUtil.debugInfo("**** domain = " + domain);
+		RoleDeclaration roleDecl =
+			credDomain.lookupRoleDeclaration(domain, roleName);
+		RoleTerm roleTerm = new RoleTerm(roleDecl);
+		NodeList children = ele.getElementsByTagName(PARAMETER);
+		int n = children.getLength();
+		for (int i = 0; i < n; i++)
+		{
+			StringBuffer prefix = new StringBuffer(roleName);
+			Element paramEle = (Element) children.item(i);
+			String paramName = paramEle.getAttribute(NAME);
+			//prefix.append(COLON).append(paramName);
+			transformParameter(
+				paramEle,
+				prefix,
+				roleTerm,
+				credDomain);
+		}
+		return roleTerm;
+	}
+	/**
+	 * Method transformParameter.<br>
+        parses element:
+        <pre>
+            &lt;Parameter name="aa" id="s"&gt;
+                ...
+            &lt;/Parameter&gt;
+        </pre>
+	 * @param ele
+	 * @param prefix
+	 * @param roleTerm
+	 * @param credDomain
+	 * @throws DomainSpecException
+	 */
+	//ValueSet 
+	private void transformParameter(
+		Element ele,
+		StringBuffer prefix,
+		RoleTerm roleTerm,
+		CredentialDomain credDomain)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(PARAMETER))
+			throw new DomainSpecException("Not a Parameter element.");
+		String parameterName = ele.getAttribute(NAME);
+		if (parameterName.length() == 0)
+			throw new DomainSpecException(
+				missing_attr_value + "'name'");
+		prefix.append(COLON).append(parameterName);
+		DataType paramType = roleTerm.getParameterType(parameterName);
+		String id = ele.getAttribute(ID);
+		RTUtil.debugInfo("transformParameter() id = " + id);
+		Element[] elements = getChildElements(ele);
+		if (elements.length > 1)
+			throw new DomainSpecException(
+				improper_sub_element_for + "'Parameter'");
+		if (elements.length == 0)
+		{
+			// TODO: Create a null parameter value in this case.
+			// It is related to Equals Element.
+			ValueSet nullParameterValue = new ValueSet(paramType);
+			roleTerm.putParameterValue(
+				prefix.toString(),
+				nullParameterValue);
+		}
+		else
+		{
+			Element valueEle = elements[0];
+			String tag = valueEle.getTagName();
+			if (tag.equals(EQUALS))
+			{
+				// TODO
+				throw new UnsupportedOperationException(
+					no_support_for + "'Equals'");
+			}
+			else if (tag.equals(SPECIAL_PRINCIPAL))
+			{
+				// TODO
+				throw new UnsupportedOperationException(
+					no_support_for + "'SpecialPrincipal'");
+			}
+			// the rest of the elements go to ValueSet
+			else
+			{
+				transformValueSetGroup(
+					paramType,
+					valueEle,
+					prefix,
+					roleTerm,
+					credDomain);
+			}
+		}
+	}
+	/**
+	 * Method transformValueSetGroup.<br>
+        Parses Parameter value elements and stores the prefix and value mapping
+        in the RoleTerm object.
+	 * @param type
+	 * @param ele
+	 * @param prefix
+	 * @param roleTerm
+	 * @param credDomain
+	 * @throws DomainSpecException
+	 */
+	//ValueSet 
+	private void transformValueSetGroup(
+		DataType type,
+		Element ele,
+		StringBuffer prefix,
+		RoleTerm roleTerm,
+		CredentialDomain credDomain)
+		throws DomainSpecException
+	{
+		ValueSet parameterValue = null;
+		String tag = ele.getTagName();
+        
+		if (tag.equals(TREE_VALUE)) // TreeValueSet
+		{
+			parameterValue = transformTreeValue((TreeType) type, ele);
+			roleTerm.putParameterValue(
+				prefix.toString(),
+				parameterValue);
+		}
+		else if (tag.equals(INTERVAL)) // IntervalValueSet
+		{
+			parameterValue =
+				transformIntervalValue((OrderedType) type, ele);
+			roleTerm.putParameterValue(
+				prefix.toString(),
+				parameterValue);
+		}
+		else if (tag.equals(SET)) // SetValueSet
+		{
+			Element[] elements = getChildElements(ele);
+			String memberTag = elements[0].getTagName();
+			if (memberTag.equals(INTEGER_VALUE))
+			{
+				SetValueSet set = new SetValueSet((IntegerType) type);
+				IntegerValue v = null;
+				for (int i = 0; i < elements.length; i++)
+				{
+					Element memberEle = elements[i];
+					v =
+						transformIntegerValue(
+							(IntegerType) type,
+							memberEle);
+					set.addValue(v);
+				}
+				parameterValue = set;
+			}
+			else if (memberTag.equals(DECIMAL_VALUE))
+			{
+				SetValueSet set = new SetValueSet((DecimalType) type);
+				DecimalValue v = null;
+				for (int i = 0; i < elements.length; i++)
+				{
+					Element memberEle = elements[i];
+					v =
+						transformDecimalValue(
+							(DecimalType) type,
+							memberEle);
+					set.addValue(v);
+				}
+				parameterValue = set;
+			}
+			else if (memberTag.equals(STRING_VALUE))
+			{
+				SetValueSet set = new SetValueSet((StringType) type);
+				StringValue v = null;
+				for (int i = 0; i < elements.length; i++)
+				{
+					Element memberEle = elements[i];
+					v =
+						transformStringValue(
+							(StringType) type,
+							memberEle);
+					set.addValue(v);
+				}
+				parameterValue = set;
+			}
+			else if (memberTag.equals(ENUM_VALUE))
+			{
+				SetValueSet set = new SetValueSet((EnumType) type);
+				EnumValue v = null;
+				for (int i = 0; i < elements.length; i++)
+				{
+					Element memberEle = elements[i];
+					v =
+						transformEnumValue(
+							(EnumType) type,
+							memberEle);
+					set.addValue(v);
+				}
+				parameterValue = set;
+			}
+			else if (memberTag.startsWith(PRINCIPAL))
+			{
+				SetValueSet set = new SetValueSet((KeyType) type);
+				PrincipalValue v = null;
+				for (int i = 0; i < elements.length; i++)
+				{
+					Element memberEle = elements[i];
+					v =
+						transformPrincipalValue(
+							memberEle,
+							credDomain);
+					set.addValue(v);
+				}
+				parameterValue = set;
+			}
+			roleTerm.putParameterValue(
+				prefix.toString(),
+				parameterValue);
+		}
+		else if (tag.equals(RECORD)) // Record
+		{
+			Element[] elements = getChildElements(ele);
+			// Fields
+			for (int i = 0; i < elements.length; i++)
+			{
+				StringBuffer newPrefix =
+					new StringBuffer(prefix.toString());
+				String fieldName = elements[i].getAttribute(NAME);
+				if (fieldName.length() == 0)
+					throw new DomainSpecException(
+						missing_attr_value + "'name'");
+				RTUtil.debugInfo(
+					"transformValueSetGroup.field name = "
+						+ fieldName);
+				newPrefix.append(COLON).append(fieldName);
+				DataType fieldType =
+					((RecordType) type).getFieldType(fieldName);
+				if (fieldType != null)
+					RTUtil.debugInfo(
+						"transformValueSetGroup.type name = "
+							+ fieldType.getName());
+				else
+					RTUtil.debugInfo(
+						"transformValueSetGroup.type  =  null");
+				Element valueEle = getChildElements(elements[i])[0];
+				// recurrsion
+				transformValueSetGroup(
+					fieldType,
+					valueEle,
+					newPrefix,
+					roleTerm,
+					credDomain);
+			}
+		}
+		else // SingletonValueSet
+			{
+			transformValueGroup(
+				(SimpleType) type,
+				ele,
+				prefix,
+				roleTerm,
+				credDomain);
+		}
+	} // end of transformValueSetGroup()
+	/**
+	 * Method transformValueGroup.<br>
+        Parses Value choice group, which can be one of the following:
+        IntegerValue, DecimalValue, StringValue, EnumValue, TimeValue, 
+        or PrincipalValue.
+	 * @param type
+	 * @param ele
+	 * @param prefix
+	 * @param roleTerm
+	 * @param credDomain
+	 * @throws DomainSpecException
+	 */
+	//SingletonValueSet 
+	private void transformValueGroup(
+		SimpleType type,
+		Element ele,
+		StringBuffer prefix,
+		RoleTerm roleTerm,
+		CredentialDomain credDomain)
+		throws DomainSpecException
+	{
+		SingletonValueSet value = null;
+		String tag = ele.getTagName();
+		if (tag.equals(INTEGER_VALUE))
+		{
+			value =
+				new SingletonValueSet(
+					(IntegerType) type,
+					transformIntegerValue((IntegerType) type, ele));
+			roleTerm.putParameterValue(prefix.toString(), value);
+		}
+		else if (tag.equals(DECIMAL_VALUE))
+		{
+			value =
+				new SingletonValueSet(
+					(DecimalType) type,
+					transformDecimalValue((DecimalType) type, ele));
+			roleTerm.putParameterValue(prefix.toString(), value);
+		}
+		else if (tag.equals(STRING_VALUE))
+		{
+			value =
+				new SingletonValueSet(
+					(StringType) type,
+					transformStringValue((StringType) type, ele));
+			roleTerm.putParameterValue(prefix.toString(), value);
+		}
+		else if (tag.equals(ENUM_VALUE))
+		{
+			value =
+				new SingletonValueSet(
+					(EnumType) type,
+					transformEnumValue((EnumType) type, ele));
+			roleTerm.putParameterValue(prefix.toString(), value);
+		}
+		else if (tag.equals(TIME_VALUE))
+		{
+			// TODO
+			//throw new UnsupportedOperationException(no_support_for+"'TimeValue'");
+			//roleTerm.putParameterValue(prefix.toString(), valu
+		}
+		else if (tag.startsWith(PRINCIPAL))
+		{
+			value =
+				new SingletonValueSet(
+					credDomain.getPrincipalType(),
+					transformPrincipalValue(ele, credDomain));
+			roleTerm.putParameterValue(prefix.toString(), value);
+		}
+	} // end of transformValueGroup()
+	/**
+	 * Method transformIntervalValue.<br>
+        Returns an IntervalValue object by parsing element:
+        <pre>
+            &lt;Interval includeMin="true" includeMax="true"&gt;
+                &lt;min&gt; ... &lt;/min&gt;
+                &lt;max&gt; ... &lt;/max&gt;
+            &lt;/Interval&gt;
+        </pre>
+	 * @param type
+	 * @param ele
+	 * @return IntervalValueSet
+	 * @throws DomainSpecException
+	 */
+	private IntervalValueSet transformIntervalValue(
+		OrderedType type,
+		Element ele)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(INTERVAL))
+			throw new DomainSpecException("Not an Interval element");
+		Element fromEle = getFirstChildElementByTagName(ele, FROM);
+		Element toEle = getFirstChildElementByTagName(ele, TO);
+		Element e1 = null, e2 = null;
+		if (fromEle != null)
+			e1 = getFirstChildElement(fromEle);
+		if (toEle != null)
+			e2 = getFirstChildElement(toEle);
+		if (e1 != null && e2 != null)
+		{
+			if (!e1.getTagName().equals(e2.getTagName()))
+				throw new DomainSpecException(
+					improper_sub_element_for + "'Interval'");
+		}
+		DataValue min = null, max = null;
+		if (e1 != null)
+			min = transformOrderedValue(type, e1);
+		if (e2 != null)
+			max = transformOrderedValue(type, e2);
+		return new IntervalValueSet(type, min, max);
+	}
+	/**
+	 * Method transformOrderedValue.<br>
+        Returns DataValue by parsing elements:
+        <pre>
+            &lt;IntegerValue&gt; ... &lt;/IntegerValue&gt; or 
+    
+            &lt;DecimalValue&gt; ... &lt;/DecimalValue&gt; or
+    
+            &lt;StirngValue&gt; ... &lt;/StringValue&gt; or
+    
+            &lt;EnumValue&gt; ... &lt;/EnumValue&gt; or
+    
+            &lt;TimeValue&gt; ... &lt;/timeValue&gt;
+        </pre>
+	 * @param type
+	 * @param ele
+	 * @return DataValue
+	 * @throws DomainSpecException
+	 */
+	private DataValue transformOrderedValue(
+		OrderedType type,
+		Element ele)
+		throws DomainSpecException
+	{
+		DataValue value = null;
+		String tag = ele.getTagName();
+		if (tag.equals(INTEGER_VALUE))
+		{
+			value = transformIntegerValue((IntegerType) type, ele);
+		}
+		if (tag.equals(DECIMAL_VALUE))
+		{
+			value = transformDecimalValue((DecimalType) type, ele);
+		}
+		if (tag.equals(STRING_VALUE))
+		{
+			value = transformStringValue((StringType) type, ele);
+		}
+		if (tag.equals(ENUM_VALUE))
+		{
+			value = transformEnumValue((EnumType) type, ele);
+		}
+		if (tag.equals(TIME_VALUE))
+		{
+			//value = transformTimeValue((TimeType)type, ele);
+		}
+		return value;
+	}
+	/**
+	 * Method transformIntegerValue.<br>
+        Returns an IntegerValue object by parsing element:
+        <pre>
+            &lt;IntegerValue&gt;
+                123
+            &lt;/IntegerValue&gt;
+        </pre>
+	 * @param type
+	 * @param ele
+	 * @return IntegerValue
+	 * @throws DomainSpecException
+	 */
+	private IntegerValue transformIntegerValue(
+		IntegerType type,
+		Element ele)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(INTEGER_VALUE))
+			throw new DomainSpecException("Not an IntegerValue element.");
+		Node textNode = ele.getFirstChild();
+		if (textNode.getNodeType() != org.w3c.dom.Node.TEXT_NODE)
+			throw new DomainSpecException("Wrong elements for StringValue");
+		IntegerValue value =
+			new IntegerValue(textNode.getNodeValue());
+		// Type checking.
+		if (type != null && !type.isValidValue(value))
+			throw new DomainSpecException(
+				illegal_value_for + "IntegerType :" + type.getName());
+		return value;
+	}
+	/**
+	 * Method transformDecimalValue.<br>
+        Returns a DecimalValue object by parsing element:
+        <pre>
+            &lt;DecimalValue&gt;
+                123
+            &lt;/DecimalValue&gt;
+        </pre>
+	 * @param type
+	 * @param ele
+	 * @return DecimalValue
+	 * @throws DomainSpecException
+	 */
+	private DecimalValue transformDecimalValue(
+		DecimalType type,
+		Element ele)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(DECIMAL_VALUE))
+			throw new DomainSpecException("Wrong element");
+		Node textNode = ele.getFirstChild();
+		if (textNode.getNodeType() != org.w3c.dom.Node.TEXT_NODE)
+			throw new DomainSpecException("Wrong elements for StringValue");
+		DecimalValue value =
+			new DecimalValue(textNode.getNodeValue());
+		// Type checking.
+		if (type != null && !type.isValidValue(value))
+			throw new DomainSpecException(
+				illegal_value_for + "DecimalType :" + type.getName());
+		return value;
+	}
+	/**
+	 * Method transformStringValue.<br>
+        Returns a StringValue object by parsing element:
+        <pre>
+            &lt;StringValue&gt;
+                123
+            &lt;/StringValue&gt;
+        </pre>
+	 * @param type
+	 * @param ele
+	 * @return StringValue
+	 * @throws DomainSpecException
+	 */
+	private StringValue transformStringValue(
+		StringType type,
+		Element ele)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(STRING_VALUE))
+			throw new DomainSpecException("Not a StringValue element");
+		Node textNode = ele.getFirstChild();
+		if (textNode.getNodeType() != org.w3c.dom.Node.TEXT_NODE)
+			throw new DomainSpecException(
+				improper_sub_element_for + "'StringValue'");
+		StringValue value = new StringValue(textNode.getNodeValue());
+		// Type checking.
+		if (type != null && !type.isValidValue(value))
+			throw new DomainSpecException(
+				illegal_value_for + "StringType :" + type.getName());
+		return value;
+	}
+	/**
+	 * Method transformEnumValue.<br>
+        Returns an EnumValue object by parsing element:
+        <pre>
+            &lt;EnumValue&gt;
+                123
+            &lt;/EnumValue&gt;
+        </pre>
+	 * @param type
+	 * @param ele
+	 * @return EnumValue
+	 * @throws DomainSpecException
+	 */
+	private EnumValue transformEnumValue(EnumType type, Element ele)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(ENUM_VALUE))
+			throw new DomainSpecException("Not an EnumValue element");
+		Node textNode = ele.getFirstChild();
+		if (textNode.getNodeType() != org.w3c.dom.Node.TEXT_NODE)
+			throw new DomainSpecException(
+				improper_sub_element_for + "'EnumValue'");
+		EnumValue value =
+			new EnumValue(textNode.getNodeValue());
+		// Type checking.
+		if (type != null && !type.isValidValue(value))
+		{
+			RTUtil.debugInfo(
+				"transformEnumValue() type name = " + type.getName());
+			RTUtil.debugInfo(
+				"transformEnumValue() value = " + value.toString());
+			throw new DomainSpecException(
+				illegal_value_for + "EnumType :" + type.getName());
+		}
+		return value;
+	}
+	/**
+	 * Method transformTreeValue.<br>
+        Returns a TreeValueSet object by parsing element:
+        <pre>
+            &lt;TreeValue includeCurrent="true" 
+                       includeChildren="true" 
+                       includeDescendents="false"&gt;    
+                cs.stanford.edu
+            &lt;/TreeValue&gt;
+        </pre>
+	 * @param type
+	 * @param ele
+	 * @return TreeValueSet
+	 * @throws DomainSpecException
+	 */
+	private TreeValueSet transformTreeValue(
+		TreeType type,
+		Element ele)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(TREE_VALUE))
+			throw new DomainSpecException("Not a TreeValue element");
+		Node textNode = ele.getFirstChild();
+		if (textNode.getNodeType() != org.w3c.dom.Node.TEXT_NODE)
+			throw new DomainSpecException(
+				improper_sub_element_for + "'TreeValue'");
+		boolean includeCurrent =
+			RTUtil.parseBoolean(
+				ele.getAttribute(INCLUDE_CURRENT),
+				true);
+		boolean includeChildren =
+			RTUtil.parseBoolean(
+				ele.getAttribute(INCLUDE_CHILDREN),
+				false);
+		boolean includeDescendents =
+			RTUtil.parseBoolean(
+				ele.getAttribute(INCLUDE_DESCENDENTS),
+				false);
+		String value = textNode.getNodeValue();
+		String separator = type.getSeparator();
+		StringTokenizer st = new StringTokenizer(value, separator);
+		int size = st.countTokens();
+		ArrayList values = new ArrayList(size);
+		while (st.hasMoreTokens())
+		{
+			values.add((String) st.nextToken());
+		}
+		TreeValue res = new TreeValue(type, values);
+		// Type checking.
+		if (type != null && !type.isValidValue(res))
+			throw new DomainSpecException(
+				illegal_value_for + "TreeType :" + type.getName());
+		return new TreeValueSet(
+			(TreeType) type,
+			res,
+			includeCurrent,
+			includeChildren,
+			includeDescendents);
+	}
+	/**
+	 * Method transformTimeValue.<br>
+        Returns a TimeValue object by parsing element:
+        <pre>
+            &lt;TimeValue&gt;
+                2002-08-29T09:31:32
+            &lt;/TimeValue&gt;
+        </pre>
+	 * @param type
+	 * @param ele
+	 * @return TimeValue
+	 * @throws DomainSpecException
+	 */
+	private TimeValue transformTimeValue(TimeType type, Element ele)
+		throws DomainSpecException
+	{
+		if (!ele.getTagName().equals(TIME_VALUE))
+			throw new DomainSpecException("Not a TimeValue element");
+		Node textNode = ele.getFirstChild();
+		if (textNode.getNodeType() != org.w3c.dom.Node.TEXT_NODE)
+			throw new DomainSpecException(
+				improper_sub_element_for + "'TimeValue'");
+		String dateString = textNode.getNodeValue();
+		String typeName = type.getName();
+		TimeValue value =
+			new TimeValue(
+				typeName,
+				transformDateTime(typeName, dateString));
+		return value;
+	}
+	/**
+	 * Method transformDateTime.<br>
+        Returns a java.uti.Date object from the given XML Schema datetype name
+        and the dateTime stirng.
+        
+        By using Sun XML Datetype Library, we validate dateTime against 
+        the corresonding datetype specified by typeName. DomainSpecExeption is
+        thrown when validation fails.
+	 * @param typeName
+	 * @param dateTime
+	 * @return Date
+	 * @throws DomainSpecException
+	 */
+	private Date transformDateTime(String typeName, String dateTime)
+		throws DomainSpecException
+	{
+		com.sun.msv.datatype.xsd.XSDatatype type = null;
+		try
+		{
+			com.sun.msv.datatype.xsd.DatatypeFactory.getTypeByName(
+				typeName);
+		}
+		catch (org.relaxng.datatype.DatatypeException e)
+		{
+			throw new DomainSpecException(
+				"Cannot recognize type " + typeName);
+		}
+		if (!type.isValid(dateTime, null))
+			throw new DomainSpecException(
+				illegal_value_for + type.getName());
+		// for datetype, the corresponding Java object is Calendar.
+		Calendar dtObject =
+			(Calendar) type.createJavaObject(dateTime, null);
+		Class dtClass = type.getJavaObjectType();
+		RTUtil.debugInfo(
+			"paseDateTime()> dtClass = " + dtClass.getName());
+		return dtObject.getTime();
+	}
+	/*
+	TreeValue parseDateTimeOld(String typeName, String dateTime)
+	    throws DomainSpecException
+	{
+	
+	        XSDatatype = DatatypeFactory.getTypeByName(tu   
+	
+	    string regExp;
+	    String s = dateTime.trim();
+	
+	    if(typeName.equals("dateTime"))
+	    {
+	        regExp = "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}";
+	        int tIndex = s.indexOf('T');
+	        
+	    }
+	    else if (typeName.equals("date"))
+	    {
+	    }
+	    else if (typeName.equals("time"))
+	    {
+	    }
+	    else if(typeName.equals("gYear"))
+	    {
+	    }
+	    else if(typeName.equals("gYearMonth"))
+	    {
+	    }
+	    else if(typeName.equals("gMonth"))
+	    {
+	    }
+	    else if(typeName.equals("gMonthDay"))
+	    {
+	    }
+	    else if(typeName.equals("gDay"))
+	    {
+	    }
+	    
+	// Issue: Not sure how to handle the optional time zone part, so ignore it for now.
+	// The following is an attempt to match the time zone.
+	// "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(Z|((+|\\0x2D)[0-2][0-9]:[0-2][0-9]))?
+	
+	    if(! s.matches(regExp))
+	        throw new DomainSpecException("'"+dateTime+
+	            "' is no in the format of 'CCYY-MM-DDThh:mm:ss'");           
+	    String year = s.substring(0, 4);
+	    if(! RTUtil.validYear(year))
+	        throw new DomainSecException("Invalid year '" + year + "'");
+	    String month = s.substring(5, 8);
+	    if(! RTUtil.validMonth(month))
+	        throw new DomainSpecException("Invalid month '" + month+"'");
+	    String day = s.substring(9, 11);
+	    if(! RTUtil.validDay(year, month, day))
+	        throw new DomainSpecException("Invalid day '" + day + 
+	            "' in month '"+month+"'");
+	    String hour = s.substring(12, 14);
+	    if(! RTUtil.validHour(hour))
+	        throw new DomainSpecException("Invalid hour '"+hour+"'");
+	    String minute = s.substring(15, 17);
+	    if(! RTUtil.validMinSec(minute))
+	        throw new DomainSpecException("Invalid minute '"+minute+"'");
+	    String second = s.substring(18, 20);
+	    if(! RTUtil.validMinSec(second))
+	        throw new DomainSpecException("Invalid second '"+second+"'");
+	    //String timeZone = s.substring(22);
+	    
+	
+	    Date date = null;
+	    try
+	    {
+	        Calendar calendar = Calendar.getInstance();
+	        calendar.set(Integer.parseInt(year), Integer.parseInt(month), 
+	                     Integer.parseInt(day), Integer.parseInt(hour), 
+	                     Integer.parseInt(minute), Integer.parseInt(second));
+	        date = calendar.getTime();
+	    } 
+	    catch(NumberFormatException e)
+	    {
+	        // Because month, day, hour, minute, second has been validated
+	        // it should never reach here. 
+	    }
+	    
+	    return ;
+	}
+	*/
+	//        DatatypeValidator validator = getDatatypeValidator("dateTime");
+	//        try
+	//        {
+	//            validator.validate(dateTime, null);
+	//        } 
+	//        catch(InvalidDatatypeValueException e)
+	//        {
+	//            
+	//        }
+	//        
+	//        
+	//        int year = date[0], month = date[1], day = date[2], 
+	//            hour = date[3], minute = date[4], second = date[5]; 
+	//        // Issue: what to do with the time zone?
+	//        
+	//        Calendar calendar = Calendar.getInstance();
+	//        calendar.set(year, month, day, hour, minute, second);
+	//        return calendar.getTime();
+
+	//    private ValidityTime parseValidityTime(Element ele)
+	//        throws DomainSpecException
+	//    {
+	//        if(! ele.getTagName().equals(VALIDITY_TIME))
+	//            throw new DomainSpecException("Not a ValidityTime element");
+	//        
+	//        Element[] elements = getChildElements(ele);
+	//        if(elements.length != 3)
+	//            throw new DomainSpecException(
+	//                improper_sub_element_for + "'ValidityTime'");
+	//                
+	//        String issueAt = getFirstChildElementByTagName(ele, ISSUE_AT).getNodeValue();
+	//        String validFrom = getFirstChildElementByTagName(ele, VALID_FROM).getNodeValue();
+	//        String validTo = getFirstChildElementByTagName(ele, VALID_TO).getNodeValue();
+	//        
+	//        return new ValidityTime(RTUtil.parseDateTime(issueAt),
+	//                                RTUtil.parseDateTime(validFrom),
+	//                                RTUtil.parseDateTime(validTo));
+	//    }
+
+} // End of Class RTParser.
Index: fedd/abac-src/rtml/src/edu/stanford/rt/parser/TagNameConstants.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/parser/TagNameConstants.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/parser/TagNameConstants.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,118 @@
+package edu.stanford.rt.parser;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * This interface defines all the XML element tag names and 
+ * attribute names in RTML.
+ */
+public interface TagNameConstants
+{
+	public static final String CREDENTIAL_STORE = "CredentialStore";
+    public static final String APP_DOMAIN_SPEC = 
+    	"ApplicationDomainSpecification";
+    public static final String CREDENTIAL = "Credential";
+    public static final String ACCESS_RULE = "AccessRule";
+	public static final String PRINCIPAL_INFO = "PrincipalInfo";
+
+    public static final String IMPORT_DOMAIN = "ImportDomain";
+
+    public static final String INTEGER_TYPE = "IntegerType";
+    public static final String DECIMAL_TYPE = "DecimalType";
+    public static final String ENUM_TYPE = "EnumType";
+    public static final String STRING_TYPE = "StringType";
+    public static final String RECORD_TYPE = "RecordType";
+    public static final String TREE_TYPE = "TreeType";
+    public static final String PRINCIPAL_TYPE = "PrincipalType";
+
+    public static final String INTEGER_VALUE = "IntegerValue";
+    public static final String DECIMAL_VALUE = "DecimalValue";
+    public static final String STRING_VALUE = "StringValue";
+    public static final String ENUM_VALUE = "EnumValue";
+    public static final String TIME_VALUE = "TimeValue";
+    public static final String TREE_VALUE = "TreeValue";
+    public static final String RECORD = "Record";
+    public static final String KEY_HASH = "KeyHash";
+    public static final String KEY_VALUE = "ds:KeyValue";
+    public static final String DSA_KEY_VALUE = "ds:DSAKeyValue";
+    public static final String RSA_KEY_VALUE = "ds:RSAKeyValue";
+
+    public static final String ROLE_DECLARATION = "RoleDeclaration";
+    public static final String PARAMETER = "Parameter";
+    public static final String FIELD = "Field";
+    public static final String ISSUER_TRACES = "issuerTraces";
+    public static final String SUBJECT_TRACES = "subjectTraces";
+    public static final String TYPE = "Type";
+    public static final String SIZE = "size";
+    public static final String IS_IDENTITY = "isIdentity";
+    public static final String RESTRICTION = "Restriction";
+    public static final String EXTENSION = "Extension";
+    public static final String PROJECTION = "Projection";
+	public static final String PLAIN = "Plain";
+    public static final String IDENTITY= "Identity";
+    public static final String BASE_ROLE = "BaseRole";
+    
+	public static final String DIMENSION = "dimension";
+    public static final String URI = "uri";
+    public static final String NAME = "name";
+    public static final String ID = "id";
+    public static final String IDREF = "idref";
+    public static final String DOMAIN = "domain";
+
+    public static final String MIN = "min";
+    public static final String MAX = "max";
+    public static final String BASE = "base";
+    public static final String STEP = "step";
+    public static final String INCLUDE_MIN = "includeMin";
+    public static final String INCLUDE_MAX = "includeMax";
+
+    public static final String SEPARATOR = "separator";
+    public static final String ORDER = "order";
+    public static final String INCLUDE_CURRENT = "includeCurrent";
+    public static final String INCLUDE_CHILDREN = "includeChildren";
+    public static final String INCLUDE_DESCENDENTS = "includeDescendents";
+    public static final String ROOT_FIRST = "rootFirst";
+    public static final String ROOT_LAST = "rootLast";
+
+    public static final String IGNORE_CASE = "ignoreCase";
+    public static final String ORDERED = "ordered";
+    public static final String FROM = "from";
+    public static final String TO = "to";
+
+
+    public static final String ISSUER = "Issuer";
+    public static final String PREAMBLE = "Preamble";
+    public static final String ROLE_TERM = "RoleTerm";
+    public static final String HEAD_ROLE_TERM = "HeadRoleTerm";
+    public static final String PRINCIPAL = "Principal";
+    public static final String PRINCIPAL_REF = "PrincipalRef";
+    public static final String REF = "ref";
+    public static final String SHORT_NAME = "shortName";
+    public static final String EXTERNAL_ROLE = "ExternalRole";
+    public static final String LINKED_ROLE = "LinkedRole";
+    public static final String INTERSECTION = "Intersection";
+    public static final String INTERVAL = "Interval";
+    public static final String SET = "Set";
+    public static final String SPECIAL_PRINCIPAL = "SpecialPrincipal";
+    public static final String EQUALS = "Equals";
+
+    public static final String CREDENTIAL_IDENTIFIER = "CredentialIdentifier";
+    public static final String RULE_IDENTIFIER = "RuleIdentifier";
+    public static final String VALIDITY_TIME = "ValidityTime";
+    public static final String ISSUE_AT = "IssueAt";
+    public static final String VALID_FROM = "ValidFrom";
+    public static final String VALID_TO = "ValidTo";
+    public static final String VALIDITY_RULE = "ValidityRule";
+    public static final String SIMPLE_MEMBER = "SimpleMember";
+    public static final String SIMPLE_CONTAINMENT = "SimpleContainment";
+    public static final String LINKED_CONTAINMENT= "LinkedContainment";
+    public static final String INTERSECTION_CONTAINMENT= "IntersectionContainment";
+    public static final String PRODUCT_CONTAINMENT= "ProductContainment";
+    public static final String EXCLUSIVE_PRODUCT_CONTAINMENT= "ExclusiveProductContainment";
+    public static final String SIMPLE_DELEGATION= "SimpleDelegation";
+    public static final String ADVANCED_DELEGATION= "AdvancedDelegation";
+    public static final String PRODUCT = "Product";
+    public static final String EXCLUSIVE_PRODUCT = "ExclusiveProduct";
+    public static final String DELEGATE_TO = "DelegateTo";
+    public static final String CONTROL = "Control";
+
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/util/CVS/Entries
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/util/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/util/CVS/Entries	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,3 @@
+/Constants.java/1.1.1.1/Fri Nov 22 17:37:54 2002//
+/RTUtil.java/1.2/Wed Jul 16 17:56:02 2003//
+D
Index: fedd/abac-src/rtml/src/edu/stanford/rt/util/CVS/Repository
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/util/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/util/CVS/Repository	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+rtml/src/edu/stanford/rt/util
Index: fedd/abac-src/rtml/src/edu/stanford/rt/util/CVS/Root
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/util/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/util/CVS/Root	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,1 @@
+:ext:jjacobs@src.columbia.sparta.com/cvs/abac
Index: fedd/abac-src/rtml/src/edu/stanford/rt/util/Constants.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/util/Constants.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/util/Constants.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,33 @@
+package edu.stanford.rt.util;
+
+/**
+ * @author Ninghui Li, Sandra Qiu <br>
+ * 
+ * This interface defines non-XML constants.
+ */
+public interface Constants
+{
+    /* traces type related */
+    public static final int ISSUER_TRACES_ALL = 0;
+    public static final int ISSUER_TRACES_DEF = 1;
+    public static final int ISSUER_TRACES_RULE = 2;
+    public static final int ISSUER_TRACES_NONE = 3;
+    public static final int SUBJECT_TRACES_ALL = 4;
+    public static final int SUBJECT_TRACES_FACT = 5;
+    public static final int SUBJECT_TRACES_NONE = 6;
+    
+
+    //other
+    public static final String COLON = ":";
+    public static final String INDENT = "    ";
+
+    // Exception msg
+    public static final String missing_attr_value = 
+        "No value specified for the required attribute ";
+    public static final String improper_sub_element_for = 
+        "Improper sub-element for element ";
+    public static final String illegal_value_for = 
+    	"Illegal value for ";
+    public static final String no_support_for = 
+    	"No support for element ";
+}
Index: fedd/abac-src/rtml/src/edu/stanford/rt/util/RTUtil.java
===================================================================
--- fedd/abac-src/rtml/src/edu/stanford/rt/util/RTUtil.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
+++ fedd/abac-src/rtml/src/edu/stanford/rt/util/RTUtil.java	(revision 8780cbecc6db2bdc2b9ef31eec6e5209ad3bff15)
@@ -0,0 +1,234 @@
+package edu.stanford.rt.util;
+
+import java.io.*;
+import java.util.*;
+
+//import org.apache.xerces.validators.datatype.*;
+
+import edu.stanford.rt.credential.*;
+
+/**
+ * @author Ninghui Li, Sandra Qiu<br>
+ * 
+ * Utility class
+ * 
+ */
+public class RTUtil
+{
+	// print debug msg to specified outstream.
+	private static PrintStream out = System.out;
+
+	private static boolean DEBUG = false;
+
+	static public void setOutputStream(PrintStream out)
+	{
+		RTUtil.out = out;
+	}
+
+	/**
+	 * Method debugInfo.
+	 * @param s
+	 */
+	static public void debugInfo(String s)
+	{
+		if (DEBUG)
+			out.println(s);
+	}
+
+	/**
+	 * Method parseLong.
+	 *  parses the given attribute value as a long. If attrValue cannot
+	 *  be correctly parsed, then returns the given default value.
+	 * @param attrValue
+	 *  the string to be parsed.
+	 * @param defValue
+	 *  the default value
+	 * @return long
+	 */
+	static public long parseLong(String attrValue, long defValue)
+	{
+		if (attrValue.length() == 0)
+			return defValue;
+
+		long res;
+		try
+		{
+			res = Long.parseLong(attrValue);
+		}
+		catch (NumberFormatException e)
+		{
+			res = defValue;
+		}
+		return res;
+	}
+	/**
+	 * Method parseInt.
+	 *  parses the given attribute value as an integer. If the attrValue 
+	 *  cannot be correctly parsed, returns the given default value.
+	 * @param attrValue
+	 *  the string to be parsed.
+	 * @param defValue
+	 *  the default value.
+	 * @return int
+	 */
+	static public int parseInt(String attrValue, int defValue)
+	{
+		if (attrValue.length() == 0)
+			return defValue;
+
+		int res;
+		try
+		{
+			res = Integer.parseInt(attrValue);
+		}
+		catch (NumberFormatException e)
+		{
+			res = defValue;
+		}
+		return res;
+	}
+
+	/**
+	 * Method parseBoolean.
+	 *  parses the given attribute value as a boolean. 
+     * If attrValue is null or an empty string, return the 
+     * given default value.
+	 * @param attrValue
+	 *  the string to be parsed.
+	 * @param defValue
+	 *  the default value
+	 * @return boolean
+	 */
+	static public boolean parseBoolean(
+		String attrValue,
+		boolean defValue)
+	{
+		if (attrValue == null || attrValue.length() == 0)
+			return defValue;
+		return Boolean.valueOf(attrValue).booleanValue();
+	}
+
+//	static public boolean validYear(String year)
+//	{
+//		boolean validYear = true;
+//		try
+//		{
+//			int yr = Integer.parseInt(year);
+//			if (yr < 0 || yr > 9999)
+//				validYear = false;
+//		}
+//		catch (NumberFormatException e)
+//		{
+//			validYear = false;
+//		}
+//		return validYear;
+//	}
+//
+//	static public boolean isLeapYear(String year)
+//	{
+//		boolean isLeap = true;
+//
+//		try
+//		{
+//			int yr = Integer.parseInt(year);
+//			if (((yr % 4 == 0) && (yr % 100 != 0))
+//				|| (yr % 400 == 0))
+//				isLeap = true;
+//			else
+//				isLeap = false;
+//		}
+//		catch (NumberFormatException e)
+//		{
+//			isLeap = false;
+//		}
+//		return isLeap;
+//
+//	}
+//
+//	static public boolean validMonth(String month)
+//	{
+//		boolean validMonth = true;
+//		try
+//		{
+//			int mon = Integer.parseInt(month);
+//			if (mon < 1 || mon > 12)
+//				validMonth = false;
+//		}
+//		catch (NumberFormatException e)
+//		{
+//			validMonth = false;
+//		}
+//		return validMonth;
+//	}
+//
+//	static int[] legalDaysOfMonthInLeapYear =
+//		{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+//	static int[] legalDaysOfMonth =
+//		{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+//	static public boolean validDay(
+//		String year,
+//		String month,
+//		String day)
+//	{
+//		boolean validDay = true;
+//		if (!validYear(year))
+//			validDay = false;
+//		if (!validMonth(month))
+//			validDay = false;
+//
+//		try
+//		{
+//			int mon = Integer.parseInt(month);
+//			int dy = Integer.parseInt(day);
+//			if (dy < 0)
+//				validDay = false;
+//			if (isLeapYear(year))
+//			{
+//				if (dy > legalDaysOfMonthInLeapYear[mon])
+//					validDay = false;
+//			}
+//			else
+//			{
+//				if (dy > legalDaysOfMonth[mon])
+//					validDay = false;
+//			}
+//		}
+//		catch (NumberFormatException e)
+//		{
+//			validDay = false;
+//		}
+//		return validDay;
+//	}
+//
+//	static public boolean validHour(String hour)
+//	{
+//		boolean validHour = true;
+//		try
+//		{
+//			int hr = Integer.parseInt(hour);
+//			if (hr < 0 || hr > 23)
+//				validHour = false;
+//		}
+//		catch (NumberFormatException e)
+//		{
+//			validHour = false;
+//		}
+//		return validHour;
+//	}
+//
+//	static public boolean validMinSec(String ms)
+//	{
+//		boolean valid = true;
+//		try
+//		{
+//			int minSec = Integer.parseInt(ms);
+//			if (minSec < 0 || minSec > 59)
+//				valid = false;
+//		}
+//		catch (NumberFormatException e)
+//		{
+//			valid = false;
+//		}
+//		return valid;
+//	}
+}
