001: /*
002: * This file is part of the WfMOpen project.
003: * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
004: * All rights reserved.
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * $Id: SimplePrincipal.java,v 1.2 2006/09/29 12:32:08 drmlipp Exp $
021: *
022: * $Log: SimplePrincipal.java,v $
023: * Revision 1.2 2006/09/29 12:32:08 drmlipp
024: * Consistently using WfMOpen as projct name now.
025: *
026: * Revision 1.1.1.2 2003/12/19 13:01:37 drmlipp
027: * Updated to 1.1rc1
028: *
029: * Revision 1.2 2003/09/03 15:22:34 lipp
030: * Improved toString.
031: *
032: * Revision 1.1 2003/08/25 20:23:33 lipp
033: * Fixed problem with weblogic principal.
034: *
035: */
036: package de.danet.an.util;
037:
038: import java.io.Serializable;
039:
040: import java.security.Principal;
041:
042: /**
043: * This class provides a very simple implementation of the interface
044: * <code>Principal</code>. The only known attribute is the principal's
045: * name.
046: *
047: * @author <a href="mailto:mnl@mnl.de">Michael N. Lipp</a>
048: * @version $Revision: 1.2 $
049: */
050:
051: public class SimplePrincipal implements Principal, Serializable {
052:
053: private String name;
054:
055: /**
056: * Creates an instance of <code>SimplePrincipal</code>
057: * with all attributes initialized to the given values.
058: * @param pn the principal's name.
059: */
060: public SimplePrincipal(String pn) {
061: name = pn;
062: }
063:
064: /**
065: * Simply return the name's hash code.
066: *
067: * @return an <code>int</code> value
068: */
069: public int hashCode() {
070: return name.hashCode();
071: }
072:
073: /**
074: * <code>SimplePrincipal</code> considers all principals with the
075: * same name as equal.
076: *
077: * @param object another principal.
078: * @return a <code>boolean</code> value
079: */
080: public boolean equals(Object object) {
081: return name.equals(((Principal) object).getName());
082: }
083:
084: /**
085: * Simply return the principal's name.
086: *
087: * @return a <code>String</code> value
088: */
089: public String toString() {
090: return "SimplePrinciple[name=" + name + "]";
091: }
092:
093: /**
094: * Returns the principal's name.
095: *
096: * @return a <code>String</code> value
097: */
098: public String getName() {
099: return name;
100: }
101: }
|