package edu.stanford.rt.credential;
/**
* @author Ninghui Li, Sandra Qiu
*
* This class handles Principal
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
* PublicKeyPrincipalInfo
.
*/
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; }
}