/* * =========================================================================== * Licensed Materials - Property of IBM * * (C) Copyright IBM Corp. 2000 All Rights Reserved. * * US Government Users Restricted Rights - Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * =========================================================================== * * File: HWPrincipal.java * * =========================================================================== * Code disclaimer information * This document contains programming examples. * * IBM grants you a nonexclusive copyright license to use all * programming code examples from which you can generate similar function * tailored to your own specific needs. * * All sample code is provided by IBM for illustrative purposes only. These * examples have not been thoroughly tested under all conditions. IBM, * therefore, cannot guarantee or imply reliability, serviceability, or * function of these programs. * * All programs contained herein are provided to you "AS IS" without any * warranties of any kind. The implied warranties of non-infringement, * merchantability and fitness for a particular purpose are expressly disclaimed. * =========================================================================== */ package com.ibm.security; import java.security.Principal; /** *

This class implements the Principal interface * and represents a HelloWorld tester. * * @version 1.1, 09/10/99 * @author D. Kent Soper */ public class HWPrincipal implements Principal, java.io.Serializable { private String name; /* * Create a HWPrincipal with the supplied name. */ public HWPrincipal(String name) { if (name == null) throw new NullPointerException("illegal null input"); this.name = name; } /* * Return the name for the HWPrincipal. */ public String getName() { return name; } /* * Return a string representation of the HWPrincipal. */ public String toString() { return("HWPrincipal: " + name); } /* * Compares the specified Object with the HWPrincipal for equality. * Returns true if the given object is also a HWPrincipal and the * two HWPrincipals have the same username. */ public boolean equals(Object o) { if (o == null) return false; if (this == o) return true; if (!(o instanceof HWPrincipal)) return false; HWPrincipal that = (HWPrincipal)o; if (this.getName().equals(that.getName())) return true; return false; } /* * Return a hash code for the HWPrincipal. */ public int hashCode() { return name.hashCode(); } }